integrazione di codice esterno x adapter: tutto ok quasi finito x DEMO (base)
This commit is contained in:
Binary file not shown.
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// estende l'init della classe base...
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// estende l'init della classe base...
|
||||
/// </summary>
|
||||
public AdapterFanuc(CMS_MachineSim caller) : base(caller)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void getCurrProgramData()
|
||||
{
|
||||
// serve?!?
|
||||
base.getCurrProgramData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// adapter globale
|
||||
/// </summary>
|
||||
Adapter mAdapter = new Adapter();
|
||||
|
||||
protected CMS_MachineSim parentForm;
|
||||
|
||||
/// <summary>
|
||||
/// inizializzo l'oggetto sulla form
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
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<string> codaM = new List<string>();
|
||||
public List<string> codaS = new List<string>();
|
||||
public List<string> codaT = new List<string>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// D.D1.AVAIL - disponibilità
|
||||
/// </summary>
|
||||
public Event mAvail = new Event("avail");
|
||||
/// <summary>
|
||||
/// XX.XX.STOP - stop per pressione emergenze
|
||||
/// </summary>
|
||||
public Event mEStop = new Event("estop");
|
||||
|
||||
/// <summary>
|
||||
/// D.D1.NAME
|
||||
/// </summary>
|
||||
public Event mName = new Event("Name");
|
||||
/// <summary>
|
||||
/// D.D1.ID
|
||||
/// </summary>
|
||||
public Event mID = new Event("ID");
|
||||
/// <summary>
|
||||
/// D.D1.UUID
|
||||
/// </summary>
|
||||
public Event mUUID = new Event("UUID");
|
||||
/// <summary>
|
||||
/// D.D1.SAMPLE_INTERVAL
|
||||
/// </summary>
|
||||
public Event mSampleInt = new Event("SampleInt");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// CURR_PROG - programma in esecuzione
|
||||
/// </summary>
|
||||
public Event mProgram = new Event("CurrProg");
|
||||
/// <summary>
|
||||
/// CURR_PROG_ROWNUM - programma in esecuzione
|
||||
/// </summary>
|
||||
public Event mProgRowNum = new Event("CurrProg_RowNum");
|
||||
/// <summary>
|
||||
/// PartId - particolare prodotto
|
||||
/// </summary>
|
||||
public Event mPartId = new Event("PartID");
|
||||
/// <summary>
|
||||
/// CURR_PROG_ROWNUM - programma in esecuzione
|
||||
/// </summary>
|
||||
public Event mOperator = new Event("OperatorId");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// D.D1.P1.PATH_MODE - modalità esecuzione
|
||||
/// </summary>
|
||||
public Event mMode = new Event("mode");
|
||||
/// <summary>
|
||||
/// D.D1.P1.PATH_STATUS - status macchina
|
||||
/// </summary>
|
||||
public Event mExec = new Event("exec");
|
||||
|
||||
/// <summary>
|
||||
/// M_CODE
|
||||
/// </summary>
|
||||
public Event mCod_M = new Event("Cod_M");
|
||||
/// <summary>
|
||||
/// S_CODE
|
||||
/// </summary>
|
||||
public Event mCod_S = new Event("Cod_S");
|
||||
/// <summary>
|
||||
/// T_CODE
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Avvia l'adapter sulla porta richiesta
|
||||
/// </summary>
|
||||
/// <param name="port"></param>
|
||||
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();
|
||||
}
|
||||
/// <summary>
|
||||
/// ferma l'adapter...
|
||||
/// </summary>
|
||||
public void stopAdapter()
|
||||
{
|
||||
// Stop everything...
|
||||
mAdapter.Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua recupero dati ed invio valori modificati...
|
||||
/// </summary>
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// controllo codici MST
|
||||
/// </summary>
|
||||
public void getCodMST()
|
||||
{
|
||||
// SE presente recupero Cod_M/S/T
|
||||
checkCodM();
|
||||
checkCodS();
|
||||
checkCodT();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// metodo di recupero dei dati di identificativo macchina - DA CONF!!!
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupera primo elemento codaM
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// recupera primo elemento codaS
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// recupera primo elemento codaT
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
+52
-18
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+124
-302
@@ -24,149 +24,37 @@ namespace MTC_Sim
|
||||
public partial class CMS_MachineSim : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// adapter globale
|
||||
/// Oggetto x gestione dell'adapter GENERICO (x poter usare metodi di ognuno...)
|
||||
/// </summary>
|
||||
Adapter mAdapter = new Adapter();
|
||||
|
||||
AdapterGeneric agObj;
|
||||
/// <summary>
|
||||
/// D.D1.AVAIL - disponibilità
|
||||
/// tipo di adapter prescelto...
|
||||
/// </summary>
|
||||
Event mAvail = new Event("avail");
|
||||
/// <summary>
|
||||
/// XX.XX.STOP - stop per pressione emergenze
|
||||
/// </summary>
|
||||
Event mEStop = new Event("estop");
|
||||
|
||||
/// <summary>
|
||||
/// D.D1.NAME
|
||||
/// </summary>
|
||||
Event mName = new Event("Name");
|
||||
/// <summary>
|
||||
/// D.D1.ID
|
||||
/// </summary>
|
||||
Event mID = new Event("ID");
|
||||
/// <summary>
|
||||
/// D.D1.UUID
|
||||
/// </summary>
|
||||
Event mUUID = new Event("UUID");
|
||||
/// <summary>
|
||||
/// D.D1.SAMPLE_INTERVAL
|
||||
/// </summary>
|
||||
Event mSampleInt = new Event("SampleInt");
|
||||
protected tipoAdapter tipoScelto = tipoAdapter.Demo;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// CURR_PROG - programma in esecuzione
|
||||
/// </summary>
|
||||
Event mProgram = new Event("CurrProg");
|
||||
/// <summary>
|
||||
/// CURR_PROG_ROWNUM - programma in esecuzione
|
||||
/// </summary>
|
||||
Event mProgRowNum = new Event("CurrProg_RowNum");
|
||||
/// <summary>
|
||||
/// PartId - particolare prodotto
|
||||
/// </summary>
|
||||
Event mPartId = new Event("PartID");
|
||||
/// <summary>
|
||||
/// CURR_PROG_ROWNUM - programma in esecuzione
|
||||
/// </summary>
|
||||
Event mOperator = new Event("OperatorId");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// D.D1.P1.PATH_MODE - modalità esecuzione
|
||||
/// </summary>
|
||||
Event mMode = new Event("mode");
|
||||
/// <summary>
|
||||
/// D.D1.P1.PATH_STATUS - status macchina
|
||||
/// </summary>
|
||||
Event mExec = new Event("exec");
|
||||
|
||||
Strobe STROBE_PLC = 0;
|
||||
Strobe STROBE_ADP = 0;
|
||||
|
||||
/// <summary>
|
||||
/// M_CODE
|
||||
/// </summary>
|
||||
Event mCod_M = new Event("Cod_M");
|
||||
/// <summary>
|
||||
/// S_CODE
|
||||
/// </summary>
|
||||
Event mCod_S = new Event("Cod_S");
|
||||
/// <summary>
|
||||
/// T_CODE
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Avvio dell'adapter
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fermata dell'adapter
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Dati di produzione (su form)
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// recupera primo elemento codaM
|
||||
/// </summary>
|
||||
protected string getNextMCode
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (codaM.Count > 0)
|
||||
{
|
||||
// accodo codice M...
|
||||
answ = codaM.First();
|
||||
// tolgo elemento
|
||||
codaM.RemoveAt(0);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupera primo elemento codaS
|
||||
/// </summary>
|
||||
protected string getNextSCode
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (codaS.Count > 0)
|
||||
{
|
||||
// accodo codice S...
|
||||
answ = codaS.First();
|
||||
// tolgo elemento
|
||||
codaS.RemoveAt(0);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupera primo elemento codaT
|
||||
/// </summary>
|
||||
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<string> codaM = new List<string>();
|
||||
protected List<string> codaS = new List<string>();
|
||||
protected List<string> codaT = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// aggiorna visualizzazione code...
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
|
||||
|
||||
@@ -141,4 +141,7 @@
|
||||
<metadata name="cv23.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>104, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -48,6 +48,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdapterGeneric.cs" />
|
||||
<Compile Include="AdapterDemo.cs" />
|
||||
<Compile Include="AdapterFanuc.cs" />
|
||||
<Compile Include="BinaryFormatter.cs" />
|
||||
<Compile Include="CMS_MachineSim.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -55,6 +58,12 @@
|
||||
<Compile Include="CMS_MachineSim.Designer.cs">
|
||||
<DependentUpon>CMS_MachineSim.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="utils.cs" />
|
||||
|
||||
Generated
+38
@@ -0,0 +1,38 @@
|
||||
namespace MTC_Sim
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Text = "MainForm";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,8 +62,57 @@ namespace MTC_Sim
|
||||
{
|
||||
return ((value & flag) != 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// formatta un numero in forma binaria 0/1
|
||||
/// </summary>
|
||||
/// <param name="valore"></param>
|
||||
/// <returns></returns>
|
||||
public static string binaryForm(int valore)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format(new BinaryFormatter(), "{0:B}", valore);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum tipoAdapter
|
||||
{
|
||||
/// <summary>
|
||||
/// Adapter generico/demo
|
||||
/// </summary>
|
||||
Demo,
|
||||
/// <summary>
|
||||
/// adapter FANUC-CMS
|
||||
/// </summary>
|
||||
Fanuc,
|
||||
/// <summary>
|
||||
/// Adapter HMI-SCM
|
||||
/// </summary>
|
||||
HMI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// informazioni di produzione
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Strobe: contiene il set di strobe di comunicazione
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user