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 @@
+
+
+
@@ -1625,16 +1646,20 @@
+
+
+
+
@@ -1674,5 +1699,6 @@
+
diff --git a/BPASmartClient.Academy/View/ReactionKettle50LView.xaml b/BPASmartClient.Academy/View/ReactionKettle50LView.xaml
index bd12f33c..9e024b6b 100644
--- a/BPASmartClient.Academy/View/ReactionKettle50LView.xaml
+++ b/BPASmartClient.Academy/View/ReactionKettle50LView.xaml
@@ -1118,7 +1118,7 @@
+ Canvas.Left="384" Canvas.Top="399" Panel.ZIndex="8" MouseLeftButtonDown="Canvas_MouseDown">
(s => { OxyInit(s); });
- CheckedCommand = new BPARelayCommand(async s =>
- {
- if (int.TryParse(s, out int index))
- {
- if (VisStatus.Length == OxyDataModels.Count && index >= 0 && index < VisStatus.Length)
- {
- IsEnable = false;
-
- await Task.Run(() =>
- {
- sw.Start();
- if (VisStatus[index]) OxyModel.Series.Add(OxyDataModels[index].Line);
- else OxyModel.Series.Remove(OxyDataModels[index].Line);
- OxyModel.InvalidatePlot(true); //重新加载曲线
- IsEnable = true;
- Debug.WriteLine(sw.ElapsedMilliseconds);
- sw.Restart();
- });
-
- }
- }
- });
-
+
ShowRefrenceWindowCommand = new BPARelayCommand(() => {
ReferenceWindownVisiblity = Visibility.Visible;
});
HiddenRefrenceWindowCommand = new BPARelayCommand(() => {
ReferenceWindownVisiblity = Visibility.Collapsed;
});
- Task.Factory.StartNew(async () =>
+ _tokenSource = new CancellationTokenSource();
+ Task.Factory.StartNew(async (o) =>
{
- while (true)
+ while (!_tokenSource.IsCancellationRequested)
{
if (ReferenceData != null && ReferenceData.Temperature.Count > 0)
{
@@ -108,10 +87,15 @@ namespace BPASmartClient.Academy.ViewModel
}
await Task.Delay(2000);
}
- }, TaskCreationOptions.LongRunning);
+ }, TaskCreationOptions.LongRunning,_tokenSource.Token);
}
+ ~DeviceChart50LViewModel()
+ {
+ _tokenSource.Cancel(false);
+ }
+ private CancellationTokenSource _tokenSource;
private DataFeedBack_50 dataFeedback;
public DataFeedBack_50 DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } }
@@ -158,20 +142,6 @@ namespace BPASmartClient.Academy.ViewModel
}
- private OxyLineSeries CreateLine(string title)
- {
- var scb = Application.Current.TryFindResource(title) as SolidColorBrush;
- var color = scb.ToOxyColor();
- return new OxyLineSeries()
- {
- LineStyle = LineStyle.Solid,
- Title = title,
- MarkerFill = scb.ToOxyColor(),
- MarkerSize = 2,
- LineLegendPosition = LineLegendPosition.End,
- Color = color,
- };
- }
private void LoadNames(List data)
{
@@ -194,8 +164,6 @@ namespace BPASmartClient.Academy.ViewModel
});
}
- public List OxyDataModels { get; set; } = new List();
-
public ObservableCollection RecipeCharts { get; set; } = new ObservableCollection();
public DateTime SelectTime { get { return _mSelectTime; } set { _mSelectTime = value; OnPropertyChanged(); } }
@@ -204,24 +172,7 @@ namespace BPASmartClient.Academy.ViewModel
public string ProductNum { get { return _mProductNum; } set { _mProductNum = value; OnPropertyChanged(); } }
private string _mProductNum;
- public PlotModel OxyModel { get { return _mOxyModel; } set { _mOxyModel = value; OnPropertyChanged(); } }
- private PlotModel _mOxyModel = new PlotModel();
-
- public bool[] VisStatus { get { return _mVisStatus; } set { _mVisStatus = value; OnPropertyChanged(); } }
- private bool[] _mVisStatus = new bool[11];
-
- public bool IsEnable
- {
- get { return _mIsEnable; }
- set
- {
- _mIsEnable = value;
- LoadingVis = value ? Visibility.Collapsed : Visibility.Visible;
- OnPropertyChanged();
- }
- }
- private bool _mIsEnable = true;
public Visibility LoadingVis { get { return _mLoadingVis; } set { _mLoadingVis = value; OnPropertyChanged(); } }
private Visibility _mLoadingVis = Visibility.Collapsed;
@@ -233,7 +184,6 @@ namespace BPASmartClient.Academy.ViewModel
public BPARelayCommand InspectDataCommand { get; set; }
- public BPARelayCommand CheckedCommand { get; set; }
public BPARelayCommand ShowRefrenceWindowCommand { get;private set; }
public BPARelayCommand HiddenRefrenceWindowCommand { get; private set; }