| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- namespace ivf_tl_Operate.ViewModel
- {
- /// <summary>
- /// 舱故障(H-08)展示映射:把 control 经 /status 透出的 HouseFaultRow 原始字段
- /// (英文枚举名 / 舱号 / UTC 时间 / 隔离布尔) 转成现场可读中文文案。
- ///
- /// 纯静态、不依赖 WPF / control 程序集,签名只收基础类型,便于独立 harness / 单测验证
- /// (ServiceMonitorViewModel.BuildFaultRows 调用它构造展示行,颜色 Brush 留在 ViewModel)。
- /// </summary>
- public static class ServiceMonitorFaultMapper
- {
- /// <summary>HouseFaultType 枚举名(control 端 ToString 透出的英文)→ 现场可读中文。未知码原样返回。</summary>
- public static string FaultTypeZh(string type)
- {
- switch (type)
- {
- case "CameraReadFailed": return "相机SN读取异常";
- case "CameraDuplicateSn": return "相机SN重复";
- case "HouseSnDuplicate": return "舱号重复";
- case "CcdSnMissing": return "相机SN缺失(相机半坏)";
- case "CcdSnDuplicate": return "舱相机SN重复";
- case "SerialReadException": return "串口读异常";
- case "InitException": return "舱初始化异常";
- case "RuntimeFault": return "运行期突发故障";
- default: return string.IsNullOrEmpty(type) ? "未知故障" : type;
- }
- }
- /// <summary>舱号文案:>0=具体舱(可被剔除);否则=相机/串口级、未定位到具体舱。</summary>
- public static string HouseText(int houseSn) =>
- houseSn > 0 ? $"{houseSn}号舱" : "未定位(相机/串口级)";
- /// <summary>发生时刻:control 端存 UtcNow,展示转本地时间;default=未知。</summary>
- public static string AtText(DateTime atUtc) =>
- atUtc == default(DateTime) ? "—" : atUtc.ToLocalTime().ToString("MM-dd HH:mm:ss");
- /// <summary>隔离态文案:已被剔除/已停=已隔离;否则仅提示(舱号未知的相机/串口级故障不剔除某舱)。</summary>
- public static string IsolatedText(bool isolated) => isolated ? "已隔离" : "仅提示";
- }
- }
|