Kaynağa Gözat

检测时间调整

ltwork 1 yıl önce
ebeveyn
işleme
2bdf3b50bc

+ 1 - 1
BlankApp1/BlankApp1/App.config

@@ -3,7 +3,7 @@
 	<appSettings>
 		<!--连接字符串 SQL Server-->
 		<add key="MySql" value="Data Source=localhost;Database=plc_point_db;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"/>
 
 	</appSettings>

+ 8 - 5
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -948,6 +948,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private async Task ReadJudge(String strLogic)
         {
             int countCond = 0;
+            DateTime entryTime = DateTime.Now;
             foreach (var item in OutConList.OrderBy(x => x.Id))
             {
                 string plcAddress = item.PlcAddress;
@@ -958,7 +959,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 {
 
                     case "bool":
-                        DateTime entryTime = DateTime.Now;
+                      
                         string readResult = string.Empty;
                         //一直读
                         await Task.Run(async () =>
@@ -979,7 +980,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                 await Task.Delay(1000);
                             }
                         });
-
+                        //可能有多个条件判定的,第二次时间到了直接跳出延时,直接读取,不用在延时20s
+                        readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
                         ProVisibility = Visibility.Hidden;
                         ///实时值记录
                         item.RealValue = readResult;
@@ -996,12 +998,12 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
                         break;
                     case "word":
-                        DateTime entryTime2 = DateTime.Now;
+                       // DateTime entryTime2 = DateTime.Now;
                         string readResult2 = string.Empty;
                         //一直读
                         await Task.Run(async () =>
                         {
-                            while (entryTime2.AddMilliseconds(delayTime * 1000) > DateTime.Now)
+                            while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
                             {
                                 //显示进度条
                                 System.Windows.Application.Current.Dispatcher.Invoke((delegate
@@ -1017,7 +1019,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                 await Task.Delay(1000);
                             }
                         });
-
+                        //可能有多个条件判定的,第二次直接跳出延时,直接读取
+                        readResult2 = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Word);
                         ProVisibility = Visibility.Hidden;
                         ///实时值记录
                         item.RealValue = readResult2;

+ 1 - 1
BlankApp1/BlankApp1/Views/BusinessManageView/AutoTestView.xaml

@@ -8,7 +8,7 @@
              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              xmlns:prism="http://prismlibrary.com/" 
              BorderBrush="#CBCBCB" BorderThickness="1" 
-             Height="700" Width="1100"   >
+             Height="600" Width="1100"   >
     <UserControl.Resources>
         <Style TargetType="TextBlock" x:Key="textBlockStyle">
             <Setter Property="Width" Value="80"/>

+ 1 - 1
BlankApp1/BlankApp1/Views/BusinessManageView/ManualTestView.xaml

@@ -8,7 +8,7 @@
              xmlns:prism="http://prismlibrary.com/" 
              xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
              BorderBrush="#CBCBCB" BorderThickness="1"
-             Height="700" Width="1100" >
+             Height="600" Width="1100" >
 
     <UserControl.Resources>
         <Style TargetType="TextBlock" x:Key="textBlockStyle">