MOre decoder FIX

This commit is contained in:
Samuele Locatelli
2022-10-24 20:06:27 +02:00
parent 98c7c254b0
commit d3164aea0e
19 changed files with 28 additions and 168 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2210.2418</Version>
<Version>1.2.2210.2420</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2210.2418</h4>
<h4>Version: 1.2.2210.2420</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2210.2418
1.2.2210.2420
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2210.2418</version>
<version>1.2.2210.2420</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
-144
View File
@@ -299,151 +299,7 @@ namespace MP.MONO.DECODER
// loggo controllo
Log.Debug($"Esito controllo | {alarmListReceivedOk.Count} ricevuti | {alarmListAdded.Count} aggiunti | {alarmListCeased.Count} cessati");
#if false
// rileggo da REDIS la conf attuale allarmi già attivi da area ALARM_CURR_KEY
// FIXME TODO !!! usare una lista thread safe?!?!?
List<string> lastAlarms = getAlarms("Current");
List<string> startedAlarms = new List<string>();
List<string> ceasedAlarms = new List<string>();
string serAlarms = "";
// ciclo x ogni allarme ricevuto x vedere se sia INIZIATO o vada filtrato x muted
if (alarmList != null)
{
// ciclo x ogni allarme attivo x verificare se si sia CHIUSO
foreach (var newAlarm in alarmList)
{
var currNewAlarm = newAlarm;
// se ho valori trim pre/post li applica...
if (!string.IsNullOrEmpty(AlarmCleanPre))
{
currNewAlarm = currNewAlarm.Replace(AlarmCleanPre, "");
}
if (!string.IsNullOrEmpty(AlarmCleanPost))
{
currNewAlarm = currNewAlarm.Replace(AlarmCleanPost, "");
}
// se AlarmIgnoreEmpty=true + vuoto --> salto
if (AlarmIgnoreEmpty && string.IsNullOrWhiteSpace(currNewAlarm))
{
alarmList.Remove(currNewAlarm);
alarmList.Remove(newAlarm);
}
else
{
// in primis... se è muted --> lo escludo...
bool isMuted = false;
var maybeMuted = mutedAlarmsList.Where(x => x.FullValue == currNewAlarm).FirstOrDefault();
if (maybeMuted != null)
{
isMuted = maybeMuted.Muted;
}
// cerco l'allarme nell'elenco degli allarmi dal DB
AlarmListModel? foundAlarm = getAlarmModel(currNewAlarm);
if (!isMuted)
{
if (!lastAlarms.Contains(currNewAlarm))
{
if (foundAlarm != null)
{
// segno come iniziato...
AlarmRecModel newAlarmRec = new AlarmRecModel()
{
MachineId = MachineId,
DtStart = adesso,
DtEnd = adesso.AddMinutes(-1),
AlarmId = foundAlarm.AlarmId
};
alarmRecList.Add(newAlarmRec);
startedAlarms.Add(currNewAlarm);
lastAlarms.Add(currNewAlarm);
needsWrite = true;
}
}
}
else
{
// rimuovo da alarmList perché muted...
alarmList.Remove(currNewAlarm);
alarmList.Remove(newAlarm);
}
}
}
}
// salvo
serAlarms = JsonConvert.SerializeObject(lastAlarms);
// invio sulla message pipeline corretta TUTTI gli allarmi serializzati
alarmsSendPipe.saveAndSendMessage(Constants.ALARM_CURR_KEY, serAlarms);
// calcolo allarmi cessati...
if (lastAlarms != null)
{
// ciclo x ogni allarme attivo x verificare se si sia CHIUSO
foreach (var oldData in lastAlarms)
{
bool trovato = false;
if (alarmList != null)
{
trovato = alarmList.Contains(oldData);
}
// se non c'è... segno cessato
if (!trovato)
{
ceasedAlarms.Add(oldData);
await Task.Run(async () =>
{
await checkCeasedAlarm(oldData);
});
}
}
}
Log.Debug($"Stato lastAlarms | count {lastAlarms.Count}");
// gli allarmi cessati avvio un task di verifica dopo periodo di blink
if (needsWrite)
{
Log.Debug($"Preparazione AlarmLogRecord | count {lastAlarms.Count}");
// preparo dati x alarmLog
AlarmLogModel newAlarmLog = new AlarmLogModel()
{
MachineId = MachineId,
DtRif = adesso,
MemAddress = "ND",
Index = 0,
// usare alarmList o lastAlarms
Status = (uint)alarmList.Count,
ValDecoded = alarmList.Count > 0 ? string.Join(", ", alarmList) : "All OK"
};
alarmLogList.Add(newAlarmLog);
}
if (lastAlarms != null)
{
lastAlarms = lastAlarms.OrderBy(x => x).ToList();
// serializzo l'elenco allarmi...
serAlarms = JsonConvert.SerializeObject(lastAlarms);
// se vuoto metto controllo x chiusura
if (lastAlarms.Count() == 0)
{
await Task.Run(async () =>
{
await checkCloseAllAlarm();
});
}
// invio sulla message pipeline corretta TUTTI gli allarmi serializzati
alarmsSendPipe.saveAndSendMessage(Constants.ALARM_CURR_KEY, serAlarms);
Log.Debug($"Salvataggio/invio allarmi | serAlarms | count {lastAlarms.Count}");
}
#endif
// restituisco esito = allarmi ricevuti da registrare
answ = (alarmListAdded.Count > 0);
return answ;
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2210.2418</Version>
<Version>1.2.2210.2420</Version>
</PropertyGroup>
<ItemGroup>
+2 -2
View File
@@ -596,7 +596,7 @@ async void AlarmsValPipe_EA_NewMessage(object? sender, EventArgs e)
// salvo sul DB
if (alarmRecList.Count > 0)
{
_ = dbController.AlarmRecInsertMany(alarmRecList).Result;
_ = dbController.AlarmRecInsertMany(alarmRecList);
}
if (alarmLogList.Count > 0)
{
@@ -677,7 +677,7 @@ async void AlarmsValPipe_EA_NewMessage(object? sender, EventArgs e)
}
}
// salvo sul DB
_ = dbController.AlarmRecInsertMany(alarmRecList).Result;
_ = dbController.AlarmRecInsertMany(alarmRecList);
Log.Debug($"Inseriti {alarmRecList.Count} Records AlarmRecModel");
}
if (ceasedAlarms.Count > 0)
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2210.2418</h4>
<h4>Version: 1.2.2210.2420</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2210.2418
1.2.2210.2420
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2210.2418</version>
<version>1.2.2210.2420</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+10 -6
View File
@@ -527,7 +527,7 @@ namespace MP.MONO.Data.Controllers
/// </summary>
/// <param name="newItems">Lista Record da inserire (senza ID...)</param>
/// <returns></returns>
public async Task<bool> AlarmRecInsertMany(List<AlarmRecModel> newItems)
public bool AlarmRecInsertMany(List<AlarmRecModel> newItems)
{
bool fatto = false;
using (MapoMonoContext localDbCtx = new MapoMonoContext())
@@ -552,24 +552,28 @@ namespace MP.MONO.Data.Controllers
.ToList();
var alarm2rem = listNewId.Intersect(stillOpenAlarms).ToList();
// andrò ad inserire solo gli item NON già presenti...
foreach (var item in alarm2rem)
{
var item2del = newItems.FirstOrDefault(x => x.AlarmId == item);
var item2del = newItems.Where(x => x.AlarmId == item).ToList();
if (item2del != null)
{
newItems.Remove(item2del);
foreach (var singleItem in item2del)
{
newItems.Remove(singleItem);
}
}
}
if (newItems.Count > 0)
{
// aggiungo
await localDbCtx
localDbCtx
.DbSetAlarmRec
.AddRangeAsync(newItems);
.AddRange(newItems);
// salvo!
await localDbCtx.SaveChangesAsync();
localDbCtx.SaveChanges();
fatto = true;
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2210.2418</Version>
<Version>1.2.2210.2420</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2210.2418</h4>
<h4>Version: 1.2.2210.2420</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2210.2418
1.2.2210.2420
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2210.2418</version>
<version>1.2.2210.2420</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.2.2210.2418</Version>
<Version>1.2.2210.2420</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.2.2210.2418</h4>
<h4>Version: 1.2.2210.2420</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2210.2418
1.2.2210.2420
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2210.2418</version>
<version>1.2.2210.2420</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>