OK mute/unmute via redis
This commit is contained in:
@@ -66,12 +66,10 @@ namespace MP.MONO.Core.CONF
|
||||
/// </summary>
|
||||
public List<string> messages { get; set; } = new List<string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary calcolato allarmi
|
||||
/// </summary>
|
||||
public Dictionary<int, string> messagesMap { get; set; } = new Dictionary<int, string>();
|
||||
#if false
|
||||
public Dictionary<int, string> messagesMap //{ get; set; } = new Dictionary<int, string>();
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -85,8 +83,22 @@ namespace MP.MONO.Core.CONF
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public bool isSilenced(int messIndex)
|
||||
{
|
||||
//decremento: è base 1 mi serve base 0...
|
||||
messIndex--;
|
||||
bool answ = false;
|
||||
int bank = (messIndex) / 16;
|
||||
if (silenceMask != null && silenceMask.Length >= bank)
|
||||
{
|
||||
var testVal = 1 << messIndex;
|
||||
answ = !((silenceMask[bank] & testVal) == testVal);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Size in byte
|
||||
/// </summary>
|
||||
@@ -223,6 +235,7 @@ namespace MP.MONO.Core.CONF
|
||||
idx = 0;
|
||||
}
|
||||
}
|
||||
#if false
|
||||
// sistemo messaggi come dizionario...
|
||||
Dictionary<int, string> map = new Dictionary<int, string>();
|
||||
if (messages != null)
|
||||
@@ -232,7 +245,8 @@ namespace MP.MONO.Core.CONF
|
||||
map.Add(map.Count + 1, item);
|
||||
}
|
||||
}
|
||||
messagesMap = map;
|
||||
messagesMap = map;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
@inject CurrentDataService MMDataService
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h3>Alarm List</h3>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
@@ -16,7 +13,7 @@
|
||||
}
|
||||
else if (ListRecords.Count == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">No record found</div>
|
||||
<div class="alert alert-warning text-center h3">No record found</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -24,7 +21,7 @@
|
||||
<ul class="list-group">
|
||||
@foreach (var item in ListRecords)
|
||||
{
|
||||
<li class="list-group-item list-group-item-action" @onclick="() => raiseSelect(item.messagesMap)">
|
||||
<li class="list-group-item list-group-item-action @cssActive(item.memAddr)" @onclick="() => raiseSelect(item)">
|
||||
@item.description
|
||||
</li>
|
||||
}
|
||||
@@ -32,23 +29,22 @@
|
||||
}
|
||||
</div>
|
||||
<div class="col-9">
|
||||
@if (AlarmMap == null || AlarmMap.Count == 0)
|
||||
@if (AlarmMap == null)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Select Bank First</div>
|
||||
<div class="alert alert-warning text-center h3">Select Bank First</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ul class="list-group">
|
||||
@foreach (var item in AlarmMap)
|
||||
@foreach (var item in AlarmMap.messagesMap)
|
||||
{
|
||||
<li class="list-group-item list-group-item-action" @onclick="() => toggleMute(item.Key)">
|
||||
<li class="list-group-item list-group-item-action @cssSilenced(item.Key)" @onclick="() => toggleMute(item.Key)">
|
||||
<div>@item.Value</div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
<b>dettaglio allarmi</b>
|
||||
<i>click to mute(unmute alarms</i>
|
||||
<i>click to mute/unmute alarms</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,32 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.MONO.UI;
|
||||
using MP.MONO.UI.Shared;
|
||||
using MP.MONO.UI.Components;
|
||||
using MP.MONO.Core.CONF;
|
||||
|
||||
namespace MP.MONO.UI.Components
|
||||
{
|
||||
public partial class AlarmsSetup
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected List<BaseAlarmConf>? ListRecords = null;
|
||||
protected Dictionary<int, string>? AlarmMap { get; set; } = null;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected BaseAlarmConf? 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) ? "text-secondary" : "text-dark";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task raiseSelect(BaseAlarmConf selBank)
|
||||
{
|
||||
AlarmMap = selBank;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
ListRecords = null;
|
||||
@@ -35,15 +56,29 @@ namespace MP.MONO.UI.Components
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected async Task raiseSelect(Dictionary<int, string> selMap)
|
||||
protected async Task toggleMute(int alarmIndex)
|
||||
{
|
||||
AlarmMap = selMap;
|
||||
// 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.setAlarmSetup(ListRecords);
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
await ReloadData();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected async Task toggleMute(int alarmIndex)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
}
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -16,21 +16,17 @@ namespace MP.MONO.UI.Components
|
||||
#region Private Methods
|
||||
|
||||
[Parameter]
|
||||
public List<string> SelVal { get; set; } = new List<string>();
|
||||
|
||||
|
||||
public List<string> SelVal { get; set; } = new List<string>();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> EC_SelValue { get; set; }
|
||||
|
||||
protected string cssActive(string ParamName)
|
||||
{
|
||||
string answ = SelVal.Contains(ParamName) ? "bg-dark text-light": "";
|
||||
string answ = SelVal.Contains(ParamName) ? "bg-dark text-light" : "";
|
||||
return answ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ParametersPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
@@ -80,10 +76,10 @@ namespace MP.MONO.UI.Components
|
||||
{
|
||||
SelVal.Add(SelectedValue);
|
||||
}
|
||||
|
||||
|
||||
EC_SelValue.InvokeAsync(SelectedValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -155,6 +155,15 @@ namespace MP.MONO.UI.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> setAlarmSetup(List<BaseAlarmConf> alarmConf)
|
||||
{
|
||||
bool answ = false;
|
||||
string cacheKey = Constants.ALARMS_CONF_KEY;
|
||||
string rawData = JsonConvert.SerializeObject(alarmConf);
|
||||
await redisDb.StringSetAsync(cacheKey, rawData);
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public async Task<List<DisplayDataDTO>> getEventHist()
|
||||
{
|
||||
List<DisplayDataDTO>? dbResult = new List<DisplayDataDTO>();
|
||||
|
||||
Reference in New Issue
Block a user