diff --git a/MTC_Adapter/MTC_Adapter/AdapterConf.cs b/MTC_Adapter/MTC_Adapter/AdapterConf.cs index 85e35ab..f995a8e 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterConf.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterConf.cs @@ -6,453 +6,476 @@ using System.Xml.Serialization; namespace MTC_Adapter { - #region -- AdapterConf Class -- + #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; + double tContOreMaccOn; + double tContOreMaccLav; + double tContSlittaTast; + int[] _ContGiriElettrom; + float[] _ContKmMovAssi; + tipoAdapter etipoAdapt; + + element[] _VacuumPump; + element[] _VacuumAct; + element[] _Lubro; + element[] _Counters; + element[] _SlittaMag; + element[] _ProtMag; + element[] _Cooler; + element[] _Press; + element[] _Temp; + element[] _Path; + element[] _UnOp; + element[] _Axis; + element[] _MemArea; /// - /// 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 + /// init conf adapter /// - [Serializable] - public class AdapterConf + public AdapterConf() { - string sNomeAdapt; - int nVers; - double tContOreMaccOn; - double tContOreMaccLav; - double tContSlittaTast; - int[] _ContGiriElettrom; - float[] _ContKmMovAssi; - tipoAdapter etipoAdapt; - - element[] _VacuumPump; - element[] _VacuumAct; - element[] _Lubro; - element[] _SlittaMag; - element[] _ProtMag; - element[] _Cooler; - element[] _Press; - element[] _Temp; - element[] _Path; - element[] _UnOp; - element[] _Axis; - element[] _MemArea; - - /// - /// init conf adapter - /// - public AdapterConf() - { - sNomeAdapt = ""; - etipoAdapt = tipoAdapter.DEMO; - } - public int nVacuumPump - { - get - { - int answ = 0; - if (VacuumPump != null) - { - try - { - answ = Convert.ToInt32(VacuumPump.Length); - } - catch - { } - } - return answ; - } - } - public int nVacuumAct - { - get - { - int answ = 0; - if (VacuumAct != null) - { - try - { - answ = Convert.ToInt32(VacuumAct.Length); - } - catch - { } - } - return answ; - } - } - public int nLubro - { - get - { - int answ = 0; - if (Lubro != null) - { - try - { - answ = Convert.ToInt32(Lubro.Length); - } - catch - { } - } - return answ; - } - } - public int nSlittaMag - { - get - { - int answ = 0; - if (SlittaMag != null) - { - try - { - answ = Convert.ToInt32(SlittaMag.Length); - } - catch - { } - } - return answ; - } - } - public int nProtMag - { - get - { - int answ = 0; - if (ProtMag != null) - { - try - { - answ = Convert.ToInt32(ProtMag.Length); - } - catch - { } - } - return answ; - } - } - public int nCooler - { - get - { - int answ = 0; - if (Cooler != null) - { - try - { - answ = Convert.ToInt32(Cooler.Length); - } - catch - { } - } - return answ; - } - } - public int nPress - { - get - { - int answ = 0; - if (Press != null) - { - try - { - answ = Convert.ToInt32(Press.Length); - } - catch - { } - } - return answ; - } - } - public int nTemp - { - get - { - int answ = 0; - if (Temp != null) - { - try - { - answ = Convert.ToInt32(Temp.Length); - } - catch - { } - } - return answ; - } - } - public int nPath - { - get - { - int answ = 0; - if (Path != null) - { - try - { - answ = Convert.ToInt32(Path.Length); - } - catch - { } - } - return answ; - } - } - public int nUnOp - { - get - { - int answ = 0; - if (UnOp != null) - { - try - { - answ = Convert.ToInt32(UnOp.Length); - } - catch - { } - } - return answ; - } - } - public int nAxis - { - get - { - int answ = 0; - if (Axis != null) - { - try - { - answ = Convert.ToInt32(Axis.Length); - } - catch - { } - } - return answ; - } - } - public int nMemArea - { - get - { - int answ = 0; - if (MemArea != null) - { - try - { - answ = Convert.ToInt32(MemArea.Length); - } - catch - { } - } - return answ; - } - } - - /// - /// Serializzazione XML dell'oggetto conf dell'adapter - /// - /// - /// - public static void Serialize(string file, AdapterConf c) - { - // prima provo a creare il file vuoto... - if (!File.Exists(file)) - { - string dirPath = file.Substring(0, file.LastIndexOf('\\')); - // verifico directory - if (!Directory.Exists(dirPath)) - { - Directory.CreateDirectory(dirPath); - } - } - // salvo effettivamente file... - 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) - { - XmlSerializer xs = new 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 double ContOreMaccOn - { - get { return tContOreMaccOn; } - set { tContOreMaccOn = value; } - } - public double ContOreMaccLav - { - get { return tContOreMaccLav; } - set { tContOreMaccLav = value; } - } - public double ContSlittaTast - { - get { return tContSlittaTast; } - set { tContSlittaTast = value; } - } - public int[] ContGiriElettrom - { - get { return _ContGiriElettrom; } - set { _ContGiriElettrom = value; } - } - public float[] ContKmMovAssi - { - get { return _ContKmMovAssi; } - set { _ContKmMovAssi = 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[] SlittaMag - { - get { return _SlittaMag; } - set { _SlittaMag = value; } - } - public element[] ProtMag - { - get { return _ProtMag; } - set { _ProtMag = 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 element[] MemArea - { - get { return _MemArea; } - set { _MemArea = value; } - } - + sNomeAdapt = ""; + etipoAdapt = tipoAdapter.DEMO; } - - - [Serializable] - [XmlType(TypeName = "dataRef")] - public struct DataRefItem + public int nVacuumPump { - public K Key { get; set; } - public V Value { get; set; } - - public DataRefItem(K k, V v) : this() { Key = k; Value = v; } + get + { + int answ = 0; + if (VacuumPump != null) + { + try + { + answ = Convert.ToInt32(VacuumPump.Length); + } + catch + { } + } + return answ; + } + } + public int nVacuumAct + { + get + { + int answ = 0; + if (VacuumAct != null) + { + try + { + answ = Convert.ToInt32(VacuumAct.Length); + } + catch + { } + } + return answ; + } + } + public int nLubro + { + get + { + int answ = 0; + if (Lubro != null) + { + try + { + answ = Convert.ToInt32(Lubro.Length); + } + catch + { } + } + return answ; + } + } + public int nSlittaMag + { + get + { + int answ = 0; + if (SlittaMag != null) + { + try + { + answ = Convert.ToInt32(SlittaMag.Length); + } + catch + { } + } + return answ; + } + } + public int nCounters + { + get + { + int answ = 0; + if (Counters != null) + { + try + { + answ = Convert.ToInt32(Counters.Length); + } + catch + { } + } + return answ; + } + } + public int nProtMag + { + get + { + int answ = 0; + if (ProtMag != null) + { + try + { + answ = Convert.ToInt32(ProtMag.Length); + } + catch + { } + } + return answ; + } + } + public int nCooler + { + get + { + int answ = 0; + if (Cooler != null) + { + try + { + answ = Convert.ToInt32(Cooler.Length); + } + catch + { } + } + return answ; + } + } + public int nPress + { + get + { + int answ = 0; + if (Press != null) + { + try + { + answ = Convert.ToInt32(Press.Length); + } + catch + { } + } + return answ; + } + } + public int nTemp + { + get + { + int answ = 0; + if (Temp != null) + { + try + { + answ = Convert.ToInt32(Temp.Length); + } + catch + { } + } + return answ; + } + } + public int nPath + { + get + { + int answ = 0; + if (Path != null) + { + try + { + answ = Convert.ToInt32(Path.Length); + } + catch + { } + } + return answ; + } + } + public int nUnOp + { + get + { + int answ = 0; + if (UnOp != null) + { + try + { + answ = Convert.ToInt32(UnOp.Length); + } + catch + { } + } + return answ; + } + } + public int nAxis + { + get + { + int answ = 0; + if (Axis != null) + { + try + { + answ = Convert.ToInt32(Axis.Length); + } + catch + { } + } + return answ; + } + } + public int nMemArea + { + get + { + int answ = 0; + if (MemArea != null) + { + try + { + answ = Convert.ToInt32(MemArea.Length); + } + catch + { } + } + return answ; + } } /// - /// classe elemento base in cui salvare i dati di conf x recupero dati adapters + /// Serializzazione XML dell'oggetto conf dell'adapter /// - public class element + /// + /// + public static void Serialize(string file, AdapterConf c) { - /// - /// identificativo univoco x classe di elemento - /// - public string ident; - /// - /// Elenco riferimento dati x recupero (es posizioni memoria separate da #) - /// - public List> dataRefList; - - /// - /// init empty - /// - public element() + // prima provo a creare il file vuoto... + if (!File.Exists(file)) + { + string dirPath = file.Substring(0, file.LastIndexOf('\\')); + // verifico directory + if (!Directory.Exists(dirPath)) { - ident = ""; - dataRefList = new List>(); - } - /// - /// init element con dati - /// - /// Identificativo univoco - /// Parametri x recupero dati in forma dictionary - public element(string Idx, List> DataRef) - { - ident = Idx; - dataRefList = DataRef; + Directory.CreateDirectory(dirPath); } + } + // salvo effettivamente file... + 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) + { + XmlSerializer xs = new 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; } - #endregion + 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 double ContOreMaccOn + { + get { return tContOreMaccOn; } + set { tContOreMaccOn = value; } + } + public double ContOreMaccLav + { + get { return tContOreMaccLav; } + set { tContOreMaccLav = value; } + } + public double ContSlittaTast + { + get { return tContSlittaTast; } + set { tContSlittaTast = value; } + } + public int[] ContGiriElettrom + { + get { return _ContGiriElettrom; } + set { _ContGiriElettrom = value; } + } + public float[] ContKmMovAssi + { + get { return _ContKmMovAssi; } + set { _ContKmMovAssi = 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[] Counters + { + get { return _Counters; } + set { _Counters = value; } + } + public element[] SlittaMag + { + get { return _SlittaMag; } + set { _SlittaMag = value; } + } + public element[] ProtMag + { + get { return _ProtMag; } + set { _ProtMag = 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 element[] MemArea + { + get { return _MemArea; } + set { _MemArea = value; } + } + + } + + + [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; } + } + + /// + /// 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; + /// + /// Elenco riferimento dati x recupero (es posizioni memoria separate da #) + /// + public List> dataRefList; + + /// + /// init empty + /// + public element() + { + ident = ""; + dataRefList = new List>(); + } + /// + /// init element con dati + /// + /// Identificativo univoco + /// Parametri x recupero dati in forma dictionary + public element(string Idx, List> DataRef) + { + ident = Idx; + dataRefList = DataRef; + } + } + + #endregion } diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index e5f5415..52d3a37 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -89,6 +89,27 @@ namespace MTC_Adapter } } /// + /// Singolo oggetto CON contatore + /// + public class ObjCount : element + { + /// + /// valore numero attivazioni/disattivazioni slitta magazzino + /// + public Event mCounter; + /// + /// Classe Slitta Magazzino + /// + /// element base contenente parametri (da XML) + public ObjCount(element baseElem) + { + ident = baseElem.ident; + dataRefList = baseElem.dataRefList; + + mCounter = new Event(string.Format("{0}", ident)); + } + } + /// /// Singola Slitta Mag, 0..n /// public class SlittaMag : element @@ -713,6 +734,10 @@ namespace MTC_Adapter /// public uint[] currNumCambiUt; /// + /// Vettore ATTUALE dei contatori GENERICI + /// + public uint[] currCounters; + /// /// Vettore ATTUALE dei contatori del numero movimenti Slitta Magazzino /// public uint[] currSlittaMag; @@ -782,6 +807,10 @@ namespace MTC_Adapter /// public uint[] istNumCambiUt; /// + /// Vettore ISTANTANEO dei contatori generici + /// + public uint[] istCounters; + /// /// Vettore ISTANTANEO dei contatori del numero movimenti Slitta Magazzino /// public uint[] istSlittaMag; @@ -1090,6 +1119,7 @@ namespace MTC_Adapter public VacuumPump[] vettVacPump; public VacuumAct[] vettVacAct; public Lubro[] vettLubro; + public ObjCount[] vettCounters; public SlittaMag[] vettSlittaMag; public ProtMag[] vettProtMag; public Cooler[] vettCooler; @@ -1161,6 +1191,14 @@ namespace MTC_Adapter mAdapter.AddDataItem(mUnkStatus); mAdapter.AddDataItem(mUnkStrobe); + // contatori generici + vettCounters = new ObjCount[adpConf.nCounters]; + for (int i = 0; i < adpConf.nCounters; i++) + { + vettCounters[i] = new ObjCount(adpConf.Counters[i]); + mAdapter.AddDataItem(vettCounters[i].mCounter); + } + // Aree memoria vettMemArea = new MemArea[adpConf.nMemArea]; for (int i = 0; i < adpConf.nMemArea; i++) @@ -1837,6 +1875,17 @@ namespace MTC_Adapter // recupero valori... currLubroCount[i] = Convert.ToUInt32(riLubro.Value); } + currCounters = new uint[currAdpConf.nCounters]; + istCounters= new uint[currAdpConf.nCounters]; + for (int i = 0; i < currAdpConf.nCounters; i++) + { + // leggo tutti i dati... + List> listaDR = currAdpConf.Counters[i].dataRefList; + // punto all'item + DataRefItem riCounters = listaDR.Find(x => x.Key == string.Format("Counter_{0:000}", i + 1)); + // recupero valori... + currCounters[i] = Convert.ToUInt32(riCounters.Value); + } currSlittaMag = new uint[currAdpConf.nSlittaMag]; istSlittaMag = new uint[currAdpConf.nSlittaMag]; for (int i = 0; i < currAdpConf.nSlittaMag; i++) @@ -3292,6 +3341,20 @@ namespace MTC_Adapter { istSlittaTast = tabDatiMtz[i]; } + else if (maintData[i].varName.StartsWith("Counter_")) + { + try + { + numero = Convert.ToInt32(maintData[i].varName.Replace("Counter_", "")); + } + catch + { + } + if (numero > 0) + { + istCounters[numero - 1] = tabDatiMtz[i]; + } + } else if (maintData[i].varName.StartsWith("Path_")) { if (maintData[i].varName.EndsWith("_PZ_TOT")) @@ -3301,8 +3364,7 @@ namespace MTC_Adapter numero = Convert.ToInt32(maintData[i].varName.Replace("Path_", "").Replace("_PZ_TOT", "")); } catch - { - } + { } if (numero > 0) { vettPath[numero - 1].mPathPartCount.Value = tabDatiMtz[i]; @@ -3543,6 +3605,7 @@ namespace MTC_Adapter needSave = procPzProd(needSave); needSave = procGiriTotUnOp(needSave); needSave = procNumCU(needSave); + needSave = procCounters(needSave); needSave = procMovTotAssi(needSave); needSave = procAccTimeAssi(needSave); needSave = procNumInvAssi(needSave); @@ -4479,6 +4542,40 @@ namespace MTC_Adapter return needSave; } /// + /// Processing delle variabili generiche Counters + /// + /// + /// + public bool procCounters(bool needSave) + { + uint delta = 0; + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < currAdpConf.nCounters; i++) + { + delta = istCounters[i] - currCounters[i]; + // controllo delta < 50% max... + if (delta < uint.MaxValue / 2) + { + //processo comunque sempre... + uint contTot = updateValUIntByIncr(i, delta, "Counters_{0:000}"); + // passo valore totale all'adapter + vettCounters[i].mCounter.Value = contTot; + // controllo valore riferimento... + if (delta > 0) + { + // segnalo necessità salvataggio! + needSave = true; + } + // ...aggiorno valore riferimento... + currCounters[i] = istCounters[i]; + } + sb.AppendLine(vettCounters[i].mCounter.ToString().Replace("|", " | ")); + } + // salvo su maschera... + parentForm.dataMonitor_2 += sb.ToString(); + return needSave; + } + /// /// Processing delle variabili sui componenti SlittaMag /// /// diff --git a/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml b/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml index ee9d1b6..b2257b3 100644 --- a/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml +++ b/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml @@ -36,18 +36,32 @@ + + + Counter_001 + + + + Counter_002 + + + + Counter_003 + + + + + + SlittaMagazzino_01 + + + ProtMagazzino_01 - - - SlittaMagazzino_ - - - Cooler_01 diff --git a/MTC_Adapter/MTC_Adapter/DATA/CONF/CounterList.map b/MTC_Adapter/MTC_Adapter/DATA/CONF/CounterList.map index 59c12a6..064fc1a 100644 --- a/MTC_Adapter/MTC_Adapter/DATA/CONF/CounterList.map +++ b/MTC_Adapter/MTC_Adapter/DATA/CONF/CounterList.map @@ -29,4 +29,7 @@ 028|Axis_03_AccTime |COUNT 029|Axis_04_AccTime |COUNT 030|Axis_05_AccTime |COUNT -031|Axis_06_AccTime |COUNT \ No newline at end of file +031|Axis_06_AccTime |COUNT +032|Counter_001 |COUNT +033|Counter_002 |COUNT +034|Counter_003 |COUNT \ No newline at end of file diff --git a/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListFANUC.map b/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListFANUC.map index 59c12a6..064fc1a 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListFANUC.map +++ b/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListFANUC.map @@ -29,4 +29,7 @@ 028|Axis_03_AccTime |COUNT 029|Axis_04_AccTime |COUNT 030|Axis_05_AccTime |COUNT -031|Axis_06_AccTime |COUNT \ No newline at end of file +031|Axis_06_AccTime |COUNT +032|Counter_001 |COUNT +033|Counter_002 |COUNT +034|Counter_003 |COUNT \ No newline at end of file diff --git a/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListOSAI.map b/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListOSAI.map index 55e0c09..fd5ce44 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListOSAI.map +++ b/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListOSAI.map @@ -29,4 +29,7 @@ 028|Axis_03_AccTime |COUNT 029|Axis_04_AccTime |COUNT 030|Axis_05_AccTime |COUNT -031|Axis_06_AccTime |COUNT \ No newline at end of file +031|Axis_06_AccTime |COUNT +032|Counter_001 |COUNT +033|Counter_002 |COUNT +034|Counter_003 |COUNT \ No newline at end of file diff --git a/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListSIEMENS.map b/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListSIEMENS.map index 59c12a6..064fc1a 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListSIEMENS.map +++ b/MTC_Adapter/MTC_Adapter/Resources/CMS/CounterListSIEMENS.map @@ -29,4 +29,7 @@ 028|Axis_03_AccTime |COUNT 029|Axis_04_AccTime |COUNT 030|Axis_05_AccTime |COUNT -031|Axis_06_AccTime |COUNT \ No newline at end of file +031|Axis_06_AccTime |COUNT +032|Counter_001 |COUNT +033|Counter_002 |COUNT +034|Counter_003 |COUNT \ No newline at end of file diff --git a/MTC_Adapter/MTC_Adapter/Resources/CMS/FANUC.xml b/MTC_Adapter/MTC_Adapter/Resources/CMS/FANUC.xml index 9bf8da6..7b65996 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/CMS/FANUC.xml +++ b/MTC_Adapter/MTC_Adapter/Resources/CMS/FANUC.xml @@ -36,18 +36,32 @@ + + + Counter_001 + + + + Counter_002 + + + + Counter_003 + + + + + + SlittaMagazzino_01 + + + ProtMagazzino_01 - - - SlittaMagazzino_ - - - Cooler_01 diff --git a/MTC_Adapter/MTC_Adapter/Resources/CMS/OSAI.xml b/MTC_Adapter/MTC_Adapter/Resources/CMS/OSAI.xml index a3cdf8c..6bdb167 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/CMS/OSAI.xml +++ b/MTC_Adapter/MTC_Adapter/Resources/CMS/OSAI.xml @@ -36,13 +36,29 @@ - + - ProtMagazzino_01 + Counter_001 - ProtMagazzino_02 + Counter_002 + + + + Counter_003 + + + + + + SlittaMagazzino_01 + + + + + + ProtMagazzino_01 diff --git a/MTC_Adapter/MTC_Adapter/Resources/CMS/SIEMENS.xml b/MTC_Adapter/MTC_Adapter/Resources/CMS/SIEMENS.xml index 66f2df4..15360b3 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/CMS/SIEMENS.xml +++ b/MTC_Adapter/MTC_Adapter/Resources/CMS/SIEMENS.xml @@ -36,18 +36,32 @@ + + + Counter_001 + + + + Counter_002 + + + + Counter_003 + + + + + + SlittaMagazzino_01 + + + ProtMagazzino_01 - - - SlittaMagazzino_ - - - Cooler_01 diff --git a/MTC_Adapter/MTC_Adapter/SetupAdapter.Designer.cs b/MTC_Adapter/MTC_Adapter/SetupAdapter.Designer.cs index 7bd7585..8ad46e4 100644 --- a/MTC_Adapter/MTC_Adapter/SetupAdapter.Designer.cs +++ b/MTC_Adapter/MTC_Adapter/SetupAdapter.Designer.cs @@ -28,364 +28,420 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupAdapter)); - this.txtAdapter = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.txtFileName = new System.Windows.Forms.TextBox(); - this.btnSave = new System.Windows.Forms.Button(); - this.btnLoad = new System.Windows.Forms.Button(); - this.label3 = new System.Windows.Forms.Label(); - this.nVacPump = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.nVacAct = new System.Windows.Forms.TextBox(); - this.label5 = new System.Windows.Forms.Label(); - this.cbTipoAdapt = new System.Windows.Forms.ComboBox(); - this.label6 = new System.Windows.Forms.Label(); - this.nLubro = new System.Windows.Forms.TextBox(); - this.label7 = new System.Windows.Forms.Label(); - this.nCooler = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.nPress = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.nTempe = new System.Windows.Forms.TextBox(); - this.label10 = new System.Windows.Forms.Label(); - this.nPath = new System.Windows.Forms.TextBox(); - this.label11 = new System.Windows.Forms.Label(); - this.nUnOp = new System.Windows.Forms.TextBox(); - this.label12 = new System.Windows.Forms.Label(); - this.nAssi = new System.Windows.Forms.TextBox(); - this.label13 = new System.Windows.Forms.Label(); - this.nMemArea = new System.Windows.Forms.TextBox(); - this.label14 = new System.Windows.Forms.Label(); - this.nProtMag = new System.Windows.Forms.TextBox(); - this.label15 = new System.Windows.Forms.Label(); - this.nSlittaMag = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // txtAdapter - // - this.txtAdapter.Location = new System.Drawing.Point(91, 10); - this.txtAdapter.Name = "txtAdapter"; - this.txtAdapter.Size = new System.Drawing.Size(214, 20); - this.txtAdapter.TabIndex = 0; - this.txtAdapter.Text = "CMS_ADAPTER_00"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(22, 13); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(58, 13); - this.label1.TabIndex = 1; - this.label1.Text = "ADAPTER"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(311, 13); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(63, 13); - this.label2.TabIndex = 3; - this.label2.Text = "FILE NAME"; - // - // txtFileName - // - this.txtFileName.Location = new System.Drawing.Point(380, 10); - this.txtFileName.Name = "txtFileName"; - this.txtFileName.Size = new System.Drawing.Size(122, 20); - this.txtFileName.TabIndex = 2; - this.txtFileName.Text = "Adapter_ItemList.xml"; - // - // btnSave - // - this.btnSave.Location = new System.Drawing.Point(479, 467); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(201, 38); - this.btnSave.TabIndex = 4; - this.btnSave.Text = "SAVE CONFIGURATION"; - this.btnSave.UseVisualStyleBackColor = true; - this.btnSave.Click += new System.EventHandler(this.btnCreateFile_Click); - // - // btnLoad - // - this.btnLoad.Location = new System.Drawing.Point(16, 467); - this.btnLoad.Name = "btnLoad"; - this.btnLoad.Size = new System.Drawing.Size(201, 38); - this.btnLoad.TabIndex = 5; - this.btnLoad.Text = "LOAD CONFIGURATION"; - this.btnLoad.UseVisualStyleBackColor = true; - this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(10, 39); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(75, 13); - this.label3.TabIndex = 7; - this.label3.Text = "n° VAC PUMP"; - // - // nVacPump - // - this.nVacPump.Location = new System.Drawing.Point(91, 36); - this.nVacPump.Name = "nVacPump"; - this.nVacPump.Size = new System.Drawing.Size(33, 20); - this.nVacPump.TabIndex = 6; - this.nVacPump.Text = "1"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(176, 39); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(60, 13); - this.label4.TabIndex = 9; - this.label4.Text = "n° VAC Act"; - // - // nVacAct - // - this.nVacAct.Location = new System.Drawing.Point(242, 36); - this.nVacAct.Name = "nVacAct"; - this.nVacAct.Size = new System.Drawing.Size(33, 20); - this.nVacAct.TabIndex = 8; - this.nVacAct.Text = "2"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(517, 13); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(32, 13); - this.label5.TabIndex = 10; - this.label5.Text = "TIPO"; - // - // cbTipoAdapt - // - this.cbTipoAdapt.FormattingEnabled = true; - this.cbTipoAdapt.Items.AddRange(new object[] { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupAdapter)); + this.txtAdapter = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtFileName = new System.Windows.Forms.TextBox(); + this.btnSave = new System.Windows.Forms.Button(); + this.btnLoad = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.nVacPump = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.nVacAct = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.cbTipoAdapt = new System.Windows.Forms.ComboBox(); + this.label6 = new System.Windows.Forms.Label(); + this.nLubro = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.nCooler = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.nPress = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.nTempe = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.nPath = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.nUnOp = new System.Windows.Forms.TextBox(); + this.label12 = new System.Windows.Forms.Label(); + this.nAssi = new System.Windows.Forms.TextBox(); + this.label13 = new System.Windows.Forms.Label(); + this.nMemArea = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.nProtMag = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); + this.nSlittaMag = new System.Windows.Forms.TextBox(); + this.label16 = new System.Windows.Forms.Label(); + this.nContatori = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // txtAdapter + // + this.txtAdapter.Location = new System.Drawing.Point(121, 12); + this.txtAdapter.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtAdapter.Name = "txtAdapter"; + this.txtAdapter.Size = new System.Drawing.Size(284, 22); + this.txtAdapter.TabIndex = 0; + this.txtAdapter.Text = "CMS_ADAPTER_00"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(29, 16); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(73, 17); + this.label1.TabIndex = 1; + this.label1.Text = "ADAPTER"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(415, 16); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(79, 17); + this.label2.TabIndex = 3; + this.label2.Text = "FILE NAME"; + // + // txtFileName + // + this.txtFileName.Location = new System.Drawing.Point(507, 12); + this.txtFileName.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.txtFileName.Name = "txtFileName"; + this.txtFileName.Size = new System.Drawing.Size(161, 22); + this.txtFileName.TabIndex = 2; + this.txtFileName.Text = "Adapter_ItemList.xml"; + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(639, 575); + this.btnSave.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(268, 47); + this.btnSave.TabIndex = 4; + this.btnSave.Text = "SAVE CONFIGURATION"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnCreateFile_Click); + // + // btnLoad + // + this.btnLoad.Location = new System.Drawing.Point(21, 575); + this.btnLoad.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnLoad.Name = "btnLoad"; + this.btnLoad.Size = new System.Drawing.Size(268, 47); + this.btnLoad.TabIndex = 5; + this.btnLoad.Text = "LOAD CONFIGURATION"; + this.btnLoad.UseVisualStyleBackColor = true; + this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(13, 48); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(96, 17); + this.label3.TabIndex = 7; + this.label3.Text = "n° VAC PUMP"; + // + // nVacPump + // + this.nVacPump.Location = new System.Drawing.Point(121, 44); + this.nVacPump.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nVacPump.Name = "nVacPump"; + this.nVacPump.Size = new System.Drawing.Size(43, 22); + this.nVacPump.TabIndex = 6; + this.nVacPump.Text = "1"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(235, 48); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(77, 17); + this.label4.TabIndex = 9; + this.label4.Text = "n° VAC Act"; + // + // nVacAct + // + this.nVacAct.Location = new System.Drawing.Point(323, 44); + this.nVacAct.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nVacAct.Name = "nVacAct"; + this.nVacAct.Size = new System.Drawing.Size(43, 22); + this.nVacAct.TabIndex = 8; + this.nVacAct.Text = "2"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(689, 16); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(40, 17); + this.label5.TabIndex = 10; + this.label5.Text = "TIPO"; + // + // cbTipoAdapt + // + this.cbTipoAdapt.FormattingEnabled = true; + this.cbTipoAdapt.Items.AddRange(new object[] { "DEMO", "ESAGV", "FANUC", "OSAI", "SIEMENS"}); - this.cbTipoAdapt.Location = new System.Drawing.Point(555, 10); - this.cbTipoAdapt.Name = "cbTipoAdapt"; - this.cbTipoAdapt.Size = new System.Drawing.Size(121, 21); - this.cbTipoAdapt.TabIndex = 11; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(314, 39); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(57, 13); - this.label6.TabIndex = 13; - this.label6.Text = "n° LUBRO"; - // - // nLubro - // - this.nLubro.Location = new System.Drawing.Point(380, 36); - this.nLubro.Name = "nLubro"; - this.nLubro.Size = new System.Drawing.Size(33, 20); - this.nLubro.TabIndex = 12; - this.nLubro.Text = "1"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(473, 39); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(64, 13); - this.label7.TabIndex = 15; - this.label7.Text = "n° COOLER"; - // - // nCooler - // - this.nCooler.Location = new System.Drawing.Point(539, 36); - this.nCooler.Name = "nCooler"; - this.nCooler.Size = new System.Drawing.Size(33, 20); - this.nCooler.TabIndex = 14; - this.nCooler.Text = "2"; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(25, 65); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(56, 13); - this.label8.TabIndex = 17; - this.label8.Text = "n° PRESS"; - // - // nPress - // - this.nPress.Location = new System.Drawing.Point(91, 62); - this.nPress.Name = "nPress"; - this.nPress.Size = new System.Drawing.Size(33, 20); - this.nPress.TabIndex = 16; - this.nPress.Text = "1"; - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(176, 65); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(50, 13); - this.label9.TabIndex = 19; - this.label9.Text = "n° TEMP"; - // - // nTempe - // - this.nTempe.Location = new System.Drawing.Point(242, 62); - this.nTempe.Name = "nTempe"; - this.nTempe.Size = new System.Drawing.Size(33, 20); - this.nTempe.TabIndex = 18; - this.nTempe.Text = "1"; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(314, 65); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(49, 13); - this.label10.TabIndex = 21; - this.label10.Text = "n° PATH"; - // - // nPath - // - this.nPath.Location = new System.Drawing.Point(380, 62); - this.nPath.Name = "nPath"; - this.nPath.Size = new System.Drawing.Size(33, 20); - this.nPath.TabIndex = 20; - this.nPath.Text = "1"; - // - // label11 - // - this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(473, 65); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(52, 13); - this.label11.TabIndex = 23; - this.label11.Text = "n° Un OP"; - // - // nUnOp - // - this.nUnOp.Location = new System.Drawing.Point(539, 62); - this.nUnOp.Name = "nUnOp"; - this.nUnOp.Size = new System.Drawing.Size(33, 20); - this.nUnOp.TabIndex = 22; - this.nUnOp.Text = "1"; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(25, 91); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(39, 13); - this.label12.TabIndex = 25; - this.label12.Text = "n° Assi"; - // - // nAssi - // - this.nAssi.Location = new System.Drawing.Point(91, 88); - this.nAssi.Name = "nAssi"; - this.nAssi.Size = new System.Drawing.Size(33, 20); - this.nAssi.TabIndex = 24; - this.nAssi.Text = "1"; - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(176, 94); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(65, 13); - this.label13.TabIndex = 27; - this.label13.Text = "n° MemArea"; - // - // nMemArea - // - this.nMemArea.Location = new System.Drawing.Point(242, 91); - this.nMemArea.Name = "nMemArea"; - this.nMemArea.Size = new System.Drawing.Size(33, 20); - this.nMemArea.TabIndex = 26; - this.nMemArea.Text = "1"; - // - // label14 - // - this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(473, 94); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(63, 13); - this.label14.TabIndex = 31; - this.label14.Text = "n° Prot Mag"; - // - // nProtMag - // - this.nProtMag.Location = new System.Drawing.Point(539, 91); - this.nProtMag.Name = "nProtMag"; - this.nProtMag.Size = new System.Drawing.Size(33, 20); - this.nProtMag.TabIndex = 30; - this.nProtMag.Text = "0"; - // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(314, 94); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(55, 13); - this.label15.TabIndex = 29; - this.label15.Text = "n° Sli Mag"; - // - // nSlittaMag - // - this.nSlittaMag.Location = new System.Drawing.Point(380, 91); - this.nSlittaMag.Name = "nSlittaMag"; - this.nSlittaMag.Size = new System.Drawing.Size(33, 20); - this.nSlittaMag.TabIndex = 28; - this.nSlittaMag.Text = "0"; - // - // SetupAdapter - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(692, 517); - this.Controls.Add(this.label14); - this.Controls.Add(this.nProtMag); - this.Controls.Add(this.label15); - this.Controls.Add(this.nSlittaMag); - this.Controls.Add(this.label13); - this.Controls.Add(this.nMemArea); - this.Controls.Add(this.label12); - this.Controls.Add(this.nAssi); - this.Controls.Add(this.label11); - this.Controls.Add(this.nUnOp); - this.Controls.Add(this.label10); - this.Controls.Add(this.nPath); - this.Controls.Add(this.label9); - this.Controls.Add(this.nTempe); - this.Controls.Add(this.label8); - this.Controls.Add(this.nPress); - this.Controls.Add(this.label7); - this.Controls.Add(this.nCooler); - this.Controls.Add(this.label6); - this.Controls.Add(this.nLubro); - this.Controls.Add(this.cbTipoAdapt); - this.Controls.Add(this.label5); - this.Controls.Add(this.label4); - this.Controls.Add(this.nVacAct); - this.Controls.Add(this.label3); - this.Controls.Add(this.nVacPump); - this.Controls.Add(this.btnLoad); - this.Controls.Add(this.btnSave); - this.Controls.Add(this.label2); - this.Controls.Add(this.txtFileName); - this.Controls.Add(this.label1); - this.Controls.Add(this.txtAdapter); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "SetupAdapter"; - this.Text = "Adapter Setup Manager"; - this.ResumeLayout(false); - this.PerformLayout(); + this.cbTipoAdapt.Location = new System.Drawing.Point(740, 12); + this.cbTipoAdapt.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.cbTipoAdapt.Name = "cbTipoAdapt"; + this.cbTipoAdapt.Size = new System.Drawing.Size(160, 24); + this.cbTipoAdapt.TabIndex = 11; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(419, 48); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(74, 17); + this.label6.TabIndex = 13; + this.label6.Text = "n° LUBRO"; + // + // nLubro + // + this.nLubro.Location = new System.Drawing.Point(507, 44); + this.nLubro.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nLubro.Name = "nLubro"; + this.nLubro.Size = new System.Drawing.Size(43, 22); + this.nLubro.TabIndex = 12; + this.nLubro.Text = "1"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(631, 48); + this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(84, 17); + this.label7.TabIndex = 15; + this.label7.Text = "n° COOLER"; + // + // nCooler + // + this.nCooler.Location = new System.Drawing.Point(719, 44); + this.nCooler.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nCooler.Name = "nCooler"; + this.nCooler.Size = new System.Drawing.Size(43, 22); + this.nCooler.TabIndex = 14; + this.nCooler.Text = "2"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(33, 80); + this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(72, 17); + this.label8.TabIndex = 17; + this.label8.Text = "n° PRESS"; + // + // nPress + // + this.nPress.Location = new System.Drawing.Point(121, 76); + this.nPress.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nPress.Name = "nPress"; + this.nPress.Size = new System.Drawing.Size(43, 22); + this.nPress.TabIndex = 16; + this.nPress.Text = "1"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(235, 80); + this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(64, 17); + this.label9.TabIndex = 19; + this.label9.Text = "n° TEMP"; + // + // nTempe + // + this.nTempe.Location = new System.Drawing.Point(323, 76); + this.nTempe.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nTempe.Name = "nTempe"; + this.nTempe.Size = new System.Drawing.Size(43, 22); + this.nTempe.TabIndex = 18; + this.nTempe.Text = "1"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(419, 80); + this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(63, 17); + this.label10.TabIndex = 21; + this.label10.Text = "n° PATH"; + // + // nPath + // + this.nPath.Location = new System.Drawing.Point(507, 76); + this.nPath.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nPath.Name = "nPath"; + this.nPath.Size = new System.Drawing.Size(43, 22); + this.nPath.TabIndex = 20; + this.nPath.Text = "1"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(631, 80); + this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(68, 17); + this.label11.TabIndex = 23; + this.label11.Text = "n° Un OP"; + // + // nUnOp + // + this.nUnOp.Location = new System.Drawing.Point(719, 76); + this.nUnOp.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nUnOp.Name = "nUnOp"; + this.nUnOp.Size = new System.Drawing.Size(43, 22); + this.nUnOp.TabIndex = 22; + this.nUnOp.Text = "1"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(33, 112); + this.label12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(52, 17); + this.label12.TabIndex = 25; + this.label12.Text = "n° Assi"; + // + // nAssi + // + this.nAssi.Location = new System.Drawing.Point(121, 108); + this.nAssi.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nAssi.Name = "nAssi"; + this.nAssi.Size = new System.Drawing.Size(43, 22); + this.nAssi.TabIndex = 24; + this.nAssi.Text = "1"; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(235, 116); + this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(86, 17); + this.label13.TabIndex = 27; + this.label13.Text = "n° MemArea"; + // + // nMemArea + // + this.nMemArea.Location = new System.Drawing.Point(323, 112); + this.nMemArea.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nMemArea.Name = "nMemArea"; + this.nMemArea.Size = new System.Drawing.Size(43, 22); + this.nMemArea.TabIndex = 26; + this.nMemArea.Text = "1"; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(631, 116); + this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(83, 17); + this.label14.TabIndex = 31; + this.label14.Text = "n° Prot Mag"; + // + // nProtMag + // + this.nProtMag.Location = new System.Drawing.Point(719, 112); + this.nProtMag.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nProtMag.Name = "nProtMag"; + this.nProtMag.Size = new System.Drawing.Size(43, 22); + this.nProtMag.TabIndex = 30; + this.nProtMag.Text = "0"; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(419, 116); + this.label15.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(72, 17); + this.label15.TabIndex = 29; + this.label15.Text = "n° Sli Mag"; + // + // nSlittaMag + // + this.nSlittaMag.Location = new System.Drawing.Point(507, 112); + this.nSlittaMag.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.nSlittaMag.Name = "nSlittaMag"; + this.nSlittaMag.Size = new System.Drawing.Size(43, 22); + this.nSlittaMag.TabIndex = 28; + this.nSlittaMag.Text = "0"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(33, 142); + this.label16.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(83, 17); + this.label16.TabIndex = 33; + this.label16.Text = "n° Contatori"; + // + // nContatori + // + this.nContatori.Location = new System.Drawing.Point(121, 138); + this.nContatori.Margin = new System.Windows.Forms.Padding(4); + this.nContatori.Name = "nContatori"; + this.nContatori.Size = new System.Drawing.Size(43, 22); + this.nContatori.TabIndex = 32; + this.nContatori.Text = "1"; + // + // SetupAdapter + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(923, 636); + this.Controls.Add(this.label16); + this.Controls.Add(this.nContatori); + this.Controls.Add(this.label14); + this.Controls.Add(this.nProtMag); + this.Controls.Add(this.label15); + this.Controls.Add(this.nSlittaMag); + this.Controls.Add(this.label13); + this.Controls.Add(this.nMemArea); + this.Controls.Add(this.label12); + this.Controls.Add(this.nAssi); + this.Controls.Add(this.label11); + this.Controls.Add(this.nUnOp); + this.Controls.Add(this.label10); + this.Controls.Add(this.nPath); + this.Controls.Add(this.label9); + this.Controls.Add(this.nTempe); + this.Controls.Add(this.label8); + this.Controls.Add(this.nPress); + this.Controls.Add(this.label7); + this.Controls.Add(this.nCooler); + this.Controls.Add(this.label6); + this.Controls.Add(this.nLubro); + this.Controls.Add(this.cbTipoAdapt); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.nVacAct); + this.Controls.Add(this.label3); + this.Controls.Add(this.nVacPump); + this.Controls.Add(this.btnLoad); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtFileName); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtAdapter); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Name = "SetupAdapter"; + this.Text = "Adapter Setup Manager"; + this.ResumeLayout(false); + this.PerformLayout(); } @@ -423,5 +479,7 @@ private System.Windows.Forms.TextBox nProtMag; private System.Windows.Forms.Label label15; private System.Windows.Forms.TextBox nSlittaMag; - } + private System.Windows.Forms.Label label16; + private System.Windows.Forms.TextBox nContatori; + } } \ No newline at end of file diff --git a/MTC_Adapter/MTC_Adapter/SetupAdapter.cs b/MTC_Adapter/MTC_Adapter/SetupAdapter.cs index c6b647c..f047861 100644 --- a/MTC_Adapter/MTC_Adapter/SetupAdapter.cs +++ b/MTC_Adapter/MTC_Adapter/SetupAdapter.cs @@ -6,543 +6,578 @@ using System.Windows.Forms; namespace MTC_Adapter { - public partial class SetupAdapter : Form + public partial class SetupAdapter : Form + { + public SetupAdapter() { - public SetupAdapter() - { - InitializeComponent(); + InitializeComponent(); - // fix icon! - this.Icon = Icon.ExtractAssociatedIcon(defIconFilePath); - } - protected string defIconFilePath - { - get - { - return string.Format(@"{0}\MTCA.ico", utils.resxDir); - } - } - /// - /// Percorso file completo - /// - protected string filePath - { - get - { - return string.Format("{0}/{1}", utils.CRS("dataConfPath"), txtFileName.Text); - } - } - - protected int numVacPump - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nVacPump.Text); - } - catch - { } - return answ; - } - set - { - nVacPump.Text = value.ToString(); - } - } - protected int numVacAct - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nVacAct.Text); - } - catch - { } - return answ; - } - set - { - nVacAct.Text = value.ToString(); - } - } - protected int numLubro - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nLubro.Text); - } - catch - { } - return answ; - } - set - { - nLubro.Text = value.ToString(); - } - } - protected int numCooler - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nCooler.Text); - } - catch - { } - return answ; - } - set - { - nCooler.Text = value.ToString(); - } - } - protected int numPress - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nPress.Text); - } - catch - { } - return answ; - } - set - { - nPress.Text = value.ToString(); - } - } - protected int numTemp - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nTempe.Text); - } - catch - { } - return answ; - } - set - { - nTempe.Text = value.ToString(); - } - } - protected int numPath - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nPath.Text); - } - catch - { } - return answ; - } - set - { - nPath.Text = value.ToString(); - } - } - protected int numUnOp - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nUnOp.Text); - } - catch - { } - return answ; - } - set - { - nUnOp.Text = value.ToString(); - } - } - protected int numAxis - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nAssi.Text); - } - catch - { } - return answ; - } - set - { - nAssi.Text = value.ToString(); - } - } - protected int numMemArea - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nMemArea.Text); - } - catch - { } - return answ; - } - set - { - nMemArea.Text = value.ToString(); - } - } - protected int numSlittaMag - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nSlittaMag.Text); - } - catch - { } - return answ; - } - set - { - nSlittaMag.Text = value.ToString(); - } - } - protected int numProtMag - { - get - { - int answ = 0; - try - { - answ = Convert.ToInt32(nProtMag.Text); - } - catch - { } - return answ; - } - set - { - nProtMag.Text = value.ToString(); - } - } - - protected element[] oAxisLoad { get; set; } - - private void btnCreateFile_Click(object sender, EventArgs e) - { - // creo un nuovo file adapter... - AdapterConf c = new AdapterConf(); - // nome da txtbox, vers 1 - c.NomeAdapt = txtAdapter.Text; - c.Version = 1; - // tipo da selettore - string valTipo = ""; - try - { - valTipo = cbTipoAdapt.SelectedItem.ToString().ToUpper(); - } - catch - { - valTipo = cbTipoAdapt.SelectedText; - } - switch (valTipo) - { - case "FANUC": - c.TipoAdapt = tipoAdapter.FANUC; - break; - case "OSAI": - c.TipoAdapt = tipoAdapter.OSAI; - break; - case "SIEMENS": - c.TipoAdapt = tipoAdapter.SIEMENS; - break; - case "HMI-ESA": - case "HMI_ESA": - case "ESAGV": - c.TipoAdapt = tipoAdapter.ESAGV; - break; - case "DEMO": - default: - c.TipoAdapt = tipoAdapter.DEMO; - break; - } - - // init lista parametri - List> listaDR; - - // MemArea - if (numMemArea > 0) - { - // creo elementi richiesti - element[] MemArea = new element[numMemArea]; - // ciclo x istanziare! - for (int i = 0; i < numMemArea; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - MemArea[i] = new element(string.Format("MemArea_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.MemArea = MemArea; - } - - // VAC PUMP - if (numVacPump > 0) - { - // creo elementi richiesti - element[] VacuumPump = new element[numVacPump]; - // ciclo x istanziare! - for (int i = 0; i < numVacPump; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - VacuumPump[i] = new element(string.Format("VacPump_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.VacuumPump = VacuumPump; - } - - // VACUUM ACT - if (numVacAct > 0) - { - // creo elementi richiesti - element[] VacuumAct = new element[numVacAct]; - // ciclo x istanziare! - for (int i = 0; i < numVacAct; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - VacuumAct[i] = new element(string.Format("VacAct_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.VacuumAct = VacuumAct; - } - - // LUBRO - if (numLubro > 0) - { - // creo elementi richiesti - element[] Lubro = new element[numLubro]; - // ciclo x istanziare! - for (int i = 0; i < numLubro; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - Lubro[i] = new element(string.Format("Lubro_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.Lubro = Lubro; - } - - // SlittaMag - if (numSlittaMag > 0) - { - // creo elementi richiesti - element[] SlittaMag = new element[numSlittaMag]; - // ciclo x istanziare! - for (int i = 0; i < numSlittaMag; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - SlittaMag[i] = new element(string.Format("SlittaMagazzino_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.SlittaMag = SlittaMag; - } - - // ProtMag - if (numProtMag > 0) - { - // creo elementi richiesti - element[] ProtMag = new element[numProtMag]; - // ciclo x istanziare! - for (int i = 0; i < numProtMag; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - ProtMag[i] = new element(string.Format("ProtMagazzino_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.ProtMag = ProtMag; - } - - // COOLER - if (numCooler > 0) - { - // creo elementi richiesti - element[] Cooler = new element[numCooler]; - // ciclo x istanziare! - for (int i = 0; i < numCooler; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - Cooler[i] = new element(string.Format("Cooler_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.Cooler = Cooler; - } - - // PRESS - if (numPress > 0) - { - // creo elementi richiesti - element[] Press = new element[numPress]; - // ciclo x istanziare! - for (int i = 0; i < numPress; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - Press[i] = new element(string.Format("Press_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.Press = Press; - } - - // TEMPERATURE - if (numTemp > 0) - { - // creo elementi richiesti - element[] Temp = new element[numTemp]; - // ciclo x istanziare! - for (int i = 0; i < numTemp; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - Temp[i] = new element(string.Format("Temp_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.Temp = Temp; - } - - // PATH - if (numPath > 0) - { - // creo elementi richiesti - element[] Path = new element[numPath]; - // ciclo x istanziare! - for (int i = 0; i < numPath; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - Path[i] = new element(string.Format("Path_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.Path = Path; - } - - // UNITA OPERATRICI - if (numUnOp > 0) - { - // creo elementi richiesti - element[] UnOp = new element[numUnOp]; - // ciclo x istanziare! - for (int i = 0; i < numUnOp; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - UnOp[i] = new element(string.Format("UnOp_{0:00}", i + 1), listaDR); - } - // salvo oggetto - c.UnOp = UnOp; - } - - // ASSI - if (numAxis > 0) - { - // creo elementi richiesti - element[] newAxis = new element[numAxis]; - // ciclo x istanziare! - for (int i = 0; i < numAxis; i++) - { - // inizializzo list x parametri - listaDR = new List>(); - // se ho un vettore di assi uso i valori già letti.. - if (oAxisLoad != null && oAxisLoad.Length > 0 && i < oAxisLoad.Length) - { - newAxis[i] = oAxisLoad[i]; - // se non ho tutto aggiungo... - if (newAxis[i].dataRefList.Count < 2) - { - // copio lista attuale - listaDR = newAxis[i].dataRefList; - // in base a cosa manca aggiunto... - if (listaDR.Count == 0) - { - // aggiungo tutto con valori default - listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Type", i + 1), "LINEAR")); - listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Grp", i + 1), "00")); - newAxis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); - } - else if (listaDR.Count == 1) - { - // aggiungo solo GRP con valori default, IPOTIZZO di avere solo type... - listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Grp", i + 1), "00")); - newAxis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); - } - } - } - else - { - // altrimenti popolo con valori default - listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Type", i + 1), "LINEAR")); - listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Grp", i + 1), "00")); - newAxis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); - } - } - // salvo oggetto - c.Axis = newAxis; - } - - // Serializzo oggetto conf su file - AdapterConf.Serialize(filePath, c); - } - - private void btnLoad_Click(object sender, EventArgs e) - { - // Read the configuration object from a file - AdapterConf objLoad = AdapterConf.Deserialize(filePath); - - txtAdapter.Text = objLoad.NomeAdapt; - cbTipoAdapt.SelectedText = objLoad.TipoAdapt.ToString(); - // carico valori da file.... - numVacPump = objLoad.nVacuumPump; - numVacAct = objLoad.nVacuumAct; - numLubro = objLoad.nLubro; - numCooler = objLoad.nCooler; - numPress = objLoad.nPress; - numTemp = objLoad.nTemp; - numPath = objLoad.nPath; - numUnOp = objLoad.nUnOp; - numAxis = objLoad.nAxis; - numMemArea = objLoad.nMemArea; - numSlittaMag = objLoad.nSlittaMag; - numProtMag = objLoad.nProtMag; - // salvo assi correnti... - oAxisLoad = objLoad.Axis; - } + // fix icon! + this.Icon = Icon.ExtractAssociatedIcon(defIconFilePath); } + protected string defIconFilePath + { + get + { + return string.Format(@"{0}\MTCA.ico", utils.resxDir); + } + } + /// + /// Percorso file completo + /// + protected string filePath + { + get + { + return string.Format("{0}/{1}", utils.CRS("dataConfPath"), txtFileName.Text); + } + } + + protected int numVacPump + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nVacPump.Text); + } + catch + { } + return answ; + } + set + { + nVacPump.Text = value.ToString(); + } + } + protected int numVacAct + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nVacAct.Text); + } + catch + { } + return answ; + } + set + { + nVacAct.Text = value.ToString(); + } + } + protected int numLubro + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nLubro.Text); + } + catch + { } + return answ; + } + set + { + nLubro.Text = value.ToString(); + } + } + protected int numCooler + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nCooler.Text); + } + catch + { } + return answ; + } + set + { + nCooler.Text = value.ToString(); + } + } + protected int numPress + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nPress.Text); + } + catch + { } + return answ; + } + set + { + nPress.Text = value.ToString(); + } + } + protected int numTemp + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nTempe.Text); + } + catch + { } + return answ; + } + set + { + nTempe.Text = value.ToString(); + } + } + protected int numPath + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nPath.Text); + } + catch + { } + return answ; + } + set + { + nPath.Text = value.ToString(); + } + } + protected int numUnOp + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nUnOp.Text); + } + catch + { } + return answ; + } + set + { + nUnOp.Text = value.ToString(); + } + } + protected int numAxis + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nAssi.Text); + } + catch + { } + return answ; + } + set + { + nAssi.Text = value.ToString(); + } + } + protected int numCounters + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nContatori.Text); + } + catch + { } + return answ; + } + set + { + nContatori.Text = value.ToString(); + } + } + protected int numMemArea + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nMemArea.Text); + } + catch + { } + return answ; + } + set + { + nMemArea.Text = value.ToString(); + } + } + protected int numSlittaMag + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nSlittaMag.Text); + } + catch + { } + return answ; + } + set + { + nSlittaMag.Text = value.ToString(); + } + } + protected int numProtMag + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nProtMag.Text); + } + catch + { } + return answ; + } + set + { + nProtMag.Text = value.ToString(); + } + } + + protected element[] oAxisLoad { get; set; } + + private void btnCreateFile_Click(object sender, EventArgs e) + { + // creo un nuovo file adapter... + AdapterConf c = new AdapterConf(); + // nome da txtbox, vers 1 + c.NomeAdapt = txtAdapter.Text; + c.Version = 1; + // tipo da selettore + string valTipo = ""; + try + { + valTipo = cbTipoAdapt.SelectedItem.ToString().ToUpper(); + } + catch + { + valTipo = cbTipoAdapt.SelectedText; + } + switch (valTipo) + { + case "FANUC": + c.TipoAdapt = tipoAdapter.FANUC; + break; + case "OSAI": + c.TipoAdapt = tipoAdapter.OSAI; + break; + case "SIEMENS": + c.TipoAdapt = tipoAdapter.SIEMENS; + break; + case "HMI-ESA": + case "HMI_ESA": + case "ESAGV": + c.TipoAdapt = tipoAdapter.ESAGV; + break; + case "DEMO": + default: + c.TipoAdapt = tipoAdapter.DEMO; + break; + } + + // init lista parametri + List> listaDR; + + // MemArea + if (numMemArea > 0) + { + // creo elementi richiesti + element[] MemArea = new element[numMemArea]; + // ciclo x istanziare! + for (int i = 0; i < numMemArea; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + MemArea[i] = new element(string.Format("MemArea_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.MemArea = MemArea; + } + + // VAC PUMP + if (numVacPump > 0) + { + // creo elementi richiesti + element[] VacuumPump = new element[numVacPump]; + // ciclo x istanziare! + for (int i = 0; i < numVacPump; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + VacuumPump[i] = new element(string.Format("VacPump_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.VacuumPump = VacuumPump; + } + + // VACUUM ACT + if (numVacAct > 0) + { + // creo elementi richiesti + element[] VacuumAct = new element[numVacAct]; + // ciclo x istanziare! + for (int i = 0; i < numVacAct; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + VacuumAct[i] = new element(string.Format("VacAct_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.VacuumAct = VacuumAct; + } + + // LUBRO + if (numLubro > 0) + { + // creo elementi richiesti + element[] Lubro = new element[numLubro]; + // ciclo x istanziare! + for (int i = 0; i < numLubro; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + Lubro[i] = new element(string.Format("Lubro_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.Lubro = Lubro; + } + + // Contatori + if (numCounters > 0) + { + // creo elementi richiesti + element[] Counters = new element[numCounters]; + // ciclo x istanziare! + for (int i = 0; i < numCounters; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + Counters[i] = new element(string.Format("Counter_{0:000}", i + 1), listaDR); + } + // salvo oggetto + c.Counters = Counters; + } + + // SlittaMag + if (numSlittaMag > 0) + { + // creo elementi richiesti + element[] SlittaMag = new element[numSlittaMag]; + // ciclo x istanziare! + for (int i = 0; i < numSlittaMag; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + SlittaMag[i] = new element(string.Format("SlittaMagazzino_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.SlittaMag = SlittaMag; + } + + // ProtMag + if (numProtMag > 0) + { + // creo elementi richiesti + element[] ProtMag = new element[numProtMag]; + // ciclo x istanziare! + for (int i = 0; i < numProtMag; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + ProtMag[i] = new element(string.Format("ProtMagazzino_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.ProtMag = ProtMag; + } + + // COOLER + if (numCooler > 0) + { + // creo elementi richiesti + element[] Cooler = new element[numCooler]; + // ciclo x istanziare! + for (int i = 0; i < numCooler; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + Cooler[i] = new element(string.Format("Cooler_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.Cooler = Cooler; + } + + // PRESS + if (numPress > 0) + { + // creo elementi richiesti + element[] Press = new element[numPress]; + // ciclo x istanziare! + for (int i = 0; i < numPress; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + Press[i] = new element(string.Format("Press_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.Press = Press; + } + + // TEMPERATURE + if (numTemp > 0) + { + // creo elementi richiesti + element[] Temp = new element[numTemp]; + // ciclo x istanziare! + for (int i = 0; i < numTemp; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + Temp[i] = new element(string.Format("Temp_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.Temp = Temp; + } + + // PATH + if (numPath > 0) + { + // creo elementi richiesti + element[] Path = new element[numPath]; + // ciclo x istanziare! + for (int i = 0; i < numPath; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + Path[i] = new element(string.Format("Path_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.Path = Path; + } + + // UNITA OPERATRICI + if (numUnOp > 0) + { + // creo elementi richiesti + element[] UnOp = new element[numUnOp]; + // ciclo x istanziare! + for (int i = 0; i < numUnOp; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + UnOp[i] = new element(string.Format("UnOp_{0:00}", i + 1), listaDR); + } + // salvo oggetto + c.UnOp = UnOp; + } + + // ASSI + if (numAxis > 0) + { + // creo elementi richiesti + element[] newAxis = new element[numAxis]; + // ciclo x istanziare! + for (int i = 0; i < numAxis; i++) + { + // inizializzo list x parametri + listaDR = new List>(); + // se ho un vettore di assi uso i valori già letti.. + if (oAxisLoad != null && oAxisLoad.Length > 0 && i < oAxisLoad.Length) + { + newAxis[i] = oAxisLoad[i]; + // se non ho tutto aggiungo... + if (newAxis[i].dataRefList.Count < 2) + { + // copio lista attuale + listaDR = newAxis[i].dataRefList; + // in base a cosa manca aggiunto... + if (listaDR.Count == 0) + { + // aggiungo tutto con valori default + listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Type", i + 1), "LINEAR")); + listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Grp", i + 1), "00")); + newAxis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); + } + else if (listaDR.Count == 1) + { + // aggiungo solo GRP con valori default, IPOTIZZO di avere solo type... + listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Grp", i + 1), "00")); + newAxis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); + } + } + } + else + { + // altrimenti popolo con valori default + listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Type", i + 1), "LINEAR")); + listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Grp", i + 1), "00")); + newAxis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); + } + } + // salvo oggetto + c.Axis = newAxis; + } + + // Serializzo oggetto conf su file + AdapterConf.Serialize(filePath, c); + } + + private void btnLoad_Click(object sender, EventArgs e) + { + // Read the configuration object from a file + AdapterConf objLoad = AdapterConf.Deserialize(filePath); + + txtAdapter.Text = objLoad.NomeAdapt; + cbTipoAdapt.SelectedText = objLoad.TipoAdapt.ToString(); + // carico valori da file.... + numVacPump = objLoad.nVacuumPump; + numVacAct = objLoad.nVacuumAct; + numLubro = objLoad.nLubro; + numCooler = objLoad.nCooler; + numPress = objLoad.nPress; + numTemp = objLoad.nTemp; + numPath = objLoad.nPath; + numUnOp = objLoad.nUnOp; + numAxis = objLoad.nAxis; + numMemArea = objLoad.nMemArea; + numSlittaMag = objLoad.nSlittaMag; + numCounters = objLoad.nCounters; + numProtMag = objLoad.nProtMag; + // salvo assi correnti... + oAxisLoad = objLoad.Axis; + } + } }