Commit 4cf775ec authored by 潘栩锋's avatar 潘栩锋 🚴

合并v5.5-qiu

parents 67374440 eaae9d79
......@@ -18,5 +18,5 @@
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
</configuration>
<Application x:Class="FLY.HeatingHelper.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace FLY.HeatingHelper.UI
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
}
......@@ -100,15 +100,23 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="UIModule\HeatThickDetector.xaml.cs">
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\HeatThickDetector\HeatThickDetector.xaml.cs">
<DependentUpon>HeatThickDetector.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\HeatThickDetector\ViewModel_HeatThickDetector.cs" />
<Compile Include="UIModule\Page_HeatDetector.xaml.cs">
<DependentUpon>Page_HeatDetector.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\UC_AirRingShift.xaml.cs">
<DependentUpon>UC_AirRingShift.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\UC_BrowseData\UC_BrowseData.xaml.cs">
<DependentUpon>UC_BrowseData.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\UC_BrowseData\ViewModel_UC_BrowseData.cs" />
<Compile Include="UIModule\UC_FrameDiff.xaml.cs">
<DependentUpon>UC_FrameDiff.xaml</DependentUpon>
</Compile>
......@@ -120,6 +128,15 @@
<DependentUpon>UC_HeatBoltAnalyst.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\UC_HeatBoltAnalystViewModel.cs" />
<Compile Include="UIModule\UC_SelectData\AlarmZone.cs" />
<Compile Include="UIModule\UC_SelectData\UC_SelectData.xaml.cs">
<DependentUpon>UC_SelectData.xaml</DependentUpon>
</Compile>
<Compile Include="UIModule\UC_SelectData\ViewModel_UC_SelectData.cs" />
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -128,7 +145,7 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="UIModule\HeatThickDetector.xaml">
<Page Include="UIModule\HeatThickDetector\HeatThickDetector.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
......@@ -140,6 +157,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UIModule\UC_BrowseData\UC_BrowseData.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UIModule\UC_FrameDiff.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -152,6 +173,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UIModule\UC_SelectData\UC_SelectData.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
......@@ -189,12 +214,25 @@
<Project>{119c3adc-f8e1-4f72-b89b-006236ff8586}</Project>
<Name>FLY.ControlLibrary</Name>
</ProjectReference>
<ProjectReference Include="..\..\thick_public\Project.FLY.UI.Module\FLY.UI.Module\FLY.UI.Module.csproj">
<Project>{4df79671-e814-49bd-864d-8257d6c6e072}</Project>
<Name>FLY.UI.Module</Name>
</ProjectReference>
<ProjectReference Include="..\FLY.HeatingHelper\FLY.HeatingHelper.csproj">
<Project>{973f0eed-3181-4fb9-abd6-196a9e816b77}</Project>
<Name>FLY.HeatingHelper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ControlzEx">
<Version>4.2.1</Version>
</PackageReference>
<PackageReference Include="MahApps.Metro">
<Version>2.0.0-alpha0316</Version>
</PackageReference>
<PackageReference Include="MahApps.Metro.IconPacks">
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="MathNet.Numerics">
<Version>4.9.0</Version>
</PackageReference>
......@@ -211,5 +249,6 @@
<Version>5.11.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
......@@ -4,9 +4,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FLY.HeatingHelper.UI"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Controls:RangeSlider/>
</Grid>
</Window>
......@@ -25,18 +25,37 @@
</ResourceDictionary>
</Page.Resources>
<Button Style="{StaticResource ButtonStyle_empty}" Background="Transparent" Click="Button_Click">
<Grid>
<Border Style="{StaticResource BorderStyle_module}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<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"/>
</StackPanel>
</StackPanel>
<!--<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"/>
</StackPanel>-->
</Grid>
</Border>
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<TextBlock Text="{Binding State,Converter={StaticResource StateToMessage}}" Background="AliceBlue"/>
<TextBlock Text="{Binding Path=Dat.State,Converter={StaticResource StateToMessage}}" Background="AliceBlue"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="风环偏转"/>
<TextBlock Text="{Binding AirRingShift}" Background="AliceBlue"/>
<TextBlock Text="{Binding Path=Dat.AirRingShift}" Background="AliceBlue"/>
</StackPanel>
</Grid>
</Grid>-->
</Button>
</Page>
......@@ -25,25 +25,26 @@ namespace FLY.HeatingHelper.UI.UIModule
public partial class HeatThickDetector : Page
{
//ThickHeatData4SQLite_V1 _thickHeatData4SQLite_V1;
IThickHeatData _dat;
ViewModel_HeatThickDetector vm;
public HeatThickDetector()
{
InitializeComponent();
_dat = DataManager.GetThickDataInstance();
_dat.SetDB(@"D:\blowingdata\airring.sqlite3");
this.DataContext = _dat;
var _dat = DataManager.GetThickDataInstance();
_dat.DBPath = @"D:\blowingdata\airring.sqlite3";
vm = new ViewModel_HeatThickDetector(_dat);
this.DataContext = vm;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (!_dat.IsDataReady) return;
if (!vm.HasData) return;
NavigationService ns = Application.Current.Properties["NavigationService"] as NavigationService;
if (ns != null)
{
if(_dat.BeginUse())
if(vm._dat.BeginUse())
{
Page_HeatDetector page = new Page_HeatDetector();
page.InitData(_dat);
page.InitData(vm._dat);
ns.Navigate(page);
}
}
......
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.HeatingHelper.UI.UIModule
{
public class ViewModel_HeatThickDetector : INotifyPropertyChanged
{
public IThickHeatData _dat;
public IThickHeatData Dat
{
get
{
return _dat;
}
set
{
_dat = value;
}
}
public ViewModel_HeatThickDetector(IThickHeatData dat)
{
_dat = dat;
}
public bool HasData
{
get
{
if (_dat == null) return false;
if (_dat.TotalDataFrom != DateTime.MinValue) return true;
return false;
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -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:local1="clr-namespace:FLY.HeatingHelper.UI.UIModule.UC_SelectData"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="960"
......@@ -171,93 +172,8 @@
</StackPanel>
</StackPanel >
<TabControl Name="tc1" Style="{DynamicResource TabControlStyle_ABC}" >
<TabItem Header="数据选择" Style="{DynamicResource TabItemStyle1}" x:Name="tabitem_dataChoose">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<DockPanel>
<DockPanel.Resources>
<Style x:Key="tb_style1" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
</Style>
</DockPanel.Resources>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader2}" Text="数据库覆盖时间:" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent2}" Text="{Binding DBFrom, StringFormat={}{0:s}}" />
<TextBlock Text="-" FontSize="15"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent2}" Text="{Binding DBTo, StringFormat={}{0:s}}" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader2}" Text="设定数据范围:" />
<CheckBox x:Name="default_cb" Content="缺省范围"
FontSize="16"
Margin="2"
IsChecked="{Binding IsDefault}"
Click="Default_cb_Click"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent2}" Text="{Binding DataFrom, StringFormat={}{0:MM/dd/yyyy HH:mm:ss}}" />
<TextBlock Text="-" FontSize="15"/>
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent2}" Text="{Binding DataTo, StringFormat={}{0:s}}" />
</StackPanel>
</StackPanel>
<Button Background="Aquamarine" Click="Button_Click_1" Height="47" Margin="5,0,5,5" Width="68">
<TextBlock Text="按厚度选择Pre" FontSize="13" TextWrapping="Wrap" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Button>
<Button Background="Aquamarine" Click="Button_Click_2" Height="47" Margin="5,0,5,5" Width="68">
<TextBlock Text="按厚度选择Nxt" FontSize="13" TextWrapping="Wrap" HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Button>
<Button BorderBrush="Blue"
BorderThickness="2" Content="下一步" Margin="5"
Background="Aquamarine"
Click="Button_Click"/>
</DockPanel>
<Border Grid.Row="1">
<lvc:CartesianChart x:Name="myChart" Series="{Binding MySeries}"
DisableAnimations="True"
Hoverable="False"
DataTooltip="{x:Null}"
LegendLocation="Top"
FontSize="20"
Margin="2,2,2,2"
MouseDown="MyChart_MouseDown"
MouseUp="MyChart_MouseUp"
MouseMove="MyChart_MouseMove"
MouseLeftButtonDown="MyChart_MouseLeftButtonDown">
<lvc:CartesianChart.VisualElements>
<lvc:VisualElement x:Name="ve1" HorizontalAlignment="Right" VerticalAlignment="Bottom" X="{Binding RX}" Y="{Binding RY}">
<lvc:VisualElement.UIElement>
<Rectangle Opacity="0.4"
Visibility="Visible"
Fill="DodgerBlue"
Height="{Binding RH}"
Width="{Binding RW}"/>
</lvc:VisualElement.UIElement>
</lvc:VisualElement>
</lvc:CartesianChart.VisualElements>
<lvc:CartesianChart.AxisY>
<lvc:Axis Foreground="DodgerBlue" Title="厚度">
</lvc:Axis>
<lvc:Axis x:Name="yax2" Foreground="IndianRed" Position="RightTop" Title="2Sigma">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding Formatter}"/>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
</Border>
</Grid>
<TabItem Header="数据选择" Style="{DynamicResource TabItemStyle1}">
<local1:UC_SelectData/>
</TabItem>
<TabItem Header="风环偏转" Style="{DynamicResource TabItemStyle1}" x:Name="tabitem_ringShift">
<local:UC_AirRingShift x:Name="uc_airRingShift">
......
......@@ -101,6 +101,8 @@ namespace FLY.HeatingHelper.UI.UIModule
public int LockFrames { get; set; } = 1;
public bool LockAngle { get; set; } = true;
public int SearchProgressValue { get; set; } = 0;
public bool SearchEnabled { get; set; } = true;
......@@ -172,27 +174,28 @@ 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);
UpdateData(1);
UpdateData(2);
UpdateVarChart();
//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);
vm1.InitData(_data);
vm2.InitData(_data);
}
public void Loaded(object s)
{
var tmpVM = ViewModel_HeatDetector.Instance;
tmpVM.PropertyChanged += DataSelecter_PropertyChanged;
vm2.SelectedFrame = vm2.MaxFrame;
vm1.UpdateChart();
vm2.UpdateChart();
//var tmpVM = ViewModel_HeatDetector.Instance;
//tmpVM.PropertyChanged += DataSelecter_PropertyChanged;
vm1.OnLoaded(true);
vm2.OnLoaded();
UpdateData(1);
UpdateData(2);
UpdateVarChart();
}
public void UnLoaded(object s)
{
var tmpVM = ViewModel_HeatDetector.Instance;
tmpVM.PropertyChanged -= DataSelecter_PropertyChanged;
//var tmpVM = ViewModel_HeatDetector.Instance;
//tmpVM.PropertyChanged -= DataSelecter_PropertyChanged;
}
private double[] vth1;
......@@ -205,20 +208,6 @@ namespace FLY.HeatingHelper.UI.UIModule
private int resetBolt2;
private double[] correls;
private void DataSelecter_PropertyChanged(object s, PropertyChangedEventArgs e)
{
if(e.PropertyName== "Selected_Idx_From")
{
vm1.MinFrame = (s as ViewModel_HeatDetector).Selected_Idx_From;
vm2.MinFrame = vm1.MinFrame;
}
if (e.PropertyName == "Selected_Idx_To")
{
vm1.MaxFrame = (s as ViewModel_HeatDetector).Selected_Idx_To;
vm2.MaxFrame = vm1.MaxFrame;
}
}
private void PickerVM_PropertyChanged(object s, PropertyChangedEventArgs e)
{
if (e.PropertyName == "SelectedFrame")
......@@ -247,17 +236,17 @@ namespace FLY.HeatingHelper.UI.UIModule
switch (whichframe)
{
case 1:
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);
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vheat1 = _data.GetHeatsByIndex(vm1.SelectedFrame, -1, -1);
resetBolt1 = _data.GetResetBoltByIndex(vm1.SelectedFrame);
rotAngle1 = _data.GetRotAngleByIndex(vm1.SelectedFrame);
break;
case 2:
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);
vth2 = _data.GetThicksByIndex(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vheat2 = _data.GetHeatsByIndex(vm2.SelectedFrame, -1, -1);
resetBolt2 = _data.GetResetBoltByIndex(vm2.SelectedFrame);
rotAngle2 = _data.GetRotAngleByIndex(vm2.SelectedFrame);
break;
default:
return;
......@@ -276,8 +265,8 @@ namespace FLY.HeatingHelper.UI.UIModule
/// <returns></returns>
private bool UpdateThickData()
{
vth1 = _data.GetThicks(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vth2 = _data.GetThicks(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
vth1 = _data.GetThicksByIndex(vm1.SelectedFrame, vm2.ResetBolt, RotAngle);
vth2 = _data.GetThicksByIndex(vm2.SelectedFrame, vm2.ResetBolt, RotAngle);
if ((vth1 == null) || (vth2 == null) || (vheat1 == null) || (vheat2 == null))
{
return false;
......@@ -363,7 +352,7 @@ namespace FLY.HeatingHelper.UI.UIModule
if(s == int.MaxValue)
{
AirRingShift = 0;
//ResetBolt = _data.GetResetBolt(vm1.SelectedFrame);
//ResetBolt = _data.GetResetBoltByID(vm1.SelectedFrame);
return;
}
else
......@@ -376,7 +365,7 @@ namespace FLY.HeatingHelper.UI.UIModule
{
if (double.IsNaN(angle))
{
RotAngle = _data.GetRotAngle(vm1.SelectedFrame);
RotAngle = _data.GetRotAngleByIndex(vm1.SelectedFrame);
return;
}
else
......@@ -392,8 +381,7 @@ namespace FLY.HeatingHelper.UI.UIModule
public void SearchAngle()
{
var tmp = _data.SearchMaxSimilarity(_data.GetIndexFromID(vm1.SelectedFrame),
_data.GetIndexFromID(vm2.SelectedFrame), 15, true);
var tmp = _data.SearchMaxSimilarity(vm1.SelectedFrame, vm2.SelectedFrame, 15, true);
RotAngle = tmp.Item3 + vm1.RotAngle;
TandH_Corel = tmp.Item2;
AirRingShift = tmp.Item1;
......@@ -428,8 +416,9 @@ namespace FLY.HeatingHelper.UI.UIModule
},
(o, e) =>
{
int rb = _data.GetResetBolt(result.frameIdx2);
double ra = _data.GetRotAngle(result.frameIdx2);
if (result.frameIdx1 < 0 || result.frameIdx2 < 0) return;
int rb = _data.GetResetBoltByIndex(result.frameIdx2);
double ra = _data.GetRotAngleByIndex(result.frameIdx2);
SearchProgressValue = 0;
SearchEnabled = true;
vm2.SelectedFrame = result.frameIdx1;
......@@ -441,7 +430,7 @@ namespace FLY.HeatingHelper.UI.UIModule
while (rb < 0) rb += _data.BoltCnt;
ResetBolt = rb;
RotAngle = ra + result.deltaAngle;
}, int.MaxValue, 15, true, true);
}, int.MaxValue, 15, !LockAngle, true);
}
public double[] ExpandOrShrinkData(double[] ori, int orideg, int dstdeg)
......
<UserControl x:Class="FLY.HeatingHelper.UI.UIModule.UC_BrowseData.UC_BrowseData"
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.UC_BrowseData"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FLY.HeatingHelper.UI.UIModule.UC_BrowseData
{
/// <summary>
/// UC_BrowseData.xaml 的交互逻辑
/// </summary>
public partial class UC_BrowseData : UserControl
{
public UC_BrowseData()
{
InitializeComponent();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.HeatingHelper.UI.UIModule.UC_BrowseData
{
class ViewModel_UC_BrowseData : INotifyPropertyChanged
{
public IThickHeatData Dat { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -7,12 +7,39 @@
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<lvc:CartesianChart Grid.Row="0" x:Name="myChart" Series="{Binding MySeries}"
<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>
</Border>
<!--<lvc:CartesianChart Grid.Row="0" x:Name="myChart" Series="{Binding MySeries}"
DisableAnimations="True"
Hoverable="False"
DataTooltip="{x:Null}"
......@@ -28,10 +55,10 @@
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</lvc:CartesianChart>-->
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="{Binding FrameIdx1, StringFormat=第一幅号:{0}}"/>
<TextBlock Text="{Binding FrameIdx2, StringFormat=第二幅号:{0}}" Margin="3,0,0,0"/>
<TextBlock Text="{Binding FrameIdx1, StringFormat=第一幅号:{0}}" Style="{StaticResource TextBlockStyle_FieldHeader}" FontSize="18" Margin="15,5,15,5"/>
<TextBlock Text="{Binding FrameIdx2, StringFormat=第二幅号:{0}}" Style="{StaticResource TextBlockStyle_FieldHeader}" FontSize="18" Margin="15,5,15,5"/>
</StackPanel>
</Grid>
......
......@@ -44,10 +44,10 @@ namespace FLY.HeatingHelper.UI.UIModule
{
return;
}
thick1 = Vector<double>.Build.DenseOfArray(mdata.GetThicks(FrameIdx1, -1, -1));
thick2 = Vector<double>.Build.DenseOfArray(mdata.GetThicks(FrameIdx2, -1, -1));
heat1 = Vector<double>.Build.DenseOfArray(mdata.GetHeats(FrameIdx1, -1, -1));
heat2 = Vector<double>.Build.DenseOfArray(mdata.GetHeats(FrameIdx2, -1, -1));
thick1 = Vector<double>.Build.DenseOfArray(mdata.GetThicksByIndex(FrameIdx1, -1, -1));
thick2 = Vector<double>.Build.DenseOfArray(mdata.GetThicksByIndex(FrameIdx2, -1, -1));
heat1 = Vector<double>.Build.DenseOfArray(mdata.GetHeatsByIndex(FrameIdx1, -1, -1));
heat2 = Vector<double>.Build.DenseOfArray(mdata.GetHeatsByIndex(FrameIdx2, -1, -1));
thickDiff = thick2 - thick1;
heatDiff = heat1 - heat2;
UpdateSeries();
......
......@@ -4,42 +4,67 @@
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:Controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Name="SP_0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="最大幅间隔" Background="LightBlue"/>
<TextBox Text="{Binding MaxFrameInterval}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="总加热变化量" Background="LightBlue"/>
<TextBox Text="{Binding HeatRateVar}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="忽略加热变化量" Background="LightBlue"/>
<TextBox Text="{Binding NeglectHeatRate}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="分离螺丝数" Background="LightBlue"/>
<TextBox Text="{Binding Separation}"/>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Name="SP_0">
<DockPanel>
<TextBlock Text="最大幅间隔" Background="LightBlue" Style="{StaticResource TextBlockStyle_FieldHeader}" DockPanel.Dock="Left" />
<TextBox Text="{Binding MaxFrameInterval}" Style="{StaticResource TextBoxStyle1}" DockPanel.Dock="Right" />
</DockPanel>
<DockPanel>
<TextBlock Text="总加热变化量" Background="LightBlue" Style="{StaticResource TextBlockStyle_FieldHeader}" />
<TextBox Text="{Binding HeatRateVar}" Style="{StaticResource TextBoxStyle1}" />
</DockPanel>
<DockPanel>
<TextBlock Text="忽略加热变化量" Background="LightBlue" Style="{StaticResource TextBlockStyle_FieldHeader}" />
<TextBox Text="{Binding NeglectHeatRate}" Style="{StaticResource TextBoxStyle1}" />
</DockPanel>
<DockPanel>
<TextBlock Text="分离螺丝数" Background="LightBlue" Style="{StaticResource TextBlockStyle_FieldHeader}" />
<TextBox Text="{Binding Separation}" Style="{StaticResource TextBoxStyle1}" />
</DockPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Path=HeatBoltItems.Count, StringFormat=搜索结果:{0}}" Background="LightBlue" Style="{StaticResource TextBlockStyle_FieldHeader}" />
<Grid Grid.Column="1">
<DockPanel>
<Controls:ToggleSwitch Content="过滤" IsChecked="{Binding IsFilter}" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" FontSize="22" Margin="5"/>
<Button Content="搜索" Click="Button_Click" FontFamily="YouYuan" Margin="5"
Style="{DynamicResource AccentedSquareButtonStyle}" />
</DockPanel>
</Grid>
</Grid>
</StackPanel>
<Button Content="搜索" Click="Button_Click"/>
<DockPanel Width="{Binding Path=ActualWidth,ElementName=SP_0}">
<TextBlock DockPanel.Dock="Left" Text="{Binding Path=HeatBoltItems.Count, StringFormat=搜索结果:{0}}" Background="LightCyan"/>
<CheckBox Content="过滤" DockPanel.Dock="Right" IsChecked="{Binding IsFilter}"/>
</DockPanel>
<ListView x:Name="lv_result" ItemsSource="{Binding HeatBoltItems}"
MaxHeight="250" SelectionChanged="Lv_result_SelectionChanged"
SelectedIndex="{Binding SelectItem}">
<ListView x:Name="lv_result" ItemsSource="{Binding HeatBoltItems}" Grid.Row="1" Margin="5,5,5,20"
SelectionChanged="Lv_result_SelectionChanged"
SelectedIndex="{Binding SelectItem}" FontFamily="YouYuan" >
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="幅1"
<GridViewColumn Header="幅1"
DisplayMemberBinding="{Binding FrameIdx1}"/>
<GridViewColumn Header="幅2"
DisplayMemberBinding="{Binding FrameIdx2}"/>
......@@ -55,16 +80,16 @@
</GridView>
</ListView.View>
</ListView>
</StackPanel>
</Grid>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<local:UC_FramePicker Grid.Row="0" DataContext="{Binding vm1}"/>
<local:UC_FramePicker Grid.Row="1" DataContext="{Binding vm2}"/>
<local:UC_FrameDiff Grid.Row="2" DataContext="{Binding vmDiff}"/>
<local:UC_FramePicker Grid.Row="0" DataContext="{Binding vm1}" Margin="5"/>
<local:UC_FramePicker Grid.Row="1" DataContext="{Binding vm2}" Margin="5"/>
<local:UC_FrameDiff Grid.Row="2" DataContext="{Binding vmDiff}" Margin="5"/>
</Grid>
</Grid>
</UserControl>
......@@ -82,33 +82,14 @@ namespace FLY.HeatingHelper.UI.UIModule
public void Loaded(object s)
{
var tmpVM = ViewModel_HeatDetector.Instance;
tmpVM.PropertyChanged += DataSelecter_PropertyChanged;
vm1.InitData(mdata, tmpVM.Selected_Idx_From, tmpVM.Selected_Idx_To);
vm2.InitData(mdata, tmpVM.Selected_Idx_From, tmpVM.Selected_Idx_To);
vm1.InitData(mdata);
vm2.InitData(mdata);
vmDiff.Init(mdata);
vm1.UpdateChart();
vm2.UpdateChart();
}
public void UnLoaded(object s)
{
var tmpVM = ViewModel_HeatDetector.Instance;
tmpVM.PropertyChanged -= DataSelecter_PropertyChanged;
}
private void DataSelecter_PropertyChanged(object s, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Selected_Idx_From")
{
vm1.MinFrame = (s as ViewModel_HeatDetector).Selected_Idx_From;
vm2.MinFrame = vm1.MinFrame;
}
if (e.PropertyName == "Selected_Idx_To")
{
vm1.MaxFrame = (s as ViewModel_HeatDetector).Selected_Idx_To;
vm2.MaxFrame = vm1.MaxFrame;
}
}
public void Wrap_SearchFeaturedBoltsItems()
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Controls;
using C1.WPF.C1Chart;
using System.Windows;
using System.ComponentModel;
namespace Chart_AlarmZones_WPF_CS
{
public class AlarmZone : XYDataSeries
{
#region "constructor"
public AlarmZone()
{
this.LayoutUpdated += new EventHandler(AlarmZone_LayoutUpdated);
this.ChartType = C1.WPF.C1Chart.ChartType.PolygonFilled;
this.XValues = new DoubleCollection();
this.Values = new DoubleCollection();
this.Opacity = 0.5;
UpdateLegend();
Update();
}
#endregion
public static readonly DependencyProperty NearProperty = DependencyProperty.Register("Near", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null,
new PropertyChangedCallback((d, e) =>
{
(d as AlarmZone).Update();
})));
public static readonly DependencyProperty FarProperty = DependencyProperty.Register("Far", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null,
new PropertyChangedCallback((d, e) =>
{
(d as AlarmZone).Update();
})));
public static readonly DependencyProperty LowExtentProperty = DependencyProperty.Register("LowExtent", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null,
new PropertyChangedCallback((d, e) =>
{
(d as AlarmZone).Update();
})));
public static readonly DependencyProperty UpperExtentProperty = DependencyProperty.Register("UpperExtent", typeof(double?), typeof(AlarmZone), new FrameworkPropertyMetadata(null,
new PropertyChangedCallback((d, e) =>
{
(d as AlarmZone).Update();
})));
#region "members"
private C1Chart _chart;
public C1Chart Chart
{
get { return _chart; }
set { _chart = value; }
}
[Bindable(true)]
public double? Near
{
get { return (double?)this.GetValue(NearProperty); }
set
{
this.SetValue(NearProperty, value);
}
}
[Bindable(true)]
public double? Far
{
get { return (double?)this.GetValue(FarProperty); }
set
{
this.SetValue(FarProperty, value);
}
}
[Bindable(true)]
public double? LowExtent
{
get { return (double?)this.GetValue(LowExtentProperty); }
set
{
this.SetValue(LowExtentProperty, value);
}
}
[Bindable(true)]
public double? UpperExtent
{
get { return (double?)this.GetValue(UpperExtentProperty); }
set
{
this.SetValue(UpperExtentProperty, value);
}
}
private bool _showInLegend = false;
public bool ShowInLegend
{
get { return _showInLegend; }
set
{
_showInLegend = value;
UpdateLegend();
}
}
#endregion
#region "implementation"
public void Update()
{
double? _near = Near, _far = Far;
if (_near != null && _far != null)
{
this.XValues.Clear();
this.XValues.Add((double)_near);
this.XValues.Add((double)_far);
this.XValues.Add((double)_far);
this.XValues.Add((double)_near);
}
double? _lowExtent = LowExtent, _upperExtent = UpperExtent;
if (_lowExtent != null && _upperExtent != null)
{
this.Values.Clear();
this.Values.Add((double)_lowExtent);
this.Values.Add((double)_lowExtent);
this.Values.Add((double)_upperExtent);
this.Values.Add((double)_upperExtent);
}
}
public void UpdateLegend()
{
if (_showInLegend)
{
this.Display = SeriesDisplay.SkipNaN;
}
else
{
this.Display = SeriesDisplay.HideLegend;
}
}
private void chart_LayoutUpdated(object sender, EventArgs e)
{
if (this.Chart != null)
{
if (this.Chart.View != null)
{
if (Near == null)
{
Near = Chart.View.AxisX.ActualMin;
Update();
}
if (Far == null)
{
Far = Chart.View.AxisX.ActualMax;
Update();
}
//if (LowExtent == null)
//{
// LowExtent = Chart.View.AxisY.ActualMin;
// Update();
//}
//if (UpperExtent == null)
//{
// UpperExtent = Chart.View.AxisY.ActualMax;
// Update();
//}
}
}
}
// obtains the parent chart control so we can later get axis bounds
void AlarmZone_LayoutUpdated(object sender, EventArgs e)
{
if (this.Parent != null && this.Chart == null)
{
Canvas c = this.Parent as Canvas;
if (c != null)
{
Canvas cv = c.Parent as Canvas;
if (cv != null)
{
Border b = cv.Parent as Border;
if (b != null)
{
Grid g = b.Parent as Grid;
if (g != null)
{
C1Chart chart = g.Parent as C1Chart;
if (chart != null)
{
this.Chart = chart;
this.Chart.LayoutUpdated += chart_LayoutUpdated;
}
}
}
}
}
}
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{
/// <summary>
/// UC_SelectData.xaml 的交互逻辑
/// </summary>
public partial class UC_SelectData : UserControl
{
public UC_SelectData()
{
InitializeComponent();
this.DataContext = new ViewModel_UC_SelectData(DataManager.GetThickDataInstance());
}
private void Button_Click(object sender, RoutedEventArgs e)
{
}
private void uc1_Loaded(object sender, RoutedEventArgs e)
{
(DataContext as ViewModel_UC_SelectData).OnLoaded();
}
}
}
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{
class ViewModel_UC_SelectData : INotifyPropertyChanged
{
public ViewModel_UC_SelectData(IThickHeatData dat)
{
Dat = dat;
DefaultLoadDataRange = new RelayCommand(Command_DefaultLoadDataRange);
ReloadData = new RelayCommand(Command_ReloadData);
PreData = new RelayCommand(Command_PreData);
NextData = new RelayCommand(Command_NextData);
DefaultAnalystData = new RelayCommand(Command_DefaultAnalystData);
Test = new RelayCommand(Command_Test);
Command_DefaultLoadDataRange();
Misc.BindingOperations.SetBinding(Dat, "AnalystIndexFrom", () =>
{
AnalystDataFrom = null;
});
Misc.BindingOperations.SetBinding(Dat, "AnalystIndexTo", () =>
{
AnalystDataTo = null;
});
}
#region UI界面
public IThickHeatData Dat { get; set; } = null;
public DateTime? TotalDataFrom { get; set; } = null;
public int RecordCount
{
get
{
if (Dat is null) return -1;
return Dat.Dat_Times.Count();
}
set
{
}
}
public double[] DS_thick { get; set; }
public double[] DS_2sigma { get; set; }
public DateTime? AnalystDataFrom
{
get
{
if (Dat is null) return null;
if (Dat.AnalystIndexFrom >= 0)
{
return Dat.Dat_Times[Dat.AnalystIndexFrom];
}
return null;
}
set
{
}
}
public DateTime? AnalystDataTo
{
get
{
if (Dat is null) return null;
if (Dat.AnalystIndexTo >= 0)
{
return Dat.Dat_Times[Dat.AnalystIndexTo];
}
return null;
}
set
{
}
}
#endregion
#region 内部功能函数
private void UpdateChart()
{
if (RecordCount <= 0) return;
DS_thick = Dat.Dat_Means.ToArray();
DS_2sigma = Dat.Dat_Sigmas.ToArray();
}
#endregion
#region UI界面按钮功能(Command)
public RelayCommand DefaultLoadDataRange { get; internal set; } = null;
private void Command_DefaultLoadDataRange()
{
Dat.SetLoadDaTaDefault();
}
public RelayCommand ReloadData { get; internal set; } = null;
private void Command_ReloadData()
{
if (Dat is null) return;
Dat.LoadDataFromDB(1);
Dat.ResetCluster();
Dat.ClusterOnThickMean();
RecordCount = 1;
OnLoaded();
//UpdateChart();
}
public RelayCommand PreData { get; internal set; } = null;
private void Command_PreData()
{
int from = 0, to = 0;
if (Dat.CalculateFromToByClass(int.MaxValue, ref from, ref to) < 0) return;
}
public RelayCommand NextData { get; internal set; } = null;
private void Command_NextData()
{
int from = 0, to = 0;
if (Dat.CalculateFromToByClass(int.MinValue, ref from, ref to) < 0) return;
}
public RelayCommand DefaultAnalystData { get; internal set; } = null;
private void Command_DefaultAnalystData()
{
Dat.SetDefaultAnalystIndexs();
}
public RelayCommand Test { get; set; } = null;
private void Command_Test()
{
}
public void OnLoaded()
{
Command_DefaultAnalystData();
UpdateChart();
}
#endregion
public event PropertyChangedEventHandler PropertyChanged;
}
}
......@@ -15,7 +15,11 @@ namespace FLY.HeatingHelper
/// </summary>
public interface IThickHeatData : INotifyPropertyChanged
{
#region 用于UI的接口
#region 用于UI的接口(数据库数据选择接口)
/// <summary>
/// 数据库路径(含数据库名)
/// </summary>
string DBPath { get; set; }
/// <summary>
/// 数据库中存在的数据范围
/// </summary>
......@@ -25,14 +29,33 @@ namespace FLY.HeatingHelper
/// <summary>
/// DataTo和DataSpan确定数据的起始位置,对象中存在的数据范围
/// </summary>
DateTime DataTo { get; set; }
TimeSpan DataSpan { get; set; }
DateTime LoadDataFrom { get; set; }
DateTime LoadDataTo { get; set; }
int LoadDataMinID { get; }
int LoadDataMaxID { get; }
/// <summary>
/// 加载数据时是否过滤掉加热相同的连续数据
/// </summary>
bool IsDataFilter { get; set; }
/// <summary>
/// 重新设定加载数据的缺省范围
/// </summary>
void SetLoadDaTaDefault();
/// <summary>
/// 加载元数据,主要包括数据的范围,即TotalDataFrom和TotalDataTo
/// </summary>
/// <returns></returns>
int LoadMetaDataFromDB();
/// <summary>
/// DFrom和DTo用于确定用于计算的数据
/// 根据上面的设定加载数据,reload=0自动判断是否是否重新加载所有数据,
/// reload=1强制重新加载所有数据
/// reload=-1只加载之后产生的数据
/// </summary>
DateTime DFrom { get; set; }
DateTime DTo { get; set; }
/// <returns></returns>
int LoadDataFromDB(int reload);
#endregion
/// <summary>
/// 风环偏差值
......@@ -40,11 +63,6 @@ namespace FLY.HeatingHelper
int AirRingShift { get; }
StateCode State { get; }
#endregion
/// <summary>
/// 通知新数据产生
/// </summary>
bool NewDataArrived { set; }
int CalculateFromToByClass(int selected_class, ref int from, ref int to);
......@@ -56,7 +74,6 @@ namespace FLY.HeatingHelper
Tuple<int, double> CalculateAirRingShiftFromCorelVector(double[] correlVec);
#endregion
void SetDB(string dbname);
#region 获取数据接口
/// <summary>
......@@ -64,11 +81,19 @@ namespace FLY.HeatingHelper
/// </summary>
/// <param name="idx"></param>
/// <returns></returns>
double[] GetThicks(int idx, int from, int to);
double[] GetHeats(int idx, int from, int to);
double[] GetThicks(int idx, int newResetBolt, double newAngle);
int GetResetBolt(int idx);
double GetRotAngle(int idx);
double[] GetThicksByID(int idx, int from, int to);
double[] GetHeatsByID(int idx, int from, int to);
double[] GetThicksByID(int idx, int newResetBolt, double newAngle);
int GetResetBoltByID(int idx);
double GetRotAngleByID(int idx);
double[] GetThicksByIndex(int idx, int from, int to);
double[] GetHeatsByIndex(int idx, int from, int to);
double[] GetThicksByIndex(int idx, int newResetBolt, double newAngle);
int GetResetBoltByIndex(int idx);
double GetRotAngleByIndex(int idx);
int Index2ID(int idx);
int NormalBolt(int bolt, int boltcnt);
List<DateTime> Dat_Times { get; }
......@@ -87,7 +112,7 @@ namespace FLY.HeatingHelper
int BoltCnt { get; }
double[] HeatEffect { get; set; }
#region 整体分析和局部分析的功能jiekou
#region 整体分析和局部分析的功能接口(数据处理)
List<HeatBoltAnalystItem> SearchFeaturedBoltsItem(int startIdx, int endIdx,
int searchNum, int maxFrameInterval, int heatRating,
int neglectHeatRate, int Separation, int shiftRange);
......@@ -107,6 +132,29 @@ namespace FLY.HeatingHelper
Tuple<int, double, double> SearchMaxSimilarity(int idxL, int idxB, double searchRange, bool SearchRotAngle);
#endregion
#region 数据处理-数据分类接口
/// <summary>
/// 初始化聚类数据,类清空。
/// </summary>
void ResetCluster();
/// <summary>
/// 依据厚度均值进行聚类
/// </summary>
void ClusterOnThickMean();
/// <summary>
/// 选择用于分析的数据项范围
/// </summary>
int AnalystIndexFrom { get; set; }
int AnalystIndexTo { get; set; }
/// <summary>
/// 设定缺省的分析数据范围
/// </summary>
/// <returns></returns>
int SetDefaultAnalystIndexs();
#endregion
#region 数据库数据变化后自动运行
List<ThickHeatEvent> AutoDetectEvents { get; }
......@@ -123,7 +171,9 @@ namespace FLY.HeatingHelper
/// 检查数据库,当数据库有新数据时,更新DataTo属性,并读取新数据到对象中。该函数可以一定时间间隔执行。
/// </summary>
void RefreshData();
bool IsDataReady { get; }
int DataChanged { get; set; }
//bool IsDataReady { get; }
bool BeginUse(bool isAsync = true);
void EndUse();
......
......@@ -61,22 +61,22 @@ namespace FLY.HeatingHelper
var result = db.Database.SqlQuery<Temp>("SELECT min(\"结束时间\")as A,MAX(\"结束时间\") as B from HeatData").First();
TotalDataFrom = DateTime.Parse(result.A);
TotalDataTo = DateTime.Parse(result.B);
DataTo = new DateTime(TotalDataTo.Ticks);
DataSpan = new TimeSpan(2, 0, 0, 0);
LoadDataTo = new DateTime(TotalDataTo.Ticks);
LoadDataSpan = new TimeSpan(2, 0, 0, 0);
//DataFrom = DBTo - new TimeSpan(2, 0, 0, 0);
}
string cmdstr;
if (reload || _dat_times.Count() <= 0)
{
cmdstr = string.Format("select * from [HeatData2] where 结束时间>=\"{0}\" and 结束时间<=\"{1}\"",
(DataTo - DataSpan).ToString("yyyy-MM-dd HH:mm:ss"),
DataTo.ToString("yyyy-MM-dd HH:mm:ss"));
(LoadDataTo - LoadDataSpan).ToString("yyyy-MM-dd HH:mm:ss"),
LoadDataTo.ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
cmdstr = string.Format("select * from [HeatData2] where 结束时间>=\"{0}\" and 结束时间<=\"{1}\"",
(_dat_times.Last()).ToString("yyyy-MM-dd HH:mm:ss"),
DataTo.ToString("yyyy-MM-dd HH:mm:ss"));
LoadDataTo.ToString("yyyy-MM-dd HH:mm:ss"));
}
SQLiteDataAdapter dbDataAdapter = new SQLiteDataAdapter(cmdstr, connectionString);
SQLiteCommandBuilder cb = new SQLiteCommandBuilder(dbDataAdapter);
......@@ -90,13 +90,14 @@ namespace FLY.HeatingHelper
/// <summary>
/// 从dataTable中提取数据到内部缓冲区
/// </summary>
protected override void FetchData()
protected override int FetchData()
{
_dat_times.Clear();
_thicks.Clear();
_thick_means.Clear();
_thick_2sigmas.Clear();
_heats.Clear();
int cnt = 0;
int i = 1;
foreach (DataRow dr in dataTable.Rows)
{
......@@ -139,10 +140,11 @@ namespace FLY.HeatingHelper
_heats.Add(heat.ToArray());
_resetBolts.Add(dr.Field<int>("复位区号"));
_rotAngles.Add(dr.Field<double>("旋转角度°"));
cnt++;
}
BoltCnt = _thicks[0].Count();
DFrom = _dat_times.First();
DTo = _dat_times.Last();
DataChanged++;
return cnt;
}
/// <summary>
......@@ -196,11 +198,20 @@ namespace FLY.HeatingHelper
_heats.Add(heat.ToArray());
cnt++;
}
DFrom = _dat_times.First();
DTo = _dat_times.Last();
DataChanged++;
return cnt;
}
public override int LoadMetaDataFromDB()
{
throw new NotImplementedException();
}
public override int LoadDataFromDB(int reload)
{
throw new NotImplementedException();
}
private DataTable dataTable = new DataTable();
#endregion
}
......
......@@ -52,7 +52,7 @@ namespace FLY.HeatingHelper
//string connectionString = ConfigurationManager.ConnectionStrings[DBName].ConnectionString.ToString();
//using (db = new Model.Model_HeatData(DBName))
//{
// var result = db.Database.SqlQuery<Temp>("SELECT min(\"EndTime\")as A,MAX(\"EndTime\") as B from ThickHeat").First();
// var result = db.Database.SqlQuery<Temp>("SELECT min(\"Time\")as A,MAX(\"Time\") as B from ThickHeat").First();
// TotalDataFrom = DateTime.Parse(result.A);
// TotalDataTo = DateTime.Parse(result.B);
// DataTo = new DateTime(TotalDataTo.Ticks);
......@@ -60,18 +60,18 @@ namespace FLY.HeatingHelper
// //DataFrom = DBTo - new TimeSpan(2, 0, 0, 0);
//}
mSQLiteHelper.ConnectionString = ConnectionString;
var dtb = mSQLiteHelper.ExecuteReader("SELECT min(\"EndTime\")as A,MAX(\"EndTime\") as B from ThickHeat");
var dtb = mSQLiteHelper.ExecuteReader("SELECT min(\"Time\")as A,MAX(\"Time\") as B from ThickHeat");
if (dtb.Rows[0].IsNull("A")) return;
TotalDataFrom = DateTime.Parse(dtb.Rows[0].Field<string>("A"));
TotalDataTo = DateTime.Parse(dtb.Rows[0].Field<string>("B"));
DataTo = new DateTime((TotalDataTo+new TimeSpan(0,0,1)).Ticks);
DataSpan = new TimeSpan(2, 0, 0, 0);
LoadDataTo = new DateTime((TotalDataTo+new TimeSpan(0,0,1)).Ticks);
LoadDataSpan = new TimeSpan(2, 0, 0, 0);
string cmdstr;
if (reload || _ids.Count() == 0)
{
cmdstr = string.Format("select * from [ThickHeat] where IsStable=1 and EndTime>=\"{0}\" and EndTime<=\"{1}\"",
(DataTo - DataSpan).ToString("yyyy-MM-dd HH:mm:ss"),
DataTo.ToString("yyyy-MM-dd HH:mm:ss"));
cmdstr = string.Format("select * from [ThickHeat] where IsStable=1 and Time>=\"{0}\" and Time<=\"{1}\"",
(LoadDataTo - LoadDataSpan).ToString("yyyy-MM-dd HH:mm:ss"),
LoadDataTo.ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
......@@ -94,7 +94,7 @@ namespace FLY.HeatingHelper
/// <summary>
/// 从dataTable中提取数据到内部缓冲区
/// </summary>
protected override void FetchData()
protected override int FetchData()
{
_dat_times.Clear();
_thicks.Clear();
......@@ -102,30 +102,33 @@ namespace FLY.HeatingHelper
_thick_2sigmas.Clear();
_heats.Clear();
_ids.Clear();
_resetBolts.Clear();
_rotAngles.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)
if ((_heats.Count() > 0) && IsDataFilter)
{
if (IsHeatSame(h1, _heats.Last())) DeleteDataLast();
}
_ids.Add((int)dr.Field<long>("ID"));
_dat_times.Add(dr.Field<DateTime>("EndTime"));
_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);
_thick_2sigmas.Add(r.Item2 * 2);
_resetBolts.Add((int)dr.Field<long>("OrgBoltNo"));
_rotAngles.Add(dr.Field<double>("RAngle"));
cnt++;
}
BoltCnt = _thicks[0].Count();
DFrom = _dat_times.First();
DTo = _dat_times.Last();
return cnt;
}
/// <summary>
......@@ -144,24 +147,22 @@ namespace FLY.HeatingHelper
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 ((_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>("EndTime"));
_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);
_thick_2sigmas.Add(r.Item2 * 2);
_resetBolts.Add((int)dr.Field<long>("OrgBoltNo"));
_rotAngles.Add(dr.Field<double>("RAngle"));
cnt++;
}
DFrom = _dat_times.First();
DTo = _dat_times.Last();
return cnt;
}
......@@ -195,6 +196,52 @@ namespace FLY.HeatingHelper
_rotAngles.RemoveAt(idx);
}
public override int LoadMetaDataFromDB()
{
mSQLiteHelper.ConnectionString = ConnectionString;
var dtb = mSQLiteHelper.ExecuteReader("SELECT min(\"Time\")as A,MAX(\"Time\") as B from ThickHeat");
if (dtb.Rows[0].IsNull("A")) return -1;
TotalDataFrom = DateTime.Parse(dtb.Rows[0].Field<string>("A"));
TotalDataTo = DateTime.Parse(dtb.Rows[0].Field<string>("B"));
return 0;
}
public override int LoadDataFromDB(int reload)
{
mSQLiteHelper.ConnectionString = ConnectionString;
string cmdstr;
bool clear = false;
if ((reload == 0 && _ids.Count() == 0) || (reload == 1))
{
clear = true;
cmdstr = string.Format("select * from [ThickHeat] where IsStable=1 and Time>=\"{0}\" and Time<=\"{1}\"",
LoadDataFrom.ToString("yyyy-MM-dd HH:mm:ss"),
LoadDataTo.ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
cmdstr = string.Format("select * from [ThickHeat] where ID>\"{0}\" and IsStable=1", _ids.Last());
}
try
{
dataTable = mSQLiteHelper.ExecuteReader(cmdstr);
if (clear)
{
return FetchData();
}
else
{
return FetchNewData();
}
}
catch
{
return -99;
}
}
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