using DataBlockHelper.Entity.DB2107Entity; using DataBlockHelper.Entity.DB2105Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DataBlockHelper.DBHelpers { public class DB2105Helper : DBHelper { public DB2105Helper() { this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 126).Content; } public List Plan => new PlanArrayManager(4, 0, 12, bytes).GetList(); public bool[] Status => new FourBoolArrayManager(48, bytes).GetList(); public bool[] End => new FourBoolArrayManager(50, bytes).GetList(); /// /// 设置启动运行 /// public List GetStartJob { get { List ls = new List(); var b = bytes.Skip(52).Take(1).First(); for (int i = 0; i < 8; i++) { int no = i + 1; ls.Add(new NoVal() { No = no, Val = b.GetBit(i) }); } return ls; } } /// /// 获取手动加粉料数据 /// public List GetManScrew { get { List ls = new List(); var b = bytes.Skip(53).Take(1).First(); for (int i = 0; i < 8; i++) { int no = i + 1; ls.Add(new NoVal() { No = no, Val = b.GetBit(i) }); } return ls; } } /// /// 获取设定值 /// public List GetSetValue { get { // 54 58 // 62 66 // 70 74 // 78 82 // 86 90 // 94 98 // 102 106 // 110 114 int start = 54; List ls = new List(); for (int i = 0; i < 4; i++) { int no = i + 1; var b = bytes.Skip(start).Take(8).ToArray(); ls.Add(new SetValue() { No = no, Value = PlcConnect.Instance.ByteTransform.TransSingle(b, 0), Toterance = PlcConnect.Instance.ByteTransform.TransSingle(b, 4), }); start += 8; } return ls; } } public List ReadReadyG1 => ReadReady(94); public List ReadReadyG2 => ReadReady(96); public List ReadReadyG3 => ReadReady(98); public List ReadReadyG4 => ReadReady(100); public List ReadReadyG5 => ReadReady(102); public List ReadReadyG6 => ReadReady(104); public List ReadReadyG7 => ReadReady(106); public List ReadReadyG8 => ReadReady(108); public bool ReadReadyM1 => ReadReadyM(110); public bool ReadReadyM2 => ReadReadyM(112); public bool ReadReadyM3 => ReadReadyM(114); public bool ReadReadyM4 => ReadReadyM(116); public bool ReadReadyM5 => ReadReadyM(118); public bool ReadReadyM6 => ReadReadyM(120); public bool ReadReadyM7 => ReadReadyM(122); public bool ReadReadyM8 => ReadReadyM(124); //94 public List ReadReady(int start) { var first = bytes.Skip(start).Take(1).First(); List ls = new List(3); var pd = first.GetBit(3); var cw = first.GetBit(4); var hw = first.GetBit(5); ls.Add(pd); ls.Add(cw); ls.Add(hw); return ls; } public bool ReadReadyM(int start) { var first = bytes.Skip(start).Take(1).First(); return first.GetBit(1); } } public class NoVal { public int No { get; set; } public bool Val { get; set; } } public class SetValue { public int No { get; set; } public float Value { get; set; } public float Toterance { get; set; } } }