Completata review IO x gestione mData + JOBS di EXE TASK
This commit is contained in:
@@ -172,23 +172,29 @@ namespace MP_IO.Controllers
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera STATO corrente x macchina:
|
||||
/// Recupera DATI correnti x macchina:
|
||||
///
|
||||
/// GET: IOB/getCurrStatus/5
|
||||
/// GET: IOB/getCurrData/5
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>jSon contenente la riga di stato macchina</returns>
|
||||
public string getCurrStatus(string id)
|
||||
public string getCurrData(string id)
|
||||
{
|
||||
string answ = "";
|
||||
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
||||
connDb.scriviKeepAlive(id, DateTime.Now);
|
||||
// recupero dati macchina...
|
||||
Dictionary<string, string> valori = DataLayer.mDatiMacchine(id);
|
||||
// cerco il SOLO stato...
|
||||
try
|
||||
{
|
||||
// recupero dati macchina...
|
||||
Dictionary<string, string> valori = DataLayer.mDatiMacchine(id);
|
||||
answ = JsonConvert.SerializeObject(valori);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -202,15 +208,65 @@ namespace MP_IO.Controllers
|
||||
public string getTask2Exe(string id)
|
||||
{
|
||||
string answ = "";
|
||||
//try
|
||||
//{
|
||||
// answ = DataLayer.currODL(id).ToString();
|
||||
//}
|
||||
//catch (Exception exc)
|
||||
//{
|
||||
// logger.lg.scriviLog(string.Format("Errore in currODL (get){0}{1}", Environment.NewLine, exc));
|
||||
// answ = "NO";
|
||||
//}
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
||||
connDb.scriviKeepAlive(id, DateTime.Now);
|
||||
try
|
||||
{
|
||||
// leggo da REDIS eventuale elenco task x macchina...
|
||||
Dictionary<string, string> valori = DataLayer.mTaskMacchina(id);
|
||||
answ = JsonConvert.SerializeObject(valori);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// AGGIUNGE TASK richiesto x macchina:
|
||||
///
|
||||
/// GET: IOB/addTask2Exe/5?taskName=T180326160502&taskVal=setPrg#PRG001
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="taskName"></param>
|
||||
/// <param name="taskVal"></param>
|
||||
public string addTask2Exe(string id, string taskName, string taskVal)
|
||||
{
|
||||
string answ = "";
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
||||
connDb.scriviKeepAlive(id, DateTime.Now);
|
||||
try
|
||||
{
|
||||
DataLayer.addTask4Machine(id, taskName, taskVal);
|
||||
answ = getTask2Exe(id);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// ELIMINA TASK richiesto x macchina:
|
||||
///
|
||||
/// GET: IOB/remTask2Exe/5?taskName=T180326160502
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="taskName"></param>
|
||||
/// <param name="taskVal"></param>
|
||||
public string remTask2Exe(string id, string taskName)
|
||||
{
|
||||
string answ = "";
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
MapoDb.MapoDb connDb = new MapoDb.MapoDb();
|
||||
connDb.scriviKeepAlive(id, DateTime.Now);
|
||||
try
|
||||
{
|
||||
DataLayer.remTask4Machine(id, taskName);
|
||||
answ = getTask2Exe(id);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
+52
-86
@@ -1011,6 +1011,15 @@ namespace MapoDb
|
||||
return mHash(string.Format("DtMac:{0}", idxMacchina));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati EXE TASK x la macchina specificata
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static string exeTaskHash(string idxMacchina)
|
||||
{
|
||||
return mHash(string.Format("ExeTask:{0}", idxMacchina));
|
||||
}
|
||||
/// <summary>
|
||||
/// Hash dati STATUS x la macchina specificata.
|
||||
/// - dati ODL
|
||||
/// - dati articolo
|
||||
@@ -1097,124 +1106,81 @@ namespace MapoDb
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione status macchina (ODL, produzione...)
|
||||
#region gestione task macchina
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi StatoMacchine + ODL per l'impianto indicato
|
||||
/// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> mStatusMacchine(string idxMacchina)
|
||||
public static Dictionary<string, string> mTaskMacchina(string idxMacchina)
|
||||
{
|
||||
// hard coded dimensione vettore DatiMacchine
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
// ORA recupero da memoria redis...
|
||||
try
|
||||
{
|
||||
string currHash = stMaccHash(idxMacchina);
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
answ = memLayer.ML.redGetHashDict(currHash);
|
||||
// se è vuoto... leggo da DB e popolo!
|
||||
if (answ.Count == 0)
|
||||
{
|
||||
answ = resetStatusMacchina(idxMacchina);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in compilazione datiSTATUS Macchina x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
|
||||
logger.lg.scriviLog(string.Format("Errore in compilazione dati EXE TASK x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiunge un task all'elenco di quelli salvati (in modalità upsert)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="taskKey"></param>
|
||||
/// <param name="taskVal"></param>
|
||||
/// <returns></returns>
|
||||
public static bool addTask4Machine(string idxMacchina, string taskKey, string taskVal)
|
||||
{
|
||||
bool answ = false;
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
try
|
||||
{
|
||||
// leggo task attuali...
|
||||
var currTask = mTaskMacchina(idxMacchina);
|
||||
currTask[taskKey] = taskVal;
|
||||
answ = memLayer.ML.redSaveHashDict(currHash, currTask);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resetta (rileggendo) i dati StatoMacchine + ODL della macchina
|
||||
/// Aggiunge un task all'elenco di quelli salvati (in modalità upsert)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="taskKey"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> resetStatusMacchina(string idxMacchina)
|
||||
public static bool remTask4Machine(string idxMacchina, string taskKey)
|
||||
{
|
||||
string currHash = stMaccHash(idxMacchina);
|
||||
// inizio con un bel reset...
|
||||
memLayer.ML.redFlushKey(currHash);
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
#if false
|
||||
DS_applicazione.MSFDDataTable tabMSFD = new DS_applicazione.MSFDDataTable();
|
||||
// 2017.09.13: inserisco gestione singleton condizionale
|
||||
if (memLayer.ML.CRB("disable_singleton"))
|
||||
{
|
||||
// instanzio un nuovo oggetto MapoDb
|
||||
MapoDb connDb = new MapoDb();
|
||||
tabMSFD = connDb.taMSFD.getByIdxMacc(idxMacchina);
|
||||
}
|
||||
else
|
||||
{
|
||||
tabMSFD = MapoDb.obj.taMSFD.getByIdxMacc(idxMacchina);
|
||||
}
|
||||
// se ho righe...
|
||||
DS_applicazione.MSFDDataTable tab = new DS_applicazione.MSFDDataTable();
|
||||
DS_applicazione.MSFDRow rigaMSFD;
|
||||
if (tabMSFD.Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
rigaMSFD = tabMSFD[0];
|
||||
}
|
||||
catch
|
||||
{
|
||||
rigaMSFD = tab.NewMSFDRow();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaMSFD = tab.NewMSFDRow();
|
||||
}
|
||||
// ora provo a compilare...
|
||||
bool answ = false;
|
||||
string currHash = exeTaskHash(idxMacchina);
|
||||
try
|
||||
{
|
||||
// salvo 1:1 i valori... STATO
|
||||
answ.Add("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString());
|
||||
answ.Add("IdxStato", rigaMSFD.IdxStato.ToString());
|
||||
answ.Add("CodArticolo", rigaMSFD.CodArticolo);
|
||||
answ.Add("insEnabled", rigaMSFD.insEnabled.ToString());
|
||||
answ.Add("sLogEnabled", rigaMSFD.sLogEnabled.ToString());
|
||||
answ.Add("pallet", rigaMSFD.pallet);
|
||||
answ.Add("CodArticolo_A", rigaMSFD.CodArticolo_A);
|
||||
answ.Add("CodArticolo_B", rigaMSFD.CodArticolo_B);
|
||||
answ.Add("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
answ.Add("PzPalletProd", rigaMSFD.PzPalletProd.ToString());
|
||||
answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString());
|
||||
answ.Add("lastVal", rigaMSFD.lastVal);
|
||||
answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
|
||||
//...e SETUP
|
||||
answ.Add("CodMacc", rigaMSFD.codmacchina);
|
||||
answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString());
|
||||
answ.Add("Multi", rigaMSFD.Multi.ToString());
|
||||
answ.Add("BitFilt", rigaMSFD.BitFilt.ToString());
|
||||
answ.Add("MaxVal", rigaMSFD.MaxVal.ToString());
|
||||
answ.Add("BSR", rigaMSFD.BSR.ToString());
|
||||
answ.Add("ExplodeBit", rigaMSFD.ExplodeBit.ToString());
|
||||
answ.Add("NumBit", rigaMSFD.NumBit.ToString());
|
||||
answ.Add("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString());
|
||||
answ.Add("simplePallet", rigaMSFD.simplePallet.ToString());
|
||||
answ.Add("palletChange", rigaMSFD.palletChange.ToString());
|
||||
// leggo task attuali...
|
||||
var currTask = mTaskMacchina(idxMacchina);
|
||||
currTask.Remove(taskKey);
|
||||
memLayer.ML.redDelKey(currHash);
|
||||
answ = memLayer.ML.redSaveHashDict(currHash, currTask);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore in compilazione dati MSFD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
#endif
|
||||
// verifico il timeout che cambia a seconda che sia vero o falso insEnabled...
|
||||
int tOutShort = memLayer.ML.cdvi("TmOut.MS.S");
|
||||
int tOutLong = memLayer.ML.cdvi("TmOut.MS.L");
|
||||
int redDtMacTOut = (answ["insEnabled"].ToLower() == "true") ? tOutShort : tOutLong;
|
||||
// salvo in redis!
|
||||
memLayer.ML.redSaveHashDict(currHash, answ, redDtMacTOut);
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione dati macchina
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user