重新设计了标签变量系统
This commit is contained in:
88
CapMachine.Wpf/Models/Tag/BaseTag.cs
Normal file
88
CapMachine.Wpf/Models/Tag/BaseTag.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
using Prism.Mvvm;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
|
{
|
||||||
|
public abstract class BaseTag<T> : BindableBase, ITag
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 公共属性
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称 中文
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称 英文
|
||||||
|
/// </summary>
|
||||||
|
public string EnName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 名称 无单位中文名称
|
||||||
|
/// </summary>
|
||||||
|
public string NameNoUnit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签组
|
||||||
|
/// </summary>
|
||||||
|
public string Group { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据类型信息
|
||||||
|
/// </summary>
|
||||||
|
public TagDataType DataType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读写信息
|
||||||
|
/// </summary>
|
||||||
|
public RWInfo RWInfo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最大值
|
||||||
|
/// </summary>
|
||||||
|
public double MaxValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最小值
|
||||||
|
/// </summary>
|
||||||
|
public double MinValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 精度 到PLC的转换精度/分辨率
|
||||||
|
/// </summary>
|
||||||
|
public short Precision { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小数点 展示时用的小数点
|
||||||
|
/// </summary>
|
||||||
|
public short DecimalPoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单位
|
||||||
|
/// </summary>
|
||||||
|
public string? Unit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为仪表参数
|
||||||
|
/// </summary>
|
||||||
|
public bool IsMeter { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PV 工程值 字符串
|
||||||
|
/// </summary>
|
||||||
|
public string? PVEngValueStr { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
20
CapMachine.Wpf/Models/Tag/CalcTag.cs
Normal file
20
CapMachine.Wpf/Models/Tag/CalcTag.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using CapMachine.Wpf.Models.Tag.Cell;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 计算得到的标签
|
||||||
|
/// </summary>
|
||||||
|
public class CalcTag : BaseTag<double>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// PV Value Model
|
||||||
|
/// </summary>
|
||||||
|
public QuickAttrCell? PVModel { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
20
CapMachine.Wpf/Models/Tag/CapTag.cs
Normal file
20
CapMachine.Wpf/Models/Tag/CapTag.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using CapMachine.Wpf.Models.Tag.Cell;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 压缩机通信标签
|
||||||
|
/// </summary>
|
||||||
|
public class CapTag : BaseTag<double>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// PV Value Model
|
||||||
|
/// </summary>
|
||||||
|
public QuickAttrCell? PVModel { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
62
CapMachine.Wpf/Models/Tag/Cell/MeterExdAttrCell.cs
Normal file
62
CapMachine.Wpf/Models/Tag/Cell/MeterExdAttrCell.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
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>
|
||||||
|
/// 标签信息仪表值拓展属性单元
|
||||||
|
/// 比如 PID Limit ALARM的值信息
|
||||||
|
/// </summary>
|
||||||
|
public class MeterExdAttrCell : BindableBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 地址
|
||||||
|
/// </summary>
|
||||||
|
public string? Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用
|
||||||
|
/// </summary>
|
||||||
|
public bool? Enable { get; set; } = true;
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 读取的块信息
|
||||||
|
///// 人工确认
|
||||||
|
///// </summary>
|
||||||
|
//public string? Block { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 读取的块信息的Index
|
||||||
|
///// </summary>
|
||||||
|
//public short BlockIndex { get; set; }
|
||||||
|
|
||||||
|
private double _EngValue;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值 SV
|
||||||
|
/// </summary>
|
||||||
|
public double EngValue
|
||||||
|
{
|
||||||
|
get { return _EngValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_EngValue = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
//EngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? _EngValueStr;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值的字符串 MV
|
||||||
|
/// </summary>
|
||||||
|
public string? EngValueStr
|
||||||
|
{
|
||||||
|
get { return _EngValueStr; }
|
||||||
|
set { _EngValueStr = value; RaisePropertyChanged(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
99
CapMachine.Wpf/Models/Tag/Cell/MeterValueAttrCell.cs
Normal file
99
CapMachine.Wpf/Models/Tag/Cell/MeterValueAttrCell.cs
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
using Prism.Mvvm;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 标签信息的主要仪表值的属性单元
|
||||||
|
/// 比如SV PV MV等主要数据的属性单元
|
||||||
|
/// </summary>
|
||||||
|
public class MeterValueAttrCell : BindableBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 实例化构造函数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Precision"></param>
|
||||||
|
/// <param name="DecimalPoint"></param>
|
||||||
|
public MeterValueAttrCell()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 地址
|
||||||
|
/// </summary>
|
||||||
|
public string? Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用
|
||||||
|
/// </summary>
|
||||||
|
public bool? Enable { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取的块信息
|
||||||
|
/// 人工确认
|
||||||
|
/// </summary>
|
||||||
|
public string? Block { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取的块信息的Index
|
||||||
|
/// </summary>
|
||||||
|
public short BlockIndex { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 精度 到PLC的转换精度/分辨率
|
||||||
|
/// 引用的属性信息
|
||||||
|
/// </summary>
|
||||||
|
public short Precision { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 小数点 展示时用的小数点
|
||||||
|
/// 引用的属性信息
|
||||||
|
/// </summary>
|
||||||
|
public short DecimalPoint { get; set; }
|
||||||
|
|
||||||
|
private short _EngSrcValue = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// PLC的原始值 SV
|
||||||
|
/// </summary>
|
||||||
|
public short EngSrcValue
|
||||||
|
{
|
||||||
|
get { return _EngSrcValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
//有改动的话则更新
|
||||||
|
if (value != _EngSrcValue)
|
||||||
|
{
|
||||||
|
_EngSrcValue = value;
|
||||||
|
//原始数据转换成工程值
|
||||||
|
EngValue = _EngSrcValue * 1.0 / Precision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _EngValue;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值 SV
|
||||||
|
/// </summary>
|
||||||
|
public double EngValue
|
||||||
|
{
|
||||||
|
get { return _EngValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_EngValue = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
//工程值转换成字符串,可以灵活显示
|
||||||
|
EngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? _EngValueStr;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值的字符串 MV
|
||||||
|
/// </summary>
|
||||||
|
public string? EngValueStr
|
||||||
|
{
|
||||||
|
get { return _EngValueStr; }
|
||||||
|
set { _EngValueStr = value; RaisePropertyChanged(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
CapMachine.Wpf/Models/Tag/Cell/MvAmAttrCell.cs
Normal file
66
CapMachine.Wpf/Models/Tag/Cell/MvAmAttrCell.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using Prism.Mvvm;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag.Cell
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MV的手自动的值的属性
|
||||||
|
/// </summary>
|
||||||
|
public class MvAmAttrCell : BindableBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 地址
|
||||||
|
/// </summary>
|
||||||
|
public string? Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用
|
||||||
|
/// </summary>
|
||||||
|
public bool? Enable { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取的块信息
|
||||||
|
/// 人工确认
|
||||||
|
/// </summary>
|
||||||
|
public string? Block { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取的块信息的Index
|
||||||
|
/// </summary>
|
||||||
|
public short BlockIndex { get; set; }
|
||||||
|
|
||||||
|
private short _EngSrcValue = -1;
|
||||||
|
/// <summary>
|
||||||
|
/// PLC的原始值
|
||||||
|
/// 手自动的切换应该没有转换,直接0和1的区别,直接使用工程的原值
|
||||||
|
/// </summary>
|
||||||
|
public short EngSrcValue
|
||||||
|
{
|
||||||
|
get { return _EngSrcValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
//有改动的话则更新
|
||||||
|
if (value != _EngSrcValue)
|
||||||
|
{
|
||||||
|
_EngSrcValue = value;
|
||||||
|
//原始数据转换成工程值
|
||||||
|
EngValueStr = _EngSrcValue.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? _EngValueStr;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值的字符串 MV
|
||||||
|
/// </summary>
|
||||||
|
public string? EngValueStr
|
||||||
|
{
|
||||||
|
get { return _EngValueStr; }
|
||||||
|
set { _EngValueStr = value; RaisePropertyChanged(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
52
CapMachine.Wpf/Models/Tag/Cell/QuickAttrCell.cs
Normal file
52
CapMachine.Wpf/Models/Tag/Cell/QuickAttrCell.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using Prism.Mvvm;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag.Cell
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 快速属性标签
|
||||||
|
/// </summary>
|
||||||
|
public class QuickAttrCell : BindableBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 地址 PLC分配的地址
|
||||||
|
/// 可能分配给PLC展示用,也可能不使用
|
||||||
|
/// </summary>
|
||||||
|
public string? Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用
|
||||||
|
/// </summary>
|
||||||
|
public bool? Enable { get; set; } = true;
|
||||||
|
|
||||||
|
private double _EngValue;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值 SV
|
||||||
|
/// </summary>
|
||||||
|
public double EngValue
|
||||||
|
{
|
||||||
|
get { return _EngValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_EngValue = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
//EngValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||||
|
EngValueStr = value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? _EngValueStr;
|
||||||
|
/// <summary>
|
||||||
|
/// 工程值的字符串
|
||||||
|
/// </summary>
|
||||||
|
public string? EngValueStr
|
||||||
|
{
|
||||||
|
get { return _EngValueStr; }
|
||||||
|
set { _EngValueStr = value; RaisePropertyChanged(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,11 @@ namespace CapMachine.Wpf.Models.Tag
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITag
|
public interface ITag
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id
|
||||||
|
/// </summary>
|
||||||
|
long Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 中文名称
|
/// 中文名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -31,42 +36,6 @@ namespace CapMachine.Wpf.Models.Tag
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string? Unit { get; set; }
|
string? Unit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工程值 PV
|
|
||||||
/// </summary>
|
|
||||||
double EngPvValue { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工程值的字符串 PV
|
|
||||||
/// </summary>
|
|
||||||
string EngPvValueStr { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工程值 Sv
|
|
||||||
/// </summary>
|
|
||||||
double EngSvValue { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工程值的字符串 Sv
|
|
||||||
/// </summary>
|
|
||||||
string EngSvValueStr { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工程值 Mv
|
|
||||||
/// </summary>
|
|
||||||
double EngMvValue { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 工程值的字符串 Mv
|
|
||||||
/// </summary>
|
|
||||||
string EngMvValueStr { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// MV
|
|
||||||
/// </summary>
|
|
||||||
double MVValue { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 最大值
|
/// 最大值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -78,29 +47,14 @@ namespace CapMachine.Wpf.Models.Tag
|
|||||||
double MinValue { get; set; }
|
double MinValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 值类型
|
/// 标签值类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Type ValueType { get; set; }
|
TagDataType DataType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 地址
|
/// 标签读写信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string PVAddress { get; set; }
|
RWInfo RWInfo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 地址
|
|
||||||
/// </summary>
|
|
||||||
string SVAddress { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 地址
|
|
||||||
/// </summary>
|
|
||||||
string MVAddress { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Index
|
|
||||||
/// </summary>
|
|
||||||
string Index { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 精度
|
/// 精度
|
||||||
@@ -116,29 +70,11 @@ namespace CapMachine.Wpf.Models.Tag
|
|||||||
/// 是否为仪表参数
|
/// 是否为仪表参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsMeter { get; set; }
|
bool IsMeter { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 手自动切换地址
|
/// PV 工程值 字符串
|
||||||
|
/// UI展示用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string AutoHandSwitchAddress { get; set; }
|
string? PVEngValueStr { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// Pid-p地址
|
|
||||||
/// </summary>
|
|
||||||
string Pid_PAddress { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Pid-i地址
|
|
||||||
/// </summary>
|
|
||||||
string Pid_IAddress { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Pid-D地址
|
|
||||||
/// </summary>
|
|
||||||
string Pid_DAddress { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Limit_Up地址
|
|
||||||
/// </summary>
|
|
||||||
string Limit_UpAddress { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Limit_Down地址
|
|
||||||
/// </summary>
|
|
||||||
string Limit_DownAddress { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
CapMachine.Wpf/Models/Tag/RWInfo.cs
Normal file
35
CapMachine.Wpf/Models/Tag/RWInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 读写信息
|
||||||
|
/// </summary>
|
||||||
|
public enum RWInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 控制
|
||||||
|
/// </summary>
|
||||||
|
Control = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从PLC读取
|
||||||
|
/// </summary>
|
||||||
|
PLCRead = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从压缩机读取
|
||||||
|
/// </summary>
|
||||||
|
CapRead = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计算
|
||||||
|
/// </summary>
|
||||||
|
PCCalcu = 8,
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
112
CapMachine.Wpf/Models/Tag/ShortControlTag.cs
Normal file
112
CapMachine.Wpf/Models/Tag/ShortControlTag.cs
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
using CapMachine.Wpf.Models.Tag.Cell;
|
||||||
|
using HslCommunication;
|
||||||
|
using NPOI.SS.Formula.Functions;
|
||||||
|
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类型 步序控制 标签数据
|
||||||
|
/// 当前的数据无论是整型、浮点数等其他数据都是用Short表示,然后根据精度运算成所需数据
|
||||||
|
/// 如果后期其他项目不是这样处理,则新建其他类对应
|
||||||
|
/// </summary>
|
||||||
|
public class ShortControlTag : BaseTag<short>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
/// </summary>
|
||||||
|
public ShortControlTag()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化数据
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateInit()
|
||||||
|
{
|
||||||
|
PVModel!.DecimalPoint = this.DecimalPoint;
|
||||||
|
PVModel!.Precision = this.Precision;
|
||||||
|
|
||||||
|
SVModel!.DecimalPoint = this.DecimalPoint;
|
||||||
|
SVModel!.Precision = this.Precision;
|
||||||
|
|
||||||
|
//MV的值是固定到0-100,不需要转换
|
||||||
|
MVModel!.DecimalPoint = 0;
|
||||||
|
MVModel!.Precision = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// PV Model
|
||||||
|
/// </summary>
|
||||||
|
public MeterValueAttrCell PVModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SV Model
|
||||||
|
/// </summary>
|
||||||
|
public MeterValueAttrCell SVModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MV Model
|
||||||
|
/// </summary>
|
||||||
|
public MeterValueAttrCell MVModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AutoHand Model
|
||||||
|
/// 仪表的MV手动和自动 模型
|
||||||
|
/// </summary>
|
||||||
|
public MvAmAttrCell MVAutoHandModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pid-P
|
||||||
|
/// </summary>
|
||||||
|
public MeterExdAttrCell Pid_PModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pid-I
|
||||||
|
/// </summary>
|
||||||
|
public MeterExdAttrCell Pid_IModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pid-D
|
||||||
|
/// </summary>
|
||||||
|
public MeterExdAttrCell Pid_DModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Limit-Up
|
||||||
|
/// </summary>
|
||||||
|
public MeterExdAttrCell Limit_UpModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Limit-Down
|
||||||
|
/// </summary>
|
||||||
|
public MeterExdAttrCell Limit_DownModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Alarm
|
||||||
|
/// </summary>
|
||||||
|
public MeterExdAttrCell AlarmModel { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
private bool _AutoHandState;
|
||||||
|
/// <summary>
|
||||||
|
/// 手自动状态
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoHandState
|
||||||
|
{
|
||||||
|
get { return _AutoHandState; }
|
||||||
|
set { _AutoHandState = value; RaisePropertyChanged(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 手自动切换地址
|
||||||
|
///// </summary>
|
||||||
|
//public string AutoHandSwitchAddress { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
29
CapMachine.Wpf/Models/Tag/ShortValueTag.cs
Normal file
29
CapMachine.Wpf/Models/Tag/ShortValueTag.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
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 ShortValueTag : BaseTag<short>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// PV Model
|
||||||
|
/// </summary>
|
||||||
|
public MeterValueAttrCell PVModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化数据
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateInit()
|
||||||
|
{
|
||||||
|
PVModel!.DecimalPoint = this.DecimalPoint;
|
||||||
|
PVModel!.Precision = this.Precision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,311 +3,311 @@ using Prism.Mvvm;
|
|||||||
|
|
||||||
namespace CapMachine.Wpf.Models.Tag
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
{
|
{
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 基础模型
|
///// 基础模型
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public class Tag<T> : BindableBase, ITag
|
//public class Tag<T> : BindableBase, ITag
|
||||||
{
|
//{
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 实例化函数
|
// /// 实例化函数
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="name"></param>
|
// /// <param name="name"></param>
|
||||||
/// <param name="enName"></param>
|
// /// <param name="enName"></param>
|
||||||
/// <param name="tagType"></param>
|
// /// <param name="tagType"></param>
|
||||||
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)
|
// 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)
|
||||||
{
|
// {
|
||||||
Group = group;
|
// Group = group;
|
||||||
Name = name;
|
// Name = name;
|
||||||
Unit = unit;
|
// Unit = unit;
|
||||||
EnName = enName;
|
// EnName = enName;
|
||||||
PVAddress = PVaddress;
|
// PVAddress = PVaddress;
|
||||||
MaxValue = maxValue;
|
// MaxValue = maxValue;
|
||||||
MinValue = minValue;
|
// MinValue = minValue;
|
||||||
Precision = precision;
|
// Precision = precision;
|
||||||
|
|
||||||
IsMeter = isMeter;
|
// IsMeter = isMeter;
|
||||||
|
|
||||||
NameNoUnit = nameNoUnit;
|
// NameNoUnit = nameNoUnit;
|
||||||
|
|
||||||
//实例化
|
// //实例化
|
||||||
TagValue = tagValue;
|
// TagValue = tagValue;
|
||||||
ValueType = typeof(T);
|
// ValueType = typeof(T);
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 实例化函数
|
// /// 实例化函数
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="name"></param>
|
// /// <param name="name"></param>
|
||||||
/// <param name="enName"></param>
|
// /// <param name="enName"></param>
|
||||||
/// <param name="tagType"></param>
|
// /// <param name="tagType"></param>
|
||||||
public Tag(ITagValue<T> tagValue)
|
// public Tag(ITagValue<T> tagValue)
|
||||||
{
|
// {
|
||||||
//实例化
|
// //实例化
|
||||||
TagValue = tagValue;
|
// TagValue = tagValue;
|
||||||
ValueType = typeof(T);
|
// ValueType = typeof(T);
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 实例化函数
|
// /// 实例化函数
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="name"></param>
|
// /// <param name="name"></param>
|
||||||
/// <param name="enName"></param>
|
// /// <param name="enName"></param>
|
||||||
/// <param name="tagType"></param>
|
// /// <param name="tagType"></param>
|
||||||
public Tag()
|
// public Tag()
|
||||||
{
|
// {
|
||||||
//实例化
|
// //实例化
|
||||||
ValueType = typeof(T);
|
// ValueType = typeof(T);
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 名称 中文
|
// /// 名称 中文
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Name { get; set; }
|
// public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 名称 英文
|
// /// 名称 英文
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string EnName { get; set; }
|
// public string EnName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 名称 无单位中文名称
|
// /// 名称 无单位中文名称
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string NameNoUnit { get; set; }
|
// public string NameNoUnit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 标签组
|
// /// 标签组
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Group { get; set; }
|
// public string Group { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
// ///// <summary>
|
||||||
///// 实时值
|
// ///// 实时值
|
||||||
///// </summary>
|
// ///// </summary>
|
||||||
//public abstract IRegisterValue<short> RtValue { get; set; }
|
// //public abstract IRegisterValue<short> RtValue { get; set; }
|
||||||
|
|
||||||
private ITagValue<T> _TagValue;
|
// private ITagValue<T> _TagValue;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 实时值
|
// /// 实时值
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public ITagValue<T> TagValue
|
// public ITagValue<T> TagValue
|
||||||
{
|
// {
|
||||||
get { return _TagValue; }
|
// get { return _TagValue; }
|
||||||
set { _TagValue = value; RaisePropertyChanged(); }
|
// set { _TagValue = value; RaisePropertyChanged(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 原始值实时值
|
// /// 原始值实时值
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public OperateResult<T> OperateResultSource { get; set; } //
|
// public OperateResult<T> OperateResultSource { get; set; } //
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 数据类型信息
|
// /// 数据类型信息
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public Type ValueType { get; set; }
|
// public Type ValueType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 PV
|
// /// 地址信息 PV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string PVAddress { get; set; }
|
// public string PVAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 SV
|
// /// 地址信息 SV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string SVAddress { get; set; }
|
// public string SVAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 MV
|
// /// 地址信息 MV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string MVAddress { get; set; }
|
// public string MVAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 Pid_P
|
// /// 地址信息 Pid_P
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Pid_PAddress { get; set; }
|
// public string Pid_PAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 Pid_I
|
// /// 地址信息 Pid_I
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Pid_IAddress { get; set; }
|
// public string Pid_IAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 Pid_D
|
// /// 地址信息 Pid_D
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Pid_DAddress { get; set; }
|
// public string Pid_DAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 Limit_Up
|
// /// 地址信息 Limit_Up
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Limit_UpAddress { get; set; }
|
// public string Limit_UpAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 Limit_Down
|
// /// 地址信息 Limit_Down
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Limit_DownAddress { get; set; }
|
// public string Limit_DownAddress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 地址信息 Index
|
// /// 地址信息 Index
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string Index { get; set; }
|
// public string Index { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 最大值
|
// /// 最大值
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public double MaxValue { get; set; }
|
// public double MaxValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 最小值
|
// /// 最小值
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public double MinValue { get; set; }
|
// public double MinValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 精度 到PLC的转换精度/分辨率
|
// /// 精度 到PLC的转换精度/分辨率
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public short Precision { get; set; }
|
// public short Precision { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 小数点 展示时用的小数点
|
// /// 小数点 展示时用的小数点
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public short DecimalPoint { get; set; }
|
// public short DecimalPoint { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 单位
|
// /// 单位
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string? Unit { get; set; }
|
// public string? Unit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 采样周期
|
// /// 采样周期
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public int Samp { get; set; }
|
// public int Samp { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 是否为仪表参数
|
// /// 是否为仪表参数
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public bool IsMeter { get; set; }
|
// public bool IsMeter { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 手自动切换地址
|
// /// 手自动切换地址
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string AutoHandSwitchAddress { get; set; }
|
// public string AutoHandSwitchAddress { get; set; }
|
||||||
|
|
||||||
private bool _AutoHandState;
|
// private bool _AutoHandState;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 手自动状态
|
// /// 手自动状态
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public bool AutoHandState
|
// public bool AutoHandState
|
||||||
{
|
// {
|
||||||
get { return _AutoHandState; }
|
// get { return _AutoHandState; }
|
||||||
set { _AutoHandState = value; RaisePropertyChanged(); }
|
// set { _AutoHandState = value; RaisePropertyChanged(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private double _EngSvValue;
|
// private double _EngSvValue;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 工程值 SV
|
// /// 工程值 SV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public double EngSvValue
|
// public double EngSvValue
|
||||||
{
|
// {
|
||||||
get { return _EngSvValue; }
|
// get { return _EngSvValue; }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_EngSvValue = value;
|
// _EngSvValue = value;
|
||||||
if (TagValue.IsShow)
|
// if (TagValue.IsShow)
|
||||||
{
|
// {
|
||||||
RaisePropertyChanged();
|
// RaisePropertyChanged();
|
||||||
}
|
// }
|
||||||
EngSvValueStr = Math.Round(value, DecimalPoint).ToString();
|
// EngSvValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private string _EngSvValueStr;
|
// private string _EngSvValueStr;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 工程值的字符串 SV
|
// /// 工程值的字符串 SV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string EngSvValueStr
|
// public string EngSvValueStr
|
||||||
{
|
// {
|
||||||
get { return _EngSvValueStr; }
|
// get { return _EngSvValueStr; }
|
||||||
set { _EngSvValueStr = value; RaisePropertyChanged(); }
|
// set { _EngSvValueStr = value; RaisePropertyChanged(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
private double _EngPvValue;
|
// private double _EngPvValue;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 工程值 PV
|
// /// 工程值 PV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public double EngPvValue
|
// public double EngPvValue
|
||||||
{
|
// {
|
||||||
get { return _EngPvValue; }
|
// get { return _EngPvValue; }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_EngPvValue = value;
|
// _EngPvValue = value;
|
||||||
if (TagValue.IsShow)
|
// if (TagValue.IsShow)
|
||||||
{
|
// {
|
||||||
RaisePropertyChanged();
|
// RaisePropertyChanged();
|
||||||
}
|
// }
|
||||||
EngPvValueStr = Math.Round(value, DecimalPoint).ToString();
|
// EngPvValueStr = Math.Round(value, DecimalPoint).ToString();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private string _EngPvValueStr;
|
// private string _EngPvValueStr;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 工程值的字符串
|
// /// 工程值的字符串
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string EngPvValueStr
|
// public string EngPvValueStr
|
||||||
{
|
// {
|
||||||
get { return _EngPvValueStr; }
|
// get { return _EngPvValueStr; }
|
||||||
set { _EngPvValueStr = value; RaisePropertyChanged(); }
|
// set { _EngPvValueStr = value; RaisePropertyChanged(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
private double _EngMvValue;
|
// private double _EngMvValue;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 工程值 MV
|
// /// 工程值 MV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public double EngMvValue
|
// public double EngMvValue
|
||||||
{
|
// {
|
||||||
get { return _EngMvValue; }
|
// get { return _EngMvValue; }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_EngMvValue = value;
|
// _EngMvValue = value;
|
||||||
if (TagValue.IsShow)
|
// if (TagValue.IsShow)
|
||||||
{
|
// {
|
||||||
RaisePropertyChanged();
|
// RaisePropertyChanged();
|
||||||
}
|
// }
|
||||||
EngMvValueStr = value.ToString();
|
// EngMvValueStr = value.ToString();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private string _EngMvValueStr;
|
// private string _EngMvValueStr;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 工程值的字符串 MV
|
// /// 工程值的字符串 MV
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public string EngMvValueStr
|
// public string EngMvValueStr
|
||||||
{
|
// {
|
||||||
get { return _EngMvValueStr; }
|
// get { return _EngMvValueStr; }
|
||||||
set { _EngMvValueStr = value; RaisePropertyChanged(); }
|
// set { _EngMvValueStr = value; RaisePropertyChanged(); }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
private double _MVValue = 20;
|
// private double _MVValue = 20;
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// MV值
|
// /// MV值
|
||||||
/// 不是所有的数据都有MV值,只有仪表参数设置的有
|
// /// 不是所有的数据都有MV值,只有仪表参数设置的有
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public double MVValue
|
// public double MVValue
|
||||||
{
|
// {
|
||||||
get { return _MVValue; }
|
// get { return _MVValue; }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_MVValue = value;
|
// _MVValue = value;
|
||||||
if (TagValue.IsShow)
|
// if (TagValue.IsShow)
|
||||||
{
|
// {
|
||||||
RaisePropertyChanged();
|
// RaisePropertyChanged();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
28
CapMachine.Wpf/Models/Tag/TagDataType.cs
Normal file
28
CapMachine.Wpf/Models/Tag/TagDataType.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 标签的数据类型
|
||||||
|
/// </summary>
|
||||||
|
public enum TagDataType
|
||||||
|
{
|
||||||
|
Short,
|
||||||
|
Int,
|
||||||
|
Long,
|
||||||
|
Float,
|
||||||
|
Double,
|
||||||
|
String,
|
||||||
|
Bool,
|
||||||
|
DateTime,
|
||||||
|
Byte,
|
||||||
|
UShort,
|
||||||
|
UInt,
|
||||||
|
ULong,
|
||||||
|
UByte
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,8 @@
|
|||||||
namespace CapMachine.Wpf.Models.Tag
|
using CapMachine.Wpf.Models.Tag.Cell;
|
||||||
|
using HslCommunication.Algorithms.PID;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
|
namespace CapMachine.Wpf.Models.Tag
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标签管理中心
|
/// 标签管理中心
|
||||||
@@ -17,23 +21,614 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标签集合数据
|
/// 标签集合数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, ITag> DicTags { get; set; } = new Dictionary<string, ITag>();
|
//public Dictionary<string, ITag> DicTags { get; set; } = new Dictionary<string, ITag>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签集合数据
|
||||||
|
/// 线程安全
|
||||||
|
/// </summary>
|
||||||
|
public readonly ConcurrentDictionary<string, ITag> DicTags = new ConcurrentDictionary<string, ITag>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 增加标签
|
/// 增加标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddTag<T>(Tag<T> baseTag)
|
public void AddTag<T>(BaseTag<T> baseTag)
|
||||||
{
|
{
|
||||||
DicTags[baseTag.Name] = baseTag;
|
DicTags[baseTag.Name] = baseTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取标签信息
|
/// PV锁
|
||||||
|
/// </summary>
|
||||||
|
private static readonly object PvLock = new object();
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取标签的PVModel SVModel MVModel
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的PVModel模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="pVModel">输出的pVModel模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取PV模型</returns>
|
||||||
|
public bool TryGetPVModel(string tagName, out MeterValueAttrCell? pVModel)
|
||||||
|
{
|
||||||
|
lock (PvLock)
|
||||||
|
{
|
||||||
|
pVModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
pVModel = controlTag.PVModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (tag is ShortValueTag shortTag)
|
||||||
|
{
|
||||||
|
pVModel = shortTag.PVModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的PVModel模型
|
||||||
|
/// 给数据记录使用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="pVModel">输出的pVModel模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取PV模型</returns>
|
||||||
|
public MeterValueAttrCell TryGetRecordPVModel(string tagName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
return controlTag.PVModel;
|
||||||
|
}
|
||||||
|
else if (tag is ShortValueTag shortTag)
|
||||||
|
{
|
||||||
|
return shortTag.PVModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的PVModel模型的数据
|
||||||
|
/// 给数据记录使用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="pVModel">输出的pVModel模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取PV模型</returns>
|
||||||
|
public double TryGetRecordPVValue(string tagName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
return controlTag.PVModel.EngValue;
|
||||||
|
}
|
||||||
|
else if (tag is ShortValueTag shortTag)
|
||||||
|
{
|
||||||
|
return shortTag.PVModel.EngValue;
|
||||||
|
}
|
||||||
|
else if (tag is CalcTag calcTag)
|
||||||
|
{
|
||||||
|
return calcTag.PVModel!.EngValue;
|
||||||
|
}
|
||||||
|
else if (tag is CapTag capTag)
|
||||||
|
{
|
||||||
|
return capTag.PVModel!.EngValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的SVModel模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="SVModel">输出的sVModel模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取SV模型</returns>
|
||||||
|
public bool TryGetSVModel(string tagName, out MeterValueAttrCell? sVModel)
|
||||||
|
{
|
||||||
|
sVModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
sVModel = controlTag.SVModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的MVModel模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="mVModel">输出的MVModel模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取MV模型</returns>
|
||||||
|
public bool TryGetMVModel(string tagName, out MeterValueAttrCell? mVModel)
|
||||||
|
{
|
||||||
|
mVModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
mVModel = controlTag.MVModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的MVAm模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="MVAm">输出的MVAmModel模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取MV模型</returns>
|
||||||
|
public bool TryGetMVAmModel(string tagName, out MvAmAttrCell? mVAmModel)
|
||||||
|
{
|
||||||
|
mVAmModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
mVAmModel = controlTag.MVAutoHandModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取控制属性的PID LIMIT ALARM
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的PID_P模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="pidPModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetPidPModel(string tagName, out MeterExdAttrCell? pidPModel)
|
||||||
|
{
|
||||||
|
pidPModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
pidPModel = controlTag.Pid_PModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的PID_I模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="pidIModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetPidIModel(string tagName, out MeterExdAttrCell? pidIModel)
|
||||||
|
{
|
||||||
|
pidIModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
pidIModel = controlTag.Pid_IModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的PID_D模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <param name="pidDModel">输出的PID_D模型,如果获取失败则为null</param>
|
||||||
|
/// <returns>是否成功获取PID_D模型</returns>
|
||||||
|
public bool TryGetPidDModel(string tagName, out MeterExdAttrCell? pidDModel)
|
||||||
|
{
|
||||||
|
pidDModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
pidDModel = controlTag.Pid_DModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的limitUpModel模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="limitUpModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetLimitUpModel(string tagName, out MeterExdAttrCell? limitUpModel)
|
||||||
|
{
|
||||||
|
limitUpModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
limitUpModel = controlTag.Limit_UpModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的limitDownModel模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="limitDownModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetLimitDownModel(string tagName, out MeterExdAttrCell? limitDownModel)
|
||||||
|
{
|
||||||
|
limitDownModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
limitDownModel = controlTag.Limit_DownModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的Alarm模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="alarmModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetAlarmModel(string tagName, out MeterExdAttrCell? alarmModel)
|
||||||
|
{
|
||||||
|
alarmModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
alarmModel = controlTag.AlarmModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的MvAmAttrCelll模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="mvAmModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetMvAmModel(string tagName, out MvAmAttrCell? mvAmModel)
|
||||||
|
{
|
||||||
|
mvAmModel = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
mvAmModel = controlTag.MVAutoHandModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取标签的MvAmAttrCelll模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName"></param>
|
||||||
|
/// <param name="limitModel"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetQuickAttrModel(string tagName, out QuickAttrCell? quickAttrCell)
|
||||||
|
{
|
||||||
|
quickAttrCell = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(tagName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is CapTag capTag)
|
||||||
|
{
|
||||||
|
quickAttrCell = capTag.PVModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (tag is CalcTag calcTag)
|
||||||
|
{
|
||||||
|
quickAttrCell = calcTag.PVModel;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取标签
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取ShortControlTag变量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="shortControlTag"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetShortControlTagByName(string name, out ShortControlTag? shortControlTag)
|
||||||
|
{
|
||||||
|
shortControlTag = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(name, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortControlTag controlTag)
|
||||||
|
{
|
||||||
|
shortControlTag = controlTag;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取ShortTag变量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="shortTag"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetShortTagByName(string name, out ShortValueTag? shortTag)
|
||||||
|
{
|
||||||
|
shortTag = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(name, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is ShortValueTag getshortTag)
|
||||||
|
{
|
||||||
|
shortTag = getshortTag;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取CapTag变量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="shortTag"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetCapTagByName(string name, out CapTag? capTag)
|
||||||
|
{
|
||||||
|
capTag = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(name, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is CapTag getshortTag)
|
||||||
|
{
|
||||||
|
capTag = getshortTag;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尝试获取CalcTag变量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="shortTag"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TryGetCalcTagByName(string name, out CalcTag? calcTag)
|
||||||
|
{
|
||||||
|
calcTag = null;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(name, out var tag))
|
||||||
|
{
|
||||||
|
// 尝试将标签转换为ShortControlTag
|
||||||
|
if (tag is CalcTag getshortTag)
|
||||||
|
{
|
||||||
|
calcTag = getshortTag;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查标签是否为ShortControlTag标签类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <returns>如果是ShortControlTag类型返回true,否则返回false</returns>
|
||||||
|
public bool IsShortControlTag(string tagName)
|
||||||
|
{
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
return tag is ShortControlTag;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查标签是否为ShortTag标签类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <returns>如果是ShortValueTag类型返回true,否则返回false</returns>
|
||||||
|
public bool IsShortTag(string tagName)
|
||||||
|
{
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
return tag is ShortValueTag;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查标签是否为CapTag标签类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <returns>如果是CapTag类型返回true,否则返回false</returns>
|
||||||
|
public bool IsCapTag(string tagName)
|
||||||
|
{
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
return tag is CapTag;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查标签是否为CalcTag标签类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagName">标签名称</param>
|
||||||
|
/// <returns>如果是CalcTag类型返回true,否则返回false</returns>
|
||||||
|
public bool IsCalcTag(string tagName)
|
||||||
|
{
|
||||||
|
if (DicTags.TryGetValue(tagName, out var tag))
|
||||||
|
{
|
||||||
|
return tag is CalcTag;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取原始标签信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Tag<T>? GetTagByName<T>(string name)
|
public BaseTag<T>? GetBaseTagByName<T>(string name)
|
||||||
{
|
{
|
||||||
//return ListTag.OfType<BaseTag<T>>()
|
//return ListTag.OfType<BaseTag<T>>()
|
||||||
// .FirstOrDefault(t => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
// .FirstOrDefault(t => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||||
@@ -41,47 +636,47 @@
|
|||||||
// 尝试从字典中获取标签,并使用 as 关键字避免类型转换失败抛出异常
|
// 尝试从字典中获取标签,并使用 as 关键字避免类型转换失败抛出异常
|
||||||
if (DicTags.TryGetValue(name, out var FindTag))
|
if (DicTags.TryGetValue(name, out var FindTag))
|
||||||
{
|
{
|
||||||
return FindTag as Tag<T>;// 成功转换返回具体类型的标签,失败返回 null
|
return FindTag as BaseTag<T>;// 成功转换返回具体类型的标签,失败返回 null
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过标签名称获取 ShortControlTag 信息 无返回是否为空
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name">标签名称</param>
|
||||||
|
/// <returns>找到则返回ShortControlTag,否则返回null</returns>
|
||||||
|
public ShortControlTag? GetShortControlTagByName(string Name)
|
||||||
|
{
|
||||||
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(Name, out var findTag))
|
||||||
|
{
|
||||||
|
// 尝试转换为 ShortControlTag
|
||||||
|
return findTag as ShortControlTag;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取标签的值
|
/// 通过标签名称获取 ShortTag 信息 无返回是否为空
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T? GetTagValueByName<T>(string name)
|
public ShortValueTag GetShortTagByName(string name)
|
||||||
{
|
{
|
||||||
var FindTag = GetTagByName<T>(name);
|
// 尝试从字典中获取标签
|
||||||
|
if (DicTags.TryGetValue(name, out var findTag))
|
||||||
// 如果找到标签,则返回其值,否则返回默认值
|
|
||||||
if (FindTag != null)
|
|
||||||
{
|
{
|
||||||
return FindTag!.TagValue.Value;
|
// 尝试转换为 ShortControlTag
|
||||||
|
return findTag as ShortValueTag;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
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);
|
|
||||||
|
|
||||||
// 如果找到标签,则返回其值,否则返回默认值
|
#endregion
|
||||||
if (FindTag != null)
|
|
||||||
{
|
|
||||||
return FindTag!.TagValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
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 ByteTagValue : BindableBase, ITagValue<byte>
|
|
||||||
{
|
|
||||||
private byte _Value;
|
|
||||||
/// <summary>
|
|
||||||
/// 值
|
|
||||||
/// </summary>
|
|
||||||
public byte Value
|
|
||||||
{
|
|
||||||
get { return _Value; }
|
|
||||||
set { _Value = value; RaisePropertyChanged(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 寄存器原始数据
|
|
||||||
/// </summary>
|
|
||||||
public OperateResult<byte>? OperateResultSource { get; set; }
|
|
||||||
public bool IsShow { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -417,10 +417,6 @@ namespace CapMachine.Wpf.Services
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Random Random = new Random();
|
private Random Random = new Random();
|
||||||
private int Add = 1;
|
private int Add = 1;
|
||||||
Stopwatch stopwatch = new Stopwatch();
|
Stopwatch stopwatch = new Stopwatch();
|
||||||
@@ -439,7 +435,7 @@ namespace CapMachine.Wpf.Services
|
|||||||
//CycleTimer.Stop(); //先关闭定时器
|
//CycleTimer.Stop(); //先关闭定时器
|
||||||
|
|
||||||
var DataInfo = MachineRtDataService.TagManger.DicTags
|
var DataInfo = MachineRtDataService.TagManger.DicTags
|
||||||
.ToDictionary(kvp => kvp.Key, kvp => (object)kvp.Value.EngPvValue);
|
.ToDictionary(kvp => kvp.Key, kvp => (object)MachineRtDataService.TagManger.TryGetRecordPVValue(kvp.Value.Name));
|
||||||
DataInfo.Add("创建时间", DateTime.Now);
|
DataInfo.Add("创建时间", DateTime.Now);
|
||||||
|
|
||||||
var RecordData = new RecordChannelData()
|
var RecordData = new RecordChannelData()
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -56,20 +56,47 @@ namespace CapMachine.Wpf.Services
|
|||||||
//SpeedTag = TagManager.DicTags.GetValueOrDefault("转速[rpm]");
|
//SpeedTag = TagManager.DicTags.GetValueOrDefault("转速[rpm]");
|
||||||
//ExPressTag = TagManager.DicTags.GetValueOrDefault("排气压力[BarA]");
|
//ExPressTag = TagManager.DicTags.GetValueOrDefault("排气压力[BarA]");
|
||||||
//ExTempTag = TagManager.DicTags.GetValueOrDefault("排气温度[℃]");
|
//ExTempTag = TagManager.DicTags.GetValueOrDefault("排气温度[℃]");
|
||||||
InhPressTag = TagManager.DicTags.GetValueOrDefault("吸气压力[BarA]")!;
|
if (TagManager.TryGetShortControlTagByName("吸气压力[BarA]",out ShortControlTag? InhPressShortControlTag))
|
||||||
InhTempTag = TagManager.DicTags.GetValueOrDefault("吸气温度[℃]")!;
|
{
|
||||||
|
InhPressTag = InhPressShortControlTag!;
|
||||||
|
}
|
||||||
|
if (TagManager.TryGetShortControlTagByName("吸气温度[℃]", out ShortControlTag? InhTempShortControlTag))
|
||||||
|
{
|
||||||
|
InhTempTag = InhTempShortControlTag!;
|
||||||
|
}
|
||||||
|
|
||||||
|
//InhTempTag = TagManager.DicTags.GetValueOrDefault("吸气温度[℃]")!;
|
||||||
//ComCapBusVolTag = TagManager.DicTags.GetValueOrDefault("通讯母线电压[V]");
|
//ComCapBusVolTag = TagManager.DicTags.GetValueOrDefault("通讯母线电压[V]");
|
||||||
//ComCapBusCurTag = TagManager.DicTags.GetValueOrDefault("通讯母线电流[A]");
|
//ComCapBusCurTag = TagManager.DicTags.GetValueOrDefault("通讯母线电流[A]");
|
||||||
//ComCapPwTag = TagManager.DicTags.GetValueOrDefault("通讯功率[W]");
|
//ComCapPwTag = TagManager.DicTags.GetValueOrDefault("通讯功率[W]");
|
||||||
//OS2TempTag = TagManager.DicTags.GetValueOrDefault("吸气混合器温度[℃]");
|
//OS2TempTag = TagManager.DicTags.GetValueOrDefault("吸气混合器温度[℃]");
|
||||||
TxvFrTempTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前温度[℃]")!;
|
|
||||||
TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[BarA]")!;
|
//TxvFrTempTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前温度[℃]")!;
|
||||||
|
//TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[BarA]")!;
|
||||||
|
|
||||||
|
if (TagManager.TryGetShortTagByName("膨胀阀前温度[℃]", out ShortValueTag? TxvFrTempShortTag))
|
||||||
|
{
|
||||||
|
TxvFrTempTag = TxvFrTempShortTag!;
|
||||||
|
}
|
||||||
|
if (TagManager.TryGetShortTagByName("膨胀阀前压力[BarA]", out ShortValueTag? TxvFrPressShortTag))
|
||||||
|
{
|
||||||
|
TxvFrPressTag = TxvFrPressShortTag!;
|
||||||
|
}
|
||||||
|
|
||||||
//Cond1TempTag = TagManager.DicTags.GetValueOrDefault("冷凝器出口水温[℃]");
|
//Cond1TempTag = TagManager.DicTags.GetValueOrDefault("冷凝器出口水温[℃]");
|
||||||
//CondInTempTag = TagManager.DicTags.GetValueOrDefault("冷凝器进口温度[℃]");
|
//CondInTempTag = TagManager.DicTags.GetValueOrDefault("冷凝器进口温度[℃]");
|
||||||
|
|
||||||
Superheat = TagManager.DicTags.GetValueOrDefault("过热度[K]");
|
//Superheat = TagManager.DicTags.GetValueOrDefault("过热度[K]");
|
||||||
Subcool = TagManager.DicTags.GetValueOrDefault("过冷度[K]");
|
//Subcool = TagManager.DicTags.GetValueOrDefault("过冷度[K]");
|
||||||
|
|
||||||
|
if (TagManager.TryGetShortTagByName("过热度[K]", out ShortValueTag? SuperheatShortTag))
|
||||||
|
{
|
||||||
|
Superheat = SuperheatShortTag!;
|
||||||
|
}
|
||||||
|
if (TagManager.TryGetShortTagByName("过冷度[K]", out ShortValueTag? SubcoolShortTag))
|
||||||
|
{
|
||||||
|
Subcool = SubcoolShortTag!;
|
||||||
|
}
|
||||||
|
|
||||||
SuperHeatCoolConfig.FluidsPath = ConfigHelper.GetValue("FluidsPath");
|
SuperHeatCoolConfig.FluidsPath = ConfigHelper.GetValue("FluidsPath");
|
||||||
SuperHeatCoolConfig.Cryogen = ConfigHelper.GetValue("Cryogen");
|
SuperHeatCoolConfig.Cryogen = ConfigHelper.GetValue("Cryogen");
|
||||||
@@ -95,32 +122,32 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 吸气压力
|
/// 吸气压力
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ITag InhPressTag { get; set; }
|
public ShortControlTag InhPressTag { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 吸气温度
|
/// 吸气温度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ITag InhTempTag { get; set; }
|
public ShortControlTag InhTempTag { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 膨胀阀前温度
|
/// 膨胀阀前温度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ITag TxvFrTempTag { get; set; }
|
public ShortValueTag TxvFrTempTag { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 膨胀阀前压力
|
/// 膨胀阀前压力
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ITag TxvFrPressTag { get; set; }
|
public ShortValueTag TxvFrPressTag { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 过热度
|
/// 过热度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ITag Superheat { get; set; }
|
public ShortValueTag Superheat { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 过冷度
|
/// 过冷度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ITag Subcool { get; set; }
|
public ShortValueTag Subcool { get; set; }
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
@@ -229,25 +256,25 @@ namespace CapMachine.Wpf.Services
|
|||||||
IRefProp64.WMOLdll(x, ref wm);
|
IRefProp64.WMOLdll(x, ref wm);
|
||||||
|
|
||||||
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||||
p = (InhPressTag.EngPvValue) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
p = (InhPressTag.PVModel.EngValue) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||||
kph = 1;
|
kph = 1;
|
||||||
|
|
||||||
p1 = (TxvFrPressTag.EngPvValue) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
p1 = (TxvFrPressTag.PVModel.EngValue) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||||
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||||
IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||||
|
|
||||||
if (iErr == 0)
|
if (iErr == 0)
|
||||||
Superheat.EngPvValue = InhTempTag.EngPvValue - (te - 273.15);
|
Superheat.PVModel.EngValue = InhTempTag.PVModel.EngValue - (te - 273.15);
|
||||||
//textBox5.Text = String.Format("{0:n4}", Convert.ToDouble(textBox1.Text) - (te - 273.15));//textBox1 Comp.吸气温度(℃)
|
//textBox5.Text = String.Format("{0:n4}", Convert.ToDouble(textBox1.Text) - (te - 273.15));//textBox1 Comp.吸气温度(℃)
|
||||||
else
|
else
|
||||||
Superheat.EngPvValue = 0;
|
Superheat.PVModel.EngValue = 0;
|
||||||
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||||
if (iErr == 0)
|
if (iErr == 0)
|
||||||
Subcool.EngPvValue = TxvFrTempTag.EngPvValue - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
Subcool.PVModel.EngValue = TxvFrTempTag.PVModel.EngValue - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
||||||
//GuoLengDu = (te1 - 273.15) - ListKRLogCellValue.Find(a => a.Name == "膨胀阀前温度").Value;//textBox4 Evap.膨胀阀前温度(℃)
|
//GuoLengDu = (te1 - 273.15) - ListKRLogCellValue.Find(a => a.Name == "膨胀阀前温度").Value;//textBox4 Evap.膨胀阀前温度(℃)
|
||||||
//textBox6.Text = String.Format("{0:n4}", Convert.ToDouble(textBox4.Text) - (te1 - 273.15));//textBox4 Evap.膨胀阀前温度(℃)
|
//textBox6.Text = String.Format("{0:n4}", Convert.ToDouble(textBox4.Text) - (te1 - 273.15));//textBox4 Evap.膨胀阀前温度(℃)
|
||||||
else
|
else
|
||||||
Subcool.EngPvValue = 0;
|
Subcool.PVModel.EngValue = 0;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -328,11 +355,11 @@ namespace CapMachine.Wpf.Services
|
|||||||
|
|
||||||
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||||
//p = (ListRtKPMeter.Find(a => a.MeterName == "吸入压力").RtPV) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
//p = (ListRtKPMeter.Find(a => a.MeterName == "吸入压力").RtPV) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||||
p = (InhPressTag.EngPvValue) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
p = (InhPressTag.PVModel.EngValue) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||||
kph = 1;
|
kph = 1;
|
||||||
|
|
||||||
//p1 = (ListKRLogCellValue.Find(a => a.Name == "膨胀阀前压力").Value) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
//p1 = (ListKRLogCellValue.Find(a => a.Name == "膨胀阀前压力").Value) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||||
p1 = (TxvFrPressTag.EngPvValue) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
p1 = (TxvFrPressTag.PVModel.EngValue) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||||
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||||
|
|
||||||
|
|
||||||
@@ -341,20 +368,20 @@ namespace CapMachine.Wpf.Services
|
|||||||
if (iErr == 0)
|
if (iErr == 0)
|
||||||
|
|
||||||
//GuoReDu = ListRtKPMeter.Find(a => a.MeterName == "吸入温度").RtPV - (te - 273.15);
|
//GuoReDu = ListRtKPMeter.Find(a => a.MeterName == "吸入温度").RtPV - (te - 273.15);
|
||||||
Superheat.EngPvValue = InhTempTag.EngPvValue - (te - 273.15);
|
Superheat.PVModel.EngValue = InhTempTag.PVModel.EngValue - (te - 273.15);
|
||||||
//textBox5.Text = String.Format("{0:n4}", Convert.ToDouble(textBox1.Text) - (te - 273.15));//textBox1 Comp.吸气温度(℃)
|
//textBox5.Text = String.Format("{0:n4}", Convert.ToDouble(textBox1.Text) - (te - 273.15));//textBox1 Comp.吸气温度(℃)
|
||||||
else
|
else
|
||||||
Superheat.EngPvValue = 0;
|
Superheat.PVModel.EngValue = 0;
|
||||||
|
|
||||||
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||||
if (iErr == 0)
|
if (iErr == 0)
|
||||||
//GuoLengDu = ListKRLogCellValue.Find(a => a.Name == "膨胀阀前温度").Value - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
//GuoLengDu = ListKRLogCellValue.Find(a => a.Name == "膨胀阀前温度").Value - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
||||||
Subcool.EngPvValue = TxvFrTempTag.EngPvValue - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
Subcool.PVModel.EngValue = TxvFrTempTag.PVModel.EngValue - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
||||||
|
|
||||||
//textBox6.Text = String.Format("{0:n4}", Convert.ToDouble(textBox4.Text) - (te1 - 273.15));//textBox4 Evap.膨胀阀前温度(℃)
|
//textBox6.Text = String.Format("{0:n4}", Convert.ToDouble(textBox4.Text) - (te1 - 273.15));//textBox4 Evap.膨胀阀前温度(℃)
|
||||||
|
|
||||||
else
|
else
|
||||||
Subcool.EngPvValue = 0;
|
Subcool.PVModel.EngValue = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ namespace CapMachine.Wpf.Services
|
|||||||
ListPlcLoadConfigCell.Add(new PlcLoadConfigCell()
|
ListPlcLoadConfigCell.Add(new PlcLoadConfigCell()
|
||||||
{
|
{
|
||||||
Name = itemKeyValue.Key,
|
Name = itemKeyValue.Key,
|
||||||
SvAddress = itemKeyValue.Value.SVAddress,
|
SvAddress = MachineRtDataService.TagManger.TryGetSVModel(itemKeyValue.Value.Name,out MeterValueAttrCell? controlAttrCell)==true? controlAttrCell!.Address:"",
|
||||||
Limit_UpAddress = itemKeyValue.Value.Limit_UpAddress,
|
Limit_UpAddress = MachineRtDataService.TagManger.TryGetLimitUpModel(itemKeyValue.Value.Name, out MeterExdAttrCell? controlAttrCell2) == true ? controlAttrCell2!.Address : "",
|
||||||
Limit_DownAddress = itemKeyValue.Value.Limit_DownAddress,
|
Limit_DownAddress = MachineRtDataService.TagManger.TryGetLimitDownModel(itemKeyValue.Value.Name, out MeterExdAttrCell? controlAttrCell3) == true ? controlAttrCell3!.Address : "",
|
||||||
Pid_PAddress = itemKeyValue.Value.Pid_PAddress,
|
Pid_PAddress = MachineRtDataService.TagManger.TryGetPidPModel(itemKeyValue.Value.Name, out MeterExdAttrCell? controlAttrCell4) == true ? controlAttrCell4!.Address : "",
|
||||||
Pid_IAddress = itemKeyValue.Value.Pid_IAddress,
|
Pid_IAddress = MachineRtDataService.TagManger.TryGetPidIModel(itemKeyValue.Value.Name, out MeterExdAttrCell? controlAttrCell5) == true ? controlAttrCell5!.Address : "",
|
||||||
Pid_DAddress = itemKeyValue.Value.Pid_DAddress,
|
Pid_DAddress = MachineRtDataService.TagManger.TryGetPidDModel(itemKeyValue.Value.Name, out MeterExdAttrCell? controlAttrCell6) == true ? controlAttrCell6!.Address : "",
|
||||||
Precision = itemKeyValue.Value.Precision,
|
Precision = itemKeyValue.Value.Precision,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -50,14 +50,18 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
//赋值实例化
|
//赋值实例化
|
||||||
ListHandSwitchData = MachineRtDataService.ListHandSwitchData;
|
ListHandSwitchData = MachineRtDataService.ListHandSwitchData;
|
||||||
|
|
||||||
ListTag = new ObservableCollection<ITag>(TagManager.DicTags.Values.ToList());
|
|
||||||
ListMeterTag = TagManager.DicTags.Values.Where(a => a.IsMeter == true).ToList();
|
//ListTag = new ObservableCollection<ITag>(TagManager.DicTags.Values.ToList());
|
||||||
|
RefreshListTag();
|
||||||
|
|
||||||
|
ListMeterTag = TagManager.DicTags.Values.Where(a => a.Group == "程序").OrderBy(a=>a.Id).Take(11).ToList();
|
||||||
|
|
||||||
SpeedTag = TagManager.DicTags.GetValueOrDefault("转速[rpm]");
|
SpeedTag = TagManager.DicTags.GetValueOrDefault("转速[rpm]");
|
||||||
ExPressTag = TagManager.DicTags.GetValueOrDefault("排气压力[BarA]");
|
ExPressTag = TagManager.DicTags.GetValueOrDefault("排气压力[BarA]");
|
||||||
ExTempTag = TagManager.DicTags.GetValueOrDefault("排气温度[℃]");
|
ExTempTag = TagManager.DicTags.GetValueOrDefault("排气温度[℃]");
|
||||||
InhPressTag = TagManager.DicTags.GetValueOrDefault("吸气压力[BarA]");
|
InhPressTag = TagManager.DicTags.GetValueOrDefault("吸气压力[BarA]");
|
||||||
InhTempTag = TagManager.DicTags.GetValueOrDefault("吸气温度[℃]");
|
InhTempTag = TagManager.DicTags.GetValueOrDefault("吸气温度[℃]");
|
||||||
|
|
||||||
ComCapBusVolTag = TagManager.DicTags.GetValueOrDefault("通讯母线电压[V]");
|
ComCapBusVolTag = TagManager.DicTags.GetValueOrDefault("通讯母线电压[V]");
|
||||||
ComCapBusCurTag = TagManager.DicTags.GetValueOrDefault("通讯母线电流[A]");
|
ComCapBusCurTag = TagManager.DicTags.GetValueOrDefault("通讯母线电流[A]");
|
||||||
ComCapPwTag = TagManager.DicTags.GetValueOrDefault("通讯功率[W]");
|
ComCapPwTag = TagManager.DicTags.GetValueOrDefault("通讯功率[W]");
|
||||||
@@ -89,6 +93,34 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
new ChartRtValue(){ Name="湿度",Value=12.3,Unit="%"},
|
new ChartRtValue(){ Name="湿度",Value=12.3,Unit="%"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private List<string> _FilterGroups = new List<string> { "程序", "采集", "压缩机" };
|
||||||
|
/// <summary>
|
||||||
|
/// 动态过滤(支持运行时更改过滤条件)
|
||||||
|
/// </summary>
|
||||||
|
public List<string> FilterGroups
|
||||||
|
{
|
||||||
|
get => _FilterGroups;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_FilterGroups = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
RefreshListTag(); // 更新ListTag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 动态过滤ListTag(支持运行时更改过滤条件)
|
||||||
|
/// </summary>
|
||||||
|
private void RefreshListTag()
|
||||||
|
{
|
||||||
|
ListTag = new ObservableCollection<ITag>(
|
||||||
|
TagManager.DicTags.Values.Where(tag =>
|
||||||
|
FilterGroups.Contains(tag.Group) || FilterGroups.Count == 0
|
||||||
|
).OrderBy(a => a.Id).ToList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private ObservableCollection<ITag> _ListTag;
|
private ObservableCollection<ITag> _ListTag;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标签集合信息
|
/// 标签集合信息
|
||||||
@@ -389,6 +421,7 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
return _AutoHandCmd;
|
return _AutoHandCmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 操作指令执行方法
|
/// 操作指令执行方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -404,11 +437,15 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
//
|
//
|
||||||
foreach (var item in TagManager.DicTags)
|
foreach (var item in TagManager.DicTags)
|
||||||
{
|
{
|
||||||
|
//用无单位的比较
|
||||||
if (item.Value.NameNoUnit == MeterControl.MeterName)
|
if (item.Value.NameNoUnit == MeterControl.MeterName)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(item.Value.AutoHandSwitchAddress))
|
if (TagManager.TryGetShortControlTagByName(item.Value.Name, out ShortControlTag? shortControlTag))
|
||||||
{
|
{
|
||||||
var Result = MachineRtDataService.SiemensDrive.Write(item.Value.AutoHandSwitchAddress, MeterControl.AutoHandState == true ? (short)1 : (short)0);
|
if (!string.IsNullOrEmpty(shortControlTag!.MVAutoHandModel.Address))
|
||||||
|
{
|
||||||
|
var Result = MachineRtDataService.SiemensDrive.Write(shortControlTag!.MVAutoHandModel.Address, MeterControl.AutoHandState == true ? (short)1 : (short)0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -450,22 +487,29 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
//
|
//
|
||||||
foreach (var item in TagManager.DicTags)
|
foreach (var item in TagManager.DicTags)
|
||||||
{
|
{
|
||||||
|
//用无单位的比较
|
||||||
if (item.Value.NameNoUnit == ChannelValue.Name)
|
if (item.Value.NameNoUnit == ChannelValue.Name)
|
||||||
{
|
{
|
||||||
switch (ChannelValue.Type)
|
switch (ChannelValue.Type)
|
||||||
{
|
{
|
||||||
case "MV"://10的倍率
|
case "MV"://10的倍率
|
||||||
if (!string.IsNullOrEmpty(item.Value.MVAddress))
|
if (TagManager.TryGetMVModel(item.Value.Name, out MeterValueAttrCell? MvcontrolAttrCell))
|
||||||
{
|
{
|
||||||
var Result = MachineRtDataService.SiemensDrive.Write(item.Value.MVAddress, (short)((double)ChannelValue.Value * 10));
|
if (!string.IsNullOrEmpty(MvcontrolAttrCell!.Address))
|
||||||
break;
|
{
|
||||||
|
var Result = MachineRtDataService.SiemensDrive.Write(MvcontrolAttrCell!.Address, (short)((double)ChannelValue.Value * 10));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "SV":
|
case "SV":
|
||||||
if (!string.IsNullOrEmpty(item.Value.SVAddress))
|
if (TagManager.TryGetSVModel(item.Value.Name, out MeterValueAttrCell? sVcontrolAttrCell))
|
||||||
{
|
{
|
||||||
var Result = MachineRtDataService.SiemensDrive.Write(item.Value.SVAddress, (short)((double)ChannelValue.Value * item.Value.Precision));
|
if (!string.IsNullOrEmpty(sVcontrolAttrCell!.Address))
|
||||||
break;
|
{
|
||||||
|
var Result = MachineRtDataService.SiemensDrive.Write(sVcontrolAttrCell!.Address, (short)((double)ChannelValue.Value * item.Value.Precision));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -168,12 +168,12 @@
|
|||||||
AutoHandCommand="{Binding Source={StaticResource Proxy}, Path=Data.AutoHandCmd}"
|
AutoHandCommand="{Binding Source={StaticResource Proxy}, Path=Data.AutoHandCmd}"
|
||||||
AutoHandState="False"
|
AutoHandState="False"
|
||||||
HandValueCommand="{Binding Source={StaticResource Proxy}, Path=Data.HandValueCmd}"
|
HandValueCommand="{Binding Source={StaticResource Proxy}, Path=Data.HandValueCmd}"
|
||||||
HandValueMVParameter="{Binding EngMvValue}"
|
HandValueMVParameter="{Binding PVModel.EngValue}"
|
||||||
HandValueSVParameter="{Binding EngSvValue}"
|
HandValueSVParameter="{Binding SVModel.EngValue}"
|
||||||
IsEnabled="False"
|
IsEnabled="True"
|
||||||
MeterName="{Binding NameNoUnit}"
|
MeterName="{Binding NameNoUnit}"
|
||||||
PVValue="{Binding EngPvValue}"
|
PVValue="{Binding PVModel.EngValueStr}"
|
||||||
SVValue="{Binding EngSvValue}"
|
SVValue="{Binding SVModel.EngValueStr}"
|
||||||
Unit="{Binding Unit}" />
|
Unit="{Binding Unit}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
@@ -1146,7 +1146,7 @@
|
|||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
<GridView ColumnHeaderContainerStyle="{StaticResource myHeaderStyle1}">
|
||||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="名称" />
|
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="名称" />
|
||||||
<GridViewColumn DisplayMemberBinding="{Binding EngPvValueStr}" Header="实时值" />
|
<GridViewColumn DisplayMemberBinding="{Binding PVModel.EngValueStr}" Header="实时值" />
|
||||||
<!-- DisplayMemberBinding="{Binding EngPvValue, Converter={StaticResource ValuePrecisionConverter}, ConverterParameter={Binding Path=DecimalPoint}}" -->
|
<!-- DisplayMemberBinding="{Binding EngPvValue, Converter={StaticResource ValuePrecisionConverter}, ConverterParameter={Binding Path=DecimalPoint}}" -->
|
||||||
<!--<GridViewColumn Header="实时值">
|
<!--<GridViewColumn Header="实时值">
|
||||||
<GridViewColumn.DisplayMemberBinding>
|
<GridViewColumn.DisplayMemberBinding>
|
||||||
|
|||||||
Reference in New Issue
Block a user