V1版本
This commit is contained in:
24
CapMachine.Wpf/Models/CacheRtChartData.cs
Normal file
24
CapMachine.Wpf/Models/CacheRtChartData.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 实时曲线数据的缓存
|
||||
/// </summary>
|
||||
public class CacheRtChartData
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public double Value { get; set; }
|
||||
}
|
||||
}
|
||||
144
CapMachine.Wpf/Models/ChartColor.cs
Normal file
144
CapMachine.Wpf/Models/ChartColor.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 曲线的配置
|
||||
/// </summary>
|
||||
public class ChartColor
|
||||
{
|
||||
public List<Color> ListColor = new List<Color>()
|
||||
{
|
||||
Colors.White,
|
||||
Colors.Red,
|
||||
Colors.Blue,
|
||||
Colors.Green,
|
||||
Colors.Orange,
|
||||
Colors.Brown,
|
||||
Colors.Lime,
|
||||
Colors.LightBlue,
|
||||
Colors.Yellow,
|
||||
Colors.BurlyWood,
|
||||
Colors.Gold,
|
||||
Colors.Magenta,
|
||||
Colors.MediumVioletRed,
|
||||
Colors.MintCream,
|
||||
Colors.Cornsilk,
|
||||
Colors.Crimson,
|
||||
Colors.LavenderBlush,
|
||||
Colors. PaleVioletRed,
|
||||
Colors.HotPink,
|
||||
Colors.DeepPink,
|
||||
Colors.MediumVioletRed,
|
||||
Colors.Orchid,
|
||||
Colors.LightPink,
|
||||
|
||||
Colors.Pink,
|
||||
Colors.Crimson,
|
||||
Colors.LavenderBlush,
|
||||
Colors.PaleVioletRed,
|
||||
Colors.HotPink,
|
||||
Colors.DeepPink,
|
||||
Colors.MediumVioletRed,
|
||||
Colors.Orchid,
|
||||
Colors.Violet,
|
||||
Colors.Magenta,
|
||||
Colors.Fuchsia,
|
||||
Colors.DarkMagenta,
|
||||
Colors.MediumOrchid,
|
||||
Colors.DarkOrchid,
|
||||
Colors.BlueViolet,
|
||||
Colors.MediumPurple,
|
||||
Colors.SlateBlue,
|
||||
Colors.DarkSlateBlue,
|
||||
Colors.Lavender,
|
||||
Colors.GhostWhite,
|
||||
Colors.Blue,
|
||||
Colors.MidnightBlue,
|
||||
Colors.DarkBlue,
|
||||
Colors.RoyalBlue,
|
||||
Colors.SlateGray,
|
||||
Colors.AliceBlue,
|
||||
Colors.SteelBlue,
|
||||
Colors.LightSkyBlue,
|
||||
Colors.SkyBlue,
|
||||
Colors.DeepSkyBlue,
|
||||
Colors.CadetBlue,
|
||||
Colors.Azure,
|
||||
Colors.PaleTurquoise,
|
||||
Colors.Cyan,
|
||||
Colors.Aqua,
|
||||
Colors.DarkTurquoise,
|
||||
Colors.DarkSlateGray,
|
||||
Colors.DarkCyan,
|
||||
Colors.Turquoise,
|
||||
Colors.MediumAquamarine,
|
||||
Colors.MediumSpringGreen,
|
||||
Colors.MintCream,
|
||||
Colors.SpringGreen,
|
||||
Colors.SeaGreen,
|
||||
Colors.Honeydew,
|
||||
Colors.LightGreen,
|
||||
Colors.PaleGreen,
|
||||
Colors.DarkSeaGreen,
|
||||
Colors.LimeGreen,
|
||||
Colors.ForestGreen,
|
||||
Colors.Green,
|
||||
Colors.DarkGreen,
|
||||
Colors.Chartreuse,
|
||||
Colors.OliveDrab,
|
||||
Colors.Beige,
|
||||
Colors.LightGoldenrodYellow,
|
||||
Colors.Ivory,
|
||||
Colors.Yellow,
|
||||
Colors.Olive,
|
||||
Colors.DarkKhaki,
|
||||
Colors.LemonChiffon,
|
||||
Colors.Khaki,
|
||||
Colors.Gold,
|
||||
Colors.FloralWhite,
|
||||
Colors.OldLace,
|
||||
Colors.Wheat,
|
||||
Colors.Moccasin,
|
||||
Colors.Orange,
|
||||
Colors.BlanchedAlmond,
|
||||
Colors.NavajoWhite,
|
||||
Colors.Tan,
|
||||
Colors.Bisque,
|
||||
Colors.DarkOrange,
|
||||
Colors.Linen,
|
||||
Colors.Peru,
|
||||
Colors.PeachPuff,
|
||||
Colors.SandyBrown,
|
||||
Colors.Chocolate,
|
||||
Colors.SaddleBrown,
|
||||
Colors.Sienna,
|
||||
Colors.Coral,
|
||||
Colors.OrangeRed,
|
||||
Colors.DarkSalmon,
|
||||
Colors.Salmon,
|
||||
Colors.Snow,
|
||||
Colors.RosyBrown,
|
||||
Colors.IndianRed,
|
||||
Colors.Red,
|
||||
Colors.Brown,
|
||||
Colors.DarkRed,
|
||||
Colors.Maroon,
|
||||
Colors.White,
|
||||
Colors.Gainsboro,
|
||||
Colors.Silver,
|
||||
Colors.DarkGray,
|
||||
Colors.Gray,
|
||||
Colors.DimGray,
|
||||
Colors.Black,
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 曲线的配置
|
||||
/// </summary>
|
||||
public class ChartConfig
|
||||
{
|
||||
public List<Color> ListColor = new List<Color>()
|
||||
{
|
||||
Colors.White,
|
||||
Colors.Red,
|
||||
Colors.Blue,
|
||||
Colors.Green,
|
||||
Colors.Orange,
|
||||
Colors.Brown,
|
||||
Colors.Lime,
|
||||
Colors.LightBlue,
|
||||
Colors.Yellow,
|
||||
Colors.BurlyWood,
|
||||
Colors.Gold,
|
||||
Colors.Magenta,
|
||||
Colors.MediumVioletRed,
|
||||
Colors.MintCream,
|
||||
Colors.Cornsilk,
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
26
CapMachine.Wpf/Models/ChartCursor.cs
Normal file
26
CapMachine.Wpf/Models/ChartCursor.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Chart光标数据
|
||||
/// </summary>
|
||||
public class ChartCursor:BindableBase
|
||||
{
|
||||
private string? _Name;
|
||||
/// <summary>
|
||||
/// 系列的名称
|
||||
/// 也是变量的名称
|
||||
/// </summary>
|
||||
public string? Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { _Name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
21
CapMachine.Wpf/Models/ChartPoint.cs
Normal file
21
CapMachine.Wpf/Models/ChartPoint.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
public class ChartPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public double Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
public DateTime Time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,385 +0,0 @@
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 曲线实时系列模型
|
||||
/// </summary>
|
||||
public class ChartRtSeries : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="axisY"></param>
|
||||
/// <param name="lightningChart"></param>
|
||||
/// <param name="SeriesName"></param>
|
||||
//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);
|
||||
|
||||
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public ChartRtSeries(LightningChart lightningChart, ChartConfig chartConfig, List<ChartRtSeries> listchartRtSeries, ConfigChartSelect configChartSelect)
|
||||
{
|
||||
//模型赋值
|
||||
LightningChartInstance = lightningChart;
|
||||
ChartConfigInfo = chartConfig;
|
||||
ChartAxisY = configChartSelect.ConfigChartYAxis;
|
||||
ChartAxisX = LightningChartInstance.ViewXY.XAxes[0];
|
||||
Name = configChartSelect.Name;
|
||||
ListChartRtSeries= listchartRtSeries;
|
||||
|
||||
AddSeries(configChartSelect.Name!, configChartSelect.ConfigChartYAxis!);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region 基本信息
|
||||
|
||||
|
||||
private string? _Name;
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string? Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { _Name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
//private string? _Unit;
|
||||
///// <summary>
|
||||
///// 单位
|
||||
///// </summary>
|
||||
//public string? Unit
|
||||
//{
|
||||
// get { return _Unit; }
|
||||
// set { _Unit = value; RaisePropertyChanged(); }
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除Y轴信息
|
||||
/// </summary>
|
||||
public void DeleteAxisY()
|
||||
{
|
||||
//删除Y轴信息
|
||||
LightningChartInstance.ViewXY.YAxes.Remove(LightningChartInstance.ViewXY.YAxes.FindFirst(a => a.Title.Text == ChartAxisY.Name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除系列
|
||||
/// </summary>
|
||||
public void DeleteSeries()
|
||||
{
|
||||
LightningChartInstance.BeginUpdate();
|
||||
|
||||
LightningChartInstance.ViewXY.PointLineSeries.Remove(ChartPointLineSeries);
|
||||
|
||||
LightningChartInstance.EndUpdate();
|
||||
|
||||
ListChartRtSeries.Remove(ListChartRtSeries.FindFirst(a=>a.Name== Name));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增加系列
|
||||
/// </summary>
|
||||
/// <param name="Name"></param>
|
||||
private void AddSeries(string SeriesName, ConfigChartYAxis configChartYAxis)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取AxisY信息
|
||||
/// </summary>
|
||||
/// <param name="AxisName"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取PointLineSeries信息
|
||||
/// </summary>
|
||||
/// <param name="AxisName"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上层管理集合
|
||||
/// </summary>
|
||||
public List<ChartRtSeries> ListChartRtSeries { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 曲线
|
||||
/// </summary>
|
||||
public PointLineSeries? ChartPointLineSeries { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Y轴
|
||||
/// </summary>
|
||||
public ConfigChartYAxis? ChartAxisY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// X轴
|
||||
/// </summary>
|
||||
public AxisX? ChartAxisX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LightningChart 实例
|
||||
/// </summary>
|
||||
public LightningChart LightningChartInstance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线配置信息
|
||||
/// </summary>
|
||||
public ChartConfig ChartConfigInfo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// X轴滚动
|
||||
/// </summary>
|
||||
private bool ScrollEnable = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Chart图表X轴的跨度-秒
|
||||
/// </summary>
|
||||
private int ChartXDateTimeRange = 3600;
|
||||
|
||||
/// <summary>
|
||||
/// 增加数据
|
||||
/// </summary>
|
||||
public void AddValue(double Data)
|
||||
{
|
||||
//foreach (var item in LightningChartInstance.ViewXY.PointLineSeries)
|
||||
//{
|
||||
//Disable updates, to prevent several extra refreshes
|
||||
LightningChartInstance.BeginUpdate();
|
||||
|
||||
//Array for 1 point
|
||||
SeriesPoint[] points = new SeriesPoint[1];
|
||||
|
||||
//Convert 'Now' to X value
|
||||
var _previousX = LightningChartInstance.ViewXY.XAxes[0].DateTimeToAxisValue(DateTime.Now);
|
||||
points[0].X = _previousX;
|
||||
points[0].Y = Data;
|
||||
//Add the new point into end of first PointLineSeries
|
||||
ChartPointLineSeries.AddPoints(points, false);
|
||||
|
||||
ChartPointLineSeries.DeletePointsBeforeX(_previousX - ChartXDateTimeRange);
|
||||
//item.DeletePointsBeforeX(_previousX - 100);
|
||||
|
||||
if (ScrollEnable)
|
||||
{
|
||||
LightningChartInstance.ViewXY.XAxes[0].ScrollPosition = _previousX;
|
||||
}
|
||||
|
||||
//Allow updates again, and update
|
||||
LightningChartInstance.EndUpdate();
|
||||
|
||||
Value = Data;
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solve value from series data points array. Accurate method, but slower than SolveValueCoarse
|
||||
/// </summary>
|
||||
/// <param name="series">Series</param>
|
||||
/// <param name="xValue">X value</param>
|
||||
/// <param name="yValue">Output Y value</param>
|
||||
/// <returns>Success status</returns>
|
||||
private bool SolveValueAccurate(PointLineSeries series, double xValue, out double yValue)
|
||||
{
|
||||
AxisY axisY = LightningChartInstance.ViewXY.YAxes[series.AssignYAxisIndex];
|
||||
yValue = 0;
|
||||
|
||||
LineSeriesValueSolveResult result = series.SolveYValueAtXValue(xValue);
|
||||
if (result.SolveStatus == LineSeriesSolveStatus.OK)
|
||||
{
|
||||
//PointLineSeries may have two or more points at same X value. If so, center it between min and max
|
||||
yValue = (result.YMax + result.YMin) / 2.0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solve value from screen coordinates. Faster method, but not less accurateValue than SolveValueAccurate
|
||||
/// </summary>
|
||||
/// <param name="series">Series</param>
|
||||
/// <param name="xValue">X value</param>
|
||||
/// <param name="yValue">Output Y value</param>
|
||||
/// <returns>Success status</returns>
|
||||
private bool SolveValueCoarse(PointLineSeries series, double xValue, out double yValue)
|
||||
{
|
||||
AxisY axisY = LightningChartInstance.ViewXY.YAxes[series.AssignYAxisIndex];
|
||||
float coordX = LightningChartInstance.ViewXY.XAxes[0].ValueToCoord(xValue);
|
||||
float coordY;
|
||||
yValue = 0;
|
||||
|
||||
LineSeriesCoordinateSolveResult result = series.SolveYCoordAtXCoord(coordX);
|
||||
if (result.SolveStatus == LineSeriesSolveStatus.OK)
|
||||
{
|
||||
coordY = (result.CoordBottom + result.CoordTop) / 2f;
|
||||
if (axisY.CoordToValue((int)Math.Round(coordY), out yValue) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Y轴标尺
|
||||
/// </summary>
|
||||
public class ChartYAxisDto
|
||||
public class ChartYAxisDto:BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
@@ -21,24 +17,45 @@ namespace CapMachine.Wpf.Models
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
private string _Name;
|
||||
/// <summary>
|
||||
/// 标尺名称
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
public string Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { _Name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _Max;
|
||||
/// <summary>
|
||||
/// Max
|
||||
/// </summary>
|
||||
public double Max { get; set; }
|
||||
public double Max
|
||||
{
|
||||
get { return _Max; }
|
||||
set { _Max = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _Min;
|
||||
/// <summary>
|
||||
/// Min
|
||||
/// </summary>
|
||||
public double Min { get; set; }
|
||||
public double Min
|
||||
{
|
||||
get { return _Min; }
|
||||
set { _Min = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string _Unit;
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string? Unit { get; set; }
|
||||
public string Unit
|
||||
{
|
||||
get { return _Unit; }
|
||||
set { _Unit = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
565
CapMachine.Wpf/Models/CsvRecordModel.cs
Normal file
565
CapMachine.Wpf/Models/CsvRecordModel.cs
Normal file
@@ -0,0 +1,565 @@
|
||||
using CapMachine.Wpf.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Csv文件保存使用
|
||||
/// </summary>
|
||||
public class CsvRecordModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
[Name("日期")]
|
||||
public string WorkDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
[Name("时间")]
|
||||
public string Time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工况
|
||||
/// </summary>
|
||||
[Name("工况")]
|
||||
public string WorkCond { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 转速[rpm]
|
||||
/// </summary>
|
||||
[Name("转速[rpm]")]
|
||||
public int Speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排气压力[BarA]
|
||||
/// </summary>
|
||||
[Name("排气压力[BarA]")]
|
||||
public double ExPress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 吸气压力[BarA]
|
||||
/// </summary>
|
||||
[Name("吸气压力[BarA]")]
|
||||
public double InhPress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 吸气温度[℃]
|
||||
/// </summary>
|
||||
[Name("吸气温度[℃]")]
|
||||
public double InhTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// COND1温度[℃]
|
||||
/// </summary>
|
||||
[Name("COND1温度[℃]")]
|
||||
public double Cond1Temp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 润滑油压力[BarA]
|
||||
/// </summary>
|
||||
[Name("润滑油压力[BarA]")]
|
||||
public double LubePress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// COND2压力[BarA]
|
||||
/// </summary>
|
||||
[Name("COND2压力[BarA]")]
|
||||
public double Cond2Press { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OCR[%]
|
||||
/// </summary>
|
||||
[Name("OCR[%]")]
|
||||
public double OCR { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HV[V]
|
||||
/// </summary>
|
||||
[Name("HV[V]")]
|
||||
public double HV { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HV[A]
|
||||
/// </summary>
|
||||
[Name("HV[A]")]
|
||||
public double HVCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HV[W]
|
||||
/// </summary>
|
||||
[Name("HV[W]")]
|
||||
public double HVPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LV[V]
|
||||
/// </summary>
|
||||
[Name("LV[V]")]
|
||||
public double LV { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LV[A]
|
||||
/// </summary>
|
||||
[Name("LV[A]")]
|
||||
public double LVCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 环境温度[℃]
|
||||
/// </summary>
|
||||
[Name("环境温度[℃]")]
|
||||
public double EnvTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 环境湿度[%]
|
||||
/// </summary>
|
||||
[Name("环境湿度[%]")]
|
||||
public double EnvRH { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OS1温度[℃]
|
||||
/// </summary>
|
||||
[Name("OS1温度[℃]")]
|
||||
public double OS1Temp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OS2温度[℃]
|
||||
/// </summary>
|
||||
[Name("OS2温度[℃]")]
|
||||
public double OS2Temp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// COND2温度[℃]
|
||||
/// </summary>
|
||||
[Name("COND2温度[℃]")]
|
||||
public double Cond2Temp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// EVAP出口温度[℃]
|
||||
/// </summary>
|
||||
[Name("EVAP出口温度[℃]")]
|
||||
public double EVAPExpTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 冷媒流量[L/min]
|
||||
/// </summary>
|
||||
[Name("冷媒流量[L/min]")]
|
||||
public double VRV { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 润滑油流量[L/min]
|
||||
/// </summary>
|
||||
[Name("润滑油流量[L/min]")]
|
||||
public double LubeFlow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排气温度[℃]
|
||||
/// </summary>
|
||||
[Name("排气温度[℃]")]
|
||||
public double ExTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 膨胀阀前压力[BarA]
|
||||
/// </summary>
|
||||
[Name("膨胀阀前压力[BarA]")]
|
||||
public double TxvFrPress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 膨胀阀前温度[℃]
|
||||
/// </summary>
|
||||
[Name("膨胀阀前温度[℃]")]
|
||||
public double TxvFrTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// EVAP出口压力[BarA]
|
||||
/// </summary>
|
||||
[Name("EVAP出口压力[BarA]")]
|
||||
public double EVAPExpPress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 腔内压力[BarA]
|
||||
/// </summary>
|
||||
[Name("腔内压力[BarA]")]
|
||||
public double IntrplPress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 压缩机表面温度[℃]
|
||||
/// </summary>
|
||||
[Name("压缩机表面温度[℃]")]
|
||||
public double CapSurfTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PTC流量[L/min]
|
||||
/// </summary>
|
||||
[Name("PTC流量[L/min]")]
|
||||
public double PTCFlow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PTC入水温度[℃]
|
||||
/// </summary>
|
||||
[Name("PTC入水温度[℃]")]
|
||||
public double PTCEntTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PTC出水温度[℃]
|
||||
/// </summary>
|
||||
[Name("PTC出水温度[℃]")]
|
||||
public double PTCExpTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯Cmp母线电流[A]
|
||||
/// </summary>
|
||||
[Name("通讯Cmp母线电流[A]")]
|
||||
public double ComCapBusCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯Cmp母线电压[V]
|
||||
/// </summary>
|
||||
[Name("通讯Cmp母线电压[V]")]
|
||||
public double ComCapBusVol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯Cmp逆变器温度[℃]
|
||||
/// </summary>
|
||||
[Name("通讯Cmp逆变器温度[℃]")]
|
||||
public double ComCapInvTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯Cmp相电流[A]
|
||||
/// </summary>
|
||||
[Name("通讯Cmp相电流[A]")]
|
||||
public double ComCapPhCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯Cmp功率[W]
|
||||
/// </summary>
|
||||
[Name("通讯Cmp功率[W]")]
|
||||
public double ComCapPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯Cmp芯片温度[℃]
|
||||
/// </summary>
|
||||
[Name("通讯Cmp芯片温度[℃]")]
|
||||
public double ComCapChipTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯PTC入水温度[℃]
|
||||
/// </summary>
|
||||
[Name("通讯PTC入水温度[℃]")]
|
||||
public double ComPTCEntTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯PTC出水温度[℃]
|
||||
/// </summary>
|
||||
[Name("通讯PTC出水温度[℃]")]
|
||||
public double ComPTCExpTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯PTC峰值电流[A]
|
||||
/// </summary>
|
||||
[Name("通讯PTC峰值电流[A]")]
|
||||
public double ComPTCPeakCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯PTC母线电流[A]
|
||||
/// </summary>
|
||||
[Name("通讯PTC母线电流[A]")]
|
||||
public double ComPTCBusCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯PTC膜温[℃]
|
||||
/// </summary>
|
||||
[Name("通讯PTC膜温[℃]")]
|
||||
public double ComPTCFlmTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通讯PTC模块温度[℃]
|
||||
/// </summary>
|
||||
[Name("通讯PTC模块温度[℃]")]
|
||||
public double ComPTCMdTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[Name("创建时间")]
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 转速
|
||||
///// </summary>
|
||||
//[Name("转速")]
|
||||
//public int Speed { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 排气压力
|
||||
///// </summary>
|
||||
//[Name("排气压力")]
|
||||
//public double ExPress { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 吸气压力
|
||||
///// </summary>
|
||||
//[Name("吸气压力")]
|
||||
//public double InhPress { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 吸气温度
|
||||
///// </summary>
|
||||
//[Name("吸气温度")]
|
||||
//public double InhTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// COND1温度
|
||||
///// </summary>
|
||||
//[Name("COND1温度")]
|
||||
//public double Cond1Temp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 润滑油压力
|
||||
///// </summary>
|
||||
//[Name("润滑油压力")]
|
||||
//public double LubePress { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// COND2压力
|
||||
///// </summary>
|
||||
//[Name("COND2压力")]
|
||||
//public double Cond2Press { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// OCR
|
||||
///// </summary>
|
||||
//[Name("OCR")]
|
||||
//public double OCR { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// HV
|
||||
///// </summary>
|
||||
//[Name("HV")]
|
||||
//public double HV { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// HV电流
|
||||
///// </summary>
|
||||
//[Name("HV电流")]
|
||||
//public double HVCur { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// HV功率
|
||||
///// </summary>
|
||||
//[Name("HV功率")]
|
||||
//public double HVPw { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// LV
|
||||
///// </summary>
|
||||
//[Name("LV")]
|
||||
//public double LV { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// LV电流
|
||||
///// </summary>
|
||||
//[Name("LV电流")]
|
||||
//public double LVCur { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 环境温度
|
||||
///// </summary>
|
||||
//[Name("环境温度")]
|
||||
//public double EnvTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 环境湿度
|
||||
///// </summary>
|
||||
//[Name("环境湿度")]
|
||||
//public double EnvRH { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// OS1温度
|
||||
///// </summary>
|
||||
//[Name("OS1温度")]
|
||||
//public double OS1Temp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// OS2温度
|
||||
///// </summary>
|
||||
//[Name("OS2温度")]
|
||||
//public double OS2Temp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// COND2温度
|
||||
///// </summary>
|
||||
//[Name("COND2温度")]
|
||||
//public double Cond2Temp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// EVAP出口温度
|
||||
///// </summary>
|
||||
//[Name("EVAP出口温度")]
|
||||
//public double EVAPExpTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 冷媒流量
|
||||
///// </summary>
|
||||
//[Name("冷媒流量")]
|
||||
//public double VRV { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 润滑油流量
|
||||
///// </summary>
|
||||
//[Name("润滑油流量")]
|
||||
//public double LubeFlow { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 排气温度
|
||||
///// </summary>
|
||||
//[Name("排气温度")]
|
||||
//public double ExTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 膨胀阀前压力
|
||||
///// </summary>
|
||||
//[Name("膨胀阀前压力")]
|
||||
//public double TxvFrPress { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 膨胀阀前温度
|
||||
///// </summary>
|
||||
//[Name("膨胀阀前温度")]
|
||||
//public double TxvFrTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// EVAP出口压力
|
||||
///// </summary>
|
||||
//[Name("EVAP出口压力")]
|
||||
//public double EVAPExpPress { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 腔内压力
|
||||
///// </summary>
|
||||
//[Name("腔内压力")]
|
||||
//public double IntrplPress { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 压缩机表面温度
|
||||
///// </summary>
|
||||
//[Name("压缩机表面温度")]
|
||||
//public double CapSurfTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// PTC流量
|
||||
///// </summary>
|
||||
//[Name("PTC流量")]
|
||||
//public double PTCFlow { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// PTC入水温度
|
||||
///// </summary>
|
||||
//[Name("PTC入水温度")]
|
||||
//public double PTCEntTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// PTC出水温度
|
||||
///// </summary>
|
||||
//[Name("PTC出水温度")]
|
||||
//public double PTCExpTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯Cmp母线电流
|
||||
///// </summary>
|
||||
//[Name("通讯Cmp母线电流")]
|
||||
//public double ComCapBusCur { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯Cmp母线电压
|
||||
///// </summary>
|
||||
//[Name("通讯Cmp母线电压")]
|
||||
//public double ComCapBusVol { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯Cmp逆变器温度
|
||||
///// </summary>
|
||||
//[Name("通讯Cmp逆变器温度")]
|
||||
//public double ComCapInvTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯Cmp相电流
|
||||
///// </summary>
|
||||
//[Name("通讯Cmp相电流")]
|
||||
//public double ComCapPhCur { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯Cmp功率
|
||||
///// </summary>
|
||||
//[Name("通讯Cmp功率")]
|
||||
//public double ComCapPw { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯Cmp芯片温度
|
||||
///// </summary>
|
||||
//[Name("通讯Cmp芯片温度")]
|
||||
//public double ComCapChipTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯PTC入水温度
|
||||
///// </summary>
|
||||
//[Name("通讯PTC入水温度")]
|
||||
//public double ComPTCEntTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯PTC出水温度
|
||||
///// </summary>
|
||||
//[Name("通讯PTC出水温度")]
|
||||
//public double ComPTCExpTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯PTC峰值电流
|
||||
///// </summary>
|
||||
//[Name("通讯PTC峰值电流")]
|
||||
//public double ComPTCPeakCur { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯PTC母线电流
|
||||
///// </summary>
|
||||
//[Name("通讯PTC母线电流")]
|
||||
//public double ComPTCBusCur { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯PTC膜温
|
||||
///// </summary>
|
||||
//[Name("通讯PTC膜温")]
|
||||
//public double ComPTCFlmTemp { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 通讯PTC模块温度
|
||||
///// </summary>
|
||||
//[Name("通讯PTC模块温度")]
|
||||
//public double ComPTCMdTemp { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class NameAttribute : Attribute
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public NameAttribute(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
115
CapMachine.Wpf/Models/CsvRecordModelMap.cs
Normal file
115
CapMachine.Wpf/Models/CsvRecordModelMap.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using CsvHelper.Configuration;
|
||||
using Masuit.Tools;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// CSV 从模型映射到CSV的Map信息
|
||||
/// </summary>
|
||||
public class CsvRecordModelMap : ClassMap<CsvRecordModel>
|
||||
{
|
||||
public CsvRecordModelMap()
|
||||
{
|
||||
//Map(m => m.WorkCond).Name("工况");
|
||||
//Map(m => m.Speed).Name("转速");
|
||||
//Map(m => m.ExPress).Name("排气压力");
|
||||
//Map(m => m.InhPress).Name("吸气压力");
|
||||
//Map(m => m.InhTemp).Name("吸气温度");
|
||||
//Map(m => m.Cond1Temp).Name("COND1温度");
|
||||
//Map(m => m.LubePress).Name("润滑油压力");
|
||||
//Map(m => m.Cond2Press).Name("COND2压力");
|
||||
//Map(m => m.OCR).Name("OCR");
|
||||
//Map(m => m.HV).Name("HV");
|
||||
//Map(m => m.HVCur).Name("HV电流");
|
||||
//Map(m => m.HVPw).Name("HV功率");
|
||||
//Map(m => m.LV).Name("LV");
|
||||
//Map(m => m.LVCur).Name("LV电流");
|
||||
//Map(m => m.EnvTemp).Name("环境温度");
|
||||
//Map(m => m.EnvRH).Name("环境湿度");
|
||||
//Map(m => m.OS1Temp).Name("OS1温度");
|
||||
//Map(m => m.OS2Temp).Name("OS2温度");
|
||||
//Map(m => m.Cond2Temp).Name("COND2温度");
|
||||
//Map(m => m.EVAPExpTemp).Name("EVAP出口温度");
|
||||
//Map(m => m.VRV).Name("冷媒流量");
|
||||
//Map(m => m.LubeFlow).Name("润滑油流量");
|
||||
//Map(m => m.ExTemp).Name("排气温度");
|
||||
//Map(m => m.TxvFrPress).Name("膨胀阀前压力");
|
||||
//Map(m => m.TxvFrTemp).Name("膨胀阀前温度");
|
||||
//Map(m => m.EVAPExpPress).Name("EVAP出口压力");
|
||||
//Map(m => m.IntrplPress).Name("腔内压力");
|
||||
//Map(m => m.CapSurfTemp).Name("压缩机表面温度");
|
||||
//Map(m => m.PTCFlow).Name("PTC流量");
|
||||
//Map(m => m.PTCEntTemp).Name("PTC入水温度");
|
||||
//Map(m => m.PTCExpTemp).Name("PTC出水温度");
|
||||
//Map(m => m.ComCapBusCur).Name("通讯Cmp母线电流");
|
||||
//Map(m => m.ComCapBusVol).Name("通讯Cmp母线电压");
|
||||
//Map(m => m.ComCapInvTemp).Name("通讯Cmp逆变器温度");
|
||||
//Map(m => m.ComCapPhCur).Name("通讯Cmp相电流");
|
||||
//Map(m => m.ComCapPw).Name("通讯Cmp功率");
|
||||
//Map(m => m.ComCapChipTemp).Name("通讯Cmp芯片温度");
|
||||
//Map(m => m.ComPTCEntTemp).Name("通讯PTC入水温度");
|
||||
//Map(m => m.ComPTCExpTemp).Name("通讯PTC出水温度");
|
||||
//Map(m => m.ComPTCPeakCur).Name("通讯PTC峰值电流");
|
||||
//Map(m => m.ComPTCBusCur).Name("通讯PTC母线电流");
|
||||
//Map(m => m.ComPTCFlmTemp).Name("通讯PTC膜温");
|
||||
//Map(m => m.ComPTCMdTemp).Name("通讯PTC模块温度");
|
||||
//Map(m => m.CreateTime).Name("时间");
|
||||
|
||||
Map(m => m.WorkDay).Name("日期");
|
||||
Map(m => m.Time).Name("时间");
|
||||
Map(m => m.WorkCond).Name("工况");
|
||||
Map(m => m.Speed).Name("转速[rpm]");
|
||||
Map(m => m.ExPress).Name("排气压力[BarA]");
|
||||
Map(m => m.InhPress).Name("吸气压力[BarA]");
|
||||
Map(m => m.InhTemp).Name("吸气温度[℃]");
|
||||
Map(m => m.Cond1Temp).Name("COND1温度[℃]");
|
||||
Map(m => m.LubePress).Name("润滑油压力[BarA]");
|
||||
Map(m => m.Cond2Press).Name("COND2压力[BarA]");
|
||||
Map(m => m.OCR).Name("OCR[%]");
|
||||
Map(m => m.HV).Name("HV[V]");
|
||||
Map(m => m.HVCur).Name("HV[A]");
|
||||
Map(m => m.HVPw).Name("HV[W]");
|
||||
Map(m => m.LV).Name("LV[V]");
|
||||
Map(m => m.LVCur).Name("LV[A]");
|
||||
Map(m => m.EnvTemp).Name("环境温度[℃]");
|
||||
Map(m => m.EnvRH).Name("环境湿度[%]");
|
||||
Map(m => m.OS1Temp).Name("OS1温度[℃]");
|
||||
Map(m => m.OS2Temp).Name("OS2温度[℃]");
|
||||
Map(m => m.Cond2Temp).Name("COND2温度[℃]");
|
||||
Map(m => m.EVAPExpTemp).Name("EVAP出口温度[℃]");
|
||||
Map(m => m.VRV).Name("冷媒流量[L/min]");
|
||||
Map(m => m.LubeFlow).Name("润滑油流量[L/min]");
|
||||
Map(m => m.ExTemp).Name("排气温度[℃]");
|
||||
Map(m => m.TxvFrPress).Name("膨胀阀前压力[BarA]");
|
||||
Map(m => m.TxvFrTemp).Name("膨胀阀前温度[℃]");
|
||||
Map(m => m.EVAPExpPress).Name("EVAP出口压力[BarA]");
|
||||
Map(m => m.IntrplPress).Name("腔内压力[BarA]");
|
||||
Map(m => m.CapSurfTemp).Name("压缩机表面温度[℃]");
|
||||
Map(m => m.PTCFlow).Name("PTC流量[L/min]");
|
||||
Map(m => m.PTCEntTemp).Name("PTC入水温度[℃]");
|
||||
Map(m => m.PTCExpTemp).Name("PTC出水温度[℃]");
|
||||
Map(m => m.ComCapBusCur).Name("通讯Cmp母线电流[A]");
|
||||
Map(m => m.ComCapBusVol).Name("通讯Cmp母线电压[V]");
|
||||
Map(m => m.ComCapInvTemp).Name("通讯Cmp逆变器温度[℃]");
|
||||
Map(m => m.ComCapPhCur).Name("通讯Cmp相电流[A]");
|
||||
Map(m => m.ComCapPw).Name("通讯Cmp功率[W]");
|
||||
Map(m => m.ComCapChipTemp).Name("通讯Cmp芯片温度[℃]");
|
||||
Map(m => m.ComPTCEntTemp).Name("通讯PTC入水温度[℃]");
|
||||
Map(m => m.ComPTCExpTemp).Name("通讯PTC出水温度[℃]");
|
||||
Map(m => m.ComPTCPeakCur).Name("通讯PTC峰值电流[A]");
|
||||
Map(m => m.ComPTCBusCur).Name("通讯PTC母线电流[A]");
|
||||
Map(m => m.ComPTCFlmTemp).Name("通讯PTC膜温[℃]");
|
||||
Map(m => m.ComPTCMdTemp).Name("通讯PTC模块温度[℃]");
|
||||
Map(m => m.CreateTime).Name("时间");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
1799
CapMachine.Wpf/Models/LightChart/ChartManager.cs
Normal file
1799
CapMachine.Wpf/Models/LightChart/ChartManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
612
CapMachine.Wpf/Models/LightChart/ChartRtSeries.cs
Normal file
612
CapMachine.Wpf/Models/LightChart/ChartRtSeries.cs
Normal file
@@ -0,0 +1,612 @@
|
||||
using Arction.Wpf.Charting;
|
||||
using Arction.Wpf.Charting.Annotations;
|
||||
using Arction.Wpf.Charting.Axes;
|
||||
using Arction.Wpf.Charting.SeriesXY;
|
||||
using CapMachine.Model;
|
||||
using CapMachine.Wpf.ChannelModel;
|
||||
using CapMachine.Wpf.Models.Tag;
|
||||
using CapMachine.Wpf.Services;
|
||||
using Force.DeepCloner;
|
||||
using ImTools;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO.Ports;
|
||||
using System.Windows;
|
||||
|
||||
namespace CapMachine.Wpf.Models.LightChart
|
||||
{
|
||||
/// <summary>
|
||||
/// 曲线实时系列模型
|
||||
/// 曲线的系列的封装
|
||||
/// </summary>
|
||||
public class ChartRtSeries : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public ChartRtSeries(LightningChart Chart, ChartColor ChartColor, ObservableCollection<ChartRtSeries> listchartRtSeries, ConfigChart configChart, ConfigService configService,short decimalPoint)
|
||||
{
|
||||
//模型赋值
|
||||
LgChart = Chart;
|
||||
ChartColorInfo = ChartColor;
|
||||
ChartAxisY = configChart.ConfigChartYAxis;
|
||||
ChartAxisX = LgChart.ViewXY.XAxes[0];
|
||||
Name = configChart.Name;
|
||||
ListChartRtSeries = listchartRtSeries;
|
||||
ConfigService = configService;
|
||||
DecimalPoint = decimalPoint;
|
||||
|
||||
AddSeries(configChart.Name!, configChart.ConfigChartYAxis!);
|
||||
|
||||
//初始化字符串
|
||||
ValueEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
LeftCursorEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
RightCursorEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
MinEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
MaxEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
AveEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
}
|
||||
public ChartRtSeries(LightningChart Chart, ChartColor ChartColor, ObservableCollection<ChartRtSeries> listchartRtSeries, HistoryConfigChart configChart, ConfigService configService, short decimalPoint)
|
||||
{
|
||||
//模型赋值
|
||||
LgChart = Chart;
|
||||
ChartColorInfo = ChartColor;
|
||||
ChartAxisY = configChart.ConfigChartYAxis;
|
||||
ChartAxisX = LgChart.ViewXY.XAxes[0];
|
||||
Name = configChart.Name;
|
||||
ListChartRtSeries = listchartRtSeries;
|
||||
|
||||
ConfigService = configService;
|
||||
DecimalPoint = decimalPoint;
|
||||
|
||||
AddSeries(configChart.Name!, configChart.ConfigChartYAxis!);
|
||||
|
||||
//初始化字符串
|
||||
ValueEngValueStr= Math.Round(0.00, DecimalPoint).ToString();
|
||||
LeftCursorEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
RightCursorEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
MinEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
MaxEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
AveEngValueStr = Math.Round(0.00, DecimalPoint).ToString();
|
||||
}
|
||||
|
||||
|
||||
#region 基本信息
|
||||
|
||||
private string? _Name;
|
||||
/// <summary>
|
||||
/// 系列的名称
|
||||
/// 也是变量的名称
|
||||
/// </summary>
|
||||
public string? Name
|
||||
{
|
||||
get { return _Name; }
|
||||
set { _Name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set
|
||||
{
|
||||
if (_Value != value)
|
||||
{
|
||||
_Value = value;
|
||||
RaisePropertyChanged();
|
||||
ValueEngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _ValueEngValueStr;
|
||||
/// <summary>
|
||||
/// ValueEngValueStr 值 工程值的字符串
|
||||
/// </summary>
|
||||
public string ValueEngValueStr
|
||||
{
|
||||
get { return _ValueEngValueStr; }
|
||||
set { _ValueEngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 小数点
|
||||
/// </summary>
|
||||
public short DecimalPoint { get; set; }
|
||||
|
||||
|
||||
private string? _Group;
|
||||
/// <summary>
|
||||
/// 组信息
|
||||
/// </summary>
|
||||
public string? Group
|
||||
{
|
||||
get { return _Group; }
|
||||
set { _Group = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string? _Unit;
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string? Unit
|
||||
{
|
||||
get { return _Unit; }
|
||||
set { _Unit = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string? _FontInfo = "";
|
||||
/// <summary>
|
||||
/// 字体信息
|
||||
/// </summary>
|
||||
public string? FontInfo
|
||||
{
|
||||
get { return _FontInfo; }
|
||||
set { _FontInfo = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 订阅到的缓存的数据
|
||||
/// </summary>
|
||||
public List<CacheRtChartData> ListCacheRtChartData { get; set; } = new List<CacheRtChartData>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 当前曲线的光标的信息
|
||||
|
||||
private double _LeftCursorValue;
|
||||
/// <summary>
|
||||
/// 左游标值
|
||||
/// </summary>
|
||||
public double LeftCursorValue
|
||||
{
|
||||
get { return _LeftCursorValue; }
|
||||
set
|
||||
{
|
||||
if (_LeftCursorValue != value)
|
||||
{
|
||||
_LeftCursorValue = value;
|
||||
RaisePropertyChanged();
|
||||
LeftCursorEngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _LeftCursorEngValueStr;
|
||||
/// <summary>
|
||||
/// LeftCursor 左游标值 工程值的字符串
|
||||
/// </summary>
|
||||
public string LeftCursorEngValueStr
|
||||
{
|
||||
get { return _LeftCursorEngValueStr; }
|
||||
set { _LeftCursorEngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
private double _RightCursorValue;
|
||||
/// <summary>
|
||||
/// 右游标值
|
||||
/// </summary>
|
||||
public double RightCursorValue
|
||||
{
|
||||
get { return _RightCursorValue; }
|
||||
set
|
||||
{
|
||||
if (_RightCursorValue != value)
|
||||
{
|
||||
_RightCursorValue = value;
|
||||
RaisePropertyChanged();
|
||||
RightCursorEngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _RightCursorEngValueStr;
|
||||
/// <summary>
|
||||
/// RightCursor 右游标值 工程值的字符串
|
||||
/// </summary>
|
||||
public string RightCursorEngValueStr
|
||||
{
|
||||
get { return _RightCursorEngValueStr; }
|
||||
set { _RightCursorEngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
private double _MinValue;
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public double MinValue
|
||||
{
|
||||
get { return _MinValue; }
|
||||
set
|
||||
{
|
||||
if (_MinValue != value)
|
||||
{
|
||||
_MinValue = value;
|
||||
RaisePropertyChanged();
|
||||
MinEngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _MinEngValueStr;
|
||||
/// <summary>
|
||||
/// Min 最小值 工程值的字符串
|
||||
/// </summary>
|
||||
public string MinEngValueStr
|
||||
{
|
||||
get { return _MinEngValueStr; }
|
||||
set { _MinEngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _MaxValue;
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
public double MaxValue
|
||||
{
|
||||
get { return _MaxValue; }
|
||||
set
|
||||
{
|
||||
if (_MaxValue != value)
|
||||
{
|
||||
_MaxValue = value;
|
||||
RaisePropertyChanged();
|
||||
MaxEngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _MaxEngValueStr;
|
||||
/// <summary>
|
||||
/// Max 最大值 工程值的字符串
|
||||
/// </summary>
|
||||
public string MaxEngValueStr
|
||||
{
|
||||
get { return _MaxEngValueStr; }
|
||||
set { _MaxEngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _AveValue;
|
||||
/// <summary>
|
||||
/// 平均值
|
||||
/// </summary>
|
||||
public double AveValue
|
||||
{
|
||||
get { return _AveValue; }
|
||||
set
|
||||
{
|
||||
if (_AveValue != value)
|
||||
{
|
||||
_AveValue = value;
|
||||
RaisePropertyChanged();
|
||||
AveEngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _AveEngValueStr;
|
||||
/// <summary>
|
||||
/// Ave 平均值 工程值的字符串
|
||||
/// </summary>
|
||||
public string AveEngValueStr
|
||||
{
|
||||
get { return _AveEngValueStr; }
|
||||
set { _AveEngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///// <summary>
|
||||
///// Chart图表X轴的跨度-秒
|
||||
///// 可以删除之前的数据
|
||||
///// </summary>
|
||||
//public int ChartXDateTimeRange { get; set; } = 3600_8;
|
||||
|
||||
/// <summary>
|
||||
/// 删除曲线系列上的数据
|
||||
/// 积累到一定量后再删除,避免每次更新都删除
|
||||
/// </summary>
|
||||
private int MaxDeleteCacheCount { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 增加系列
|
||||
/// </summary>
|
||||
/// <param name="Name"></param>
|
||||
private void AddSeries(string SeriesName, ConfigChartYAxis configChartYAxis)
|
||||
{
|
||||
LgChart.BeginUpdate();
|
||||
//定义一个轴设置
|
||||
AxisY AxisYInfo;
|
||||
|
||||
if (configChartYAxis == null)
|
||||
{
|
||||
MessageBox.Show($"没有发现曲线:【{SeriesName}】轴设置信息,将使用默认的轴设置。请到【曲线轴设置】中进行检查", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
|
||||
//新增
|
||||
AxisYInfo = new AxisY();
|
||||
}
|
||||
else
|
||||
{
|
||||
//轴信息不为空的话,则进行后续的判断
|
||||
//判断之前的系列是否已经存在(依据名称),存在使用之前的系列,否则新增
|
||||
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;
|
||||
LgChart.ViewXY.YAxes.Add(AxisYInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
//使用之前
|
||||
AxisYInfo.SetRange(configChartYAxis.Min, configChartYAxis.Max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var SeriesInfo = GetPointLineSeries(SeriesName);
|
||||
if (SeriesInfo == null)
|
||||
{
|
||||
//新增
|
||||
SeriesInfo = new PointLineSeries(LgChart.ViewXY, LgChart.ViewXY.XAxes[0], AxisYInfo);
|
||||
SeriesInfo.Title.Text = SeriesName;
|
||||
SeriesInfo.LineStyle.Color = ChartColorInfo.ListColor[LgChart.ViewXY.PointLineSeries.Count];
|
||||
SeriesInfo.AllowUserInteraction = false;
|
||||
LgChart.ViewXY.PointLineSeries.Add(SeriesInfo);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//使用之前
|
||||
SeriesInfo.AssignYAxisIndex = AxisYInfo.SegmentIndex;
|
||||
}
|
||||
|
||||
//赋值给当前的模型
|
||||
ChartPointLineSeries = SeriesInfo;
|
||||
|
||||
//Configure and add series to the chart
|
||||
|
||||
LgChart.EndUpdate();
|
||||
}
|
||||
|
||||
public void AddPointByCache(DateTime dateTime, double value, bool IsDeleteBefore, bool IsScrollEnable)
|
||||
{
|
||||
//入缓存集合中
|
||||
ListCacheRtChartData.Add(new CacheRtChartData()
|
||||
{
|
||||
Value = value,
|
||||
CreateTime = dateTime,
|
||||
});
|
||||
//判断是否满足要求
|
||||
if (ListCacheRtChartData.Count() >= 6)
|
||||
{
|
||||
|
||||
//Disable updates, to prevent several extra refreshes
|
||||
LgChart.BeginUpdate();
|
||||
|
||||
var ListSeriesPoint = ListCacheRtChartData.Select(a => new SeriesPoint()
|
||||
{
|
||||
X = ChartAxisX!.DateTimeToAxisValue(a.CreateTime),
|
||||
Y = a.Value
|
||||
});
|
||||
|
||||
ChartPointLineSeries!.AddPoints(ListSeriesPoint.ToArray(), false);
|
||||
|
||||
//暂时不删除数据
|
||||
if (IsDeleteBefore)
|
||||
{
|
||||
MaxDeleteCacheCount++;
|
||||
//积累到一定量后再删除旧的数据
|
||||
if (MaxDeleteCacheCount >= 200)
|
||||
{
|
||||
ChartPointLineSeries!.DeletePointsBeforeX(ListSeriesPoint.LastOrDefault().X - ConfigService.ChartRtDataCacheTimeSec);
|
||||
MaxDeleteCacheCount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
//ChartPointLineSeries!.DeletePointsBeforeX(_previousX - ChartXDateTimeRange);
|
||||
//item.DeletePointsBeforeX(_previousX - 100);
|
||||
|
||||
if (IsScrollEnable)
|
||||
{
|
||||
LgChart.ViewXY.XAxes[0].ScrollPosition = ListSeriesPoint.FirstOrDefault().X;
|
||||
}
|
||||
|
||||
//Allow updates again, and update
|
||||
LgChart.EndUpdate();
|
||||
|
||||
//删除缓存的数据
|
||||
ListCacheRtChartData.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加数据的点
|
||||
/// </summary>
|
||||
public void AddPoint(DateTime dateTime, double value, bool IsDeleteBefore, bool IsScrollEnable)
|
||||
{
|
||||
//Disable updates, to prevent several extra refreshes
|
||||
LgChart.BeginUpdate();
|
||||
|
||||
//Array for 1 point
|
||||
SeriesPoint[] points = new SeriesPoint[1];
|
||||
|
||||
//Convert 'Now' to X value
|
||||
var _previousX = LgChart.ViewXY.XAxes[0].DateTimeToAxisValue(dateTime);
|
||||
points[0].X = _previousX;
|
||||
points[0].Y = value;
|
||||
//Add the new point into end of first PointLineSeries
|
||||
ChartPointLineSeries!.AddPoints(points, false);
|
||||
|
||||
//暂时不删除数据
|
||||
if (IsDeleteBefore)
|
||||
{
|
||||
ChartPointLineSeries!.DeletePointsBeforeX(_previousX - ConfigService.ChartRtDataCacheTimeSec);
|
||||
}
|
||||
//ChartPointLineSeries!.DeletePointsBeforeX(_previousX - ChartXDateTimeRange);
|
||||
//item.DeletePointsBeforeX(_previousX - 100);
|
||||
|
||||
if (IsScrollEnable)
|
||||
{
|
||||
LgChart.ViewXY.XAxes[0].ScrollPosition = _previousX;
|
||||
}
|
||||
|
||||
//Allow updates again, and update
|
||||
LgChart.EndUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量增加数据的点
|
||||
/// </summary>
|
||||
public void AddRangePoint(List<ChartPoint> Data)
|
||||
{
|
||||
//Disable updates, to prevent several extra refreshes
|
||||
LgChart.BeginUpdate();
|
||||
|
||||
//Array for 1 point
|
||||
SeriesPoint[] points = new SeriesPoint[Data.Count];
|
||||
for (int i = 0; i < Data.Count; i++)
|
||||
{
|
||||
//Convert 'Now' to X value
|
||||
points[i].X = LgChart.ViewXY.XAxes[0].DateTimeToAxisValue(Data[i].Time); ;
|
||||
points[i].Y = Data[i].Value;
|
||||
}
|
||||
|
||||
//Add the new point into end of first PointLineSeries
|
||||
ChartPointLineSeries!.AddPoints(points, false);
|
||||
|
||||
|
||||
//Allow updates again, and update
|
||||
LgChart.EndUpdate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增加RecordChannelData集合的数据的点
|
||||
/// </summary>
|
||||
public void AddPointByDicData(List<RecordChannelData> recordChannelDatas, string Name)
|
||||
{
|
||||
var Data = recordChannelDatas.DeepClone();
|
||||
foreach (var item in Data)
|
||||
{
|
||||
if (item.Data!.TryGetValue(Name, out object result))
|
||||
{
|
||||
AddPoint(item.CreateTime, Convert.ToDouble(result), false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加历史数据的点集合
|
||||
/// </summary>
|
||||
/// <param name="chartPoints"></param>
|
||||
/// <param name="Name"></param>
|
||||
public void AddRecordPointByName(List<ChartPoint> chartPoints)
|
||||
{
|
||||
AddRangePoint(chartPoints);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取AxisY信息
|
||||
/// </summary>
|
||||
/// <param name="AxisName"></param>
|
||||
/// <returns></returns>
|
||||
private AxisY GetAxisY(string AxisName)
|
||||
{
|
||||
var AxisYs = LgChart.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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取PointLineSeries信息
|
||||
/// </summary>
|
||||
/// <param name="AxisName"></param>
|
||||
/// <returns></returns>
|
||||
private PointLineSeries GetPointLineSeries(string SeriesName)
|
||||
{
|
||||
var PointLineSeries = LgChart.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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上层管理集合
|
||||
/// </summary>
|
||||
public ObservableCollection<ChartRtSeries> ListChartRtSeries { get; set; }
|
||||
public ConfigService ConfigService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线数据
|
||||
/// </summary>
|
||||
public PointLineSeries? ChartPointLineSeries { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Y轴
|
||||
/// </summary>
|
||||
public ConfigChartYAxis? ChartAxisY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Y轴 ConfigChartYAxis Id
|
||||
/// 用于标记Y轴的配置信息
|
||||
/// </summary>
|
||||
public long ConfigChartYAxisId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// X轴
|
||||
/// </summary>
|
||||
public AxisX? ChartAxisX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// LightningChart 实例
|
||||
/// </summary>
|
||||
public LightningChart LgChart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 曲线配置信息
|
||||
/// </summary>
|
||||
public ChartColor ChartColorInfo { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
100
CapMachine.Wpf/Models/SeekData.cs
Normal file
100
CapMachine.Wpf/Models/SeekData.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using CapMachine.Model;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 种子数据
|
||||
/// </summary>
|
||||
public class SeekData
|
||||
{
|
||||
public SeekData(IFreeSql freeSql)
|
||||
{
|
||||
FreeSql = freeSql;
|
||||
|
||||
LoadChartTabGroupData();
|
||||
LoadConfigChartYAxisData();
|
||||
LoadUserData();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载Tab数据
|
||||
/// </summary>
|
||||
public void LoadChartTabGroupData()
|
||||
{
|
||||
var FindChartTabGroupData = FreeSql.Select<ChartTabGroup>().ToList();
|
||||
|
||||
if (FindChartTabGroupData!.Count() == 0)
|
||||
{
|
||||
var ListChartTabGroup = new List<ChartTabGroup>()
|
||||
{
|
||||
new ChartTabGroup(){ Index=0,IsEnable=true,Machine="M1",Name="工况1"},
|
||||
new ChartTabGroup(){ Index=1,IsEnable=true,Machine="M1",Name="工况2"},
|
||||
new ChartTabGroup(){ Index=2,IsEnable=true,Machine="M1",Name="工况3"},
|
||||
new ChartTabGroup(){ Index=3,IsEnable=true,Machine="M1",Name="工况4"},
|
||||
new ChartTabGroup(){ Index=4,IsEnable=true,Machine="M1",Name="工况5"},
|
||||
};
|
||||
FreeSql.Insert<ChartTabGroup>(ListChartTabGroup).ExecuteAffrows();
|
||||
}
|
||||
|
||||
var FindHistoryChartTabGroup = FreeSql.Select<HistoryChartTabGroup>().ToList();
|
||||
|
||||
if (FindHistoryChartTabGroup!.Count() == 0)
|
||||
{
|
||||
var ListChartTabGroup = new List<HistoryChartTabGroup>()
|
||||
{
|
||||
new HistoryChartTabGroup(){ Index=0,IsEnable=true,Machine="History",Name="工况1"},
|
||||
new HistoryChartTabGroup(){ Index=1,IsEnable=true,Machine="History",Name="工况2"},
|
||||
new HistoryChartTabGroup(){ Index=2,IsEnable=true,Machine="History",Name="工况3"},
|
||||
new HistoryChartTabGroup(){ Index=3,IsEnable=true,Machine="History",Name="工况4"},
|
||||
new HistoryChartTabGroup(){ Index=4,IsEnable=true,Machine="History",Name="工况5"},
|
||||
};
|
||||
FreeSql.Insert<HistoryChartTabGroup>(ListChartTabGroup).ExecuteAffrows();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载Y轴的数据
|
||||
/// </summary>
|
||||
public void LoadConfigChartYAxisData()
|
||||
{
|
||||
var FindConfigChartYAxis = FreeSql.Select<ConfigChartYAxis>().ToList();
|
||||
|
||||
if (FindConfigChartYAxis!.Count() == 0)
|
||||
{
|
||||
var ListConfigChartYAxis = new List<ConfigChartYAxis>()
|
||||
{
|
||||
new ConfigChartYAxis(){ Index=0,Min=0,Max=100,Name="温度",Unit="℃"},
|
||||
new ConfigChartYAxis(){ Index=1,Min=0,Max=100,Name="湿度",Unit="%"},
|
||||
new ConfigChartYAxis(){ Index=2,Min=0,Max=8000,Name="转速",Unit="rpm"},
|
||||
new ConfigChartYAxis(){ Index=3,Min=0,Max=100,Name="电压",Unit="V"},
|
||||
new ConfigChartYAxis(){ Index=4,Min=0,Max=100,Name="电流",Unit="A"},
|
||||
new ConfigChartYAxis(){ Index=5,Min=0,Max=5,Name="压力",Unit="BarA"},
|
||||
new ConfigChartYAxis(){ Index=6,Min=0,Max=5,Name="流量",Unit="L/min"},
|
||||
new ConfigChartYAxis(){ Index=7,Min=0,Max=5,Name="功率",Unit="W"},
|
||||
};
|
||||
FreeSql.Insert<ConfigChartYAxis>(ListConfigChartYAxis).ExecuteAffrows();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载Y轴的数据
|
||||
/// </summary>
|
||||
public void LoadUserData()
|
||||
{
|
||||
var FindUser = FreeSql.Select<User>().ToList();
|
||||
|
||||
if (FindUser!.Count() == 0)
|
||||
{
|
||||
var ListUser = new List<User>()
|
||||
{
|
||||
new User(){ Name="admin",Password="123",Level="管理员",IsEnable=true},
|
||||
};
|
||||
FreeSql.Insert<User>(ListUser).ExecuteAffrows();
|
||||
}
|
||||
|
||||
}
|
||||
public IFreeSql FreeSql { get; }
|
||||
}
|
||||
}
|
||||
380
CapMachine.Wpf/Models/State/MachineRunState.cs
Normal file
380
CapMachine.Wpf/Models/State/MachineRunState.cs
Normal file
@@ -0,0 +1,380 @@
|
||||
using CapMachine.Wpf.Services;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using Stateless;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备的运行状态
|
||||
/// https://www.cnblogs.com/podolski/p/13215064.html
|
||||
/// </summary>
|
||||
public class MachineRunState : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化
|
||||
/// </summary>
|
||||
public MachineRunState(string name, IEventAggregator eventAggregator, ConfigService configService)
|
||||
{
|
||||
Name = name;
|
||||
EventAggregator = eventAggregator;
|
||||
ConfigService = configService;
|
||||
InitConfig();
|
||||
|
||||
}
|
||||
|
||||
private string _RunStateMsg="等待";
|
||||
/// <summary>
|
||||
/// 运行状态
|
||||
/// </summary>
|
||||
public string RunStateMsg
|
||||
{
|
||||
get { return _RunStateMsg; }
|
||||
set { _RunStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC程序是否下载
|
||||
/// </summary>
|
||||
public bool IsProLoad { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态机
|
||||
/// </summary>
|
||||
public StateMachine<RunState, RunStateTrig> StateMachine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始化配置信息
|
||||
/// </summary>
|
||||
private void InitConfig()
|
||||
{
|
||||
//状态机初始化
|
||||
StateMachine = new StateMachine<RunState, RunStateTrig>(RunState.Wait);
|
||||
|
||||
StateMachine.Configure(RunState.Wait)
|
||||
.OnEntry(t => WaitEntryCall())
|
||||
.OnExit(t => WaitExitCall())
|
||||
.PermitIf(RunStateTrig.AlarmTrig, RunState.Alarm, () => AlarmPreValid())
|
||||
.PermitIf(RunStateTrig.StartTrig, RunState.Run, () => RunPreValid())
|
||||
//.Permit(RunStateTrig.StartTrig, RunState.Run)
|
||||
//.Permit(RunStateTrig.ResetTrig, RunState.Wait)
|
||||
.PermitIf(RunStateTrig.EndTrig, RunState.Stop, () => StopPreValid())
|
||||
.PermitIf(RunStateTrig.PauseTrig, RunState.Pause, () => PausePreValid())
|
||||
.Ignore(RunStateTrig.ResetTrig)
|
||||
.Ignore(RunStateTrig.WaitTrig);
|
||||
|
||||
StateMachine.Configure(RunState.Alarm)
|
||||
.OnEntry(t => AlarmEntryCall())
|
||||
.OnExit(t => AlarmExitCall())
|
||||
.PermitIf(RunStateTrig.WaitTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.ResetTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.StartTrig, RunState.Run, () => RunPreValid())
|
||||
.PermitIf(RunStateTrig.EndTrig, RunState.Stop, () => StopPreValid())
|
||||
.PermitIf(RunStateTrig.PauseTrig, RunState.Pause, () => PausePreValid())
|
||||
.Ignore(RunStateTrig.AlarmTrig);
|
||||
|
||||
StateMachine.Configure(RunState.Run)
|
||||
.OnEntry(t => RunEntryCall())
|
||||
.OnExit(t => RunExitCall())
|
||||
.PermitIf(RunStateTrig.WaitTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.ResetTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.AlarmTrig, RunState.Alarm, () => AlarmPreValid())
|
||||
.PermitIf(RunStateTrig.EndTrig, RunState.Stop, () => StopPreValid())
|
||||
.PermitIf(RunStateTrig.PauseTrig, RunState.Pause, () => PausePreValid())
|
||||
.Ignore(RunStateTrig.StartTrig);
|
||||
|
||||
StateMachine.Configure(RunState.Stop)
|
||||
.OnEntry(t => StopEntryCall())
|
||||
.OnExit(t => StopExitCall())
|
||||
.PermitIf(RunStateTrig.WaitTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.ResetTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.AlarmTrig, RunState.Alarm, () => AlarmPreValid())
|
||||
.PermitIf(RunStateTrig.StartTrig, RunState.Run, () => RunPreValid())
|
||||
.PermitIf(RunStateTrig.PauseTrig, RunState.Pause, () => PausePreValid())
|
||||
.Ignore(RunStateTrig.EndTrig);
|
||||
|
||||
StateMachine.Configure(RunState.Pause)
|
||||
.OnEntry(t => PauseEntryCall())
|
||||
.OnExit(t => PauseExitCall())
|
||||
.PermitIf(RunStateTrig.WaitTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.ResetTrig, RunState.Wait, () => WaitPreValid())
|
||||
.PermitIf(RunStateTrig.AlarmTrig, RunState.Alarm, () => AlarmPreValid())
|
||||
.PermitIf(RunStateTrig.StartTrig, RunState.Run, () => RunPreValid())
|
||||
.PermitIf(RunStateTrig.EndTrig, RunState.Stop, () => StopPreValid())
|
||||
.Ignore(RunStateTrig.PauseTrig);
|
||||
|
||||
}
|
||||
|
||||
#region 验证状态
|
||||
|
||||
/// <summary>
|
||||
/// 进入 Wait 状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FireWait()
|
||||
{
|
||||
var Result = StateMachine.CanFire(RunStateTrig.WaitTrig);
|
||||
if (Result)
|
||||
{
|
||||
StateMachine.Fire(RunStateTrig.WaitTrig);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"WaitTrig-没有满足条件");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入 Alarm状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FireAlarm()
|
||||
{
|
||||
var Result = StateMachine.CanFire(RunStateTrig.AlarmTrig);
|
||||
if (Result)
|
||||
{
|
||||
StateMachine.Fire(RunStateTrig.AlarmTrig);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"AlarmTrig-没有满足条件");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入 Reset状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FireReset()
|
||||
{
|
||||
var Result = StateMachine.CanFire(RunStateTrig.ResetTrig);
|
||||
if (Result)
|
||||
{
|
||||
StateMachine.Fire(RunStateTrig.ResetTrig);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"ResetTrig-没有满足条件");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入 Start 状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FireStart()
|
||||
{
|
||||
var Result = StateMachine.CanFire(RunStateTrig.StartTrig);
|
||||
if (Result)
|
||||
{
|
||||
StateMachine.Fire(RunStateTrig.StartTrig);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"StartTrig-没有满足条件");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入 End 状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FireEnd()
|
||||
{
|
||||
var Result = StateMachine.CanFire(RunStateTrig.EndTrig);
|
||||
if (Result)
|
||||
{
|
||||
StateMachine.Fire(RunStateTrig.EndTrig);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"EndTrig-没有满足条件");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入 Pause 状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool FirePause()
|
||||
{
|
||||
var Result = StateMachine.CanFire(RunStateTrig.PauseTrig);
|
||||
if (Result)
|
||||
{
|
||||
StateMachine.Fire(RunStateTrig.PauseTrig);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"PauseTrig-没有满足条件");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行 状态的条件判断验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private bool RunPreValid()
|
||||
{
|
||||
if (ConfigService.IsExpInfoOk && IsProLoad)
|
||||
{
|
||||
//程序下载并且,试验信息已经设置好后,就可以开始了
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///进入 报警 状态的条件判断验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private bool AlarmPreValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///进入 等待 状态的条件判断验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private bool WaitPreValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///进入 停止 状态的条件判断验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private bool StopPreValid()
|
||||
{
|
||||
//运行切换到停止
|
||||
if (StateMachine.State == RunState.Run)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///进入 暂停 状态的条件判断验证
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private bool PausePreValid()
|
||||
{
|
||||
//运行切换到停止
|
||||
if (StateMachine.State == RunState.Run)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 状态离开和进入方法
|
||||
|
||||
private void PauseExitCall()
|
||||
{
|
||||
Console.WriteLine($"{Name}-PauseExitCall");
|
||||
}
|
||||
|
||||
private void PauseEntryCall()
|
||||
{
|
||||
RunStateMsg = "暂停";
|
||||
Console.WriteLine($"{Name}-PauseEntryCall");
|
||||
}
|
||||
|
||||
private void StopExitCall()
|
||||
{
|
||||
Console.WriteLine($"{Name}-StopExitCall");
|
||||
}
|
||||
|
||||
private void StopEntryCall()
|
||||
{
|
||||
RunStateMsg = "停止";
|
||||
Console.WriteLine($"{Name}-StopEntryCall");
|
||||
}
|
||||
|
||||
private void RunExitCall()
|
||||
{
|
||||
Console.WriteLine($"{Name}-RunExitCall");
|
||||
}
|
||||
|
||||
private void RunEntryCall()
|
||||
{
|
||||
RunStateMsg = "运行";
|
||||
Console.WriteLine($"{Name}-RunEntryCall");
|
||||
|
||||
}
|
||||
|
||||
private void AlarmExitCall()
|
||||
{
|
||||
Console.WriteLine($"{Name}-AlarmExitCall");
|
||||
}
|
||||
|
||||
private void AlarmEntryCall()
|
||||
{
|
||||
RunStateMsg = "报警";
|
||||
Console.WriteLine($"{Name}-AlarmEntryCall");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 离开 等待
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void WaitExitCall()
|
||||
{
|
||||
Console.WriteLine($"{Name}-WaitExitCall");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入 等待
|
||||
/// </summary>
|
||||
private void WaitEntryCall()
|
||||
{
|
||||
RunStateMsg = "等待";
|
||||
Console.WriteLine($"{Name}-WaitExitCall");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public IEventAggregator EventAggregator { get; }
|
||||
public ConfigService ConfigService { get; }
|
||||
}
|
||||
}
|
||||
78
CapMachine.Wpf/Models/State/RunState.cs
Normal file
78
CapMachine.Wpf/Models/State/RunState.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态触发枚举
|
||||
/// </summary>
|
||||
public enum RunStateTrig
|
||||
{
|
||||
/// <summary>
|
||||
/// 等待 触发
|
||||
/// </summary>
|
||||
WaitTrig = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 报警 触发
|
||||
/// </summary>
|
||||
AlarmTrig = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 开始 触发
|
||||
/// </summary>
|
||||
StartTrig = 3,
|
||||
|
||||
/// <summary>
|
||||
/// 结束 触发
|
||||
/// </summary>
|
||||
EndTrig = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 暂停 触发
|
||||
/// </summary>
|
||||
PauseTrig = 5,
|
||||
|
||||
/// <summary>
|
||||
/// 复位 触发
|
||||
/// </summary>
|
||||
ResetTrig = 6,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 状态枚举
|
||||
/// </summary>
|
||||
public enum RunState
|
||||
{
|
||||
/// <summary>
|
||||
/// 等待中
|
||||
/// </summary>
|
||||
Wait = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 报警中
|
||||
/// </summary>
|
||||
Alarm = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 运行中
|
||||
/// </summary>
|
||||
Run = 3,
|
||||
|
||||
/// <summary>
|
||||
/// 停止中
|
||||
/// </summary>
|
||||
Stop = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 暂停中
|
||||
/// </summary>
|
||||
Pause = 5,
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
using HslCommunication;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Prism.Mvvm;
|
||||
using static CapMachine.Wpf.Models.ComEnum;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// 字节变量模型
|
||||
/// </summary>
|
||||
public class ByteTag<T> /*: BaseTag*/
|
||||
{
|
||||
///// <summary>
|
||||
///// 实例化函数
|
||||
///// </summary>
|
||||
///// <param name="name"></param>
|
||||
///// <param name="enName"></param>
|
||||
///// <param name="unit"></param>
|
||||
///// <param name="tagType"></param>
|
||||
//public ByteTag(string name, string enName, string unit, ComEnum.TagType tagType, T registerValue) : base(name, enName, unit, tagType)
|
||||
//{
|
||||
// //IRegisterValue<short> registerValue = new RegisterValue<short>();
|
||||
|
||||
// //RtValue = registerValue;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
public string Name { get; set; }
|
||||
//T BaseTag.RtValue { get; set; }
|
||||
|
||||
//private IRegisterValue<T> _RtValue;
|
||||
///// <summary>
|
||||
///// 实时值
|
||||
///// </summary>
|
||||
//public override IRegisterValue<T> RtValue
|
||||
//{
|
||||
// get { return _RtValue; }
|
||||
// set { _RtValue = value; RaisePropertyChanged(); }
|
||||
//}
|
||||
|
||||
//public override IRegisterValue<T> RtValue { set => throw new NotImplementedException(); }
|
||||
|
||||
//private OperateResult<byte> _OperateResultSource;
|
||||
///// <summary>
|
||||
///// 原始值
|
||||
///// </summary>
|
||||
//public override OperateResult<byte> OperateResultSource
|
||||
//{
|
||||
// get { return _OperateResultSource; }
|
||||
// set
|
||||
// {
|
||||
// if (value != _OperateResultSource)
|
||||
// {
|
||||
// RtValue = value.Content;
|
||||
// }
|
||||
// _OperateResultSource = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private DataType _DataTypeInfo;
|
||||
///// <summary>
|
||||
///// 数据类型信息
|
||||
///// </summary>
|
||||
//public override DataType DataTypeInfo
|
||||
//{
|
||||
// get { return _DataTypeInfo; }
|
||||
// set { _DataTypeInfo = value; RaisePropertyChanged(); }
|
||||
//}
|
||||
|
||||
//public override IRegisterValue<T> RtValue { set => throw new NotImplementedException(); }
|
||||
|
||||
//public override IRegisterValue<T> RtValue => throw new NotImplementedException();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
@@ -21,5 +15,75 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// 英文名称
|
||||
/// </summary>
|
||||
string EnName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称 无单位中文名称
|
||||
/// </summary>
|
||||
string NameNoUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组
|
||||
/// </summary>
|
||||
string Group { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工程值
|
||||
/// </summary>
|
||||
double EngValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工程值的字符串
|
||||
/// </summary>
|
||||
string EngValueStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// MV
|
||||
/// </summary>
|
||||
double MVValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
double MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
double MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值类型
|
||||
/// </summary>
|
||||
Type ValueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// </summary>
|
||||
string PVAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Index
|
||||
/// </summary>
|
||||
string Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 精度
|
||||
/// </summary>
|
||||
short Precision { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 小数点
|
||||
/// </summary>
|
||||
short DecimalPoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为仪表参数
|
||||
/// </summary>
|
||||
bool IsMeter { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
using HslCommunication;
|
||||
using static CapMachine.Wpf.Models.ComEnum;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// 实时数据模型
|
||||
/// </summary>
|
||||
public class RtDataModel : TagInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="enName"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="tagType"></param>
|
||||
public RtDataModel(string name, string enName, string unit, TagType tagType, bool IsChart) : base(name, enName, unit, tagType)
|
||||
{
|
||||
IsChartShow = IsChart;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分类信息
|
||||
/// </summary>
|
||||
public string Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通信结果 实时值
|
||||
/// </summary>
|
||||
private OperateResult<Int16> _OperateResultRtValue;
|
||||
public OperateResult<Int16> OperateResultRtValue
|
||||
{
|
||||
get { return _OperateResultRtValue; }
|
||||
set { _OperateResultRtValue = value; }
|
||||
}
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 实时值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实时值的地址
|
||||
/// </summary>
|
||||
public string RtValueAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否曲线显示
|
||||
/// </summary>
|
||||
public bool IsChartShow { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using HslCommunication;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using static CapMachine.Wpf.Models.ComEnum;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
///// <summary>
|
||||
///// 字变量模型
|
||||
///// </summary>
|
||||
//public class ShortTag : BaseTag
|
||||
//{
|
||||
// public ShortTag(string name, string enName, string unit, ComEnum.TagType tagType) : base(name, enName, unit, tagType)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// private TestType _RtValue;
|
||||
// /// <summary>
|
||||
// /// 实时值
|
||||
// /// </summary>
|
||||
// public override TestType RtValue
|
||||
// {
|
||||
// get { return _RtValue; }
|
||||
// set { _RtValue = value; RaisePropertyChanged(); }
|
||||
// }
|
||||
|
||||
// //private OperateResult<short> _OperateResultSource;
|
||||
// ///// <summary>
|
||||
// ///// 原始值
|
||||
// ///// </summary>
|
||||
// //public override OperateResult<short> OperateResultSource
|
||||
// //{
|
||||
// // get { return _OperateResultSource; }
|
||||
// // set
|
||||
// // {
|
||||
// // if (value != _OperateResultSource)
|
||||
// // {
|
||||
// // RtValue = value.Content;
|
||||
// // }
|
||||
// // _OperateResultSource = value;
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// private DataType _DataTypeInfo;
|
||||
// /// <summary>
|
||||
// /// 数据类型信息
|
||||
// /// </summary>
|
||||
// public override DataType DataTypeInfo
|
||||
// {
|
||||
// get { return _DataTypeInfo; }
|
||||
// set { _DataTypeInfo = value; RaisePropertyChanged(); }
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using HslCommunication;
|
||||
using Prism.Mvvm;
|
||||
using static CapMachine.Wpf.Models.ComEnum;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
@@ -15,15 +14,38 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// <param name="name"></param>
|
||||
/// <param name="enName"></param>
|
||||
/// <param name="tagType"></param>
|
||||
public Tag(string name, string enName, string unit, TagType tagType, IRegisterValue<T> registerValue)
|
||||
public Tag(string nameNoUnit, string name, string enName, string group, string PVaddress, double maxValue, double minValue, short precision, string unit, ITagValue<T> tagValue, bool isMeter)
|
||||
{
|
||||
TagTypeInfo = tagType;
|
||||
Group = group;
|
||||
Name = name;
|
||||
Unit = unit;
|
||||
EnName = enName;
|
||||
PVAddress = PVaddress;
|
||||
MaxValue = maxValue;
|
||||
MinValue = minValue;
|
||||
Precision = precision;
|
||||
|
||||
IsMeter = isMeter;
|
||||
|
||||
NameNoUnit = nameNoUnit;
|
||||
|
||||
//实例化
|
||||
RtValue = registerValue;
|
||||
TagValue = tagValue;
|
||||
ValueType = typeof(T);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="enName"></param>
|
||||
/// <param name="tagType"></param>
|
||||
public Tag(ITagValue<T> tagValue)
|
||||
{
|
||||
//实例化
|
||||
TagValue = tagValue;
|
||||
ValueType = typeof(T);
|
||||
|
||||
}
|
||||
|
||||
@@ -37,19 +59,29 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// </summary>
|
||||
public string EnName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称 无单位中文名称
|
||||
/// </summary>
|
||||
public string NameNoUnit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签组
|
||||
/// </summary>
|
||||
public string Group { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 实时值
|
||||
///// </summary>
|
||||
//public abstract IRegisterValue<short> RtValue { get; set; }
|
||||
|
||||
private IRegisterValue<T> _RtValue;
|
||||
private ITagValue<T> _TagValue;
|
||||
/// <summary>
|
||||
/// 寄存器
|
||||
/// 实时值
|
||||
/// </summary>
|
||||
public IRegisterValue<T> RtValue
|
||||
public ITagValue<T> TagValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; RaisePropertyChanged(); }
|
||||
get { return _TagValue; }
|
||||
set { _TagValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,20 +89,25 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// </summary>
|
||||
public OperateResult<T> OperateResultSource { get; set; } //
|
||||
|
||||
/// <summary>
|
||||
/// 标签类型信息
|
||||
/// </summary>
|
||||
public TagType TagTypeInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型信息
|
||||
/// </summary>
|
||||
public DataType DataTypeInfo { get; set; }
|
||||
public Type ValueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址信息
|
||||
/// 地址信息 PV
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
public string PVAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址信息 SV
|
||||
/// </summary>
|
||||
public string SVAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址信息 MV
|
||||
/// </summary>
|
||||
public string MVAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址信息 Index
|
||||
@@ -88,11 +125,15 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
public double MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 精度
|
||||
/// 小数点
|
||||
/// 精度 到PLC的转换精度/分辨率
|
||||
/// </summary>
|
||||
public short Precision { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 小数点 展示时用的小数点
|
||||
/// </summary>
|
||||
public short DecimalPoint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
@@ -101,14 +142,59 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// <summary>
|
||||
/// 采样周期
|
||||
/// </summary>
|
||||
public int SamplingPeriod { get; set; }
|
||||
}
|
||||
public int Samp { get; set; }
|
||||
|
||||
public struct TestType
|
||||
{
|
||||
public short shortValue { get; set; }
|
||||
public byte byteValue { get; set; }
|
||||
public double doubleValue { get; set; }
|
||||
/// <summary>
|
||||
/// 是否为仪表参数
|
||||
/// </summary>
|
||||
public bool IsMeter { get; set; }
|
||||
|
||||
private double _EngValue;
|
||||
/// <summary>
|
||||
/// 工程值
|
||||
/// </summary>
|
||||
public double EngValue
|
||||
{
|
||||
get { return _EngValue; }
|
||||
set
|
||||
{
|
||||
_EngValue = value;
|
||||
if (TagValue.IsShow)
|
||||
{
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
EngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private string _EngValueStr;
|
||||
/// <summary>
|
||||
/// 工程值的字符串
|
||||
/// </summary>
|
||||
public string EngValueStr
|
||||
{
|
||||
get { return _EngValueStr; }
|
||||
set { _EngValueStr = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _MVValue = 20;
|
||||
/// <summary>
|
||||
/// MV值
|
||||
/// 不是所有的数据都有MV值,只有仪表参数设置的有
|
||||
/// </summary>
|
||||
public double MVValue
|
||||
{
|
||||
get { return _MVValue; }
|
||||
set
|
||||
{
|
||||
_MVValue = value;
|
||||
if (TagValue.IsShow)
|
||||
{
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,32 +11,32 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// </summary>
|
||||
public class TagHelper
|
||||
{
|
||||
private void ParseData(List<TagInfo> tagInfos)
|
||||
private void ParseData(List<ITag> tagInfos)
|
||||
{
|
||||
//分组数据
|
||||
var GroupData = tagInfos.GroupBy(x => x.DataTypeInfo).ToList();
|
||||
foreach (var group in GroupData)
|
||||
{
|
||||
var key = group.Key;
|
||||
var TagListData = group.ToList();
|
||||
switch (group.Key)
|
||||
{
|
||||
case ComEnum.DataType.Short:
|
||||
////分组数据
|
||||
//var GroupData = tagInfos.GroupBy(x => x.DataTypeInfo).ToList();
|
||||
//foreach (var group in GroupData)
|
||||
//{
|
||||
// var key = group.Key;
|
||||
// var TagListData = group.ToList();
|
||||
// switch (group.Key)
|
||||
// {
|
||||
// case ComEnum.DataType.Short:
|
||||
|
||||
break;
|
||||
case ComEnum.DataType.Double:
|
||||
// break;
|
||||
// case ComEnum.DataType.Double:
|
||||
|
||||
break;
|
||||
case ComEnum.DataType.String:
|
||||
// break;
|
||||
// case ComEnum.DataType.String:
|
||||
|
||||
break;
|
||||
case ComEnum.DataType.Byte:
|
||||
// break;
|
||||
// case ComEnum.DataType.Byte:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static CapMachine.Wpf.Models.ComEnum;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签的信息
|
||||
/// </summary>
|
||||
public abstract class TagInfo : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="enName"></param>
|
||||
/// <param name="tagType"></param>
|
||||
public TagInfo(string name,string enName, string unit,TagType tagType)
|
||||
{
|
||||
TagTypeInfo = tagType;
|
||||
Name = name;
|
||||
Unit = unit;
|
||||
EnName = enName;
|
||||
|
||||
//ListRtDataModel=new List<RtDataModel>();
|
||||
}
|
||||
|
||||
|
||||
//public List<RtDataModel> ListRtDataModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称 中文
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称 英文
|
||||
/// </summary>
|
||||
public string EnName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签类型信息
|
||||
/// </summary>
|
||||
public TagType TagTypeInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据类型信息
|
||||
/// </summary>
|
||||
public DataType DataTypeInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址信息
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址信息 Index
|
||||
/// </summary>
|
||||
public string Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
public double MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public double MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 精度
|
||||
/// 小数点
|
||||
/// </summary>
|
||||
public short Precision { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采样周期
|
||||
/// </summary>
|
||||
public int SamplingPeriod { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,4 @@
|
||||
using NPOI.SS.Formula.PTG;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签管理中心
|
||||
@@ -25,7 +17,7 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// <summary>
|
||||
/// 标签集合数据
|
||||
/// </summary>
|
||||
public Dictionary<string, ITag> DicTags = new Dictionary<string, ITag>();
|
||||
public Dictionary<string, ITag> DicTags { get; set; } = new Dictionary<string, ITag>();
|
||||
|
||||
/// <summary>
|
||||
/// 增加标签
|
||||
@@ -67,11 +59,29 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
// 如果找到标签,则返回其值,否则返回默认值
|
||||
if (FindTag != null)
|
||||
{
|
||||
return FindTag!.RtValue.Value;
|
||||
return FindTag!.TagValue.Value;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取标签的值信息
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public ITagValue<T>? GetTagInfoValueByName<T>(string name)
|
||||
{
|
||||
var FindTag = GetTagByName<T>(name);
|
||||
|
||||
// 如果找到标签,则返回其值,否则返回默认值
|
||||
if (FindTag != null)
|
||||
{
|
||||
return FindTag!.TagValue;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,21 +11,22 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// <summary>
|
||||
/// Short类型的寄存器数据
|
||||
/// </summary>
|
||||
public class ShortRegisterValue :BindableBase, IRegisterValue<short>
|
||||
public class ByteTagValue : BindableBase, ITagValue<byte>
|
||||
{
|
||||
private short _Value;
|
||||
private byte _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public short Value
|
||||
public byte Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value;RaisePropertyChanged(); }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 寄存器原始数据
|
||||
/// </summary>
|
||||
public OperateResult<short>? OperateResultSource { get; set; }
|
||||
/// <summary>
|
||||
/// 寄存器原始数据
|
||||
/// </summary>
|
||||
public OperateResult<byte>? OperateResultSource { get; set; }
|
||||
public bool IsShow { get; set; }
|
||||
}
|
||||
}
|
||||
31
CapMachine.Wpf/Models/Tag/TagValue/DoubleTagValue.cs
Normal file
31
CapMachine.Wpf/Models/Tag/TagValue/DoubleTagValue.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using HslCommunication;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// Short类型的寄存器数据
|
||||
/// </summary>
|
||||
public class DoubleTagValue : BindableBase, ITagValue<double>
|
||||
{
|
||||
private double _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否更新展示
|
||||
/// </summary>
|
||||
public bool IsShow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 寄存器原始数据
|
||||
/// </summary>
|
||||
public OperateResult<double>? OperateResultSource { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// 寄存器类型
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IRegisterValue<T> : INotifyPropertyChanged
|
||||
public interface ITagValue<T> : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// 值
|
||||
@@ -18,5 +18,10 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// 值原始数据
|
||||
/// </summary>
|
||||
OperateResult<T> OperateResultSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否展示
|
||||
/// </summary>
|
||||
bool IsShow { get; set; }
|
||||
}
|
||||
}
|
||||
66
CapMachine.Wpf/Models/Tag/TagValue/ShortTagValue.cs
Normal file
66
CapMachine.Wpf/Models/Tag/TagValue/ShortTagValue.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using HslCommunication;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// Short类型的寄存器数据
|
||||
/// </summary>
|
||||
public class ShortTagValue : BindableBase, ITagValue<short>
|
||||
{
|
||||
private short _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public short Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set
|
||||
{
|
||||
if (Value != value)
|
||||
{
|
||||
_Value = value;
|
||||
if (IsShow)
|
||||
{
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private OperateResult<short>? _OperateResultSource = new OperateResult<short>();
|
||||
/// <summary>
|
||||
/// 寄存器原始数据
|
||||
/// </summary>
|
||||
public OperateResult<short>? OperateResultSource
|
||||
{
|
||||
get { return _OperateResultSource; }
|
||||
set
|
||||
{
|
||||
if (value != _OperateResultSource)
|
||||
{
|
||||
Value = value.Content;
|
||||
_OperateResultSource = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否更新展示
|
||||
/// </summary>
|
||||
public bool IsShow { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 寄存器原始数据
|
||||
///// </summary>
|
||||
//public OperateResult<short>? OperateResultSource { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
32
CapMachine.Wpf/Models/Tag/TagValue/StringTagValue.cs
Normal file
32
CapMachine.Wpf/Models/Tag/TagValue/StringTagValue.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using HslCommunication;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
/// <summary>
|
||||
/// String类型的寄存器数据
|
||||
/// </summary>
|
||||
public class StringTagValue : BindableBase, ITagValue<string>
|
||||
{
|
||||
private string? _Value;
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public string? Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 寄存器原始数据
|
||||
/// </summary>
|
||||
public OperateResult<string>? OperateResultSource { get; set; }
|
||||
public bool IsShow { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static CapMachine.Wpf.Models.ComEnum;
|
||||
|
||||
namespace CapMachine.Wpf.Models.Tag
|
||||
{
|
||||
///// <summary>
|
||||
///// 一般的处理方法
|
||||
///// </summary>
|
||||
///// <typeparam name="T"></typeparam>
|
||||
//public class VarTag<T> : BaseTag
|
||||
//{
|
||||
// public VarTag(string name, string enName, string unit, ComEnum.TagType tagType) : base(name, enName, unit, tagType)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// private object _RtValue;
|
||||
// /// <summary>
|
||||
// /// 实时值
|
||||
// /// </summary>
|
||||
// public override object RtValue
|
||||
// {
|
||||
// get { return _RtValue; }
|
||||
// set { _RtValue = (T)Convert.ChangeType(value, typeof(T)); RaisePropertyChanged(); }
|
||||
// }
|
||||
|
||||
|
||||
// private DataType _DataTypeInfo;
|
||||
// /// <summary>
|
||||
// /// 数据类型信息
|
||||
// /// </summary>
|
||||
// public override DataType DataTypeInfo
|
||||
// {
|
||||
// get { return _DataTypeInfo; }
|
||||
// set { _DataTypeInfo = value; RaisePropertyChanged(); }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user