From 33e55abe7d64c7f4f0fa5d0c15b1a5b01d52b661 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 1 Apr 2016 18:46:25 +0200 Subject: [PATCH] completata gestione strobe x recupero dati MST --- MTC_Sim/.vs/MTC_Sim/v14/.suo | Bin 99328 -> 100352 bytes MTC_Sim/MTC_Sim/App.config | 1 + MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs | 286 ++++++++++++----- MTC_Sim/MTC_Sim/CMS_MachineSim.cs | 351 ++++++++++++++++++--- MTC_Sim/MTC_Sim/utils.cs | 62 ++++ 5 files changed, 580 insertions(+), 120 deletions(-) diff --git a/MTC_Sim/.vs/MTC_Sim/v14/.suo b/MTC_Sim/.vs/MTC_Sim/v14/.suo index 3f5a7b44bc7a0db6a69c58e97cc1e2bad4fe9cda..b72db5b44c7749d2f41d2ccd1711c1bd9de76e05 100644 GIT binary patch delta 4359 zcmc&%e^Aud5&!OS2giBf9UO3i90wdHf*`+)C=kDRfJFJNA!v;e6$M4EDmMv?>0Qi^ z<`0vB+mz=_>`Y8LYSNAcj`pUe(bGCkGSm8_rcSg?YtzJOJCi0&xrs5Uboa}hBL2uE zlbPDjWJk%~ z^I+k=I_y{V!z>J{+>tA(yxi5)iEHV2glH5Jxt*3f>^mHm8=+Pt5re)u&8qcT%7$q=4r;S`-?E*fl3shmB{ z$j-l*Vv8X?I@Gq3)DWkJ+UX=sgUu_9wvd5$Sw{Sf?_=!@P`gRRucEDLo(-)!tHB7A zF5-A%#n_}X;qyA%0&dvIm_=+4b!L;COPmvG&m);foKHNTZ6oat@aoHz1aV}n(v??m zq%eQGh_Su!Cc0wXa1?{|`zv(KJgeuAOpz7BL6c3>Pli3%XILI1>8ADJxS>fui;Q7J z@BnxWT}C%Nib11W(@32*?2BvEPK^n57)*4-3Unp8BRQwuXuNLh*E}-mop`%r+7qWQf~h#;q~}zD4z66D2bdy#;cRY!qCu?$XqgJ1Gd*KAKC*tJX2BR zHI3h8QeSV%S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Uw(r!HjzO|7mDJlpI*U$ax* z{nxpS!0U%q@?ht!_<+j^pJ9ye4Ll_;_4h)|s>l6lftiDV9djdi=c{?>`@UNK`;*4R zz)X9Jtlpg{Vd1?F`NprZ0cTzeV4;+T!-v$eWzS6=nrAZQkssUyeEYsUx$IzlJRW}I z0xHc;|H4BF17n_%p4!14kL+7;s!+L-C!hG?f{uJXkWO}Vsop%lsx65B1>ODqeSjXui>A5TF#x>Fz#qzt!y8grtcNqib}$;-s_nJWoA6~(J}Sy= zLO0du7#;B;ek&UqRKUz=m@(_b_nxR15uY=|e%@k+TJ9{M+1qAF3Dd;H8gVUH#~nMJk1|3heUqC4kd7PMex=Ju=BS{L9zb#z9iPjJJ&q$HiISpz%}vj#`t^{Y~@M?6)ukN*a4 + diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs b/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs index 5dd9739..a8605af 100644 --- a/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs +++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs @@ -59,6 +59,7 @@ this.groupBox6 = new System.Windows.Forms.GroupBox(); this.something = new System.Windows.Forms.CheckBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.dump = new System.Windows.Forms.Button(); this.stop = new System.Windows.Forms.Button(); this.start = new System.Windows.Forms.Button(); this.port = new System.Windows.Forms.TextBox(); @@ -89,27 +90,36 @@ this.program = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.groupBox7 = new System.Windows.Forms.GroupBox(); + this.label16 = new System.Windows.Forms.Label(); + this.D1_UUID = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); + this.D1_ID = new System.Windows.Forms.TextBox(); this.label14 = new System.Windows.Forms.Label(); this.D1_NAME = new System.Windows.Forms.TextBox(); this.estop = new System.Windows.Forms.CheckBox(); - this.label15 = new System.Windows.Forms.Label(); - this.D1_ID = new System.Windows.Forms.TextBox(); - this.label16 = new System.Windows.Forms.Label(); - this.D1_UUID = new System.Windows.Forms.TextBox(); - this.dump = new System.Windows.Forms.Button(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.groupBox9 = new System.Windows.Forms.GroupBox(); + this.OPERATOR_ID = new System.Windows.Forms.TextBox(); + this.label19 = new System.Windows.Forms.Label(); this.PROG_ROW_NUM = new System.Windows.Forms.TextBox(); this.label17 = new System.Windows.Forms.Label(); this.groupBox10 = new System.Windows.Forms.GroupBox(); this.enableDataSim = new System.Windows.Forms.CheckBox(); this.groupBox11 = new System.Windows.Forms.GroupBox(); - this.STATUS_PLC_ADP = new System.Windows.Forms.TextBox(); - this.lblPLC_ADP = new System.Windows.Forms.Label(); this.STATUS_ADP_PLC = new System.Windows.Forms.TextBox(); this.label18 = new System.Windows.Forms.Label(); - this.OPERATOR_ID = new System.Windows.Forms.TextBox(); - this.label19 = new System.Windows.Forms.Label(); + this.STATUS_PLC_ADP = new System.Windows.Forms.TextBox(); + this.lblPLC_ADP = new System.Windows.Forms.Label(); + this.groupBox12 = new System.Windows.Forms.GroupBox(); + this.lblCodaT = new System.Windows.Forms.Label(); + this.addCodT = new System.Windows.Forms.TextBox(); + this.label24 = new System.Windows.Forms.Label(); + this.lblCodaS = new System.Windows.Forms.Label(); + this.addCodS = new System.Windows.Forms.TextBox(); + this.label22 = new System.Windows.Forms.Label(); + this.lblCodaM = new System.Windows.Forms.Label(); + this.addCodM = new System.Windows.Forms.TextBox(); + this.label20 = new System.Windows.Forms.Label(); this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.commonVariables)).BeginInit(); @@ -124,6 +134,7 @@ this.groupBox9.SuspendLayout(); this.groupBox10.SuspendLayout(); this.groupBox11.SuspendLayout(); + this.groupBox12.SuspendLayout(); this.SuspendLayout(); // // flazBat @@ -307,7 +318,7 @@ "TEARDOWN", "MAINTENANCE", "PROCESS_DEVELOPMENT"}); - this.functionalMode.Location = new System.Drawing.Point(102, 273); + this.functionalMode.Location = new System.Drawing.Point(655, 313); this.functionalMode.Name = "functionalMode"; this.functionalMode.Size = new System.Drawing.Size(121, 21); this.functionalMode.TabIndex = 47; @@ -316,7 +327,7 @@ // label12 // this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(13, 276); + this.label12.Location = new System.Drawing.Point(566, 316); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(86, 13); this.label12.TabIndex = 46; @@ -402,6 +413,16 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Server Info"; // + // dump + // + this.dump.Location = new System.Drawing.Point(298, 15); + this.dump.Name = "dump"; + this.dump.Size = new System.Drawing.Size(75, 23); + this.dump.TabIndex = 4; + this.dump.Text = "Show Dump"; + this.dump.UseVisualStyleBackColor = true; + this.dump.Click += new System.EventHandler(this.dump_Click); + // // stop // this.stop.Location = new System.Drawing.Point(202, 15); @@ -710,6 +731,38 @@ this.groupBox7.TabStop = false; this.groupBox7.Text = "Macchina"; // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(193, 53); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(34, 13); + this.label16.TabIndex = 59; + this.label16.Text = "UUID"; + // + // D1_UUID + // + this.D1_UUID.Location = new System.Drawing.Point(234, 50); + this.D1_UUID.Name = "D1_UUID"; + this.D1_UUID.Size = new System.Drawing.Size(140, 20); + this.D1_UUID.TabIndex = 58; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(10, 53); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(18, 13); + this.label15.TabIndex = 57; + this.label15.Text = "ID"; + // + // D1_ID + // + this.D1_ID.Location = new System.Drawing.Point(51, 50); + this.D1_ID.Name = "D1_ID"; + this.D1_ID.Size = new System.Drawing.Size(124, 20); + this.D1_ID.TabIndex = 56; + // // label14 // this.label14.AutoSize = true; @@ -737,48 +790,6 @@ this.estop.Text = "Emergency Stop"; this.estop.UseVisualStyleBackColor = true; // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(10, 53); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(18, 13); - this.label15.TabIndex = 57; - this.label15.Text = "ID"; - // - // D1_ID - // - this.D1_ID.Location = new System.Drawing.Point(51, 50); - this.D1_ID.Name = "D1_ID"; - this.D1_ID.Size = new System.Drawing.Size(124, 20); - this.D1_ID.TabIndex = 56; - // - // label16 - // - this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(193, 53); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(34, 13); - this.label16.TabIndex = 59; - this.label16.Text = "UUID"; - // - // D1_UUID - // - this.D1_UUID.Location = new System.Drawing.Point(234, 50); - this.D1_UUID.Name = "D1_UUID"; - this.D1_UUID.Size = new System.Drawing.Size(140, 20); - this.D1_UUID.TabIndex = 58; - // - // dump - // - this.dump.Location = new System.Drawing.Point(298, 15); - this.dump.Name = "dump"; - this.dump.Size = new System.Drawing.Size(75, 23); - this.dump.TabIndex = 4; - this.dump.Text = "Show Dump"; - this.dump.UseVisualStyleBackColor = true; - this.dump.Click += new System.EventHandler(this.dump_Click); - // // groupBox8 // this.groupBox8.Controls.Add(this.estop); @@ -806,6 +817,22 @@ this.groupBox9.TabStop = false; this.groupBox9.Text = "Produzione"; // + // OPERATOR_ID + // + this.OPERATOR_ID.Location = new System.Drawing.Point(273, 45); + this.OPERATOR_ID.Name = "OPERATOR_ID"; + this.OPERATOR_ID.Size = new System.Drawing.Size(100, 20); + this.OPERATOR_ID.TabIndex = 53; + // + // label19 + // + this.label19.AutoSize = true; + this.label19.Location = new System.Drawing.Point(222, 48); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(45, 13); + this.label19.TabIndex = 52; + this.label19.Text = "ID oper."; + // // PROG_ROW_NUM // this.PROG_ROW_NUM.Location = new System.Drawing.Point(313, 19); @@ -856,22 +883,6 @@ this.groupBox11.TabStop = false; this.groupBox11.Text = "Strobes"; // - // STATUS_PLC_ADP - // - this.STATUS_PLC_ADP.Location = new System.Drawing.Point(85, 19); - this.STATUS_PLC_ADP.Name = "STATUS_PLC_ADP"; - this.STATUS_PLC_ADP.Size = new System.Drawing.Size(286, 20); - this.STATUS_PLC_ADP.TabIndex = 53; - // - // lblPLC_ADP - // - this.lblPLC_ADP.AutoSize = true; - this.lblPLC_ADP.Location = new System.Drawing.Point(15, 22); - this.lblPLC_ADP.Name = "lblPLC_ADP"; - this.lblPLC_ADP.Size = new System.Drawing.Size(64, 13); - this.lblPLC_ADP.TabIndex = 52; - this.lblPLC_ADP.Text = "PLC -> ADP"; - // // STATUS_ADP_PLC // this.STATUS_ADP_PLC.Location = new System.Drawing.Point(85, 45); @@ -888,28 +899,127 @@ this.label18.TabIndex = 54; this.label18.Text = "ADP -> PLC"; // - // OPERATOR_ID + // STATUS_PLC_ADP // - this.OPERATOR_ID.Location = new System.Drawing.Point(273, 45); - this.OPERATOR_ID.Name = "OPERATOR_ID"; - this.OPERATOR_ID.Size = new System.Drawing.Size(100, 20); - this.OPERATOR_ID.TabIndex = 53; + this.STATUS_PLC_ADP.Location = new System.Drawing.Point(85, 19); + this.STATUS_PLC_ADP.Name = "STATUS_PLC_ADP"; + this.STATUS_PLC_ADP.Size = new System.Drawing.Size(286, 20); + this.STATUS_PLC_ADP.TabIndex = 53; // - // label19 + // lblPLC_ADP // - this.label19.AutoSize = true; - this.label19.Location = new System.Drawing.Point(222, 48); - this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(45, 13); - this.label19.TabIndex = 52; - this.label19.Text = "ID oper."; - this.label19.Click += new System.EventHandler(this.label19_Click); + this.lblPLC_ADP.AutoSize = true; + this.lblPLC_ADP.Location = new System.Drawing.Point(15, 22); + this.lblPLC_ADP.Name = "lblPLC_ADP"; + this.lblPLC_ADP.Size = new System.Drawing.Size(64, 13); + this.lblPLC_ADP.TabIndex = 52; + this.lblPLC_ADP.Text = "PLC -> ADP"; + // + // groupBox12 + // + this.groupBox12.Controls.Add(this.lblCodaT); + this.groupBox12.Controls.Add(this.addCodT); + this.groupBox12.Controls.Add(this.label24); + this.groupBox12.Controls.Add(this.lblCodaS); + this.groupBox12.Controls.Add(this.addCodS); + this.groupBox12.Controls.Add(this.label22); + this.groupBox12.Controls.Add(this.lblCodaM); + this.groupBox12.Controls.Add(this.addCodM); + this.groupBox12.Controls.Add(this.label20); + this.groupBox12.Location = new System.Drawing.Point(12, 228); + this.groupBox12.Name = "groupBox12"; + this.groupBox12.Size = new System.Drawing.Size(379, 100); + this.groupBox12.TabIndex = 58; + this.groupBox12.TabStop = false; + this.groupBox12.Text = "Codici M/S/T"; + // + // lblCodaT + // + this.lblCodaT.AutoSize = true; + this.lblCodaT.Location = new System.Drawing.Point(117, 74); + this.lblCodaT.Name = "lblCodaT"; + this.lblCodaT.Size = new System.Drawing.Size(22, 13); + this.lblCodaT.TabIndex = 60; + this.lblCodaT.Text = "[...]"; + // + // addCodT + // + this.addCodT.Location = new System.Drawing.Point(51, 71); + this.addCodT.Name = "addCodT"; + this.addCodT.Size = new System.Drawing.Size(60, 20); + this.addCodT.TabIndex = 59; + this.addCodT.KeyDown += new System.Windows.Forms.KeyEventHandler(this.addCodT_KeyDown); + this.addCodT.Leave += new System.EventHandler(this.addCodT_Leave); + // + // label24 + // + this.label24.AutoSize = true; + this.label24.Location = new System.Drawing.Point(9, 74); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(33, 13); + this.label24.TabIndex = 58; + this.label24.Text = "AddT"; + // + // lblCodaS + // + this.lblCodaS.AutoSize = true; + this.lblCodaS.Location = new System.Drawing.Point(118, 48); + this.lblCodaS.Name = "lblCodaS"; + this.lblCodaS.Size = new System.Drawing.Size(22, 13); + this.lblCodaS.TabIndex = 57; + this.lblCodaS.Text = "[...]"; + // + // addCodS + // + this.addCodS.Location = new System.Drawing.Point(52, 45); + this.addCodS.Name = "addCodS"; + this.addCodS.Size = new System.Drawing.Size(60, 20); + this.addCodS.TabIndex = 56; + this.addCodS.KeyDown += new System.Windows.Forms.KeyEventHandler(this.addCodS_KeyDown); + this.addCodS.Leave += new System.EventHandler(this.addCodS_Leave); + // + // label22 + // + this.label22.AutoSize = true; + this.label22.Location = new System.Drawing.Point(10, 48); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(33, 13); + this.label22.TabIndex = 55; + this.label22.Text = "AddS"; + // + // lblCodaM + // + this.lblCodaM.AutoSize = true; + this.lblCodaM.Location = new System.Drawing.Point(118, 22); + this.lblCodaM.Name = "lblCodaM"; + this.lblCodaM.Size = new System.Drawing.Size(22, 13); + this.lblCodaM.TabIndex = 54; + this.lblCodaM.Text = "[...]"; + // + // addCodM + // + this.addCodM.Location = new System.Drawing.Point(52, 19); + this.addCodM.Name = "addCodM"; + this.addCodM.Size = new System.Drawing.Size(60, 20); + this.addCodM.TabIndex = 53; + this.addCodM.KeyDown += new System.Windows.Forms.KeyEventHandler(this.addCodM_KeyDown); + this.addCodM.Leave += new System.EventHandler(this.addCodM_Leave); + // + // label20 + // + this.label20.AutoSize = true; + this.label20.Location = new System.Drawing.Point(10, 22); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(35, 13); + this.label20.TabIndex = 52; + this.label20.Text = "AddM"; // // CMS_MachineSim // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(794, 733); + this.Controls.Add(this.groupBox12); this.Controls.Add(this.groupBox11); this.Controls.Add(this.groupBox10); this.Controls.Add(this.groupBox9); @@ -955,6 +1065,8 @@ this.groupBox10.PerformLayout(); this.groupBox11.ResumeLayout(false); this.groupBox11.PerformLayout(); + this.groupBox12.ResumeLayout(false); + this.groupBox12.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1043,6 +1155,16 @@ private System.Windows.Forms.Label lblPLC_ADP; private System.Windows.Forms.TextBox OPERATOR_ID; private System.Windows.Forms.Label label19; + private System.Windows.Forms.GroupBox groupBox12; + private System.Windows.Forms.Label lblCodaT; + private System.Windows.Forms.TextBox addCodT; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.Label lblCodaS; + private System.Windows.Forms.TextBox addCodS; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.Label lblCodaM; + private System.Windows.Forms.TextBox addCodM; + private System.Windows.Forms.Label label20; } } diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.cs b/MTC_Sim/MTC_Sim/CMS_MachineSim.cs index 6c6daf1..e785522 100644 --- a/MTC_Sim/MTC_Sim/CMS_MachineSim.cs +++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.cs @@ -62,7 +62,11 @@ namespace MTC_Sim /// /// CURR_PROG_ROWNUM - programma in esecuzione /// - Event mProgRowNum = new Event("CurrPRog_RowNum"); + Event mProgRowNum = new Event("CurrProg_RowNum"); + /// + /// PartId - particolare prodotto + /// + Event mPartId = new Event("PartID"); /// /// CURR_PROG_ROWNUM - programma in esecuzione /// @@ -78,6 +82,22 @@ namespace MTC_Sim /// Event mExec = new Event("exec"); + Strobe STROBE_PLC = 0; + Strobe STROBE_ADP = 0; + + /// + /// M_CODE + /// + Event mCod_M = new Event("Cod_M"); + /// + /// S_CODE + /// + Event mCod_S = new Event("Cod_S"); + /// + /// T_CODE + /// + Event mCod_T = new Event("Cod_T"); + Event mFunctionalMode = new Event("func"); Message mMessage = new Message("message"); @@ -116,8 +136,14 @@ namespace MTC_Sim // programma e produzione mAdapter.AddDataItem(mProgram); mAdapter.AddDataItem(mProgRowNum); + mAdapter.AddDataItem(mPartId); mAdapter.AddDataItem(mOperator); + // codici speciali M/S/T + mAdapter.AddDataItem(mCod_M); + mAdapter.AddDataItem(mCod_S); + mAdapter.AddDataItem(mCod_T); + mAdapter.AddDataItem(mMode); mAdapter.AddDataItem(mExec); @@ -155,6 +181,7 @@ namespace MTC_Sim D1_UUID.Text = utils.CRS("D1_UUID"); program.Text = utils.CRS("D1_PROGRAM"); PROG_ROW_NUM.Text = "0"; + partID.Text = utils.CRS("PartID"); OPERATOR_ID.Text = "M9999"; STATUS_PLC_ADP.Text = binaryForm(utils.CRI("STATUS_PLC_ADP")); STATUS_ADP_PLC.Text = binaryForm(utils.CRI("STATUS_ADP_PLC")); @@ -172,41 +199,6 @@ namespace MTC_Sim return answ; } - /// - /// simula alcuni dati generando ad esempio numeri casuali... SE abilitato - /// - private void simulateData() - { - if (enableDataSim.Checked) - { - DateTime adesso = DateTime.Now; - Random rnd = new Random(); - PROG_ROW_NUM.Text = rnd.Next(1, 10000).ToString(); - // verifica se ci sia un evento strobe da recepire... - if (STATUS_PLC_ADP.Text.IndexOf("1") >= 0) - { - // verifica SE sia stato recepito da adapter... - if (STATUS_ADP_PLC.Text == STATUS_PLC_ADP.Text) - { - // in questo caso ripulisco da PLC... - STATUS_PLC_ADP.Text = binaryForm(0); - } - } - else - { - // se era ancora sollevato strobe lettura lo abbasso... - if (STATUS_ADP_PLC.Text.IndexOf("1") >= 0) - { - STATUS_ADP_PLC.Text = binaryForm(0); - } - else - { - // se il numero è < 1000 (10%) imposto strobe... - STATUS_PLC_ADP.Text = binaryForm(rnd.Next(1, 10000000)); - } - } - } - } private void start_Click(object sender, EventArgs e) { @@ -246,7 +238,7 @@ namespace MTC_Sim { mAdapter.Begin(); - // eseguoe ventuali simulazioni + // eseguo eventuali simulazioni x dati/flags simulateData(); // nome @@ -257,8 +249,15 @@ namespace MTC_Sim // programma mProgram.Value = program.Text; mProgRowNum.Value = PROG_ROW_NUM.Text; + mPartId.Value = partID.Text; mOperator.Value = OPERATOR_ID.Text; + // SE presente recupero Cod_M/S/T + checkCodM(); + checkCodS(); + checkCodT(); + + if (estop.Checked) mEStop.Value = "TRIGGERED"; @@ -322,6 +321,67 @@ namespace MTC_Sim mAdapter.SendChanged(); } + + private void checkCodM() + { + if (utils.IsSetAll(STROBE_PLC, Strobe.M_CODE)) + { + mCod_M.Value = getNextMCode; + // se il valore è "" allora alzo flag lettura... + if (mCod_M.Value.ToString() == "") STROBE_ADP = STROBE_ADP | Strobe.M_CODE; + // refresh stringhe + refreshCodeMST(); + } + else + { + // resetto eventuali flag di lettura... + if (utils.IsSetAll(STROBE_ADP, Strobe.M_CODE)) + { + STROBE_ADP -= Strobe.M_CODE; + } + } + } + private void checkCodS() + { + if (utils.IsSetAll(STROBE_PLC, Strobe.S_CODE)) + { + mCod_S.Value = getNextSCode; + // se il valore è "" allora alzo flag lettura... + if (mCod_S.Value.ToString() == "") STROBE_ADP = STROBE_ADP | Strobe.S_CODE; + // refresh stringhe + refreshCodeMST(); + } + else + { + // resetto eventuali flag di lettura... + if (utils.IsSetAll(STROBE_ADP, Strobe.S_CODE)) + { + STROBE_ADP -= Strobe.S_CODE; + } + } + } + private void checkCodT() + { + if (utils.IsSetAll(STROBE_PLC, Strobe.T_CODE)) + { + mCod_T.Value = getNextTCode; + // se il valore è "" allora alzo flag lettura... + if (mCod_T.Value.ToString() == "") STROBE_ADP = STROBE_ADP | Strobe.T_CODE; + // refresh stringhe + refreshCodeMST(); + } + else + { + // resetto eventuali flag di lettura... + if (utils.IsSetAll(STROBE_ADP, Strobe.T_CODE)) + { + STROBE_ADP -= Strobe.T_CODE; + } + } + } + + + private void message_Leave(object sender, EventArgs e) { mMessage.Value = messageText.Text; @@ -379,9 +439,224 @@ namespace MTC_Sim Process.Start(string.Format(@"{0}\..\..\dump\dump.exe", path)); } - private void label19_Click(object sender, EventArgs e) + + #region area metodi comunicazione con PLC/CNC + + /// + /// recupera primo elemento codaM + /// + protected string getNextMCode + { + get + { + string answ = ""; + if (codaM.Count > 0) + { + // accodo codice M... + answ = codaM.First(); + // tolgo elemento + codaM.RemoveAt(0); + } + return answ; + } + } + + /// + /// recupera primo elemento codaS + /// + protected string getNextSCode + { + get + { + string answ = ""; + if (codaS.Count > 0) + { + // accodo codice S... + answ = codaS.First(); + // tolgo elemento + codaS.RemoveAt(0); + } + return answ; + } + } + + /// + /// recupera primo elemento codaT + /// + protected string getNextTCode + { + get + { + string answ = ""; + if (codaT.Count > 0) + { + // accodo codice T... + answ = codaT.First(); + // tolgo elemento + codaT.RemoveAt(0); + } + return answ; + } + } + + #endregion + + + #region classi x simulazione valori vari + + /// + /// simula alcuni dati generando ad esempio numeri casuali... SE abilitato + /// + private void simulateData() + { + if (enableDataSim.Checked) + { + DateTime adesso = DateTime.Now; + Random rnd = new Random(); + PROG_ROW_NUM.Text = rnd.Next(1, 10000).ToString(); + // ora controllo se ci siano eventi M/S/T x alzare flag... + if (codaM.Count > 0) STROBE_PLC = STROBE_PLC | Strobe.M_CODE; + if (codaS.Count > 0) STROBE_PLC = STROBE_PLC | Strobe.S_CODE; + if (codaT.Count > 0) STROBE_PLC = STROBE_PLC | Strobe.T_CODE; + + // controllo se ci sia il flag di lettura di un evento M/S/T nel qual caso lo abbasso... + if (STROBE_ADP > 0) STROBE_PLC -= STROBE_ADP; + + // aggiorno visualizzazione strobe! + STATUS_PLC_ADP.Text = binaryForm((int)STROBE_PLC); + STATUS_ADP_PLC.Text = binaryForm((int)STROBE_ADP); + +#if false + // verifica se ci sia un evento strobe da recepire... + if (STATUS_PLC_ADP.Text.IndexOf("1") >= 0) + { + // verifica SE sia stato recepito da adapter... + if (STATUS_ADP_PLC.Text == STATUS_PLC_ADP.Text) + { + // in questo caso ripulisco da PLC... + STATUS_PLC_ADP.Text = binaryForm(0); + } + } + else + { + // se era ancora sollevato strobe lettura lo abbasso... + if (STATUS_ADP_PLC.Text.IndexOf("1") >= 0) + { + STATUS_ADP_PLC.Text = binaryForm(0); + } + else + { + // se il numero è < 1000 (10%) imposto strobe... + STATUS_PLC_ADP.Text = binaryForm(rnd.Next(1, 10000000)); + } + } +#endif + } + } + + + + protected List codaM = new List(); + protected List codaS = new List(); + protected List codaT = new List(); + + /// + /// aggiorna visualizzazione code... + /// + private void refreshCodeMST() + { + lblCodaM.Text = string.Join(",", codaM.ToArray()); + lblCodaT.Text = string.Join(",", codaT.ToArray()); + lblCodaS.Text = string.Join(",", codaS.ToArray()); + } + + private void accodaCodM() + { + if (addCodM.Text.Trim() != "") + { + codaM.Add(addCodM.Text.Trim()); + addCodM.Text = ""; + } + refreshCodeMST(); + } + private void accodaCodS() + { + if (addCodS.Text.Trim() != "") + { + codaS.Add(addCodS.Text.Trim()); + addCodS.Text = ""; + } + refreshCodeMST(); + } + private void accodaCodT() + { + if (addCodT.Text.Trim() != "") + { + codaT.Add(addCodT.Text.Trim()); + addCodT.Text = ""; + } + refreshCodeMST(); + } + + private void addCodM_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + // accodo testo + accodaCodM(); + } + else if (e.KeyCode == Keys.Escape) + { + // svuoto! + addCodM.Text = ""; + } + } + private void addCodM_Leave(object sender, EventArgs e) + { + accodaCodM(); + } + + private void addCodS_KeyDown(object sender, KeyEventArgs e) { + if (e.KeyCode == Keys.Enter) + { + // accodo testo + accodaCodS(); + } + else if (e.KeyCode == Keys.Escape) + { + // svuoto! + addCodS.Text = ""; + } } + + private void addCodS_Leave(object sender, EventArgs e) + { + accodaCodS(); + } + + + private void addCodT_KeyDown(object sender, KeyEventArgs e) + { + + if (e.KeyCode == Keys.Enter) + { + // accodo testo + accodaCodT(); + } + else if (e.KeyCode == Keys.Escape) + { + // svuoto! + addCodT.Text = ""; + } + } + private void addCodT_Leave(object sender, EventArgs e) + { + accodaCodT(); + } + + + #endregion } } diff --git a/MTC_Sim/MTC_Sim/utils.cs b/MTC_Sim/MTC_Sim/utils.cs index e6ed6fe..6c8b081 100644 --- a/MTC_Sim/MTC_Sim/utils.cs +++ b/MTC_Sim/MTC_Sim/utils.cs @@ -42,7 +42,69 @@ namespace MTC_Sim { } return answ; } + /// + /// verifica se un dato bit sia alzato (come flag di strobe) + /// + /// valore da testare + /// valore cercato, può essere un singolo valore o un insieme in modalità AND + /// + public static bool IsSetAll(Strobe value, Strobe flag) + { + return ((value & flag) == flag); + } + /// + /// verifica se un dato bit sia alzato (come flag di strobe) + /// + /// valore da testare + /// valore cercato, può essere un singolo valore o un insieme in modalità OR + /// + public static bool IsSetAny(Strobe value, Strobe flag) + { + return ((value & flag) != 0); + } } + /// + /// Strobe: contiene il set di strobe di comunicazione + /// + /// rif: http://stackoverflow.com/questions/17209054/parse-bits-in-a-byte-to-enum + /// + [Flags] + public enum Strobe : int + { + NONE = 0, + M_CODE = 1 << 0, + S_CODE = 1 << 1, + T_CODE = 1 << 2, + SP04 = 1 << 3, + SP05 = 1 << 4, + SP06 = 1 << 5, + SP07 = 1 << 6, + SP08 = 1 << 8, + SP09 = 1 << 9, + SP10 = 1 << 10, + SP11 = 1 << 11, + SP12 = 1 << 12, + SP13 = 1 << 13, + SP14 = 1 << 14, + SP15 = 1 << 15, + SP16 = 1 << 16, + SP17 = 1 << 17, + SP18 = 1 << 18, + SP19 = 1 << 19, + SP20 = 1 << 20, + SP21 = 1 << 21, + SP22 = 1 << 22, + SP23 = 1 << 23, + SP24 = 1 << 24, + SP25 = 1 << 25, + SP26 = 1 << 26, + SP27 = 1 << 27, + SP28 = 1 << 28, + SP29 = 1 << 29, + SP30 = 1 << 30, + SP31 = 1 << 31, + SP32 = 1 << 32 + } }