using Microsoft.VisualBasic; using System; using System.Collections.Generic; using System.Linq; namespace DataBlockHelper.Entity.DB2107Entity { public class WeightPraEntity { public List Silo => new WeightParaArrayManager(15, 694, 18).GetList(); public List Daybin => new WeightParaArrayManager(12, 964, 18).GetList(); public List Hoper => new WeightParaArrayManager(4, 1180, 18).GetList(); public List Water => new WeightParaArrayManager(4, 1252, 18).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; public WeightParaArrayManager(ushort length, int startSet, int sLength) { Length = length; StartSet = startSet; SLength = sLength; } public List GetList() { List ListE = new List(Length); var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); var content = getListE.Content; for (int i = 0; i < Length; i++) { var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); ListE.Add(new WeightParaE(singleBlock)); } return ListE; } } }