Aggiunti primi campi definiti in variabili_00

This commit is contained in:
Samuele E. Locatelli
2016-03-31 12:03:42 +02:00
parent 9985acf7fb
commit 214ac85baf
6 changed files with 277 additions and 39 deletions
Binary file not shown.
+6
View File
@@ -3,4 +3,10 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<add key="timerInt" value="1000"/>
<add key="D1_NAME" value="ARES-SIM"/>
<add key="D1_ID" value="12345"/>
<add key="D1_UUID" value="asdf12345erty9876"/>
</appSettings>
</configuration>
+143 -34
View File
@@ -68,7 +68,6 @@
this.mdi = new System.Windows.Forms.RadioButton();
this.manual = new System.Windows.Forms.RadioButton();
this.automatic = new System.Windows.Forms.RadioButton();
this.estop = new System.Windows.Forms.CheckBox();
this.Execution = new System.Windows.Forms.GroupBox();
this.ready = new System.Windows.Forms.RadioButton();
this.feedhold = new System.Windows.Forms.RadioButton();
@@ -89,6 +88,16 @@
this.xLoad = new System.Windows.Forms.HScrollBar();
this.program = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.groupBox7 = new System.Windows.Forms.GroupBox();
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.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.commonVariables)).BeginInit();
@@ -98,6 +107,8 @@
this.Execution.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox7.SuspendLayout();
this.groupBox8.SuspendLayout();
this.SuspendLayout();
//
// flazBat
@@ -126,7 +137,7 @@
this.groupBox4.Controls.Add(this.label7);
this.groupBox4.Controls.Add(this.messageText);
this.groupBox4.Controls.Add(this.messageCode);
this.groupBox4.Location = new System.Drawing.Point(20, 269);
this.groupBox4.Location = new System.Drawing.Point(11, 330);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(375, 52);
this.groupBox4.TabIndex = 44;
@@ -169,14 +180,14 @@
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(21, 306);
this.label6.Location = new System.Drawing.Point(12, 367);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(0, 13);
this.label6.TabIndex = 43;
//
// cuttingToolButton
//
this.cuttingToolButton.Location = new System.Drawing.Point(512, 344);
this.cuttingToolButton.Location = new System.Drawing.Point(511, 657);
this.cuttingToolButton.Name = "cuttingToolButton";
this.cuttingToolButton.Size = new System.Drawing.Size(75, 23);
this.cuttingToolButton.TabIndex = 42;
@@ -193,7 +204,7 @@
this.groupBox5.Controls.Add(this.label10);
this.groupBox5.Controls.Add(this.label11);
this.groupBox5.Controls.Add(this.cLoad);
this.groupBox5.Location = new System.Drawing.Point(411, 103);
this.groupBox5.Location = new System.Drawing.Point(410, 416);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(375, 70);
this.groupBox5.TabIndex = 45;
@@ -258,7 +269,7 @@
//
// partID
//
this.partID.Location = new System.Drawing.Point(286, 240);
this.partID.Location = new System.Drawing.Point(277, 301);
this.partID.Name = "partID";
this.partID.Size = new System.Drawing.Size(100, 20);
this.partID.TabIndex = 49;
@@ -266,7 +277,7 @@
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(220, 243);
this.label13.Location = new System.Drawing.Point(211, 304);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(40, 13);
this.label13.TabIndex = 48;
@@ -281,7 +292,7 @@
"TEARDOWN",
"MAINTENANCE",
"PROCESS_DEVELOPMENT"});
this.functionalMode.Location = new System.Drawing.Point(111, 212);
this.functionalMode.Location = new System.Drawing.Point(102, 273);
this.functionalMode.Name = "functionalMode";
this.functionalMode.Size = new System.Drawing.Size(121, 21);
this.functionalMode.TabIndex = 47;
@@ -290,7 +301,7 @@
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(22, 215);
this.label12.Location = new System.Drawing.Point(13, 276);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(86, 13);
this.label12.TabIndex = 46;
@@ -345,7 +356,7 @@
// groupBox6
//
this.groupBox6.Controls.Add(this.commonVariables);
this.groupBox6.Location = new System.Drawing.Point(21, 327);
this.groupBox6.Location = new System.Drawing.Point(12, 388);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(374, 74);
this.groupBox6.TabIndex = 50;
@@ -364,20 +375,21 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dump);
this.groupBox1.Controls.Add(this.stop);
this.groupBox1.Controls.Add(this.start);
this.groupBox1.Controls.Add(this.port);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(21, 27);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(322, 43);
this.groupBox1.Size = new System.Drawing.Size(379, 43);
this.groupBox1.TabIndex = 34;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Server Info";
//
// stop
//
this.stop.Location = new System.Drawing.Point(213, 14);
this.stop.Location = new System.Drawing.Point(202, 15);
this.stop.Name = "stop";
this.stop.Size = new System.Drawing.Size(75, 23);
this.stop.TabIndex = 3;
@@ -387,7 +399,7 @@
//
// start
//
this.start.Location = new System.Drawing.Point(132, 14);
this.start.Location = new System.Drawing.Point(121, 15);
this.start.Name = "start";
this.start.Size = new System.Drawing.Size(75, 23);
this.start.TabIndex = 2;
@@ -419,7 +431,7 @@
this.mode.Controls.Add(this.mdi);
this.mode.Controls.Add(this.manual);
this.mode.Controls.Add(this.automatic);
this.mode.Location = new System.Drawing.Point(21, 103);
this.mode.Location = new System.Drawing.Point(12, 93);
this.mode.Name = "mode";
this.mode.Size = new System.Drawing.Size(379, 48);
this.mode.TabIndex = 36;
@@ -468,24 +480,13 @@
this.automatic.Text = "Automatic";
this.automatic.UseVisualStyleBackColor = true;
//
// estop
//
this.estop.AutoSize = true;
this.estop.Location = new System.Drawing.Point(21, 79);
this.estop.Name = "estop";
this.estop.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.estop.Size = new System.Drawing.Size(104, 17);
this.estop.TabIndex = 35;
this.estop.Text = "Emergency Stop";
this.estop.UseVisualStyleBackColor = true;
//
// Execution
//
this.Execution.Controls.Add(this.ready);
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(21, 154);
this.Execution.Location = new System.Drawing.Point(406, 93);
this.Execution.Name = "Execution";
this.Execution.Size = new System.Drawing.Size(379, 48);
this.Execution.TabIndex = 37;
@@ -543,7 +544,7 @@
this.groupBox3.Controls.Add(this.coolant);
this.groupBox3.Controls.Add(this.noProgram);
this.groupBox3.Controls.Add(this.overload);
this.groupBox3.Location = new System.Drawing.Point(411, 179);
this.groupBox3.Location = new System.Drawing.Point(410, 492);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(375, 114);
this.groupBox3.TabIndex = 41;
@@ -600,7 +601,7 @@
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.xLoad);
this.groupBox2.Location = new System.Drawing.Point(411, 27);
this.groupBox2.Location = new System.Drawing.Point(410, 340);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(375, 70);
this.groupBox2.TabIndex = 40;
@@ -665,7 +666,7 @@
//
// program
//
this.program.Location = new System.Drawing.Point(111, 240);
this.program.Location = new System.Drawing.Point(102, 301);
this.program.Name = "program";
this.program.Size = new System.Drawing.Size(100, 20);
this.program.TabIndex = 39;
@@ -673,17 +674,113 @@
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(22, 243);
this.label2.Location = new System.Drawing.Point(13, 304);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(46, 13);
this.label2.TabIndex = 38;
this.label2.Text = "Program";
//
// groupBox7
//
this.groupBox7.Controls.Add(this.label16);
this.groupBox7.Controls.Add(this.D1_UUID);
this.groupBox7.Controls.Add(this.label15);
this.groupBox7.Controls.Add(this.D1_ID);
this.groupBox7.Controls.Add(this.label14);
this.groupBox7.Controls.Add(this.D1_NAME);
this.groupBox7.Location = new System.Drawing.Point(405, 12);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(380, 75);
this.groupBox7.TabIndex = 53;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "Macchina";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(10, 20);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(35, 13);
this.label14.TabIndex = 54;
this.label14.Text = "Nome";
//
// D1_NAME
//
this.D1_NAME.Location = new System.Drawing.Point(51, 17);
this.D1_NAME.Name = "D1_NAME";
this.D1_NAME.Size = new System.Drawing.Size(174, 20);
this.D1_NAME.TabIndex = 53;
//
// estop
//
this.estop.AutoSize = true;
this.estop.Location = new System.Drawing.Point(269, 8);
this.estop.Name = "estop";
this.estop.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.estop.Size = new System.Drawing.Size(104, 17);
this.estop.TabIndex = 55;
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);
this.groupBox8.Location = new System.Drawing.Point(12, 56);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(379, 31);
this.groupBox8.TabIndex = 54;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "Sicurezze";
//
// CMS_MachineSim
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(834, 434);
this.ClientSize = new System.Drawing.Size(794, 733);
this.Controls.Add(this.groupBox8);
this.Controls.Add(this.groupBox7);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.label6);
this.Controls.Add(this.cuttingToolButton);
@@ -695,7 +792,6 @@
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.mode);
this.Controls.Add(this.estop);
this.Controls.Add(this.Execution);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
@@ -719,6 +815,10 @@
this.groupBox3.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox7.ResumeLayout(false);
this.groupBox7.PerformLayout();
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -765,7 +865,6 @@
private System.Windows.Forms.RadioButton mdi;
private System.Windows.Forms.RadioButton manual;
private System.Windows.Forms.RadioButton automatic;
private System.Windows.Forms.CheckBox estop;
private System.Windows.Forms.GroupBox Execution;
private System.Windows.Forms.RadioButton ready;
private System.Windows.Forms.RadioButton feedhold;
@@ -786,6 +885,16 @@
private System.Windows.Forms.HScrollBar xLoad;
private System.Windows.Forms.TextBox program;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button dump;
private System.Windows.Forms.GroupBox groupBox7;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.TextBox D1_UUID;
private System.Windows.Forms.Label label15;
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;
}
}
+80 -5
View File
@@ -18,18 +18,60 @@ using System.Windows.Forms;
namespace MTC_Sim
{
using MTConnect;
using System.Configuration;
using System.Diagnostics;
public partial class CMS_MachineSim : Form
{
/// <summary>
/// adapter globale
/// </summary>
Adapter mAdapter = new Adapter();
/// <summary>
/// D.D1.AVAIL - disponibilità
/// </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");
/// <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");
Event mFunctionalMode = new Event("func");
/// <summary>
/// - programma in esecuzione
/// </summary>
Event mProgram = new Event("program");
Event mFunctionalMode = new Event("func");
Message mMessage = new Message("message");
Sample mPosition = new Sample("xPosition");
@@ -49,13 +91,24 @@ namespace MTC_Sim
public CMS_MachineSim()
{
InitializeComponent();
stop.Enabled = false;
// carico i default values
setDefaults();
stop.Enabled = false;
// 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);
mAdapter.AddDataItem(mMode);
mAdapter.AddDataItem(mExec);
@@ -80,6 +133,15 @@ namespace MTC_Sim
string[] row = { "1", "2", "3", "4" };
commonVariables.Rows.Add(row);
}
/// <summary>
/// impostazione valori defaults
/// </summary>
private void setDefaults()
{
D1_NAME.Text = utils.CRS("D1_NAME");
D1_ID.Text = utils.CRS("D1_ID");
D1_UUID.Text = utils.CRS("D1_UUID");
}
private void start_Click(object sender, EventArgs e)
{
@@ -87,12 +149,13 @@ namespace MTC_Sim
mAdapter.Port = Convert.ToInt32(port.Text);
mAdapter.Start();
// Disable start and enable stop.
// Disable start and enable stop/dump.
start.Enabled = false;
stop.Enabled = true;
dump.Enabled = true;
// Start our periodic timer
gather.Interval = 1000;
gather.Interval = utils.CRI("timerInt");
gather.Enabled = true;
mSystem.Normal();
@@ -109,6 +172,7 @@ namespace MTC_Sim
// Stop everything...
mAdapter.Stop();
stop.Enabled = false;
dump.Enabled = false;
start.Enabled = true;
gather.Enabled = false;
}
@@ -117,6 +181,10 @@ namespace MTC_Sim
{
mAdapter.Begin();
mName.Value = D1_NAME.Text;
mID.Value = D1_ID.Text;
mUUID.Value = D1_UUID.Text;
if (estop.Checked)
mEStop.Value = "TRIGGERED";
else
@@ -229,5 +297,12 @@ namespace MTC_Sim
toolWindow.Show(this);
#endif
}
// apro eseguibile dump
private void dump_Click(object sender, EventArgs e)
{
string path = Application.StartupPath;
Process.Start(string.Format(@"{0}\..\..\dump\dump.exe",path));
}
}
}
+2
View File
@@ -34,6 +34,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -54,6 +55,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="utils.cs" />
<EmbeddedResource Include="CMS_MachineSim.resx">
<DependentUpon>CMS_MachineSim.cs</DependentUpon>
</EmbeddedResource>
+46
View File
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTC_Sim
{
public class utils
{
/// <summary>
/// legge conf in formato stringa
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string CRS(string key)
{
string answ = "";
try
{
answ = ConfigurationManager.AppSettings[key].ToString();
}
catch
{ }
return answ;
}
/// <summary>
/// legge conf in formato INT
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static Int32 CRI(string key)
{
int answ = 0;
try
{
answ = Convert.ToInt32(CRS(key));
}
catch
{ }
return answ;
}
}
}