|
@@ -47,6 +47,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
private long selctStartDetailId = 0; //当前选择的第一个方案明细id
|
|
|
private BizTestRecordDtlDto bizTestRecordDtlDto = new BizTestRecordDtlDto(); //测试方案明细表
|
|
|
private const string TestMode = "自动测试";
|
|
|
+ private int delayTime = 20;
|
|
|
ManualResetEvent m = new ManualResetEvent(true); //实例化阻塞事件
|
|
|
CancellationTokenSource tokensource = new CancellationTokenSource(); //声明令牌
|
|
|
public AutoTestViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, ILogger logger)
|
|
@@ -892,7 +893,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
//一直读
|
|
|
await Task.Run(async () =>
|
|
|
{
|
|
|
- while (entryTime.AddMilliseconds(10 * 1000) > DateTime.Now)
|
|
|
+ while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
|
|
|
{
|
|
|
//显示进度条
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
@@ -925,7 +926,44 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
|
|
|
break;
|
|
|
case "word":
|
|
|
+ DateTime entryTime2 = DateTime.Now;
|
|
|
+ string readResult2 = string.Empty;
|
|
|
+ //一直读
|
|
|
+ await Task.Run(async () =>
|
|
|
+ {
|
|
|
+ while (entryTime2.AddMilliseconds(delayTime * 1000) > DateTime.Now)
|
|
|
+ {
|
|
|
+ //显示进度条
|
|
|
+ System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
+ {
|
|
|
+ ProVisibility = Visibility.Visible;
|
|
|
+ }));
|
|
|
+
|
|
|
+ readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Word);
|
|
|
+ if (readResult == item.PlcValue)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ await Task.Delay(1000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ ProVisibility = Visibility.Hidden;
|
|
|
+ ///实时值记录
|
|
|
+ item.RealValue = readResult2;
|
|
|
+ item.TestTime = DateTime.Now;
|
|
|
+ if (readResult2.Trim() == plcValue?.Trim())
|
|
|
+ {
|
|
|
+ item.TestResult = "合格";
|
|
|
+ countCond++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.TestResult = "不合格";
|
|
|
+ }
|
|
|
+
|
|
|
break;
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|