Commit 20657021 authored by 潘栩锋's avatar 潘栩锋 🚴

合并 glee08 修复20200317 bug

parents f0822f1a c315aef5
......@@ -4,8 +4,9 @@
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"
mc:Ignorable="d" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded" d:DesignHeight="450" d:DesignWidth="800">
xmlns:c1c="clr-namespace:C1.WPF.C1Chart;assembly=C1.WPF.C1Chart.4.5.2"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
......@@ -40,23 +41,26 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2">
<lvc:CartesianChart Series="{Binding VarSeries}" Margin="3"
DisableAnimations="True"
Hoverable="False"
DataTooltip="{x:Null}"
LegendLocation="Top"
FontSize="16">
<lvc:CartesianChart.AxisY>
<lvc:Axis Foreground="DodgerBlue" Title="厚度变化">
</lvc:Axis>
<lvc:Axis 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>
<!--<DockPanel Grid.Column="2">
<TextBlock Text="锁定设置:" Style="{StaticResource TextBlockStyle_FieldHeader}" HorizontalAlignment="Center" DockPanel.Dock="Top"/>
......
......@@ -108,6 +108,9 @@ namespace FLY.HeatingHelper.UI.UIModule
public SeriesCollection VarSeries { get; set; } = new SeriesCollection();
public double[] DS_vthick { get; protected set; } = null;
public double[] DS_vheat { get; protected set; } = null;
private IThickHeatData _data;
private int _airRingShift = 0;
......@@ -309,10 +312,13 @@ namespace FLY.HeatingHelper.UI.UIModule
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);
var tmp = vth.Concat(vth).Skip(cnt-s).Take(cnt).ToArray();
var vheat = DataHelper.VectorSub(vheat2, vheat1);
DS_vthick = tmp;
DS_vheat = vheat;
tv.Clear();tv.AddRange(tmp);
hv.Clear();hv.AddRange(vheat);
if (VarSeries.Count == 0)
......
......@@ -200,7 +200,7 @@ namespace FLY.HeatingHelper.UI.UIModule
//private ChartValues<double> v1 = new ChartValues<double>();
//private ChartValues<double> v2 = new ChartValues<double>();
#region For C1Chart
public DoubleCollection DS_thick { get; set; }
public DoubleCollection DS_heat { get; set; }
......@@ -230,7 +230,7 @@ namespace FLY.HeatingHelper.UI.UIModule
pe.Fill = new SolidColorBrush(Colors.Red);
}
}
#endregion
private void UpdateData()
{
if (SelectedFrame < 0) return;
......
......@@ -75,6 +75,7 @@
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Margin="15,0,15,0">
<Controls:ToggleSwitch Content="过滤加热重复项" Margin="0,10,0,15" IsChecked="{Binding Path=Dat.IsDataFilter}" FontFamily="YouYuan" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" FontSize="20"/>
<Controls:ToggleSwitch Content="过滤不稳定数据" Margin="0,10,0,15" IsChecked="{Binding Path=Dat.IsFilterUnstable}" FontFamily="YouYuan" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" FontSize="20"/>
<Button Content="缺省数据范围" FontFamily="YouYuan" Margin="0,0,0,10"
Style="{DynamicResource AccentedSquareButtonStyle}"
Command="{Binding DefaultLoadDataRange}"/>
......@@ -139,30 +140,41 @@
Style="{DynamicResource AccentedSquareButtonStyle}"/>
</Grid>
<Border Grid.Row="2" Margin="2,5,2,2">
<c1c:C1Chart ChartType="Line" Margin="5,0,0,0">
<c1c:C1Chart Name="c1chart" ChartType="columnstacked"
Margin="5,0,0,0" FontSize="12" Loaded="C1chart_Loaded">
<c1c:C1Chart.Data>
<c1c:ChartData>
<az:AlarmZone Near="{Binding Dat.AnalystIndexFrom}"
<c1c:DataSeries ValuesSource="{Binding DS_2sigma}" RenderMode="Default" PlotElementLoaded="DataSeries_PlotElementLoaded"/>
<c1c:DataSeries ValuesSource="{Binding DS_2sigmaN}" RenderMode="Default" PlotElementLoaded="DataSeries_PlotElementLoaded"/>
<az:AlarmZone Near="{Binding Dat.AnalystIndexFrom}" AxisY="ay1"
Far="{Binding Dat.AnalystIndexTo}"
LowExtent="-1"
UpperExtent="11"
ConnectionFill="AliceBlue"/>
<c1c:DataSeries ValuesSource="{Binding DS_thick}" AxisY="ay0" Label="厚度"/>
<c1c:DataSeries ValuesSource="{Binding DS_2sigma}" AxisY="ay1" Label="2Sigma"/>
<c1c:DataSeries ValuesSource="{Binding DS_thick}" AxisY="ay0" Label="厚度" ChartType="line"/>
</c1c:ChartData>
</c1c:C1Chart.Data>
<c1c:C1Chart.View>
<c1c:ChartView>
<c1c:ChartView.PlotAreaRowDefinitions>
<c1c:PlotAreaRowDefinition Height="*"/>
<c1c:PlotAreaRowDefinition Height="*"/>
</c1c:ChartView.PlotAreaRowDefinitions>
<c1c:ChartView.PlotAreas>
<c1c:PlotArea/>
<c1c:PlotArea Row="1"/>
</c1c:ChartView.PlotAreas>
<c1c:ChartView.AxisY>
<c1c:Axis Visible="False" Min="0" Max="10"/>
<c1c:Axis Title="2Sigma" Position="Near"
Min="-0.09" Max="0.09" PlotAreaIndex="0" MajorGridStroke="Blue"
MajorUnit="0.03"/>
</c1c:ChartView.AxisY>
<c1c:ChartView.AxisX>
<c1c:Axis Max="{Binding RecordCount, Mode=OneWay}" />
<c1c:Axis Max="{Binding RecordCount, Mode=OneWay}" Min="0"/>
</c1c:ChartView.AxisX>
<c1c:Axis Name="ay0" AxisType="Y" Title="厚度" Position="Near"
/>
<c1c:Axis Name="ay1" AxisType="Y" Title="2Sigma" Position="Far"
Min="-2" Max="20"/>
PlotAreaIndex="1"/>
<c1c:Axis Visible="False" Min="0" Max="10" PlotAreaIndex="1" Name="ay1"/>
</c1c:ChartView>
</c1c:C1Chart.View>
</c1c:C1Chart>
......
using System;
using C1.WPF.C1Chart;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -35,5 +36,15 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{
(DataContext as ViewModel_UC_SelectData).OnLoaded();
}
private void DataSeries_PlotElementLoaded(object sender, EventArgs e)
{
(DataContext as ViewModel_UC_SelectData).PlotElementLoaded(sender, e);
}
private void C1chart_Loaded(object sender, RoutedEventArgs e)
{
LineAreaOptions.SetOptimizationRadius(c1chart, 5);
}
}
}
using GalaSoft.MvvmLight.Command;
using C1.WPF.C1Chart;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -6,6 +7,7 @@ using System.Linq;
using System.ServiceModel.Channels;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{
......@@ -52,6 +54,7 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
public double[] DS_thick { get; set; }
public double[] DS_2sigma { get; set; }
public double[] DS_2sigmaN { get; set; }
public DateTime? AnalystDataFrom
{
......@@ -92,10 +95,45 @@ namespace FLY.HeatingHelper.UI.UIModule.UC_SelectData
{
if (RecordCount <= 0) return;
DS_thick = Dat.Dat_Means.ToArray();
DS_2sigma = Dat.Dat_Sigmas.ToArray();
double[] tmp0 = Dat.Dat_Sigmas.ToArray();
int cnt = tmp0.Count();
double[] tmp = new double[cnt];
for (int i = 0; i < cnt; i++)
{
if (double.IsNaN(DS_thick[i]))
{
tmp[i] = tmp0[i] = double.NaN;
}
if (Math.Abs(DS_thick[i]) < 1)
{
tmp[i] = tmp0[i] = double.NaN;
}
tmp0[i] = tmp0[i] / DS_thick[i];
tmp[i] = -tmp0[i];
}
DS_2sigma = tmp0;
DS_2sigmaN = tmp;
}
#endregion
public void PlotElementLoaded(object s, EventArgs e)
{
PlotElement pe = s as PlotElement;
double v = Math.Abs(pe.DataPoint.Value);
if (v <= 0.03)
{
pe.Fill = new SolidColorBrush(Colors.Green);
}
else if (v <= 0.06)
{
pe.Fill = new SolidColorBrush(Colors.Yellow);
}
else
{
pe.Fill = new SolidColorBrush(Colors.Red);
}
}
#region UI界面按钮功能(Command)
public RelayCommand DefaultLoadDataRange { get; internal set; } = null;
......
......@@ -39,6 +39,10 @@ namespace FLY.HeatingHelper
/// </summary>
bool IsDataFilter { get; set; }
/// <summary>
/// 加载数据时是否过滤掉没有稳定的数据
/// </summary>
bool IsFilterUnstable { get; set; }
/// <summary>
/// 重新设定加载数据的缺省范围
/// </summary>
void SetLoadDaTaDefault();
......
......@@ -147,6 +147,11 @@ namespace FLY.HeatingHelper
/// 加载数据时是否过滤掉加热相同的连续数据
/// </summary>
public bool IsDataFilter { get; set; } = true;
/// <summary>
/// 加载数据时是否过滤掉没有稳定的数据
/// </summary>
public bool IsFilterUnstable { get; set; } = true;
/// <summary>
/// 重新设定加载数据的缺省范围
/// </summary>
......@@ -445,8 +450,34 @@ namespace FLY.HeatingHelper
}
}
public int AnalystIndexFrom { get; set; }
public int AnalystIndexTo { get; set; }
private int _analystIndexFrom = -1;
public int AnalystIndexFrom
{
get => _analystIndexFrom;
set
{
int cnt = _dat_times.Count();
if (cnt <= 0) return;
if (value >= 0 && value < cnt)
{
_analystIndexFrom = value;
}
}
}
private int _analystIndexTo = -1;
public int AnalystIndexTo
{
get => _analystIndexTo;
set
{
int cnt = _dat_times.Count();
if (cnt <= 0) return;
if(value >=0 && value < cnt)
{
_analystIndexTo = value;
}
}
}
/// <summary>
/// 设定缺省的分析数据范围
/// </summary>
......@@ -788,6 +819,7 @@ namespace FLY.HeatingHelper
}
public double[] GetThicksByIndex(int idx,int from, int to)
{
if (idx < 0) return null;
int cnt = _thicks[0].Count();
if ((to >= cnt) || (to < 0)) to = cnt - 1;
if ((from < 0) || (from > to)) from = 0;
......@@ -817,6 +849,7 @@ namespace FLY.HeatingHelper
}
public double[] GetThicksByIndex(int idx, int newResetBolt, double newAngle)
{
if (idx < 0) return null;
double[] ret = GetThicksByIndex(idx, -1, -1);
if (ret is null) return null;
int index = idx;
......@@ -853,6 +886,7 @@ namespace FLY.HeatingHelper
}
public double[] GetHeatsByIndex(int idx, int from, int to)
{
if (idx < 0) return null;
int cnt = _heats[0].Count();
if ((to >= cnt) || (to < 0)) to = cnt - 1;
if ((from < 0) || (from > to)) from = 0;
......@@ -873,6 +907,7 @@ namespace FLY.HeatingHelper
}
public int GetResetBoltByIndex(int idx)
{
if (idx < 0) return -1;
return _resetBolts[idx];
}
......@@ -889,12 +924,12 @@ namespace FLY.HeatingHelper
}
public double GetRotAngleByIndex(int idx)
{
return _rotAngles[idx];
return idx < 0 ? -1 : _rotAngles[idx];
}
public int Index2ID(int idx)
{
if (idx < _ids.Count()) return _ids[idx];
if (idx >= 0 && idx < _ids.Count()) return _ids[idx];
return -1;
}
......@@ -1492,7 +1527,10 @@ namespace FLY.HeatingHelper
{
if (BeginUse())
{
bool tmp = IsFilterUnstable;
IsFilterUnstable = true;
RefreshData();
IsFilterUnstable = tmp;
EndUse();
Thread.Sleep(1000 * 60);
}
......
......@@ -69,13 +69,21 @@ namespace FLY.HeatingHelper
string cmdstr;
if (reload || _ids.Count() == 0)
{
if(IsFilterUnstable)
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
cmdstr = string.Format("select * from [ThickHeat] where Time>=\"{0}\" and Time<=\"{1}\"",
(LoadDataTo - LoadDataSpan).ToString("yyyy-MM-dd HH:mm:ss"),
LoadDataTo.ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
if(IsFilterUnstable)
cmdstr = string.Format("select * from [ThickHeat] where ID>\"{0}\" and IsStable=1", _ids.Last());
else
cmdstr = string.Format("select * from [ThickHeat] where ID>\"{0}\"", _ids.Last());
}
dataTable = mSQLiteHelper.ExecuteReader(cmdstr);
//SQLiteDataAdapter dbDataAdapter = new SQLiteDataAdapter(cmdstr, connectionString);
......@@ -215,13 +223,21 @@ namespace FLY.HeatingHelper
if ((reload == 0 && _ids.Count() == 0) || (reload == 1))
{
clear = true;
if(IsFilterUnstable)
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 Time>=\"{0}\" and Time<=\"{1}\"",
LoadDataFrom.ToString("yyyy-MM-dd HH:mm:ss"),
LoadDataTo.ToString("yyyy-MM-dd HH:mm:ss"));
}
else
{
if(IsFilterUnstable)
cmdstr = string.Format("select * from [ThickHeat] where ID>\"{0}\" and IsStable=1", _ids.Last());
else
cmdstr = string.Format("select * from [ThickHeat] where ID>\"{0}\"", _ids.Last());
}
try
{
......
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