using Bro.Common.Helper;
|
using System;
|
using System.Collections.Generic;
|
using static Bro.Common.Helper.EnumHelper;
|
|
namespace Bro.Common.Model
|
{
|
public class PLCItem : IComplexDisplay
|
{
|
/// <summary>
|
/// 读写地址
|
/// </summary>
|
public string Address { get; set; } = "";
|
|
/// <summary>
|
/// 读写地址长度
|
/// </summary>
|
public int ItemLength { get; set; } = 1;
|
|
/// <summary>
|
/// PLC项目值
|
/// </summary>
|
public List<int> ItemValues { get; set; } = new List<int>();
|
|
/// <summary>
|
/// 是否写数据 1:读数据 2:写数据 4:监控 参见枚举PLCOpType
|
/// </summary>
|
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)}";
|
}
|
}
|
}
|
}
|