Porting iniziale demo project... ora si inizia ad integrare info definite CMS

This commit is contained in:
Samuele E. Locatelli
2016-03-31 10:02:50 +02:00
parent 541a1d0821
commit 9985acf7fb
13 changed files with 1392 additions and 63 deletions
+10
View File
@@ -1,4 +1,14 @@
# git ignore file
bin
obj
*.csproj.user
System.pdb
TestResults
*.suo
*.exe
*.obj
Tests.VisualState.xml
TestResult.xml
# -----------------------------------------------
# MTC_AdapterTest
Binary file not shown.
Binary file not shown.
+6
View File
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTC_Sim", "MTC_Sim\MTC_Sim.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTC_AdapterTest", "MTC_AdapterTest\MTC_AdapterTest.csproj", "{460848B8-154B-469F-915A-5E550AA68D71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetAdapterSDK", "..\..\..\GitHub\MTConnect\dot_net_sdk\DotNetAdapterSDK.csproj", "{D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{460848B8-154B-469F-915A-5E550AA68D71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{460848B8-154B-469F-915A-5E550AA68D71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{460848B8-154B-469F-915A-5E550AA68D71}.Release|Any CPU.Build.0 = Release|Any CPU
{D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+791
View File
@@ -0,0 +1,791 @@
namespace MTC_Sim
{
partial class CMS_MachineSim
{
/// <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.flazBat = new System.Windows.Forms.CheckBox();
this.cv24 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.gather = new System.Windows.Forms.Timer(this.components);
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.messageText = new System.Windows.Forms.TextBox();
this.messageCode = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.cuttingToolButton = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.cSpeedValue = new System.Windows.Forms.TextBox();
this.cLoadValue = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.cSpeed = new System.Windows.Forms.HScrollBar();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.cLoad = new System.Windows.Forms.HScrollBar();
this.partID = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.functionalMode = new System.Windows.Forms.ComboBox();
this.label12 = new System.Windows.Forms.Label();
this.commonVariables = new System.Windows.Forms.DataGridView();
this.cv21 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.cv22 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.cv23 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.travel = new System.Windows.Forms.CheckBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.something = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.stop = new System.Windows.Forms.Button();
this.start = new System.Windows.Forms.Button();
this.port = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.mode = new System.Windows.Forms.GroupBox();
this.edit = new System.Windows.Forms.RadioButton();
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();
this.stopped = new System.Windows.Forms.RadioButton();
this.running = new System.Windows.Forms.RadioButton();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.overtemp = new System.Windows.Forms.CheckBox();
this.coolant = new System.Windows.Forms.CheckBox();
this.noProgram = new System.Windows.Forms.CheckBox();
this.overload = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.xPositionValue = new System.Windows.Forms.TextBox();
this.xLoadValue = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.xPosition = new System.Windows.Forms.HScrollBar();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.xLoad = new System.Windows.Forms.HScrollBar();
this.program = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.commonVariables)).BeginInit();
this.groupBox6.SuspendLayout();
this.groupBox1.SuspendLayout();
this.mode.SuspendLayout();
this.Execution.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// flazBat
//
this.flazBat.AutoSize = true;
this.flazBat.Location = new System.Drawing.Point(151, 43);
this.flazBat.Name = "flazBat";
this.flazBat.Size = new System.Drawing.Size(76, 17);
this.flazBat.TabIndex = 6;
this.flazBat.Text = "FLAZ BAT";
this.flazBat.UseVisualStyleBackColor = true;
//
// cv24
//
this.cv24.HeaderText = "24";
this.cv24.Name = "cv24";
this.cv24.Width = 75;
//
// gather
//
this.gather.Tick += new System.EventHandler(this.gather_Tick);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label8);
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.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(375, 52);
this.groupBox4.TabIndex = 44;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Message";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(118, 26);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(28, 13);
this.label8.TabIndex = 19;
this.label8.Text = "Text";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(4, 26);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(32, 13);
this.label7.TabIndex = 18;
this.label7.Text = "Code";
//
// messageText
//
this.messageText.Location = new System.Drawing.Point(151, 23);
this.messageText.Name = "messageText";
this.messageText.Size = new System.Drawing.Size(215, 20);
this.messageText.TabIndex = 14;
this.messageText.Leave += new System.EventHandler(this.message_Leave);
//
// messageCode
//
this.messageCode.Location = new System.Drawing.Point(50, 23);
this.messageCode.Name = "messageCode";
this.messageCode.Size = new System.Drawing.Size(62, 20);
this.messageCode.TabIndex = 13;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(21, 306);
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.Name = "cuttingToolButton";
this.cuttingToolButton.Size = new System.Drawing.Size(75, 23);
this.cuttingToolButton.TabIndex = 42;
this.cuttingToolButton.Text = "Add Tool";
this.cuttingToolButton.UseVisualStyleBackColor = true;
this.cuttingToolButton.Click += new System.EventHandler(this.cuttingToolButton_Click);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.cSpeedValue);
this.groupBox5.Controls.Add(this.cLoadValue);
this.groupBox5.Controls.Add(this.label9);
this.groupBox5.Controls.Add(this.cSpeed);
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.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(375, 70);
this.groupBox5.TabIndex = 45;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Rotary C (Spindle)";
//
// cSpeedValue
//
this.cSpeedValue.Location = new System.Drawing.Point(266, 39);
this.cSpeedValue.Name = "cSpeedValue";
this.cSpeedValue.Size = new System.Drawing.Size(100, 20);
this.cSpeedValue.TabIndex = 26;
//
// cLoadValue
//
this.cLoadValue.Location = new System.Drawing.Point(266, 16);
this.cLoadValue.Name = "cLoadValue";
this.cLoadValue.Size = new System.Drawing.Size(100, 20);
this.cLoadValue.TabIndex = 25;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 43);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(38, 13);
this.label9.TabIndex = 24;
this.label9.Text = "Speed";
//
// cSpeed
//
this.cSpeed.Location = new System.Drawing.Point(82, 39);
this.cSpeed.Name = "cSpeed";
this.cSpeed.Size = new System.Drawing.Size(168, 18);
this.cSpeed.TabIndex = 23;
this.cSpeed.Scroll += new System.Windows.Forms.ScrollEventHandler(this.cSpeed_Scroll);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(12, 22);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(31, 13);
this.label10.TabIndex = 22;
this.label10.Text = "Load";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(88, 39);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(0, 13);
this.label11.TabIndex = 21;
//
// cLoad
//
this.cLoad.Location = new System.Drawing.Point(82, 18);
this.cLoad.Name = "cLoad";
this.cLoad.Size = new System.Drawing.Size(168, 18);
this.cLoad.TabIndex = 20;
this.cLoad.Scroll += new System.Windows.Forms.ScrollEventHandler(this.cLoad_Scroll);
//
// partID
//
this.partID.Location = new System.Drawing.Point(286, 240);
this.partID.Name = "partID";
this.partID.Size = new System.Drawing.Size(100, 20);
this.partID.TabIndex = 49;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(220, 243);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(40, 13);
this.label13.TabIndex = 48;
this.label13.Text = "Part ID";
//
// functionalMode
//
this.functionalMode.FormattingEnabled = true;
this.functionalMode.Items.AddRange(new object[] {
"PRODUCTION",
"SETUP",
"TEARDOWN",
"MAINTENANCE",
"PROCESS_DEVELOPMENT"});
this.functionalMode.Location = new System.Drawing.Point(111, 212);
this.functionalMode.Name = "functionalMode";
this.functionalMode.Size = new System.Drawing.Size(121, 21);
this.functionalMode.TabIndex = 47;
this.functionalMode.Text = "SETUP";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(22, 215);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(86, 13);
this.label12.TabIndex = 46;
this.label12.Text = "Functional Mode";
//
// commonVariables
//
this.commonVariables.AllowUserToAddRows = false;
this.commonVariables.AllowUserToDeleteRows = false;
this.commonVariables.AllowUserToResizeColumns = false;
this.commonVariables.AllowUserToResizeRows = false;
this.commonVariables.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.commonVariables.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.cv21,
this.cv22,
this.cv23,
this.cv24});
this.commonVariables.Location = new System.Drawing.Point(9, 17);
this.commonVariables.Name = "commonVariables";
this.commonVariables.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.commonVariables.Size = new System.Drawing.Size(344, 48);
this.commonVariables.TabIndex = 32;
//
// cv21
//
this.cv21.HeaderText = "21";
this.cv21.Name = "cv21";
this.cv21.Width = 75;
//
// cv22
//
this.cv22.HeaderText = "22";
this.cv22.Name = "cv22";
this.cv22.Width = 75;
//
// cv23
//
this.cv23.HeaderText = "23";
this.cv23.Name = "cv23";
this.cv23.Width = 75;
//
// travel
//
this.travel.AutoSize = true;
this.travel.Location = new System.Drawing.Point(151, 89);
this.travel.Name = "travel";
this.travel.Size = new System.Drawing.Size(155, 17);
this.travel.TabIndex = 5;
this.travel.Text = "FM_1_Achse_Positionierun";
this.travel.UseVisualStyleBackColor = true;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.commonVariables);
this.groupBox6.Location = new System.Drawing.Point(21, 327);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(374, 74);
this.groupBox6.TabIndex = 50;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Common Variables (EXT)";
//
// something
//
this.something.AutoSize = true;
this.something.Location = new System.Drawing.Point(151, 20);
this.something.Name = "something";
this.something.Size = new System.Drawing.Size(89, 17);
this.something.TabIndex = 4;
this.something.Text = "ALR DK TLD";
this.something.UseVisualStyleBackColor = true;
//
// groupBox1
//
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.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(322, 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.Name = "stop";
this.stop.Size = new System.Drawing.Size(75, 23);
this.stop.TabIndex = 3;
this.stop.Text = "Stop";
this.stop.UseVisualStyleBackColor = true;
this.stop.Click += new System.EventHandler(this.stop_Click);
//
// start
//
this.start.Location = new System.Drawing.Point(132, 14);
this.start.Name = "start";
this.start.Size = new System.Drawing.Size(75, 23);
this.start.TabIndex = 2;
this.start.Text = "Start";
this.start.UseVisualStyleBackColor = true;
this.start.Click += new System.EventHandler(this.start_Click);
//
// port
//
this.port.Location = new System.Drawing.Point(50, 17);
this.port.Name = "port";
this.port.Size = new System.Drawing.Size(62, 20);
this.port.TabIndex = 1;
this.port.Text = "7878";
this.port.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(18, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(26, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Port";
//
// mode
//
this.mode.Controls.Add(this.edit);
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.Name = "mode";
this.mode.Size = new System.Drawing.Size(379, 48);
this.mode.TabIndex = 36;
this.mode.TabStop = false;
this.mode.Text = "Mode";
//
// edit
//
this.edit.AutoSize = true;
this.edit.Location = new System.Drawing.Point(299, 16);
this.edit.Name = "edit";
this.edit.Size = new System.Drawing.Size(43, 17);
this.edit.TabIndex = 9;
this.edit.Text = "Edit";
this.edit.UseVisualStyleBackColor = true;
//
// mdi
//
this.mdi.AutoSize = true;
this.mdi.Location = new System.Drawing.Point(180, 15);
this.mdi.Name = "mdi";
this.mdi.Size = new System.Drawing.Size(113, 17);
this.mdi.TabIndex = 8;
this.mdi.Text = "Manual Data Input";
this.mdi.UseVisualStyleBackColor = true;
//
// manual
//
this.manual.AutoSize = true;
this.manual.Checked = true;
this.manual.Location = new System.Drawing.Point(114, 15);
this.manual.Name = "manual";
this.manual.Size = new System.Drawing.Size(60, 17);
this.manual.TabIndex = 7;
this.manual.TabStop = true;
this.manual.Text = "Manual";
this.manual.UseVisualStyleBackColor = true;
//
// automatic
//
this.automatic.AutoSize = true;
this.automatic.Location = new System.Drawing.Point(36, 16);
this.automatic.Name = "automatic";
this.automatic.Size = new System.Drawing.Size(72, 17);
this.automatic.TabIndex = 6;
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.Name = "Execution";
this.Execution.Size = new System.Drawing.Size(379, 48);
this.Execution.TabIndex = 37;
this.Execution.TabStop = false;
this.Execution.Text = "Execution";
//
// ready
//
this.ready.AutoSize = true;
this.ready.Checked = true;
this.ready.Location = new System.Drawing.Point(114, 16);
this.ready.Name = "ready";
this.ready.Size = new System.Drawing.Size(56, 17);
this.ready.TabIndex = 9;
this.ready.TabStop = true;
this.ready.Text = "Ready";
this.ready.UseVisualStyleBackColor = true;
//
// feedhold
//
this.feedhold.AutoSize = true;
this.feedhold.Location = new System.Drawing.Point(253, 16);
this.feedhold.Name = "feedhold";
this.feedhold.Size = new System.Drawing.Size(74, 17);
this.feedhold.TabIndex = 8;
this.feedhold.Text = "Feed Hold";
this.feedhold.UseVisualStyleBackColor = true;
//
// stopped
//
this.stopped.AutoSize = true;
this.stopped.Location = new System.Drawing.Point(180, 16);
this.stopped.Name = "stopped";
this.stopped.Size = new System.Drawing.Size(65, 17);
this.stopped.TabIndex = 7;
this.stopped.Text = "Stopped";
this.stopped.UseVisualStyleBackColor = true;
//
// running
//
this.running.AutoSize = true;
this.running.Location = new System.Drawing.Point(36, 16);
this.running.Name = "running";
this.running.Size = new System.Drawing.Size(65, 17);
this.running.TabIndex = 6;
this.running.Text = "Running";
this.running.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.flazBat);
this.groupBox3.Controls.Add(this.travel);
this.groupBox3.Controls.Add(this.something);
this.groupBox3.Controls.Add(this.overtemp);
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.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(375, 114);
this.groupBox3.TabIndex = 41;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Alarms";
//
// overtemp
//
this.overtemp.AutoSize = true;
this.overtemp.Location = new System.Drawing.Point(7, 89);
this.overtemp.Name = "overtemp";
this.overtemp.Size = new System.Drawing.Size(72, 17);
this.overtemp.TabIndex = 3;
this.overtemp.Text = "Overtemp";
this.overtemp.UseVisualStyleBackColor = true;
//
// coolant
//
this.coolant.AutoSize = true;
this.coolant.Location = new System.Drawing.Point(7, 66);
this.coolant.Name = "coolant";
this.coolant.Size = new System.Drawing.Size(85, 17);
this.coolant.TabIndex = 2;
this.coolant.Text = "Coolant Low";
this.coolant.UseVisualStyleBackColor = true;
this.coolant.CheckedChanged += new System.EventHandler(this.coolant_CheckedChanged);
//
// noProgram
//
this.noProgram.AutoSize = true;
this.noProgram.Location = new System.Drawing.Point(7, 43);
this.noProgram.Name = "noProgram";
this.noProgram.Size = new System.Drawing.Size(82, 17);
this.noProgram.TabIndex = 1;
this.noProgram.Text = "No Program";
this.noProgram.UseVisualStyleBackColor = true;
//
// overload
//
this.overload.AutoSize = true;
this.overload.Location = new System.Drawing.Point(7, 20);
this.overload.Name = "overload";
this.overload.Size = new System.Drawing.Size(91, 17);
this.overload.TabIndex = 0;
this.overload.Text = "Axis Overload";
this.overload.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.xPositionValue);
this.groupBox2.Controls.Add(this.xLoadValue);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.xPosition);
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.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(375, 70);
this.groupBox2.TabIndex = 40;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "X Axis";
//
// xPositionValue
//
this.xPositionValue.Location = new System.Drawing.Point(266, 39);
this.xPositionValue.Name = "xPositionValue";
this.xPositionValue.Size = new System.Drawing.Size(100, 20);
this.xPositionValue.TabIndex = 26;
//
// xLoadValue
//
this.xLoadValue.Location = new System.Drawing.Point(266, 16);
this.xLoadValue.Name = "xLoadValue";
this.xLoadValue.Size = new System.Drawing.Size(100, 20);
this.xLoadValue.TabIndex = 25;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 43);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(44, 13);
this.label5.TabIndex = 24;
this.label5.Text = "Position";
//
// xPosition
//
this.xPosition.Location = new System.Drawing.Point(82, 39);
this.xPosition.Name = "xPosition";
this.xPosition.Size = new System.Drawing.Size(168, 18);
this.xPosition.TabIndex = 23;
this.xPosition.Scroll += new System.Windows.Forms.ScrollEventHandler(this.xPosition_Scroll);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 22);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(31, 13);
this.label4.TabIndex = 22;
this.label4.Text = "Load";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(88, 39);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 13);
this.label3.TabIndex = 21;
//
// xLoad
//
this.xLoad.Location = new System.Drawing.Point(82, 18);
this.xLoad.Name = "xLoad";
this.xLoad.Size = new System.Drawing.Size(168, 18);
this.xLoad.TabIndex = 20;
this.xLoad.Scroll += new System.Windows.Forms.ScrollEventHandler(this.xLoad_Scroll);
//
// program
//
this.program.Location = new System.Drawing.Point(111, 240);
this.program.Name = "program";
this.program.Size = new System.Drawing.Size(100, 20);
this.program.TabIndex = 39;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(22, 243);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(46, 13);
this.label2.TabIndex = 38;
this.label2.Text = "Program";
//
// 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.Controls.Add(this.groupBox4);
this.Controls.Add(this.label6);
this.Controls.Add(this.cuttingToolButton);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.partID);
this.Controls.Add(this.label13);
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);
this.Controls.Add(this.estop);
this.Controls.Add(this.Execution);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.program);
this.Controls.Add(this.label2);
this.Name = "CMS_MachineSim";
this.Text = "CMS MTConn Adapter SIM";
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.commonVariables)).EndInit();
this.groupBox6.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.mode.ResumeLayout(false);
this.mode.PerformLayout();
this.Execution.ResumeLayout(false);
this.Execution.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.CheckBox flazBat;
private System.Windows.Forms.DataGridViewTextBoxColumn cv24;
private System.Windows.Forms.Timer gather;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox messageText;
private System.Windows.Forms.TextBox messageCode;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button cuttingToolButton;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.TextBox cSpeedValue;
private System.Windows.Forms.TextBox cLoadValue;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.HScrollBar cSpeed;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.HScrollBar cLoad;
private System.Windows.Forms.TextBox partID;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.ComboBox functionalMode;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.DataGridView commonVariables;
private System.Windows.Forms.DataGridViewTextBoxColumn cv21;
private System.Windows.Forms.DataGridViewTextBoxColumn cv22;
private System.Windows.Forms.DataGridViewTextBoxColumn cv23;
private System.Windows.Forms.CheckBox travel;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.CheckBox something;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button stop;
private System.Windows.Forms.Button start;
private System.Windows.Forms.TextBox port;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox mode;
private System.Windows.Forms.RadioButton edit;
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;
private System.Windows.Forms.RadioButton stopped;
private System.Windows.Forms.RadioButton running;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox overtemp;
private System.Windows.Forms.CheckBox coolant;
private System.Windows.Forms.CheckBox noProgram;
private System.Windows.Forms.CheckBox overload;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox xPositionValue;
private System.Windows.Forms.TextBox xLoadValue;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.HScrollBar xPosition;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.HScrollBar xLoad;
private System.Windows.Forms.TextBox program;
private System.Windows.Forms.Label label2;
}
}
+233
View File
@@ -0,0 +1,233 @@
/*
* Copyright Copyright 2016, Steamware s.r.l. & CMS s.p.a.
*
* Based on data, code and example by MTC consortium & System Insights, Inc.
*
* */
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
{
using MTConnect;
public partial class CMS_MachineSim : Form
{
Adapter mAdapter = new Adapter();
Event mAvail = new Event("avail");
Event mEStop = new Event("estop");
Event mMode = new Event("mode");
Event mExec = new Event("exec");
Event mFunctionalMode = new Event("func");
Event mProgram = new Event("program");
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();
stop.Enabled = false;
mAdapter.AddDataItem(mAvail);
mAvail.Value = "AVAILABLE";
mAdapter.AddDataItem(mEStop);
mAdapter.AddDataItem(mMode);
mAdapter.AddDataItem(mExec);
mAdapter.AddDataItem(mFunctionalMode);
mAdapter.AddDataItem(mProgram);
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);
}
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();
// Disable start and enable stop.
start.Enabled = false;
stop.Enabled = true;
// Start our periodic timer
gather.Interval = 1000;
gather.Enabled = true;
mSystem.Normal();
mTemp.Normal();
mOverload.Normal();
mTravel.Normal();
mFillLevel.Normal();
//mWave.StartRecording();
}
private void stop_Click(object sender, EventArgs e)
{
// Stop everything...
mAdapter.Stop();
stop.Enabled = false;
start.Enabled = true;
gather.Enabled = false;
}
private void gather_Tick(object sender, EventArgs e)
{
mAdapter.Begin();
if (estop.Checked)
mEStop.Value = "TRIGGERED";
else
mEStop.Value = "ARMED";
if (automatic.Checked)
mMode.Value = "AUTOMATIC";
else if (mdi.Checked)
mMode.Value = "MANUAL_DATA_INPUT";
else if (edit.Checked)
mMode.Value = "EDIT";
else
mMode.Value = "MANUAL";
if (running.Checked)
mExec.Value = "ACTIVE";
else if (feedhold.Checked)
mExec.Value = "FEED_HOLD";
else if (stopped.Checked)
mExec.Value = "STOPPED";
else if (ready.Checked)
mExec.Value = "READY";
mFunctionalMode.Value = functionalMode.Text;
mProgram.Value = program.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;
mAdapter.SendChanged();
}
private void message_Leave(object sender, EventArgs e)
{
mMessage.Value = messageText.Text;
mMessage.ForceChanged();
mAdapter.SendChanged();
}
private void xLoad_Scroll(object sender, ScrollEventArgs e)
{
xLoadValue.Text = xLoad.Value.ToString();
}
private void xPosition_Scroll(object sender, ScrollEventArgs e)
{
mPosition.Value = xPosition.Value;
mAdapter.SendChanged();
xPositionValue.Text = xPosition.Value.ToString();
}
private void cLoad_Scroll(object sender, ScrollEventArgs e)
{
cLoadValue.Text = cLoad.Value.ToString();
}
private void cSpeed_Scroll(object sender, ScrollEventArgs e)
{
mSpeed.Value = cSpeed.Value * 100.0;
mAdapter.SendChanged();
cSpeedValue.Text = mSpeed.Value.ToString();
}
private void coolant_CheckedChanged(object sender, EventArgs e)
{
if (coolant.Checked)
mFillLevel.Add(Condition.Level.WARNING, "Coolant Low", "COOL", "LOW");
else
mFillLevel.Clear("COOL");
mAdapter.SendChanged();
}
private void cuttingToolButton_Click(object sender, EventArgs e)
{
#if false
CuttingToolForm toolWindow = new CuttingToolForm(mAdapter);
toolWindow.Show(this);
#endif
}
}
}
+144
View File
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="cv24.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="gather.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="cv21.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cv22.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cv23.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cv21.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cv22.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="cv23.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
-39
View File
@@ -1,39 +0,0 @@
namespace MTC_Sim
{
partial class Form1
{
/// <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 = "Form1";
}
#endregion
}
}
-20
View File
@@ -1,20 +0,0 @@
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 Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
+12 -3
View File
@@ -46,14 +46,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<Compile Include="CMS_MachineSim.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="CMS_MachineSim.Designer.cs">
<DependentUpon>CMS_MachineSim.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="CMS_MachineSim.resx">
<DependentUpon>CMS_MachineSim.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -76,6 +79,12 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\GitHub\MTConnect\dot_net_sdk\DotNetAdapterSDK.csproj">
<Project>{d8d08dbe-b511-4de0-b5a9-563ebfc60c4f}</Project>
<Name>DotNetAdapterSDK</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+11 -1
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -8,15 +9,24 @@ namespace MTC_Sim
{
static class Program
{
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool AllocConsole();
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool FreeConsole();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//AllocConsole();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new CMS_MachineSim());
//FreeConsole();
}
}
}
+1
View File
@@ -0,0 +1 @@
cl dump.c ws2_32.lib
+184
View File
@@ -0,0 +1,184 @@
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <sys/socket.h>
#include <sys/select.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <time.h>
#include <unistd.h>
#endif
#include <sys/types.h>
#include <string.h>
#define PORT 7878
#define HOST "localhost"
#define BUFFER_SIZE 1024
#ifndef _WIN32
#define SOCKET int
#define closesocket close
#endif
void cleanup_and_exit(int ret)
{
#ifdef _WIN32
WSACleanup();
#endif
exit(ret);
}
void usage()
{
fprintf(stderr, "Usage: dump [-t timeout] [host] [port] [file]\n host defaults to localhost\n port defaults to 7878\n file defaults to stdout\n");
exit(0);
}
int main(int argc, char **argv)
{
char hostname[100];
SOCKET sd;
struct sockaddr_in pin;
struct hostent *hp;
char buffer[BUFFER_SIZE];
int port;
FILE *file;
char dump = 0;
char **argvp = argv;
time_t start = 0;
int remaining = 1, timeout = 0, nfds;
struct fd_set fds;
struct timeval tv, *tvp = 0;
#ifdef _WIN32
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) {
fprintf(stderr, "WSAStartup failed\n");
cleanup_and_exit(1);
}
#endif
if (argc > 1) {
if (strcmp(argv[1], "-h") == 0) {
usage();
} else if (strcmp(argv[1], "-t") == 0) {
if (argc < 3) {
fprintf(stderr, "Missing timeout argument\n");
usage();
}
timeout = atoi(argv[2]);
argc -= 2;
argvp += 2;
}
}
strcpy(hostname,HOST);
if (argc > 1) {
strcpy(hostname,argvp[1]);
}
port = PORT;
if (argc > 2) {
port = atoi(argvp[2]);
}
file = stdout;
if (argc > 3) {
file = fopen(argvp[3], "w");
if (file == NULL) {
perror("fopen");
fprintf(stderr, "Cannot open file %s\n", argv[3]);
exit(1);
}
dump = 1;
}
/* go find out about the desired host machine */
if ((hp = gethostbyname(hostname)) == (void*) 0) {
perror("gethostbyname");
cleanup_and_exit(1);
}
/* fill in the socket structure with host information */
memset(&pin, 0, sizeof(pin));
pin.sin_family = AF_INET;
memcpy(&pin.sin_addr.s_addr, hp->h_addr, hp->h_length);
pin.sin_port = htons(port);
/* grab an Internet domain socket */
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
cleanup_and_exit(1);
}
/* connect to PORT on HOST */
if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) {
perror("connect");
cleanup_and_exit(1);
}
if (dump) {
printf("Connected to %s port %d\n", hostname, port);
}
/* wait for a message to come back from the server */
if (timeout > 0) {
start = time(0);
remaining = timeout;
tv.tv_usec = 0;
tvp = &tv;
}
#ifdef _WIN32
nfds = 1;
#else
nfds = sd + 1;
#endif
while (remaining > 0) {
int n;
FD_ZERO(&fds);
FD_SET(sd, &fds);
tv.tv_sec = remaining;
n = select(nfds, &fds, (fd_set*) 0, (fd_set*) 0, tvp);
if (n < 0) {
closesocket(sd);
perror("recv");
cleanup_and_exit(1);
} else if (n > 0) {
int count = recv(sd, buffer, BUFFER_SIZE, 0);
if (count == -1) {
closesocket(sd);
perror("recv");
cleanup_and_exit(1);
}
if (count == 0)
break;
fwrite(buffer, 1, count, file);
if (dump) {
fputc('.', stdout);
fflush(stdout);
}
fflush(file);
}
if (timeout > 0) {
time_t now = time(0);
remaining -= (int) (now - start);
start = now;
}
}
if (dump) printf("\nFinished\n");
fclose(file);
closesocket(sd);
#ifdef _WIN32
WSACleanup();
#endif
return 0;
}