check su setObjItems e flogJson --> addCheckTask4Machine x resend PLC
This commit is contained in:
@@ -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
|
||||
|
||||
+75
-58
@@ -819,6 +819,39 @@ namespace MapoDb
|
||||
return mHash($"VetoOdlMacc:{idxMacchina}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica se sia da reinviare un task alla macchina dall'elenco di quelli salvati (in modalità upsert) se non scaduti
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="taskKey"></param>
|
||||
/// <param name="taskVal"></param>
|
||||
/// <returns></returns>
|
||||
public bool addCheckTask4Machine(string idxMacchina, taskType taskKey, string taskVal)
|
||||
{
|
||||
bool answ = false;
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> 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<string, string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge un PARAMETRO OPZIONALE all'elenco di quelli salvati (in modalità upsert)
|
||||
/// </summary>
|
||||
@@ -854,6 +887,7 @@ namespace MapoDb
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
string currSavedParHash = savedTaskHash(idxMacchina);
|
||||
Dictionary<string, string> currTask = new Dictionary<string, string>();
|
||||
Dictionary<string, string> savedTask = new Dictionary<string, string>();
|
||||
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<string, string>();
|
||||
answ = memLayer.ML.redSaveHashDict(currSavedParHash, currTask);
|
||||
savedTask = new Dictionary<string, string>();
|
||||
answ = memLayer.ML.redSaveHashDict(currSavedParHash, savedTask);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1962,6 +1999,28 @@ namespace MapoDb
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> mSavedTaskMacchina(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
|
||||
/// <summary>
|
||||
/// Elenco task ammessi (x IOB-WIN da eseguire...)
|
||||
/// </summary>
|
||||
public enum taskType {
|
||||
/// <summary>
|
||||
/// Task nullo / fake
|
||||
/// </summary>
|
||||
nihil,
|
||||
/// <summary>
|
||||
/// Rimanda a PLC eventuale segnale NON in setup (MA NON RESETTA)
|
||||
/// </summary>
|
||||
fixStopSetup,
|
||||
/// <summary>
|
||||
/// Indica al PLC di forzare il reset del contapezzi
|
||||
/// </summary>
|
||||
forceResetPzCount,
|
||||
/// <summary>
|
||||
/// Indica al PLC di forzare il NUOVO valore di contapezzi (impostato come value)
|
||||
/// </summary>
|
||||
forceSetPzCount,
|
||||
/// <summary>
|
||||
/// Imposta Articolo su PLC
|
||||
/// </summary>
|
||||
setArt,
|
||||
/// <summary>
|
||||
/// Imposta Commessa su PLC
|
||||
/// </summary>
|
||||
setComm,
|
||||
/// <summary>
|
||||
/// Set Programma CNC su PLC
|
||||
/// </summary>
|
||||
setProg,
|
||||
/// <summary>
|
||||
/// Indica al PLC iniziato setup (e secondo casi ferma contapezzi /resetta)
|
||||
/// </summary>
|
||||
startSetup,
|
||||
/// <summary>
|
||||
/// Indica al PLC finito setup (e secondo casi ferma contapezzi /resetta)
|
||||
/// </summary>
|
||||
stopSetup,
|
||||
/// <summary>
|
||||
/// Richiesta invio watchdog a PLC
|
||||
/// </summary>
|
||||
sendWatchDogMes2Plc
|
||||
}
|
||||
public enum tipoSelettore {
|
||||
articoli
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user