using DataBlockHelper; using DataBlockHelper.DBHelpers; using DataBlockHelper.Entity.DB2107Entity; using Mesnac.Action.ChemicalWeighing.LjWeight; using System; using System.Collections.Generic; namespace Mesnac.Action.ChemicalWeighing.LjProportional { public class ProportionalPlc { private static DB2107Helper _db2107Helper = new DB2107Helper(); private static void DownProportionalSettingView(int start, ProportionalSettingView view) { int sv = start + 4; PlcConnect.Instance.Write($"DB2107.{sv}.0", Convert.ToSingle(view.SV)); } private static void Down614(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(614,view); //var basePlcHelper = GetPlcHelper; //basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.conveyV1_SV, view.SV); } } private static ProportionalSettingView GetProportionalSettingView(int id, PID_HMI pID) { ProportionalSettingView vi = new ProportionalSettingView() { Id = id, PV = pID.PV, SV =pID.SV }; return vi; } private static ProportionalSettingView Up614() { // ProportionalSettingView vi = GetProportionalSettingView(1, _db2107Helper.PID.Convey_V1); //{ // Id = 1, // PV = basePlcHelper.conveyV1_PV.NowValue.ToFloat(), // SV = basePlcHelper.conveyV1_SV.NowValue.ToFloat() //}; return vi; } private static void Down622(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(622, view); } } private static ProportionalSettingView Up622() { ProportionalSettingView vi = GetProportionalSettingView(2, _db2107Helper.PID.Purge_V1); //{ // Id = 2, // PV = basePlcHelper.purgeV1_PV.NowValue.ToFloat(), // SV = basePlcHelper.purgeV1_SV.NowValue.ToFloat() //}; return vi; } private static void Down630(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(630, view); } } private static ProportionalSettingView Up630() { ProportionalSettingView vi = GetProportionalSettingView(3, _db2107Helper.PID.Convey_V2); //{ // Id = 3, // PV = basePlcHelper.conveyV2_PV.NowValue.ToFloat(), // SV = basePlcHelper.conveyV2_SV.NowValue.ToFloat() //}; return vi; } private static void Down638(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(638, view); } } private static ProportionalSettingView Up638() { ProportionalSettingView vi = GetProportionalSettingView(4, _db2107Helper.PID.Purge_V2); //{ // Id = 4, // PV = basePlcHelper.purgeV2_PV.NowValue.ToFloat(), // SV = basePlcHelper.purgeV2_SV.NowValue.ToFloat() //}; return vi; } private static void Down646(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(646, view); } } private static ProportionalSettingView Up646() { ProportionalSettingView vi = GetProportionalSettingView(5, _db2107Helper.PID.Convey_V3); //{ // Id = 5, // PV = basePlcHelper.conveyV3_PV.NowValue.ToFloat(), // SV = basePlcHelper.conveyV3_SV.NowValue.ToFloat() //}; return vi; } private static void Down654(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(654, view); } } private static ProportionalSettingView Up654() { ProportionalSettingView vi = GetProportionalSettingView(6, _db2107Helper.PID.Purge_V3); //{ // Id = 6, // PV = basePlcHelper.purgeV3_PV.NowValue.ToFloat(), // SV = basePlcHelper.purgeV3_SV.NowValue.ToFloat() //}; return vi; } private static void Down662(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(662, view); } } private static ProportionalSettingView Up662() { ProportionalSettingView vi = GetProportionalSettingView(7, _db2107Helper.PID.Convey_V4); //{ // Id = 7, // PV = basePlcHelper.conveyV4_PV.NowValue.ToFloat(), // SV = basePlcHelper.conveyV4_SV.NowValue.ToFloat() //}; return vi; } private static void Down670(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(670, view); } } private static ProportionalSettingView Up670() { ProportionalSettingView vi = GetProportionalSettingView(8, _db2107Helper.PID.Purge_V4); //{ // Id = 8, // PV = basePlcHelper.purgeV4_PV.NowValue.ToFloat(), // SV = basePlcHelper.purgeV4_SV.NowValue.ToFloat() //}; return vi; } private static void Down678(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(678, view); } } private static ProportionalSettingView Up678() { ProportionalSettingView vi = GetProportionalSettingView(9, _db2107Helper.PID.Convey_V5); //{ // Id = 9, // PV = basePlcHelper.conveyV5_PV.NowValue.ToFloat(), // SV = basePlcHelper.conveyV5_SV.NowValue.ToFloat() //}; return vi; } private static void Down686(ProportionalSettingView view) { if (null != view) { DownProportionalSettingView(686, view); } } private static ProportionalSettingView Up686() { ProportionalSettingView vi = GetProportionalSettingView(10, _db2107Helper.PID.Purge_V5); //{ // Id = 10, // PV = basePlcHelper.purgeV5_PV.NowValue.ToFloat(), // SV = basePlcHelper.purgeV5_SV.NowValue.ToFloat() //}; return vi; } public static void DownToPlc(IEnumerable views) { foreach (var v in views) { switch (v.Id) { case 1: Down614(v); break; case 2: Down622(v); break; case 3: Down630(v); break; case 4: Down638(v); break; case 5: Down646(v); break; case 6: Down654(v); break; case 7: Down662(v); break; case 8: Down670(v); break; case 9: Down678(v); break; case 10: Down686(v); break; } } } public static ProportionalSettingView UpFromPlc(int id) { switch (id) { case 1: return Up614(); case 2: return Up622(); case 3: return Up630(); case 4: return Up638(); case 5: return Up646(); case 6: return Up654(); case 7: return Up662(); case 8: return Up670(); case 9: return Up678(); case 10: return Up686(); } return null; } public static IEnumerable UpFromPlc() { ICollection co = new List(); co.Add(Up614()); co.Add(Up622()); co.Add(Up630()); co.Add(Up638()); co.Add(Up646()); co.Add(Up654()); co.Add(Up662()); co.Add(Up670()); co.Add(Up678()); co.Add(Up686()); return co; } } }