From eb0072bcffdad4c8cd209ccb208f73b8ba053c48 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 22 Apr 2016 12:20:47 +0200 Subject: [PATCH] aggiunti assi generato CONF XML adapter demo completo --- MTC_Sim/.vs/MTC_Sim/v14/.suo | Bin 126976 -> 126976 bytes MTC_Sim/MTC_Sim/AdapterConf.cs | 10 +- MTC_Sim/MTC_Sim/AdapterConf/Demo.xml | 589 ++++++++++++++++++++++- MTC_Sim/MTC_Sim/AdapterGeneric.cs | 59 +-- MTC_Sim/MTC_Sim/SetupAdapter.Designer.cs | 23 + MTC_Sim/MTC_Sim/SetupAdapter.cs | 43 ++ 6 files changed, 682 insertions(+), 42 deletions(-) diff --git a/MTC_Sim/.vs/MTC_Sim/v14/.suo b/MTC_Sim/.vs/MTC_Sim/v14/.suo index 126808b5897fbae141785550881f4c001be513e2..74fb05142f19b70bed981e8eee445490c2e9bc41 100644 GIT binary patch delta 392 zcmZp8z~1nHeS*RC4-$-=5&{ei;tUK7%s~9_|Ns9$ih&V`RW=4nGqEac@p)ahxsd5M zGpj%%&&#^zLbmONY>ck{(kc4kQ8D$sp}#AlfffGIC6Rm&K^Dowt(Fky+3OZUzIxeIT1}di)ATrR|M1 Xj2&_V?2Z~nd8YM=+Z$FeHn;--BXVOJ delta 420 zcmZp8z~1nHeS(1^69W_oFfa%Mnan`^@Bjb*AW;xoa$}%06YB!T$?1ig3z>d1vli$- zKUdgX$hN(ZjnUPAdRG|ZEyhdJ8FLtyOg~q`sL%Ka#Gbt^f{}}FS`Op&>4C+JS20vg zH>hHKvfU$#@gR$sJR`_15a2j)7|3P?vRrO~Oqn}9uYgf-``LWP05(Ce3Mf$vq$RfN zl`;Nd6k~>K|FGW@$W8@mKLgQzp^}kf`nxPfjqSXZjE>BL_DF_g1KBLo<7*h@r#BWe i=50S$#VEqKt&WjXmYOay2D-?XR2M02Z(PAx?+yUK;$;E= diff --git a/MTC_Sim/MTC_Sim/AdapterConf.cs b/MTC_Sim/MTC_Sim/AdapterConf.cs index f7d1be3..949a629 100644 --- a/MTC_Sim/MTC_Sim/AdapterConf.cs +++ b/MTC_Sim/MTC_Sim/AdapterConf.cs @@ -31,8 +31,7 @@ namespace MTC_Sim element[] _Temp; element[] _Path; element[] _UnOp; - - int nAxis; + element[] _Axis; /// /// init conf adapter @@ -41,8 +40,6 @@ namespace MTC_Sim { sNomeAdapt = ""; etipoAdapt = tipoAdapter.Demo; - - nAxis = 0; } /// /// Serializzazione XML dell'oggetto conf dell'adapter @@ -125,6 +122,11 @@ namespace MTC_Sim get { return _UnOp; } set { _UnOp = value; } } + public element[] Axis + { + get { return _Axis; } + set { _Axis= value; } + } } diff --git a/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml b/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml index 455d5f8..fe53240 100644 --- a/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml +++ b/MTC_Sim/MTC_Sim/AdapterConf/Demo.xml @@ -1,6 +1,589 @@ - + + Demo 1 - CMS_ADAPTER_ABC - 2456 + CMS_ADAPTER_00 + Demo + + + VacPump_01 + Pompa 1 + Random + + + Status + 0#7 + + + + + VacPump_02 + Pompa 2 + Random + + + Status + 0#7 + + + + + + + VacAct_01 + Attuatore vuoto 1 + Random + + + Count + 0#15 + + + + + VacAct_02 + Attuatore vuoto 2 + Random + + + Count + 0#15 + + + + + + + Lubro_01 + Lubrorefrigerante 1 + Random + + + Num + 0#15 + + + + + Lubro_02 + Lubrorefrigerante 2 + Random + + + Num + 0#15 + + + + + + + Cooler_01 + Cooler 1 + Random + + + Status + 0#3 + + + + + Cooler_02 + Cooler 2 + Random + + + Status + 0#3 + + + + + + + Press_01 + Pressostato 1 + Random + + + Value + 0#7 + + + + + Press_02 + Pressostato 2 + Random + + + Value + 0#7 + + + + + + + Temp_01 + Sonda Temperatura 1 + Random + + + Value + 0#7 + + + + + Temp_02 + Sonda Temperatura 2 + Random + + + Value + 0#7 + + + + + + + Path_01 + Path num 1 + Random + + + FeedRate + 0#15 + + + FeedOverr + 16#31 + + + SpeedOverr + 32#47 + + + PosActX + 48#63 + + + PosActY + 64#79 + + + PosActZ + 80#95 + + + PosActI + 96#111 + + + PosActJ + 112#127 + + + PosActK + 128#143 + + + + + + + UnOp_01 + Unita Op num 1 + Random + + + ToolId + 0#7 + + + NumCU + 8#15 + + + Status + 16#23 + + + VitaRes + 24#31 + + + Speed + 32#39 + + + Load + 40#47 + + + AccTime + 48#55 + + + + + + + Axis_01 + Asse num 1 + Random + + + MainProc + 0#7 + + + IsMast + 8#15 + + + MastId + 16#23 + + + Type + 24#31 + + + Dir + 32#39 + + + Load + 40#47 + + + PosAct + 48#55 + + + PosTgt + 56#63 + + + FeedAct + 64#71 + + + FeedOver + 72#79 + + + AccelAct + 80#87 + + + AccTime + 88#95 + + + Battery + 96#103 + + + + + Axis_02 + Asse num 2 + Random + + + MainProc + 0#7 + + + IsMast + 8#15 + + + MastId + 16#23 + + + Type + 24#31 + + + Dir + 32#39 + + + Load + 40#47 + + + PosAct + 48#55 + + + PosTgt + 56#63 + + + FeedAct + 64#71 + + + FeedOver + 72#79 + + + AccelAct + 80#87 + + + AccTime + 88#95 + + + Battery + 96#103 + + + + + Axis_03 + Asse num 3 + Random + + + MainProc + 0#7 + + + IsMast + 8#15 + + + MastId + 16#23 + + + Type + 24#31 + + + Dir + 32#39 + + + Load + 40#47 + + + PosAct + 48#55 + + + PosTgt + 56#63 + + + FeedAct + 64#71 + + + FeedOver + 72#79 + + + AccelAct + 80#87 + + + AccTime + 88#95 + + + Battery + 96#103 + + + + + Axis_04 + Asse num 4 + Random + + + MainProc + 0#7 + + + IsMast + 8#15 + + + MastId + 16#23 + + + Type + 24#31 + + + Dir + 32#39 + + + Load + 40#47 + + + PosAct + 48#55 + + + PosTgt + 56#63 + + + FeedAct + 64#71 + + + FeedOver + 72#79 + + + AccelAct + 80#87 + + + AccTime + 88#95 + + + Battery + 96#103 + + + + + Axis_05 + Asse num 5 + Random + + + MainProc + 0#7 + + + IsMast + 8#15 + + + MastId + 16#23 + + + Type + 24#31 + + + Dir + 32#39 + + + Load + 40#47 + + + PosAct + 48#55 + + + PosTgt + 56#63 + + + FeedAct + 64#71 + + + FeedOver + 72#79 + + + AccelAct + 80#87 + + + AccTime + 88#95 + + + Battery + 96#103 + + + + + Axis_06 + Asse num 6 + Random + + + MainProc + 0#7 + + + IsMast + 8#15 + + + MastId + 16#23 + + + Type + 24#31 + + + Dir + 32#39 + + + Load + 40#47 + + + PosAct + 48#55 + + + PosTgt + 56#63 + + + FeedAct + 64#71 + + + FeedOver + 72#79 + + + AccelAct + 80#87 + + + AccTime + 88#95 + + + Battery + 96#103 + + + + \ No newline at end of file diff --git a/MTC_Sim/MTC_Sim/AdapterGeneric.cs b/MTC_Sim/MTC_Sim/AdapterGeneric.cs index 51ffde3..672a5b5 100644 --- a/MTC_Sim/MTC_Sim/AdapterGeneric.cs +++ b/MTC_Sim/MTC_Sim/AdapterGeneric.cs @@ -346,22 +346,8 @@ namespace MTC_Sim /// /// Asse singolo, 1..n /// - public class Axis + public class Axis : element { - /// - /// Id univoco - /// - protected string idx; - /// - /// Descrizione/Alias - /// - protected string descr; - - - /// - /// ID - /// - public Event mAxId; /// /// Descrizione / Alias /// @@ -424,29 +410,32 @@ namespace MTC_Sim /// /// Classe Asse con relativo ID UNIVOCO ed alias /// - /// Identificativo misura, codice sarà Ax_{0} dove {0}= ident - /// Alias misura, salvato in event Ax_{0}_alias dove {0}=ident - public Axis(string ident, string alias) + /// Identificativo univoco + /// Alias/descrizione + /// Tipo fonte dati + /// Parametri x recupero dati in forma dictionary + public Axis(string Idx, string Alias, fonteDati FonteD, List> DataRefList) { - idx = ident; - descr = alias; + ident = Idx; + alias = Alias; + fonte = FonteD; + dataRefList = DataRefList; // inizializzo vari eventi, sample, condizioni - mAxId = new Event(string.Format("Ax_{0}_ID", idx)); - mAxAlias = new Event(string.Format("Ax_{0}_Alias", idx)); - mAxMainProc = new Event(string.Format("Ax_{0}_MainProc", idx)); - mAxIsMaster = new Event(string.Format("Ax_{0}_IsMast", idx)); - mAxMastId = new Event(string.Format("Ax_{0}_MastId", idx)); - mAxType = new Event(string.Format("Ax_{0}_Type", idx)); - mAxDir = new Sample(string.Format("Ax_{0}_Dir", idx)); - mAxLoad = new Sample(string.Format("Ax_{0}_Load", idx)); - mAxPosAct = new Sample(string.Format("Ax_{0}_PosAct", idx)); - mAxPosTgt = new Sample(string.Format("Ax_{0}_PosTgt", idx)); - mAxFeedAct = new Sample(string.Format("Ax_{0}_FeedAct", idx)); - mAxFeedOver = new Sample(string.Format("Ax_{0}_FeedOver", idx)); - mAxAccelAct = new Sample(string.Format("Ax_{0}_AccelAct", idx)); - mAxAccTime = new Sample(string.Format("Ax_{0}_AccTime", idx)); - mAxBattery = new Sample(string.Format("Ax_{0}_Battery", idx)); + mAxAlias = new Event(string.Format("{0}_Alias", Idx)); + mAxMainProc = new Event(string.Format("{0}_MainProc", Idx)); + mAxIsMaster = new Event(string.Format("{0}_IsMast", Idx)); + mAxMastId = new Event(string.Format("{0}_MastId", Idx)); + mAxType = new Event(string.Format("{0}_Type", Idx)); + mAxDir = new Sample(string.Format("{0}_Dir", Idx)); + mAxLoad = new Sample(string.Format("{0}_Load", Idx)); + mAxPosAct = new Sample(string.Format("{0}_PosAct", Idx)); + mAxPosTgt = new Sample(string.Format("{0}_PosTgt", Idx)); + mAxFeedAct = new Sample(string.Format("{0}_FeedAct", Idx)); + mAxFeedOver = new Sample(string.Format("{0}_FeedOver", Idx)); + mAxAccelAct = new Sample(string.Format("{0}_AccelAct", Idx)); + mAxAccTime = new Sample(string.Format("{0}_AccTime", Idx)); + mAxBattery = new Sample(string.Format("{0}_Battery", Idx)); } } diff --git a/MTC_Sim/MTC_Sim/SetupAdapter.Designer.cs b/MTC_Sim/MTC_Sim/SetupAdapter.Designer.cs index 8a036ed..f404b02 100644 --- a/MTC_Sim/MTC_Sim/SetupAdapter.Designer.cs +++ b/MTC_Sim/MTC_Sim/SetupAdapter.Designer.cs @@ -52,6 +52,8 @@ 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.SuspendLayout(); // // txtAdapter @@ -266,11 +268,30 @@ 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"; + // // 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.label12); + this.Controls.Add(this.nAssi); this.Controls.Add(this.label11); this.Controls.Add(this.nUnOp); this.Controls.Add(this.label10); @@ -328,5 +349,7 @@ private System.Windows.Forms.TextBox nPath; private System.Windows.Forms.Label label11; private System.Windows.Forms.TextBox nUnOp; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox nAssi; } } \ No newline at end of file diff --git a/MTC_Sim/MTC_Sim/SetupAdapter.cs b/MTC_Sim/MTC_Sim/SetupAdapter.cs index 29b6d54..db24fe0 100644 --- a/MTC_Sim/MTC_Sim/SetupAdapter.cs +++ b/MTC_Sim/MTC_Sim/SetupAdapter.cs @@ -139,6 +139,20 @@ namespace MTC_Sim return answ; } } + int numAxis + { + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(nAssi.Text); + } + catch + { } + return answ; + } + } private void btnCreateFile_Click(object sender, EventArgs e) { @@ -315,6 +329,35 @@ namespace MTC_Sim c.UnOp = UnOp; } + // UNITA OPERATRICI + if (numAxis > 0) + { + // creo elementi richiesti + element[] Axis = new element[numAxis]; + // inizializzo list x parametri + listaDR = new List>(); + listaDR.Add(new DataRefItem("MainProc", "0#7")); + listaDR.Add(new DataRefItem("IsMast", "8#15")); + listaDR.Add(new DataRefItem("MastId", "16#23")); + listaDR.Add(new DataRefItem("Type", "24#31")); + listaDR.Add(new DataRefItem("Dir", "32#39")); + listaDR.Add(new DataRefItem("Load", "40#47")); + listaDR.Add(new DataRefItem("PosAct", "48#55")); + listaDR.Add(new DataRefItem("PosTgt", "56#63")); + listaDR.Add(new DataRefItem("FeedAct", "64#71")); + listaDR.Add(new DataRefItem("FeedOver", "72#79")); + listaDR.Add(new DataRefItem("AccelAct", "80#87")); + listaDR.Add(new DataRefItem("AccTime", "88#95")); + listaDR.Add(new DataRefItem("Battery", "96#103")); + // ciclo x istanziare! + for (int i = 0; i < numAxis; i++) + { + Axis[i] = new element(string.Format("Axis_{0:00}", i + 1), string.Format("Asse num {0}", i + 1), fonteDati.Random, listaDR); + } + // salvo oggetto + c.Axis = Axis; + } + // Serializzo oggetto conf su file AdapterConf.Serialize(filePath, c);