using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DataBlockHelper.Entity.DB2104Entity { public class DryerEntity { private int StartSet; public DryerEntity(int startSet) { this.StartSet = startSet; } public DaybinE Daybin => new DaybinE(StartSet); public List Step => new RecipeArrayManager(10, StartSet + 40, 12).GetRecipe_GmixEList(); } public class DaybinE { private int StartSet; public DaybinE(int startSet) { this.StartSet = startSet; } public List Recipe => new RecipeArrayManager(4, StartSet, 10).GetRecipe_DosEList(); } public class Recipe_DosE { public Recipe_DosE(byte[] content) { Bin = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); Set = PlcConnect.Instance.ByteTransform.TransSingle(content, 2); TolErance = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); } public short Bin { get; private set; } public float Set { get; private set; } public float TolErance { get; private set; } } public class Recipe_GmixE { public Recipe_GmixE(byte[] content) { MixCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); } public short MixCode { get; private set; } public short MixTime { get; private set; } public float MixTemp { get; private set; } public float MixSpeed { get; private set; } } public class RecipeArrayManager { private int Length; private int StartSet; private int SLength; public RecipeArrayManager(ushort length, int startSet, int sLength) { Length = length; StartSet = startSet; SLength = sLength; } public List GetRecipe_GmixEList() { List ListE = new List(Length); var getListE = PlcConnect.Instance.Read("DB2104." + 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 Recipe_GmixE(singleBlock)); } return ListE; } public List GetRecipe_DosEList() { List ListE = new List(Length); var getListE = PlcConnect.Instance.Read("DB2104." + 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 Recipe_DosE(singleBlock)); } return ListE; } } }