From 39750266a244d31832eb4f200a9bfab04a824888 Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 12 Oct 2022 17:45:27 +0900 Subject: [PATCH] modbus slave I --- ModbusStudy/CommClient/App.config | 6 + ModbusStudy/CommClient/CommClient.csproj | 83 ++++ ModbusStudy/CommClient/MainForm.Designer.cs | 416 ++++++++++++++++ ModbusStudy/CommClient/MainForm.cs | 20 + ModbusStudy/CommClient/MainForm.resx | 120 +++++ ModbusStudy/CommClient/Program.cs | 22 + .../CommClient/Properties/AssemblyInfo.cs | 36 ++ .../Properties/Resources.Designer.cs | 70 +++ .../CommClient/Properties/Resources.resx | 117 +++++ .../Properties/Settings.Designer.cs | 29 ++ .../CommClient/Properties/Settings.settings | 7 + ModbusStudy/ModbusSlave/App.config | 6 + ModbusStudy/ModbusSlave/MainForm.Designer.cs | 443 ++++++++++++++++++ ModbusStudy/ModbusSlave/MainForm.cs | 151 ++++++ ModbusStudy/ModbusSlave/MainForm.resx | 120 +++++ ModbusStudy/ModbusSlave/ModbusSlave.csproj | 87 ++++ ModbusStudy/ModbusSlave/Program.cs | 22 + .../ModbusSlave/Properties/AssemblyInfo.cs | 36 ++ .../Properties/Resources.Designer.cs | 70 +++ .../ModbusSlave/Properties/Resources.resx | 117 +++++ .../Properties/Settings.Designer.cs | 29 ++ .../ModbusSlave/Properties/Settings.settings | 7 + ModbusStudy/ModbusSlave/packages.config | 4 + ModbusStudy/ModbusStudy.sln | 31 ++ 24 files changed, 2049 insertions(+) create mode 100644 ModbusStudy/CommClient/App.config create mode 100644 ModbusStudy/CommClient/CommClient.csproj create mode 100644 ModbusStudy/CommClient/MainForm.Designer.cs create mode 100644 ModbusStudy/CommClient/MainForm.cs create mode 100644 ModbusStudy/CommClient/MainForm.resx create mode 100644 ModbusStudy/CommClient/Program.cs create mode 100644 ModbusStudy/CommClient/Properties/AssemblyInfo.cs create mode 100644 ModbusStudy/CommClient/Properties/Resources.Designer.cs create mode 100644 ModbusStudy/CommClient/Properties/Resources.resx create mode 100644 ModbusStudy/CommClient/Properties/Settings.Designer.cs create mode 100644 ModbusStudy/CommClient/Properties/Settings.settings create mode 100644 ModbusStudy/ModbusSlave/App.config create mode 100644 ModbusStudy/ModbusSlave/MainForm.Designer.cs create mode 100644 ModbusStudy/ModbusSlave/MainForm.cs create mode 100644 ModbusStudy/ModbusSlave/MainForm.resx create mode 100644 ModbusStudy/ModbusSlave/ModbusSlave.csproj create mode 100644 ModbusStudy/ModbusSlave/Program.cs create mode 100644 ModbusStudy/ModbusSlave/Properties/AssemblyInfo.cs create mode 100644 ModbusStudy/ModbusSlave/Properties/Resources.Designer.cs create mode 100644 ModbusStudy/ModbusSlave/Properties/Resources.resx create mode 100644 ModbusStudy/ModbusSlave/Properties/Settings.Designer.cs create mode 100644 ModbusStudy/ModbusSlave/Properties/Settings.settings create mode 100644 ModbusStudy/ModbusSlave/packages.config create mode 100644 ModbusStudy/ModbusStudy.sln diff --git a/ModbusStudy/CommClient/App.config b/ModbusStudy/CommClient/App.config new file mode 100644 index 0000000..aee9adf --- /dev/null +++ b/ModbusStudy/CommClient/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ModbusStudy/CommClient/CommClient.csproj b/ModbusStudy/CommClient/CommClient.csproj new file mode 100644 index 0000000..5a4182e --- /dev/null +++ b/ModbusStudy/CommClient/CommClient.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {F47D20AF-4D05-4AA5-9160-401599079F1A} + WinExe + CommClient + CommClient + v4.8.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/ModbusStudy/CommClient/MainForm.Designer.cs b/ModbusStudy/CommClient/MainForm.Designer.cs new file mode 100644 index 0000000..b29ea97 --- /dev/null +++ b/ModbusStudy/CommClient/MainForm.Designer.cs @@ -0,0 +1,416 @@ + +namespace CommClient +{ + partial class MainForm + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.tbStatus = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.nudPort = new System.Windows.Forms.NumericUpDown(); + this.btnConnect = new System.Windows.Forms.Button(); + this.btnDisconnect = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.tbName = new System.Windows.Forms.TextBox(); + this.btnRead = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.tbWriteName = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.tbWriteValue = new System.Windows.Forms.TextBox(); + this.btnWrite = new System.Windows.Forms.Button(); + this.chkModbus = new System.Windows.Forms.RadioButton(); + this.chkOPCUA = new System.Windows.Forms.RadioButton(); + this.chkSdk = new System.Windows.Forms.RadioButton(); + this.rtbLog = new System.Windows.Forms.RichTextBox(); + this.chkAutoScroll = new System.Windows.Forms.CheckBox(); + this.btnClear = new System.Windows.Forms.Button(); + this.tbIP = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.btnDisconnect); + this.groupBox1.Controls.Add(this.tbIP); + this.groupBox1.Controls.Add(this.btnConnect); + this.groupBox1.Controls.Add(this.nudPort); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.tbStatus); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(13, 13); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(240, 135); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Server"; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.chkAutoScroll); + this.groupBox5.Controls.Add(this.btnClear); + this.groupBox5.Controls.Add(this.rtbLog); + this.groupBox5.Location = new System.Drawing.Point(259, 13); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(417, 384); + this.groupBox5.TabIndex = 0; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "Log"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.btnRead); + this.groupBox2.Controls.Add(this.tbName); + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Location = new System.Drawing.Point(13, 154); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(240, 75); + this.groupBox2.TabIndex = 0; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Read Config"; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.btnWrite); + this.groupBox3.Controls.Add(this.tbWriteValue); + this.groupBox3.Controls.Add(this.label6); + this.groupBox3.Controls.Add(this.tbWriteName); + this.groupBox3.Controls.Add(this.label5); + this.groupBox3.Location = new System.Drawing.Point(13, 235); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(240, 105); + this.groupBox3.TabIndex = 0; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Write Config"; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.chkSdk); + this.groupBox4.Controls.Add(this.chkOPCUA); + this.groupBox4.Controls.Add(this.chkModbus); + this.groupBox4.Location = new System.Drawing.Point(13, 346); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(240, 51); + this.groupBox4.TabIndex = 0; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "Mode"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(4, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(40, 12); + this.label1.TabIndex = 6; + this.label1.Text = "Status"; + // + // tbStatus + // + this.tbStatus.BackColor = System.Drawing.Color.Silver; + this.tbStatus.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbStatus.Location = new System.Drawing.Point(78, 20); + this.tbStatus.Name = "tbStatus"; + this.tbStatus.ReadOnly = true; + this.tbStatus.Size = new System.Drawing.Size(156, 21); + this.tbStatus.TabIndex = 7; + this.tbStatus.Text = "Disconnected"; + this.tbStatus.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 78); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(55, 12); + this.label2.TabIndex = 5; + this.label2.Text = "TCP port"; + // + // nudPort + // + this.nudPort.Location = new System.Drawing.Point(78, 74); + this.nudPort.Maximum = new decimal(new int[] { + 65535, + 0, + 0, + 0}); + this.nudPort.Name = "nudPort"; + this.nudPort.Size = new System.Drawing.Size(156, 21); + this.nudPort.TabIndex = 9; + this.nudPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.nudPort.Value = new decimal(new int[] { + 502, + 0, + 0, + 0}); + // + // btnConnect + // + this.btnConnect.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnConnect.Location = new System.Drawing.Point(78, 101); + this.btnConnect.Name = "btnConnect"; + this.btnConnect.Size = new System.Drawing.Size(68, 23); + this.btnConnect.TabIndex = 11; + this.btnConnect.Text = "Connect"; + this.btnConnect.UseVisualStyleBackColor = true; + // + // btnDisconnect + // + this.btnDisconnect.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnDisconnect.Location = new System.Drawing.Point(152, 101); + this.btnDisconnect.Name = "btnDisconnect"; + this.btnDisconnect.Size = new System.Drawing.Size(82, 23); + this.btnDisconnect.TabIndex = 10; + this.btnDisconnect.Text = "Disconnect"; + this.btnDisconnect.UseVisualStyleBackColor = true; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 17); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(79, 12); + this.label4.TabIndex = 6; + this.label4.Text = "Tag name/Id"; + // + // tbName + // + this.tbName.Location = new System.Drawing.Point(91, 13); + this.tbName.Name = "tbName"; + this.tbName.Size = new System.Drawing.Size(143, 21); + this.tbName.TabIndex = 7; + this.tbName.Text = "00001"; + // + // btnRead + // + this.btnRead.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnRead.Location = new System.Drawing.Point(159, 40); + this.btnRead.Name = "btnRead"; + this.btnRead.Size = new System.Drawing.Size(75, 23); + this.btnRead.TabIndex = 10; + this.btnRead.Text = "Read"; + this.btnRead.UseVisualStyleBackColor = true; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 24); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(79, 12); + this.label5.TabIndex = 6; + this.label5.Text = "Tag name/Id"; + // + // tbWriteName + // + this.tbWriteName.Location = new System.Drawing.Point(91, 20); + this.tbWriteName.Name = "tbWriteName"; + this.tbWriteName.Size = new System.Drawing.Size(143, 21); + this.tbWriteName.TabIndex = 7; + this.tbWriteName.Text = "00001"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 51); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(66, 12); + this.label6.TabIndex = 6; + this.label6.Text = "Write value"; + // + // tbWriteValue + // + this.tbWriteValue.Location = new System.Drawing.Point(91, 47); + this.tbWriteValue.Name = "tbWriteValue"; + this.tbWriteValue.Size = new System.Drawing.Size(143, 21); + this.tbWriteValue.TabIndex = 7; + this.tbWriteValue.Text = "0"; + // + // btnWrite + // + this.btnWrite.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnWrite.Location = new System.Drawing.Point(159, 74); + this.btnWrite.Name = "btnWrite"; + this.btnWrite.Size = new System.Drawing.Size(75, 23); + this.btnWrite.TabIndex = 10; + this.btnWrite.Text = "Write"; + this.btnWrite.UseVisualStyleBackColor = true; + // + // chkModbus + // + this.chkModbus.AutoSize = true; + this.chkModbus.Checked = true; + this.chkModbus.Location = new System.Drawing.Point(8, 21); + this.chkModbus.Name = "chkModbus"; + this.chkModbus.Size = new System.Drawing.Size(69, 16); + this.chkModbus.TabIndex = 0; + this.chkModbus.TabStop = true; + this.chkModbus.Text = "Modbus"; + this.chkModbus.UseVisualStyleBackColor = true; + // + // chkOPCUA + // + this.chkOPCUA.AutoSize = true; + this.chkOPCUA.Location = new System.Drawing.Point(91, 21); + this.chkOPCUA.Name = "chkOPCUA"; + this.chkOPCUA.Size = new System.Drawing.Size(69, 16); + this.chkOPCUA.TabIndex = 0; + this.chkOPCUA.Text = "OPC UA"; + this.chkOPCUA.UseVisualStyleBackColor = true; + // + // chkSdk + // + this.chkSdk.AutoSize = true; + this.chkSdk.Location = new System.Drawing.Point(174, 21); + this.chkSdk.Name = "chkSdk"; + this.chkSdk.Size = new System.Drawing.Size(47, 16); + this.chkSdk.TabIndex = 0; + this.chkSdk.Text = "SDK"; + this.chkSdk.UseVisualStyleBackColor = true; + // + // rtbLog + // + this.rtbLog.BackColor = System.Drawing.Color.Black; + this.rtbLog.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.rtbLog.ForeColor = System.Drawing.Color.Lime; + this.rtbLog.Location = new System.Drawing.Point(6, 20); + this.rtbLog.Name = "rtbLog"; + this.rtbLog.ReadOnly = true; + this.rtbLog.Size = new System.Drawing.Size(405, 329); + this.rtbLog.TabIndex = 1; + this.rtbLog.Text = ""; + // + // chkAutoScroll + // + this.chkAutoScroll.AutoSize = true; + this.chkAutoScroll.Checked = true; + this.chkAutoScroll.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkAutoScroll.Location = new System.Drawing.Point(6, 362); + this.chkAutoScroll.Name = "chkAutoScroll"; + this.chkAutoScroll.Size = new System.Drawing.Size(84, 16); + this.chkAutoScroll.TabIndex = 4; + this.chkAutoScroll.Text = "Auto scroll"; + this.chkAutoScroll.UseVisualStyleBackColor = true; + // + // btnClear + // + this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnClear.Location = new System.Drawing.Point(336, 355); + this.btnClear.Name = "btnClear"; + this.btnClear.Size = new System.Drawing.Size(75, 23); + this.btnClear.TabIndex = 5; + this.btnClear.Text = "Clear log"; + this.btnClear.UseVisualStyleBackColor = true; + // + // tbIP + // + this.tbIP.Location = new System.Drawing.Point(78, 47); + this.tbIP.Name = "tbIP"; + this.tbIP.Size = new System.Drawing.Size(156, 21); + this.tbIP.TabIndex = 7; + this.tbIP.Text = "127.0.0.1"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(4, 51); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(56, 12); + this.label3.TabIndex = 5; + this.label3.Text = "Server IP"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(690, 407); + this.Controls.Add(this.groupBox5); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "MainForm"; + this.Text = "Comm Client"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudPort)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.Button btnDisconnect; + private System.Windows.Forms.Button btnConnect; + private System.Windows.Forms.NumericUpDown nudPort; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox tbStatus; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.Button btnRead; + private System.Windows.Forms.TextBox tbName; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button btnWrite; + private System.Windows.Forms.TextBox tbWriteValue; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox tbWriteName; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.RadioButton chkSdk; + private System.Windows.Forms.RadioButton chkOPCUA; + private System.Windows.Forms.RadioButton chkModbus; + private System.Windows.Forms.RichTextBox rtbLog; + private System.Windows.Forms.CheckBox chkAutoScroll; + private System.Windows.Forms.Button btnClear; + private System.Windows.Forms.TextBox tbIP; + private System.Windows.Forms.Label label3; + } +} + diff --git a/ModbusStudy/CommClient/MainForm.cs b/ModbusStudy/CommClient/MainForm.cs new file mode 100644 index 0000000..96e2c38 --- /dev/null +++ b/ModbusStudy/CommClient/MainForm.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CommClient +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + } + } +} diff --git a/ModbusStudy/CommClient/MainForm.resx b/ModbusStudy/CommClient/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ModbusStudy/CommClient/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ModbusStudy/CommClient/Program.cs b/ModbusStudy/CommClient/Program.cs new file mode 100644 index 0000000..d697cdf --- /dev/null +++ b/ModbusStudy/CommClient/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CommClient +{ + static class Program + { + /// + /// 해당 애플리케이션의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/ModbusStudy/CommClient/Properties/AssemblyInfo.cs b/ModbusStudy/CommClient/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ded7ebf --- /dev/null +++ b/ModbusStudy/CommClient/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("CommClient")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CommClient")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("f47d20af-4d05-4aa5-9160-401599079f1a")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ModbusStudy/CommClient/Properties/Resources.Designer.cs b/ModbusStudy/CommClient/Properties/Resources.Designer.cs new file mode 100644 index 0000000..000dbab --- /dev/null +++ b/ModbusStudy/CommClient/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + + +namespace CommClient.Properties +{ + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 + // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CommClient.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ModbusStudy/CommClient/Properties/Resources.resx b/ModbusStudy/CommClient/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ModbusStudy/CommClient/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ModbusStudy/CommClient/Properties/Settings.Designer.cs b/ModbusStudy/CommClient/Properties/Settings.Designer.cs new file mode 100644 index 0000000..2cb0101 --- /dev/null +++ b/ModbusStudy/CommClient/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace CommClient.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ModbusStudy/CommClient/Properties/Settings.settings b/ModbusStudy/CommClient/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/ModbusStudy/CommClient/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ModbusStudy/ModbusSlave/App.config b/ModbusStudy/ModbusSlave/App.config new file mode 100644 index 0000000..aee9adf --- /dev/null +++ b/ModbusStudy/ModbusSlave/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ModbusStudy/ModbusSlave/MainForm.Designer.cs b/ModbusStudy/ModbusSlave/MainForm.Designer.cs new file mode 100644 index 0000000..6732e2a --- /dev/null +++ b/ModbusStudy/ModbusSlave/MainForm.Designer.cs @@ -0,0 +1,443 @@ + +namespace ModbusSlave +{ + partial class MainForm + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btnStop = new System.Windows.Forms.Button(); + this.btnRun = new System.Windows.Forms.Button(); + this.nudAddress = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.nudPort = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.tbStatus = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.chkAutoScroll = new System.Windows.Forms.CheckBox(); + this.btnClear = new System.Windows.Forms.Button(); + this.rtbLog = new System.Windows.Forms.RichTextBox(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.lv0x = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.lv1x = new System.Windows.Forms.ListView(); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.lv3x = new System.Windows.Forms.ListView(); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.lv4x = new System.Windows.Forms.ListView(); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudAddress)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit(); + this.groupBox2.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.tabPage3.SuspendLayout(); + this.tabPage4.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.btnStop); + this.groupBox1.Controls.Add(this.btnRun); + this.groupBox1.Controls.Add(this.nudAddress); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.nudPort); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.tbStatus); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(250, 131); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Server"; + // + // btnStop + // + this.btnStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStop.Location = new System.Drawing.Point(162, 99); + this.btnStop.Name = "btnStop"; + this.btnStop.Size = new System.Drawing.Size(75, 23); + this.btnStop.TabIndex = 3; + this.btnStop.Text = "Stop"; + this.btnStop.UseVisualStyleBackColor = true; + this.btnStop.Click += new System.EventHandler(this.btnStop_Click); + // + // btnRun + // + this.btnRun.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnRun.Location = new System.Drawing.Point(81, 99); + this.btnRun.Name = "btnRun"; + this.btnRun.Size = new System.Drawing.Size(75, 23); + this.btnRun.TabIndex = 3; + this.btnRun.Text = "Run"; + this.btnRun.UseVisualStyleBackColor = true; + this.btnRun.Click += new System.EventHandler(this.btnRun_Click); + // + // nudAddress + // + this.nudAddress.Location = new System.Drawing.Point(81, 72); + this.nudAddress.Name = "nudAddress"; + this.nudAddress.Size = new System.Drawing.Size(156, 21); + this.nudAddress.TabIndex = 2; + this.nudAddress.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(7, 76); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(52, 12); + this.label3.TabIndex = 0; + this.label3.Text = "Address"; + // + // nudPort + // + this.nudPort.Location = new System.Drawing.Point(81, 45); + this.nudPort.Maximum = new decimal(new int[] { + 65535, + 0, + 0, + 0}); + this.nudPort.Name = "nudPort"; + this.nudPort.Size = new System.Drawing.Size(156, 21); + this.nudPort.TabIndex = 2; + this.nudPort.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.nudPort.Value = new decimal(new int[] { + 502, + 0, + 0, + 0}); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(7, 49); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(55, 12); + this.label2.TabIndex = 0; + this.label2.Text = "TCP port"; + // + // tbStatus + // + this.tbStatus.BackColor = System.Drawing.Color.Silver; + this.tbStatus.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.tbStatus.Location = new System.Drawing.Point(81, 18); + this.tbStatus.Name = "tbStatus"; + this.tbStatus.ReadOnly = true; + this.tbStatus.Size = new System.Drawing.Size(156, 21); + this.tbStatus.TabIndex = 1; + this.tbStatus.Text = "Stop"; + this.tbStatus.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(7, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(40, 12); + this.label1.TabIndex = 0; + this.label1.Text = "Status"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.chkAutoScroll); + this.groupBox2.Controls.Add(this.btnClear); + this.groupBox2.Controls.Add(this.rtbLog); + this.groupBox2.Location = new System.Drawing.Point(12, 149); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(250, 225); + this.groupBox2.TabIndex = 0; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Log"; + // + // chkAutoScroll + // + this.chkAutoScroll.AutoSize = true; + this.chkAutoScroll.Checked = true; + this.chkAutoScroll.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkAutoScroll.Location = new System.Drawing.Point(9, 203); + this.chkAutoScroll.Name = "chkAutoScroll"; + this.chkAutoScroll.Size = new System.Drawing.Size(84, 16); + this.chkAutoScroll.TabIndex = 1; + this.chkAutoScroll.Text = "Auto scroll"; + this.chkAutoScroll.UseVisualStyleBackColor = true; + // + // btnClear + // + this.btnClear.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnClear.Location = new System.Drawing.Point(162, 196); + this.btnClear.Name = "btnClear"; + this.btnClear.Size = new System.Drawing.Size(75, 23); + this.btnClear.TabIndex = 3; + this.btnClear.Text = "Clear log"; + this.btnClear.UseVisualStyleBackColor = true; + this.btnClear.Click += new System.EventHandler(this.btnClear_Click); + // + // rtbLog + // + this.rtbLog.BackColor = System.Drawing.Color.Black; + this.rtbLog.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.rtbLog.ForeColor = System.Drawing.Color.Lime; + this.rtbLog.Location = new System.Drawing.Point(9, 21); + this.rtbLog.Name = "rtbLog"; + this.rtbLog.ReadOnly = true; + this.rtbLog.Size = new System.Drawing.Size(228, 169); + this.rtbLog.TabIndex = 0; + this.rtbLog.Text = ""; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Controls.Add(this.tabPage3); + this.tabControl1.Controls.Add(this.tabPage4); + this.tabControl1.Location = new System.Drawing.Point(268, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(263, 362); + this.tabControl1.TabIndex = 1; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.lv0x); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(255, 336); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "0x"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // lv0x + // + this.lv0x.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.lv0x.Dock = System.Windows.Forms.DockStyle.Fill; + this.lv0x.FullRowSelect = true; + this.lv0x.HideSelection = false; + this.lv0x.Location = new System.Drawing.Point(3, 3); + this.lv0x.MultiSelect = false; + this.lv0x.Name = "lv0x"; + this.lv0x.Size = new System.Drawing.Size(249, 330); + this.lv0x.TabIndex = 0; + this.lv0x.UseCompatibleStateImageBehavior = false; + this.lv0x.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Address"; + this.columnHeader1.Width = 109; + // + // columnHeader2 + // + this.columnHeader2.Text = "Value"; + this.columnHeader2.Width = 133; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.lv1x); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(255, 336); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "1x"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // lv1x + // + this.lv1x.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader3, + this.columnHeader4}); + this.lv1x.Dock = System.Windows.Forms.DockStyle.Fill; + this.lv1x.FullRowSelect = true; + this.lv1x.HideSelection = false; + this.lv1x.Location = new System.Drawing.Point(3, 3); + this.lv1x.MultiSelect = false; + this.lv1x.Name = "lv1x"; + this.lv1x.Size = new System.Drawing.Size(249, 330); + this.lv1x.TabIndex = 1; + this.lv1x.UseCompatibleStateImageBehavior = false; + this.lv1x.View = System.Windows.Forms.View.Details; + // + // columnHeader3 + // + this.columnHeader3.Text = "Address"; + this.columnHeader3.Width = 109; + // + // columnHeader4 + // + this.columnHeader4.Text = "Value"; + this.columnHeader4.Width = 133; + // + // tabPage3 + // + this.tabPage3.Controls.Add(this.lv3x); + this.tabPage3.Location = new System.Drawing.Point(4, 22); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Size = new System.Drawing.Size(255, 336); + this.tabPage3.TabIndex = 2; + this.tabPage3.Text = "3x"; + this.tabPage3.UseVisualStyleBackColor = true; + // + // lv3x + // + this.lv3x.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader5, + this.columnHeader6}); + this.lv3x.Dock = System.Windows.Forms.DockStyle.Fill; + this.lv3x.FullRowSelect = true; + this.lv3x.HideSelection = false; + this.lv3x.Location = new System.Drawing.Point(0, 0); + this.lv3x.MultiSelect = false; + this.lv3x.Name = "lv3x"; + this.lv3x.Size = new System.Drawing.Size(255, 336); + this.lv3x.TabIndex = 1; + this.lv3x.UseCompatibleStateImageBehavior = false; + this.lv3x.View = System.Windows.Forms.View.Details; + // + // columnHeader5 + // + this.columnHeader5.Text = "Address"; + this.columnHeader5.Width = 109; + // + // columnHeader6 + // + this.columnHeader6.Text = "Value"; + this.columnHeader6.Width = 133; + // + // tabPage4 + // + this.tabPage4.Controls.Add(this.lv4x); + this.tabPage4.Location = new System.Drawing.Point(4, 22); + this.tabPage4.Name = "tabPage4"; + this.tabPage4.Size = new System.Drawing.Size(255, 336); + this.tabPage4.TabIndex = 3; + this.tabPage4.Text = "4x"; + this.tabPage4.UseVisualStyleBackColor = true; + // + // lv4x + // + this.lv4x.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader7, + this.columnHeader8}); + this.lv4x.Dock = System.Windows.Forms.DockStyle.Fill; + this.lv4x.FullRowSelect = true; + this.lv4x.HideSelection = false; + this.lv4x.Location = new System.Drawing.Point(0, 0); + this.lv4x.MultiSelect = false; + this.lv4x.Name = "lv4x"; + this.lv4x.Size = new System.Drawing.Size(255, 336); + this.lv4x.TabIndex = 1; + this.lv4x.UseCompatibleStateImageBehavior = false; + this.lv4x.View = System.Windows.Forms.View.Details; + // + // columnHeader7 + // + this.columnHeader7.Text = "Address"; + this.columnHeader7.Width = 109; + // + // columnHeader8 + // + this.columnHeader8.Text = "Value"; + this.columnHeader8.Width = 133; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(536, 386); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "MainForm"; + this.Text = "Modbus Slave"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudAddress)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudPort)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage2.ResumeLayout(false); + this.tabPage3.ResumeLayout(false); + this.tabPage4.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button btnStop; + private System.Windows.Forms.Button btnRun; + private System.Windows.Forms.NumericUpDown nudAddress; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.NumericUpDown nudPort; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox tbStatus; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.CheckBox chkAutoScroll; + private System.Windows.Forms.Button btnClear; + private System.Windows.Forms.RichTextBox rtbLog; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.ListView lv0x; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.ListView lv1x; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.ListView lv3x; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.TabPage tabPage4; + private System.Windows.Forms.ListView lv4x; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + } +} + diff --git a/ModbusStudy/ModbusSlave/MainForm.cs b/ModbusStudy/ModbusSlave/MainForm.cs new file mode 100644 index 0000000..8708cae --- /dev/null +++ b/ModbusStudy/ModbusSlave/MainForm.cs @@ -0,0 +1,151 @@ +using EasyModbus; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Net.NetworkInformation; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ModbusSlave +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + InitInstance(); + } + + #region Field + + private ModbusServer server; + private bool isFirstLog = true; + + #endregion + + #region Button event + + private void btnRun_Click(object sender, EventArgs e) + { + try + { + server.Port = (int)nudPort.Value; + server.UnitIdentifier = Convert.ToByte(nudAddress.Value); + + if (!CheckPortInUse(server.Port)) + { + Log("[WARNING] unavailable port"); + return; + } + + server.Listen(); + Log("--- Server start ---"); + + btnRun.Enabled = false; + nudAddress.Enabled = false; + nudPort.Enabled = false; + + tbStatus.Text = "Run"; + tbStatus.BackColor = Color.Lime; + } + catch (Exception ex) + { + Log("[ERROR] " + ex.Message); + } + } + + private void btnStop_Click(object sender, EventArgs e) + { + try + { + server.StopListening(); + Log("--- Server stop ---"); + + btnRun.Enabled = true; + nudAddress.Enabled = true; + nudPort.Enabled = true; + + tbStatus.Text = "Stop"; + tbStatus.BackColor = Color.Silver; + } + catch (Exception ex) + { + Log("[ERROR] " + ex.Message); + } + } + + private void btnClear_Click(object sender, EventArgs e) + { + ClearLog(); + } + + #endregion + + #region Timer event + + #endregion + + #region Listview event + + #endregion + + #region Etc event + + #endregion + + #region Method + + private void InitInstance() + { + server = new ModbusServer(); + } + + private void Log(string text) + { + rtbLog.AppendText((isFirstLog ? "" : Environment.NewLine) + text); + isFirstLog = false; + + ScrollToEnd(); + } + + private void ScrollToEnd() + { + if (!chkAutoScroll.Checked) + return; + + rtbLog.SelectionStart = rtbLog.Text.Length; + rtbLog.ScrollToCaret(); + } + + private void ClearLog() + { + rtbLog.Clear(); + isFirstLog = true; + ScrollToEnd(); + } + + private bool CheckPortInUse(int port) + { + bool isAvailable = true; + var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); + var tcpListenerArray = ipGlobalProperties.GetActiveTcpListeners(); + + foreach (var ip in tcpListenerArray) + { + if (ip.Port == port) + { + isAvailable = false; + break; + } + } + + return isAvailable; + } + + #endregion + } +} diff --git a/ModbusStudy/ModbusSlave/MainForm.resx b/ModbusStudy/ModbusSlave/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ModbusStudy/ModbusSlave/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ModbusStudy/ModbusSlave/ModbusSlave.csproj b/ModbusStudy/ModbusSlave/ModbusSlave.csproj new file mode 100644 index 0000000..e8feed4 --- /dev/null +++ b/ModbusStudy/ModbusSlave/ModbusSlave.csproj @@ -0,0 +1,87 @@ + + + + + Debug + AnyCPU + {439FCE65-14FD-4495-96CF-C4473455249D} + WinExe + ModbusSlave + ModbusSlave + v4.8.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/ModbusStudy/ModbusSlave/Program.cs b/ModbusStudy/ModbusSlave/Program.cs new file mode 100644 index 0000000..acf8154 --- /dev/null +++ b/ModbusStudy/ModbusSlave/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ModbusSlave +{ + static class Program + { + /// + /// 해당 애플리케이션의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/ModbusStudy/ModbusSlave/Properties/AssemblyInfo.cs b/ModbusStudy/ModbusSlave/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fc663a2 --- /dev/null +++ b/ModbusStudy/ModbusSlave/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("ModbusSlave")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ModbusSlave")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("439fce65-14fd-4495-96cf-c4473455249d")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ModbusStudy/ModbusSlave/Properties/Resources.Designer.cs b/ModbusStudy/ModbusSlave/Properties/Resources.Designer.cs new file mode 100644 index 0000000..2bad8b4 --- /dev/null +++ b/ModbusStudy/ModbusSlave/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + + +namespace ModbusSlave.Properties +{ + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 + // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ModbusSlave.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/ModbusStudy/ModbusSlave/Properties/Resources.resx b/ModbusStudy/ModbusSlave/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/ModbusStudy/ModbusSlave/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ModbusStudy/ModbusSlave/Properties/Settings.Designer.cs b/ModbusStudy/ModbusSlave/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ac03fe0 --- /dev/null +++ b/ModbusStudy/ModbusSlave/Properties/Settings.Designer.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace ModbusSlave.Properties +{ + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/ModbusStudy/ModbusSlave/Properties/Settings.settings b/ModbusStudy/ModbusSlave/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/ModbusStudy/ModbusSlave/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ModbusStudy/ModbusSlave/packages.config b/ModbusStudy/ModbusSlave/packages.config new file mode 100644 index 0000000..011170f --- /dev/null +++ b/ModbusStudy/ModbusSlave/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ModbusStudy/ModbusStudy.sln b/ModbusStudy/ModbusStudy.sln new file mode 100644 index 0000000..e710409 --- /dev/null +++ b/ModbusStudy/ModbusStudy.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32630.194 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModbusSlave", "ModbusSlave\ModbusSlave.csproj", "{439FCE65-14FD-4495-96CF-C4473455249D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommClient", "CommClient\CommClient.csproj", "{F47D20AF-4D05-4AA5-9160-401599079F1A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {439FCE65-14FD-4495-96CF-C4473455249D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {439FCE65-14FD-4495-96CF-C4473455249D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {439FCE65-14FD-4495-96CF-C4473455249D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {439FCE65-14FD-4495-96CF-C4473455249D}.Release|Any CPU.Build.0 = Release|Any CPU + {F47D20AF-4D05-4AA5-9160-401599079F1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F47D20AF-4D05-4AA5-9160-401599079F1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F47D20AF-4D05-4AA5-9160-401599079F1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F47D20AF-4D05-4AA5-9160-401599079F1A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2813945E-B7D4-4F67-9628-3987E70FC070} + EndGlobalSection +EndGlobal