Przeglądaj źródła

修改PLC发送

ltwork 1 rok temu
rodzic
commit
0478dfc237
1 zmienionych plików z 22 dodań i 2 usunięć
  1. 22 2
      BlankApp1/BlankApp1/Common/PLCCom.cs

+ 22 - 2
BlankApp1/BlankApp1/Common/PLCCom.cs

@@ -161,6 +161,7 @@ namespace PLCTool.Common
                 switch (valueType)
                 {
                     case VarType.Bit:
+                    
                         BitState bit = BitState.OFF;
                         if (writeValue.Trim() == "1")
                         {
@@ -174,7 +175,16 @@ namespace PLCTool.Common
                             }
 
                         }
-                        reSuc = ENT.SetBitState(PlcMemory.CIO, address, bit);
+                        if (address.Contains("w") || address.Contains("W"))
+                        {
+                            reSuc = ENT.SetBitState(PlcMemory.WR, address, bit);
+                           
+                        }
+                        else
+                        {
+                            reSuc = ENT.SetBitState(PlcMemory.CIO, address, bit);
+                        }
+                       
                         //写成功
                         if (reSuc == 0)
                         {
@@ -185,7 +195,17 @@ namespace PLCTool.Common
                         break;
                     case VarType.Word:
                         short wValue = Convert.ToInt16(writeValue);
-                        reSuc = ENT.WriteWord(PlcMemory.DM, short.Parse(address), wValue);
+                        if (address.Contains("w") || address.Contains("W"))
+                        {
+                            reSuc = ENT.WriteWord(PlcMemory.WR, short.Parse(address), wValue);
+
+                        }
+                        else
+                        {
+                            reSuc = ENT.WriteWord(PlcMemory.DM, short.Parse(address), wValue);
+
+                        }
+                        
                         //写成功
                         if (reSuc == 0)
                         {