Commit 759d1131 authored by 540597360@qq.com's avatar 540597360@qq.com

首次使用ComponentOne C1Chart

parent eeeb97c2
C1.WPF.C1Chart.C1Chart, C1.WPF.C1Chart.4
C1.WPF.C1Chart.C1ChartLegend, C1.WPF.C1Chart.4
C1.WPF.C1Chart3D.C1Chart3D, C1.WPF.C1Chart3D.4
C1.WPF.C1Chart3D.C1Chart3DLegend, C1.WPF.C1Chart3D.4
C1.WPF.Extended.C1PropertyGrid, C1.WPF.Extended.4
C1.WPF.FlexGrid.C1FlexGrid, C1.WPF.FlexGrid.4
C1.WPF.C1NumericBox, C1.WPF.4
\ No newline at end of file
......@@ -41,9 +41,33 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="C1.Win.C1Chart.4, Version=4.0.20183.338, Culture=neutral, PublicKeyToken=a22e16972c085838, processorArchitecture=MSIL">
<Reference Include="C1.WPF.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.Win.C1Chart.4.dll</HintPath>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.4.dll</HintPath>
</Reference>
<Reference Include="C1.WPF.C1Chart.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.C1Chart.4.dll</HintPath>
</Reference>
<Reference Include="C1.WPF.C1Chart.Extended.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.C1Chart.Extended.4.dll</HintPath>
</Reference>
<Reference Include="C1.WPF.C1Chart3D.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.C1Chart3D.4.dll</HintPath>
</Reference>
<Reference Include="C1.WPF.DX.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.DX.4.dll</HintPath>
</Reference>
<Reference Include="C1.WPF.Extended.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.Extended.4.dll</HintPath>
</Reference>
<Reference Include="C1.WPF.FlexGrid.4, Version=4.0.20183.611, Culture=neutral, PublicKeyToken=2aa4ec5576d6c3ce, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v4\C1.WPF.FlexGrid.4.dll</HintPath>
</Reference>
<Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
......@@ -143,6 +167,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
......
C1.WPF.C1Chart.C1Chart, C1.WPF.C1Chart.4
C1.WPF.C1Chart.C1ChartLegend, C1.WPF.C1Chart.4
C1.WPF.C1Chart3D.C1Chart3D, C1.WPF.C1Chart3D.4
C1.WPF.C1Chart3D.C1Chart3DLegend, C1.WPF.C1Chart3D.4
C1.WPF.Extended.C1PropertyGrid, C1.WPF.Extended.4
C1.WPF.FlexGrid.C1FlexGrid, C1.WPF.FlexGrid.4
C1.WPF.C1NumericBox, C1.WPF.4
\ No newline at end of file
......@@ -28,7 +28,7 @@ namespace FLY.HeatingHelper.UI.UIModule
{
InitializeComponent();
_dat = DataManager.GetThickDataInstance();
_dat.SetDB("airring.sqlite3");
_dat.SetDB(@"D:\blowingdata\airring.sqlite3");
this.DataContext = _dat;
}
......
......@@ -183,7 +183,7 @@ namespace FLY.HeatingHelper.UI.UIModule
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
await Task.Delay(100);
await Task.Delay(200);
Default_cb_Click(this, null);
}
......
......@@ -7,7 +7,18 @@
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
<UserControl.Resources>
<local:LockFramesConverter x:Key="lfc"/>
</UserControl.Resources>
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14"/>
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="12"/>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
......@@ -47,8 +58,20 @@
<DockPanel.Resources>
<Style x:Key="tb_style" TargetType="TextBlock">
<Setter Property="Background" Value="AntiqueWhite"/>
<Setter Property="FontSize" Value="16"/>
</Style>
</DockPanel.Resources>
<Grid DockPanel.Dock="Top" Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="锁定设置:"/>
<RadioButton Content="锁定1幅" Grid.Column="1" IsChecked="{Binding LockFrames,Converter={StaticResource lfc},ConverterParameter=1}"/>
<RadioButton Content="锁定2幅" Grid.Column="2" IsChecked="{Binding LockFrames,Converter={StaticResource lfc},ConverterParameter=2}"/>
</Grid>
<Grid DockPanel.Dock="Top">
<ProgressBar Value="{Binding SearchProgressValue}" Width="{Binding ElementName=searchBtn, Path=ActualWidth}"/>
<Button Content="搜索最大相关度" Click="AutoSearch_Shift" x:Name="searchBtn"
......
......@@ -17,6 +17,7 @@ using System.Windows.Shapes;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using LiveCharts.Wpf;
using System.Globalization;
namespace FLY.HeatingHelper.UI.UIModule
{
......@@ -94,6 +95,8 @@ namespace FLY.HeatingHelper.UI.UIModule
public UC_FramePickerViewModel vm1 = new UC_FramePickerViewModel();
public UC_FramePickerViewModel vm2 = new UC_FramePickerViewModel();
public int LockFrames { get; set; } = 1;
public int SearchProgressValue { get; set; } = 0;
public bool SearchEnabled { get; set; } = true;
......@@ -118,7 +121,7 @@ namespace FLY.HeatingHelper.UI.UIModule
_airRingShift = value;
while (_airRingShift < 0) _airRingShift += cnt;
while (_airRingShift >= cnt) _airRingShift -= cnt;
int rb = resetBolt1 + _airRingShift;
int rb = _airRingShift + resetBolt1;
while (rb < 0) rb += cnt;
while (rb >= cnt) rb -= cnt;
ResetBolt = rb;
......@@ -177,6 +180,9 @@ namespace FLY.HeatingHelper.UI.UIModule
{
var tmpVM = ViewModel_HeatDetector.Instance;
tmpVM.PropertyChanged += DataSelecter_PropertyChanged;
vm2.SelectedFrame = vm2.MaxFrame;
vm1.UpdateChart();
vm2.UpdateChart();
}
public void UnLoaded(object s)
......@@ -237,13 +243,14 @@ namespace FLY.HeatingHelper.UI.UIModule
switch (whichframe)
{
case 1:
vth1 = _data.GetThicks(vm1.SelectedFrame, int.MaxValue, RotAngle);
vth1 = _data.GetThicks(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vheat1 = _data.GetHeats(vm1.SelectedFrame, -1, -1);
resetBolt1 = _data.GetResetBolt(vm1.SelectedFrame);
rotAngle1 = _data.GetRotAngle(vm1.SelectedFrame);
break;
case 2:
vth2 = _data.GetThicks(vm2.SelectedFrame, int.MaxValue, RotAngle);
vth2 = _data.GetThicks(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
vth1 = _data.GetThicks(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vheat2 = _data.GetHeats(vm2.SelectedFrame, -1, -1);
resetBolt2 = _data.GetResetBolt(vm2.SelectedFrame);
rotAngle2 = _data.GetRotAngle(vm2.SelectedFrame);
......@@ -265,8 +272,8 @@ namespace FLY.HeatingHelper.UI.UIModule
/// <returns></returns>
private bool UpdateThickData()
{
vth1 = _data.GetThicks(vm1.SelectedFrame, int.MaxValue, RotAngle);
vth2 = _data.GetThicks(vm2.SelectedFrame, int.MaxValue, RotAngle);
vth1 = _data.GetThicks(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vth2 = _data.GetThicks(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
if ((vth1 == null) || (vth2 == null) || (vheat1 == null) || (vheat2 == null))
{
return false;
......@@ -302,14 +309,14 @@ namespace FLY.HeatingHelper.UI.UIModule
}
else
{
//s = ResetBolt - resetBolt1;
s = resetBolt1 - ResetBolt;
s = ResetBolt - resetBolt1;
//s = resetBolt1 + ResetBolt;
}
int cnt = vth1.Count();
while (s >= cnt) s -= cnt;
while (s < 0) s += cnt;
var vth = DataHelper.VectorSub(vth1, vth2);
var tmp = vth.Concat(vth).Skip(s).Take(cnt);
var tmp = vth.Concat(vth).Skip(cnt-s).Take(cnt);
var vheat = DataHelper.VectorSub(vheat2, vheat1);
......@@ -352,7 +359,7 @@ namespace FLY.HeatingHelper.UI.UIModule
if(s == int.MaxValue)
{
AirRingShift = 0;
ResetBolt = _data.GetResetBolt(vm1.SelectedFrame);
//ResetBolt = _data.GetResetBolt(vm1.SelectedFrame);
return;
}
else
......@@ -383,29 +390,35 @@ namespace FLY.HeatingHelper.UI.UIModule
{
SearchEnabled = false;
MaxSimilarityResult result = new MaxSimilarityResult();
_data.StartSearchMaxSimilarity(vm1.MinFrame, vm1.MaxFrame, int.MaxValue, 10, result,
(o, e) =>
{
SearchProgressValue = e.ProgressPercentage;
},
(o, e) =>
{
int rb = _data.GetResetBolt(result.frameIdx1);
double ra = _data.GetRotAngle(result.frameIdx1);
SearchProgressValue = 0;
SearchEnabled = true;
vm1.SelectedFrame = result.frameIdx1;
vm2.SelectedFrame = result.frameIdx2;
AirRingShift = result.frameShift;
TandH_Corel = result.similarity;
rb += AirRingShift;
while (rb >= _data.BoltCnt) rb -= _data.BoltCnt;
while (rb < 0) rb += _data.BoltCnt;
ResetBolt = rb;
RotAngle = ra + result.deltaAngle;
}, int.MaxValue, 15, true, true);
int searchCnt = int.MaxValue;
int start = vm1.MinFrame;
int end = vm1.MaxFrame;
if (LockFrames == 1)
{
searchCnt = 1;
end = vm2.SelectedFrame;
}
_data.StartSearchMaxSimilarity(start, end, searchCnt, 5, result,
(o, e) =>
{
SearchProgressValue = e.ProgressPercentage;
},
(o, e) =>
{
int rb = _data.GetResetBolt(result.frameIdx2);
double ra = _data.GetRotAngle(result.frameIdx2);
SearchProgressValue = 0;
SearchEnabled = true;
vm2.SelectedFrame = result.frameIdx1;
vm1.SelectedFrame = result.frameIdx2;
AirRingShift = result.frameShift;
TandH_Corel = result.similarity;
rb += AirRingShift;
while (rb >= _data.BoltCnt) rb -= _data.BoltCnt;
while (rb < 0) rb += _data.BoltCnt;
ResetBolt = rb;
RotAngle = ra + result.deltaAngle;
}, int.MaxValue, 15, true, true);
}
public double[] ExpandOrShrinkData(double[] ori, int orideg, int dstdeg)
......@@ -476,4 +489,28 @@ namespace FLY.HeatingHelper.UI.UIModule
public event PropertyChangedEventHandler PropertyChanged;
}
public class LockFramesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int locks = (int)value;
string n = parameter.ToString();
switch (n)
{
case "0":
return locks == 0;
case "1":
return locks == 1;
case "2":
return locks == 2;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return int.Parse(parameter.ToString());
}
}
}
......@@ -5,37 +5,72 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UIModule"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:c1c="clr-namespace:C1.Win.C1Chart;assembly=C1.Win.C1Chart.4"
xmlns:c1c="clr-namespace:C1.WPF.C1Chart;assembly=C1.WPF.C1Chart.4"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="600">
<UserControl.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="12"/>
</Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Margin" Value="0,0,5,0"/>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="#4C000F14" Opacity="0.7"/>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type c1c:C1Chart}">
<Setter Property="Foreground" Value="#FFF0F8FE" />
<Setter Property="Background" Value="#4C000F14" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0 10" />
<Setter Property="FontSize" Value="12"/>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<lvc:CartesianChart Grid.Row="0" x:Name="myChart" Series="{Binding MySeries}"
DisableAnimations="True"
Hoverable="False"
DataTooltip="{x:Null}"
LegendLocation="Top"
FontSize="20"
Margin="2,2,2,2">
<lvc:CartesianChart.AxisY>
<lvc:Axis Foreground="DodgerBlue" Title="厚度">
</lvc:Axis>
<lvc:Axis x:Name="yax2" Foreground="IndianRed" Position="RightTop" Title="加热">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
<Border Grid.Row="0">
<c1c:C1Chart x:Name="myChart" ChartType="Line" Margin="5,0,0,0">
<c1c:C1Chart.Data>
<c1c:ChartData>
<c1c:DataSeries Values="{Binding DS_thick}" AxisY="ay0" Label="厚度"/>
<c1c:DataSeries Values="{Binding DS_heat}" AxisY="ay1" Label="加热率"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
<c1c:ChartView>
<c1c:ChartView.AxisY>
<c1c:Axis Visible="False"/>
</c1c:ChartView.AxisY>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"/>
<c1c:Axis Name="ay1" AxisType="Y" Title="加热率" Position="Far"/>
</c1c:ChartView>
</c1c:C1Chart.View>
<c1c:Legend Position="Right" />
</c1c:C1Chart>
</Border>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="{Binding ResetBolt, StringFormat=复位分区:{0}}"/>
<TextBlock Text="{Binding RotAngle, StringFormat=旋转角度:{0:f1}}"/>
<TextBlock Text="{Binding SelectedFrame}"/>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}/({1})-({2})">
<Binding Path="SelectedFrame" />
<Binding Path="MinFrame"/>
<Binding Path="MaxFrame"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<!--<TextBlock Text="{Binding SelectedFrame}"/>
<TextBlock Text="{Binding MinFrame,StringFormat=/(\{0\})-}"/>
<TextBlock Text="{Binding MaxFrame,StringFormat=(\{0\})}"/>
<TextBlock Text="{Binding MaxFrame,StringFormat=(\{0\})}"/>-->
<Button Content="前一幅" Margin="3" Command="{Binding PreCmd}"/>
<Button Content="后一幅" Margin="3" Command="{Binding NxtCmd}"/>
</StackPanel>
......
......@@ -16,6 +16,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using C1.WPF.C1Chart;
namespace FLY.HeatingHelper.UI.UIModule
{
......@@ -82,6 +83,7 @@ namespace FLY.HeatingHelper.UI.UIModule
public UC_FramePicker()
{
InitializeComponent();
//myChart.Data.Children
}
}
......@@ -164,7 +166,6 @@ namespace FLY.HeatingHelper.UI.UIModule
if (_resetBolt != value)
{
_resetBolt = value;
UpdateChart();
}
}
}
......@@ -177,10 +178,9 @@ namespace FLY.HeatingHelper.UI.UIModule
}
set
{
if (Math.Abs(_rotAngle - value) >= 0.00099)
if ((Math.Abs(_rotAngle - value) >= 0.00099) || double.IsNaN(_rotAngle))
{
_rotAngle = value;
UpdateChart();
}
}
}
......@@ -188,7 +188,7 @@ namespace FLY.HeatingHelper.UI.UIModule
public RelayCommand PreCmd { get; internal set; }
public RelayCommand NxtCmd { get; internal set; }
public SeriesCollection MySeries { get; set; } = new SeriesCollection();
public ChartData myData { get; set; } = new ChartData();
/// <summary>
/// 初始化数据
......@@ -215,42 +215,48 @@ namespace FLY.HeatingHelper.UI.UIModule
}
}
private ChartValues<double> v1 = new ChartValues<double>();
private ChartValues<double> v2 = new ChartValues<double>();
//private ChartValues<double> v1 = new ChartValues<double>();
//private ChartValues<double> v2 = new ChartValues<double>();
private void UpdateChart()
public DoubleCollection DS_thick { get; set; }
public DoubleCollection DS_heat { get; set; }
public void UpdateChart()
{
if (MySeries.Count == 0)
{
var L1 = new LineSeries
{
Title = "厚度",
Values = v1,
DataLabels = false,
Fill = new SolidColorBrush(Colors.Transparent),
PointGeometrySize = 3,
ScalesYAt = 0,
};
var L2 = new LineSeries
{
Title = "加热率",
Values = v2,
DataLabels = false,
Fill = new SolidColorBrush(Colors.Transparent),
PointGeometrySize = 3,
ScalesYAt = 1,
};
MySeries.Add(L1);
MySeries.Add(L2);
}
v1.Clear(); v1.AddRange(_data.GetThicks(SelectedFrame, ResetBolt, RotAngle));
v2.Clear(); v2.AddRange(_data.GetHeats(SelectedFrame, -1, -1));
DS_thick = new DoubleCollection(_data.GetThicks(SelectedFrame, ResetBolt, RotAngle));
DS_heat = new DoubleCollection(_data.GetHeats(SelectedFrame, -1, -1));
//if (MySeries.Count == 0)
//{
// var L1 = new LineSeries
// {
// Title = "厚度",
// Values = v1,
// DataLabels = false,
// Fill = new SolidColorBrush(Colors.Transparent),
// PointGeometrySize = 3,
// ScalesYAt = 0,
// };
// var L2 = new LineSeries
// {
// Title = "加热率",
// Values = v2,
// DataLabels = false,
// Fill = new SolidColorBrush(Colors.Transparent),
// PointGeometrySize = 3,
// ScalesYAt = 1,
// };
// MySeries.Add(L1);
// MySeries.Add(L2);
//}
//v1.Clear(); v1.AddRange(_data.GetThicks(SelectedFrame, ResetBolt, RotAngle));
//v2.Clear(); v2.AddRange(_data.GetHeats(SelectedFrame, -1, -1));
}
private void UpdateData()
{
_resetBolt = _data.GetResetBolt(SelectedFrame);
_rotAngle = _data.GetRotAngle(SelectedFrame);
ResetBolt = _data.GetResetBolt(SelectedFrame);
RotAngle = _data.GetRotAngle(SelectedFrame);
UpdateChart();
}
......
......@@ -87,6 +87,8 @@ namespace FLY.HeatingHelper.UI.UIModule
vm1.InitData(mdata, tmpVM.Selected_Idx_From, tmpVM.Selected_Idx_To);
vm2.InitData(mdata, tmpVM.Selected_Idx_From, tmpVM.Selected_Idx_To);
vmDiff.Init(mdata);
vm1.UpdateChart();
vm2.UpdateChart();
}
public void UnLoaded(object s)
......
......@@ -17,7 +17,7 @@ namespace FLY.HeatingHelper
{
bool IsDataReady { get; }
bool BeginUse();
bool BeginUse(bool isAsync = true);
void EndUse();
/// <summary>
......
......@@ -104,12 +104,16 @@ namespace FLY.HeatingHelper
_ids.Clear();
foreach (DataRow dr in dataTable.Rows)
{
_ids.Add((int)dr.Field<long>("ID"));
_dat_times.Add(dr.Field<DateTime>("EndTime"));
string th_dat = dr.Field<string>("Thicks");
string heat_dat = dr.Field<string>("Heats");
var t1 = Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(th_dat);
var h1 = Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(heat_dat);
if (_heats.Count() > 0)
{
if (IsHeatSame(h1, _heats.Last())) DeleteDataLast();
}
_ids.Add((int)dr.Field<long>("ID"));
_dat_times.Add(dr.Field<DateTime>("EndTime"));
_thicks.Add(t1);
_heats.Add(h1);
var t2 = RemoveNaN(t1);
......@@ -136,14 +140,18 @@ namespace FLY.HeatingHelper
{
var id = (int)dr.Field<long>("ID");
if (lastID >= id) continue;
_ids.Add(id);
_dat_times.Add(dr.Field<DateTime>("EndTime"));
string th_dat = dr.Field<string>("Thicks");
string heat_dat = dr.Field<string>("Heats");
var t1 = Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(th_dat);
var h1 = Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(heat_dat);
if(_heats.Count()>0)
{
if (IsHeatSame(h1, _heats.Last())) DeleteDataLast();
}
_ids.Add(id);
_thicks.Add(t1);
_heats.Add(h1);
_dat_times.Add(dr.Field<DateTime>("EndTime"));
var t2 = RemoveNaN(t1);
var r = MathNet.Numerics.Statistics.Statistics.MeanStandardDeviation(t2);
_thick_means.Add(r.Item1);
......@@ -157,6 +165,36 @@ namespace FLY.HeatingHelper
return cnt;
}
/// <summary>
/// 判断两个加热是否相同
/// </summary>
/// <param name="h1"></param>
/// <param name="h2"></param>
/// <returns></returns>
private bool IsHeatSame(double[] h1, double[] h2)
{
int cnt = h1.Count();
if (h2.Count() != cnt) return false;
for (int i = 0; i < cnt; i++)
{
if (Math.Abs(h1[i] - h2[i]) > 0.1) return false;
}
return true;
}
private void DeleteDataLast()
{
int idx = _ids.Count() - 1;
_ids.RemoveAt(idx);
_dat_times.RemoveAt(idx);
_thicks.RemoveAt(idx);
_thick_2sigmas.RemoveAt(idx);
_thick_means.RemoveAt(idx);
_heats.RemoveAt(idx);
_resetBolts.RemoveAt(idx);
_rotAngles.RemoveAt(idx);
}
private DataTable dataTable = new DataTable();
#endregion
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment