diff --git a/MTC_Sim/.vs/MTC_Sim/v14/.suo b/MTC_Sim/.vs/MTC_Sim/v14/.suo
index b72db5b..30231be 100644
Binary files a/MTC_Sim/.vs/MTC_Sim/v14/.suo and b/MTC_Sim/.vs/MTC_Sim/v14/.suo differ
diff --git a/MTC_Sim/MTC_Sim/AdapterDemo.cs b/MTC_Sim/MTC_Sim/AdapterDemo.cs
new file mode 100644
index 0000000..18f55c0
--- /dev/null
+++ b/MTC_Sim/MTC_Sim/AdapterDemo.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTC_Sim
+{
+ public class AdapterDemo : AdapterGeneric
+ {
+ ///
+ /// estende l'init della classe base...
+ ///
+ public AdapterDemo(CMS_MachineSim caller) : base(caller)
+ {
+
+ }
+
+ public override void getCurrProgramData()
+ {
+ // serve?!?
+ base.getCurrProgramData();
+
+ // recupero programma da FORM!!!
+ mProgram.Value = parentForm.datiProd.ProgramName;
+ mProgRowNum.Value = parentForm.datiProd.ProgrRow;
+ mPartId.Value = parentForm.datiProd.PartId;
+ mOperator.Value = parentForm.datiProd.Operator;
+ }
+
+ public override void getCurrMode()
+ {
+ base.getCurrMode();
+
+ // controllo bool allarmi...
+ if (parentForm.datiProd.EmrStop)
+ {
+ mEStop.Value = "TRIGGERED";
+ }
+ else
+ {
+ mEStop.Value = "ARMED";
+ }
+
+ // imposto RUN mode
+ mMode.Value = parentForm.datiProd.RunMode;
+
+ // imposto EXE mode
+ mExec.Value = parentForm.datiProd.ExeMode;
+
+ }
+
+ }
+}
diff --git a/MTC_Sim/MTC_Sim/AdapterFanuc.cs b/MTC_Sim/MTC_Sim/AdapterFanuc.cs
new file mode 100644
index 0000000..e4bc0e1
--- /dev/null
+++ b/MTC_Sim/MTC_Sim/AdapterFanuc.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTC_Sim
+{
+ public class AdapterFanuc : AdapterGeneric
+ {
+ ///
+ /// estende l'init della classe base...
+ ///
+ public AdapterFanuc(CMS_MachineSim caller) : base(caller)
+ {
+
+ }
+
+ public override void getCurrProgramData()
+ {
+ // serve?!?
+ base.getCurrProgramData();
+ }
+ }
+}
diff --git a/MTC_Sim/MTC_Sim/AdapterGeneric.cs b/MTC_Sim/MTC_Sim/AdapterGeneric.cs
new file mode 100644
index 0000000..f4073f4
--- /dev/null
+++ b/MTC_Sim/MTC_Sim/AdapterGeneric.cs
@@ -0,0 +1,474 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace MTC_Sim
+{
+ using MTConnect;
+ using System.Configuration;
+ using System.Diagnostics;
+
+ public class AdapterGeneric
+ {
+
+
+ ///
+ /// adapter globale
+ ///
+ Adapter mAdapter = new Adapter();
+
+ protected CMS_MachineSim parentForm;
+
+ ///
+ /// inizializzo l'oggetto sulla form
+ ///
+ ///
+ public AdapterGeneric(CMS_MachineSim caller)
+ {
+ // salvo al form chiamante
+ parentForm = caller;
+
+ // item disponibilità
+ mAdapter.AddDataItem(mAvail);
+ mAvail.Value = "AVAILABLE";
+ // emergency stop
+ mAdapter.AddDataItem(mEStop);
+
+ // nome ed ID/UUID - e li imposto...
+ mAdapter.AddDataItem(mName);
+ mAdapter.AddDataItem(mID);
+ mAdapter.AddDataItem(mUUID);
+
+ // 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);
+
+ mAdapter.AddDataItem(mFunctionalMode);
+ mAdapter.AddDataItem(mMessage);
+
+ mAdapter.AddDataItem(mPosition);
+ mAdapter.AddDataItem(mxLoad);
+
+ mAdapter.AddDataItem(mSpeed);
+ mAdapter.AddDataItem(mcLoad);
+
+ mAdapter.AddDataItem(mSystem);
+ mAdapter.AddDataItem(mTemp);
+ mAdapter.AddDataItem(mOverload);
+ mAdapter.AddDataItem(mTravel);
+ mAdapter.AddDataItem(mFillLevel);
+
+ mAdapter.AddDataItem(mCommonVariable);
+
+ }
+
+
+ #region altri oggetti
+
+ public Strobe STROBE_PLC = 0;
+ public Strobe STROBE_ADP = 0;
+
+
+ public List codaM = new List();
+ public List codaS = new List();
+ public List codaT = new List();
+
+ #endregion
+
+ #region Events
+
+ ///
+ /// D.D1.AVAIL - disponibilità
+ ///
+ public Event mAvail = new Event("avail");
+ ///
+ /// XX.XX.STOP - stop per pressione emergenze
+ ///
+ public Event mEStop = new Event("estop");
+
+ ///
+ /// D.D1.NAME
+ ///
+ public Event mName = new Event("Name");
+ ///
+ /// D.D1.ID
+ ///
+ public Event mID = new Event("ID");
+ ///
+ /// D.D1.UUID
+ ///
+ public Event mUUID = new Event("UUID");
+ ///
+ /// D.D1.SAMPLE_INTERVAL
+ ///
+ public Event mSampleInt = new Event("SampleInt");
+
+
+ ///
+ /// CURR_PROG - programma in esecuzione
+ ///
+ public Event mProgram = new Event("CurrProg");
+ ///
+ /// CURR_PROG_ROWNUM - programma in esecuzione
+ ///
+ public Event mProgRowNum = new Event("CurrProg_RowNum");
+ ///
+ /// PartId - particolare prodotto
+ ///
+ public Event mPartId = new Event("PartID");
+ ///
+ /// CURR_PROG_ROWNUM - programma in esecuzione
+ ///
+ public Event mOperator = new Event("OperatorId");
+
+
+ ///
+ /// D.D1.P1.PATH_MODE - modalità esecuzione
+ ///
+ public Event mMode = new Event("mode");
+ ///
+ /// D.D1.P1.PATH_STATUS - status macchina
+ ///
+ public Event mExec = new Event("exec");
+
+ ///
+ /// M_CODE
+ ///
+ public Event mCod_M = new Event("Cod_M");
+ ///
+ /// S_CODE
+ ///
+ public Event mCod_S = new Event("Cod_S");
+ ///
+ /// T_CODE
+ ///
+ public Event mCod_T = new Event("Cod_T");
+
+
+
+
+ public Event mFunctionalMode = new Event("func");
+
+
+ public Event mCommonVariable = new Event("cv");
+
+ #endregion
+
+ #region Conditions
+
+
+ Condition mSystem = new Condition("system");
+ Condition mTemp = new Condition("temp");
+ Condition mOverload = new Condition("overload");
+ Condition mTravel = new Condition("travel");
+ Condition mFillLevel = new Condition("cool_low", true);
+
+ #endregion
+
+
+ #region Messages
+
+
+ Message mMessage = new Message("message");
+
+ #endregion
+
+
+
+ #region Samples
+
+
+
+ Sample mPosition = new Sample("xPosition");
+ Sample mxLoad = new Sample("xLoad");
+
+ Sample mSpeed = new Sample("sSpeed");
+ Sample mcLoad = new Sample("sLoad");
+
+ #endregion
+
+
+ #region metodi adapter
+
+ ///
+ /// Avvia l'adapter sulla porta richiesta
+ ///
+ ///
+ public void startAdapter(int port)
+ {
+ // Start the adapter lib with the port number in the text box
+ mAdapter.Port = port;
+ mAdapter.Start();
+
+
+
+ mSystem.Normal();
+ mTemp.Normal();
+ mOverload.Normal();
+ mTravel.Normal();
+ mFillLevel.Normal();
+
+
+ //mWave.StartRecording();
+ }
+ ///
+ /// ferma l'adapter...
+ ///
+ public void stopAdapter()
+ {
+ // Stop everything...
+ mAdapter.Stop();
+ }
+
+ ///
+ /// effettua recupero dati ed invio valori modificati...
+ ///
+ public void gaterAndSend()
+ {
+ // !!!FARE!!!: ripensare se riscrivere con un timer rapido ed un insieme di task preimpostati a scadenza... (al posto di altri timers...)
+
+
+ // avvio fase raccolta dati
+ mAdapter.Begin();
+
+ // leggo parametri da config file
+ getConfigParam();
+
+ ///acquisisco dati su programma in esecuzione
+ getCurrProgramData();
+
+ // fix codici M/S/T
+ getCodMST();
+
+
+ // fix dati x allarmi e modalità RUN/EXEC
+ getCurrMode();
+
+#if false
+
+
+ mFunctionalMode.Value = functionalMode.Text;
+
+ if (messageCode.Text.Length > 0)
+ {
+ mMessage.Code = messageCode.Text;
+ mMessage.Value = messageText.Text;
+ }
+
+ mxLoad.Value = xLoad.Value;
+ mcLoad.Value = cLoad.Value;
+
+ if (flazBat.Checked)
+ mSystem.Add(Condition.Level.FAULT, "Yur Flaz Bat is flapping", "FLAZBAT");
+ if (something.Checked)
+ mSystem.Add(Condition.Level.WARNING, "Something went wrong", "AKAK");
+ if (noProgram.Checked)
+ mSystem.Add(Condition.Level.FAULT, "No program loaded", "PROG");
+
+ if (overtemp.Checked)
+ mTemp.Add(Condition.Level.WARNING, "Temperature is too high", "OT");
+ if (overload.Checked)
+ mOverload.Add(Condition.Level.FAULT, "Axis overload", "OL");
+ if (travel.Checked)
+ mTravel.Add(Condition.Level.FAULT, "Travel outside boundaries", "OP");
+
+ DataGridViewColumnCollection headers = commonVariables.Columns;
+ DataGridViewCellCollection cells = commonVariables.Rows[0].Cells;
+ string result = "";
+
+ for (int i = 0; i < cells.Count; i++)
+ {
+ result += headers[i].HeaderText + ":" + cells[i].Value + " ";
+ }
+
+ mCommonVariable.Value = result;
+#endif
+
+ mAdapter.SendChanged();
+
+ }
+
+
+ ///
+ /// controllo codici MST
+ ///
+ public void getCodMST()
+ {
+ // SE presente recupero Cod_M/S/T
+ checkCodM();
+ checkCodS();
+ checkCodT();
+ }
+
+ ///
+ /// metodo di recupero dei dati di identificativo macchina - DA CONF!!!
+ ///
+ public void getConfigParam()
+ {
+ mName.Value = utils.CRS("D1_NAME");
+ mID.Value = utils.CRS("D1_ID");
+ mUUID.Value = utils.CRS("D1_UUID");
+ }
+
+ public virtual void getCurrProgramData()
+ {
+ // da gestire su ogni adapter...
+ }
+ public virtual void getCurrMode()
+ {
+ // da gestire su ogni adapter...
+ }
+
+
+ #endregion
+
+ #region area metodi comunicazione con PLC/CNC
+
+ public 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;
+
+ }
+ else
+ {
+ // resetto eventuali flag di lettura...
+ if (utils.IsSetAll(STROBE_ADP, Strobe.M_CODE))
+ {
+ STROBE_ADP -= Strobe.M_CODE;
+ }
+ }
+ }
+ public 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;
+ }
+ else
+ {
+ // resetto eventuali flag di lettura...
+ if (utils.IsSetAll(STROBE_ADP, Strobe.S_CODE))
+ {
+ STROBE_ADP -= Strobe.S_CODE;
+ }
+ }
+ }
+ public 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;
+ }
+ else
+ {
+ // resetto eventuali flag di lettura...
+ if (utils.IsSetAll(STROBE_ADP, Strobe.T_CODE))
+ {
+ STROBE_ADP -= Strobe.T_CODE;
+ }
+ }
+ }
+
+ ///
+ /// recupera primo elemento codaM
+ ///
+ protected string getNextMCode
+ {
+ get
+ {
+ // PRE: eventuale rilettura da PLC x accumulare in coda...
+ tryGetMCode();
+ // ora controllo array locale
+ 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
+ {
+ // PRE: eventuale rilettura da PLC x accumulare in coda...
+ tryGetSCode();
+ // ora controllo array locale
+ 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
+ {
+ // PRE: eventuale rilettura da PLC x accumulare in coda...
+ tryGetTCode();
+ // ora controllo array locale
+ string answ = "";
+ if (codaT.Count > 0)
+ {
+ // accodo codice T...
+ answ = codaT.First();
+ // tolgo elemento
+ codaT.RemoveAt(0);
+ }
+ return answ;
+ }
+ }
+
+
+ protected virtual void tryGetMCode()
+ {
+ // altri adapter: DA IMPLEMENTARE lettura buffer codici M (1 alla volta?)
+ }
+ protected virtual void tryGetSCode()
+ {
+ // DA IMPLEMENTARE: lettura buffer codici S (1 alla volta?)
+ }
+ protected virtual void tryGetTCode()
+ {
+ // DA IMPLEMENTARE: lettura buffer codici T (1 alla volta?)
+ }
+
+ #endregion
+ }
+}
diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs b/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs
index a8605af..4fa6fae 100644
--- a/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs
+++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs
@@ -120,6 +120,9 @@
this.lblCodaM = new System.Windows.Forms.Label();
this.addCodM = new System.Windows.Forms.TextBox();
this.label20 = new System.Windows.Forms.Label();
+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.MainProgrBar = new System.Windows.Forms.ToolStripProgressBar();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.commonVariables)).BeginInit();
@@ -135,6 +138,7 @@
this.groupBox10.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox12.SuspendLayout();
+ this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// flazBat
@@ -213,7 +217,7 @@
//
// cuttingToolButton
//
- this.cuttingToolButton.Location = new System.Drawing.Point(511, 657);
+ this.cuttingToolButton.Location = new System.Drawing.Point(237, 575);
this.cuttingToolButton.Name = "cuttingToolButton";
this.cuttingToolButton.Size = new System.Drawing.Size(75, 23);
this.cuttingToolButton.TabIndex = 42;
@@ -318,7 +322,7 @@
"TEARDOWN",
"MAINTENANCE",
"PROCESS_DEVELOPMENT"});
- this.functionalMode.Location = new System.Drawing.Point(655, 313);
+ this.functionalMode.Location = new System.Drawing.Point(253, 71);
this.functionalMode.Name = "functionalMode";
this.functionalMode.Size = new System.Drawing.Size(121, 21);
this.functionalMode.TabIndex = 47;
@@ -327,7 +331,7 @@
// label12
//
this.label12.AutoSize = true;
- this.label12.Location = new System.Drawing.Point(566, 316);
+ this.label12.Location = new System.Drawing.Point(164, 74);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(86, 13);
this.label12.TabIndex = 46;
@@ -522,9 +526,9 @@
this.Execution.Controls.Add(this.feedhold);
this.Execution.Controls.Add(this.stopped);
this.Execution.Controls.Add(this.running);
- this.Execution.Location = new System.Drawing.Point(406, 93);
+ this.Execution.Location = new System.Drawing.Point(405, 93);
this.Execution.Name = "Execution";
- this.Execution.Size = new System.Drawing.Size(379, 48);
+ this.Execution.Size = new System.Drawing.Size(380, 48);
this.Execution.TabIndex = 37;
this.Execution.TabStop = false;
this.Execution.Text = "Execution";
@@ -810,9 +814,11 @@
this.groupBox9.Controls.Add(this.label2);
this.groupBox9.Controls.Add(this.partID);
this.groupBox9.Controls.Add(this.label13);
+ this.groupBox9.Controls.Add(this.functionalMode);
+ this.groupBox9.Controls.Add(this.label12);
this.groupBox9.Location = new System.Drawing.Point(12, 147);
this.groupBox9.Name = "groupBox9";
- this.groupBox9.Size = new System.Drawing.Size(379, 75);
+ this.groupBox9.Size = new System.Drawing.Size(379, 100);
this.groupBox9.TabIndex = 55;
this.groupBox9.TabStop = false;
this.groupBox9.Text = "Produzione";
@@ -876,24 +882,25 @@
this.groupBox11.Controls.Add(this.label18);
this.groupBox11.Controls.Add(this.STATUS_PLC_ADP);
this.groupBox11.Controls.Add(this.lblPLC_ADP);
- this.groupBox11.Location = new System.Drawing.Point(405, 147);
+ this.groupBox11.Location = new System.Drawing.Point(12, 612);
this.groupBox11.Name = "groupBox11";
- this.groupBox11.Size = new System.Drawing.Size(380, 75);
+ this.groupBox11.Size = new System.Drawing.Size(773, 75);
this.groupBox11.TabIndex = 57;
this.groupBox11.TabStop = false;
this.groupBox11.Text = "Strobes";
//
// STATUS_ADP_PLC
//
- this.STATUS_ADP_PLC.Location = new System.Drawing.Point(85, 45);
+ this.STATUS_ADP_PLC.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.STATUS_ADP_PLC.Location = new System.Drawing.Point(85, 43);
this.STATUS_ADP_PLC.Name = "STATUS_ADP_PLC";
- this.STATUS_ADP_PLC.Size = new System.Drawing.Size(286, 20);
+ this.STATUS_ADP_PLC.Size = new System.Drawing.Size(363, 29);
this.STATUS_ADP_PLC.TabIndex = 55;
//
// label18
//
this.label18.AutoSize = true;
- this.label18.Location = new System.Drawing.Point(15, 48);
+ this.label18.Location = new System.Drawing.Point(15, 49);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(64, 13);
this.label18.TabIndex = 54;
@@ -901,15 +908,16 @@
//
// STATUS_PLC_ADP
//
- this.STATUS_PLC_ADP.Location = new System.Drawing.Point(85, 19);
+ this.STATUS_PLC_ADP.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.STATUS_PLC_ADP.Location = new System.Drawing.Point(85, 11);
this.STATUS_PLC_ADP.Name = "STATUS_PLC_ADP";
- this.STATUS_PLC_ADP.Size = new System.Drawing.Size(286, 20);
+ this.STATUS_PLC_ADP.Size = new System.Drawing.Size(363, 29);
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.Location = new System.Drawing.Point(15, 19);
this.lblPLC_ADP.Name = "lblPLC_ADP";
this.lblPLC_ADP.Size = new System.Drawing.Size(64, 13);
this.lblPLC_ADP.TabIndex = 52;
@@ -926,7 +934,7 @@
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.Location = new System.Drawing.Point(405, 147);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(379, 100);
this.groupBox12.TabIndex = 58;
@@ -1014,11 +1022,34 @@
this.label20.TabIndex = 52;
this.label20.Text = "AddM";
//
+ // statusStrip1
+ //
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabel1,
+ this.MainProgrBar});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 711);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(794, 22);
+ this.statusStrip1.TabIndex = 59;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // toolStripStatusLabel1
+ //
+ this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
+ this.toolStripStatusLabel1.Size = new System.Drawing.Size(52, 17);
+ this.toolStripStatusLabel1.Text = "Running";
+ //
+ // MainProgrBar
+ //
+ this.MainProgrBar.Name = "MainProgrBar";
+ this.MainProgrBar.Size = new System.Drawing.Size(100, 16);
+ //
// 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.statusStrip1);
this.Controls.Add(this.groupBox12);
this.Controls.Add(this.groupBox11);
this.Controls.Add(this.groupBox10);
@@ -1029,8 +1060,6 @@
this.Controls.Add(this.label6);
this.Controls.Add(this.cuttingToolButton);
this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.functionalMode);
- this.Controls.Add(this.label12);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.mode);
@@ -1067,6 +1096,8 @@
this.groupBox11.PerformLayout();
this.groupBox12.ResumeLayout(false);
this.groupBox12.PerformLayout();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -1141,7 +1172,6 @@
private System.Windows.Forms.TextBox D1_ID;
private System.Windows.Forms.CheckBox estop;
private System.Windows.Forms.Label label14;
- private System.Windows.Forms.TextBox D1_NAME;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.GroupBox groupBox9;
private System.Windows.Forms.TextBox PROG_ROW_NUM;
@@ -1165,6 +1195,10 @@
private System.Windows.Forms.Label lblCodaM;
private System.Windows.Forms.TextBox addCodM;
private System.Windows.Forms.Label label20;
+ private System.Windows.Forms.TextBox D1_NAME;
+ private System.Windows.Forms.StatusStrip statusStrip1;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
+ private System.Windows.Forms.ToolStripProgressBar MainProgrBar;
}
}
diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.cs b/MTC_Sim/MTC_Sim/CMS_MachineSim.cs
index e785522..84ac084 100644
--- a/MTC_Sim/MTC_Sim/CMS_MachineSim.cs
+++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.cs
@@ -24,149 +24,37 @@ namespace MTC_Sim
public partial class CMS_MachineSim : Form
{
///
- /// adapter globale
+ /// Oggetto x gestione dell'adapter GENERICO (x poter usare metodi di ognuno...)
///
- Adapter mAdapter = new Adapter();
-
+ AdapterGeneric agObj;
///
- /// D.D1.AVAIL - disponibilità
+ /// tipo di adapter prescelto...
///
- Event mAvail = new Event("avail");
- ///
- /// XX.XX.STOP - stop per pressione emergenze
- ///
- Event mEStop = new Event("estop");
-
- ///
- /// D.D1.NAME
- ///
- Event mName = new Event("Name");
- ///
- /// D.D1.ID
- ///
- Event mID = new Event("ID");
- ///
- /// D.D1.UUID
- ///
- Event mUUID = new Event("UUID");
- ///
- /// D.D1.SAMPLE_INTERVAL
- ///
- Event mSampleInt = new Event("SampleInt");
+ protected tipoAdapter tipoScelto = tipoAdapter.Demo;
- ///
- /// CURR_PROG - programma in esecuzione
- ///
- Event mProgram = new Event("CurrProg");
- ///
- /// CURR_PROG_ROWNUM - programma in esecuzione
- ///
- Event mProgRowNum = new Event("CurrProg_RowNum");
- ///
- /// PartId - particolare prodotto
- ///
- Event mPartId = new Event("PartID");
- ///
- /// CURR_PROG_ROWNUM - programma in esecuzione
- ///
- Event mOperator = new Event("OperatorId");
-
-
- ///
- /// D.D1.P1.PATH_MODE - modalità esecuzione
- ///
- Event mMode = new Event("mode");
- ///
- /// D.D1.P1.PATH_STATUS - status macchina
- ///
- 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");
-
- Sample mPosition = new Sample("xPosition");
- Sample mxLoad = new Sample("xLoad");
-
- Sample mSpeed = new Sample("sSpeed");
- Sample mcLoad = new Sample("sLoad");
-
- Condition mSystem = new Condition("system");
- Condition mTemp = new Condition("temp");
- Condition mOverload = new Condition("overload");
- Condition mTravel = new Condition("travel");
- Condition mFillLevel = new Condition("cool_low", true);
-
- Event mCommonVariable = new Event("cv");
public CMS_MachineSim()
{
InitializeComponent();
- // carico i default values
+
+ // definisco tipo adapter in base a selezione: FARE, x ora blindato...
+ tipoScelto = tipoAdapter.Demo;
+ switch (tipoScelto)
+ {
+ case tipoAdapter.Fanuc:
+ agObj = new AdapterFanuc(this);
+ break;
+ case tipoAdapter.HMI:
+ case tipoAdapter.Demo:
+ default:
+ agObj = new AdapterDemo(this);
+ break;
+ }
+
+ // carico i default values su interfaccia
setDefaults();
- // item disponibilità
- mAdapter.AddDataItem(mAvail);
- mAvail.Value = "AVAILABLE";
- // emergency stop
- mAdapter.AddDataItem(mEStop);
-
- // nome ed ID/UUID - e li imposto...
- mAdapter.AddDataItem(mName);
- mAdapter.AddDataItem(mID);
- mAdapter.AddDataItem(mUUID);
-
- // 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);
-
- mAdapter.AddDataItem(mFunctionalMode);
- mAdapter.AddDataItem(mMessage);
-
- mAdapter.AddDataItem(mPosition);
- mAdapter.AddDataItem(mxLoad);
-
- mAdapter.AddDataItem(mSpeed);
- mAdapter.AddDataItem(mcLoad);
-
- mAdapter.AddDataItem(mSystem);
- mAdapter.AddDataItem(mTemp);
- mAdapter.AddDataItem(mOverload);
- mAdapter.AddDataItem(mTravel);
- mAdapter.AddDataItem(mFillLevel);
-
- mAdapter.AddDataItem(mCommonVariable);
-
- string[] row = { "1", "2", "3", "4" };
- commonVariables.Rows.Add(row);
}
///
/// impostazione valori defaults
@@ -179,55 +67,52 @@ namespace MTC_Sim
D1_NAME.Text = utils.CRS("D1_NAME");
D1_ID.Text = utils.CRS("D1_ID");
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"));
+
+ STATUS_PLC_ADP.Text = utils.binaryForm(utils.CRI("STATUS_PLC_ADP"));
+ STATUS_ADP_PLC.Text = utils.binaryForm(utils.CRI("STATUS_ADP_PLC"));
+
+ MainProgrBar.Minimum = 0;
+ MainProgrBar.Maximum = 6;
+ MainProgrBar.Value = 0;
+ MainProgrBar.Step = 1;
+
+ string[] row = { "1", "2", "3", "4" };
+ commonVariables.Rows.Add(row);
}
- protected string binaryForm(int valore)
- {
- string answ = "";
- try
- {
- answ = string.Format(new BinaryFormatter(), "{0:B}", valore);
- }
- catch
- { }
- return answ;
- }
-
-
+ ///
+ /// Avvio dell'adapter
+ ///
+ ///
+ ///
private void start_Click(object sender, EventArgs e)
{
- // Start the adapter lib with the port number in the text box
- mAdapter.Port = Convert.ToInt32(port.Text);
- mAdapter.Start();
+ int porta = Convert.ToInt32(port.Text);
+ agObj.startAdapter(porta);
- // Disable start and enable stop/dump.
+ // fix buttons start/stop/dump
start.Enabled = false;
stop.Enabled = true;
dump.Enabled = true;
- // Start our periodic timer
+ // Start timer periodico
gather.Interval = utils.CRI("timerInt");
gather.Enabled = true;
-
- mSystem.Normal();
- mTemp.Normal();
- mOverload.Normal();
- mTravel.Normal();
- mFillLevel.Normal();
-
- //mWave.StartRecording();
}
-
+ ///
+ /// fermata dell'adapter
+ ///
+ ///
+ ///
private void stop_Click(object sender, EventArgs e)
{
- // Stop everything...
- mAdapter.Stop();
+ agObj.stopAdapter();
+
stop.Enabled = false;
dump.Enabled = false;
start.Enabled = true;
@@ -236,17 +121,27 @@ namespace MTC_Sim
private void gather_Tick(object sender, EventArgs e)
{
- mAdapter.Begin();
+ MainProgrBar.PerformStep();
// eseguo eventuali simulazioni x dati/flags
simulateData();
+ MainProgrBar.PerformStep();
+ // avvio fase raccolta dati e invio con adapter
+ agObj.gaterAndSend();
+ MainProgrBar.PerformStep();
+
+ // refresh stringhe code M/S/T
+ refreshCodeMST();
+ MainProgrBar.PerformStep();
+#if false
+ mAdapter.Begin();
// nome
mName.Value = D1_NAME.Text;
mID.Value = D1_ID.Text;
- mUUID.Value = D1_UUID.Text;
+ mUUID.Value = D1_UUID.Text;
- // programma
+ // programma
mProgram.Value = program.Text;
mProgRowNum.Value = PROG_ROW_NUM.Text;
mPartId.Value = partID.Text;
@@ -319,74 +214,61 @@ namespace MTC_Sim
mCommonVariable.Value = result;
mAdapter.SendChanged();
+#endif
+
+ // chiudo update...
+ MainProgrBar.PerformStep();
+
+ // se è arrivato a 100 resetto...
+ if (MainProgrBar.Value >= MainProgrBar.Maximum) MainProgrBar.Value = 0;
}
- private void checkCodM()
+ #region accesso dati FROM/TO maschera
+
+ ///
+ /// Dati di produzione (su form)
+ ///
+ public prodData datiProd
{
- if (utils.IsSetAll(STROBE_PLC, Strobe.M_CODE))
+ get
{
- 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;
- }
+ prodData answ = new prodData();
+ // carico da form
+ answ.ProgramName = program.Text;
+ answ.ProgrRow = PROG_ROW_NUM.Text;
+ answ.PartId = partID.Text;
+ answ.Operator = OPERATOR_ID.Text;
+
+ // variabili lette da + controlli
+ answ.EmrStop = estop.Checked;
+ if (automatic.Checked) answ.RunMode = "AUTOMATIC";
+ else if (mdi.Checked) answ.RunMode = "MANUAL_DATA_INPUT";
+ else if (edit.Checked) answ.RunMode = "EDIT";
+ else answ.RunMode = "MANUAL";
+
+ if (running.Checked) answ.ExeMode = "ACTIVE";
+ else if (feedhold.Checked) answ.ExeMode = "FEED_HOLD";
+ else if (stopped.Checked) answ.ExeMode = "STOPPED";
+ else if (ready.Checked) answ.ExeMode = "READY";
+
+ // ritorno oggetto!
+ return answ;
}
}
+ #endregion
+
+
private void message_Leave(object sender, EventArgs e)
{
+#if false
mMessage.Value = messageText.Text;
mMessage.ForceChanged();
- mAdapter.SendChanged();
+ mAdapter.SendChanged();
+#endif
}
private void xLoad_Scroll(object sender, ScrollEventArgs e)
@@ -396,10 +278,12 @@ namespace MTC_Sim
private void xPosition_Scroll(object sender, ScrollEventArgs e)
{
+#if false
mPosition.Value = xPosition.Value;
mAdapter.SendChanged();
- xPositionValue.Text = xPosition.Value.ToString();
+ xPositionValue.Text = xPosition.Value.ToString();
+#endif
}
private void cLoad_Scroll(object sender, ScrollEventArgs e)
@@ -409,21 +293,26 @@ namespace MTC_Sim
private void cSpeed_Scroll(object sender, ScrollEventArgs e)
{
+#if false
mSpeed.Value = cSpeed.Value * 100.0;
mAdapter.SendChanged();
- cSpeedValue.Text = mSpeed.Value.ToString();
+ cSpeedValue.Text = mSpeed.Value.ToString();
+#endif
}
private void coolant_CheckedChanged(object sender, EventArgs e)
{
+#if false
if (coolant.Checked)
mFillLevel.Add(Condition.Level.WARNING, "Coolant Low", "COOL", "LOW");
else
mFillLevel.Clear("COOL");
- mAdapter.SendChanged();
+ mAdapter.SendChanged();
+#endif
}
+
private void cuttingToolButton_Click(object sender, EventArgs e)
{
#if false
@@ -440,66 +329,7 @@ namespace MTC_Sim
}
- #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
@@ -515,16 +345,16 @@ namespace MTC_Sim
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;
+ if (agObj.codaM.Count > 0) agObj.STROBE_PLC = agObj.STROBE_PLC | Strobe.M_CODE;
+ if (agObj.codaS.Count > 0) agObj.STROBE_PLC = agObj.STROBE_PLC | Strobe.S_CODE;
+ if (agObj.codaT.Count > 0) agObj.STROBE_PLC = agObj.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;
+ if (agObj.STROBE_ADP > 0) agObj.STROBE_PLC -= agObj.STROBE_ADP;
// aggiorno visualizzazione strobe!
- STATUS_PLC_ADP.Text = binaryForm((int)STROBE_PLC);
- STATUS_ADP_PLC.Text = binaryForm((int)STROBE_ADP);
+ STATUS_PLC_ADP.Text = utils.binaryForm((int)agObj.STROBE_PLC);
+ STATUS_ADP_PLC.Text = utils.binaryForm((int)agObj.STROBE_ADP);
#if false
// verifica se ci sia un evento strobe da recepire...
@@ -556,25 +386,21 @@ namespace MTC_Sim
- 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());
+ lblCodaM.Text = string.Join(",", agObj.codaM.ToArray());
+ lblCodaT.Text = string.Join(",", agObj.codaT.ToArray());
+ lblCodaS.Text = string.Join(",", agObj.codaS.ToArray());
}
private void accodaCodM()
{
if (addCodM.Text.Trim() != "")
{
- codaM.Add(addCodM.Text.Trim());
+ agObj.codaM.Add(addCodM.Text.Trim());
addCodM.Text = "";
}
refreshCodeMST();
@@ -583,7 +409,7 @@ namespace MTC_Sim
{
if (addCodS.Text.Trim() != "")
{
- codaS.Add(addCodS.Text.Trim());
+ agObj.codaS.Add(addCodS.Text.Trim());
addCodS.Text = "";
}
refreshCodeMST();
@@ -592,7 +418,7 @@ namespace MTC_Sim
{
if (addCodT.Text.Trim() != "")
{
- codaT.Add(addCodT.Text.Trim());
+ agObj.codaT.Add(addCodT.Text.Trim());
addCodT.Text = "";
}
refreshCodeMST();
@@ -615,7 +441,6 @@ namespace MTC_Sim
{
accodaCodM();
}
-
private void addCodS_KeyDown(object sender, KeyEventArgs e)
{
@@ -630,13 +455,10 @@ namespace MTC_Sim
addCodS.Text = "";
}
}
-
private void addCodS_Leave(object sender, EventArgs e)
{
accodaCodS();
}
-
-
private void addCodT_KeyDown(object sender, KeyEventArgs e)
{
diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.resx b/MTC_Sim/MTC_Sim/CMS_MachineSim.resx
index 36b5f1d..d0af042 100644
--- a/MTC_Sim/MTC_Sim/CMS_MachineSim.resx
+++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.resx
@@ -141,4 +141,7 @@
True
+
+ 104, 17
+
\ No newline at end of file
diff --git a/MTC_Sim/MTC_Sim/MTC_Sim.csproj b/MTC_Sim/MTC_Sim/MTC_Sim.csproj
index 28c74cd..dde5336 100644
--- a/MTC_Sim/MTC_Sim/MTC_Sim.csproj
+++ b/MTC_Sim/MTC_Sim/MTC_Sim.csproj
@@ -48,6 +48,9 @@
+
+
+
Form
@@ -55,6 +58,12 @@
CMS_MachineSim.cs
+
+ Form
+
+
+ MainForm.cs
+
diff --git a/MTC_Sim/MTC_Sim/MainForm.Designer.cs b/MTC_Sim/MTC_Sim/MainForm.Designer.cs
new file mode 100644
index 0000000..080a1c6
--- /dev/null
+++ b/MTC_Sim/MTC_Sim/MainForm.Designer.cs
@@ -0,0 +1,38 @@
+namespace MTC_Sim
+{
+ partial class MainForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Text = "MainForm";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/MTC_Sim/MTC_Sim/MainForm.cs b/MTC_Sim/MTC_Sim/MainForm.cs
new file mode 100644
index 0000000..6872cd5
--- /dev/null
+++ b/MTC_Sim/MTC_Sim/MainForm.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace MTC_Sim
+{
+ public partial class MainForm : Form
+ {
+ public MainForm()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/MTC_Sim/MTC_Sim/utils.cs b/MTC_Sim/MTC_Sim/utils.cs
index 6c8b081..3bde8bd 100644
--- a/MTC_Sim/MTC_Sim/utils.cs
+++ b/MTC_Sim/MTC_Sim/utils.cs
@@ -62,8 +62,57 @@ namespace MTC_Sim
{
return ((value & flag) != 0);
}
+ ///
+ /// formatta un numero in forma binaria 0/1
+ ///
+ ///
+ ///
+ public static string binaryForm(int valore)
+ {
+ string answ = "";
+ try
+ {
+ answ = string.Format(new BinaryFormatter(), "{0:B}", valore);
+ }
+ catch
+ { }
+ return answ;
+ }
}
+
+ public enum tipoAdapter
+ {
+ ///
+ /// Adapter generico/demo
+ ///
+ Demo,
+ ///
+ /// adapter FANUC-CMS
+ ///
+ Fanuc,
+ ///
+ /// Adapter HMI-SCM
+ ///
+ HMI
+ }
+
+ ///
+ /// informazioni di produzione
+ ///
+ public struct prodData
+ {
+ public string ProgramName;
+ public string ProgrRow;
+ public string PartId;
+ public string Operator;
+ public bool EmrStop;
+ public string RunMode;
+ public string ExeMode;
+ }
+
+ //public struct runningData
+
///
/// Strobe: contiene il set di strobe di comunicazione
///