Browse Source

50L曲线界面修改并测试。

HK研究所反应釜三屏显示
ZhaoGang 1 week ago
parent
commit
9cfbb830dd
5 changed files with 449 additions and 35 deletions
  1. +12
    -0
      BPASmartClient.Academy/ColorResource.xaml
  2. +167
    -3
      BPASmartClient.Academy/View/DeviceChart50LView.xaml
  3. +27
    -14
      BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs
  4. +241
    -17
      BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs
  5. +2
    -1
      BPASmartClient.Academy/ViewModel/HistoryChart50LViewModel.cs

+ 12
- 0
BPASmartClient.Academy/ColorResource.xaml View File

@@ -10,4 +10,16 @@
<SolidColorBrush x:Key="比例阀实际开度">#ff00ff</SolidColorBrush>
<SolidColorBrush x:Key="卤水配制罐重量">#0000ff</SolidColorBrush>
<SolidColorBrush x:Key="反应釜压力">#A26189</SolidColorBrush>
<SolidColorBrush x:Key="反应釜温度_参考">#ff0000</SolidColorBrush>
<SolidColorBrush x:Key="反应釜蒸汽压力_参考">#90ee90</SolidColorBrush>
<SolidColorBrush x:Key="反应釜蒸汽流量_参考">#00bfff</SolidColorBrush>
<SolidColorBrush x:Key="冷凝水罐温度_参考">#ffff00</SolidColorBrush>
<SolidColorBrush x:Key="冷凝水罐湿度_参考">#ffa500</SolidColorBrush>
<SolidColorBrush x:Key="负压流量_参考">#9b30ff</SolidColorBrush>
<SolidColorBrush x:Key="称重水罐重量_参考">#00ffff</SolidColorBrush>
<SolidColorBrush x:Key="反应釜编码器值_参考">#7FFF00</SolidColorBrush>
<SolidColorBrush x:Key="比例阀实际开度_参考">#ff00ff</SolidColorBrush>
<SolidColorBrush x:Key="卤水配制罐重量_参考">#0000ff</SolidColorBrush>
<SolidColorBrush x:Key="反应釜压力_参考">#A26189</SolidColorBrush>
</ResourceDictionary>

+ 167
- 3
BPASmartClient.Academy/View/DeviceChart50LView.xaml View File

@@ -176,11 +176,12 @@
<!--#endregion-->
</StackPanel>
<UniformGrid Columns="2" Rows="4">
<StackPanel
<!--#region 废弃-->
<!--<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<lvc:CartesianChart
x:Name="ppp" Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
AnimationsSpeed="0:0:1"
AnimationsSpeed="0:0:1"
DataTooltip="{x:Null}"
Hoverable="False" MouseDoubleClick="DataView_CLick" ToolTip="温度曲线">
<lvc:CartesianChart.Series>
@@ -213,7 +214,11 @@
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}" Unit="{Binding AxisUnit}" MinValue="{Binding AxisXMinValue}" MaxValue="{Binding AxisXMaxValue}">
<lvc:Axis
LabelFormatter="{Binding DateTimeFormatter}"
MaxValue="{Binding AxisXMaxValue}"
MinValue="{Binding AxisXMinValue}"
Unit="{Binding AxisUnit}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="False" Step="{Binding AxisStep}" />
</lvc:Axis.Separator>
@@ -559,7 +564,166 @@
<TextBlock Foreground="White" Text="反应釜编码器角度值_参考" />
</StackPanel>

</StackPanel>-->
<!--#endregion-->
<!--#region 新图表 OxyPlot-->
<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[0]}"
MouseDoubleClick="DataView_CLick" ToolTip="温度曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="温度曲线/℃" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 反应釜温度}" />
<TextBlock Foreground="White" Text="反应釜温度" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 冷凝水罐温度}" />
<TextBlock Foreground="White" Text="冷凝水罐温度" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 反应釜温度_参考}" />
<TextBlock Foreground="White" Text="反应釜温度_参考" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 冷凝水罐温度_参考}" />
<TextBlock Foreground="White" Text="冷凝水罐温度_参考" />
</StackPanel>

</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[1]}"
MouseDoubleClick="DataView_CLick" ToolTip="压力曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="压力曲线/MPa" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 反应釜蒸汽压力}" />
<TextBlock Foreground="White" Text="反应釜蒸汽压力" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 反应釜压力}" />
<TextBlock Foreground="White" Text="反应釜压力" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 反应釜蒸汽压力_参考}" />
<TextBlock Foreground="White" Text="反应釜蒸汽压力_参考" />
<Rectangle
Width="20" Height="2" Margin="10,0,0,2" Fill="{StaticResource 反应釜压力_参考}" />
<TextBlock Foreground="White" Text="反应釜压力_参考" />
</StackPanel>

</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[2]}"
MouseDoubleClick="DataView_CLick" ToolTip="比例阀开度曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="比例阀开度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 比例阀实际开度}" />
<TextBlock Foreground="White" Text="比例阀实际开度" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 比例阀实际开度_参考}" />
<TextBlock Foreground="White" Text="比例阀实际开度_参考" />
</StackPanel>

</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[3]}"
MouseDoubleClick="DataView_CLick" ToolTip="流量曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="流量曲线/Mpa" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 反应釜蒸汽流量}" />
<TextBlock Foreground="White" Text="反应釜蒸汽流量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 负压流量}" />
<TextBlock Foreground="White" Text="负压流量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 反应釜蒸汽流量_参考}" />
<TextBlock Foreground="White" Text="反应釜蒸汽流量_参考" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 负压流量_参考}" />
<TextBlock Foreground="White" Text="负压流量_参考" />
</StackPanel>

</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[4]}"
MouseDoubleClick="DataView_CLick" ToolTip="重量曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="重量曲线/kg" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 称重水罐重量}" />
<TextBlock Foreground="White" Text="称重水罐重量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 卤水配制罐重量}" />
<TextBlock Foreground="White" Text="卤水配制罐重量" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 称重水罐重量_参考}" />
<TextBlock Foreground="White" Text="称重水罐重量_参考" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 卤水配制罐重量_参考}" />
<TextBlock Foreground="White" Text="卤水配制罐重量_参考" />
</StackPanel>

</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[5]}"
MouseDoubleClick="DataView_CLick" ToolTip="湿度曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="湿度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 冷凝水罐湿度}" />
<TextBlock Foreground="White" Text="冷凝水罐湿度" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 冷凝水罐湿度_参考}" />
<TextBlock Foreground="White" Text="冷凝水罐湿度_参考" />
</StackPanel>

</StackPanel>

<StackPanel
Margin="20" Orientation="Vertical" Visibility="Visible">
<oxy:PlotView
Height="270" HorizontalAlignment="Stretch" VerticalAlignment="Top"
Model="{Binding PlotModels[6]}"
MouseDoubleClick="DataView_CLick" ToolTip="反应釜角度曲线">
</oxy:PlotView>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<TextBlock Foreground="White" Text="反应釜角度曲线" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 反应釜编码器值}" />
<TextBlock Foreground="White" Text="反应釜编码器值" />
<Rectangle
Width="20" Height="2" Margin="20,0,0,2" Fill="{StaticResource 反应釜编码器值_参考}" />
<TextBlock Foreground="White" Text="反应釜编码器值_参考" />
</StackPanel>

</StackPanel>
<!--#endregion-->
</UniformGrid>
</StackPanel>
</ScrollViewer>


+ 27
- 14
BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs View File

@@ -20,6 +20,7 @@ using ThingsGateway.Foundation.Core;
using BPASmartClient.Academy._50L;
using ThingsGateway.Foundation.Extension.String;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using OxyPlot.Wpf;

namespace BPASmartClient.Academy.View
{
@@ -28,9 +29,9 @@ namespace BPASmartClient.Academy.View
/// </summary>
public partial class DeviceChart50LView : UserControl
{
//private volatile static DeviceChart50LView _Instance;
//public static DeviceChart50LView GetInstance => _Instance ?? (_Instance = new DeviceChart50LView());
public DeviceChart50LView()
private volatile static DeviceChart50LView _Instance;
public static DeviceChart50LView GetInstance => _Instance ?? (_Instance = new DeviceChart50LView());
private DeviceChart50LView()
{
InitializeComponent();
//this.DataContext = DeviceChart50LViewModel.GetInstance;
@@ -42,13 +43,13 @@ namespace BPASmartClient.Academy.View
{
var datas = SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id);
if (datas is null || datas.Count==0)
if (datas is null || datas.Count==0 || e.Source is not PlotView)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error,App.MainWindow,"无数据","当前无曲线数据。");
return;
}
ooo.Visibility = Visibility.Collapsed;
CartesianChart liveCharts = sender as CartesianChart;
double min = DateTimeAxis.ToDouble(DateTime.MinValue);

DateTime startTime = datas.Select(x => x.Createtime).Min();
@@ -57,7 +58,8 @@ namespace BPASmartClient.Academy.View
//double max = DateTimeAxis.ToDouble(DateTime.Now);
double maxrange = max - min;

switch (liveCharts.ToolTip)
PlotView charts = e.Source as PlotView;
switch (charts.ToolTip)
{
case "温度曲线":
{
@@ -66,7 +68,7 @@ namespace BPASmartClient.Academy.View
chartGrid.Visibility = Visibility.Visible;
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "温度/℃", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
List<HistoryDataPoint> reactorTemp = new();
@@ -101,7 +103,7 @@ namespace BPASmartClient.Academy.View
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max, MaximumRange = maxrange });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max, MaximumRange = maxrange });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "压力/Mpa", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
}

@@ -135,7 +137,7 @@ namespace BPASmartClient.Academy.View
chartGrid.Visibility = Visibility.Visible;
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max, MaximumRange = maxrange });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max, MaximumRange = maxrange });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "比例阀开度/%", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2"), IsZoomEnabled = false });
}
List<HistoryDataPoint> point1 = new();
@@ -163,7 +165,7 @@ namespace BPASmartClient.Academy.View
chartGrid.Visibility = Visibility.Visible;
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "流量", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}

@@ -198,7 +200,7 @@ namespace BPASmartClient.Academy.View

if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}

@@ -232,7 +234,7 @@ namespace BPASmartClient.Academy.View
chartGrid.Visibility = Visibility.Visible;
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "湿度", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
List<HistoryDataPoint> point1 = new();
@@ -260,7 +262,7 @@ namespace BPASmartClient.Academy.View

if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "HH:mm:ss", AbsoluteMinimum = min, AbsoluteMaximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "角度/°", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}

@@ -287,13 +289,24 @@ namespace BPASmartClient.Academy.View
}
private void AddOxyLineSeries(string title,OxyColor markerFill, List<HistoryDataPoint> dataPoints)
{
OxyPlot.Series.LineSeries templine = new OxyPlot.Series.LineSeries()
{ LineStyle = LineStyle.Solid,
{
LineStyle = title.Contains("_参考")?LineStyle.Dot : LineStyle.Solid,
Title = title,
MarkerFill = markerFill,
MarkerSize = 2,
LineLegendPosition = OxyPlot.Series.LineLegendPosition.End
};
try
{
var scb = Application.Current.TryFindResource(title) as SolidColorBrush;
var color = scb.ToOxyColor();
templine.Color = color;
}
catch (Exception)
{
}
List<DataPoint> twValues = new List<DataPoint>();
foreach (var item in dataPoints)
{


+ 241
- 17
BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs View File

@@ -18,6 +18,7 @@ using System.Windows.Media;
using System.Windows;
using OxyLineSeries = OxyPlot.Series.LineSeries;
using OxyPlot.Wpf;
using ThingsGateway.Foundation.Extension.String;

namespace BPASmartClient.Academy.ViewModel
{
@@ -34,7 +35,7 @@ namespace BPASmartClient.Academy.ViewModel
Charting.For<DataValue>(mapper);
DataFeedback = SqliteOperate.GetInstance.DataFeedBacks;

InitialOxyChart();
LoadNames(SqliteOperate.GetInstance.FindNames(SelectTime));

Select = new BPARelayCommand(() => { LoadNames(SqliteOperate.GetInstance.FindNames(SelectTime)); });
@@ -55,6 +56,34 @@ namespace BPASmartClient.Academy.ViewModel
{
while (!_tokenSource.IsCancellationRequested)
{
#region 实时数据刷新
for (int i = 0; i < PlotModels.Count; i++)
{
for (int j = 0; j < PlotModels[i].Series.Count; j++)
{
((OxyLineSeries)(PlotModels[i].Series[j])).Points.Clear();
}
}
RefreshOxyPlotSeries(0, 0,DataFeedback.Temperature);
RefreshOxyPlotSeries(0, 1, DataFeedback.CondensateWaterTemperature);

RefreshOxyPlotSeries(1, 0, DataFeedback.SteamPressure);
RefreshOxyPlotSeries(1, 1, DataFeedback.ReactPressure);

RefreshOxyPlotSeries(2, 0, DataFeedback.ProportionalValveOpening);

RefreshOxyPlotSeries(3, 0, DataFeedback.SteamFlowRate);
RefreshOxyPlotSeries(3, 1, DataFeedback.NegativePressureFlowRate);

RefreshOxyPlotSeries(4, 0, DataFeedback.WeighingWaterTankWeight);
RefreshOxyPlotSeries(4, 1, DataFeedback.BrineTankWeight);

RefreshOxyPlotSeries(5, 0, DataFeedback.CondensateWaterHumidity);

RefreshOxyPlotSeries(6, 0, DataFeedback.ReactEncoderValue);
#endregion
#region 参照数据刷新
if (ReferenceData != null && ReferenceData.Temperature.Count > 0)
{
DateTime startTime = DataFeedback.Temperature.Min(x => x.DateTime);
@@ -66,7 +95,7 @@ namespace BPASmartClient.Academy.ViewModel

//PartReferenceData.Temperature.RemoveWhere(x => x.DateTime < startTime);
//PartReferenceData.SteamPressure.RemoveWhere(x => x.DateTime < startTime);
//PartReferenceData.SteamPressure.RemoveWhere(x => x.DateTime < startTime);
//PartReferenceData.SteamFlowRate.RemoveWhere(x => x.DateTime < startTime);
//PartReferenceData.CondensateWaterTemperature.RemoveWhere(x => x.DateTime < startTime);
//PartReferenceData.CondensateWaterHumidity.RemoveWhere(x => x.DateTime < startTime);
//PartReferenceData.NegativePressureFlowRate.RemoveWhere(x => x.DateTime < startTime);
@@ -78,7 +107,7 @@ namespace BPASmartClient.Academy.ViewModel

PartReferenceData.Temperature.Clear();
PartReferenceData.SteamPressure.Clear();
PartReferenceData.SteamPressure.Clear();
PartReferenceData.SteamFlowRate.Clear();
PartReferenceData.CondensateWaterTemperature.Clear();
PartReferenceData.CondensateWaterHumidity.Clear();
PartReferenceData.NegativePressureFlowRate.Clear();
@@ -92,7 +121,7 @@ namespace BPASmartClient.Academy.ViewModel
{
PartReferenceData.Temperature.AddRange(ReferenceData.Temperature.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.SteamPressure.AddRange(ReferenceData.SteamPressure.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.SteamPressure.AddRange(ReferenceData.SteamFlowRate.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.SteamFlowRate.AddRange(ReferenceData.SteamFlowRate.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.CondensateWaterTemperature.AddRange(ReferenceData.CondensateWaterTemperature.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.CondensateWaterHumidity.AddRange(ReferenceData.CondensateWaterHumidity.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.NegativePressureFlowRate.AddRange(ReferenceData.NegativePressureFlowRate.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
@@ -102,7 +131,29 @@ namespace BPASmartClient.Academy.ViewModel
PartReferenceData.BrineTankWeight.AddRange(ReferenceData.BrineTankWeight.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
PartReferenceData.ReactPressure.AddRange(ReferenceData.ReactPressure.Where(x => x.DateTime >= startTime && x.DateTime <= endTime));
}
RefreshOxyPlotSeries(0, 2, PartReferenceData.Temperature);
RefreshOxyPlotSeries(0, 3, PartReferenceData.CondensateWaterTemperature);

RefreshOxyPlotSeries(1, 2, PartReferenceData.SteamPressure);
RefreshOxyPlotSeries(1, 3, PartReferenceData.ReactPressure);

RefreshOxyPlotSeries(2, 1, PartReferenceData.ProportionalValveOpening);

RefreshOxyPlotSeries(3, 2, PartReferenceData.SteamFlowRate);
RefreshOxyPlotSeries(3, 3, PartReferenceData.NegativePressureFlowRate);

RefreshOxyPlotSeries(4, 2, PartReferenceData.WeighingWaterTankWeight);
RefreshOxyPlotSeries(4, 3, PartReferenceData.BrineTankWeight);

RefreshOxyPlotSeries(5, 1, PartReferenceData.CondensateWaterHumidity);

RefreshOxyPlotSeries(6, 1, PartReferenceData.ReactEncoderValue);
}
#endregion

for (int i = 0; i < PlotModels.Count; i++)
{
PlotModels[i].InvalidatePlot(true);
}
//await Task.Delay(2000);
Thread.Sleep(2000);
@@ -115,7 +166,12 @@ namespace BPASmartClient.Academy.ViewModel
_tokenSource.Cancel(false);
}

#region Private Fields
private CancellationTokenSource _tokenSource;
Stopwatch sw = new Stopwatch();
#endregion

#region Properties
private DataFeedBack_50 dataFeedback;
public DataFeedBack_50 DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } }

@@ -134,14 +190,31 @@ namespace BPASmartClient.Academy.ViewModel

public Func<double, string> doubleFormatter { get; set; } = value => value.ToString("F2");

private Visibility _referenceWindownVisiblity=Visibility.Collapsed;
private Visibility _referenceWindownVisiblity = Visibility.Collapsed;
public Visibility ReferenceWindownVisiblity { get { return _referenceWindownVisiblity; } set { _referenceWindownVisiblity = value; OnPropertyChanged(); } }

public double AxisStep { get; set; } = TimeSpan.FromSeconds(2).Ticks;
public double AxisUnit { get; set; } = TimeSpan.TicksPerSecond;

Stopwatch sw = new Stopwatch();
public ObservableCollection<PlotModel> PlotModels { get => _plotModels; set { _plotModels = value; OnPropertyChanged(); } }
private ObservableCollection<PlotModel> _plotModels;

public ObservableCollection<RecipeChart> RecipeCharts { get; set; } = new ObservableCollection<RecipeChart>();

public DateTime SelectTime { get { return _mSelectTime; } set { _mSelectTime = value; OnPropertyChanged(); } }
private DateTime _mSelectTime = DateTime.Now;

public string ProductNum { get { return _mProductNum; } set { _mProductNum = value; OnPropertyChanged(); } }
private string _mProductNum;



public Visibility LoadingVis { get { return _mLoadingVis; } set { _mLoadingVis = value; OnPropertyChanged(); } }
private Visibility _mLoadingVis = Visibility.Collapsed;
#endregion


#region Parivate Methods
private void OxyInit(string Id)
{
ReferenceData = new();
@@ -167,7 +240,14 @@ namespace BPASmartClient.Academy.ViewModel

}


private void RefreshOxyPlotSeries(int plotIndex,int seriesIndex,ChartValues<DataValue> dataValues)
{
if (plotIndex>=0 && plotIndex <= PlotModels.Count && seriesIndex>=0 && seriesIndex <= PlotModels[plotIndex].Series.Count && dataValues != null && dataValues.Count>0)
{
((OxyLineSeries)(PlotModels[plotIndex].Series[seriesIndex])).Points
.AddRange(dataValues.Select(x => new DataPoint(DateTimeAxis.ToDouble(x.DateTime), Math.Round(x.Value,2))));
}
}
private void LoadNames(List<SaveNameData> data)
{
if (data == null) return;
@@ -187,21 +267,164 @@ namespace BPASmartClient.Academy.ViewModel
Id = item.Id,
});
});
}
}

public ObservableCollection<RecipeChart> RecipeCharts { get; set; } = new ObservableCollection<RecipeChart>();
private void InitialOxyChart()
{
PlotModels = new();

#region 创建曲线
OxyLineSeries temperatureSeries = CreateLine("反应釜温度");
OxyLineSeries steamPressureSeries = CreateLine("反应釜蒸汽压力");
OxyLineSeries steamFlowRateSeries = CreateLine("反应釜蒸汽流量");
OxyLineSeries condensateWaterTemperatureSeries = CreateLine("冷凝水罐温度");
OxyLineSeries condensateWaterHumiditySeries = CreateLine("冷凝水罐湿度");
OxyLineSeries negativePressureFlowRateSeries = CreateLine("负压流量");
OxyLineSeries weighingWaterTankWeightSeries = CreateLine("称重水罐重量");
OxyLineSeries reactEncoderValueSeries = CreateLine("反应釜编码器值");
OxyLineSeries proportionalValveOpeningSeries = CreateLine("比例阀实际开度");
OxyLineSeries brineTankWeightSeries = CreateLine("卤水配制罐重量");
OxyLineSeries reactPressureSeries = CreateLine("反应釜压力");

OxyLineSeries reftemperatureSeries = CreateLine("反应釜温度_参考",LineStyle.Dot);
OxyLineSeries refsteamPressureSeries = CreateLine("反应釜蒸汽压力_参考",LineStyle.Dot);
OxyLineSeries refsteamFlowRateSeries = CreateLine("反应釜蒸汽流量_参考",LineStyle.Dot);
OxyLineSeries refcondensateWaterTemperatureSeries = CreateLine("冷凝水罐温度_参考",LineStyle.Dot);
OxyLineSeries refcondensateWaterHumiditySeries = CreateLine("冷凝水罐湿度_参考",LineStyle.Dot);
OxyLineSeries refnegativePressureFlowRateSeries = CreateLine("负压流量_参考",LineStyle.Dot);
OxyLineSeries refweighingWaterTankWeightSeries = CreateLine("称重水罐重量_参考",LineStyle.Dot);
OxyLineSeries refreactEncoderValueSeries = CreateLine("反应釜编码器值_参考",LineStyle.Dot);
OxyLineSeries refproportionalValveOpeningSeries = CreateLine("比例阀实际开度_参考",LineStyle.Dot);
OxyLineSeries refbrineTankWeightSeries = CreateLine("卤水配制罐重量_参考",LineStyle.Dot);
OxyLineSeries refreactPressureSeries = CreateLine("反应釜压力_参考",LineStyle.Dot);
#endregion
#region 温度曲线
{
PlotModel tempPlotModel = CreatePlotModel("温度/℃",0,200);
tempPlotModel.Series.Add(temperatureSeries);
tempPlotModel.Series.Add(condensateWaterTemperatureSeries);

public DateTime SelectTime { get { return _mSelectTime; } set { _mSelectTime = value; OnPropertyChanged(); } }
private DateTime _mSelectTime = DateTime.Now;
tempPlotModel.Series.Add(reftemperatureSeries);
tempPlotModel.Series.Add(refcondensateWaterTemperatureSeries);
PlotModels.Add(tempPlotModel);
}
#endregion
#region 压力曲线
{
PlotModel tempPlotModel = CreatePlotModel("压力/Mpa",-0.1,0.6);
tempPlotModel.Series.Add(steamPressureSeries);
tempPlotModel.Series.Add(reactPressureSeries);

public string ProductNum { get { return _mProductNum; } set { _mProductNum = value; OnPropertyChanged(); } }
private string _mProductNum;
tempPlotModel.Series.Add(refsteamPressureSeries);
tempPlotModel.Series.Add(refreactPressureSeries);
PlotModels.Add(tempPlotModel);
}
#endregion
#region 比例阀开度曲线
{
PlotModel tempPlotModel = CreatePlotModel("比例阀开度/%",0,100);
tempPlotModel.Series.Add(proportionalValveOpeningSeries);

tempPlotModel.Series.Add(refproportionalValveOpeningSeries);
PlotModels.Add(tempPlotModel);
}
#endregion
#region 流量曲线
{
PlotModel tempPlotModel = CreatePlotModel("流量",0,100);
tempPlotModel.Series.Add(steamFlowRateSeries);
tempPlotModel.Series.Add(negativePressureFlowRateSeries);

tempPlotModel.Series.Add(refsteamFlowRateSeries);
tempPlotModel.Series.Add(refnegativePressureFlowRateSeries);
PlotModels.Add(tempPlotModel);
}
#endregion
#region 重量曲线
{
PlotModel tempPlotModel = CreatePlotModel("重量/kg",0,50);
tempPlotModel.Series.Add(weighingWaterTankWeightSeries);
tempPlotModel.Series.Add(brineTankWeightSeries);

tempPlotModel.Series.Add(refweighingWaterTankWeightSeries);
tempPlotModel.Series.Add(refbrineTankWeightSeries);
PlotModels.Add(tempPlotModel);
}
#endregion
#region 湿度曲线
{
PlotModel tempPlotModel = CreatePlotModel("湿度/%RH",0,200);
tempPlotModel.Series.Add(condensateWaterHumiditySeries);

tempPlotModel.Series.Add(refcondensateWaterHumiditySeries);
PlotModels.Add(tempPlotModel);
}
#endregion
#region 反应釜角度曲线
{
PlotModel tempPlotModel = CreatePlotModel("角度/°",0,360);
tempPlotModel.Series.Add(reactEncoderValueSeries);

tempPlotModel.Series.Add(refreactEncoderValueSeries);
PlotModels.Add(tempPlotModel);
}
#endregion
}
private PlotModel CreatePlotModel(string axisYTitle,double axisYMinValue,double axisYMaxValue)
{
PlotModel plotModel = new PlotModel();
//plotModel.Background = OxyColors.Transparent;
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis()
{
Position = OxyPlot.Axes.AxisPosition.Bottom,
//Title = "时间",
StringFormat = "HH:mm:ss",
AxislineColor = OxyColor.FromRgb(84, 164, 227),
AbsoluteMinimum = DateTimeAxis.ToDouble(new DateTime()),
IsZoomEnabled = false,
IsPanEnabled = false,
});
plotModel.Axes.Add(new LinearAxis()
{
//Title = axisYTitle,
Position = OxyPlot.Axes.AxisPosition.Left,
LabelFormatter = value => value.ToString("F2"),
AxislineColor = OxyColor.Parse("#9C9C9C"),
AxislineStyle = LineStyle.Solid,
AxislineThickness = 1,
IsZoomEnabled = false,
IsPanEnabled = false,
AbsoluteMinimum=axisYMinValue,EdgeRenderingMode= EdgeRenderingMode.PreferSpeed,
AbsoluteMaximum = axisYMaxValue,
});
}
return plotModel;
}

private OxyLineSeries CreateLine(string title,LineStyle lineStyle=LineStyle.Solid)
{
var scb = Application.Current.TryFindResource(title) as SolidColorBrush;
var color = scb.ToOxyColor();
return new OxyLineSeries()
{
LineStyle = lineStyle,
//Title = title,
MarkerFill = scb.ToOxyColor(),
MarkerSize = 2,
StrokeThickness=3,
LineLegendPosition = LineLegendPosition.End,
InterpolationAlgorithm=InterpolationAlgorithms.CatmullRomSpline,
CanTrackerInterpolatePoints=false,
Color = color,
};
}
#endregion


public Visibility LoadingVis { get { return _mLoadingVis; } set { _mLoadingVis = value; OnPropertyChanged(); } }
private Visibility _mLoadingVis = Visibility.Collapsed;

#region Commands

public BPARelayCommand Select { get; set; }

@@ -210,7 +433,8 @@ namespace BPASmartClient.Academy.ViewModel
public BPARelayCommand<string> InspectDataCommand { get; set; }


public BPARelayCommand ShowRefrenceWindowCommand { get;private set; }
public BPARelayCommand HiddenRefrenceWindowCommand { get; private set; }
public BPARelayCommand ShowRefrenceWindowCommand { get; private set; }
public BPARelayCommand HiddenRefrenceWindowCommand { get; private set; }
#endregion
}
}

+ 2
- 1
BPASmartClient.Academy/ViewModel/HistoryChart50LViewModel.cs View File

@@ -98,7 +98,8 @@ namespace BPASmartClient.Academy.ViewModel
StringFormat = "HH:mm:ss",
AxislineColor = OxyColor.FromRgb(84, 164, 227),
AbsoluteMinimum = OxyDataModels[0].dataPoints[0].X,
AbsoluteMaximum = OxyDataModels[0].dataPoints[OxyDataModels[0].dataPoints.Count - 1].X,
//AbsoluteMaximum = OxyDataModels[0].dataPoints[OxyDataModels[0].dataPoints.Count - 1].X,
//MaximumPadding=0.05,
});
OxyModel.Axes.Add(new LinearAxis()
{


Loading…
Cancel
Save