diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs index c3cdbde..c95400b 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs @@ -743,57 +743,57 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl case 1: PowderDownSignel(MinAnPlc.Heir1, 1); - DB2105WriteHelper.WriteSetValueH1(value); - DB2105WriteHelper.WriteH(1, "L", true); + DB2105WriteHelper.WriteSetValueL1(value); + DB2105WriteHelper.WriteHNo(1, "L", true); // DB2105WriteHelper.WriteManScrewH1(); break; case 2: PowderDownSignel(MinAnPlc.Heir1, 1); - DB2105WriteHelper.WriteSetValueH1(value); - DB2105WriteHelper.WriteH(1, "R", true); + DB2105WriteHelper.WriteSetValueR1(value); + DB2105WriteHelper.WriteHNo(1, "R", true); // DB2105WriteHelper.WriteManScrewH2(); break; case 3: PowderDownSignel(MinAnPlc.Heir2, 2); - DB2105WriteHelper.WriteSetValueH2(value); - DB2105WriteHelper.WriteH(2, "L", true); + DB2105WriteHelper.WriteSetValueL2(value); + DB2105WriteHelper.WriteHNo(2, "L", true); // DB2105WriteHelper.WriteManScrewH3(); break; case 4: PowderDownSignel(MinAnPlc.Heir2, 2); - DB2105WriteHelper.WriteSetValueH2(value); - DB2105WriteHelper.WriteH(2, "R", true); + DB2105WriteHelper.WriteSetValueR2(value); + DB2105WriteHelper.WriteHNo(2, "R", true); // DB2105WriteHelper.WriteManScrewH4(); break; case 5: PowderDownSignel(MinAnPlc.Heir3, 3); - DB2105WriteHelper.WriteSetValueH3(value); - DB2105WriteHelper.WriteH(3, "L", true); + DB2105WriteHelper.WriteSetValueL3(value); + DB2105WriteHelper.WriteHNo(3, "L", true); //DB2105WriteHelper.WriteManScrewH5(); break; case 6: PowderDownSignel(MinAnPlc.Heir3, 3); - DB2105WriteHelper.WriteSetValueH3(value); + DB2105WriteHelper.WriteSetValueR3(value); - DB2105WriteHelper.WriteH(3, "R", true); + DB2105WriteHelper.WriteHNo(3, "R", true); // DB2105WriteHelper.WriteManScrewH6(); break; case 7: PowderDownSignel(MinAnPlc.Heir4, 4); - DB2105WriteHelper.WriteSetValueH4(value); - DB2105WriteHelper.WriteH(4, "L", true); + DB2105WriteHelper.WriteSetValueL4(value); + DB2105WriteHelper.WriteHNo(4, "L", true); // DB2105WriteHelper.WriteManScrewH7(); break; case 8: PowderDownSignel(MinAnPlc.Heir4, 4); - DB2105WriteHelper.WriteSetValueH4(value); - DB2105WriteHelper.WriteH(4, "R", true); + DB2105WriteHelper.WriteSetValueR4(value); + DB2105WriteHelper.WriteHNo(4, "R", true); //DB2105WriteHelper.WriteManScrewH8(); break; @@ -820,36 +820,66 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl public static bool WetSetWeight(SetValue value, MCRadioButtonEntity RadioE) { - - var singE = ControlsHelper.SingleSelect(RadioE); - switch (singE) { case 1: + + + DB2105WriteHelper.WriteSetValueL1(value); + + // DB2105WriteHelper.WriteManScrewH1(); + + break; case 2: - DB2105WriteHelper.WriteSetValueH1(value); + + DB2105WriteHelper.WriteSetValueR1(value); + + // DB2105WriteHelper.WriteManScrewH2(); + break; case 3: + + DB2105WriteHelper.WriteSetValueL2(value); + + // DB2105WriteHelper.WriteManScrewH3(); + + break; case 4: + + DB2105WriteHelper.WriteSetValueR2(value); + + // DB2105WriteHelper.WriteManScrewH4(); - DB2105WriteHelper.WriteSetValueH2(value); break; - case 5: + + DB2105WriteHelper.WriteSetValueL3(value); + + //DB2105WriteHelper.WriteManScrewH5(); + + break; case 6: - DB2105WriteHelper.WriteSetValueH3(value); + DB2105WriteHelper.WriteSetValueR3(value); + + + // DB2105WriteHelper.WriteManScrewH6(); break; - - case 7: + + DB2105WriteHelper.WriteSetValueL4(value); + + // DB2105WriteHelper.WriteManScrewH7(); + + break; case 8: - - DB2105WriteHelper.WriteSetValueH4(value); - + + DB2105WriteHelper.WriteSetValueR4(value); + + //DB2105WriteHelper.WriteManScrewH8(); + break; - default: MessageBox.Show("当前未选择产线!"); return false; @@ -872,7 +902,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl { var singE = ControlsHelper.SingleSelect(RadioE); int no = (singE + 1) / 2; - DB2105WriteHelper.WriteH(no, "S", true); + DB2105WriteHelper.WriteHNo(no, "S", true); } diff --git a/DataBlockHelper/DBHelpers/DB2104Helper.cs b/DataBlockHelper/DBHelpers/DB2104Helper.cs index 66841c0..3817d73 100644 --- a/DataBlockHelper/DBHelpers/DB2104Helper.cs +++ b/DataBlockHelper/DBHelpers/DB2104Helper.cs @@ -83,16 +83,20 @@ namespace DataBlockHelper.DBHelpers { var instanceByteTransform = PlcConnect.Instance.ByteTransform; var ls = this.bytes = PlcConnect.Instance.Read($"DB2104.{start}.0", 16).Content; - WaterEntity entity = new WaterEntity + if (ls != null) { - Bin = instanceByteTransform.TransInt16(ls, 0), - Set = instanceByteTransform.TransSingle(ls, 2), - Tolerance = instanceByteTransform.TransSingle(ls, 6), - differ = instanceByteTransform.TransSingle(ls, 10), - stand = instanceByteTransform.TransInt16(ls, 14), - }; - return entity; + WaterEntity entity = new WaterEntity + { + Bin = instanceByteTransform.TransInt16(ls, 0), + Set = instanceByteTransform.TransSingle(ls, 2), + Tolerance = instanceByteTransform.TransSingle(ls, 6), + differ = instanceByteTransform.TransSingle(ls, 10), + stand = instanceByteTransform.TransInt16(ls, 14), + }; + return entity; + } + return new WaterEntity(); } diff --git a/DataBlockHelper/DBHelpers/DB2105Helper.cs b/DataBlockHelper/DBHelpers/DB2105Helper.cs index 1ac0f4f..2183089 100644 --- a/DataBlockHelper/DBHelpers/DB2105Helper.cs +++ b/DataBlockHelper/DBHelpers/DB2105Helper.cs @@ -12,7 +12,7 @@ namespace DataBlockHelper.DBHelpers { public DB2105Helper() { - this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 206).Content; + this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 222).Content; } public List Plan => new PlanArrayManager(4, 0, 12, bytes).GetList(); public bool[] Status => new FourBoolArrayManager(48, bytes).GetList(); @@ -151,18 +151,19 @@ namespace DataBlockHelper.DBHelpers public bool FeededDry => ReadReady(110, 4); + // public ManualH H1 => ReadH(134); - public ManualH H2 => ReadH(144); + public ManualH H2 => ReadH(148); - public ManualH H3 => ReadH(154); + public ManualH H3 => ReadH(162); - public ManualH H4 => ReadH(164); + public ManualH H4 => ReadH(176); - public ForceWaterEntity Force_HA => new ForceWaterEntity(bytes, 174); - public ForceWaterEntity Force_HB => new ForceWaterEntity(bytes, 182); - public ForceWaterEntity Force_CA => new ForceWaterEntity(bytes, 190); - public ForceWaterEntity Force_CB => new ForceWaterEntity(bytes, 198); + public ForceWaterEntity Force_HA => new ForceWaterEntity(bytes, 190); + public ForceWaterEntity Force_HB => new ForceWaterEntity(bytes, 198); + public ForceWaterEntity Force_CA => new ForceWaterEntity(bytes, 206); + public ForceWaterEntity Force_CB => new ForceWaterEntity(bytes, 214); /// /// 获取所有的 feededDry 是不是读取好了 @@ -220,16 +221,17 @@ namespace DataBlockHelper.DBHelpers { ManualH manual = new ManualH(); - var content = bytes.Skip(start).Take(10).ToArray(); + var content = bytes.Skip(start).Take(14).ToArray(); var first = bytes.Skip(start).Take(1).First(); manual.FeedStartL = first.GetBit(0); manual.FeedStartR = first.GetBit(1); manual.FeedStop = first.GetBit(2); manual.RunStatus = first.GetBit(3); - manual.SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 2); - manual.Toterance = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + manual.SetValueL = PlcConnect.Instance.ByteTransform.TransSingle(content, 2); + manual.SetValueR = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + manual.Toterance = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); return manual; } @@ -259,7 +261,9 @@ namespace DataBlockHelper.DBHelpers public bool FeedStartR { get; set; } public bool FeedStop { get; set; } public bool RunStatus { get; set; } - public float SetValue { get; set; } + public float SetValueL { get; set; } + + public float SetValueR { get; set; } public float Toterance { get; set; } } diff --git a/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs b/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs index d529b86..cc11e51 100644 --- a/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs +++ b/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs @@ -159,28 +159,49 @@ namespace DataBlockHelper.DBHelpers /// 换一个数据区 134 /// /// - public static void WriteSetValueH1(SetValue setValue) + public static void WriteSetValueL1(SetValue setValue) { - WriteH(1, setValue.Value,setValue.Toterance); + WriteL(1, setValue.Value,setValue.Toterance); } - public static void WriteSetValueH2(SetValue setValue) + public static void WriteSetValueR1(SetValue setValue) { - WriteH(2, setValue.Value, setValue.Toterance); + WriteR(1, setValue.Value, setValue.Toterance); } - public static void WriteSetValueH3(SetValue setValue) + public static void WriteSetValueL2(SetValue setValue) { - WriteH(3, setValue.Value, setValue.Toterance); + WriteL(2, setValue.Value, setValue.Toterance); } - public static void WriteSetValueH4(SetValue setValue) + public static void WriteSetValueR2(SetValue setValue) { - WriteH(4, setValue.Value, setValue.Toterance); + WriteR(2, setValue.Value, setValue.Toterance); + } + + + public static void WriteSetValueL3(SetValue setValue) + { + WriteL(3, setValue.Value, setValue.Toterance); + } + + public static void WriteSetValueR3(SetValue setValue) + { + WriteR(3, setValue.Value, setValue.Toterance); + } + + + public static void WriteSetValueL4(SetValue setValue) + { + WriteL(4, setValue.Value, setValue.Toterance); + } + + public static void WriteSetValueR4(SetValue setValue) + { + WriteR(4, setValue.Value, setValue.Toterance); } - - + private static void WriteSetValue(int start,SetValue setValue) { @@ -413,11 +434,11 @@ namespace DataBlockHelper.DBHelpers - public static bool WriteH(int no,string t, bool b) + public static bool WriteHNo(int no,string t, bool b) { var siemensS7Net = PlcConnect.Instance; int start = 134; - int db=start+((no - 1)*10); + int db=start+((no - 1)*14); int dian = 0; if (t == "L") { @@ -443,21 +464,36 @@ namespace DataBlockHelper.DBHelpers } - public static bool WriteH(int no,float value,float tolerance) + public static bool WriteL(int no, float value, float tolerance) + { + var siemensS7Net = PlcConnect.Instance; + int start = 134; + int db = start + ((no - 1) * 14); + + var operate = siemensS7Net.Write($"{DbName}.{db + 2}.0", value); + operate = siemensS7Net.Write($"{DbName}.{db + 10}.0", tolerance); + return operate.IsSuccess; + } + + + public static bool WriteR(int no, float value, float tolerance) { var siemensS7Net = PlcConnect.Instance; int start = 134; - int db = start + ((no - 1) * 10); + int db = start + ((no - 1) * 14); - var operate = siemensS7Net.Write($"{DbName}.{db+2}.0", value); - operate = siemensS7Net.Write($"{DbName}.{db+6}.0", tolerance); + var operate = siemensS7Net.Write($"{DbName}.{db + 6}.0", value); + operate = siemensS7Net.Write($"{DbName}.{db + 10}.0", tolerance); return operate.IsSuccess; } - private static readonly int HaNo = 174; - public static readonly int HbNo = 182; - private static readonly int CaNo = 190; - private static readonly int CbNo = 198; + + + + private static readonly int HaNo = 190; + public static readonly int HbNo = 198; + private static readonly int CaNo = 206; + private static readonly int CbNo = 214; #region 添加方法Ha