using OrpaonEMS.Core.Enums; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OrpaonEMS.App.Models { /// /// 读写信号 /// BMS的保持寄存器(功能码:读 0x03,写 0x06、0x10) /// 一些阀值的设置及参数配置 /// public class BmsRwCell : BindableBase { /// /// 实例化函数 /// public BmsRwCell(string name, int offset, double ratio, int index, int lengh, string address, bool focus, string unit, ValueRange valueRange, string WR) { this.Name = name; this.Offset = offset; this.Ratio = ratio; this.Index = index; this.Unit = unit; this.Address = address; //this.ValueRangeInfo = valueRange; this.Lengh = lengh; this.Focus = focus; ValueRangeInfo = valueRange; switch (WR) { case "读/写": IOTypeInfo = IOType.RW; break; case "读": IOTypeInfo = IOType.R; break; case "写": IOTypeInfo = IOType.W; break; default: break; } } private short _SrRtValue; /// /// 标签原始的实时值 /// public short SrRtValue { get { return _SrRtValue; } set { _SrRtValue = value; RtValue = (value * Ratio) + Offset; //LastUpdateTime = DateTime.Now; } } private double _RtValue; /// /// 标签实时值 /// 工程含义值 /// public double RtValue { get { return _RtValue; } set { _RtValue = value; RaisePropertyChanged(); } } /// /// 写入的值 /// public double WriteValue { get; set; } ///// ///// 写入设备的值 ///// //public ushort WriteDeviceValue { get; set; } /// /// 获取写入设备的值 /// /// public ushort GetWriteDeviceValue() { //RtValue = (value * Ratio) + Offset; if (Ratio != 0) { return (ushort)((RtValue - Offset) / Ratio); } //如果数据有问题的话,则返回之前的值 return (ushort)SrRtValue; } /// /// 偏移值 /// public int Offset { get; set; } /// /// 分辨率 /// public double Ratio { get; set; } /// /// Index 连续区域的位置 /// public int Index { get; set; } /// /// 值长度 /// public int Lengh { get; set; } /// /// 地址标签 /// public string Address { get; set; } /// /// 标签名称 /// public string Name { get; set; } /// /// 单位 /// public string Unit { get; set; } /// /// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示 /// public bool Focus { get; set; } /// /// 当前数据的范围 /// public ValueRange ValueRangeInfo { get; set; } /// /// 读写类型 /// public IOType IOTypeInfo { get; set; } } }