using Bro.Common.Helper; using System; using System.Collections.Generic; using static Bro.Common.Helper.EnumHelper; namespace Bro.Common.Model { public class PLCItem : IComplexDisplay { /// /// 读写地址 /// public string Address { get; set; } = ""; /// /// 读写地址长度 /// public int ItemLength { get; set; } = 1; /// /// PLC项目值 /// public List ItemValues { get; set; } = new List(); /// /// 是否写数据 1:读数据 2:写数据 4:监控 参见枚举PLCOpType /// public PLCOpType PLCOpType { get; set; } = PLCOpType.Read; public DateTime OpTimeStamp { get; set; } = DateTime.Now; public string GetDisplayText() { switch (PLCOpType) { case PLCOpType.Read: return $"{PLCOpType.GetEnumDescription()}{Address},长度{ItemLength}"; case PLCOpType.Write: return $"{PLCOpType.GetEnumDescription()}{Address},数值{string.Join(" ", ItemValues)}"; default: return $"{PLCOpType.GetEnumDescription()}{Address},长度{ItemLength},数值{string.Join(" ", ItemValues)}"; } } } }