|
@@ -4,6 +4,7 @@ using System.Windows;
|
|
|
using System.Windows.Media;
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Threading;
|
|
using System.Windows.Threading;
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
+using CommunityToolkit.Mvvm.Input;
|
|
|
using MonitorSnapshot = ivf_tl_Control.MonitorSnapshot;
|
|
using MonitorSnapshot = ivf_tl_Control.MonitorSnapshot;
|
|
|
using ControlAppData = ivf_tl_Control.AppData;
|
|
using ControlAppData = ivf_tl_Control.AppData;
|
|
|
|
|
|
|
@@ -74,7 +75,8 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
MonitorSnapshot snap = null;
|
|
MonitorSnapshot snap = null;
|
|
|
- try { snap = ControlAppData.Instance != null ? ControlAppData.Instance.GetMonitorSnapshot() : null; } catch { snap = null; }
|
|
|
|
|
|
|
+ // 阶段2:拆分后 control 是独立进程,改经本地 HTTP /status 跨进程读快照(不再读同进程 AppData)。
|
|
|
|
|
+ try { snap = ivf_tl_Operate.Helpers.ControlClient.GetStatusSnapshot(); } catch { snap = null; }
|
|
|
|
|
|
|
|
if (snap == null)
|
|
if (snap == null)
|
|
|
{
|
|
{
|
|
@@ -149,6 +151,11 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
ComBrush = (h.ComState == "已连接") ? Green : Red,
|
|
ComBrush = (h.ComState == "已连接") ? Green : Red,
|
|
|
CcdText = (h.CcdState == "正常" && !h.CcdError) ? "正常" : "异常",
|
|
CcdText = (h.CcdState == "正常" && !h.CcdError) ? "正常" : "异常",
|
|
|
CcdBrush = (h.CcdState == "正常" && !h.CcdError) ? Green : Red,
|
|
CcdBrush = (h.CcdState == "正常" && !h.CcdError) ? Green : Red,
|
|
|
|
|
+ // 阶段2 §6 三块:实时活动 / 阀态 / 串口借用让路
|
|
|
|
|
+ WorkingType = string.IsNullOrEmpty(h.WorkingType) ? "—" : h.WorkingType,
|
|
|
|
|
+ ValveState = string.IsNullOrEmpty(h.ValveState) ? "—" : h.ValveState,
|
|
|
|
|
+ CapturePausedText = h.CapturePausedByGate ? "借用中(让路)" : "采集中",
|
|
|
|
|
+ CapturePausedBrush = h.CapturePausedByGate ? Amber : Green,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -158,6 +165,27 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 阶段2 §5.4 受护栏整体停止 control:二次确认 + 工程师口令 → POST /shutdown。
|
|
|
|
|
+ /// control 端校验口令(tl13579,App.config engineerPwd)通过才安全停机。
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ [RelayCommand]
|
|
|
|
|
+ private void ShutdownControl()
|
|
|
|
|
+ {
|
|
|
|
|
+ var c1 = MessageBox.Show(
|
|
|
|
|
+ "确定要【整体停止 control 后台采集】吗?\n停止后机器将不再被驱动,需重启 operate 才会重新拉起 control。",
|
|
|
|
|
+ "受护栏停止 · 二次确认", MessageBoxButton.YesNo, MessageBoxImage.Warning);
|
|
|
|
|
+ if (c1 != MessageBoxResult.Yes) return;
|
|
|
|
|
+ string pwd = Microsoft.VisualBasic.Interaction.InputBox(
|
|
|
|
|
+ "请输入工程师口令以确认整体停止 control:", "受护栏停止 · 工程师口令", "");
|
|
|
|
|
+ if (string.IsNullOrEmpty(pwd)) return;
|
|
|
|
|
+ bool ok = ivf_tl_Operate.Helpers.ControlClient.Shutdown(pwd);
|
|
|
|
|
+ MessageBox.Show(
|
|
|
|
|
+ ok ? "已发送停机指令,control 正在安全停机(关相机/串口句柄并退出)。"
|
|
|
|
|
+ : "停机失败:工程师口令错误,或 control 未连接。",
|
|
|
|
|
+ "受护栏停止", MessageBoxButton.OK, ok ? MessageBoxImage.Information : MessageBoxImage.Error);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static bool IsStale(DateTime? t) => t == null || (DateTime.Now - t.Value).TotalSeconds > StaleSeconds;
|
|
private static bool IsStale(DateTime? t) => t == null || (DateTime.Now - t.Value).TotalSeconds > StaleSeconds;
|
|
|
|
|
|
|
|
private static Brush LinkBrush(DateTime? t)
|
|
private static Brush LinkBrush(DateTime? t)
|
|
@@ -188,5 +216,10 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
public Brush ComBrush { get; set; }
|
|
public Brush ComBrush { get; set; }
|
|
|
public string CcdText { get; set; }
|
|
public string CcdText { get; set; }
|
|
|
public Brush CcdBrush { get; set; }
|
|
public Brush CcdBrush { get; set; }
|
|
|
|
|
+ // 阶段2 §6 三块补充
|
|
|
|
|
+ public string WorkingType { get; set; }
|
|
|
|
|
+ public string ValveState { get; set; }
|
|
|
|
|
+ public string CapturePausedText { get; set; }
|
|
|
|
|
+ public Brush CapturePausedBrush { get; set; }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|