소스 검색

修改PLC发送

ltwork 1 년 전
부모
커밋
0478dfc237
1개의 변경된 파일22개의 추가작업 그리고 2개의 파일을 삭제
  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)
                         {