瀏覽代碼

修改PLC复位

ltwork 1 年之前
父節點
當前提交
9405181bd7

+ 2 - 2
BlankApp1/BlankApp1/App.config

@@ -3,8 +3,8 @@
 	<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.250.1"/>
-		<add key="PLCPort" value="5999"/>
+		<add key="PLCIp" value="192.168.3.39"/>
+		<add key="PLCPort" value="3000"/>
 		<add key="DelayTime" value="20"/>
 		<add key="LongDelayTime" value="60"/>
 	</appSettings>

+ 19 - 0
BlankApp1/BlankApp1/Common/IPLCConnection.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PLCTool.Common
+{
+    public interface IPLCConnection
+    {
+     
+        bool ConnectPLC();
+        bool IsConnectPLC();
+        string ReadPlcObject(string address, VarType valueType);
+        bool WritePlcObject(string address, VarType valueType, string writeValue);
+        bool ResetPLC(string address, VarType valueType, string writeValue);
+    }
+
+}

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

@@ -232,7 +232,7 @@ namespace PLCTool.Common
             
             return isSuccess;
         }
-        public bool WritePlcCIOObject(string address, VarType valueType, string writeValue)
+        public bool ResetPLC(string address, VarType valueType, string writeValue)
         {
             bool isSuccess = false;
 

+ 3 - 3
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -96,11 +96,11 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         /// </summary>
         private async void Reset()
         {
-            PLCCom.GetInstance().WritePlcCIOObject("1.00", VarType.Bit, "0");
+            PLCCom.GetInstance().ResetPLC("1.00", VarType.Bit, "0");
             await Task.Delay(1000);
-            PLCCom.GetInstance().WritePlcCIOObject("1.00", VarType.Bit, "1");
+            PLCCom.GetInstance().ResetPLC("1.00", VarType.Bit, "1");
             await Task.Delay(1000);
-            bool isResult=PLCCom.GetInstance().WritePlcCIOObject("1.00", VarType.Bit, "0");
+            bool isResult=PLCCom.GetInstance().ResetPLC("1.00", VarType.Bit, "0");
             if(isResult)
             {
                 MessageBox.Show("复位成功!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);