a3366188fc
- OK reset - OK ricerca
98 lines
2.9 KiB
C#
98 lines
2.9 KiB
C#
using Microsoft.JSInterop;
|
|
using MP.MONO.Core.CONF;
|
|
|
|
namespace MP.MONO.UI.Components
|
|
{
|
|
public partial class AlarmsSetupBankBit
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected List<BaseAlarmBankConf>? ListRecords = null;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected BaseAlarmBankConf? AlarmMap { get; set; } = null;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string cssActive(string memAddr)
|
|
{
|
|
string answ = "";
|
|
if (AlarmMap != null)
|
|
{
|
|
answ = AlarmMap.memAddr.Equals(memAddr) ? "bg-dark text-light" : "";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected string cssSilenced(int messIndex)
|
|
{
|
|
string answ = "";
|
|
if (AlarmMap != null)
|
|
{
|
|
answ = AlarmMap.isSilenced(messIndex) ? "bg-secondary text-light" : "bg-primary text-light";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task raiseSelect(BaseAlarmBankConf selBank)
|
|
{
|
|
AlarmMap = selBank;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
ListRecords = null;
|
|
await Task.Delay(1);
|
|
ListRecords = await MMDataService.getAlarmBankBitSetup();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task resetAlarmSetup()
|
|
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Reset Alarm Config: you are going to reset actual alarm configuration. Are you sure to proceed?"))
|
|
return;
|
|
await Task.Delay(1);
|
|
var baseConf = await MMDataService.getAlarmBBConfig();
|
|
await MMDataService.setAlarmSetupBankBit(baseConf);
|
|
AlarmMap = null;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task toggleMute(int alarmIndex)
|
|
{
|
|
// base 1 --> base 0
|
|
alarmIndex--;
|
|
int bank = alarmIndex / 16;
|
|
// calcolo inverso del valore richiesto
|
|
if (ListRecords != null && AlarmMap != null)
|
|
{
|
|
AlarmMap.silenceMask[bank] = AlarmMap.silenceMask[bank] ^ (uint)(1 << alarmIndex);
|
|
// sostituisco...
|
|
var currObj = ListRecords.FirstOrDefault(x => x.memAddr == AlarmMap.memAddr);
|
|
if (currObj != null)
|
|
{
|
|
currObj.silenceMask = AlarmMap.silenceMask;
|
|
// salvo su redis...
|
|
await MMDataService.setAlarmSetupBankBit(ListRecords);
|
|
}
|
|
}
|
|
await Task.Delay(1);
|
|
await ReloadData();
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |