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