From e1c80500674d0e8f3dcf12f16126f593a67fa1e7 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 6 Apr 2017 15:11:56 +0200 Subject: [PATCH] Gestione nuova conf x Axis: comprende gruppo, e permette di caricare e salvare tenendo info base x assi... Aggiornata definizione base x AdapterItemList.xml di KVARA --- MTC_Adapter/MTC_Adapter/AdapterESA.cs | 21 ++++++ MTC_Adapter/MTC_Adapter/AdapterGeneric.cs | 38 +++++++++- .../DATA/CONF/Adapter_ItemList.xml | 60 ++++++++++++++++ .../Resources/SCM/IOT_DWordList.map | 5 +- .../MTC_Adapter/Resources/SCM/SCM_ESA.xml | 60 ++++++++++++++++ MTC_Adapter/MTC_Adapter/SetupAdapter.cs | 70 ++++++++++++++----- 6 files changed, 232 insertions(+), 22 deletions(-) diff --git a/MTC_Adapter/MTC_Adapter/AdapterESA.cs b/MTC_Adapter/MTC_Adapter/AdapterESA.cs index 3b5f864..d2e21dc 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterESA.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterESA.cs @@ -802,6 +802,27 @@ namespace MTC_Adapter { FeedRate = BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0); } + else if (mapIOT_DWord[i].varName.StartsWith("IOT_FEED_")) + { + // recupero NUMERO + try + { + numero = Convert.ToInt32(mapIOT_DWord[i].varName.Replace("IOT_FEED_", "")); + // salvo in vettore SE possibile... + if (numero <= FeedRateGrp.Length) + { + FeedRateGrp[numero - 1] = BitConverter.ToInt32(BitConverter.GetBytes(ncDevice.PLC_MemoryAreaIOT_DWord[byteNum]), 0); + } + else + { + lg.Error("Errore in inserimento vettore " + mapIOT_DWord[i].varName); + } + } + catch (Exception exc) + { + lg.Error(exc, "Errore in decodifica " + mapIOT_DWord[i].varName); + } + } else if (mapIOT_DWord[i].varName.StartsWith("IOT_C_KU_AX_")) { // recupero NUMERO diff --git a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs index f88b6e3..9ce7ca4 100644 --- a/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs +++ b/MTC_Adapter/MTC_Adapter/AdapterGeneric.cs @@ -416,6 +416,10 @@ namespace MTC_Adapter /// public Event mAxMastId; /// + /// Gruppo di appartenenza dell'asse + /// + public Event mAxGrp; + /// /// Event tipo asse: lineare, rotazionale... /// public Event mAxType; @@ -478,10 +482,31 @@ namespace MTC_Adapter public Axis(element baseElem) { ident = baseElem.ident; + // valori da conf esplicita dataRefList = baseElem.dataRefList; + try + { + mAxType = new Event(dataRefList[0].Key); + mAxType.Value = dataRefList[0].Value; + } + catch + { + mAxType = new Event(string.Format("{0}_Type", ident)); + mAxType.Value = "LINEAR"; - mAxType = new Event(dataRefList[0].Key); - mAxType.Value = dataRefList[0].Value; + } + try + { + mAxGrp = new Event(dataRefList[1].Key); + mAxGrp.Value = dataRefList[1].Value; + } + catch + { + mAxGrp = new Event(string.Format("{0}_Grp", ident)); + mAxGrp.Value = "00"; + + } + // valori standard mAxMainProc = new MTConnect.Message(string.Format("{0}_MainProc", ident)); mAxIsMaster = new MTConnect.Message(string.Format("{0}_IsMast", ident)); mAxMastId = new Event(string.Format("{0}_MastId", ident)); @@ -951,7 +976,10 @@ namespace MTC_Adapter currAdpConf = adpConf; - // salvo al form chiamante + // inizializzo vettore gruppi assi, MAX 20!!! + FeedRateGrp = new int[20]; + + // salvo il form chiamante parentForm = caller; // item disponibilità @@ -1917,6 +1945,10 @@ namespace MTC_Adapter /// public int FeedRate { get; set; } /// + /// FeedRate di gruppo MAX 20!!! + /// + public int[] FeedRateGrp { get; set; } + /// /// SpeedRate mandrino globale /// public int SpeedRate { get; set; } diff --git a/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml b/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml index 2ec34fc..7e6ab10 100644 --- a/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml +++ b/MTC_Adapter/MTC_Adapter/DATA/CONF/Adapter_ItemList.xml @@ -121,6 +121,10 @@ Axis_01_Type LINEAR + + Axis_01_Grp + 00 + @@ -130,6 +134,10 @@ Axis_02_Type LINEAR + + Axis_02_Grp + 00 + @@ -139,6 +147,10 @@ Axis_03_Type LINEAR + + Axis_03_Grp + 00 + @@ -148,6 +160,10 @@ Axis_04_Type ROTARY + + Axis_04_Grp + 00 + @@ -157,6 +173,10 @@ Axis_05_Type ROTARY + + Axis_05_Grp + 00 + @@ -166,6 +186,10 @@ Axis_06_Type LINEAR + + Axis_06_Grp + 00 + @@ -175,6 +199,10 @@ Axis_07_Type LINEAR + + Axis_07_Grp + 00 + @@ -184,6 +212,10 @@ Axis_08_Type LINEAR + + Axis_08_Grp + 00 + @@ -193,6 +225,10 @@ Axis_09_Type LINEAR + + Axis_09_Grp + 00 + @@ -202,6 +238,10 @@ Axis_10_Type LINEAR + + Axis_10_Grp + 00 + @@ -211,6 +251,10 @@ Axis_11_Type LINEAR + + Axis_11_Grp + 00 + @@ -220,6 +264,10 @@ Axis_12_Type LINEAR + + Axis_12_Grp + 00 + @@ -229,6 +277,10 @@ Axis_13_Type LINEAR + + Axis_13_Grp + 00 + @@ -238,6 +290,10 @@ Axis_14_Type LINEAR + + Axis_14_Grp + 00 + @@ -247,6 +303,10 @@ Axis_15_Type LINEAR + + Axis_15_Grp + 00 + diff --git a/MTC_Adapter/MTC_Adapter/Resources/SCM/IOT_DWordList.map b/MTC_Adapter/MTC_Adapter/Resources/SCM/IOT_DWordList.map index 98a6fef..792a083 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/SCM/IOT_DWordList.map +++ b/MTC_Adapter/MTC_Adapter/Resources/SCM/IOT_DWordList.map @@ -65,4 +65,7 @@ 063|IOT_PLC_MSG_10 |DWORD 064|IOT_PLC_MSG_11 |DWORD 065|IOT_PLC_MSG_12 |DWORD -066|IOT_FEED |DWORD \ No newline at end of file +066|IOT_FEED |DWORD +067|IOT_FEED_01 |DWORD +068|IOT_FEED_02 |DWORD +069|IOT_FEED_03 |DWORD \ No newline at end of file diff --git a/MTC_Adapter/MTC_Adapter/Resources/SCM/SCM_ESA.xml b/MTC_Adapter/MTC_Adapter/Resources/SCM/SCM_ESA.xml index 2ec34fc..7e6ab10 100644 --- a/MTC_Adapter/MTC_Adapter/Resources/SCM/SCM_ESA.xml +++ b/MTC_Adapter/MTC_Adapter/Resources/SCM/SCM_ESA.xml @@ -121,6 +121,10 @@ Axis_01_Type LINEAR + + Axis_01_Grp + 00 + @@ -130,6 +134,10 @@ Axis_02_Type LINEAR + + Axis_02_Grp + 00 + @@ -139,6 +147,10 @@ Axis_03_Type LINEAR + + Axis_03_Grp + 00 + @@ -148,6 +160,10 @@ Axis_04_Type ROTARY + + Axis_04_Grp + 00 + @@ -157,6 +173,10 @@ Axis_05_Type ROTARY + + Axis_05_Grp + 00 + @@ -166,6 +186,10 @@ Axis_06_Type LINEAR + + Axis_06_Grp + 00 + @@ -175,6 +199,10 @@ Axis_07_Type LINEAR + + Axis_07_Grp + 00 + @@ -184,6 +212,10 @@ Axis_08_Type LINEAR + + Axis_08_Grp + 00 + @@ -193,6 +225,10 @@ Axis_09_Type LINEAR + + Axis_09_Grp + 00 + @@ -202,6 +238,10 @@ Axis_10_Type LINEAR + + Axis_10_Grp + 00 + @@ -211,6 +251,10 @@ Axis_11_Type LINEAR + + Axis_11_Grp + 00 + @@ -220,6 +264,10 @@ Axis_12_Type LINEAR + + Axis_12_Grp + 00 + @@ -229,6 +277,10 @@ Axis_13_Type LINEAR + + Axis_13_Grp + 00 + @@ -238,6 +290,10 @@ Axis_14_Type LINEAR + + Axis_14_Grp + 00 + @@ -247,6 +303,10 @@ Axis_15_Type LINEAR + + Axis_15_Grp + 00 + diff --git a/MTC_Adapter/MTC_Adapter/SetupAdapter.cs b/MTC_Adapter/MTC_Adapter/SetupAdapter.cs index ff811c2..d970081 100644 --- a/MTC_Adapter/MTC_Adapter/SetupAdapter.cs +++ b/MTC_Adapter/MTC_Adapter/SetupAdapter.cs @@ -219,6 +219,8 @@ namespace MTC_Adapter } } + protected element[] oAxisLoad { get; set; } + private void btnCreateFile_Click(object sender, EventArgs e) { // creo un nuovo file adapter... @@ -406,17 +408,47 @@ namespace MTC_Adapter if (numAxis > 0) { // creo elementi richiesti - element[] Axis = new element[numAxis]; + element[] newAxis = new element[numAxis]; // ciclo x istanziare! for (int i = 0; i < numAxis; i++) { // inizializzo list x parametri listaDR = new List>(); - listaDR.Add(new DataRefItem(string.Format("Axis_{0:00}_Type", i + 1), "LINEAR")); - Axis[i] = new element(string.Format("Axis_{0:00}", i + 1), listaDR); + // 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 = Axis; + c.Axis = newAxis; } // Serializzo oggetto conf su file @@ -426,21 +458,23 @@ namespace MTC_Adapter private void btnLoad_Click(object sender, EventArgs e) { // Read the configuration object from a file - AdapterConf c2 = AdapterConf.Deserialize(filePath); + AdapterConf objLoad = AdapterConf.Deserialize(filePath); - txtAdapter.Text = c2.NomeAdapt; - cbTipoAdapt.SelectedText = c2.TipoAdapt.ToString(); - //cbTipoAdapt.SelectedItem = c2.TipoAdapt; - 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; - numMemArea = c2.nMemArea; + txtAdapter.Text = objLoad.NomeAdapt; + cbTipoAdapt.SelectedText = objLoad.TipoAdapt.ToString(); + //cbTipoAdapt.Refresh(); + 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; + // salvo assi correnti... + oAxisLoad = objLoad.Axis; } } }