Commit 3a906c73 authored by 540597360@qq.com's avatar 540597360@qq.com

改风环偏转为复位分区号,优化界面,增加Boltmap的处理(未调试)

parent 95a8e74e
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace FLY.HeatingHelper.UI.Converter
{
public class StateToMessage : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
StateCode s = (StateCode)value;
switch (s)
{
case StateCode.STC_IDLE:
return "等待新数据";
case StateCode.STC_NODAT:
return "没有数据";
case StateCode.STC_READING:
return "正在读取数据...";
case StateCode.STC_UPDATING:
return "正在检查新数据...";
}
return "未知状态";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
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());
}
}
}
......@@ -103,6 +103,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Converter\ValueConverters.cs" />
<Compile Include="UiModule\HeatThickDetector\HeatThickDetector.xaml.cs">
<DependentUpon>HeatThickDetector.xaml</DependentUpon>
</Compile>
......
......@@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI.UiModule"
xmlns:cvter="clr-namespace:FLY.HeatingHelper.UI.Converter"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Page.Resources>
......@@ -13,7 +14,7 @@
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Converter/Dictionary_MyConv.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:StateToMessage x:Key="StateToMessage"/>
<cvter:StateToMessage x:Key="StateToMessage"/>
<Style TargetType="{x:Type Path}" x:Key="PathStyle_icon">
<Setter Property="Fill" Value="White"/>
......@@ -34,8 +35,14 @@
<TextBlock Text="{Binding Path=Dat.State,Converter={StaticResource StateToMessage}}" HorizontalAlignment="Center" FontFamily="YouYuan" FontSize="25" Margin="0,10,0,3"/>
<StackPanel Grid.Row="1" Background="#FF119EDA" Margin="5">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="风环偏转" FontFamily="YouYuan" FontSize="25" Margin="0,3,0,3"/>
<TextBlock Text="{Binding Path=Dat.AirRingShift}" Background="AliceBlue" FontFamily="YouYuan" Margin="15,3,0,3" FontSize="25"/>
<TextBlock FontFamily="YouYuan" Margin="15,3,0,3" FontSize="25">
<TextBlock.Text>
<MultiBinding StringFormat="复位分区:{0}({1})">
<Binding Path="NewResetBolt" />
<Binding Path="CurrentResetBolt"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</StackPanel>
<!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
......
......@@ -37,7 +37,7 @@ namespace FLY.HeatingHelper.UI.UiModule
public void Init(IUnityContainer container,IThickHeatData dat)
{
this.container = container;
vm = new ViewModel_HeatThickDetector(dat);
vm = new ViewModel_HeatThickDetector(container.Resolve<FLY.Thick.Blowing.IService.IBlowingService>(), dat);
this.DataContext = vm;
}
......@@ -86,29 +86,4 @@ namespace FLY.HeatingHelper.UI.UiModule
}
#endregion
}
public class StateToMessage : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
StateCode s = (StateCode)value;
switch (s)
{
case StateCode.STC_IDLE:
return "等待新数据";
case StateCode.STC_NODAT:
return "没有数据";
case StateCode.STC_READING:
return "正在读取数据...";
case StateCode.STC_UPDATING:
return "正在检查新数据...";
}
return "未知状态";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
......@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
namespace FLY.HeatingHelper.UI.UiModule
{
......@@ -21,9 +22,13 @@ namespace FLY.HeatingHelper.UI.UiModule
_dat = value;
}
}
public ViewModel_HeatThickDetector(IThickHeatData dat)
public ViewModel_HeatThickDetector(FLY.Thick.Blowing.IService.IBlowingService blowing, IThickHeatData dat)
{
_dat = dat;
Misc.BindingOperations.SetBinding(blowing, "OrgBoltNo", this, "CurrentResetBolt");
NewResetBolt = CurrentResetBolt;
}
public bool HasData
......@@ -36,6 +41,9 @@ namespace FLY.HeatingHelper.UI.UiModule
}
}
public int NewResetBolt { get; set; }
public int CurrentResetBolt { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -108,6 +108,8 @@ namespace FLY.HeatingHelper.UI.UiModule
{
blowing = blowingService;
bDetect = blowingDetectService;
Misc.BindingOperations.SetBinding(blowing, "OrgBoltNo", this, "CurrentResetBolt");
}
FLY.Thick.Blowing.IService.IBlowingService blowing;
......@@ -133,28 +135,30 @@ namespace FLY.HeatingHelper.UI.UiModule
private IThickHeatData _data;
private int _airRingShift = 0;
public int AirRingShift
private int _NewResetBolt = 0;
public int NewResetBolt
{
get
{
return _airRingShift;
return _NewResetBolt;
}
internal set
{
if (_airRingShift != value)
if (_NewResetBolt != value)
{
int cnt = vth1.Count();
if (cnt > 0)
{
_airRingShift = value;
while (_airRingShift < 0) _airRingShift += cnt;
while (_airRingShift >= cnt) _airRingShift -= cnt;
int rb = _airRingShift + resetBolt1;
while (rb < 0) rb += cnt;
while (rb >= cnt) rb -= cnt;
ResetBolt = rb;
TandH_Corel = correls[_airRingShift];
while (value < 1) value += cnt;
while (value > cnt) value -= cnt;
_NewResetBolt = value;
//while (_airRingShift < 0) _airRingShift += cnt;
//while (_airRingShift >= cnt) _airRingShift -= cnt;
//int rb = _airRingShift + resetBolt1;
//while (rb < 0) rb += cnt;
//while (rb >= cnt) rb -= cnt;
//ResetBolt = rb;
TandH_Corel = correls[_NewResetBolt - 1];
}
}
}
......@@ -197,6 +201,7 @@ namespace FLY.HeatingHelper.UI.UiModule
public void Init(object dat)
{
_data = dat as IThickHeatData;
//var tmpVM = ViewModel_HeatDetector.Instance;
//vm1.InitData(dat, tmpVM.Selected_Idx_From, tmpVM.Selected_Idx_To);
//vm2.InitData(dat, tmpVM.Selected_Idx_From, tmpVM.Selected_Idx_To);
......@@ -211,6 +216,7 @@ namespace FLY.HeatingHelper.UI.UiModule
//CurrentAngle = bDetect.Angle;
CurrentAngle = bDetect.RAngle;
CurrentResetBolt = blowing.OrgBoltNo;
RotAngle = CurrentAngle;
vm1.OnLoaded(true);
vm2.OnLoaded();
......@@ -263,14 +269,13 @@ namespace FLY.HeatingHelper.UI.UiModule
switch (whichframe)
{
case 1:
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, 1, RotAngle);
vheat1 = _data.GetHeatsByIndex(vm1.SelectedFrame, -1, -1);
resetBolt1 = _data.GetResetBoltByIndex(vm1.SelectedFrame);
rotAngle1 = _data.GetRotAngleByIndex(vm1.SelectedFrame);
break;
case 2:
vth2 = _data.GetThicksByIndex(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vth2 = _data.GetThicksByIndex(vm2.SelectedFrame, 1, RotAngle);
vheat2 = _data.GetHeatsByIndex(vm2.SelectedFrame, -1, -1);
resetBolt2 = _data.GetResetBoltByIndex(vm2.SelectedFrame);
rotAngle2 = _data.GetRotAngleByIndex(vm2.SelectedFrame);
......@@ -292,8 +297,8 @@ namespace FLY.HeatingHelper.UI.UiModule
/// <returns></returns>
private bool UpdateThickData()
{
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vth2 = _data.GetThicksByIndex(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, 1, RotAngle);
vth2 = _data.GetThicksByIndex(vm2.SelectedFrame, 1, RotAngle);
if ((vth1 == null) || (vth2 == null) || (vheat1 == null) || (vheat2 == null))
{
return false;
......@@ -322,19 +327,19 @@ namespace FLY.HeatingHelper.UI.UiModule
//int s = AirRingShift % cnt;
//var tmp = vth.Concat(vth).Skip(s).Take(cnt);
int s;
if (ResetBolt == int.MaxValue)
{
s = 0;
}
else
{
s = ResetBolt - resetBolt1;
//s = resetBolt1 + ResetBolt;
}
int cnt = vth1.Count();
while (s >= cnt) s -= cnt;
while (s < 0) s += cnt;
int s = NewResetBolt - 1;
//if (ResetBolt == int.MaxValue)
//{
// s = 0;
//}
//else
//{
// s = ResetBolt - resetBolt1;
// //s = resetBolt1 + ResetBolt;
//}
//while (s >= cnt) s -= cnt;
//while (s < 0) s += cnt;
var vth = DataHelper.VectorSub(vth1, vth2);
var tmp = vth.Concat(vth).Skip(cnt-s).Take(cnt).ToArray();
......@@ -373,7 +378,7 @@ namespace FLY.HeatingHelper.UI.UiModule
{// 根据选定两幅计算偏转量
double[] corels = _data.CalculateCorrelVector(DataHelper.VectorSub(vth1, vth2), DataHelper.VectorSub(vheat2, vheat1));
var r = _data.CalculateAirRingShiftFromCorelVector(corels);
AirRingShift = r.Item1;
NewResetBolt = r.Item1;
TandH_Corel = r.Item2;
}
......@@ -381,14 +386,14 @@ namespace FLY.HeatingHelper.UI.UiModule
{
if(s == int.MaxValue)
{
AirRingShift = 0;
NewResetBolt = 1;
//ResetBolt = _data.GetResetBoltByID(vm1.SelectedFrame);
return;
}
else
{
AirRingShift += s;
NewResetBolt += s;
}
UpdateVarChart();
}
public void Change_Angle(double angle)
......@@ -412,13 +417,13 @@ namespace FLY.HeatingHelper.UI.UiModule
public void SearchAngle()
{
var tmp = _data.SearchMaxSimilarity(vm1.SelectedFrame, vm2.SelectedFrame, 15, true);
RotAngle = tmp.Item3 + vm1.RotAngle;
RotAngle = tmp.Item3;
TandH_Corel = tmp.Item2;
AirRingShift = tmp.Item1;
int rb = AirRingShift + vm1.ResetBolt;
while (rb >= _data.BoltCnt) rb -= _data.BoltCnt;
while (rb < 0) rb += _data.BoltCnt;
ResetBolt = rb;
NewResetBolt = tmp.Item1;
//int rb = AirRingShift + vm1.ResetBolt;
//while (rb >= _data.BoltCnt) rb -= _data.BoltCnt;
//while (rb < 0) rb += _data.BoltCnt;
//ResetBolt = rb;
}
public void AutoSearchAndCal_Shift()
......@@ -430,8 +435,16 @@ namespace FLY.HeatingHelper.UI.UiModule
int end = vm1.MaxFrame;
if (LockFrames == 2)
{
SearchAngle();
if (!LockAngle) SearchAngle();
else
{
UpdateThickData();
var tmp = _data.CalculateAirRingShiftFromCorelVector(correls);
NewResetBolt = tmp.Item1;
TandH_Corel = tmp.Item2;
}
SearchEnabled = true;
UpdateVarChart();
return;
}
if (LockFrames == 1)
......@@ -453,13 +466,15 @@ namespace FLY.HeatingHelper.UI.UiModule
SearchEnabled = true;
vm2.SelectedFrame = result.frameIdx1;
vm1.SelectedFrame = result.frameIdx2;
AirRingShift = result.frameShift;
NewResetBolt = 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;
//rb += AirRingShift;
//while (rb >= _data.BoltCnt) rb -= _data.BoltCnt;
//while (rb < 0) rb += _data.BoltCnt;
//ResetBolt = rb;
if (result.deltaAngle > 100)
RotAngle = result.deltaAngle;
UpdateVarChart();
}, int.MaxValue, 15, !LockAngle, true);
}
......@@ -532,27 +547,5 @@ 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());
}
}
}
......@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
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.WPF.C1Chart;assembly=C1.WPF.C1Chart.4.5.2"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
......@@ -12,10 +12,6 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="13"/>
<Setter Property="Margin" Value="7,13,7,5" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
......@@ -24,42 +20,34 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border>
<lvc:CartesianChart x:Name="myChart" Series="{Binding MySeries}"
DisableAnimations="True"
Hoverable="False"
DataTooltip="{x:Null}"
LegendLocation="Top"
FontSize="16"
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>
<c1c:C1Chart Margin="5,0,0,0" FontSize="12">
<c1c:C1Chart.Data>
<c1c:ChartData>
<c1c:DataSeries ValuesSource="{Binding DS_vthick}" ChartType="linesymbols" AxisY="ay0"
SymbolSize="3,3"/>
<c1c:DataSeries ValuesSource="{Binding DS_vheat}" ChartType="linesymbols" AxisY="ay1"
SymbolSize="3,3"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
<c1c:ChartView>
<c1c:ChartView.AxisY>
<c1c:Axis Name="ay0" Position="Near" Title="厚度变化"></c1c:Axis>
</c1c:ChartView.AxisY>
<c1c:Axis AxisType="Y" Name="ay1" Position="Far" Title="加热变化"
Min="-60" Max="60" MajorUnit="20"
MajorGridStroke="Green"/>
</c1c:ChartView>
</c1c:C1Chart.View>
</c1c:C1Chart>
</Border>
<!--<lvc:CartesianChart Grid.Row="0" x:Name="myChart" Series="{Binding MySeries}"
DisableAnimations="True"
Hoverable="False"
DataTooltip="{x:Null}"
LegendLocation="Top"
FontSize="16"
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>-->
<StackPanel Orientation="Horizontal" Grid.Row="1">
<StackPanel.Resources>
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="13"/>
<Setter Property="Margin" Value="7,13,7,5" />
</Style>
</StackPanel.Resources>
<TextBlock Text="{Binding FrameIdx1, StringFormat=第一幅号:{0}}" />
<TextBlock Text="{Binding FrameIdx2, StringFormat=第二幅号:{0}}" />
</StackPanel>
......
......@@ -23,7 +23,6 @@ namespace FLY.HeatingHelper.UI.UiModule
/// </summary>
public int FrameIdx1 { get; set; } = -1;
public int FrameIdx2 { get; set; } = -1;
public SeriesCollection MySeries { get; set; } = new SeriesCollection();
public void Init(IThickHeatData dat)
{
......@@ -53,36 +52,13 @@ namespace FLY.HeatingHelper.UI.UiModule
UpdateSeries();
}
private ChartValues<double> v1 = new ChartValues<double>();
private ChartValues<double> v2 = new ChartValues<double>();
public double[] DS_vthick { get; set; }
public double[] DS_vheat { get; set; }
private void UpdateSeries()
{
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(thickDiff);
v2.Clear(); v2.AddRange(heatDiff);
DS_vthick = thickDiff.ToArray();
DS_vheat = heatDiff.ToArray();
}
private void DataSelecter_PropertyChanged(object s, PropertyChangedEventArgs e)
......
<UserControl
<UserControl x:Class="FLY.HeatingHelper.UI.UiModule.UC_FramePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
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.WPF.C1Chart;assembly=C1.WPF.C1Chart.4.5.2"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" x:Class="FLY.HeatingHelper.UI.UiModule.UC_FramePicker"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="600">
<UserControl.Resources>
......@@ -92,10 +90,6 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="13"/>
<Setter Property="Margin" Value="7,13,7,5" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
......@@ -133,7 +127,7 @@
</c1c:ChartView>
</c1c:C1Chart.View>
</c1c:C1Chart>
<Slider Grid.Row="1" Margin="20"
<Slider Grid.Row="1" Margin="10,5,10,5"
Minimum="{Binding MinFrame}"
Maximum="{Binding MaxFrame}"
Value="{Binding SelectedFrame}"/>
......@@ -147,6 +141,12 @@
<Button Content="后一幅" Command="{Binding NxtCmd}" Margin="10,5,5,5" Style="{StaticResource RightButton}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left" >
<StackPanel.Resources>
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="13"/>
<Setter Property="Margin" Value="7,13,7,5" />
</Style>
</StackPanel.Resources>
<TextBlock Text="{Binding FrameID, Mode=OneWay, StringFormat=ID:\{0\}}" />
<TextBlock Text="{Binding FrameTime, Mode=OneWay, StringFormat=\{0:MM/dd HH:mm:ss\}}" />
<TextBlock Text="{Binding ResetBolt, StringFormat=复位分区:\{0\}}" />
......
......@@ -12,16 +12,6 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="5"/>
<Setter Property="FontFamily" Value="YouYuan" />
<Setter Property="FontSize" Value="25" />
</Style>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="22" />
<Setter Property="FontFamily" Value="YouYuan" />
<Setter Property="Margin" Value="0,5,5,5" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
......@@ -31,6 +21,18 @@
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="5"/>
<Setter Property="FontFamily" Value="YouYuan" />
<Setter Property="FontSize" Value="25" />
</Style>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="22" />
<Setter Property="FontFamily" Value="YouYuan" />
<Setter Property="Margin" Value="0,5,5,5" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
......
......@@ -75,6 +75,10 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\thick_public\Project.FLY.Misc\MISC\Misc.csproj">
<Project>{5ee61ac6-5269-4f0f-b8fa-4334fe4a678f}</Project>
<Name>Misc</Name>
</ProjectReference>
<ProjectReference Include="..\..\thick_public\Project.SQLiteHelper\SQLiteHelper\SQLiteHelper.csproj">
<Project>{4cbabfaa-1c62-4510-ac63-a51ee5fd50ff}</Project>
<Name>SQLiteHelper</Name>
......
......@@ -64,7 +64,7 @@ namespace FLY.HeatingHelper
/// <summary>
/// 风环偏差值
/// </summary>
int AirRingShift { get; }
int NewResetBolt { get; }
StateCode State { get; }
......@@ -80,6 +80,7 @@ namespace FLY.HeatingHelper
#endregion
#region 获取数据接口
bool MapBack { get; set; }
/// <summary>
/// 获取厚度和加热的值
/// </summary>
......
......@@ -102,7 +102,18 @@ namespace FLY.HeatingHelper
protected List<double[]> _heats = new List<double[]>();
protected List<int> _resetBolts = new List<int>(); // 每幅数据的复位分区号
protected List<double> _rotAngles = new List<double>(); // 每幅数据旋转角度
public int BoltCnt { get; set; } = -1;
protected List<Dictionary<int, int>> _mapbacks = new List<Dictionary<int, int>>();
protected List<double[]> _mapback_thicks = new List<double[]>();
public int BoltCnt
{
get
{
var tmp = _thicks.Count();
if (tmp == 0) return -1;
return _thicks[tmp - 1].Count();
}
}
protected int _index_from;
protected int _index_to;
protected int _last_cluster_idx; // 最后聚类的点的索引号,当新数据到来时,可以只处理新数据了。
......@@ -174,7 +185,7 @@ namespace FLY.HeatingHelper
#endregion
public int AirRingShift { get; internal set; } = 0;
public int NewResetBolt { get; internal set; } = 0;
public bool BeginUse(bool isAsync = true)
{
......@@ -202,7 +213,7 @@ namespace FLY.HeatingHelper
MaxSimilarityResult ms = re.EvtData as MaxSimilarityResult;
if (ms.similarity > 0.7)
{
AirRingShift = ms.frameShift;
NewResetBolt = ms.frameShift;
}
}
......@@ -216,7 +227,7 @@ namespace FLY.HeatingHelper
if (max < correlVec[j])
{
max = correlVec[j];
shift = j;
shift = j + 1;
}
}
return new Tuple<int, double>(shift, max);
......@@ -501,8 +512,7 @@ namespace FLY.HeatingHelper
#endregion
public int _select_frame_idx1;
public int _select_frame_idx2;
//public double[] _heatVariation;
//public double[] _thickVariation;
#region 一些辅助计算的函数
private double HeatVariation(int idx1, int idx2)
......@@ -808,7 +818,7 @@ namespace FLY.HeatingHelper
#endregion
#region 获取数据
public bool MapBack { get; set; } = true;
/// <summary>
/// 获取某幅厚度数据的一部分
/// </summary>
......@@ -828,7 +838,10 @@ namespace FLY.HeatingHelper
int cnt = _thicks[0].Count();
if ((to >= cnt) || (to < 0)) to = cnt - 1;
if ((from < 0) || (from > to)) from = 0;
return _thicks[idx].Skip(from).Take(to - from + 1).ToArray();
if (MapBack)
return _mapback_thicks[idx].Skip(from).Take(to - from + 1).ToArray();
else
return _thicks[idx].Skip(from).Take(to - from + 1).ToArray();
}
public double[] GetThicksByID(int idx, int newResetBolt, double newAngle)
{
......@@ -852,6 +865,13 @@ namespace FLY.HeatingHelper
}
return ret;
}
/// <summary>
///
/// </summary>
/// <param name="idx"></param>
/// <param name="newResetBolt">从1开始起算</param>
/// <param name="newAngle"></param>
/// <returns></returns>
public double[] GetThicksByIndex(int idx, int newResetBolt, double newAngle)
{
if (idx < 0) return null;
......@@ -1337,8 +1357,8 @@ namespace FLY.HeatingHelper
result.deltaAngle = deltaAngle;
var angle = GetRotAngleByIndex(idx1) + deltaAngle;
var heat = DataHelper.VectorSub(GetHeatsByIndex(idx2, -1, -1), GetHeatsByIndex(idx1, -1, -1));
var t1 = GetThicksByIndex(idx1, int.MinValue, angle);
var th = DataHelper.VectorSub(t1, GetThicksByIndex(idx2, int.MaxValue, angle));
var t1 = GetThicksByIndex(idx1, 1, angle);
var th = DataHelper.VectorSub(t1, GetThicksByIndex(idx2, 1, angle));
result.ThickToHeatFactor = CalculateHeatToThickFactor(heat, th,
MathNet.Numerics.Statistics.Statistics.Mean(t1));
});
......@@ -1385,30 +1405,28 @@ namespace FLY.HeatingHelper
double angle_L = GetRotAngleByIndex(idxL);
int rb_B = GetResetBoltByIndex(idxB);
int rb_L = GetResetBoltByIndex(idxL);
Vector<double> vthickL = Vector<double>.Build.DenseOfArray(GetThicksByIndex(idxL, rb_B, angle_B));
Vector<double> vthickB = Vector<double>.Build.DenseOfArray(GetThicksByIndex(idxB, -1, -1));
Vector<double> vthickL = Vector<double>.Build.DenseOfArray(GetThicksByIndex(idxL, 1, angle_B));
Vector<double> vthickB = Vector<double>.Build.DenseOfArray(GetThicksByIndex(idxB, 1, double.NaN));
Vector<double> v_heatL = Vector<double>.Build.DenseOfArray(GetHeatsByIndex(idxL, -1, -1));
Vector<double> v_heatB = Vector<double>.Build.DenseOfArray(GetHeatsByIndex(idxB, -1, -1));
if (!SearchRotAngle)
{
double[] corels = CalculateCorrelVector((vthickL - vthickB).ToArray(), (v_heatB - v_heatL).ToArray());
double max = -100;
var r = CalculateAirRingShiftFromCorelVector(corels);
int shift = r.Item1;
if (maxcorel < r.Item2)
{
maxcorel = r.Item2;
theshift = shift;
}
maxcorel = r.Item2;
theshift = r.Item1;
}
else
{
double range = searchRange / 360.0;
double di = -range;
double u_range = 360 / angle_B - 1;
for (; di < u_range; di += 0.001)
double di = angle_B - searchRange;
double u_range = angle_B + searchRange;
if (u_range > 360) u_range = 360;
for (; di <= u_range; di += 0.5)
{
var vth = ReSampleForChangeRotAngle((vthickL - vthickB).ToArray(), rb_B, 1 + di);
var vthL = GetThicksByIndex(idxL, 1, di);
var vthB = GetThicksByIndex(idxB, 1, di);
var vth = DataHelper.VectorSub(vthL, vthB);
double[] corels = CalculateCorrelVector(vth, (v_heatB - v_heatL).ToArray());
var r = CalculateAirRingShiftFromCorelVector(corels);
int shift = r.Item1;
......@@ -1416,7 +1434,7 @@ namespace FLY.HeatingHelper
{
maxcorel = r.Item2;
theshift = shift;
deltaAngle = di * angle_B;
deltaAngle = di;
}
}
}
......
......@@ -142,7 +142,6 @@ namespace FLY.HeatingHelper
_rotAngles.Add(dr.Field<double>("旋转角度°"));
cnt++;
}
BoltCnt = _thicks[0].Count();
DataChanged++;
return cnt;
}
......
......@@ -90,9 +90,10 @@ namespace FLY.HeatingHelper
}
class Boltmap
{
public int Begin;
public int End;
public int OldNo;
public int NewNo;
}
/// <summary>
/// 从dataTable中提取数据到内部缓冲区
/// </summary>
......@@ -106,30 +107,14 @@ namespace FLY.HeatingHelper
_ids.Clear();
_resetBolts.Clear();
_rotAngles.Clear();
_mapbacks.Clear();
_mapback_thicks.Clear();
int cnt = 0;
foreach (DataRow dr in dataTable.Rows)
{
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) && IsDataFilter)
{
if (IsHeatSame(h1, _heats.Last())) DeleteDataLast();
}
_ids.Add((int)dr.Field<long>("ID"));
_dat_times.Add(dr.Field<DateTime>("Time"));
_thicks.Add(t1);
_heats.Add(h1);
var t2 = RemoveNaN(t1);
var r = MathNet.Numerics.Statistics.Statistics.MeanStandardDeviation(t2);
_thick_means.Add(r.Item1);
_thick_2sigmas.Add(r.Item2 * 2);
_resetBolts.Add((int)dr.Field<long>("OrgBoltNo"));
_rotAngles.Add(dr.Field<double>("RAngle"));
AddOneRecord(dr);
cnt++;
}
BoltCnt = _thicks[0].Count();
return cnt;
}
......@@ -140,34 +125,55 @@ namespace FLY.HeatingHelper
{
int lastID = _ids.Last();
int cnt = 0;
int i = 1;
foreach (DataRow dr in dataTable.Rows)
{
var id = (int)dr.Field<long>("ID");
if (lastID >= id) continue;
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) && IsDataFilter)
{
if (IsHeatSame(h1, _heats.Last())) DeleteDataLast();
}
_ids.Add(id);
_thicks.Add(t1);
_heats.Add(h1);
_dat_times.Add(dr.Field<DateTime>("Time"));
var t2 = RemoveNaN(t1);
var r = MathNet.Numerics.Statistics.Statistics.MeanStandardDeviation(t2);
_thick_means.Add(r.Item1);
_thick_2sigmas.Add(r.Item2 * 2);
_resetBolts.Add((int)dr.Field<long>("OrgBoltNo"));
_rotAngles.Add(dr.Field<double>("RAngle"));
AddOneRecord(dr);
cnt++;
}
return cnt;
}
private void AddOneRecord(DataRow dr)
{
string th_dat = dr.Field<string>("Thicks");
string heat_dat = dr.Field<string>("Heats");
var map_dat = dr.Field<string>("Boltmap");
var t1 = Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(th_dat);
var h1 = Newtonsoft.Json.JsonConvert.DeserializeObject<double[]>(heat_dat);
var map = Newtonsoft.Json.JsonConvert.DeserializeObject<Boltmap[]>(map_dat);
if ((_heats.Count() > 0) && IsDataFilter)
{
if (IsHeatSame(h1, _heats.Last())) DeleteDataLast();
}
_ids.Add((int)dr.Field<long>("ID"));
_dat_times.Add(dr.Field<DateTime>("Time"));
_thicks.Add(t1);
_heats.Add(h1);
var t2 = RemoveNaN(t1);
var r = MathNet.Numerics.Statistics.Statistics.MeanStandardDeviation(t2);
_thick_means.Add(r.Item1);
_thick_2sigmas.Add(r.Item2 * 2);
_resetBolts.Add((int)dr.Field<long>("OrgBoltNo"));
_rotAngles.Add(dr.Field<double>("RAngle"));
if(map != null)
{
Dictionary<int, int> m = new Dictionary<int, int>();
foreach (Boltmap bm in map)
{
m.Add(bm.NewNo - 1, bm.OldNo - 1);
}
_mapbacks.Add(m);
_mapback_thicks.Add(Misc.MyMath.Map(t1, m));
}
else
{
_mapbacks.Add(null);
_mapback_thicks.Add(t1);
}
}
/// <summary>
/// 判断两个加热是否相同
/// </summary>
......@@ -196,6 +202,8 @@ namespace FLY.HeatingHelper
_heats.RemoveAt(idx);
_resetBolts.RemoveAt(idx);
_rotAngles.RemoveAt(idx);
_mapbacks.RemoveAt(idx);
_mapback_thicks.RemoveAt(idx);
}
public override int LoadMetaDataFromDB()
......
Subproject commit d91e9ad36251710e057ea37a110305435ff870ca
Subproject commit f9a1629c79a6452fc67ded6a91ab7b153cad85d6
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