|
@@ -65,12 +65,23 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
StartCommand = new DelegateCommand(Start);
|
|
|
StopOrContinueCommand = new DelegateCommand<object>(StopOrContinueMethod);
|
|
|
CancelCommand = new DelegateCommand<object>(Cancel);
|
|
|
+ UnLoadCommand = new DelegateCommand(Unload);
|
|
|
BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
|
|
|
InConList = new ObservableCollection<BasPlcItemConfigDto>();
|
|
|
OutConList = new ObservableCollection<BasPlcItemConfigDto>();
|
|
|
GetConfigOption();
|
|
|
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 关闭窗体是触发
|
|
|
+ /// </summary>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ private void Unload()
|
|
|
+ {
|
|
|
+
|
|
|
+ m.Reset(); //阻塞线程
|
|
|
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
|
+ }
|
|
|
|
|
|
private void Cancel(object obj)
|
|
|
{
|
|
@@ -551,6 +562,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
bool isJudgeResult = await TestJudgementMethod();
|
|
|
//下一项
|
|
|
StepIndex = 0;
|
|
|
+ await Task.Delay(2000);
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -651,7 +663,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
|
|
|
item.RealValue = readResult;
|
|
|
item.TestTime = DateTime.Now;
|
|
|
- if (readResult.Trim() == plcValue.Trim())
|
|
|
+ if (readResult.Trim() == plcValue?.Trim())
|
|
|
{
|
|
|
item.TestResult = "通过";
|
|
|
countCond++;
|
|
@@ -869,6 +881,21 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
switch (SelectOutJudge)
|
|
|
{
|
|
|
case "人工判定":
|
|
|
+ DateTime entryTime = DateTime.Now;
|
|
|
+ await Task.Run(async () =>
|
|
|
+ {
|
|
|
+ while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
|
|
|
+ {
|
|
|
+ //显示进度条
|
|
|
+ System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
+ {
|
|
|
+ ProVisibility = Visibility.Visible;
|
|
|
+ }));
|
|
|
+
|
|
|
+ await Task.Delay(1000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ProVisibility = Visibility.Hidden;
|
|
|
//弹出确认的对话框
|
|
|
MessageBoxResult boxResult = MessageBox.Show(OutDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
|
|
|
if (boxResult == MessageBoxResult.OK)
|
|
@@ -887,6 +914,21 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
switch (OutSelectLogic)
|
|
|
{
|
|
|
case "NULL":
|
|
|
+ DateTime entryTime2 = DateTime.Now;
|
|
|
+ await Task.Run(async () =>
|
|
|
+ {
|
|
|
+ while (entryTime2.AddMilliseconds(delayTime * 1000) > DateTime.Now)
|
|
|
+ {
|
|
|
+ //显示进度条
|
|
|
+ System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
+ {
|
|
|
+ ProVisibility = Visibility.Visible;
|
|
|
+ }));
|
|
|
+
|
|
|
+ await Task.Delay(1000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ProVisibility = Visibility.Hidden;
|
|
|
bizTestRecordDtlDto.JudgementResult = "通过";
|
|
|
StepIndex = 3;
|
|
|
break;
|
|
@@ -902,6 +944,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}
|
|
|
//更新测试记录
|
|
|
//更新测试记录
|
|
|
+ endTime = DateTime.Now;
|
|
|
AddOrEditTesDtltRecord(globalSchDetailId);
|
|
|
|
|
|
return isJudge;
|
|
@@ -912,6 +955,21 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
private async Task ReadJudge(String strLogic)
|
|
|
{
|
|
|
int countCond = 0;
|
|
|
+ DateTime entryTime = DateTime.Now;
|
|
|
+ await Task.Run(async () =>
|
|
|
+ {
|
|
|
+ while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
|
|
|
+ {
|
|
|
+ //显示进度条
|
|
|
+ System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
+ {
|
|
|
+ ProVisibility = Visibility.Visible;
|
|
|
+ }));
|
|
|
+
|
|
|
+ await Task.Delay(1000);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ProVisibility = Visibility.Hidden;
|
|
|
foreach (var item in OutConList.OrderBy(x => x.Id))
|
|
|
{
|
|
|
string plcAddress = item.PlcAddress;
|
|
@@ -922,24 +980,12 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
{
|
|
|
|
|
|
case "bool":
|
|
|
- DateTime entryTime = DateTime.Now;
|
|
|
+
|
|
|
string readResult = string.Empty;
|
|
|
- //一直读
|
|
|
- await Task.Run(async () =>
|
|
|
- {
|
|
|
- while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
|
|
|
- {
|
|
|
- //显示进度条
|
|
|
- System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
- {
|
|
|
- ProVisibility = Visibility.Visible;
|
|
|
- }));
|
|
|
-
|
|
|
- await Task.Delay(1000);
|
|
|
- }
|
|
|
- });
|
|
|
+ //
|
|
|
+
|
|
|
readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
|
|
|
- ProVisibility = Visibility.Hidden;
|
|
|
+
|
|
|
///实时值记录
|
|
|
item.RealValue = readResult;
|
|
|
item.TestTime = DateTime.Now;
|
|
@@ -997,6 +1043,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//测试记录存入数据库
|
|
|
//输出项测试结果json转化
|
|
|
string prefixJsonStr = ModelToJsonToStr(SelectOutJudge, OutSelectLogic, OutDetail, OutConList);
|
|
@@ -1077,7 +1124,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
/// </summary>
|
|
|
private void Close()
|
|
|
{
|
|
|
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1128,9 +1176,9 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
public DelegateCommand StartCommand { set; get; }
|
|
|
public DelegateCommand<object> StopOrContinueCommand { set; get; }
|
|
|
public DelegateCommand<object> CancelCommand { set; get; }
|
|
|
+ public DelegateCommand UnLoadCommand { set; get; }
|
|
|
|
|
|
|
|
|
-
|
|
|
#endregion
|
|
|
#region 变量绑定
|
|
|
/// <summary>
|