|
@@ -31,6 +31,7 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
public ServiceMonitorViewModel()
|
|
public ServiceMonitorViewModel()
|
|
|
{
|
|
{
|
|
|
Houses = new ObservableCollection<HouseMonitorRowVm>();
|
|
Houses = new ObservableCollection<HouseMonitorRowVm>();
|
|
|
|
|
+ Faults = new ObservableCollection<HouseFaultRowVm>();
|
|
|
Refresh();
|
|
Refresh();
|
|
|
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
|
|
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
|
|
|
_timer.Tick += (s, e) => Refresh();
|
|
_timer.Tick += (s, e) => Refresh();
|
|
@@ -62,7 +63,21 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
[ObservableProperty] private string diskText;
|
|
[ObservableProperty] private string diskText;
|
|
|
[ObservableProperty] private Brush diskBrush;
|
|
[ObservableProperty] private Brush diskBrush;
|
|
|
|
|
|
|
|
|
|
+ // —— 舱故障(H-08:读 /status Faults,红色高亮展示)——
|
|
|
|
|
+ /// <summary>是否存在舱故障(内部逻辑用)。</summary>
|
|
|
|
|
+ [ObservableProperty] private bool hasFaults;
|
|
|
|
|
+ /// <summary>故障区标题文案(有故障="舱故障(N)" / 无故障="舱室均正常")。</summary>
|
|
|
|
|
+ [ObservableProperty] private string faultSummaryText;
|
|
|
|
|
+ /// <summary>故障区标题色(有故障=红 / 无故障=绿)。</summary>
|
|
|
|
|
+ [ObservableProperty] private Brush faultSummaryBrush;
|
|
|
|
|
+ /// <summary>故障列表显隐(有故障可见)。直接给 Visibility,避免依赖未注册的布尔转换器。</summary>
|
|
|
|
|
+ [ObservableProperty] private Visibility faultListVisibility = Visibility.Collapsed;
|
|
|
|
|
+ /// <summary>"无故障"绿条显隐(无故障可见)。</summary>
|
|
|
|
|
+ [ObservableProperty] private Visibility noFaultVisibility = Visibility.Visible;
|
|
|
|
|
+
|
|
|
public ObservableCollection<HouseMonitorRowVm> Houses { get; }
|
|
public ObservableCollection<HouseMonitorRowVm> Houses { get; }
|
|
|
|
|
+ /// <summary>舱故障只读行(启动排除 + 运行期突发,来源 snap.Faults)。</summary>
|
|
|
|
|
+ public ObservableCollection<HouseFaultRowVm> Faults { get; }
|
|
|
|
|
|
|
|
private static readonly Brush Green = new SolidColorBrush(Color.FromRgb(0x2E, 0xA0, 0x43));
|
|
private static readonly Brush Green = new SolidColorBrush(Color.FromRgb(0x2E, 0xA0, 0x43));
|
|
|
private static readonly Brush Red = new SolidColorBrush(Color.FromRgb(0xD0, 0x32, 0x2D));
|
|
private static readonly Brush Red = new SolidColorBrush(Color.FromRgb(0xD0, 0x32, 0x2D));
|
|
@@ -158,6 +173,15 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
CapturePausedBrush = h.CapturePausedByGate ? Amber : Green,
|
|
CapturePausedBrush = h.CapturePausedByGate ? Amber : Green,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 舱故障(H-08):启动排除 + 运行期突发,红色高亮;无故障显示绿色"舱室均正常"。
|
|
|
|
|
+ Faults.Clear();
|
|
|
|
|
+ foreach (var vm in BuildFaultRows(snap.Faults)) Faults.Add(vm);
|
|
|
|
|
+ HasFaults = Faults.Count > 0;
|
|
|
|
|
+ FaultSummaryText = HasFaults ? $"舱故障({Faults.Count})" : "舱室均正常,无故障";
|
|
|
|
|
+ FaultSummaryBrush = HasFaults ? Red : Green;
|
|
|
|
|
+ FaultListVisibility = HasFaults ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
|
+ NoFaultVisibility = HasFaults ? Visibility.Collapsed : Visibility.Visible;
|
|
|
}
|
|
}
|
|
|
catch
|
|
catch
|
|
|
{
|
|
{
|
|
@@ -196,6 +220,32 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
|
|
|
|
|
private static string FmtOk(DateTime? t) => t == null ? "—" : t.Value.ToString("HH:mm:ss");
|
|
private static string FmtOk(DateTime? t) => t == null ? "—" : t.Value.ToString("HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// 舱故障行映射(H-08):snap.Faults(control 透出的 HouseFaultRow) → 展示行。
|
|
|
|
|
+ /// 文案走纯静态 <see cref="ServiceMonitorFaultMapper"/>(可独立 harness/单测),颜色 Brush 在此加。
|
|
|
|
|
+ /// public static 便于不起 WPF 外壳即可验证有故障场景的中文/时间/隔离映射。
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public static System.Collections.Generic.List<HouseFaultRowVm> BuildFaultRows(
|
|
|
|
|
+ System.Collections.Generic.IEnumerable<ivf_tl_Control.HouseFaultRow> faults)
|
|
|
|
|
+ {
|
|
|
|
|
+ var list = new System.Collections.Generic.List<HouseFaultRowVm>();
|
|
|
|
|
+ if (faults == null) return list;
|
|
|
|
|
+ foreach (var f in faults)
|
|
|
|
|
+ {
|
|
|
|
|
+ list.Add(new HouseFaultRowVm
|
|
|
|
|
+ {
|
|
|
|
|
+ HouseText = ServiceMonitorFaultMapper.HouseText(f.HouseSn),
|
|
|
|
|
+ FaultTypeText = ServiceMonitorFaultMapper.FaultTypeZh(f.FaultType),
|
|
|
|
|
+ Reason = string.IsNullOrEmpty(f.Reason) ? "—" : f.Reason,
|
|
|
|
|
+ Stage = string.IsNullOrEmpty(f.Stage) ? "—" : f.Stage,
|
|
|
|
|
+ AtText = ServiceMonitorFaultMapper.AtText(f.At),
|
|
|
|
|
+ IsolatedText = ServiceMonitorFaultMapper.IsolatedText(f.Isolated),
|
|
|
|
|
+ IsolatedBrush = f.Isolated ? Red : Amber,
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void Dispose()
|
|
public void Dispose()
|
|
|
{
|
|
{
|
|
|
try { _timer?.Stop(); } catch { }
|
|
try { _timer?.Stop(); } catch { }
|
|
@@ -222,4 +272,16 @@ namespace ivf_tl_Operate.ViewModel
|
|
|
public string CapturePausedText { get; set; }
|
|
public string CapturePausedText { get; set; }
|
|
|
public Brush CapturePausedBrush { get; set; }
|
|
public Brush CapturePausedBrush { get; set; }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /// <summary>单条舱故障只读展示行(H-08)。</summary>
|
|
|
|
|
+ public class HouseFaultRowVm
|
|
|
|
|
+ {
|
|
|
|
|
+ public string HouseText { get; set; }
|
|
|
|
|
+ public string FaultTypeText { get; set; }
|
|
|
|
|
+ public string Reason { get; set; }
|
|
|
|
|
+ public string Stage { get; set; }
|
|
|
|
|
+ public string AtText { get; set; }
|
|
|
|
|
+ public string IsolatedText { get; set; }
|
|
|
|
|
+ public Brush IsolatedBrush { get; set; }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|