diff --git a/BPASmartClient.Academy/View/DeviceChart50LView.xaml b/BPASmartClient.Academy/View/DeviceChart50LView.xaml index 89db7986..82cb2d66 100644 --- a/BPASmartClient.Academy/View/DeviceChart50LView.xaml +++ b/BPASmartClient.Academy/View/DeviceChart50LView.xaml @@ -197,12 +197,12 @@ @@ -229,6 +229,12 @@ + + + + @@ -243,20 +249,23 @@ - + + - + Width="20" Height="2" Margin="10,0,0,2" Fill="Red" /> + Width="20" Height="2" Margin="10,0,0,2" Fill="Blue" /> + + + + @@ -303,8 +312,13 @@ + @@ -324,8 +338,11 @@ + Width="20" Height="2" Margin="20,0,0,2" Fill="Red" /> + + @@ -345,8 +362,18 @@ + + @@ -369,8 +396,14 @@ Width="20" Height="2" Margin="20,0,0,2" Fill="Red" /> + Width="20" Height="2" Margin="20,0,0,2" Fill="Blue" /> + + + + @@ -385,13 +418,23 @@ + + + Width="20" Height="2" Margin="20,0,0,2" Fill="Red" /> + Width="20" Height="2" Margin="20,0,0,2" Fill="Blue" /> + + + + @@ -432,8 +481,13 @@ + @@ -453,8 +507,11 @@ + Width="20" Height="2" Margin="20,0,0,2" Fill="Red" /> + + @@ -469,8 +526,13 @@ + @@ -490,8 +552,11 @@ + Width="20" Height="2" Margin="20,0,0,2" Fill="Red" /> + + diff --git a/BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs b/BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs index f94606f8..8d800a78 100644 --- a/BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs +++ b/BPASmartClient.Academy/View/DeviceChart50LView.xaml.cs @@ -18,6 +18,8 @@ using System.Windows.Navigation; using System.Windows.Shapes; using ThingsGateway.Foundation.Core; using BPASmartClient.Academy._50L; +using ThingsGateway.Foundation.Extension.String; +using BPASmartClient.CustomResource.UserControls.MessageShow; namespace BPASmartClient.Academy.View { @@ -38,11 +40,22 @@ namespace BPASmartClient.Academy.View public PlotModel plotModel { get; set; } = new PlotModel(); private void DataView_CLick(object sender, MouseButtonEventArgs e) { + + var datas = SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id); + if (datas is null || datas.Count==0) + { + NoticeDemoViewModel.OpenMsg(EnumPromptType.Error,App.MainWindow,"无数据","当前无曲线数据。"); + return; + } ooo.Visibility = Visibility.Collapsed; - double min = DateTimeAxis.ToDouble(System.DateTime.Now.AddMinutes(-10)); - double max = DateTimeAxis.ToDouble(System.DateTime.Now); - double maxrange = max - min; CartesianChart liveCharts = sender as CartesianChart; + double min = DateTimeAxis.ToDouble(DateTime.MinValue); + + DateTime startTime = datas.Select(x => x.Createtime).Min(); + double max = DateTimeAxis.ToDouble(new DateTime((datas.Select(x=>x.Createtime).Max().AddMinutes(6) - startTime).Ticks)); + //double min = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(-10)); + //double max = DateTimeAxis.ToDouble(DateTime.Now); + double maxrange = max - min; switch (liveCharts.ToolTip) { @@ -51,27 +64,31 @@ namespace BPASmartClient.Academy.View plotModel.Series.Clear(); plotModel = new PlotModel() { Title = "温度曲线" }; chartGrid.Visibility = Visibility.Visible; - OxyPlot.Series.LineSeries templine = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "反应釜温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End }; - OxyPlot.Series.LineSeries templine_1 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "冷凝水罐温度", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End }; - List twValues = new List(); - List tvValues = new List(); - ConcurrentDictionary keyValues = new ConcurrentDictionary(); - SqliteOperate.GetInstance.QueryableById(PlcControl.GetInstance.id).ForEach(t => - { - twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.Temperature)); - tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Createtime), t.CondensateWaterTemperature)); - keyValues[t.Createtime] = t.Temperature; - }); - templine.Points.AddRange(twValues); - templine_1.Points.AddRange(tvValues); - //line_2.Points.AddRange(tmValues); if (!(plotModel.Axes.Count > 0)) { - plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间", StringFormat = "hh:mm:ss", Minimum = min, Maximum = 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") }); } - plotModel.Series.Add(templine); - plotModel.Series.Add(templine_1); + List reactorTemp = new(); + List CWTTemp = new(); + + datas.ForEach(t => + { + var time =new DateTime((t.Createtime - startTime).Ticks); + reactorTemp.Add(new(time, t.Temperature)); + CWTTemp.Add(new(time, t.CondensateWaterTemperature)); + }); + AddOxyLineSeries("反应釜温度", OxyColor.FromRgb(110, 79, 79), reactorTemp); + AddOxyLineSeries("冷凝水罐温度", OxyColor.FromRgb(110, 79, 79), CWTTemp); + if (this.DataContext is DeviceChart50LViewModel viewModel && viewModel.ReferenceData != null) + { + List refReactorTemp = new(); + List refCWTTemp = new(); + refReactorTemp = viewModel.ReferenceData.Temperature.Select(x => new HistoryDataPoint(x.DateTime, (float)x.Value)).ToList(); + refCWTTemp = viewModel.ReferenceData.CondensateWaterTemperature.Select(x => new HistoryDataPoint(x.DateTime, (float)x.Value)).ToList(); + AddOxyLineSeries("反应釜温度_参考", OxyColor.FromRgb(110, 79, 79), refReactorTemp); + AddOxyLineSeries("冷凝水罐温度_参考", OxyColor.FromRgb(110, 79, 79), refCWTTemp); + } plotModel.InvalidatePlot(true);//重新加载曲线 chartView.Model = plotModel; } @@ -233,7 +250,7 @@ namespace BPASmartClient.Academy.View break; } } - private void AddOxyLineSeries(string title,OxyColor markerFill, ConcurrentDictionary keyValues) + private void AddOxyLineSeries(string title,OxyColor markerFill, List dataPoints) { OxyPlot.Series.LineSeries templine = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, @@ -243,9 +260,9 @@ namespace BPASmartClient.Academy.View LineLegendPosition = OxyPlot.Series.LineLegendPosition.End }; List twValues = new List(); - foreach (var item in keyValues) + foreach (var item in dataPoints) { - twValues.Add(new DataPoint(DateTimeAxis.ToDouble(item.Key), item.Value)); + twValues.Add(new DataPoint(DateTimeAxis.ToDouble(item.DateTime), item.Value)); } templine.Points.AddRange(twValues); plotModel.Series.Add(templine); @@ -259,5 +276,12 @@ namespace BPASmartClient.Academy.View plotModel.InvalidatePlot(true); chartView.Model = plotModel; } + + record HistoryDataPoint(DateTime DateTime, float Value); + //class HistoryDataPoint + //{ + // public DateTime DateTime { get; set; } + // public float Value { get; set; } + //} } } diff --git a/BPASmartClient.Academy/View/DeviceMotion_2View.xaml b/BPASmartClient.Academy/View/DeviceMotion_2View.xaml index a783bfb8..5d32252b 100644 --- a/BPASmartClient.Academy/View/DeviceMotion_2View.xaml +++ b/BPASmartClient.Academy/View/DeviceMotion_2View.xaml @@ -89,6 +89,7 @@ + @@ -99,6 +100,7 @@ Style="{StaticResource ButtonStyle}" /> + @@ -107,6 +109,7 @@ + + Text="回水阀" /> + LineWidth="4" /> + Text="冷却水排水阀" /> + Text="出料阀" /> @@ -717,20 +723,23 @@ + Canvas.Left="107" Canvas.Top="84" HorizontalAlignment="Left" VerticalAlignment="Center" + FontSize="10" Foreground="Blue" Text="配料罐" /> + Canvas.Left="217" Canvas.Top="290" HorizontalAlignment="Left" VerticalAlignment="Center" + FontSize="10" Foreground="Blue" Text="反应釜" /> + Canvas.Left="573" Canvas.Top="88" HorizontalAlignment="Left" VerticalAlignment="Center" + FontSize="10" Foreground="Blue" Text="冷凝器" /> + Canvas.Left="573" Canvas.Top="168" HorizontalAlignment="Left" VerticalAlignment="Center" + FontSize="10" Foreground="Blue" Text="蒸馏罐" /> + Canvas.Left="590" Canvas.Top="312" HorizontalAlignment="Left" VerticalAlignment="Center" + FontSize="10" Foreground="Blue" Text="水罐" /> @@ -772,7 +784,7 @@