源适应性界面
This commit is contained in:
@@ -24,6 +24,7 @@ namespace MainModule.ViewModels
|
||||
private bool IsInitialized =false;
|
||||
private bool _isRunningErrorSteps = false;
|
||||
private SubscriptionToken? _alarmToken;
|
||||
private SubscriptionToken? _silenceToken;
|
||||
#endregion
|
||||
|
||||
#region 属性
|
||||
@@ -87,7 +88,7 @@ namespace MainModule.ViewModels
|
||||
RefreshCommand = new DelegateCommand(OnRefresh);
|
||||
BackToProtocolCommand = new DelegateCommand(OnBackToProtocol);
|
||||
LoadedCommand = new AsyncDelegateCommand(OnLoad);
|
||||
_eventAggregator.GetEvent<SilenceBuzzerEvent>().Subscribe(async (scope) => await SilenceBuzzer(scope));
|
||||
_silenceToken = _eventAggregator.GetEvent<SilenceBuzzerEvent>().Subscribe(async (scope) => await SilenceBuzzer(scope));
|
||||
_alarmToken = _eventAggregator.GetEvent<AlarmEvent>().Subscribe(OnAlarmTriggered);
|
||||
}
|
||||
|
||||
@@ -95,21 +96,29 @@ namespace MainModule.ViewModels
|
||||
{
|
||||
if (_deviceManager.IOGroup == null) return;
|
||||
|
||||
if (scope == "default")
|
||||
try
|
||||
{
|
||||
for(int i = 1; i <= 8; i++)
|
||||
if (scope == "default")
|
||||
{
|
||||
await _deviceManager.IOGroup.执行台架动作Async(i, 功能动作.蜂鸣器报警, false);
|
||||
for(int i = 1; i <= 8; i++)
|
||||
{
|
||||
await _deviceManager.IOGroup.执行台架动作Async(i, 功能动作.蜂鸣器报警, false);
|
||||
}
|
||||
}
|
||||
else if (scope == TestStatus)
|
||||
{
|
||||
int 台架号 = _systemConfig.SharedParameterList
|
||||
.FirstOrDefault(x => x.ParameterName == "台架序号")?.Value ?? 0;
|
||||
if (台架号 >= 1 && 台架号 <= 8)
|
||||
{
|
||||
await _deviceManager.IOGroup.执行台架动作Async(台架号, 功能动作.蜂鸣器报警, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (scope == TestStatus)
|
||||
catch (Exception ex)
|
||||
{
|
||||
int 台架号 = _systemConfig.SharedParameterList
|
||||
.FirstOrDefault(x => x.ParameterName == "台架序号")?.Value ?? 0;
|
||||
if (台架号 >= 1 && 台架号 <= 8)
|
||||
{
|
||||
await _deviceManager.IOGroup.执行台架动作Async(台架号, 功能动作.蜂鸣器报警, false);
|
||||
}
|
||||
// 消音为尽力而为动作:IO 板卡未连接或通信失败时仅记录日志,避免切换页面/点击消音时崩溃
|
||||
LoggerHelper.Error($"[{scope}] 蜂鸣器消音失败:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,9 +136,17 @@ namespace MainModule.ViewModels
|
||||
.FirstOrDefault(x => x.ParameterName == "台架序号")?.Value ?? 0;
|
||||
if (台架号 < 1 || 台架号 > 8) return;
|
||||
|
||||
// 上下限 / 上下极限 均触发蜂鸣器报警
|
||||
await _deviceManager.IOGroup.执行台架动作Async(台架号, 功能动作.蜂鸣器报警, true);
|
||||
LoggerHelper.WarnWithNotify(args.Scope, $"[{args.Scope}] 报警触发: {args.Status} ({args.Fingerprint}),蜂鸣器已开启。");
|
||||
try
|
||||
{
|
||||
// 上下限 / 上下极限 均触发蜂鸣器报警
|
||||
await _deviceManager.IOGroup.执行台架动作Async(台架号, 功能动作.蜂鸣器报警, true);
|
||||
LoggerHelper.WarnWithNotify(args.Scope, $"[{args.Scope}] 报警触发: {args.Status} ({args.Fingerprint}),蜂鸣器已开启。");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// async void 内绝不能抛出异常:蜂鸣器为尽力而为动作,IO 板卡未连接/通信失败时仅记录日志,避免程序崩溃
|
||||
LoggerHelper.Error($"[{args.Scope}] 蜂鸣器报警开启失败:{ex.Message}");
|
||||
}
|
||||
|
||||
// 上下极限额外触发异常流程
|
||||
if (args.Status == "超上极限" || args.Status == "超下极限")
|
||||
@@ -205,7 +222,8 @@ namespace MainModule.ViewModels
|
||||
{
|
||||
if (_alarmToken != null)
|
||||
_eventAggregator.GetEvent<AlarmEvent>().Unsubscribe(_alarmToken);
|
||||
_eventAggregator.GetEvent<SilenceBuzzerEvent>().Unsubscribe(async (scope) => await SilenceBuzzer(scope));
|
||||
if (_silenceToken != null)
|
||||
_eventAggregator.GetEvent<SilenceBuzzerEvent>().Unsubscribe(_silenceToken);
|
||||
// 2. 显式释放硬件资源(防止端口占用/死锁)
|
||||
if (_deviceManager is IDisposable disposableDevice)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user