diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs
index 062413e3..35838081 100644
--- a/MP-IO/Controllers/IOBController.cs
+++ b/MP-IO/Controllers/IOBController.cs
@@ -280,6 +280,12 @@ namespace MP_IO.Controllers
// aggiorno valore e data
trovato.value = item.valore;
trovato.lastRead = DateTime.Now;
+ // se fosse un valore WRITE e mi ha dato un valore vuoto --> mando un fix x riscrittura
+ if (trovato.writable && string.IsNullOrEmpty(item.valore))
+ {
+ taskType currTask = (taskType)Enum.Parse(typeof(taskType), trovato.uid);
+ DataLayerObj.addCheckTask4Machine(id, currTask, item.valore);
+ }
}
// altrimenti AGGIUNGO (READ ONLY)...
else
diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs
index 79c26bd4..0983af42 100644
--- a/MapoDb/DataLayer.cs
+++ b/MapoDb/DataLayer.cs
@@ -819,6 +819,39 @@ namespace MapoDb
return mHash($"VetoOdlMacc:{idxMacchina}");
}
+ ///
+ /// verifica se sia da reinviare un task alla macchina dall'elenco di quelli salvati (in modalità upsert) se non scaduti
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool addCheckTask4Machine(string idxMacchina, taskType taskKey, string taskVal)
+ {
+ bool answ = false;
+ string currHash = exeTaskHash(idxMacchina);
+ try
+ {
+ Dictionary savedTask = mSavedTaskMacchina(idxMacchina);
+ // cerco valore saved
+ string savedVal = savedTask[taskKey.ToString()];
+ // se ho un valore != "" --> rimetto in coda di invio...
+ if (!string.IsNullOrEmpty(savedVal))
+ {
+ // leggo task attuali...
+ Dictionary currTask = mTaskMacchina(idxMacchina);
+ // rimetto in task da eseguire...
+ currTask[taskKey.ToString()] = savedVal;
+ answ = memLayer.ML.redSaveHashDict(currHash, currTask);
+ }
+ }
+ catch
+ { }
+ // chiamo update come task di scrittura
+
+ return answ;
+ }
+
///
/// Aggiunge un PARAMETRO OPZIONALE all'elenco di quelli salvati (in modalità upsert)
///
@@ -854,6 +887,7 @@ namespace MapoDb
string currHash = exeTaskHash(idxMacchina);
string currSavedParHash = savedTaskHash(idxMacchina);
Dictionary currTask = new Dictionary();
+ Dictionary savedTask = new Dictionary();
try
{
// leggo task attuali...
@@ -870,13 +904,16 @@ namespace MapoDb
case taskType.setComm:
case taskType.setPzComm:
case taskType.setProg:
- answ = memLayer.ML.redSaveHashDict(currSavedParHash, currTask);
+ // leggo task SALVATI attuali...
+ savedTask = mSavedTaskMacchina(idxMacchina);
+ savedTask[taskKey.ToString()] = taskVal;
+ answ = memLayer.ML.redSaveHashDict(currSavedParHash, savedTask);
break;
case taskType.endProd:
// salvo un DICT vuoto x resettare
- currTask = new Dictionary();
- answ = memLayer.ML.redSaveHashDict(currSavedParHash, currTask);
+ savedTask = new Dictionary();
+ answ = memLayer.ML.redSaveHashDict(currSavedParHash, savedTask);
break;
default:
@@ -1962,6 +1999,28 @@ namespace MapoDb
return answ;
}
+ ///
+ /// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato
+ ///
+ ///
+ ///
+ public Dictionary mSavedTaskMacchina(string idxMacchina)
+ {
+ // hard coded dimensione vettore DatiMacchine
+ Dictionary answ = new Dictionary();
+ // ORA recupero da memoria redis...
+ try
+ {
+ string currHash = savedTaskHash(idxMacchina);
+ answ = memLayer.ML.redGetHashDict(currHash);
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog(string.Format("Errore in recupero dati SAVED TASK x Redis mSavedTaskMacchina - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
+ }
+ return answ;
+ }
+
///
/// Restitusice elenco KVP
/// key: IdxMacchina
@@ -2041,7 +2100,7 @@ namespace MapoDb
}
catch (Exception exc)
{
- logger.lg.scriviLog(string.Format("Errore in compilazione dati EXE TASK x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
+ logger.lg.scriviLog(string.Format("Errore in recupero dati EXE TASK x Redis mTaskMacchina - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
}
return answ;
}
@@ -3364,6 +3423,17 @@ namespace MapoDb
{
string serVal = JsonConvert.SerializeObject(currValues);
memLayer.ML.setRSV(currParametersHash(idxMacchina), serVal);
+
+ // controllo se ha valori write...
+ foreach (var item in currValues)
+ {
+ // se fosse un valore WRITE e mi ha dato un valore vuoto --> mando un fix x riscrittura
+ if (item.writable && string.IsNullOrEmpty(item.value))
+ {
+ taskType currTask = (taskType)Enum.Parse(typeof(taskType), item.uid);
+ addCheckTask4Machine(idxMacchina, currTask, item.value);
+ }
+ }
}
return answ;
}
@@ -3498,57 +3568,4 @@ namespace MapoDb
#endregion Public Methods
}
-}
-
-#if false
-
-///
-/// Elenco task ammessi (x IOB-WIN da eseguire...)
-///
-public enum taskType {
- ///
- /// Task nullo / fake
- ///
- nihil,
- ///
- /// Rimanda a PLC eventuale segnale NON in setup (MA NON RESETTA)
- ///
- fixStopSetup,
- ///
- /// Indica al PLC di forzare il reset del contapezzi
- ///
- forceResetPzCount,
- ///
- /// Indica al PLC di forzare il NUOVO valore di contapezzi (impostato come value)
- ///
- forceSetPzCount,
- ///
- /// Imposta Articolo su PLC
- ///
- setArt,
- ///
- /// Imposta Commessa su PLC
- ///
- setComm,
- ///
- /// Set Programma CNC su PLC
- ///
- setProg,
- ///
- /// Indica al PLC iniziato setup (e secondo casi ferma contapezzi /resetta)
- ///
- startSetup,
- ///
- /// Indica al PLC finito setup (e secondo casi ferma contapezzi /resetta)
- ///
- stopSetup,
- ///
- /// Richiesta invio watchdog a PLC
- ///
- sendWatchDogMes2Plc
-}
-public enum tipoSelettore {
- articoli
-}
-
-#endif
\ No newline at end of file
+}
\ No newline at end of file