namespace WorkerSynReport.Plc; public class WeightPraEntity { byte[] bytes; public WeightPraEntity(byte[] bytes) { this.bytes = bytes; } public List Silo => new WeightParaArrayManager(15, 694, 18, bytes).GetList(); public List Daybin => new WeightParaArrayManager(12, 964, 18, bytes).GetList(); public List Hoper => new WeightParaArrayManager(4, 1180, 18, bytes).GetList(); public List Water => new WeightParaArrayManager(4, 1252, 18, bytes).GetList(); } public class WeightParaE { public WeightParaE(byte[] content) { HighSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 0); LowSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); WeightSlow = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); Precut = PlcConnect.Instance.ByteTransform.TransSingle(content, 12); JogTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 16); } public float HighSpeed { get; private set; } public float LowSpeed { get; private set; } public float WeightSlow { get; private set; } public float Precut { get; private set; } public int JogTime { get; private set; } } public class WeightParaArrayManager { private int Length; private int StartSet; private int SLength; byte[] bytes; public WeightParaArrayManager(ushort length, int startSet, int sLength, byte[] bytes) { Length = length; StartSet = startSet; SLength = sLength; this.bytes = bytes; } public List GetList() { List ListE = new List(Length); //var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); var content = bytes.Skip(StartSet).Take(Length * SLength).ToArray(); for (int i = 0; i < Length; i++) { var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); ListE.Add(new WeightParaE(singleBlock)); } return ListE; } }