Commit 58b34086 authored by 540597360@qq.com's avatar 540597360@qq.com

Fix Bugs

parent 6effbe49
......@@ -210,6 +210,10 @@
<Project>{119c3adc-f8e1-4f72-b89b-006236ff8586}</Project>
<Name>FLY.ControlLibrary</Name>
</ProjectReference>
<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.FLY.UI.Module\FLY.UI.Module\FLY.UI.Module.csproj">
<Project>{4df79671-e814-49bd-864d-8257d6c6e072}</Project>
<Name>FLY.UI.Module</Name>
......
......@@ -68,10 +68,15 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<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}"/>
<RadioButton Content="无锁定" Grid.Column="3" IsChecked="{Binding LockFrames,Converter={StaticResource lfc},ConverterParameter=0}"/>
<CheckBox IsChecked="{Binding LockAngle}" Content="锁定旋转角" Grid.Row="1" Grid.ColumnSpan="2"/>
</Grid>
<Grid DockPanel.Dock="Top">
<ProgressBar Value="{Binding SearchProgressValue}" Width="{Binding ElementName=searchBtn, Path=ActualWidth}"/>
......
......@@ -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;
......@@ -185,8 +187,6 @@ namespace FLY.HeatingHelper.UI.UIModule
//tmpVM.PropertyChanged += DataSelecter_PropertyChanged;
vm1.OnLoaded(true);
vm2.OnLoaded();
vm1.UpdateChart();
vm2.UpdateChart();
UpdateData(1);
UpdateData(2);
UpdateVarChart();
......@@ -430,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)
......
......@@ -22,8 +22,8 @@
</Setter>
</Style>
<Style TargetType="{x:Type c1c:C1Chart}">
<Setter Property="Foreground" Value="#FFF0F8FE" />
<Setter Property="Background" Value="#4C000F14" />
<!--<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" />
......@@ -37,24 +37,38 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Row="0">
<c1c:C1Chart x:Name="myChart" ChartType="Line" Margin="5,0,0,0">
<c1c:C1Chart.Data>
<c1c:ChartData>
<c1c:DataSeries Values="{Binding DS_thick}" AxisY="ay0" Label="厚度"/>
<c1c:DataSeries Values="{Binding DS_heat}" AxisY="ay1" Label="加热率"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
<c1c:ChartView>
<c1c:ChartView.AxisY>
<c1c:Axis Visible="False"/>
</c1c:ChartView.AxisY>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"/>
<c1c:Axis Name="ay1" AxisType="Y" Title="加热率" Position="Far"/>
</c1c:ChartView>
</c1c:C1Chart.View>
<c1c:Legend Position="Right" />
</c1c:C1Chart>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<c1c:C1Chart x:Name="myChart" ChartType="Line" Margin="5,0,0,0">
<c1c:C1Chart.Data>
<c1c:ChartData>
<c1c:DataSeries Values="{Binding DS_thick}" AxisY="ay0" Label="厚度" ChartType="Column"
PlotElementLoaded="DataSeries_PlotElementLoaded"/>
<c1c:DataSeries Values="{Binding DS_heat}" AxisY="ay1" Label="加热率"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
<c1c:ChartView>
<c1c:ChartView.AxisY>
<c1c:Axis Visible="False"/>
</c1c:ChartView.AxisY>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"
Min="{Binding AsisY_Min}"
Max="{Binding AsisY_Max}"
ItemsSource="{Binding AsisY_Ticks}"/>
<c1c:Axis Name="ay1" AxisType="Y" Title="加热率" Position="Far"
Min="0" Max="100"/>
</c1c:ChartView>
</c1c:C1Chart.View>
</c1c:C1Chart>
<Slider Grid.Row="1" Margin="20,3,20,3"
Minimum="{Binding MinFrame}"
Maximum="{Binding MaxFrame}"
Value="{Binding SelectedFrame}"/>
</Grid>
</Border>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock Text="{Binding FrameID,StringFormat=ID:{0}, Mode=OneWay}" Margin="0,0,5,0"/>
......
......@@ -25,67 +25,15 @@ namespace FLY.HeatingHelper.UI.UIModule
/// </summary>
public partial class UC_FramePicker : UserControl
{
#region SelectedFrame属性
public static readonly DependencyProperty SelectedFrameProperty =
DependencyProperty.Register(
"SelectedFrame", typeof(Int32), typeof(UC_FramePicker),
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnSelectedFrameChanged)));
public Int32 SelectedFrame
{
get { return (Int32)GetValue(SelectedFrameProperty); }
set { SetValue(SelectedFrameProperty, value); }
}
private static void OnSelectedFrameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
UC_FramePicker control = (UC_FramePicker)obj;
//RoutedPropertyChangedEventArgs<decimal> e = new RoutedPropertyChangedEventArgs<decimal>(
// (decimal)args.OldValue, (decimal)args.NewValue, ValueChangedEvent);
RoutedPropertyChangedEventArgs<decimal> e = new RoutedPropertyChangedEventArgs<decimal>(
(decimal)args.OldValue, (decimal)args.NewValue);
control.OnValueChanged(e);
}
protected virtual void OnValueChanged(RoutedPropertyChangedEventArgs<decimal> args)
{
RaiseEvent(args);
}
#endregion
#region MinFrame属性
public static readonly DependencyProperty MinFrameProperty =
DependencyProperty.Register(
"MinFrame", typeof(Int32), typeof(UC_FramePicker),
new FrameworkPropertyMetadata());
public Int32 MinFrame
{
get { return (Int32)GetValue(MinFrameProperty); }
set { SetValue(MinFrameProperty, value); }
}
#endregion
#region MaxFrame属性
public static readonly DependencyProperty MaxFrameProperty =
DependencyProperty.Register(
"MaxFrame", typeof(Int32), typeof(UC_FramePicker),
new FrameworkPropertyMetadata());
public Int32 MaxFrame
{
get { return (Int32)GetValue(MaxFrameProperty); }
set { SetValue(MaxFrameProperty, value); }
}
#endregion
public UC_FramePicker()
{
InitializeComponent();
//myChart.Data.Children
}
private void DataSeries_PlotElementLoaded(object sender, EventArgs e)
{
(DataContext as UC_FramePickerViewModel).PELoaded(sender, e);
}
}
public class UC_FramePickerViewModel : INotifyPropertyChanged
......@@ -125,11 +73,11 @@ namespace FLY.HeatingHelper.UI.UIModule
{
if (_minFrame != value)
{
_minFrame = value;
if (SelectedFrame < _minFrame)
if (SelectedFrame < value)
{
SelectedFrame = _minFrame;
SelectedFrame = value;
}
_minFrame = value;
}
}
}
......@@ -145,11 +93,11 @@ namespace FLY.HeatingHelper.UI.UIModule
{
if (_maxFrame != value)
{
_maxFrame = value;
if (SelectedFrame > _maxFrame)
if (SelectedFrame > value)
{
SelectedFrame = _maxFrame;
SelectedFrame = value;
}
_maxFrame = value;
}
}
}
......@@ -196,7 +144,8 @@ namespace FLY.HeatingHelper.UI.UIModule
get
{
if (_data == null) return DateTime.MinValue;
if (SelectedFrame < MinFrame && SelectedFrame > MaxFrame) return DateTime.MinValue;
if (SelectedFrame < MinFrame || SelectedFrame > MaxFrame) return DateTime.MinValue;
if (SelectedFrame < 0 || SelectedFrame > _data.Dat_Times.Count()) return DateTime.MinValue;
return _data.Dat_Times[SelectedFrame];
}
}
......@@ -256,38 +205,30 @@ namespace FLY.HeatingHelper.UI.UIModule
public DoubleCollection DS_heat { get; set; }
public void UpdateChart()
public double Thick_Mean { get; set; }
public double AsisY_Min { get; set; }
public double AsisY_Max { get; set; }
public List<KeyValuePair<object, double>> AsisY_Ticks { get; set; }
public void PELoaded(object s, EventArgs e)
{
double[] tmp = _data.GetThicksByIndex(SelectedFrame, ResetBolt, RotAngle);
double[] tmph = _data.GetHeatsByIndex(SelectedFrame, -1, -1);
if (tmp == null || tmph == null) return;
DS_thick = new DoubleCollection(tmp);
DS_heat = new DoubleCollection(tmph);
//if (MySeries.Count == 0)
//{
// var L1 = new LineSeries
// {
// Title = "厚度",
// Values = v1,
// DataLabels = false,
// Fill = new SolidColorBrush(Colors.Transparent),
// PointGeometrySize = 3,
// ScalesYAt = 0,
// };
// var L2 = new LineSeries
// {
// Title = "加热率",
// Values = v2,
// DataLabels = false,
// Fill = new SolidColorBrush(Colors.Transparent),
// PointGeometrySize = 3,
// ScalesYAt = 1,
// };
// MySeries.Add(L1);
// MySeries.Add(L2);
//}
//v1.Clear(); v1.AddRange(_data.GetThicksByID(SelectedFrame, ResetBolt, RotAngle));
//v2.Clear(); v2.AddRange(_data.GetHeatsByID(SelectedFrame, -1, -1));
PlotElement pe = s as PlotElement;
double v = Math.Abs(pe.DataPoint.Value);
if(v <=AsisY_Max / 3)
{
pe.Fill = new SolidColorBrush(Colors.Green);
}
else if (v <= AsisY_Max * 2 / 3)
{
pe.Fill = new SolidColorBrush(Colors.Yellow);
}
else
{
pe.Fill = new SolidColorBrush(Colors.Red);
}
}
private void UpdateData()
......@@ -295,7 +236,29 @@ namespace FLY.HeatingHelper.UI.UIModule
if (SelectedFrame < 0) return;
ResetBolt = _data.GetResetBoltByIndex(SelectedFrame);
RotAngle = _data.GetRotAngleByIndex(SelectedFrame);
UpdateChart();
Thick_Mean = _data.Dat_Means[SelectedFrame];
double[] tmp = _data.GetThicksByIndex(SelectedFrame, ResetBolt, RotAngle);
double[] tmph = _data.GetHeatsByIndex(SelectedFrame, -1, -1);
if (tmp == null || tmph == null) return;
for(int i=0;i<tmp.Count();i++)
{
if (double.IsNaN(tmp[i])) continue;
tmp[i] -= Thick_Mean;
}
AsisY_Min = - Thick_Mean * 0.09;
AsisY_Max = Thick_Mean * 0.09;
AsisY_Ticks = new List<KeyValuePair<object, double>>
{
new KeyValuePair<object, double>(Thick_Mean.ToString("F1"), 0),
new KeyValuePair<object, double>("3%", Thick_Mean * 0.03),
new KeyValuePair<object, double>("-3%", -Thick_Mean * 0.03),
new KeyValuePair<object, double>("6%", Thick_Mean * 0.06),
new KeyValuePair<object, double>("-6%", -Thick_Mean * 0.06),
new KeyValuePair<object, double>("9%", Thick_Mean * 0.09),
new KeyValuePair<object, double>("-9%", -Thick_Mean * 0.09)
};
DS_thick = new DoubleCollection(tmp);
DS_heat = new DoubleCollection(tmph);
}
public void InitCmd()
......
......@@ -85,8 +85,6 @@ namespace FLY.HeatingHelper.UI.UIModule
vm1.InitData(mdata);
vm2.InitData(mdata);
vmDiff.Init(mdata);
vm1.UpdateChart();
vm2.UpdateChart();
}
public void UnLoaded(object s)
......
......@@ -98,7 +98,25 @@
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="0" Margin="0,0,5,0">
<Label Content="分析数据范围:"/>
<StackPanel Orientation="Horizontal">
<Label Content="分析数据范围:"/>
<TextBlock Margin="10,5">
<TextBlock.Text>
<MultiBinding StringFormat="{}({0:MM/dd HH:mm:ss})-({1:MM/dd HH:mm:ss})">
<Binding Path="AnalystDataFrom" />
<Binding Path="AnalystDataTo" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Margin="10,5">
<TextBlock.Text>
<MultiBinding StringFormat="{}({0})-({1})">
<Binding Path="Dat.AnalystIndexFrom" />
<Binding Path="Dat.AnalystIndexTo" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
<Controls:RangeSlider Minimum="0"
Maximum="{Binding RecordCount, Mode=OneWay}"
LowerValue="{Binding Dat.AnalystIndexFrom}"
......@@ -129,6 +147,7 @@
UpperExtent="11"
ConnectionFill="AliceBlue"/>
<c1c:DataSeries ValuesSource="{Binding DS_thick}" AxisY="ay0" Label="厚度"/>
<c1c:DataSeries ValuesSource="{Binding DS_2sigma}" AxisY="ay1" Label="2Sigma"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
......@@ -137,9 +156,12 @@
<c1c:Axis Visible="False" Min="0" Max="10"/>
</c1c:ChartView.AxisY>
<c1c:ChartView.AxisX>
<c1c:Axis Max="{Binding RecordCount, Mode=OneWay}"/>
<c1c:Axis Max="{Binding RecordCount, Mode=OneWay}" />
</c1c:ChartView.AxisX>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"/>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"
/>
<c1c:Axis Name="ay1" AxisType="Y" Title="2Sigma" Position="Far"
Min="-2" Max="20"/>
</c1c:ChartView>
</c1c:C1Chart.View>
</c1c:C1Chart>
......
......@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
......@@ -20,6 +21,14 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
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界面
......@@ -41,6 +50,40 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
}
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 内部功能函数
......@@ -48,6 +91,7 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{
if (RecordCount <= 0) return;
DS_thick = Dat.Dat_Means.ToArray();
DS_2sigma = Dat.Dat_Sigmas.ToArray();
}
#endregion
......@@ -68,7 +112,8 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
Dat.ResetCluster();
Dat.ClusterOnThickMean();
RecordCount = 1;
UpdateChart();
OnLoaded();
//UpdateChart();
}
public RelayCommand PreData { get; internal set; } = null;
......
......@@ -1357,7 +1357,7 @@ namespace FLY.HeatingHelper
int shift = r.Item1;
if (maxcorel < r.Item2)
{
maxcorel = max;
maxcorel = r.Item2;
theshift = shift;
}
}
......
......@@ -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,7 +60,7 @@ 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"));
......@@ -69,7 +69,7 @@ namespace FLY.HeatingHelper
string cmdstr;
if (reload || _ids.Count() == 0)
{
cmdstr = string.Format("select * from [ThickHeat] where IsStable=1 and EndTime>=\"{0}\" and EndTime<=\"{1}\"",
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"));
}
......@@ -102,6 +102,8 @@ namespace FLY.HeatingHelper
_thick_2sigmas.Clear();
_heats.Clear();
_ids.Clear();
_resetBolts.Clear();
_rotAngles.Clear();
int cnt = 0;
foreach (DataRow dr in dataTable.Rows)
{
......@@ -114,13 +116,13 @@ namespace FLY.HeatingHelper
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++;
......@@ -152,11 +154,11 @@ namespace FLY.HeatingHelper
_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++;
......@@ -197,7 +199,7 @@ namespace FLY.HeatingHelper
public override int LoadMetaDataFromDB()
{
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 -1;
TotalDataFrom = DateTime.Parse(dtb.Rows[0].Field<string>("A"));
TotalDataTo = DateTime.Parse(dtb.Rows[0].Field<string>("B"));
......@@ -213,7 +215,7 @@ namespace FLY.HeatingHelper
if ((reload == 0 && _ids.Count() == 0) || (reload == 1))
{
clear = true;
cmdstr = string.Format("select * from [ThickHeat] where IsStable=1 and EndTime>=\"{0}\" and EndTime<=\"{1}\"",
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"));
}
......
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