diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index a33f0b8f..31ae48ea 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -133,7 +133,7 @@ namespace MP_IO.Controllers return answ; } /// - /// Processa una chiamata POST per l'invio di un array jSon di oggetti fluxLog + /// Processa una chiamata POST per l'invio di un array Json di oggetti fluxLog /// PUT: IOB/flogJson/SIMUL_03 /// /// ID dell'IOB @@ -169,7 +169,7 @@ namespace MP_IO.Controllers return answ; } /// - /// Processa una chiamata POST per l'invio di un array jSon di oggetti LIVE REC + /// Processa una chiamata POST per l'invio di un array Json di oggetti LIVE REC /// PUT: IOB/liveJson/SIMUL_03 /// /// ID dell'IOB @@ -285,7 +285,7 @@ namespace MP_IO.Controllers return answ; } /// - /// Processa una chiamata POST per l'invio di un array jSon di oggetti plcMemConf + /// Processa una chiamata POST per l'invio di un array Json di oggetti plcMemConf /// PUT: IOB/flogJson/SIMUL_03 /// /// ID dell'IOB @@ -327,6 +327,88 @@ namespace MP_IO.Controllers } return answ; } + /// + /// restituisce elenco parametri correnti come una List Json di oggetti parameterConf + /// PUT: IOB/getCurrParam/SIMUL_03 + /// + /// ID dell'IOB + /// + [HttpPost] + public string getCurrParams(string id) + { + string answ = ""; + if (string.IsNullOrWhiteSpace(id)) + { + answ = "Missing IOB"; + } + else + { + // procedo a recuperare l'oggetto... + List currParams = new List(); + try + { + // deserializzo. + currParams = DataLayer.getIobCurrParams(id); + // se != null --> salvo! + if (currParams != null) + { + answ = JsonConvert.SerializeObject(currParams); + } + } + catch(Exception exc) + { + logger.lg.scriviLog($"Errore in getCurrParams{Environment.NewLine}{exc}"); + answ = "NO"; + } + } + return answ; + } + /// + /// Processa una chiamata POST per l'invio di una List Json di oggetti parameterConf + /// PUT: IOB/setCurrParam/SIMUL_03 + /// + /// ID dell'IOB + /// + [HttpPost] + public string setCurrParams(string id) + { + string answ = ""; + if (string.IsNullOrWhiteSpace(id)) + { + answ = "Missing IOB"; + } + else + { + // questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo... + string content = ""; + System.Web.HttpContext.Current.Request.InputStream.Position = 0; + using (var reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true)) + { + content = reader.ReadToEnd(); + } + //Rest + System.Web.HttpContext.Current.Request.InputStream.Position = 0; + // procedo a deserializzare in blocco l'oggetto... + List< parameterConf> currParams = new List(); + try + { + // deserializzo. + currParams = JsonConvert.DeserializeObject>(content); + // se != null --> salvo! + if (currParams != null) + { + DataLayer.setIobCurrParams(id, currParams); + answ = "OK"; + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Errore in setCurrParams{Environment.NewLine}{exc}"); + answ = "NO"; + } + } + return answ; + } // GET: IOB/liveRec/SIMUL_03?&liveData=chiave1|valore1#chiave2|valore#|chiave3|valore3 public string liveRec(string id, string liveData) @@ -489,7 +571,7 @@ namespace MP_IO.Controllers /// /// /// - /// jSon contenente la riga di stato macchina + /// Json contenente la riga di stato macchina public string getCurrData(string id) { // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#" @@ -515,7 +597,7 @@ namespace MP_IO.Controllers /// /// /// - /// jSon contenente la riga di stato macchina + /// Json contenente la riga di stato macchina public string forceSplitOdl(string id) { // attenzione! poiché nell'URL il carattere "#" fiene filtrato ci aspettiamo il carattere "|" che poi trasformiamo ora in "#" @@ -530,7 +612,7 @@ namespace MP_IO.Controllers /// /// /// - /// jSon contenente 1..n task da eseguire + /// Json contenente 1..n task da eseguire public string getTask2Exe(string id) { string answ = ""; @@ -625,7 +707,7 @@ namespace MP_IO.Controllers /// /// /// - /// jSon contenente 1..n task da eseguire + /// Json contenente 1..n task da eseguire public string getOptPar(string id) { string answ = ""; @@ -837,7 +919,7 @@ namespace MP_IO.Controllers string dataSer = memLayer.ML.getRSV(hM2IOB); if (dataSer != "" && dataSer != null) { - // restituisco jSon + // restituisco Json answ = dataSer; } else diff --git a/MP-TAB/WebUserControls/mod_sendParameters.ascx b/MP-TAB/WebUserControls/mod_sendParameters.ascx index ffaf62ab..1e82e001 100644 --- a/MP-TAB/WebUserControls/mod_sendParameters.ascx +++ b/MP-TAB/WebUserControls/mod_sendParameters.ascx @@ -4,7 +4,14 @@
+
+

GESTIONE PARAMETRI MACCHINA

+
+
+ +
+
Elenco parametri di configurazione ammessi per l'impianto diff --git a/MP-TAB/WebUserControls/mod_sendParameters.ascx.cs b/MP-TAB/WebUserControls/mod_sendParameters.ascx.cs index b9e520c9..40981fa8 100644 --- a/MP-TAB/WebUserControls/mod_sendParameters.ascx.cs +++ b/MP-TAB/WebUserControls/mod_sendParameters.ascx.cs @@ -1,4 +1,6 @@ -using MapoSDK; +using MapoDb; +using MapoSDK; +using SteamWare; using System; using System.Collections; using System.Collections.Generic; @@ -15,35 +17,54 @@ namespace MoonProTablet.WebUserControls { } - public static List GetParameters() + /// + /// idx macchina selezionata + /// + public string idxMacchina { - //!!!FIXME !!!FARE recuperare VERI DATI da memoria REDIS dell'IOB... - - List dcList = new List(); - plcMemMap memoria = new plcMemMap(); - - for (int i = 0; i < 10; i++) + get { - - parameterConf currPar = new parameterConf() - { - name = $"Par_{i}", - description = $"Parametro {i}", - value = $"{i * 100}", - newValue = $"{i * 100 + 5}" - }; - dcList.Add(currPar); -#if false - memoria.mMapWrite.Add($"Parametro {i}", currConf); -#endif + return memLayer.ML.StringSessionObj("IdxMacchina"); } -#if false - foreach (var item in memoria.mMapWrite) + set { - dcList.Add(item.Value); - } -#endif - return dcList;// memoria.mMapWrite; + memLayer.ML.setSessionVal("IdxMacchina", value); + } + } + public List GetParameters() + { + bool fatto = false; + //!!!FIXME !!!FARE recuperare VERI DATI da memoria REDIS dell'IOB... + List dcList = new List(); + try + { + dcList = DataLayer.getIobCurrParams(idxMacchina); + fatto = true; + } + catch + { + } + if (!fatto || dcList.Count == 0) + { + plcMemMap memoria = new plcMemMap(); + for (int i = 0; i < 10; i++) + { + parameterConf currPar = new parameterConf() + { + name = $"Par_{i}", + description = $"Parametro {i}", + value = $"{i * 100}", + newValue = $"{i * 100 + DateTime.Now.Second}" + }; + dcList.Add(currPar); + } + } + return dcList;// memoria.mMapWrite; + } + + protected void lbtReload_Click(object sender, EventArgs e) + { + grView.DataBind(); } } } \ No newline at end of file diff --git a/MP-TAB/WebUserControls/mod_sendParameters.ascx.designer.cs b/MP-TAB/WebUserControls/mod_sendParameters.ascx.designer.cs index 18615f7e..70c9b206 100644 --- a/MP-TAB/WebUserControls/mod_sendParameters.ascx.designer.cs +++ b/MP-TAB/WebUserControls/mod_sendParameters.ascx.designer.cs @@ -14,6 +14,15 @@ namespace MoonProTablet.WebUserControls public partial class mod_sendParameters { + /// + /// Controllo lbtReload. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtReload; + /// /// Controllo grView. /// diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index 47775467..162d3241 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -1014,13 +1014,51 @@ namespace MapoDb // se ho un area memoria valida... if (currMemMap != null) { - // salvo!ve + // salvo! string serVal = JsonConvert.SerializeObject(currMemMap); memLayer.ML.setRSV(memMapHash(idxMacchina), serVal); } return answ; } /// + /// GET elenco parametri correnti x IOB + /// + /// + /// + public static List getIobCurrParams(string idxMacchina) + { + string serVal = memLayer.ML.getRSV(currParametersHash(idxMacchina)); + List currParameters = new List(); + if(serVal != null) + { + try + { + currParameters = JsonConvert.DeserializeObject>(serVal); + } + catch(Exception exc) + { + logger.lg.scriviLog($"Eccezione in deserializzazione getIobCurrParam{Environment.NewLine}{exc}"); + } + } + return currParameters; + } + /// + /// SET elenco parametri correnti x IOB + /// + /// + /// + /// + public static bool setIobCurrParams(string idxMacchina, List currParameters) + { + bool answ = false; + if(currParameters!=null) + { + string serVal = JsonConvert.SerializeObject(currParameters); + memLayer.ML.setRSV(currParametersHash(idxMacchina), serVal); + } + return answ; + } + /// /// Rimuove Key dell'ODL corrente x una data macchina IOB /// /// @@ -1151,6 +1189,15 @@ namespace MapoDb return mHash(string.Format("MemMap:{0}", idxMacchina)); } /// + /// Hash dati CurrentParameters x la macchina specificata + /// + /// + /// + public static string currParametersHash(string idxMacchina) + { + return mHash(string.Format("CurrentParameters:{0}", idxMacchina)); + } + /// /// Hash dati Current ODL x la macchina specificata /// /// diff --git a/MapoSDK/Objects.cs b/MapoSDK/Objects.cs index 37cecbbd..0a994c53 100644 --- a/MapoSDK/Objects.cs +++ b/MapoSDK/Objects.cs @@ -114,7 +114,7 @@ namespace MapoSDK /// public int factor { get; set; } = 1; /// - /// Valore parametro (come stringa, decimali con ",", default VUORO) + /// Valore parametro (come stringa, decimali con ",", default VUOTO), poi LETTO da PLC (o appena scritto) /// public string value { get; set; } = ""; /// @@ -129,10 +129,36 @@ namespace MapoSDK /// /// Classe estesa dei parametri da impostare sul PLC /// - public class parameterConf: dataConf + public class parameterConf : dataConf { - public string newValue { get; set; } = "ND"; + /// + /// Indica il NUOVO valore inviato che si richiede di impostare (da IOB/tablet), quando scritto su PLC corrisponde a value + /// + public string newValue { get; set; } = ""; + /// + /// Indica se il parametro sia impostabile (da tablet / IOB) + /// + public bool setEnabled { get; set; } = false; + /// + /// Indica se il parametro sia stato salvato (value = newValue) oppure newValue NON impostato + /// + public bool saved + { + get + { + bool hasData = !string.IsNullOrWhiteSpace(value); + bool areEqual = value == newValue; + bool noWriteReq = string.IsNullOrWhiteSpace(newValue); + return (areEqual || (hasData && noWriteReq)); + } + } + /// + /// Ultimo messaggio associato (conferma scrittura, errore, ...) + /// + public string lastMessage { get; set; } = ""; } + + /// /// Struttura conf tipo dati ///