From 3c12952284fd73fc047380591e4e1a5a8cc34b9a Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 27 Apr 2016 11:58:35 +0200 Subject: [PATCH] completato gestione edit conf e caricamento istanza (x demo) --- MTC_Sim/.vs/MTC_Sim/v14/.suo | Bin 131072 -> 132608 bytes MTC_Sim/MTC_Sim/AdapterConf.cs | 363 +++++++++++++-------------- MTC_Sim/MTC_Sim/AdapterConf/Demo.xml | 22 ++ MTC_Sim/MTC_Sim/SetupAdapter.cs | 45 ++++ 4 files changed, 248 insertions(+), 182 deletions(-) diff --git a/MTC_Sim/.vs/MTC_Sim/v14/.suo b/MTC_Sim/.vs/MTC_Sim/v14/.suo index a21faecdcdd1503465b024809cc63b5f068d165e..c694fd48646ad5961cb0d986e83bb8a42b7e3a0f 100644 GIT binary patch delta 2844 zcmeH}drZ?;6vuzxw$f566k$FPkvf>-0})Wkaas_ZW9HeLXEgEerAg? z69sxVu5r^SIyRHd2fwAi8JDdji^fNE=;rpv;s766vMtU<66b^N+(O;vOqOhM*&n;j zr{|t?PtQH~+()V?CZ)mDloT%onpKh#sIMpbd_JErgP24VvwX+0BUO2D>&io|7Y)PL z?CHdE8c^(PqwY4snM+@fuUM}>1wNKw$O=9}gA~MfSalkV2);+%5;ARPn+AO!n#2a3 zSxph1ct`|e3i?=rDJ!^@21gKknbY*RKfqYhTGU;pmodpmnVE=S!c2q^7Gf|FN`w(s zLM)_DwV98h-EtF_5{j@kh`y+~&BOmr7;B9V7ny5FJ-%kW^j)mFBI<)sqV|qBX0Uuf zfe#Xg2=;MIv_&NF5h+5lD=|s)kCSqOI76HyP7$XG;c#|9o+J4=(Mg;qE)ZW3{?&*T z4WO2cj)cf2)}IZ1Q#Q8KMme9H7ZC+SA@K~cm{>wAC7vaUh(Mr#6k96#s*;d|e|<3% z-T=O2y%T-tX1$XNtZz~_l#IWLtk}}TxcEI}v=LFnK4L%d4$(%uOT0(iV|x>;g9DZB z5{I|B%4G1zcx`fO_;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{=6pOT|JT?1u|HqAc{v>q_7D=-Cq=yu}Ak8o6K^Xq&JqV8PIAd?U^e6 zva(Fe(%90aLFRjH6sz!EWS{L$(+?dll><39V!E7Tk$IC8@e1q3`xJXM>s?Luu_NA; zd(M)(|M0NO-e>J%@J;fbC&b}k-uYU(aQ;Y!5aB1{79o5>22p-5LqaVLnJW$oh3I_7 zrK^h!1PX7&gb6W!(OOpeR5JVSd0Sv#9LrvurcbFm>Ix=94iwk-O12hE-gJPei|pYO zsTgkwlr;2e*uEyA)hKP-X6@Cf%-fh3cE`ctV8*KVmpkeFz9^rEtmIRgP%bC__AW*EEa>FPx6)GH*YGWNtiy zSi8AN3P3%kJmE|Z- zI6+Aj*I$Bkjvr~jR=#p3;(6OD*mz_)GI>!Qw(%Lwn83fN!C6u5;<>ZY$=_LwqHs|F zCoQ28WXu0oO@xNCF+4nc1+I{&l~{%UMxi);&T`w~wgbO$Q + /// This Configuration class is basically just a set of + /// properties with a couple of static methods to manage + /// the serialization to and deserialization from a + /// simple XML file. + /// + /// ref: http://www.cambiaresearch.com/articles/33/how-can-i-easily-manage-an-xml-configuration-file-in-dotnet + /// + [Serializable] + public class AdapterConf + { + string sNomeAdapt; + int nVers; + public tipoAdapter etipoAdapt; - #region -- AdapterConf Class -- - /// - /// This Configuration class is basically just a set of - /// properties with a couple of static methods to manage - /// the serialization to and deserialization from a - /// simple XML file. - /// - /// ref: http://www.cambiaresearch.com/articles/33/how-can-i-easily-manage-an-xml-configuration-file-in-dotnet - /// - [Serializable] - public class AdapterConf - { - string sNomeAdapt; - int nVers; - public tipoAdapter etipoAdapt; + element[] _VacuumPump; + element[] _VacuumAct; + element[] _Lubro; + element[] _Cooler; + element[] _Press; + element[] _Temp; + element[] _Path; + element[] _UnOp; + element[] _Axis; - element[] _VacuumPump; - element[] _VacuumAct; - element[] _Lubro; - element[] _Cooler; - element[] _Press; - element[] _Temp; - element[] _Path; - element[] _UnOp; - element[] _Axis; - - /// - /// init conf adapter - /// - public AdapterConf() - { - sNomeAdapt = ""; - etipoAdapt = tipoAdapter.Demo; + /// + /// init conf adapter + /// + public AdapterConf() + { + sNomeAdapt = ""; + etipoAdapt = tipoAdapter.Demo; } public int nVacuumPump { @@ -174,163 +173,163 @@ namespace MTC_Sim /// /// public static void Serialize(string file, AdapterConf c) - { - System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(c.GetType()); - StreamWriter writer = File.CreateText(file); - xs.Serialize(writer, c); - writer.Flush(); - writer.Close(); - } - /// - /// deserializzazione oggetto conf adapter - /// - /// - /// - public static AdapterConf Deserialize(string file) - { - System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(AdapterConf)); - StreamReader reader = File.OpenText(file); - AdapterConf c = (AdapterConf)xs.Deserialize(reader); - reader.Close(); - return c; - } - /// - /// restitusice forma XML grezza del file - /// - /// - /// - public static string rawXml(string file) - { - string answ = ""; - System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(AdapterConf)); - StreamReader reader = File.OpenText(file); - answ = reader.ReadToEnd(); - reader.Close(); - return answ; - } + { + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(c.GetType()); + StreamWriter writer = File.CreateText(file); + xs.Serialize(writer, c); + writer.Flush(); + writer.Close(); + } + /// + /// deserializzazione oggetto conf adapter + /// + /// + /// + public static AdapterConf Deserialize(string file) + { + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(AdapterConf)); + StreamReader reader = File.OpenText(file); + AdapterConf c = (AdapterConf)xs.Deserialize(reader); + reader.Close(); + return c; + } + /// + /// restitusice forma XML grezza del file + /// + /// + /// + public static string rawXml(string file) + { + string answ = ""; + System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(AdapterConf)); + StreamReader reader = File.OpenText(file); + answ = reader.ReadToEnd(); + reader.Close(); + return answ; + } - public int Version - { - get { return nVers; } - set { nVers = value; } - } - public string NomeAdapt - { - get { return sNomeAdapt; } - set { sNomeAdapt = value; } - } - public tipoAdapter TipoAdapt - { - get { return etipoAdapt; } - set { etipoAdapt = value; } - } - public element[] VacuumPump - { - get { return _VacuumPump; } - set { _VacuumPump = value; } - } - public element[] VacuumAct - { - get { return _VacuumAct; } - set { _VacuumAct = value; } - } - public element[] Lubro - { - get { return _Lubro; } - set { _Lubro = value; } - } - public element[] Cooler - { - get { return _Cooler; } - set { _Cooler = value; } - } - public element[] Press - { - get { return _Press; } - set { _Press = value; } - } - public element[] Temp - { - get { return _Temp; } - set { _Temp = value; } - } - public element[] Path - { - get { return _Path; } - set { _Path = value; } - } - public element[] UnOp - { - get { return _UnOp; } - set { _UnOp = value; } - } - public element[] Axis - { - get { return _Axis; } - set { _Axis = value; } - } + public int Version + { + get { return nVers; } + set { nVers = value; } + } + public string NomeAdapt + { + get { return sNomeAdapt; } + set { sNomeAdapt = value; } + } + public tipoAdapter TipoAdapt + { + get { return etipoAdapt; } + set { etipoAdapt = value; } + } + public element[] VacuumPump + { + get { return _VacuumPump; } + set { _VacuumPump = value; } + } + public element[] VacuumAct + { + get { return _VacuumAct; } + set { _VacuumAct = value; } + } + public element[] Lubro + { + get { return _Lubro; } + set { _Lubro = value; } + } + public element[] Cooler + { + get { return _Cooler; } + set { _Cooler = value; } + } + public element[] Press + { + get { return _Press; } + set { _Press = value; } + } + public element[] Temp + { + get { return _Temp; } + set { _Temp = value; } + } + public element[] Path + { + get { return _Path; } + set { _Path = value; } + } + public element[] UnOp + { + get { return _UnOp; } + set { _UnOp = value; } + } + public element[] Axis + { + get { return _Axis; } + set { _Axis = value; } + } - } + } - [Serializable] - [XmlType(TypeName = "dataRef")] - public struct DataRefItem - { - public K Key { get; set; } - public V Value { get; set; } + [Serializable] + [XmlType(TypeName = "dataRef")] + public struct DataRefItem + { + public K Key { get; set; } + public V Value { get; set; } - public DataRefItem(K k, V v) : this() { Key = k; Value = v; } - } + public DataRefItem(K k, V v) : this() { Key = k; Value = v; } + } - /// - /// classe elemento base in cui salvare i dati di conf x recupero dati adapters - /// - public class element - { - /// - /// identificativo univoco x classe di elemento - /// - public string ident; - /// - /// alias x poterlo riconoscere/riferire in agent - /// - public string alias; - /// - /// fonte dati - /// - public fonteDati fonte; - /// - /// Elenco riferimento dati x recupero (es posizioni memoria separate da #) - /// - public List> dataRefList; + /// + /// classe elemento base in cui salvare i dati di conf x recupero dati adapters + /// + public class element + { + /// + /// identificativo univoco x classe di elemento + /// + public string ident; + /// + /// alias x poterlo riconoscere/riferire in agent + /// + public string alias; + /// + /// fonte dati + /// + public fonteDati fonte; + /// + /// Elenco riferimento dati x recupero (es posizioni memoria separate da #) + /// + public List> dataRefList; - /// - /// init empty - /// - public element() - { - ident = ""; - alias = ""; - fonte = fonteDati.NoData; - dataRefList = new List>(); - } - /// - /// init element con dati - /// - /// Identificativo univoco - /// Alias/descrizione - /// Tipo fonte dati - /// Parametri x recupero dati in forma dictionary - public element(string Idx, string Alias, fonteDati FonteD, List> DataRef) - { - ident = Idx; - alias = Alias; - fonte = FonteD; - dataRefList = DataRef; - } - } + /// + /// init empty + /// + public element() + { + ident = ""; + alias = ""; + fonte = fonteDati.NoData; + dataRefList = new List>(); + } + /// + /// init element con dati + /// + /// Identificativo univoco + /// Alias/descrizione + /// Tipo fonte dati + /// Parametri x recupero dati in forma dictionary + public element(string Idx, string Alias, fonteDati FonteD, List> DataRef) + { + ident = Idx; + alias = Alias; + fonte = FonteD; + dataRefList = DataRef; + } + } - #endregion + #endregion } diff --git a/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml b/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml index 441deda..5b1babd 100644 --- a/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml +++ b/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml @@ -16,6 +16,17 @@ + + VacPump_02 + Pompa 2 + Random + + + VacPump_02_Status + 0#7 + + + @@ -53,6 +64,17 @@ + + Lubro_02 + Lubrorefrigerante 2 + Random + + + Lubro_02_Num + 0#15 + + + diff --git a/MTC_Sim/MTC_Sim/SetupAdapter.cs b/MTC_Sim/MTC_Sim/SetupAdapter.cs index a6b2083..ab2a646 100644 --- a/MTC_Sim/MTC_Sim/SetupAdapter.cs +++ b/MTC_Sim/MTC_Sim/SetupAdapter.cs @@ -40,6 +40,10 @@ namespace MTC_Sim { } return answ; } + set + { + nVacPump.Text = value.ToString(); + } } protected int numVacAct { @@ -54,6 +58,10 @@ namespace MTC_Sim { } return answ; } + set + { + nVacAct.Text = value.ToString(); + } } protected int numLubro { @@ -68,6 +76,10 @@ namespace MTC_Sim { } return answ; } + set + { + nLubro.Text = value.ToString(); + } } protected int numCooler { @@ -82,6 +94,10 @@ namespace MTC_Sim { } return answ; } + set + { + nCooler.Text = value.ToString(); + } } protected int numPress { @@ -96,6 +112,10 @@ namespace MTC_Sim { } return answ; } + set + { + nPress.Text = value.ToString(); + } } protected int numTemp { @@ -110,6 +130,10 @@ namespace MTC_Sim { } return answ; } + set + { + nTempe.Text = value.ToString(); + } } protected int numPath { @@ -124,6 +148,10 @@ namespace MTC_Sim { } return answ; } + set + { + nPath.Text = value.ToString(); + } } protected int numUnOp { @@ -138,6 +166,10 @@ namespace MTC_Sim { } return answ; } + set + { + nUnOp.Text = value.ToString(); + } } protected int numAxis { @@ -152,6 +184,10 @@ namespace MTC_Sim { } return answ; } + set + { + nAssi.Text = value.ToString(); + } } private void btnCreateFile_Click(object sender, EventArgs e) @@ -370,6 +406,15 @@ namespace MTC_Sim AdapterConf c2 = AdapterConf.Deserialize(filePath); txtAdapter.Text = c2.NomeAdapt; + numVacPump = c2.nVacuumPump; + numVacAct = c2.nVacuumAct; + numLubro = c2.nLubro; + numCooler = c2.nCooler; + numPress = c2.nPress; + numTemp = c2.nTemp; + numPath = c2.nPath; + numUnOp = c2.nUnOp; + numAxis = c2.nAxis; } } }