diff --git a/CapMachine.Shared/Controls/Meter.xaml b/CapMachine.Shared/Controls/Meter.xaml
new file mode 100644
index 0000000..a56d94e
--- /dev/null
+++ b/CapMachine.Shared/Controls/Meter.xaml
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CapMachine.Shared/Controls/Meter.xaml.cs b/CapMachine.Shared/Controls/Meter.xaml.cs
new file mode 100644
index 0000000..992f75e
--- /dev/null
+++ b/CapMachine.Shared/Controls/Meter.xaml.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace CapMachine.Shared.Controls
+{
+ ///
+ /// Meter.xaml 的交互逻辑
+ ///
+ public partial class Meter : UserControl
+ {
+ public Meter()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// 仪表名称
+ ///
+ public string MeterName
+ {
+ get
+ {
+ return (string)base.GetValue(MeterConfig.MeterNameProperty);
+ }
+ set
+ {
+ base.SetValue(MeterConfig.MeterNameProperty, value);
+ }
+ }
+ public static readonly DependencyProperty MeterNameProperty = DependencyProperty.Register("MeterName", typeof(string), typeof(MeterConfig), new PropertyMetadata("速度"));
+
+
+
+
+ }
+}
diff --git a/CapMachine.Wpf/Assets/Images/参考工艺图.png b/CapMachine.Wpf/Assets/Images/参考工艺图.png
new file mode 100644
index 0000000..dc40cbe
Binary files /dev/null and b/CapMachine.Wpf/Assets/Images/参考工艺图.png differ
diff --git a/CapMachine.Wpf/CapMachine.Wpf.csproj b/CapMachine.Wpf/CapMachine.Wpf.csproj
index 0d702c7..6bb4200 100644
--- a/CapMachine.Wpf/CapMachine.Wpf.csproj
+++ b/CapMachine.Wpf/CapMachine.Wpf.csproj
@@ -7,6 +7,16 @@
enable
true
+
+
+
+
+
+
+
+ Never
+
+
@@ -25,7 +35,6 @@
-
diff --git a/CapMachine.Wpf/Models/ChartRtSeries.cs b/CapMachine.Wpf/Models/ChartRtSeries.cs
index c3810f3..eb85c91 100644
--- a/CapMachine.Wpf/Models/ChartRtSeries.cs
+++ b/CapMachine.Wpf/Models/ChartRtSeries.cs
@@ -1,9 +1,11 @@
using Arction.Wpf.Charting;
using Arction.Wpf.Charting.Annotations;
using Arction.Wpf.Charting.Axes;
+using Arction.Wpf.Charting.Maps;
using Arction.Wpf.Charting.Series3D;
using Arction.Wpf.Charting.SeriesXY;
using Arction.Wpf.Charting.Views.ViewXY;
+using CapMachine.Model;
using ImTools;
using Prism.Mvvm;
using System;
@@ -18,60 +20,64 @@ namespace CapMachine.Wpf.Models
///
/// 曲线实时系列模型
///
- public class ChartRtSeries:BindableBase
+ public class ChartRtSeries : BindableBase
{
- public ChartRtSeries(AxisY axisY, LightningChart lightningChart, string SeriesName)
- {
- //var CreateAxisY = new AxisY();
- //CreateAxisY.Title.Text = Name;
- //CreateAxisY.Title.AllowDragging = false;
- //CreateAxisY.SetRange(0, 100);
- //CreateAxisY.MajorGrid.Visible = false;
- ////取消滚轮缩放
- //CreateAxisY.ZoomingEnabled = false;
+ ///
+ /// 实例化函数
+ ///
+ ///
+ ///
+ ///
+ //public ChartRtSeries(AxisY axisY, LightningChart lightningChart, string SeriesName)
+ //{
+ // //var CreateAxisY = new AxisY();
+ // //CreateAxisY.Title.Text = Name;
+ // //CreateAxisY.Title.AllowDragging = false;
+ // //CreateAxisY.SetRange(0, 100);
+ // //CreateAxisY.MajorGrid.Visible = false;
+ // ////取消滚轮缩放
+ // //CreateAxisY.ZoomingEnabled = false;
+ // //模型赋值
+ // LightningChartInstance = lightningChart;
+ // //ChartAxisY = axisY;
+ // ChartAxisX = lightningChart.ViewXY.XAxes[0];
+ // Name = SeriesName;
+
+ // //Unit = "℃";
+
+ // //判断别重复,因为可能共用Y轴的信息
+ // //绑定lightningChart
+ // lightningChart.ViewXY.YAxes.Add(axisY);
+
+ // ChartPointLineSeries = new PointLineSeries(lightningChart.ViewXY, lightningChart.ViewXY.XAxes[0], axisY);
+ // ChartPointLineSeries.Title.Text = SeriesName;
+ // //绑定lightningChart
+ // lightningChart.ViewXY.PointLineSeries.Add(ChartPointLineSeries);
+
+
+ //}
+
+ ///
+ /// 实例化函数
+ ///
+ public ChartRtSeries(LightningChart lightningChart, ChartConfig chartConfig, List listchartRtSeries, ConfigChartSelect configChartSelect)
+ {
//模型赋值
LightningChartInstance = lightningChart;
- ChartAxisY = axisY;
- ChartAxisX = lightningChart.ViewXY.XAxes[0];
- Name = SeriesName;
+ ChartConfigInfo = chartConfig;
+ ChartAxisY = configChartSelect.ConfigChartYAxis;
+ ChartAxisX = LightningChartInstance.ViewXY.XAxes[0];
+ Name = configChartSelect.Name;
+ ListChartRtSeries= listchartRtSeries;
- Unit = "℃";
+ AddSeries(configChartSelect.Name!, configChartSelect.ConfigChartYAxis!);
- //判断别重复,因为可能共用Y轴的信息
- //绑定lightningChart
- lightningChart.ViewXY.YAxes.Add(axisY);
-
- ChartPointLineSeries = new PointLineSeries(lightningChart.ViewXY, lightningChart.ViewXY.XAxes[0], axisY);
- ChartPointLineSeries.Title.Text = SeriesName;
- //绑定lightningChart
- lightningChart.ViewXY.PointLineSeries.Add(ChartPointLineSeries);
}
- /////
- ///// 名称
- /////
- //public string? Name { get; set; }
- /////
- ///// 值
- /////
- //public double Value { get; set; }
+ #region 基本信息
- /////
- ///// Max
- /////
- //public double Max { get; set; }
-
- /////
- ///// Min
- /////
- //public double Min { get; set; }
-
- /////
- ///// 单位
- /////
- //public string? Unit { get; set; }
private string? _Name;
///
@@ -93,37 +99,159 @@ namespace CapMachine.Wpf.Models
set { _Value = value; RaisePropertyChanged(); }
}
- private double _Max;
+
+ //private string? _Unit;
+ /////
+ ///// 单位
+ /////
+ //public string? Unit
+ //{
+ // get { return _Unit; }
+ // set { _Unit = value; RaisePropertyChanged(); }
+ //}
+
+
+ #endregion
+
+
///
- /// Max
+ /// 删除Y轴信息
///
- public double Max
+ public void DeleteAxisY()
{
- get { return _Max; }
- set { _Max = value; RaisePropertyChanged(); }
+ //删除Y轴信息
+ LightningChartInstance.ViewXY.YAxes.Remove(LightningChartInstance.ViewXY.YAxes.FindFirst(a => a.Title.Text == ChartAxisY.Name));
}
- private double _Min;
///
- /// Min
+ /// 删除系列
///
- public double Min
+ public void DeleteSeries()
{
- get { return _Min; }
- set { _Min = value; RaisePropertyChanged(); }
+ LightningChartInstance.BeginUpdate();
+
+ LightningChartInstance.ViewXY.PointLineSeries.Remove(ChartPointLineSeries);
+
+ LightningChartInstance.EndUpdate();
+
+ ListChartRtSeries.Remove(ListChartRtSeries.FindFirst(a=>a.Name== Name));
}
- private string? _Unit;
///
- /// 单位
+ /// 增加系列
///
- public string? Unit
+ ///
+ private void AddSeries(string SeriesName, ConfigChartYAxis configChartYAxis)
{
- get { return _Unit; }
- set { _Unit = value; RaisePropertyChanged(); }
+ LightningChartInstance.BeginUpdate();
+
+ //判断之前的系列是否已经存在(依据名称),存在使用之前的系列,否则新增
+ var AxisYInfo = GetAxisY(configChartYAxis.Name);
+ if (AxisYInfo == null)
+ {
+ //新增
+ AxisYInfo = new AxisY();
+ AxisYInfo.Title.Text = configChartYAxis.Name;
+ AxisYInfo.Title.AllowDragging = false;
+ AxisYInfo.SetRange(configChartYAxis.Min, configChartYAxis.Max);
+ AxisYInfo.MajorGrid.Visible = false;
+ //取消滚轮缩放
+ AxisYInfo.ZoomingEnabled = false;
+ LightningChartInstance.ViewXY.YAxes.Add(AxisYInfo);
+ }
+ else
+ {
+ //使用之前
+ AxisYInfo.SetRange(configChartYAxis.Min, configChartYAxis.Max);
+ }
+
+ var SeriesInfo = GetPointLineSeries(SeriesName);
+ if (SeriesInfo == null)
+ {
+ //新增
+ SeriesInfo = new PointLineSeries(LightningChartInstance.ViewXY, LightningChartInstance.ViewXY.XAxes[0], AxisYInfo);
+ SeriesInfo.Title.Text = SeriesName;
+ SeriesInfo.LineStyle.Color = ChartConfigInfo.ListColor[LightningChartInstance.ViewXY.YAxes.Count + 1];
+ SeriesInfo.AllowUserInteraction = false;
+ LightningChartInstance.ViewXY.PointLineSeries.Add(SeriesInfo);
+ }
+ else
+ {
+ //使用之前
+ SeriesInfo.AssignYAxisIndex = AxisYInfo.SegmentIndex;
+ }
+
+ //赋值给当前的模型
+ ChartPointLineSeries = SeriesInfo;
+
+ //Configure and add series to the chart
+
+
+ LightningChartInstance.EndUpdate();
}
+ ///
+ /// 获取AxisY信息
+ ///
+ ///
+ ///
+ private AxisY GetAxisY(string AxisName)
+ {
+ var AxisYs = LightningChartInstance.ViewXY.YAxes;
+
+ if (AxisYs != null)
+ {
+ var findAxis = AxisYs.FindFirst(a => a.Title.Text == AxisName);
+ if (findAxis != null)
+ {
+ return findAxis;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获取PointLineSeries信息
+ ///
+ ///
+ ///
+ private PointLineSeries GetPointLineSeries(string SeriesName)
+ {
+ var PointLineSeries = LightningChartInstance.ViewXY.PointLineSeries;
+
+ if (PointLineSeries != null)
+ {
+ var findSeries = PointLineSeries.FindFirst(a => a.Title.Text == SeriesName);
+ if (findSeries != null)
+ {
+ return findSeries;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ ///
+ /// 上层管理集合
+ ///
+ public List ListChartRtSeries { get; set; }
+
+
///
/// 曲线
///
@@ -132,7 +260,7 @@ namespace CapMachine.Wpf.Models
///
/// Y轴
///
- public AxisY? ChartAxisY { get; set; }
+ public ConfigChartYAxis? ChartAxisY { get; set; }
///
/// X轴
@@ -144,6 +272,12 @@ namespace CapMachine.Wpf.Models
///
public LightningChart LightningChartInstance { get; set; }
+ ///
+ /// 曲线配置信息
+ ///
+ public ChartConfig ChartConfigInfo { get; set; }
+
+
///
/// X轴滚动
///
@@ -160,7 +294,7 @@ namespace CapMachine.Wpf.Models
///
public void AddValue(double Data)
{
- //foreach (var item in lightningChart1.ViewXY.PointLineSeries)
+ //foreach (var item in LightningChartInstance.ViewXY.PointLineSeries)
//{
//Disable updates, to prevent several extra refreshes
LightningChartInstance.BeginUpdate();
@@ -183,10 +317,11 @@ namespace CapMachine.Wpf.Models
LightningChartInstance.ViewXY.XAxes[0].ScrollPosition = _previousX;
}
-
//Allow updates again, and update
LightningChartInstance.EndUpdate();
+ Value = Data;
+
//}
}
diff --git a/CapMachine.Wpf/Models/ChartRtValue.cs b/CapMachine.Wpf/Models/ChartRtValue.cs
index 7d1aa12..61cf327 100644
--- a/CapMachine.Wpf/Models/ChartRtValue.cs
+++ b/CapMachine.Wpf/Models/ChartRtValue.cs
@@ -1,5 +1,6 @@
using Arction.Wpf.Charting.Axes;
using Arction.Wpf.Charting.SeriesXY;
+using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,7 +12,7 @@ namespace CapMachine.Wpf.Models
///
/// 曲线实时数据模型
///
- public class ChartRtValue
+ public class ChartRtValue:BindableBase
{
public ChartRtValue()
{
@@ -23,10 +24,15 @@ namespace CapMachine.Wpf.Models
///
public string? Name { get; set; }
+ private double _Value;
///
/// 值
///
- public double Value { get; set; }
+ public double Value
+ {
+ get { return _Value; }
+ set { _Value = value; RaisePropertyChanged(); }
+ }
///
/// Max
diff --git a/CapMachine.Wpf/Services/MachineRtDataService.cs b/CapMachine.Wpf/Services/MachineRtDataService.cs
index 9206b2c..fd860c2 100644
--- a/CapMachine.Wpf/Services/MachineRtDataService.cs
+++ b/CapMachine.Wpf/Services/MachineRtDataService.cs
@@ -54,28 +54,28 @@ namespace CapMachine.Wpf.Services
- Stopwatch stopwatch = new Stopwatch();
- //第一次计时
- stopwatch.Start(); //启动Stopwatch
+ //Stopwatch stopwatch = new Stopwatch();
+ ////第一次计时
+ //stopwatch.Start(); //启动Stopwatch
- for (var i = 0; i < 10000000; i++)
- {
- keyValuePairs.TryAdd(DateTime.UtcNow, new RecordInfo()
- {
- CreateTime = DateTime.UtcNow,
- WorkCondition = "dadf",
- Temp = 23.3
- });
- //keyValuePairs.Add(new RecordInfo()
- //{
- // CreateTime = DateTime.UtcNow,
- // WorkCondition = "dadf",
- // Temp = 23.3
- //});
- }
+ //for (var i = 0; i < 10000000; i++)
+ //{
+ // keyValuePairs.TryAdd(DateTime.UtcNow, new RecordInfo()
+ // {
+ // CreateTime = DateTime.UtcNow,
+ // WorkCondition = "dadf",
+ // Temp = 23.3
+ // });
+ // //keyValuePairs.Add(new RecordInfo()
+ // //{
+ // // CreateTime = DateTime.UtcNow,
+ // // WorkCondition = "dadf",
+ // // Temp = 23.3
+ // //});
+ //}
- stopwatch.Stop(); //停止Stopwatch
- Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.ToString());
+ //stopwatch.Stop(); //停止Stopwatch
+ //Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.ToString());
//事件服务
_EventAggregator = eventAggregator;
@@ -216,12 +216,13 @@ namespace CapMachine.Wpf.Services
await Task.Delay(1000);
_EventAggregator.GetEvent().Publish(new List()
{
- new Models.ChartRtValue(){Name="室温0",Value=random.NextDouble()*100,Unit="℃"},
- new Models.ChartRtValue(){Name="室温1",Value=random.NextDouble()*100,Unit="℃"},
- new Models.ChartRtValue(){Name="室温2",Value=random.NextDouble()*100,Unit="℃"},
- new Models.ChartRtValue(){Name="室温3",Value=random.NextDouble()*100,Unit="℃"},
- new Models.ChartRtValue(){Name="室温4",Value=random.NextDouble()*100,Unit="℃"},
- new Models.ChartRtValue(){Name="室温5",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="EVA风量",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="中间轴转速",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="加热电力",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="加湿电力",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="EMPCV电流",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="INJ压力",Value=random.NextDouble()*100,Unit="℃"},
+ new Models.ChartRtValue(){Name="冷媒流量",Value=random.NextDouble()*100,Unit="℃"},
});
}
diff --git a/CapMachine.Wpf/ViewModels/MonitorViewModel.cs b/CapMachine.Wpf/ViewModels/MonitorViewModel.cs
index 809066a..e1c46eb 100644
--- a/CapMachine.Wpf/ViewModels/MonitorViewModel.cs
+++ b/CapMachine.Wpf/ViewModels/MonitorViewModel.cs
@@ -1,14 +1,39 @@
using CapMachine.Core;
+using CapMachine.Wpf.Models;
+using CapMachine.Wpf.PrismEvent;
+using Prism.Events;
namespace CapMachine.Wpf.ViewModels
{
public class MonitorViewModel : NavigationViewModel
{
- public MonitorViewModel()
+ public MonitorViewModel(IEventAggregator eventAggregator)
{
-
+ //事件服务
+ _EventAggregator = eventAggregator;
+ _EventAggregator.GetEvent().Subscribe(GetChartRtEvent);
}
+ private IEventAggregator _EventAggregator { get; set; }
+
+ public List ListChartRtValue { get; set; } = new List()
+ {
+ new ChartRtValue(){ Name="温度",Value=12.3,Unit="℃"},
+ new ChartRtValue(){ Name="压力",Value=12.3,Unit="bar"},
+ new ChartRtValue(){ Name="湿度",Value=12.3,Unit="%"},
+ };
+
+ ///
+ /// 获取曲线的实时值
+ /// 数据是发布过来
+ ///
+ ///
+ ///
+ private void GetChartRtEvent(List RtData)
+ {
+ //ListChartRtValue = RtData;
+
+ }
}
}
diff --git a/CapMachine.Wpf/Views/MainView.xaml b/CapMachine.Wpf/Views/MainView.xaml
index a8e6685..4e1b275 100644
--- a/CapMachine.Wpf/Views/MainView.xaml
+++ b/CapMachine.Wpf/Views/MainView.xaml
@@ -17,6 +17,7 @@
+
@@ -160,5 +161,74 @@
x:Name="MainViewContentControl"
prism:RegionManager.RegionName="MainViewContentRegion"
Visibility="Collapsed" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CapMachine.Wpf/Views/MonitorView.xaml b/CapMachine.Wpf/Views/MonitorView.xaml
index baddd2a..1491dde 100644
--- a/CapMachine.Wpf/Views/MonitorView.xaml
+++ b/CapMachine.Wpf/Views/MonitorView.xaml
@@ -2,42 +2,317 @@
x:Class="CapMachine.Wpf.Views.MonitorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Controls="clr-namespace:CapMachine.Shared.Controls;assembly=CapMachine.Shared"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="1000"
d:DesignWidth="1920"
mc:Ignorable="d">
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
diff --git a/CapMachine.Wpf/Views/RealTimeChartView.xaml.cs b/CapMachine.Wpf/Views/RealTimeChartView.xaml.cs
index b6c4e44..e4d4870 100644
--- a/CapMachine.Wpf/Views/RealTimeChartView.xaml.cs
+++ b/CapMachine.Wpf/Views/RealTimeChartView.xaml.cs
@@ -3,10 +3,12 @@ using Arction.Wpf.Charting.Annotations;
using Arction.Wpf.Charting.Axes;
using Arction.Wpf.Charting.SeriesXY;
using Arction.Wpf.Charting.Views.ViewXY;
+using CapMachine.Model;
using CapMachine.Wpf.Models;
using CapMachine.Wpf.PrismEvent;
using CapMachine.Wpf.Services;
using CapMachine.Wpf.ViewModels;
+using ImTools;
using NLog;
using Prism.Events;
using System.Text;
@@ -28,18 +30,19 @@ namespace CapMachine.Wpf.Views
private IEventAggregator _EventAggregator { get; set; }
public MachineRtDataService MachineRtDataService { get; }
+ public IFreeSql FreeSql { get; }
///
/// 曲线配置
///
- public ChartConfig ChartConfigInfo { get; set; }
+ public ChartConfig ChartConfigInfo { get; set; } = new ChartConfig();
///
/// 实例化函数
///
///
///
- public RealTimeChartView(IEventAggregator eventAggregator, MachineRtDataService machineRtDataService)
+ public RealTimeChartView(IEventAggregator eventAggregator, MachineRtDataService machineRtDataService, IFreeSql freeSql)
{
InitializeComponent();
@@ -51,18 +54,10 @@ namespace CapMachine.Wpf.Views
//事件服务
_EventAggregator = eventAggregator;
MachineRtDataService = machineRtDataService;
-
+ FreeSql = freeSql;
_EventAggregator.GetEvent().Subscribe(GetChartRtEvent);
_EventAggregator.GetEvent().Subscribe(ReLoadData);
- var CreateAxisY = new AxisY();
- CreateAxisY.Title.Text = Name;
- CreateAxisY.Title.AllowDragging = false;
- CreateAxisY.SetRange(0, 100);
- CreateAxisY.MajorGrid.Visible = false;
- //取消滚轮缩放
- CreateAxisY.ZoomingEnabled = false;
- ListChartRtSeries.Add(new ChartRtSeries(CreateAxisY, lightningChart1, "室温0"));
}
///
@@ -73,7 +68,17 @@ namespace CapMachine.Wpf.Views
///
private void ReLoadData(ChartActionType type)
{
- throw new NotImplementedException();
+ //
+ switch (type)
+ {
+ case ChartActionType.ReLoadChart:
+ var ChartSelectedData = FreeSql.Select().Include(a => a.ConfigChartYAxis).ToList();
+ LoadChartConfigSelect(ChartSelectedData);
+ break;
+ default:
+ break;
+ }
+
}
@@ -106,23 +111,97 @@ namespace CapMachine.Wpf.Views
}
- private void CurTimer2_Elapsed(object? sender, ElapsedEventArgs e)
- {
-
- }
-
+ ///
+ /// 时间序列
+ ///
+ ///
+ ///
private void CurTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
}
- #region ListView配置
-
+ #region 开始测试
#endregion
#region 曲线配置
+ ///
+ /// 当前曲线配置信息
+ ///
+ public List CurListConfigChartSelect { get; set; }
+
+
+ ///
+ /// 加载曲线配置信息
+ ///
+ private void LoadChartConfigSelect(List configChartSelects)
+ {
+ //从配置入手对比目前的状态,针对配置新增
+ foreach (var itemConfig in configChartSelects)
+ {
+ //曲线增加时
+ var data = ListChartRtSeries.FindFirst(a => a.Name == itemConfig.Name);
+ if (data == null)
+ {
+ ListChartRtSeries.Add(new ChartRtSeries(lightningChart1, ChartConfigInfo, ListChartRtSeries, itemConfig));
+ }
+ else
+ {
+ //修改
+ }
+ }
+
+ ////从目前的状态对比配置,针对删除项目
+ //foreach (var itemSeries in ListChartRtSeries)
+ //{
+ // var data = configChartSelects.FindFirst(a => a.Name == itemSeries.Name);
+ // if (data == null)
+ // {
+ // //查找删除的系列的Y轴是否还有其他的配置使用
+ // var configChartYAxis = configChartSelects.Find(a => a.ConfigChartYAxis.Name == itemSeries.ChartAxisY.Name);
+ // if (configChartYAxis == null)
+ // {
+ // //Y轴没有使用,则删除
+ // itemSeries.DeleteAxisY();
+ // }
+
+ // //未找到,则删除
+ // ListChartRtSeries.Remove(itemSeries);
+
+ // }
+ // else
+ // {
+ // //存在就不需要操作
+ // }
+ //}
+
+
+ //从目前的状态对比配置,针对删除项目
+ for (int i = 0; i < ListChartRtSeries.Count; i++)
+ {
+ var data = configChartSelects.FindFirst(a => a.Name == ListChartRtSeries[i].Name);
+ if (data == null)
+ {
+ //查找删除的系列的Y轴是否还有其他的配置使用-先删除Y轴
+ var configChartYAxis = configChartSelects.Find(a => a.ConfigChartYAxis.Name == ListChartRtSeries[i].ChartAxisY.Name);
+ if (configChartYAxis == null)
+ {
+ //Y轴没有使用,则删除
+ ListChartRtSeries[i].DeleteAxisY();
+ }
+
+ //未找到,则删除 曲线实例删除
+ ListChartRtSeries[i].DeleteSeries();
+ }
+ else
+ {
+ //存在就不需要操作
+ }
+ }
+ }
+
///
/// 实时曲线数据集合
///
@@ -502,6 +581,7 @@ namespace CapMachine.Wpf.Views
MainRealTimeChartSeriesCount++;
}
+
private void DeleteYAxis(string Name)
{
lightningChart1.BeginUpdate();