Bläddra i källkod

修改手动检测

user_lt 1 år sedan
förälder
incheckning
6a482d8ca3

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

@@ -63,7 +63,7 @@ namespace PLCTool.Common
             {
                 case VarType.Bit:
            
-                    reSuc = ENT.GetBitState(PlcMemory.DM, address, out rb);
+                    reSuc = ENT.GetBitState(PlcMemory.CIO, address, out rb);
                     //读取成功
                     if (reSuc == 0)
                     {

+ 22 - 6
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -588,7 +588,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                             {
                                                  bool writeResult = PLCCom.GetInstance().WritePlcObject(plcAddress, VarType.Bit, plcValue);
                                                 ///实时值记录
-                                              
+                                                item.RealValue = plcValue;
                                                 item.TestTime = DateTime.Now;
                                                 if (writeResult)
                                                 {
@@ -619,7 +619,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                             {
                                                 bool writeResult = PLCCom.GetInstance().WritePlcObject(plcAddress, VarType.Word, plcValue);
                                                 ///实时值记录
-
+                                                item.RealValue = plcValue;
                                                 item.TestTime = DateTime.Now;
                                                 if (writeResult)
                                                 {
@@ -670,7 +670,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             //更新测试记录
             UpdateTesDtltRecord();
         }
-        private void TestJudgementMethod()
+        private async  void TestJudgementMethod()
         {
             switch (SelectOutJudge)
             {
@@ -703,7 +703,23 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                 {
                                  
                                     case "bool":
-                                        string readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
+                                        DateTime entryTime = DateTime.Now;
+                                        string readResult = string.Empty;
+                                        //一直读
+                                        await Task.Run(async () =>
+                                        {
+                                            while (entryTime.AddMilliseconds(10 * 1000) > DateTime.Now)
+                                            {
+                                                readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
+                                                if (readResult == item.PlcValue)
+                                                {
+                                                    break;
+                                                }
+                                                await Task.Delay(1000);
+                                            }
+                                        });
+                                       
+                                       
                                         ///实时值记录
                                         item.RealValue = readResult;
                                         item.TestTime = DateTime.Now;
@@ -733,13 +749,13 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             if ((countCond == OutConList.Count)&&(countCond!=0))
                             {
                                 bizTestRecordDtlDto.JudgementResult = "合格";
-                                StepIndex = 3;
+                                
                             }
                             else
                             {
                                 bizTestRecordDtlDto.JudgementResult = "不合格";
                             }
-
+                            StepIndex = 3;
                             break;
                         case "OR":
                             break;