ltwork 1 year ago
parent
commit
e7195a6893
2 changed files with 11 additions and 2 deletions
  1. 1 1
      BlankApp1/BlankApp1/App.config
  2. 10 1
      BlankApp1/BlankApp1/Common/PLCCom.cs

+ 1 - 1
BlankApp1/BlankApp1/App.config

@@ -3,7 +3,7 @@
 	<appSettings>
 		<!--连接字符串 SQL Server-->
 		<add key="MySql" value="Data Source=localhost;Database=plc_point_db2;User Id='root';Password='521125';port=3306;charset=utf8mb4;"/>
-		<add key="PLCIp" value="192.168.0.20"/>
+		<add key="PLCIp" value="192.168.250.1"/>
 		<add key="PLCPort" value="9600"/>
 		<add key="DelayTime" value="20"/>
 		<add key="LongDelayTime" value="60"/>

+ 10 - 1
BlankApp1/BlankApp1/Common/PLCCom.cs

@@ -36,7 +36,16 @@ namespace PLCTool.Common
 
         public bool IsConnectPLC()
         {
-            return isConnect;
+            //return ENT.IsConnect;
+            short rb;
+            //读取CIO区判断PLC连接情况
+            short reSuc = ENT.GetBitState(PlcMemory.CIO, "3321.10", out rb);
+            //读取成功
+            if (reSuc == 0)
+            {
+                return true;
+            }
+            return false;
         }
 
         private bool ConnectPLC()