+++ KHModbus.sln
... | ... | @@ -0,0 +1,25 @@ |
| 1 | + | |
| 2 | +Microsoft Visual Studio Solution File, Format Version 12.00 | |
| 3 | +# Visual Studio Version 16 | |
| 4 | +VisualStudioVersion = 16.0.32002.261 | |
| 5 | +MinimumVisualStudioVersion = 10.0.40219.1 | |
| 6 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KHModbus", "ModbusTest\KHModbus.csproj", "{2A789031-AEE6-436C-B5E0-AB764F55FCD2}" | |
| 7 | +EndProject | |
| 8 | +Global | |
| 9 | + GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
| 10 | + Debug|Any CPU = Debug|Any CPU | |
| 11 | + Release|Any CPU = Release|Any CPU | |
| 12 | + EndGlobalSection | |
| 13 | + GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
| 14 | + {2A789031-AEE6-436C-B5E0-AB764F55FCD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
| 15 | + {2A789031-AEE6-436C-B5E0-AB764F55FCD2}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
| 16 | + {2A789031-AEE6-436C-B5E0-AB764F55FCD2}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
| 17 | + {2A789031-AEE6-436C-B5E0-AB764F55FCD2}.Release|Any CPU.Build.0 = Release|Any CPU | |
| 18 | + EndGlobalSection | |
| 19 | + GlobalSection(SolutionProperties) = preSolution | |
| 20 | + HideSolutionNode = FALSE | |
| 21 | + EndGlobalSection | |
| 22 | + GlobalSection(ExtensibilityGlobals) = postSolution | |
| 23 | + SolutionGuid = {9A1A26FC-96E9-4FF3-84D8-E1FED938441E} | |
| 24 | + EndGlobalSection | |
| 25 | +EndGlobal |
+++ ModbusTest/App.config
... | ... | @@ -0,0 +1,6 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8" ?> | |
| 2 | +<configuration> | |
| 3 | + <startup> | |
| 4 | + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | |
| 5 | + </startup> | |
| 6 | +</configuration>(No newline at end of file) |
+++ ModbusTest/DBConnectionSingleton.cs
... | ... | @@ -0,0 +1,177 @@ |
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Data; | |
| 4 | +using System.Data.SqlClient; | |
| 5 | +using System.Linq; | |
| 6 | +using System.Text; | |
| 7 | +using System.Threading.Tasks; | |
| 8 | + | |
| 9 | +namespace KHModbus | |
| 10 | +{ | |
| 11 | + public class DBConnectionSingleton | |
| 12 | + { | |
| 13 | + private static DBConnectionSingleton DBConnection; | |
| 14 | + | |
| 15 | + // Connection 정보를 세팅한다. | |
| 16 | + private string DBURL = "192.168.1.17,1433"; | |
| 17 | + private string DBPASSWORD = "signus1!"; | |
| 18 | + //private string DBURL = "signus-smes.koreacentral.cloudapp.azure.com,14443"; | |
| 19 | + //private string DBPASSWORD = "tlrmsjtm~1@3"; | |
| 20 | + private string DBNAME = "U3SMES"; | |
| 21 | + private string DBID = "sa"; | |
| 22 | + SqlConnection mConn; | |
| 23 | + | |
| 24 | + public struct DBValue | |
| 25 | + { | |
| 26 | + public string name; | |
| 27 | + public string value; | |
| 28 | + public SqlDbType type; | |
| 29 | + }; | |
| 30 | + | |
| 31 | + | |
| 32 | + public static DBConnectionSingleton Instance() | |
| 33 | + { | |
| 34 | + if (DBConnection == null) | |
| 35 | + { | |
| 36 | + DBConnection = new DBConnectionSingleton(); | |
| 37 | + } | |
| 38 | + return DBConnection; | |
| 39 | + } | |
| 40 | + | |
| 41 | + public bool isConnect() | |
| 42 | + { | |
| 43 | + if (mConn == null) return false; | |
| 44 | + if(mConn.State == ConnectionState.Open) | |
| 45 | + { | |
| 46 | + return true; | |
| 47 | + } | |
| 48 | + return false; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public bool Connect() | |
| 52 | + { | |
| 53 | + string strconn = string.Format(" Data Source={0};Initial Catalog={1};Persist Security Info=false;Integrated Security=false;User ID={2};Password={3};enlist=true;Connect Timeout=2", DBURL, DBNAME, DBID, DBPASSWORD); | |
| 54 | + mConn = new SqlConnection(strconn); | |
| 55 | + try | |
| 56 | + { | |
| 57 | + // DB 연결 | |
| 58 | + mConn.Open(); | |
| 59 | + | |
| 60 | + // 연결여부에 따라 다른 메시지를 보여준다 | |
| 61 | + if (mConn.State == ConnectionState.Open) | |
| 62 | + { | |
| 63 | + return true; | |
| 64 | + } | |
| 65 | + else | |
| 66 | + { | |
| 67 | + return false; | |
| 68 | + } | |
| 69 | + } | |
| 70 | + catch (Exception ex) | |
| 71 | + { | |
| 72 | + return false; | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + | |
| 77 | + public bool Close() | |
| 78 | + { | |
| 79 | + try | |
| 80 | + { | |
| 81 | + // DB 연결해제 | |
| 82 | + mConn.Close(); | |
| 83 | + | |
| 84 | + // 연결여부에 따라 다른 메시지를 보여준다 | |
| 85 | + if (mConn.State == ConnectionState.Closed) | |
| 86 | + { | |
| 87 | + return true; | |
| 88 | + } | |
| 89 | + else | |
| 90 | + { | |
| 91 | + return false; | |
| 92 | + } | |
| 93 | + } | |
| 94 | + catch (Exception ex) | |
| 95 | + { | |
| 96 | + return false; | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 100 | + | |
| 101 | + public DBValue getParams(string name, string value) | |
| 102 | + { | |
| 103 | + DBValue d = new DBValue(); | |
| 104 | + | |
| 105 | + d.value = value; | |
| 106 | + d.name = name; | |
| 107 | + | |
| 108 | + return d; | |
| 109 | + | |
| 110 | + } | |
| 111 | + | |
| 112 | + | |
| 113 | + public bool SetCommand(string sql, params DBValue[] data) | |
| 114 | + { | |
| 115 | + if (!isConnect()) | |
| 116 | + { | |
| 117 | + Connect(); | |
| 118 | + } | |
| 119 | + try | |
| 120 | + { | |
| 121 | + SqlCommand com = new SqlCommand(sql, mConn); | |
| 122 | + com.CommandType = CommandType.StoredProcedure; | |
| 123 | + for (int i = 0; i < data.Length; i++) | |
| 124 | + { | |
| 125 | + SqlParameter pInput = new SqlParameter("@" + data[i].name, SqlDbType.NVarChar, data[i].value.Length); | |
| 126 | + pInput.Direction = ParameterDirection.Input; | |
| 127 | + pInput.Value = data[i].value; | |
| 128 | + com.Parameters.Add(pInput); | |
| 129 | + //com.Parameters.AddWithValue("@" + data[i].name, data[i].value); | |
| 130 | + } | |
| 131 | + | |
| 132 | + com.ExecuteNonQuery(); | |
| 133 | + | |
| 134 | + Close(); | |
| 135 | + } | |
| 136 | + catch(Exception ex) | |
| 137 | + { | |
| 138 | + return false; | |
| 139 | + } | |
| 140 | + return true; | |
| 141 | + | |
| 142 | + } | |
| 143 | + | |
| 144 | + | |
| 145 | + public DataTable GetSqlData(string sql) | |
| 146 | + { | |
| 147 | + try | |
| 148 | + { | |
| 149 | + if (!isConnect()) | |
| 150 | + { | |
| 151 | + if (!Connect()) | |
| 152 | + { | |
| 153 | + return null; | |
| 154 | + } | |
| 155 | + } | |
| 156 | + SqlDataAdapter da = new SqlDataAdapter(sql, mConn); | |
| 157 | + | |
| 158 | + | |
| 159 | + DataTable dt = new DataTable(); | |
| 160 | + | |
| 161 | + | |
| 162 | + da.Fill(dt); | |
| 163 | + | |
| 164 | + Close(); | |
| 165 | + return dt; | |
| 166 | + }catch(Exception ex) | |
| 167 | + { | |
| 168 | + return null; | |
| 169 | + } | |
| 170 | + } | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + } | |
| 177 | +} |
+++ ModbusTest/FormModbus.Designer.cs
... | ... | @@ -0,0 +1,831 @@ |
| 1 | + | |
| 2 | +namespace KHModbus | |
| 3 | +{ | |
| 4 | + partial class FormModbus | |
| 5 | + { | |
| 6 | + /// <summary> | |
| 7 | + /// 필수 디자이너 변수입니다. | |
| 8 | + /// </summary> | |
| 9 | + private System.ComponentModel.IContainer components = null; | |
| 10 | + | |
| 11 | + /// <summary> | |
| 12 | + /// 사용 중인 모든 리소스를 정리합니다. | |
| 13 | + /// </summary> | |
| 14 | + /// <param name="disposing">관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다.</param> | |
| 15 | + protected override void Dispose(bool disposing) | |
| 16 | + { | |
| 17 | + if (disposing && (components != null)) | |
| 18 | + { | |
| 19 | + components.Dispose(); | |
| 20 | + } | |
| 21 | + base.Dispose(disposing); | |
| 22 | + } | |
| 23 | + | |
| 24 | + #region Windows Form 디자이너에서 생성한 코드 | |
| 25 | + | |
| 26 | + /// <summary> | |
| 27 | + /// 디자이너 지원에 필요한 메서드입니다. | |
| 28 | + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. | |
| 29 | + /// </summary> | |
| 30 | + private void InitializeComponent() | |
| 31 | + { | |
| 32 | + this.components = new System.ComponentModel.Container(); | |
| 33 | + this.textBox_State = new System.Windows.Forms.TextBox(); | |
| 34 | + this.timer_Connect = new System.Windows.Forms.Timer(this.components); | |
| 35 | + this.simpleButton2 = new DevExpress.XtraEditors.SimpleButton(); | |
| 36 | + this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton(); | |
| 37 | + this.simpleButton3 = new DevExpress.XtraEditors.SimpleButton(); | |
| 38 | + this.simpleButton4 = new DevExpress.XtraEditors.SimpleButton(); | |
| 39 | + this.timer_AutoInput = new System.Windows.Forms.Timer(this.components); | |
| 40 | + this.toggleSwitch_Auto = new DevExpress.XtraEditors.ToggleSwitch(); | |
| 41 | + this.label1 = new System.Windows.Forms.Label(); | |
| 42 | + this.simpleButton5 = new DevExpress.XtraEditors.SimpleButton(); | |
| 43 | + this.simpleButton6 = new DevExpress.XtraEditors.SimpleButton(); | |
| 44 | + this.label2 = new System.Windows.Forms.Label(); | |
| 45 | + this.textBox_DEV_ID = new System.Windows.Forms.TextBox(); | |
| 46 | + this.textBox_FUNC = new System.Windows.Forms.TextBox(); | |
| 47 | + this.label3 = new System.Windows.Forms.Label(); | |
| 48 | + this.textBox_ADDR = new System.Windows.Forms.TextBox(); | |
| 49 | + this.label4 = new System.Windows.Forms.Label(); | |
| 50 | + this.simpleButton7 = new DevExpress.XtraEditors.SimpleButton(); | |
| 51 | + this.simpleButton_InputRegister_1 = new DevExpress.XtraEditors.SimpleButton(); | |
| 52 | + this.textBox_LENGTH_1 = new System.Windows.Forms.TextBox(); | |
| 53 | + this.label5 = new System.Windows.Forms.Label(); | |
| 54 | + this.textBox_Addr_1 = new System.Windows.Forms.TextBox(); | |
| 55 | + this.label6 = new System.Windows.Forms.Label(); | |
| 56 | + this.textBox_LENGTH_2 = new System.Windows.Forms.TextBox(); | |
| 57 | + this.label7 = new System.Windows.Forms.Label(); | |
| 58 | + this.textBox_Addr_2 = new System.Windows.Forms.TextBox(); | |
| 59 | + this.label8 = new System.Windows.Forms.Label(); | |
| 60 | + this.simpleButton_InputRegister_2 = new DevExpress.XtraEditors.SimpleButton(); | |
| 61 | + this.textBox_LENGTH_3 = new System.Windows.Forms.TextBox(); | |
| 62 | + this.label9 = new System.Windows.Forms.Label(); | |
| 63 | + this.textBox_Addr_3 = new System.Windows.Forms.TextBox(); | |
| 64 | + this.label10 = new System.Windows.Forms.Label(); | |
| 65 | + this.simpleButton_InputRegister_3 = new DevExpress.XtraEditors.SimpleButton(); | |
| 66 | + this.textBox_LENGTH_5 = new System.Windows.Forms.TextBox(); | |
| 67 | + this.label13 = new System.Windows.Forms.Label(); | |
| 68 | + this.textBox_Addr_5 = new System.Windows.Forms.TextBox(); | |
| 69 | + this.label14 = new System.Windows.Forms.Label(); | |
| 70 | + this.simpleButton_InputRegister_5 = new DevExpress.XtraEditors.SimpleButton(); | |
| 71 | + this.textBox_LENGTH_4 = new System.Windows.Forms.TextBox(); | |
| 72 | + this.label15 = new System.Windows.Forms.Label(); | |
| 73 | + this.textBox_Addr_4 = new System.Windows.Forms.TextBox(); | |
| 74 | + this.label16 = new System.Windows.Forms.Label(); | |
| 75 | + this.simpleButton_InputRegister_4 = new DevExpress.XtraEditors.SimpleButton(); | |
| 76 | + this.textBox_LENGTH_6 = new System.Windows.Forms.TextBox(); | |
| 77 | + this.label17 = new System.Windows.Forms.Label(); | |
| 78 | + this.textBox_Addr_6 = new System.Windows.Forms.TextBox(); | |
| 79 | + this.label18 = new System.Windows.Forms.Label(); | |
| 80 | + this.simpleButton_InputRegister_6 = new DevExpress.XtraEditors.SimpleButton(); | |
| 81 | + this.textBox_LENGTH_2_2 = new System.Windows.Forms.TextBox(); | |
| 82 | + this.label11 = new System.Windows.Forms.Label(); | |
| 83 | + this.textBox_Addr_2_2 = new System.Windows.Forms.TextBox(); | |
| 84 | + this.label12 = new System.Windows.Forms.Label(); | |
| 85 | + this.simpleButton_InputRegister_2_2 = new DevExpress.XtraEditors.SimpleButton(); | |
| 86 | + this.simpleButton_All = new DevExpress.XtraEditors.SimpleButton(); | |
| 87 | + this.timer_DBInsert = new System.Windows.Forms.Timer(this.components); | |
| 88 | + this.panel_DBConnect = new System.Windows.Forms.Panel(); | |
| 89 | + this.label19 = new System.Windows.Forms.Label(); | |
| 90 | + this.label20 = new System.Windows.Forms.Label(); | |
| 91 | + this.toggleSwitch_Log = new DevExpress.XtraEditors.ToggleSwitch(); | |
| 92 | + this.timer_Log = new System.Windows.Forms.Timer(this.components); | |
| 93 | + this.textBox1 = new System.Windows.Forms.TextBox(); | |
| 94 | + this.label21 = new System.Windows.Forms.Label(); | |
| 95 | + this.simpleButton8 = new DevExpress.XtraEditors.SimpleButton(); | |
| 96 | + ((System.ComponentModel.ISupportInitialize)(this.toggleSwitch_Auto.Properties)).BeginInit(); | |
| 97 | + this.panel_DBConnect.SuspendLayout(); | |
| 98 | + ((System.ComponentModel.ISupportInitialize)(this.toggleSwitch_Log.Properties)).BeginInit(); | |
| 99 | + this.SuspendLayout(); | |
| 100 | + // | |
| 101 | + // textBox_State | |
| 102 | + // | |
| 103 | + this.textBox_State.Location = new System.Drawing.Point(12, 177); | |
| 104 | + this.textBox_State.Multiline = true; | |
| 105 | + this.textBox_State.Name = "textBox_State"; | |
| 106 | + this.textBox_State.ScrollBars = System.Windows.Forms.ScrollBars.Both; | |
| 107 | + this.textBox_State.Size = new System.Drawing.Size(915, 234); | |
| 108 | + this.textBox_State.TabIndex = 1; | |
| 109 | + // | |
| 110 | + // timer_Connect | |
| 111 | + // | |
| 112 | + this.timer_Connect.Enabled = true; | |
| 113 | + this.timer_Connect.Interval = 5000; | |
| 114 | + this.timer_Connect.Tick += new System.EventHandler(this.timer_Connect_Tick); | |
| 115 | + // | |
| 116 | + // simpleButton2 | |
| 117 | + // | |
| 118 | + this.simpleButton2.Location = new System.Drawing.Point(16, 88); | |
| 119 | + this.simpleButton2.Name = "simpleButton2"; | |
| 120 | + this.simpleButton2.Size = new System.Drawing.Size(122, 85); | |
| 121 | + this.simpleButton2.TabIndex = 2; | |
| 122 | + this.simpleButton2.Text = "DataReadingTEST"; | |
| 123 | + this.simpleButton2.Visible = false; | |
| 124 | + this.simpleButton2.Click += new System.EventHandler(this.simpleButton2_Click); | |
| 125 | + // | |
| 126 | + // simpleButton1 | |
| 127 | + // | |
| 128 | + this.simpleButton1.Location = new System.Drawing.Point(272, 88); | |
| 129 | + this.simpleButton1.Name = "simpleButton1"; | |
| 130 | + this.simpleButton1.Size = new System.Drawing.Size(122, 85); | |
| 131 | + this.simpleButton1.TabIndex = 3; | |
| 132 | + this.simpleButton1.Text = "DBTEST"; | |
| 133 | + this.simpleButton1.Visible = false; | |
| 134 | + this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click_1); | |
| 135 | + // | |
| 136 | + // simpleButton3 | |
| 137 | + // | |
| 138 | + this.simpleButton3.Location = new System.Drawing.Point(144, 88); | |
| 139 | + this.simpleButton3.Name = "simpleButton3"; | |
| 140 | + this.simpleButton3.Size = new System.Drawing.Size(122, 85); | |
| 141 | + this.simpleButton3.TabIndex = 4; | |
| 142 | + this.simpleButton3.Text = "DBIsertTest"; | |
| 143 | + this.simpleButton3.Visible = false; | |
| 144 | + this.simpleButton3.Click += new System.EventHandler(this.simpleButton3_Click); | |
| 145 | + // | |
| 146 | + // simpleButton4 | |
| 147 | + // | |
| 148 | + this.simpleButton4.Location = new System.Drawing.Point(444, 88); | |
| 149 | + this.simpleButton4.Name = "simpleButton4"; | |
| 150 | + this.simpleButton4.Size = new System.Drawing.Size(122, 85); | |
| 151 | + this.simpleButton4.TabIndex = 5; | |
| 152 | + this.simpleButton4.Text = "[PLC]\r\nReading&&Insert"; | |
| 153 | + this.simpleButton4.Visible = false; | |
| 154 | + this.simpleButton4.Click += new System.EventHandler(this.simpleButton4_Click); | |
| 155 | + // | |
| 156 | + // timer_AutoInput | |
| 157 | + // | |
| 158 | + this.timer_AutoInput.Enabled = true; | |
| 159 | + this.timer_AutoInput.Interval = 500; | |
| 160 | + this.timer_AutoInput.Tick += new System.EventHandler(this.timer_AutoInput_Tick); | |
| 161 | + // | |
| 162 | + // toggleSwitch_Auto | |
| 163 | + // | |
| 164 | + this.toggleSwitch_Auto.EditValue = true; | |
| 165 | + this.toggleSwitch_Auto.Location = new System.Drawing.Point(686, 146); | |
| 166 | + this.toggleSwitch_Auto.Name = "toggleSwitch_Auto"; | |
| 167 | + this.toggleSwitch_Auto.Properties.OffText = "Off"; | |
| 168 | + this.toggleSwitch_Auto.Properties.OnText = "On"; | |
| 169 | + this.toggleSwitch_Auto.Size = new System.Drawing.Size(105, 25); | |
| 170 | + this.toggleSwitch_Auto.TabIndex = 6; | |
| 171 | + this.toggleSwitch_Auto.Toggled += new System.EventHandler(this.toggleSwitch_Auto_Toggled); | |
| 172 | + // | |
| 173 | + // label1 | |
| 174 | + // | |
| 175 | + this.label1.AutoSize = true; | |
| 176 | + this.label1.Location = new System.Drawing.Point(684, 131); | |
| 177 | + this.label1.Name = "label1"; | |
| 178 | + this.label1.Size = new System.Drawing.Size(61, 12); | |
| 179 | + this.label1.TabIndex = 7; | |
| 180 | + this.label1.Text = "AutoInsert"; | |
| 181 | + // | |
| 182 | + // simpleButton5 | |
| 183 | + // | |
| 184 | + this.simpleButton5.Location = new System.Drawing.Point(558, 12); | |
| 185 | + this.simpleButton5.Name = "simpleButton5"; | |
| 186 | + this.simpleButton5.Size = new System.Drawing.Size(122, 57); | |
| 187 | + this.simpleButton5.TabIndex = 8; | |
| 188 | + this.simpleButton5.Text = "{SERIAL]\r\nReading&&Insert"; | |
| 189 | + this.simpleButton5.Visible = false; | |
| 190 | + this.simpleButton5.Click += new System.EventHandler(this.simpleButton5_Click); | |
| 191 | + // | |
| 192 | + // simpleButton6 | |
| 193 | + // | |
| 194 | + this.simpleButton6.Location = new System.Drawing.Point(444, 12); | |
| 195 | + this.simpleButton6.Name = "simpleButton6"; | |
| 196 | + this.simpleButton6.Size = new System.Drawing.Size(98, 57); | |
| 197 | + this.simpleButton6.TabIndex = 9; | |
| 198 | + this.simpleButton6.Text = "[4Byte][SERIAL]\r\nCOMM_TEST"; | |
| 199 | + this.simpleButton6.Visible = false; | |
| 200 | + this.simpleButton6.Click += new System.EventHandler(this.simpleButton6_Click); | |
| 201 | + // | |
| 202 | + // label2 | |
| 203 | + // | |
| 204 | + this.label2.AutoSize = true; | |
| 205 | + this.label2.Location = new System.Drawing.Point(14, 28); | |
| 206 | + this.label2.Name = "label2"; | |
| 207 | + this.label2.Size = new System.Drawing.Size(44, 12); | |
| 208 | + this.label2.TabIndex = 10; | |
| 209 | + this.label2.Text = "SLAVE"; | |
| 210 | + this.label2.Visible = false; | |
| 211 | + // | |
| 212 | + // textBox_DEV_ID | |
| 213 | + // | |
| 214 | + this.textBox_DEV_ID.Location = new System.Drawing.Point(65, 23); | |
| 215 | + this.textBox_DEV_ID.Name = "textBox_DEV_ID"; | |
| 216 | + this.textBox_DEV_ID.Size = new System.Drawing.Size(44, 21); | |
| 217 | + this.textBox_DEV_ID.TabIndex = 11; | |
| 218 | + this.textBox_DEV_ID.Text = "1"; | |
| 219 | + this.textBox_DEV_ID.Visible = false; | |
| 220 | + // | |
| 221 | + // textBox_FUNC | |
| 222 | + // | |
| 223 | + this.textBox_FUNC.Location = new System.Drawing.Point(171, 22); | |
| 224 | + this.textBox_FUNC.Name = "textBox_FUNC"; | |
| 225 | + this.textBox_FUNC.Size = new System.Drawing.Size(44, 21); | |
| 226 | + this.textBox_FUNC.TabIndex = 13; | |
| 227 | + this.textBox_FUNC.Text = "4"; | |
| 228 | + this.textBox_FUNC.Visible = false; | |
| 229 | + // | |
| 230 | + // label3 | |
| 231 | + // | |
| 232 | + this.label3.AutoSize = true; | |
| 233 | + this.label3.Location = new System.Drawing.Point(124, 27); | |
| 234 | + this.label3.Name = "label3"; | |
| 235 | + this.label3.Size = new System.Drawing.Size(38, 12); | |
| 236 | + this.label3.TabIndex = 12; | |
| 237 | + this.label3.Text = "FUNC"; | |
| 238 | + this.label3.Visible = false; | |
| 239 | + // | |
| 240 | + // textBox_ADDR | |
| 241 | + // | |
| 242 | + this.textBox_ADDR.Location = new System.Drawing.Point(276, 22); | |
| 243 | + this.textBox_ADDR.Name = "textBox_ADDR"; | |
| 244 | + this.textBox_ADDR.Size = new System.Drawing.Size(44, 21); | |
| 245 | + this.textBox_ADDR.TabIndex = 15; | |
| 246 | + this.textBox_ADDR.Text = "220"; | |
| 247 | + this.textBox_ADDR.Visible = false; | |
| 248 | + // | |
| 249 | + // label4 | |
| 250 | + // | |
| 251 | + this.label4.AutoSize = true; | |
| 252 | + this.label4.Location = new System.Drawing.Point(229, 27); | |
| 253 | + this.label4.Name = "label4"; | |
| 254 | + this.label4.Size = new System.Drawing.Size(37, 12); | |
| 255 | + this.label4.TabIndex = 14; | |
| 256 | + this.label4.Text = "ADDR"; | |
| 257 | + this.label4.Visible = false; | |
| 258 | + // | |
| 259 | + // simpleButton7 | |
| 260 | + // | |
| 261 | + this.simpleButton7.Location = new System.Drawing.Point(326, 12); | |
| 262 | + this.simpleButton7.Name = "simpleButton7"; | |
| 263 | + this.simpleButton7.Size = new System.Drawing.Size(98, 57); | |
| 264 | + this.simpleButton7.TabIndex = 16; | |
| 265 | + this.simpleButton7.Text = "[2Byte][SERIAL]\r\nCOMM_TEST"; | |
| 266 | + this.simpleButton7.Visible = false; | |
| 267 | + this.simpleButton7.Click += new System.EventHandler(this.simpleButton7_Click); | |
| 268 | + // | |
| 269 | + // simpleButton_InputRegister_1 | |
| 270 | + // | |
| 271 | + this.simpleButton_InputRegister_1.Location = new System.Drawing.Point(1146, 39); | |
| 272 | + this.simpleButton_InputRegister_1.Name = "simpleButton_InputRegister_1"; | |
| 273 | + this.simpleButton_InputRegister_1.Size = new System.Drawing.Size(122, 32); | |
| 274 | + this.simpleButton_InputRegister_1.TabIndex = 17; | |
| 275 | + this.simpleButton_InputRegister_1.Text = "InputRegister"; | |
| 276 | + this.simpleButton_InputRegister_1.Visible = false; | |
| 277 | + this.simpleButton_InputRegister_1.Click += new System.EventHandler(this.simpleButton_InputRegister_1_Click); | |
| 278 | + // | |
| 279 | + // textBox_LENGTH_1 | |
| 280 | + // | |
| 281 | + this.textBox_LENGTH_1.Location = new System.Drawing.Point(1085, 46); | |
| 282 | + this.textBox_LENGTH_1.Name = "textBox_LENGTH_1"; | |
| 283 | + this.textBox_LENGTH_1.Size = new System.Drawing.Size(44, 21); | |
| 284 | + this.textBox_LENGTH_1.TabIndex = 21; | |
| 285 | + this.textBox_LENGTH_1.Text = "48"; | |
| 286 | + this.textBox_LENGTH_1.Visible = false; | |
| 287 | + // | |
| 288 | + // label5 | |
| 289 | + // | |
| 290 | + this.label5.AutoSize = true; | |
| 291 | + this.label5.Location = new System.Drawing.Point(1030, 51); | |
| 292 | + this.label5.Name = "label5"; | |
| 293 | + this.label5.Size = new System.Drawing.Size(54, 12); | |
| 294 | + this.label5.TabIndex = 20; | |
| 295 | + this.label5.Text = "LENGTH"; | |
| 296 | + this.label5.Visible = false; | |
| 297 | + // | |
| 298 | + // textBox_Addr_1 | |
| 299 | + // | |
| 300 | + this.textBox_Addr_1.Location = new System.Drawing.Point(980, 46); | |
| 301 | + this.textBox_Addr_1.Name = "textBox_Addr_1"; | |
| 302 | + this.textBox_Addr_1.Size = new System.Drawing.Size(44, 21); | |
| 303 | + this.textBox_Addr_1.TabIndex = 19; | |
| 304 | + this.textBox_Addr_1.Text = "400"; | |
| 305 | + this.textBox_Addr_1.Visible = false; | |
| 306 | + // | |
| 307 | + // label6 | |
| 308 | + // | |
| 309 | + this.label6.AutoSize = true; | |
| 310 | + this.label6.Location = new System.Drawing.Point(933, 51); | |
| 311 | + this.label6.Name = "label6"; | |
| 312 | + this.label6.Size = new System.Drawing.Size(37, 12); | |
| 313 | + this.label6.TabIndex = 18; | |
| 314 | + this.label6.Text = "ADDR"; | |
| 315 | + this.label6.Visible = false; | |
| 316 | + // | |
| 317 | + // textBox_LENGTH_2 | |
| 318 | + // | |
| 319 | + this.textBox_LENGTH_2.Location = new System.Drawing.Point(1085, 84); | |
| 320 | + this.textBox_LENGTH_2.Name = "textBox_LENGTH_2"; | |
| 321 | + this.textBox_LENGTH_2.Size = new System.Drawing.Size(44, 21); | |
| 322 | + this.textBox_LENGTH_2.TabIndex = 26; | |
| 323 | + this.textBox_LENGTH_2.Text = "20"; | |
| 324 | + this.textBox_LENGTH_2.Visible = false; | |
| 325 | + // | |
| 326 | + // label7 | |
| 327 | + // | |
| 328 | + this.label7.AutoSize = true; | |
| 329 | + this.label7.Location = new System.Drawing.Point(1030, 89); | |
| 330 | + this.label7.Name = "label7"; | |
| 331 | + this.label7.Size = new System.Drawing.Size(54, 12); | |
| 332 | + this.label7.TabIndex = 25; | |
| 333 | + this.label7.Text = "LENGTH"; | |
| 334 | + this.label7.Visible = false; | |
| 335 | + // | |
| 336 | + // textBox_Addr_2 | |
| 337 | + // | |
| 338 | + this.textBox_Addr_2.Location = new System.Drawing.Point(980, 84); | |
| 339 | + this.textBox_Addr_2.Name = "textBox_Addr_2"; | |
| 340 | + this.textBox_Addr_2.Size = new System.Drawing.Size(44, 21); | |
| 341 | + this.textBox_Addr_2.TabIndex = 24; | |
| 342 | + this.textBox_Addr_2.Text = "500"; | |
| 343 | + this.textBox_Addr_2.Visible = false; | |
| 344 | + // | |
| 345 | + // label8 | |
| 346 | + // | |
| 347 | + this.label8.AutoSize = true; | |
| 348 | + this.label8.Location = new System.Drawing.Point(933, 89); | |
| 349 | + this.label8.Name = "label8"; | |
| 350 | + this.label8.Size = new System.Drawing.Size(37, 12); | |
| 351 | + this.label8.TabIndex = 23; | |
| 352 | + this.label8.Text = "ADDR"; | |
| 353 | + this.label8.Visible = false; | |
| 354 | + // | |
| 355 | + // simpleButton_InputRegister_2 | |
| 356 | + // | |
| 357 | + this.simpleButton_InputRegister_2.Location = new System.Drawing.Point(1146, 77); | |
| 358 | + this.simpleButton_InputRegister_2.Name = "simpleButton_InputRegister_2"; | |
| 359 | + this.simpleButton_InputRegister_2.Size = new System.Drawing.Size(122, 32); | |
| 360 | + this.simpleButton_InputRegister_2.TabIndex = 22; | |
| 361 | + this.simpleButton_InputRegister_2.Text = "InputRegister"; | |
| 362 | + this.simpleButton_InputRegister_2.Visible = false; | |
| 363 | + this.simpleButton_InputRegister_2.Click += new System.EventHandler(this.simpleButton_InputRegister_2_Click); | |
| 364 | + // | |
| 365 | + // textBox_LENGTH_3 | |
| 366 | + // | |
| 367 | + this.textBox_LENGTH_3.Location = new System.Drawing.Point(1085, 171); | |
| 368 | + this.textBox_LENGTH_3.Name = "textBox_LENGTH_3"; | |
| 369 | + this.textBox_LENGTH_3.Size = new System.Drawing.Size(44, 21); | |
| 370 | + this.textBox_LENGTH_3.TabIndex = 31; | |
| 371 | + this.textBox_LENGTH_3.Text = "19"; | |
| 372 | + this.textBox_LENGTH_3.Visible = false; | |
| 373 | + // | |
| 374 | + // label9 | |
| 375 | + // | |
| 376 | + this.label9.AutoSize = true; | |
| 377 | + this.label9.Location = new System.Drawing.Point(1030, 176); | |
| 378 | + this.label9.Name = "label9"; | |
| 379 | + this.label9.Size = new System.Drawing.Size(54, 12); | |
| 380 | + this.label9.TabIndex = 30; | |
| 381 | + this.label9.Text = "LENGTH"; | |
| 382 | + this.label9.Visible = false; | |
| 383 | + // | |
| 384 | + // textBox_Addr_3 | |
| 385 | + // | |
| 386 | + this.textBox_Addr_3.Location = new System.Drawing.Point(980, 171); | |
| 387 | + this.textBox_Addr_3.Name = "textBox_Addr_3"; | |
| 388 | + this.textBox_Addr_3.Size = new System.Drawing.Size(44, 21); | |
| 389 | + this.textBox_Addr_3.TabIndex = 29; | |
| 390 | + this.textBox_Addr_3.Text = "600"; | |
| 391 | + this.textBox_Addr_3.Visible = false; | |
| 392 | + // | |
| 393 | + // label10 | |
| 394 | + // | |
| 395 | + this.label10.AutoSize = true; | |
| 396 | + this.label10.Location = new System.Drawing.Point(933, 176); | |
| 397 | + this.label10.Name = "label10"; | |
| 398 | + this.label10.Size = new System.Drawing.Size(37, 12); | |
| 399 | + this.label10.TabIndex = 28; | |
| 400 | + this.label10.Text = "ADDR"; | |
| 401 | + this.label10.Visible = false; | |
| 402 | + // | |
| 403 | + // simpleButton_InputRegister_3 | |
| 404 | + // | |
| 405 | + this.simpleButton_InputRegister_3.Location = new System.Drawing.Point(1146, 164); | |
| 406 | + this.simpleButton_InputRegister_3.Name = "simpleButton_InputRegister_3"; | |
| 407 | + this.simpleButton_InputRegister_3.Size = new System.Drawing.Size(122, 32); | |
| 408 | + this.simpleButton_InputRegister_3.TabIndex = 27; | |
| 409 | + this.simpleButton_InputRegister_3.Text = "InputRegister"; | |
| 410 | + this.simpleButton_InputRegister_3.Visible = false; | |
| 411 | + this.simpleButton_InputRegister_3.Click += new System.EventHandler(this.simpleButton_InputRegister_3_Click); | |
| 412 | + // | |
| 413 | + // textBox_LENGTH_5 | |
| 414 | + // | |
| 415 | + this.textBox_LENGTH_5.Location = new System.Drawing.Point(1085, 247); | |
| 416 | + this.textBox_LENGTH_5.Name = "textBox_LENGTH_5"; | |
| 417 | + this.textBox_LENGTH_5.Size = new System.Drawing.Size(44, 21); | |
| 418 | + this.textBox_LENGTH_5.TabIndex = 41; | |
| 419 | + this.textBox_LENGTH_5.Text = "40"; | |
| 420 | + this.textBox_LENGTH_5.Visible = false; | |
| 421 | + // | |
| 422 | + // label13 | |
| 423 | + // | |
| 424 | + this.label13.AutoSize = true; | |
| 425 | + this.label13.Location = new System.Drawing.Point(1030, 252); | |
| 426 | + this.label13.Name = "label13"; | |
| 427 | + this.label13.Size = new System.Drawing.Size(54, 12); | |
| 428 | + this.label13.TabIndex = 40; | |
| 429 | + this.label13.Text = "LENGTH"; | |
| 430 | + this.label13.Visible = false; | |
| 431 | + // | |
| 432 | + // textBox_Addr_5 | |
| 433 | + // | |
| 434 | + this.textBox_Addr_5.Location = new System.Drawing.Point(980, 247); | |
| 435 | + this.textBox_Addr_5.Name = "textBox_Addr_5"; | |
| 436 | + this.textBox_Addr_5.Size = new System.Drawing.Size(44, 21); | |
| 437 | + this.textBox_Addr_5.TabIndex = 39; | |
| 438 | + this.textBox_Addr_5.Text = "700"; | |
| 439 | + this.textBox_Addr_5.Visible = false; | |
| 440 | + // | |
| 441 | + // label14 | |
| 442 | + // | |
| 443 | + this.label14.AutoSize = true; | |
| 444 | + this.label14.Location = new System.Drawing.Point(933, 252); | |
| 445 | + this.label14.Name = "label14"; | |
| 446 | + this.label14.Size = new System.Drawing.Size(37, 12); | |
| 447 | + this.label14.TabIndex = 38; | |
| 448 | + this.label14.Text = "ADDR"; | |
| 449 | + this.label14.Visible = false; | |
| 450 | + // | |
| 451 | + // simpleButton_InputRegister_5 | |
| 452 | + // | |
| 453 | + this.simpleButton_InputRegister_5.Location = new System.Drawing.Point(1146, 240); | |
| 454 | + this.simpleButton_InputRegister_5.Name = "simpleButton_InputRegister_5"; | |
| 455 | + this.simpleButton_InputRegister_5.Size = new System.Drawing.Size(122, 32); | |
| 456 | + this.simpleButton_InputRegister_5.TabIndex = 37; | |
| 457 | + this.simpleButton_InputRegister_5.Text = "InputRegister"; | |
| 458 | + this.simpleButton_InputRegister_5.Visible = false; | |
| 459 | + this.simpleButton_InputRegister_5.Click += new System.EventHandler(this.simpleButton_InputRegister_5_Click); | |
| 460 | + // | |
| 461 | + // textBox_LENGTH_4 | |
| 462 | + // | |
| 463 | + this.textBox_LENGTH_4.Location = new System.Drawing.Point(1085, 209); | |
| 464 | + this.textBox_LENGTH_4.Name = "textBox_LENGTH_4"; | |
| 465 | + this.textBox_LENGTH_4.Size = new System.Drawing.Size(44, 21); | |
| 466 | + this.textBox_LENGTH_4.TabIndex = 36; | |
| 467 | + this.textBox_LENGTH_4.Text = "19"; | |
| 468 | + this.textBox_LENGTH_4.Visible = false; | |
| 469 | + // | |
| 470 | + // label15 | |
| 471 | + // | |
| 472 | + this.label15.AutoSize = true; | |
| 473 | + this.label15.Location = new System.Drawing.Point(1030, 214); | |
| 474 | + this.label15.Name = "label15"; | |
| 475 | + this.label15.Size = new System.Drawing.Size(54, 12); | |
| 476 | + this.label15.TabIndex = 35; | |
| 477 | + this.label15.Text = "LENGTH"; | |
| 478 | + this.label15.Visible = false; | |
| 479 | + // | |
| 480 | + // textBox_Addr_4 | |
| 481 | + // | |
| 482 | + this.textBox_Addr_4.Location = new System.Drawing.Point(980, 209); | |
| 483 | + this.textBox_Addr_4.Name = "textBox_Addr_4"; | |
| 484 | + this.textBox_Addr_4.Size = new System.Drawing.Size(44, 21); | |
| 485 | + this.textBox_Addr_4.TabIndex = 34; | |
| 486 | + this.textBox_Addr_4.Text = "650"; | |
| 487 | + this.textBox_Addr_4.Visible = false; | |
| 488 | + // | |
| 489 | + // label16 | |
| 490 | + // | |
| 491 | + this.label16.AutoSize = true; | |
| 492 | + this.label16.Location = new System.Drawing.Point(933, 214); | |
| 493 | + this.label16.Name = "label16"; | |
| 494 | + this.label16.Size = new System.Drawing.Size(37, 12); | |
| 495 | + this.label16.TabIndex = 33; | |
| 496 | + this.label16.Text = "ADDR"; | |
| 497 | + this.label16.Visible = false; | |
| 498 | + // | |
| 499 | + // simpleButton_InputRegister_4 | |
| 500 | + // | |
| 501 | + this.simpleButton_InputRegister_4.Location = new System.Drawing.Point(1146, 202); | |
| 502 | + this.simpleButton_InputRegister_4.Name = "simpleButton_InputRegister_4"; | |
| 503 | + this.simpleButton_InputRegister_4.Size = new System.Drawing.Size(122, 32); | |
| 504 | + this.simpleButton_InputRegister_4.TabIndex = 32; | |
| 505 | + this.simpleButton_InputRegister_4.Text = "InputRegister"; | |
| 506 | + this.simpleButton_InputRegister_4.Visible = false; | |
| 507 | + this.simpleButton_InputRegister_4.Click += new System.EventHandler(this.simpleButton_InputRegister_4_Click); | |
| 508 | + // | |
| 509 | + // textBox_LENGTH_6 | |
| 510 | + // | |
| 511 | + this.textBox_LENGTH_6.Location = new System.Drawing.Point(1085, 350); | |
| 512 | + this.textBox_LENGTH_6.Name = "textBox_LENGTH_6"; | |
| 513 | + this.textBox_LENGTH_6.Size = new System.Drawing.Size(44, 21); | |
| 514 | + this.textBox_LENGTH_6.TabIndex = 61; | |
| 515 | + this.textBox_LENGTH_6.Text = "2"; | |
| 516 | + // | |
| 517 | + // label17 | |
| 518 | + // | |
| 519 | + this.label17.AutoSize = true; | |
| 520 | + this.label17.Location = new System.Drawing.Point(1030, 355); | |
| 521 | + this.label17.Name = "label17"; | |
| 522 | + this.label17.Size = new System.Drawing.Size(54, 12); | |
| 523 | + this.label17.TabIndex = 60; | |
| 524 | + this.label17.Text = "LENGTH"; | |
| 525 | + // | |
| 526 | + // textBox_Addr_6 | |
| 527 | + // | |
| 528 | + this.textBox_Addr_6.Location = new System.Drawing.Point(980, 350); | |
| 529 | + this.textBox_Addr_6.Name = "textBox_Addr_6"; | |
| 530 | + this.textBox_Addr_6.Size = new System.Drawing.Size(44, 21); | |
| 531 | + this.textBox_Addr_6.TabIndex = 59; | |
| 532 | + this.textBox_Addr_6.Text = "620"; | |
| 533 | + // | |
| 534 | + // label18 | |
| 535 | + // | |
| 536 | + this.label18.AutoSize = true; | |
| 537 | + this.label18.Location = new System.Drawing.Point(933, 355); | |
| 538 | + this.label18.Name = "label18"; | |
| 539 | + this.label18.Size = new System.Drawing.Size(37, 12); | |
| 540 | + this.label18.TabIndex = 58; | |
| 541 | + this.label18.Text = "ADDR"; | |
| 542 | + // | |
| 543 | + // simpleButton_InputRegister_6 | |
| 544 | + // | |
| 545 | + this.simpleButton_InputRegister_6.Location = new System.Drawing.Point(1146, 343); | |
| 546 | + this.simpleButton_InputRegister_6.Name = "simpleButton_InputRegister_6"; | |
| 547 | + this.simpleButton_InputRegister_6.Size = new System.Drawing.Size(122, 32); | |
| 548 | + this.simpleButton_InputRegister_6.TabIndex = 57; | |
| 549 | + this.simpleButton_InputRegister_6.Text = "InputRegister"; | |
| 550 | + this.simpleButton_InputRegister_6.Click += new System.EventHandler(this.simpleButton_InputRegister_6_Click); | |
| 551 | + // | |
| 552 | + // textBox_LENGTH_2_2 | |
| 553 | + // | |
| 554 | + this.textBox_LENGTH_2_2.Location = new System.Drawing.Point(1085, 122); | |
| 555 | + this.textBox_LENGTH_2_2.Name = "textBox_LENGTH_2_2"; | |
| 556 | + this.textBox_LENGTH_2_2.Size = new System.Drawing.Size(44, 21); | |
| 557 | + this.textBox_LENGTH_2_2.TabIndex = 66; | |
| 558 | + this.textBox_LENGTH_2_2.Text = "20"; | |
| 559 | + this.textBox_LENGTH_2_2.Visible = false; | |
| 560 | + // | |
| 561 | + // label11 | |
| 562 | + // | |
| 563 | + this.label11.AutoSize = true; | |
| 564 | + this.label11.Location = new System.Drawing.Point(1030, 127); | |
| 565 | + this.label11.Name = "label11"; | |
| 566 | + this.label11.Size = new System.Drawing.Size(54, 12); | |
| 567 | + this.label11.TabIndex = 65; | |
| 568 | + this.label11.Text = "LENGTH"; | |
| 569 | + this.label11.Visible = false; | |
| 570 | + // | |
| 571 | + // textBox_Addr_2_2 | |
| 572 | + // | |
| 573 | + this.textBox_Addr_2_2.Location = new System.Drawing.Point(980, 122); | |
| 574 | + this.textBox_Addr_2_2.Name = "textBox_Addr_2_2"; | |
| 575 | + this.textBox_Addr_2_2.Size = new System.Drawing.Size(44, 21); | |
| 576 | + this.textBox_Addr_2_2.TabIndex = 64; | |
| 577 | + this.textBox_Addr_2_2.Text = "520"; | |
| 578 | + this.textBox_Addr_2_2.Visible = false; | |
| 579 | + // | |
| 580 | + // label12 | |
| 581 | + // | |
| 582 | + this.label12.AutoSize = true; | |
| 583 | + this.label12.Location = new System.Drawing.Point(933, 127); | |
| 584 | + this.label12.Name = "label12"; | |
| 585 | + this.label12.Size = new System.Drawing.Size(37, 12); | |
| 586 | + this.label12.TabIndex = 63; | |
| 587 | + this.label12.Text = "ADDR"; | |
| 588 | + this.label12.Visible = false; | |
| 589 | + // | |
| 590 | + // simpleButton_InputRegister_2_2 | |
| 591 | + // | |
| 592 | + this.simpleButton_InputRegister_2_2.Location = new System.Drawing.Point(1146, 115); | |
| 593 | + this.simpleButton_InputRegister_2_2.Name = "simpleButton_InputRegister_2_2"; | |
| 594 | + this.simpleButton_InputRegister_2_2.Size = new System.Drawing.Size(122, 32); | |
| 595 | + this.simpleButton_InputRegister_2_2.TabIndex = 62; | |
| 596 | + this.simpleButton_InputRegister_2_2.Text = "InputRegister"; | |
| 597 | + this.simpleButton_InputRegister_2_2.Visible = false; | |
| 598 | + this.simpleButton_InputRegister_2_2.Click += new System.EventHandler(this.simpleButton_InputRegister_2_2_Click); | |
| 599 | + // | |
| 600 | + // simpleButton_All | |
| 601 | + // | |
| 602 | + this.simpleButton_All.Location = new System.Drawing.Point(1293, 406); | |
| 603 | + this.simpleButton_All.Name = "simpleButton_All"; | |
| 604 | + this.simpleButton_All.Size = new System.Drawing.Size(122, 32); | |
| 605 | + this.simpleButton_All.TabIndex = 67; | |
| 606 | + this.simpleButton_All.Text = "AllReading"; | |
| 607 | + this.simpleButton_All.Visible = false; | |
| 608 | + this.simpleButton_All.Click += new System.EventHandler(this.simpleButton_All_Click); | |
| 609 | + // | |
| 610 | + // timer_DBInsert | |
| 611 | + // | |
| 612 | + this.timer_DBInsert.Enabled = true; | |
| 613 | + this.timer_DBInsert.Interval = 10000; | |
| 614 | + this.timer_DBInsert.Tick += new System.EventHandler(this.timer_DBConnect_Tick); | |
| 615 | + // | |
| 616 | + // panel_DBConnect | |
| 617 | + // | |
| 618 | + this.panel_DBConnect.BackColor = System.Drawing.Color.White; | |
| 619 | + this.panel_DBConnect.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; | |
| 620 | + this.panel_DBConnect.Controls.Add(this.label19); | |
| 621 | + this.panel_DBConnect.Location = new System.Drawing.Point(797, 122); | |
| 622 | + this.panel_DBConnect.Name = "panel_DBConnect"; | |
| 623 | + this.panel_DBConnect.Size = new System.Drawing.Size(130, 49); | |
| 624 | + this.panel_DBConnect.TabIndex = 68; | |
| 625 | + // | |
| 626 | + // label19 | |
| 627 | + // | |
| 628 | + this.label19.AutoSize = true; | |
| 629 | + this.label19.Location = new System.Drawing.Point(30, 20); | |
| 630 | + this.label19.Name = "label19"; | |
| 631 | + this.label19.Size = new System.Drawing.Size(72, 12); | |
| 632 | + this.label19.TabIndex = 0; | |
| 633 | + this.label19.Text = "DB Connect"; | |
| 634 | + // | |
| 635 | + // label20 | |
| 636 | + // | |
| 637 | + this.label20.AutoSize = true; | |
| 638 | + this.label20.Location = new System.Drawing.Point(573, 131); | |
| 639 | + this.label20.Name = "label20"; | |
| 640 | + this.label20.Size = new System.Drawing.Size(51, 12); | |
| 641 | + this.label20.TabIndex = 70; | |
| 642 | + this.label20.Text = "AutoLog"; | |
| 643 | + // | |
| 644 | + // toggleSwitch_Log | |
| 645 | + // | |
| 646 | + this.toggleSwitch_Log.EditValue = true; | |
| 647 | + this.toggleSwitch_Log.Location = new System.Drawing.Point(575, 146); | |
| 648 | + this.toggleSwitch_Log.Name = "toggleSwitch_Log"; | |
| 649 | + this.toggleSwitch_Log.Properties.OffText = "Off"; | |
| 650 | + this.toggleSwitch_Log.Properties.OnText = "On"; | |
| 651 | + this.toggleSwitch_Log.Size = new System.Drawing.Size(105, 25); | |
| 652 | + this.toggleSwitch_Log.TabIndex = 69; | |
| 653 | + this.toggleSwitch_Log.Toggled += new System.EventHandler(this.toggleSwitch_Log_Toggled); | |
| 654 | + // | |
| 655 | + // timer_Log | |
| 656 | + // | |
| 657 | + this.timer_Log.Enabled = true; | |
| 658 | + this.timer_Log.Interval = 5000; | |
| 659 | + this.timer_Log.Tick += new System.EventHandler(this.timer_Log_Tick); | |
| 660 | + // | |
| 661 | + // textBox1 | |
| 662 | + // | |
| 663 | + this.textBox1.Location = new System.Drawing.Point(789, 12); | |
| 664 | + this.textBox1.Name = "textBox1"; | |
| 665 | + this.textBox1.Size = new System.Drawing.Size(73, 21); | |
| 666 | + this.textBox1.TabIndex = 72; | |
| 667 | + this.textBox1.Visible = false; | |
| 668 | + // | |
| 669 | + // label21 | |
| 670 | + // | |
| 671 | + this.label21.AutoSize = true; | |
| 672 | + this.label21.Location = new System.Drawing.Point(719, 17); | |
| 673 | + this.label21.Name = "label21"; | |
| 674 | + this.label21.Size = new System.Drawing.Size(64, 12); | |
| 675 | + this.label21.TabIndex = 71; | |
| 676 | + this.label21.Text = "MACH_CD"; | |
| 677 | + this.label21.Visible = false; | |
| 678 | + // | |
| 679 | + // simpleButton8 | |
| 680 | + // | |
| 681 | + this.simpleButton8.Location = new System.Drawing.Point(789, 39); | |
| 682 | + this.simpleButton8.Name = "simpleButton8"; | |
| 683 | + this.simpleButton8.Size = new System.Drawing.Size(73, 30); | |
| 684 | + this.simpleButton8.TabIndex = 73; | |
| 685 | + this.simpleButton8.Text = "CHECK"; | |
| 686 | + this.simpleButton8.Visible = false; | |
| 687 | + this.simpleButton8.Click += new System.EventHandler(this.simpleButton8_Click_1); | |
| 688 | + // | |
| 689 | + // FormModbus | |
| 690 | + // | |
| 691 | + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; | |
| 692 | + this.ClientSize = new System.Drawing.Size(932, 450); | |
| 693 | + this.Controls.Add(this.simpleButton8); | |
| 694 | + this.Controls.Add(this.textBox1); | |
| 695 | + this.Controls.Add(this.label21); | |
| 696 | + this.Controls.Add(this.label20); | |
| 697 | + this.Controls.Add(this.toggleSwitch_Log); | |
| 698 | + this.Controls.Add(this.panel_DBConnect); | |
| 699 | + this.Controls.Add(this.simpleButton_All); | |
| 700 | + this.Controls.Add(this.textBox_LENGTH_2_2); | |
| 701 | + this.Controls.Add(this.label11); | |
| 702 | + this.Controls.Add(this.textBox_Addr_2_2); | |
| 703 | + this.Controls.Add(this.label12); | |
| 704 | + this.Controls.Add(this.simpleButton_InputRegister_2_2); | |
| 705 | + this.Controls.Add(this.textBox_LENGTH_6); | |
| 706 | + this.Controls.Add(this.label17); | |
| 707 | + this.Controls.Add(this.textBox_Addr_6); | |
| 708 | + this.Controls.Add(this.label18); | |
| 709 | + this.Controls.Add(this.simpleButton_InputRegister_6); | |
| 710 | + this.Controls.Add(this.textBox_LENGTH_5); | |
| 711 | + this.Controls.Add(this.label13); | |
| 712 | + this.Controls.Add(this.textBox_Addr_5); | |
| 713 | + this.Controls.Add(this.label14); | |
| 714 | + this.Controls.Add(this.simpleButton_InputRegister_5); | |
| 715 | + this.Controls.Add(this.textBox_LENGTH_4); | |
| 716 | + this.Controls.Add(this.label15); | |
| 717 | + this.Controls.Add(this.textBox_Addr_4); | |
| 718 | + this.Controls.Add(this.label16); | |
| 719 | + this.Controls.Add(this.simpleButton_InputRegister_4); | |
| 720 | + this.Controls.Add(this.textBox_LENGTH_3); | |
| 721 | + this.Controls.Add(this.label9); | |
| 722 | + this.Controls.Add(this.textBox_Addr_3); | |
| 723 | + this.Controls.Add(this.label10); | |
| 724 | + this.Controls.Add(this.simpleButton_InputRegister_3); | |
| 725 | + this.Controls.Add(this.textBox_LENGTH_2); | |
| 726 | + this.Controls.Add(this.label7); | |
| 727 | + this.Controls.Add(this.textBox_Addr_2); | |
| 728 | + this.Controls.Add(this.label8); | |
| 729 | + this.Controls.Add(this.simpleButton_InputRegister_2); | |
| 730 | + this.Controls.Add(this.textBox_LENGTH_1); | |
| 731 | + this.Controls.Add(this.label5); | |
| 732 | + this.Controls.Add(this.textBox_Addr_1); | |
| 733 | + this.Controls.Add(this.label6); | |
| 734 | + this.Controls.Add(this.simpleButton_InputRegister_1); | |
| 735 | + this.Controls.Add(this.simpleButton7); | |
| 736 | + this.Controls.Add(this.textBox_ADDR); | |
| 737 | + this.Controls.Add(this.label4); | |
| 738 | + this.Controls.Add(this.textBox_FUNC); | |
| 739 | + this.Controls.Add(this.label3); | |
| 740 | + this.Controls.Add(this.textBox_DEV_ID); | |
| 741 | + this.Controls.Add(this.label2); | |
| 742 | + this.Controls.Add(this.simpleButton6); | |
| 743 | + this.Controls.Add(this.simpleButton5); | |
| 744 | + this.Controls.Add(this.label1); | |
| 745 | + this.Controls.Add(this.toggleSwitch_Auto); | |
| 746 | + this.Controls.Add(this.simpleButton4); | |
| 747 | + this.Controls.Add(this.simpleButton3); | |
| 748 | + this.Controls.Add(this.simpleButton1); | |
| 749 | + this.Controls.Add(this.simpleButton2); | |
| 750 | + this.Controls.Add(this.textBox_State); | |
| 751 | + this.Name = "FormModbus"; | |
| 752 | + this.Text = "SignusSensorUploader"; | |
| 753 | + this.WindowState = System.Windows.Forms.FormWindowState.Minimized; | |
| 754 | + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); | |
| 755 | + this.Load += new System.EventHandler(this.FormModbus_Load); | |
| 756 | + ((System.ComponentModel.ISupportInitialize)(this.toggleSwitch_Auto.Properties)).EndInit(); | |
| 757 | + this.panel_DBConnect.ResumeLayout(false); | |
| 758 | + this.panel_DBConnect.PerformLayout(); | |
| 759 | + ((System.ComponentModel.ISupportInitialize)(this.toggleSwitch_Log.Properties)).EndInit(); | |
| 760 | + this.ResumeLayout(false); | |
| 761 | + this.PerformLayout(); | |
| 762 | + | |
| 763 | + } | |
| 764 | + | |
| 765 | + #endregion | |
| 766 | + private System.Windows.Forms.TextBox textBox_State; | |
| 767 | + private System.Windows.Forms.Timer timer_Connect; | |
| 768 | + private DevExpress.XtraEditors.SimpleButton simpleButton2; | |
| 769 | + private DevExpress.XtraEditors.SimpleButton simpleButton1; | |
| 770 | + private DevExpress.XtraEditors.SimpleButton simpleButton3; | |
| 771 | + private DevExpress.XtraEditors.SimpleButton simpleButton4; | |
| 772 | + private System.Windows.Forms.Timer timer_AutoInput; | |
| 773 | + private DevExpress.XtraEditors.ToggleSwitch toggleSwitch_Auto; | |
| 774 | + private System.Windows.Forms.Label label1; | |
| 775 | + private DevExpress.XtraEditors.SimpleButton simpleButton5; | |
| 776 | + private DevExpress.XtraEditors.SimpleButton simpleButton6; | |
| 777 | + private System.Windows.Forms.Label label2; | |
| 778 | + private System.Windows.Forms.TextBox textBox_DEV_ID; | |
| 779 | + private System.Windows.Forms.TextBox textBox_FUNC; | |
| 780 | + private System.Windows.Forms.Label label3; | |
| 781 | + private System.Windows.Forms.TextBox textBox_ADDR; | |
| 782 | + private System.Windows.Forms.Label label4; | |
| 783 | + private DevExpress.XtraEditors.SimpleButton simpleButton7; | |
| 784 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_1; | |
| 785 | + private System.Windows.Forms.TextBox textBox_LENGTH_1; | |
| 786 | + private System.Windows.Forms.Label label5; | |
| 787 | + private System.Windows.Forms.TextBox textBox_Addr_1; | |
| 788 | + private System.Windows.Forms.Label label6; | |
| 789 | + private System.Windows.Forms.TextBox textBox_LENGTH_2; | |
| 790 | + private System.Windows.Forms.Label label7; | |
| 791 | + private System.Windows.Forms.TextBox textBox_Addr_2; | |
| 792 | + private System.Windows.Forms.Label label8; | |
| 793 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_2; | |
| 794 | + private System.Windows.Forms.TextBox textBox_LENGTH_3; | |
| 795 | + private System.Windows.Forms.Label label9; | |
| 796 | + private System.Windows.Forms.TextBox textBox_Addr_3; | |
| 797 | + private System.Windows.Forms.Label label10; | |
| 798 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_3; | |
| 799 | + private System.Windows.Forms.TextBox textBox_LENGTH_5; | |
| 800 | + private System.Windows.Forms.Label label13; | |
| 801 | + private System.Windows.Forms.TextBox textBox_Addr_5; | |
| 802 | + private System.Windows.Forms.Label label14; | |
| 803 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_5; | |
| 804 | + private System.Windows.Forms.TextBox textBox_LENGTH_4; | |
| 805 | + private System.Windows.Forms.Label label15; | |
| 806 | + private System.Windows.Forms.TextBox textBox_Addr_4; | |
| 807 | + private System.Windows.Forms.Label label16; | |
| 808 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_4; | |
| 809 | + private System.Windows.Forms.TextBox textBox_LENGTH_6; | |
| 810 | + private System.Windows.Forms.Label label17; | |
| 811 | + private System.Windows.Forms.TextBox textBox_Addr_6; | |
| 812 | + private System.Windows.Forms.Label label18; | |
| 813 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_6; | |
| 814 | + private System.Windows.Forms.TextBox textBox_LENGTH_2_2; | |
| 815 | + private System.Windows.Forms.Label label11; | |
| 816 | + private System.Windows.Forms.TextBox textBox_Addr_2_2; | |
| 817 | + private System.Windows.Forms.Label label12; | |
| 818 | + private DevExpress.XtraEditors.SimpleButton simpleButton_InputRegister_2_2; | |
| 819 | + private DevExpress.XtraEditors.SimpleButton simpleButton_All; | |
| 820 | + private System.Windows.Forms.Timer timer_DBInsert; | |
| 821 | + private System.Windows.Forms.Panel panel_DBConnect; | |
| 822 | + private System.Windows.Forms.Label label19; | |
| 823 | + private System.Windows.Forms.Label label20; | |
| 824 | + private DevExpress.XtraEditors.ToggleSwitch toggleSwitch_Log; | |
| 825 | + private System.Windows.Forms.Timer timer_Log; | |
| 826 | + private System.Windows.Forms.TextBox textBox1; | |
| 827 | + private System.Windows.Forms.Label label21; | |
| 828 | + private DevExpress.XtraEditors.SimpleButton simpleButton8; | |
| 829 | + } | |
| 830 | +} | |
| 831 | + |
+++ ModbusTest/FormModbus.cs
... | ... | @@ -0,0 +1,1150 @@ |
| 1 | +using EasyModbus; | |
| 2 | +using Modbus.Device; | |
| 3 | +using System; | |
| 4 | +using System.Collections.Generic; | |
| 5 | +using System.ComponentModel; | |
| 6 | +using System.Data; | |
| 7 | +using System.Diagnostics; | |
| 8 | +using System.Drawing; | |
| 9 | +using System.Linq; | |
| 10 | +using System.Net.Sockets; | |
| 11 | +using System.Text; | |
| 12 | +using System.Threading; | |
| 13 | +using System.Threading.Tasks; | |
| 14 | +using System.Windows.Forms; | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | +namespace KHModbus | |
| 20 | +{ | |
| 21 | + public partial class FormModbus : Form | |
| 22 | + { | |
| 23 | + string mipAddr = "192.168.1.200"; | |
| 24 | + //string mipAddr = "127.0.0.1"; | |
| 25 | + int mPortNumber = 502; | |
| 26 | + | |
| 27 | + ModbusClient mModbusClient; | |
| 28 | + List<string[,]> m_Data = new List<string[,]>(); | |
| 29 | + public FormModbus() | |
| 30 | + { | |
| 31 | + InitializeComponent(); | |
| 32 | + mModbusClient = new ModbusClient(mipAddr, mPortNumber); //Ip-Address and Port of Modbus-TCP-Server | |
| 33 | + //timer_Connect.Enabled = true; | |
| 34 | + | |
| 35 | + SerialConnectionSingleton.Instance().InitialModBus(); | |
| 36 | + | |
| 37 | + SerialConnectionSingleton.Instance().PortName = "COM1"; | |
| 38 | + SerialConnectionSingleton.Instance().BaudRate = 9600; | |
| 39 | + SerialConnectionSingleton.Instance().Parity = System.IO.Ports.Parity.None; | |
| 40 | + SerialConnectionSingleton.Instance().StopBits = System.IO.Ports.StopBits.One; | |
| 41 | + SerialConnectionSingleton.Instance().DataBits = 8; | |
| 42 | + SerialConnectionSingleton.Instance().SlaveNo = 1; | |
| 43 | + } | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + public void KHModbus2() | |
| 50 | + { | |
| 51 | + //client로 연결하는 부분 | |
| 52 | + ModbusClient modbusClient = new ModbusClient(mipAddr, mPortNumber); //Ip-Address and Port of Modbus-TCP-Server | |
| 53 | + modbusClient.Connect(); //Connect to Server | |
| 54 | + modbusClient.WriteMultipleCoils(0, new bool[] { true, true, true, true, true, true, true, true, true, true }); //Write Coils starting with Address 5 | |
| 55 | + bool[] readCoils = modbusClient.ReadCoils(9, 10); //Read 10 Coils from Server, starting with address 10 | |
| 56 | + int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(0, 10); //Read 10 Holding Registers from Server, starting with Address 1 | |
| 57 | + | |
| 58 | + // Console Output | |
| 59 | + //for (int i = 0; i < readCoils.Length; i++) | |
| 60 | + // textBox1.Text += "Value of Coil " + (9 + i + 1) + " " + readCoils[i].ToString() +"\r\n"; | |
| 61 | + | |
| 62 | + //for (int i = 0; i < readHoldingRegisters.Length; i++) | |
| 63 | + // textBox1.Text += "Value of HoldingRegister " + (i + 1) + " " + readHoldingRegisters[i].ToString() + "\r\n"; | |
| 64 | + modbusClient.Disconnect(); //Disconnect from Server | |
| 65 | + //Console.ReadKey(true); | |
| 66 | + } | |
| 67 | + | |
| 68 | + | |
| 69 | + public bool Connect() | |
| 70 | + { | |
| 71 | + try | |
| 72 | + { | |
| 73 | + | |
| 74 | + if (!mModbusClient.Connected) | |
| 75 | + mModbusClient.Connect(); | |
| 76 | + | |
| 77 | + if (mModbusClient.Connected) | |
| 78 | + { | |
| 79 | + textBox_State.Text += "Connected\r\n"; | |
| 80 | + return true; | |
| 81 | + }else | |
| 82 | + { | |
| 83 | + return false; | |
| 84 | + } | |
| 85 | + } | |
| 86 | + catch(Exception ex) | |
| 87 | + { | |
| 88 | + textBox_State.Text += "PLC Connect Error : "+ ex.Message+ "\r\n"; | |
| 89 | + return false; | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + public bool[] DataReadCoils(int Addr, int Size) | |
| 94 | + { | |
| 95 | + if (mModbusClient.Connected) | |
| 96 | + { | |
| 97 | + bool[] read = mModbusClient.ReadCoils(Addr, Size); //Read 10 Holding Registers from Server, starting with Address 1 | |
| 98 | + return read; | |
| 99 | + } | |
| 100 | + else | |
| 101 | + { | |
| 102 | + return null; | |
| 103 | + } | |
| 104 | + } | |
| 105 | + public int[] DataReadHolding(int Addr, int Size) | |
| 106 | + { | |
| 107 | + try | |
| 108 | + { | |
| 109 | + if (mModbusClient.Connected) | |
| 110 | + { | |
| 111 | + int[] readHoldingRegisters = mModbusClient.ReadHoldingRegisters(Addr, Size); //Read 10 Holding Registers from Server, starting with Address 1 | |
| 112 | + return readHoldingRegisters; | |
| 113 | + } | |
| 114 | + else | |
| 115 | + { | |
| 116 | + return null; | |
| 117 | + } | |
| 118 | + }catch(Exception ex) | |
| 119 | + { | |
| 120 | + textBox_State.Text += "DataReading Error : " + ex.Message + "\r\n"; | |
| 121 | + mModbusClient.Disconnect(); | |
| 122 | + return null; | |
| 123 | + } | |
| 124 | + } | |
| 125 | + public int[] DataReadInput(int Addr, int Size) | |
| 126 | + { | |
| 127 | + try | |
| 128 | + { | |
| 129 | + if (mModbusClient.Connected) | |
| 130 | + { | |
| 131 | + int[] readHoldingRegisters = mModbusClient.ReadInputRegisters(Addr, Size); //Read 10 Holding Registers from Server, starting with Address 1 | |
| 132 | + return readHoldingRegisters; | |
| 133 | + } | |
| 134 | + else | |
| 135 | + { | |
| 136 | + return null; | |
| 137 | + } | |
| 138 | + } | |
| 139 | + catch (Exception ex) | |
| 140 | + { | |
| 141 | + textBox_State.Text += "DataReading Error : " + ex.Message + "\r\n"; | |
| 142 | + mModbusClient.Disconnect(); | |
| 143 | + return null; | |
| 144 | + } | |
| 145 | + } | |
| 146 | + | |
| 147 | + | |
| 148 | + public async void modbusReadWrite() | |
| 149 | + { | |
| 150 | + TcpClient tcpc = new TcpClient(); | |
| 151 | + tcpc.BeginConnect("127.0.0.1", 502, null, null); | |
| 152 | + ModbusIpMaster master = ModbusIpMaster.CreateIp(tcpc); | |
| 153 | + try | |
| 154 | + { | |
| 155 | + | |
| 156 | + while(true) | |
| 157 | + { | |
| 158 | + bool[] coil = master.ReadCoils(0, 1); | |
| 159 | + | |
| 160 | + textBox_State.Text += coil[0].ToString(); | |
| 161 | + | |
| 162 | + ushort[] holding = master.ReadHoldingRegisters(0, 1); | |
| 163 | + //textBox2.Text = holding[0].ToString(); | |
| 164 | + | |
| 165 | + | |
| 166 | + ushort[] input = master.ReadHoldingRegisters(0, 9); | |
| 167 | + //textBox2.Text = input[0].ToString(); | |
| 168 | + | |
| 169 | + await Task.Delay(500); | |
| 170 | + } | |
| 171 | + | |
| 172 | + }catch (Exception ex) | |
| 173 | + { | |
| 174 | + | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + private void simpleButton1_Click(object sender, EventArgs e) | |
| 179 | + { | |
| 180 | + KHModbus2(); | |
| 181 | + } | |
| 182 | + | |
| 183 | + private void Form1_FormClosing(object sender, FormClosingEventArgs e) | |
| 184 | + { | |
| 185 | + if (mModbusClient.Connected) | |
| 186 | + { | |
| 187 | + mModbusClient.Disconnect(); | |
| 188 | + } | |
| 189 | + else | |
| 190 | + { | |
| 191 | + } | |
| 192 | + } | |
| 193 | + | |
| 194 | + private void timer_Connect_Tick(object sender, EventArgs e) | |
| 195 | + { | |
| 196 | + if(mModbusClient != null) | |
| 197 | + { | |
| 198 | + if(mModbusClient.Connected == false) | |
| 199 | + { | |
| 200 | + Connect(); | |
| 201 | + } | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + private void simpleButton2_Click(object sender, EventArgs e) | |
| 206 | + { | |
| 207 | + int[] Data = DataReadInput(400, 47); | |
| 208 | + if (Data == null) return; | |
| 209 | + | |
| 210 | + textBox_State.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+ "[400,47]: "; | |
| 211 | + foreach (int i in Data) | |
| 212 | + { | |
| 213 | + textBox_State.Text += i.ToString() + " "; | |
| 214 | + | |
| 215 | + } | |
| 216 | + textBox_State.Text += "\r\n"; | |
| 217 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 218 | + textBox_State.ScrollToCaret(); | |
| 219 | + | |
| 220 | + } | |
| 221 | + | |
| 222 | + private void simpleButton1_Click_1(object sender, EventArgs e) | |
| 223 | + { | |
| 224 | + DBConnectionSingleton.Instance().GetSqlData("select * from T_STD_COMPANY"); | |
| 225 | + } | |
| 226 | + | |
| 227 | + private void simpleButton3_Click(object sender, EventArgs e) | |
| 228 | + { | |
| 229 | + if(DBConnectionSingleton.Instance().SetCommand("HTSaveRealData", | |
| 230 | + DBConnectionSingleton.Instance().getParams("COMP_CD", "0001"), | |
| 231 | + DBConnectionSingleton.Instance().getParams("MACH_CD", "M0001"), | |
| 232 | + DBConnectionSingleton.Instance().getParams("REAL_DATA", "1"))) | |
| 233 | + { | |
| 234 | + textBox_State.Text += "DBInsert Complete\r\n"; | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + private void simpleButton4_Click(object sender, EventArgs e) | |
| 239 | + { | |
| 240 | + //Stopwatch sw = new Stopwatch(); | |
| 241 | + | |
| 242 | + //sw.Reset(); | |
| 243 | + //sw.Start(); | |
| 244 | + | |
| 245 | + //DB 설비정보내에서 온도계 정보를 가져옵니다.[온도계는 CODE정보로 E03으로 저장되어있다] | |
| 246 | + DataTable dt = DBConnectionSingleton.Instance().GetSqlData("SELECT [COMP_CD],[MACH_CD],[MACH_NO],[MACH_NM] FROM [dbo].[T_STD_MACH] m where m.COMP_CD = '0001' and m.MACH_TYPE = '03' order by MACH_NO asc"); | |
| 247 | + | |
| 248 | + //sw.Stop(); | |
| 249 | + //textBox_State.Text += "Timer Check 1 : "+sw.ElapsedMilliseconds.ToString() + "\r\n"; | |
| 250 | + //sw.Start(); | |
| 251 | + | |
| 252 | + //ReadHolding데이터 0자리에서 10개를 가져온다 | |
| 253 | + int[] Data = DataReadHolding(0, 10); | |
| 254 | + | |
| 255 | + //데이터를 가져오지 못하면 도루묵 | |
| 256 | + if (Data == null) return; | |
| 257 | + | |
| 258 | + //sw.Stop(); | |
| 259 | + //textBox_State.Text += "Timer Check 2 : " + sw.ElapsedMilliseconds.ToString() + "\r\n"; | |
| 260 | + //sw.Start(); | |
| 261 | + | |
| 262 | + int Number= 1; | |
| 263 | + string input_Mach_CD = ""; | |
| 264 | + string input_RealData = ""; | |
| 265 | + | |
| 266 | + //설비정보에서 번호(1~10)와 가져온 정보 0~9)를 매칭하여 설비코드와 데이터를 나열한다. | |
| 267 | + foreach (int i in Data) | |
| 268 | + { | |
| 269 | + for(int j = 0; j < dt.Rows.Count;j++) | |
| 270 | + { | |
| 271 | + if(dt.Rows[j]["MACH_NO"].ToString() == Number.ToString()) | |
| 272 | + { | |
| 273 | + input_Mach_CD += dt.Rows[j]["MACH_CD"].ToString() + ","; | |
| 274 | + input_RealData += Data[i].ToString() + ","; | |
| 275 | + } | |
| 276 | + } | |
| 277 | + Number++; | |
| 278 | + } | |
| 279 | + | |
| 280 | + if(input_Mach_CD.LastIndexOf(',') == input_Mach_CD.Length-1) | |
| 281 | + { | |
| 282 | + input_Mach_CD = input_Mach_CD.Substring(0, input_Mach_CD.Length - 1); | |
| 283 | + } | |
| 284 | + | |
| 285 | + if (input_RealData.LastIndexOf(',') == input_RealData.Length-1) | |
| 286 | + { | |
| 287 | + input_RealData = input_RealData.Substring(0, input_RealData.Length - 1); | |
| 288 | + } | |
| 289 | + | |
| 290 | + //sw.Stop(); | |
| 291 | + //textBox_State.Text += "Timer Check 3 : " + sw.ElapsedMilliseconds.ToString() + "\r\n"; | |
| 292 | + //sw.Start(); | |
| 293 | + | |
| 294 | + if (DBConnectionSingleton.Instance().SetCommand("HTSaveRealDataAll", | |
| 295 | + DBConnectionSingleton.Instance().getParams("COMP_CD", "0001"), | |
| 296 | + DBConnectionSingleton.Instance().getParams("MACH_CD", input_Mach_CD), | |
| 297 | + DBConnectionSingleton.Instance().getParams("REAL_DATA", input_RealData))) | |
| 298 | + { | |
| 299 | + textBox_State.Text += "DBInsert Complete : " + input_Mach_CD + "\r\n"; | |
| 300 | + textBox_State.Text += "DBInsert Complete : " + input_RealData + "\r\n"; | |
| 301 | + } | |
| 302 | + | |
| 303 | + //sw.Stop(); | |
| 304 | + | |
| 305 | + //textBox_State.Text += "Timer Check 4 : " + sw.ElapsedMilliseconds.ToString() + "\r\n"; | |
| 306 | + | |
| 307 | + | |
| 308 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 309 | + textBox_State.ScrollToCaret(); | |
| 310 | + | |
| 311 | + } | |
| 312 | + | |
| 313 | + public int RunState = 0; | |
| 314 | + List<string[,]> lst = new List<string[,]>(); | |
| 315 | + string[,] array; | |
| 316 | + private void timer_AutoInput_Tick(object sender, EventArgs e) | |
| 317 | + { | |
| 318 | + switch(RunState) | |
| 319 | + { | |
| 320 | + case 0: | |
| 321 | + textBox_State.Text = ""; | |
| 322 | + lst = new List<string[,]>(); | |
| 323 | + break; | |
| 324 | + case 1: | |
| 325 | + array = DataReadInputToInt64(textBox_Addr_1.Text, textBox_LENGTH_1.Text); | |
| 326 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 327 | + break; | |
| 328 | + case 2: | |
| 329 | + array = DataReadInputToInt64(textBox_Addr_2.Text, textBox_LENGTH_2.Text); | |
| 330 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 331 | + break; | |
| 332 | + case 3: | |
| 333 | + array = DataReadInput(textBox_Addr_2_2.Text, textBox_LENGTH_2_2.Text); | |
| 334 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 335 | + break; | |
| 336 | + case 4: | |
| 337 | + array = DataReadInput(textBox_Addr_3.Text, textBox_LENGTH_3.Text); | |
| 338 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 339 | + break; | |
| 340 | + case 5: | |
| 341 | + array = DataReadInput(textBox_Addr_4.Text, textBox_LENGTH_4.Text); | |
| 342 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 343 | + break; | |
| 344 | + case 6: | |
| 345 | + array = DataReadInputToInt64(textBox_Addr_5.Text, textBox_LENGTH_5.Text); | |
| 346 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 347 | + break; | |
| 348 | + case 7: | |
| 349 | + array = DataReadInputToBit(textBox_Addr_6.Text, textBox_LENGTH_6.Text); | |
| 350 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 351 | + break; | |
| 352 | + case 8: | |
| 353 | + DB_Input(lst); | |
| 354 | + break; | |
| 355 | + } | |
| 356 | + RunState++; | |
| 357 | + | |
| 358 | + if(RunState >=10) | |
| 359 | + { | |
| 360 | + RunState = 0; | |
| 361 | + } | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + //textBox_State.Text = ""; | |
| 367 | + //List<string[,]> lst = new List<string[,]>(); | |
| 368 | + //string[,] array; | |
| 369 | + | |
| 370 | + | |
| 371 | + //array = DataReadInputToInt64(textBox_Addr_1.Text, textBox_LENGTH_1.Text); | |
| 372 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 373 | + //array = DataReadInputToInt64(textBox_Addr_2.Text, textBox_LENGTH_2.Text); | |
| 374 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 375 | + //array = DataReadInput(textBox_Addr_2_2.Text, textBox_LENGTH_2_2.Text); | |
| 376 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 377 | + //array = DataReadInput(textBox_Addr_3.Text, textBox_LENGTH_3.Text); | |
| 378 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 379 | + //array = DataReadInput(textBox_Addr_4.Text, textBox_LENGTH_4.Text); | |
| 380 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 381 | + //array = DataReadInputToInt64(textBox_Addr_5.Text, textBox_LENGTH_5.Text); | |
| 382 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 383 | + //array = DataReadInputToBit(textBox_Addr_6.Text, textBox_LENGTH_6.Text); | |
| 384 | + //if (array != null) if (array.Length > 1) lst.Add(array); | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + //DB_Input(lst); | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + //if (SerialConnectionSingleton.Instance().IsOpen()) | |
| 393 | + //{ | |
| 394 | + // try | |
| 395 | + // { | |
| 396 | + | |
| 397 | + // array = SerialConnectionSingleton.Instance().DataReadHolding("220", "1"); | |
| 398 | + // if (array != null) | |
| 399 | + // { | |
| 400 | + // if (array.Length > 1) | |
| 401 | + // { | |
| 402 | + // lst.Add(array); | |
| 403 | + // for (int i = 0; i < array.Length / 2; i++) | |
| 404 | + // { | |
| 405 | + // textBox_State.Text += "[" + array[i, 0] + ":" + array[i, 1] + "]"; | |
| 406 | + // } | |
| 407 | + | |
| 408 | + // textBox_State.Text += "\r\n"; | |
| 409 | + // } | |
| 410 | + // } | |
| 411 | + | |
| 412 | + | |
| 413 | + // array = SerialConnectionSingleton.Instance().DataReadHolding("231", "1"); | |
| 414 | + // if (array != null) | |
| 415 | + // { | |
| 416 | + // if (array.Length > 1) | |
| 417 | + // { | |
| 418 | + // lst.Add(array); | |
| 419 | + // for (int i = 0; i < array.Length / 2; i++) | |
| 420 | + // { | |
| 421 | + // textBox_State.Text += "[" + array[i, 0] + ":" + array[i, 1] + "]"; | |
| 422 | + // } | |
| 423 | + | |
| 424 | + // textBox_State.Text += "\r\n"; | |
| 425 | + // } | |
| 426 | + // } | |
| 427 | + | |
| 428 | + | |
| 429 | + // array = SerialConnectionSingleton.Instance().DataReadHolding("242", "1"); | |
| 430 | + // if (array != null) | |
| 431 | + // { | |
| 432 | + // if (array.Length > 1) | |
| 433 | + // { | |
| 434 | + // lst.Add(array); | |
| 435 | + // for (int i = 0; i < array.Length / 2; i++) | |
| 436 | + // { | |
| 437 | + // textBox_State.Text += "[" + array[i, 0] + ":" + array[i, 1] + "]"; | |
| 438 | + // } | |
| 439 | + | |
| 440 | + // textBox_State.Text += "\r\n"; | |
| 441 | + // } | |
| 442 | + // } | |
| 443 | + | |
| 444 | + | |
| 445 | + // array = SerialConnectionSingleton.Instance().DataReadHolding("253", "1"); | |
| 446 | + // if (array != null) | |
| 447 | + // { | |
| 448 | + // if (array.Length > 1) | |
| 449 | + // { | |
| 450 | + // lst.Add(array); | |
| 451 | + // for (int i = 0; i < array.Length / 2; i++) | |
| 452 | + // { | |
| 453 | + // textBox_State.Text += "[" + array[i, 0] + ":" + array[i, 1] + "]"; | |
| 454 | + // } | |
| 455 | + | |
| 456 | + // textBox_State.Text += "\r\n"; | |
| 457 | + // } | |
| 458 | + // } | |
| 459 | + | |
| 460 | + | |
| 461 | + // array = SerialConnectionSingleton.Instance().DataReadHolding("264", "1"); | |
| 462 | + // if (array != null) | |
| 463 | + // { | |
| 464 | + // if (array.Length > 1) | |
| 465 | + // { | |
| 466 | + // lst.Add(array); | |
| 467 | + // for (int i = 0; i < array.Length / 2; i++) | |
| 468 | + // { | |
| 469 | + // textBox_State.Text += "[" + array[i, 0] + ":" + array[i, 1] + "]"; | |
| 470 | + // } | |
| 471 | + | |
| 472 | + // textBox_State.Text += "\r\n"; | |
| 473 | + // } | |
| 474 | + // } | |
| 475 | + | |
| 476 | + | |
| 477 | + // array = SerialConnectionSingleton.Instance().DataReadHolding("275", "1"); | |
| 478 | + // if (array != null) | |
| 479 | + // { | |
| 480 | + // if (array.Length > 1) | |
| 481 | + // { | |
| 482 | + // lst.Add(array); | |
| 483 | + // for (int i = 0; i < array.Length / 2; i++) | |
| 484 | + // { | |
| 485 | + // textBox_State.Text += "[" + array[i, 0] + ":" + array[i, 1] + "]"; | |
| 486 | + // } | |
| 487 | + | |
| 488 | + // textBox_State.Text += "\r\n"; | |
| 489 | + // } | |
| 490 | + // } | |
| 491 | + | |
| 492 | + | |
| 493 | + // DB_Input(lst); | |
| 494 | + // } | |
| 495 | + // catch (Exception ex) | |
| 496 | + // { | |
| 497 | + // textBox_State.Text += "시리얼통신 연결중..." + "\r\n"; | |
| 498 | + // } | |
| 499 | + //} | |
| 500 | + } | |
| 501 | + | |
| 502 | + private void toggleSwitch_Auto_Toggled(object sender, EventArgs e) | |
| 503 | + { | |
| 504 | + timer_Connect.Enabled = toggleSwitch_Auto.IsOn; | |
| 505 | + timer_AutoInput.Enabled = toggleSwitch_Auto.IsOn; | |
| 506 | + timer_DBInsert.Enabled = toggleSwitch_Auto.IsOn; | |
| 507 | + } | |
| 508 | + | |
| 509 | + private void simpleButton5_Click(object sender, EventArgs e) | |
| 510 | + { | |
| 511 | + if(SerialConnectionSingleton.Instance().IsOpen()) | |
| 512 | + { | |
| 513 | + //ushort resultBit = SerialConnectionSingleton.Instance().ReadWords_To_ushort(4, 0, 2); | |
| 514 | + //ushort resultBit2 = SerialConnectionSingleton.Instance().ReadWords_To_ushort(4, 1, 1); | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + //for(int i = 1000; i<=1010;i++) | |
| 519 | + //{ | |
| 520 | + // int resultBit = SerialConnectionSingleton.Instance().ReadWords_To_int(1, 4, (ushort)i, 2); | |
| 521 | + // textBox_State.Text += "Slave1_4_"+i+" : " + resultBit + "\r\n"; | |
| 522 | + | |
| 523 | + // textBox_State.Select(textBox_State.Text.Length, 0); | |
| 524 | + // textBox_State.ScrollToCaret(); | |
| 525 | + //} | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + //for (int i = 31000; i <= 31010; i++) | |
| 530 | + //{ | |
| 531 | + // int resultBit = SerialConnectionSingleton.Instance().ReadWords_To_int(1, 4, (ushort)i, 2); | |
| 532 | + // textBox_State.Text += "Slave1_4_" + i + " : " + resultBit + "\r\n"; | |
| 533 | + | |
| 534 | + // textBox_State.Select(textBox_State.Text.Length, 0); | |
| 535 | + // textBox_State.ScrollToCaret(); | |
| 536 | + //} | |
| 537 | + | |
| 538 | + | |
| 539 | + //for (int i = 1000; i <= 1010; i++) | |
| 540 | + //{ | |
| 541 | + // int resultBit = SerialConnectionSingleton.Instance().ReadWords_To_int(2, 4, (ushort)i, 2); | |
| 542 | + // textBox_State.Text += "Slave1_3_" + i + " : " + resultBit + "\r\n"; | |
| 543 | + | |
| 544 | + // textBox_State.Select(textBox_State.Text.Length, 0); | |
| 545 | + // textBox_State.ScrollToCaret(); | |
| 546 | + //} | |
| 547 | + | |
| 548 | + | |
| 549 | + int resultBit1 = SerialConnectionSingleton.Instance().ReadWords_To_int(2, 4, 1002, 2); | |
| 550 | + textBox_State.Text += "[SV]Slave2_4_" + 1002 + " : " + resultBit1 + "\r\n"; | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + int resultBit2 = SerialConnectionSingleton.Instance().ReadWords_To_int(2, 4, 1005, 2); | |
| 555 | + textBox_State.Text += "[PV]Slave2_4_" + 1005 + " : " + resultBit2 + "\r\n"; | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + //for (int i = 31000; i <= 31010; i++) | |
| 560 | + //{ | |
| 561 | + // int resultBit = SerialConnectionSingleton.Instance().ReadWords_To_int(1, 3, (ushort)i, 2); | |
| 562 | + // textBox_State.Text += "Slave1_3_" + i + " : " + resultBit + "\r\n"; | |
| 563 | + | |
| 564 | + // textBox_State.Select(textBox_State.Text.Length, 0); | |
| 565 | + // textBox_State.ScrollToCaret(); | |
| 566 | + //} | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + //int resultBit3 = SerialConnectionSingleton.Instance().ReadWords_To_int(1, 4, 1005, 2); | |
| 573 | + | |
| 574 | + //int resultBit4 = SerialConnectionSingleton.Instance().ReadWords_To_int(2, 4, 31004, 2); | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + //int resultBit3 = SerialConnectionSingleton.Instance().ReadWords_To_int(1, 4, 1005, 2); | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + //int resultBit4 = SerialConnectionSingleton.Instance().ReadWords_To_int(4, 0, 2); | |
| 591 | + | |
| 592 | + //textBox_State.Text += "ReadSerial1 : " + resultBit + "\r\n"; | |
| 593 | + //textBox_State.Text += "ReadSerial2 : " + resultBit2 + "\r\n"; | |
| 594 | + //textBox_State.Text += "Slave1_4_31004 : " + resultBit3 + "\r\n"; | |
| 595 | + //textBox_State.Text += "Slave2_4_31004 : " + resultBit4 + "\r\n"; | |
| 596 | + } | |
| 597 | + } | |
| 598 | + | |
| 599 | + private void simpleButton6_Click(object sender, EventArgs e) | |
| 600 | + { | |
| 601 | + if (SerialConnectionSingleton.Instance().IsOpen()) | |
| 602 | + { | |
| 603 | + try | |
| 604 | + { | |
| 605 | + int resultBit1 = SerialConnectionSingleton.Instance().ReadWords_To_int(Convert.ToByte(textBox_DEV_ID.Text), Convert.ToByte(textBox_FUNC.Text), Convert.ToUInt16(textBox_ADDR.Text), 2); | |
| 606 | + textBox_State.Text += "[4Byte]Slave"+ textBox_DEV_ID.Text + "_"+ textBox_FUNC.Text + "_" + textBox_ADDR.Text + " : " + resultBit1 + "\r\n"; | |
| 607 | + | |
| 608 | + | |
| 609 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 610 | + textBox_State.ScrollToCaret(); | |
| 611 | + }catch(Exception ex) | |
| 612 | + { | |
| 613 | + textBox_State.Text += ex.Message+"\r\n"; | |
| 614 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 615 | + textBox_State.ScrollToCaret(); | |
| 616 | + } | |
| 617 | + } | |
| 618 | + } | |
| 619 | + | |
| 620 | + private void simpleButton7_Click(object sender, EventArgs e) | |
| 621 | + { | |
| 622 | + if (SerialConnectionSingleton.Instance().IsOpen()) | |
| 623 | + { | |
| 624 | + try | |
| 625 | + { | |
| 626 | + ushort resultBit1 = SerialConnectionSingleton.Instance().ReadWords_To_ushort(Convert.ToByte(textBox_DEV_ID.Text), Convert.ToByte(textBox_FUNC.Text), Convert.ToUInt16(textBox_ADDR.Text), 1); | |
| 627 | + textBox_State.Text += "[2Byte]Slave" + textBox_DEV_ID.Text + "_" + textBox_FUNC.Text + "_" + textBox_ADDR.Text + " : " + resultBit1 + "\r\n"; | |
| 628 | + | |
| 629 | + | |
| 630 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 631 | + textBox_State.ScrollToCaret(); | |
| 632 | + } | |
| 633 | + catch (Exception ex) | |
| 634 | + { | |
| 635 | + textBox_State.Text += ex.Message + "\r\n"; | |
| 636 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 637 | + textBox_State.ScrollToCaret(); | |
| 638 | + } | |
| 639 | + } | |
| 640 | + } | |
| 641 | + | |
| 642 | + private void FormModbus_Load(object sender, EventArgs e) | |
| 643 | + { | |
| 644 | + | |
| 645 | + } | |
| 646 | + | |
| 647 | + | |
| 648 | + public string[,] DataReadHolding(string Addr, string Length) | |
| 649 | + { | |
| 650 | + | |
| 651 | + int[] Data = DataReadHolding(Convert.ToInt32(Addr), Convert.ToInt32(Length)); | |
| 652 | + if (Data == null) return null; | |
| 653 | + | |
| 654 | + | |
| 655 | + string[,] result = new string[Data.Length, 2]; | |
| 656 | + | |
| 657 | + textBox_State.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": "; | |
| 658 | + int aa = 0; | |
| 659 | + foreach (int i in Data) | |
| 660 | + { | |
| 661 | + textBox_State.Text += "[" + (Convert.ToInt32(Addr) + aa).ToString() + ":" + i.ToString() + "]."; | |
| 662 | + result[aa, 0] = (Convert.ToInt32(Addr) + aa).ToString(); | |
| 663 | + result[aa, 1] = i.ToString(); | |
| 664 | + aa++; | |
| 665 | + } | |
| 666 | + textBox_State.Text += "\r\n"; | |
| 667 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 668 | + textBox_State.ScrollToCaret(); | |
| 669 | + return result; | |
| 670 | + } | |
| 671 | + | |
| 672 | + | |
| 673 | + public string[,] DataReadInput(string Addr, string Length) | |
| 674 | + { | |
| 675 | + | |
| 676 | + int[] Data = DataReadInput(Convert.ToInt32(Addr), Convert.ToInt32(Length)); | |
| 677 | + if (Data == null) return null; | |
| 678 | + | |
| 679 | + | |
| 680 | + string[,] result = new string[Data.Length, 2]; | |
| 681 | + | |
| 682 | + textBox_State.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": "; | |
| 683 | + int aa = 0; | |
| 684 | + foreach (int i in Data) | |
| 685 | + { | |
| 686 | + textBox_State.Text += "[" + (Convert.ToInt32(Addr) + aa).ToString() + ":" + i.ToString() + "]."; | |
| 687 | + result[aa, 0] = (Convert.ToInt32(Addr) + aa).ToString(); | |
| 688 | + result[aa, 1] = i.ToString(); | |
| 689 | + aa++; | |
| 690 | + } | |
| 691 | + textBox_State.Text += "\r\n"; | |
| 692 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 693 | + textBox_State.ScrollToCaret(); | |
| 694 | + return result; | |
| 695 | + } | |
| 696 | + | |
| 697 | + public string[,] DataReadInputToBit(string Addr, string Length) | |
| 698 | + { | |
| 699 | + int[] Data = DataReadInput(Convert.ToInt32(Addr), Convert.ToInt32(Length)); | |
| 700 | + if (Data == null) return null; | |
| 701 | + | |
| 702 | + string[,] result = new string[Data.Length*32, 2]; | |
| 703 | + | |
| 704 | + | |
| 705 | + textBox_State.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": "; | |
| 706 | + int aa = 0; | |
| 707 | + string Result = ""; | |
| 708 | + for (int i = 0; i < Data.Length; i++) | |
| 709 | + { | |
| 710 | + byte[] a = BitConverter.GetBytes(Convert.ToInt32(Data[i])); | |
| 711 | + | |
| 712 | + | |
| 713 | + textBox_State.Text += "[" + (Convert.ToInt32(Addr) + i).ToString() + ":"; | |
| 714 | + for (int j = 0; j < a.Length; j++) | |
| 715 | + { | |
| 716 | + string s = Convert.ToString(a[j], 2).PadLeft(8, '0'); | |
| 717 | + char[] sa = s.ToCharArray(); | |
| 718 | + Array.Reverse(sa); | |
| 719 | + | |
| 720 | + for (int r = 0; r < sa.Length; r++) | |
| 721 | + { | |
| 722 | + result[((i * a.Length * 8) + (j * 8)) + r, 0] = (Convert.ToInt32(Addr) + i).ToString()+"."+((j*8)+r).ToString(); | |
| 723 | + result[((i * a.Length * 8) + (j * 8)) + r, 1] = sa[r].ToString(); | |
| 724 | + } | |
| 725 | + | |
| 726 | + textBox_State.Text += new string(sa); | |
| 727 | + Result += new string(sa); | |
| 728 | + | |
| 729 | + } | |
| 730 | + textBox_State.Text += "]."; | |
| 731 | + } | |
| 732 | + | |
| 733 | + | |
| 734 | + textBox_State.Text += "\r\n"; | |
| 735 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 736 | + textBox_State.ScrollToCaret(); | |
| 737 | + | |
| 738 | + return result; | |
| 739 | + } | |
| 740 | + | |
| 741 | + public void ByteToBit(byte b) | |
| 742 | + { | |
| 743 | + | |
| 744 | + | |
| 745 | + } | |
| 746 | + | |
| 747 | + public string[,] DataReadInputTouUint64(string Addr, string Length) | |
| 748 | + { | |
| 749 | + //Stopwatch sw = new Stopwatch(); | |
| 750 | + //sw.Start(); | |
| 751 | + int[] Data = DataReadInput(Convert.ToInt32(Addr), Convert.ToInt32(Length)); | |
| 752 | + if (Data == null) return null; | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + string[,] result = new string[Data.Length / 2 + ((Data.Length & 2) == 1 ? 1 : 0), 2]; | |
| 757 | + //sw.Stop(); | |
| 758 | + //textBox_State.Text += "[Time1: " + sw.ElapsedMilliseconds + "] \r\n"; | |
| 759 | + | |
| 760 | + //sw.Reset(); | |
| 761 | + //sw.Start(); | |
| 762 | + textBox_State.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": "; | |
| 763 | + int aa = 0; | |
| 764 | + for (int i = 0; i < Data.Length - 1; i++) | |
| 765 | + { | |
| 766 | + byte[] a = BitConverter.GetBytes(Convert.ToInt16(Data[i])); | |
| 767 | + byte[] b = null; | |
| 768 | + if (Data.Length > i + 1) | |
| 769 | + { | |
| 770 | + b = BitConverter.GetBytes(Convert.ToInt16(Data[i + 1])); | |
| 771 | + } | |
| 772 | + else | |
| 773 | + { | |
| 774 | + b = new byte[2] { 0, 0 }; | |
| 775 | + } | |
| 776 | + | |
| 777 | + byte[] c = new byte[4]; | |
| 778 | + | |
| 779 | + Array.Copy(a, 0, c, 0, a.Length); | |
| 780 | + Array.Copy(b, 0, c, a.Length, b.Length); | |
| 781 | + | |
| 782 | + | |
| 783 | + textBox_State.Text += "[" + (Convert.ToInt32(Addr) + i).ToString() + ":" + BitConverter.ToInt32(c, 0).ToString() + "]."; | |
| 784 | + | |
| 785 | + | |
| 786 | + result[aa, 0] = (Convert.ToInt32(Addr) + i).ToString(); | |
| 787 | + result[aa, 1] = BitConverter.ToUInt32(c, 0).ToString(); | |
| 788 | + | |
| 789 | + | |
| 790 | + aa++; | |
| 791 | + i++; | |
| 792 | + } | |
| 793 | + | |
| 794 | + foreach (int i in Data) | |
| 795 | + { | |
| 796 | + } | |
| 797 | + textBox_State.Text += "\r\n"; | |
| 798 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 799 | + textBox_State.ScrollToCaret(); | |
| 800 | + | |
| 801 | + //sw.Stop(); | |
| 802 | + //textBox_State.Text += "[Time2: " + sw.ElapsedMilliseconds + "] \r\n"; | |
| 803 | + return result; | |
| 804 | + } | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + public string[,] DataReadInputToInt64(string Addr, string Length) | |
| 809 | + { | |
| 810 | + //Stopwatch sw = new Stopwatch(); | |
| 811 | + //sw.Start(); | |
| 812 | + int[] Data = DataReadInput(Convert.ToInt32(Addr), Convert.ToInt32(Length)); | |
| 813 | + if (Data == null) return null; | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + string[,] result = new string[Data.Length/2+((Data.Length&2)==1?1:0), 2]; | |
| 818 | + //sw.Stop(); | |
| 819 | + //textBox_State.Text += "[Time1: " + sw.ElapsedMilliseconds + "] \r\n"; | |
| 820 | + | |
| 821 | + //sw.Reset(); | |
| 822 | + //sw.Start(); | |
| 823 | + textBox_State.Text += DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": "; | |
| 824 | + int aa = 0; | |
| 825 | + for(int i=0 ; i<Data.Length-1;i++) | |
| 826 | + { | |
| 827 | + byte[] a = BitConverter.GetBytes(Convert.ToInt16(Data[i])); | |
| 828 | + byte[] b = null; | |
| 829 | + if (Data.Length > i+1) | |
| 830 | + { | |
| 831 | + b = BitConverter.GetBytes(Convert.ToInt16(Data[i + 1])); | |
| 832 | + }else | |
| 833 | + { | |
| 834 | + b = new byte[2] {0,0}; | |
| 835 | + } | |
| 836 | + | |
| 837 | + byte[] c = new byte[4]; | |
| 838 | + | |
| 839 | + Array.Copy(a, 0, c, 0, a.Length); | |
| 840 | + Array.Copy(b, 0, c, a.Length, b.Length); | |
| 841 | + | |
| 842 | + | |
| 843 | + textBox_State.Text += "[" + (Convert.ToInt32(Addr) + i).ToString() + ":" + BitConverter.ToInt32(c,0).ToString() + "]."; | |
| 844 | + | |
| 845 | + | |
| 846 | + result[aa, 0] = (Convert.ToInt32(Addr) + i).ToString(); | |
| 847 | + result[aa, 1] = BitConverter.ToInt32(c, 0).ToString(); | |
| 848 | + | |
| 849 | + | |
| 850 | + aa++; | |
| 851 | + i++; | |
| 852 | + } | |
| 853 | + | |
| 854 | + foreach (int i in Data) | |
| 855 | + { | |
| 856 | + } | |
| 857 | + textBox_State.Text += "\r\n"; | |
| 858 | + textBox_State.Select(textBox_State.Text.Length, 0); | |
| 859 | + textBox_State.ScrollToCaret(); | |
| 860 | + | |
| 861 | + //sw.Stop(); | |
| 862 | + //textBox_State.Text += "[Time2: " + sw.ElapsedMilliseconds + "] \r\n"; | |
| 863 | + return result; | |
| 864 | + } | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + private void simpleButton_InputRegister_1_Click(object sender, EventArgs e) | |
| 869 | + { | |
| 870 | + textBox_State.Text = ""; | |
| 871 | + string[,] Data = DataReadInputToInt64(textBox_Addr_1.Text, textBox_LENGTH_1.Text); | |
| 872 | + DB_Input(Data); | |
| 873 | + } | |
| 874 | + | |
| 875 | + private void simpleButton_InputRegister_2_Click(object sender, EventArgs e) | |
| 876 | + { | |
| 877 | + textBox_State.Text = ""; | |
| 878 | + string[,] Data = DataReadInputToInt64(textBox_Addr_2.Text, textBox_LENGTH_2.Text); | |
| 879 | + DB_Input(Data); | |
| 880 | + } | |
| 881 | + | |
| 882 | + private void simpleButton_InputRegister_3_Click(object sender, EventArgs e) | |
| 883 | + { | |
| 884 | + textBox_State.Text = ""; | |
| 885 | + string[,] Data = DataReadInput(textBox_Addr_3.Text, textBox_LENGTH_3.Text); | |
| 886 | + DB_Input(Data); | |
| 887 | + } | |
| 888 | + | |
| 889 | + private void simpleButton_InputRegister_4_Click(object sender, EventArgs e) | |
| 890 | + { | |
| 891 | + textBox_State.Text = ""; | |
| 892 | + string[,] Data = DataReadInput(textBox_Addr_4.Text, textBox_LENGTH_4.Text); | |
| 893 | + DB_Input(Data); | |
| 894 | + } | |
| 895 | + | |
| 896 | + private void simpleButton_InputRegister_5_Click(object sender, EventArgs e) | |
| 897 | + { | |
| 898 | + textBox_State.Text = ""; | |
| 899 | + string[,] Data = DataReadInputTouUint64(textBox_Addr_5.Text, textBox_LENGTH_5.Text); | |
| 900 | + DB_Input(Data); | |
| 901 | + } | |
| 902 | + | |
| 903 | + private void simpleButton_InputRegister_6_Click(object sender, EventArgs e) | |
| 904 | + { | |
| 905 | + //textBox_State.Text = ""; | |
| 906 | + string[,] Data = DataReadInputToBit(textBox_Addr_6.Text, textBox_LENGTH_6.Text); | |
| 907 | + //for (int i = 0; i < Data.Length / 2; i++) | |
| 908 | + //{ | |
| 909 | + // textBox_State.Text += "["+Data[i,0]+ " : "+Data[i,1]+"]"; | |
| 910 | + //} | |
| 911 | + //textBox_State.Text += "\r\n"; | |
| 912 | + DB_Input(Data); | |
| 913 | + } | |
| 914 | + | |
| 915 | + private void simpleButton_InputRegister_2_2_Click(object sender, EventArgs e) | |
| 916 | + { | |
| 917 | + textBox_State.Text = ""; | |
| 918 | + string[,] Data = DataReadInput(textBox_Addr_2_2.Text, textBox_LENGTH_2_2.Text); | |
| 919 | + DB_Input(Data); | |
| 920 | + } | |
| 921 | + | |
| 922 | + | |
| 923 | + public void DB_Input(List<string[,]> Data) | |
| 924 | + { | |
| 925 | + m_Data = Data; | |
| 926 | + } | |
| 927 | + | |
| 928 | + public void DB_Input(string[,]Data) | |
| 929 | + { | |
| 930 | + if (!DBConnectionSingleton.Instance().isConnect()) return; | |
| 931 | + | |
| 932 | + //DB 설비정보내에서 온도계 정보를 가져옵니다.[온도계는 CODE정보로 E03으로 저장되어있다] | |
| 933 | + DataTable dt = DBConnectionSingleton.Instance().GetSqlData("SELECT [COMP_CD],[MACH_CD],[MACH_NO],[MACH_NM] FROM [dbo].[T_STD_MACH] m where m.COMP_CD = '0001' order by MACH_NO asc"); | |
| 934 | + if (dt == null) return; | |
| 935 | + | |
| 936 | + | |
| 937 | + string input_Mach_CD = ""; | |
| 938 | + string input_RealData = ""; | |
| 939 | + | |
| 940 | + textBox_State.Text += "TEST START \r\n"; | |
| 941 | + if (Data != null) | |
| 942 | + { | |
| 943 | + for (int i = 0; i < Data.Length / 2; i++) | |
| 944 | + { | |
| 945 | + for (int j = 0; j < dt.Rows.Count; j++) | |
| 946 | + { | |
| 947 | + if (dt.Rows[j]["MACH_NO"].ToString() == Data[i,0].ToString()) | |
| 948 | + { | |
| 949 | + textBox_State.Text += "["+ dt.Rows[j]["MACH_CD"].ToString() + ":"+ Data[i, 1].ToString() + "]"; | |
| 950 | + input_Mach_CD += dt.Rows[j]["MACH_CD"].ToString() + ","; | |
| 951 | + input_RealData += Data[i,1].ToString() + ","; | |
| 952 | + break; | |
| 953 | + } | |
| 954 | + } | |
| 955 | + } | |
| 956 | + } | |
| 957 | + textBox_State.Text += "TEST END\r\n"; | |
| 958 | + | |
| 959 | + | |
| 960 | + if (input_Mach_CD.LastIndexOf(',') == input_Mach_CD.Length - 1 && input_Mach_CD.LastIndexOf(',') != -1) | |
| 961 | + { | |
| 962 | + input_Mach_CD = input_Mach_CD.Substring(0, input_Mach_CD.Length - 1); | |
| 963 | + } | |
| 964 | + | |
| 965 | + if (input_RealData.LastIndexOf(',') == input_RealData.Length - 1 && input_RealData.LastIndexOf(',') != -1) | |
| 966 | + { | |
| 967 | + input_RealData = input_RealData.Substring(0, input_RealData.Length - 1); | |
| 968 | + } | |
| 969 | + | |
| 970 | + //sw.Stop(); | |
| 971 | + | |
| 972 | + //textBox_State.Text += "Timer Check 3 : " + sw.ElapsedMilliseconds.ToString() + "\r\n"; | |
| 973 | + | |
| 974 | + //sw.Start(); | |
| 975 | + | |
| 976 | + if (input_Mach_CD == "" || input_RealData == "") return; | |
| 977 | + | |
| 978 | + if (DBConnectionSingleton.Instance().SetCommand("HTSaveRealDataAll", | |
| 979 | + DBConnectionSingleton.Instance().getParams("COMP_CD", "0001"), | |
| 980 | + DBConnectionSingleton.Instance().getParams("MACH_CD", input_Mach_CD), | |
| 981 | + DBConnectionSingleton.Instance().getParams("REAL_DATA", input_RealData))) | |
| 982 | + { | |
| 983 | + textBox_State.Text += "DBInsert Complete : " + input_Mach_CD + "\r\n"; | |
| 984 | + textBox_State.Text += "DBInsert Complete : " + input_RealData + "\r\n"; | |
| 985 | + } | |
| 986 | + | |
| 987 | + | |
| 988 | + } | |
| 989 | + | |
| 990 | + class MACHDATA | |
| 991 | + { | |
| 992 | + public string MACH_NO { get; set; } | |
| 993 | + public string DATA { get; set; } | |
| 994 | + } | |
| 995 | + | |
| 996 | + public void All_Data_Insert() | |
| 997 | + { | |
| 998 | + //DB 설비정보내에서 온도계 정보를 가져옵니다.[온도계는 CODE정보로 E03으로 저장되어있다] | |
| 999 | + DataTable dt = DBConnectionSingleton.Instance().GetSqlData("SELECT [COMP_CD],[MACH_CD],[MACH_NO],[MACH_NM] FROM [dbo].[T_STD_MACH] m where m.COMP_CD = '0001' order by MACH_CD asc"); | |
| 1000 | + if (dt == null) return; | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + string input_Mach_CD = ""; | |
| 1004 | + string input_RealData = ""; | |
| 1005 | + | |
| 1006 | + List<MACHDATA> inputData = new List<MACHDATA>(); | |
| 1007 | + | |
| 1008 | + if (m_Data != null) | |
| 1009 | + { | |
| 1010 | + if (m_Data.Count >= 1) | |
| 1011 | + { | |
| 1012 | + foreach (string[,] strData in m_Data) | |
| 1013 | + { | |
| 1014 | + for (int i = 0; i < strData.Length / 2; i++) | |
| 1015 | + { | |
| 1016 | + for (int j = 0; j < dt.Rows.Count; j++) | |
| 1017 | + { | |
| 1018 | + if (dt.Rows[j]["MACH_NO"].ToString() == strData[i, 0].ToString()) | |
| 1019 | + { | |
| 1020 | + MACHDATA MData = new MACHDATA(); | |
| 1021 | + MData.MACH_NO = dt.Rows[j]["MACH_CD"].ToString(); | |
| 1022 | + MData.DATA = strData[i, 1].ToString(); | |
| 1023 | + inputData.Add(MData); | |
| 1024 | + | |
| 1025 | + //input_Mach_CD += dt.Rows[j]["MACH_CD"].ToString() + ","; | |
| 1026 | + //input_RealData += strData[i, 1].ToString() + ","; | |
| 1027 | + break; | |
| 1028 | + } | |
| 1029 | + } | |
| 1030 | + } | |
| 1031 | + } | |
| 1032 | + } | |
| 1033 | + } | |
| 1034 | + List<MACHDATA> sortList = inputData.OrderBy(x => x.MACH_NO).ThenBy(x => x.DATA).ToList(); | |
| 1035 | + | |
| 1036 | + foreach(MACHDATA md in sortList) | |
| 1037 | + { | |
| 1038 | + input_Mach_CD += md.MACH_NO + ","; | |
| 1039 | + input_RealData += md.DATA + ","; | |
| 1040 | + } | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + if (input_Mach_CD.LastIndexOf(',') == input_Mach_CD.Length - 1 && input_Mach_CD.LastIndexOf(',') != -1) | |
| 1045 | + { | |
| 1046 | + input_Mach_CD = input_Mach_CD.Substring(0, input_Mach_CD.Length - 1); | |
| 1047 | + } | |
| 1048 | + | |
| 1049 | + if (input_RealData.LastIndexOf(',') == input_RealData.Length - 1 && input_RealData.LastIndexOf(',') != -1) | |
| 1050 | + { | |
| 1051 | + input_RealData = input_RealData.Substring(0, input_RealData.Length - 1); | |
| 1052 | + } | |
| 1053 | + | |
| 1054 | + //sw.Stop(); | |
| 1055 | + | |
| 1056 | + //textBox_State.Text += "Timer Check 3 : " + sw.ElapsedMilliseconds.ToString() + "\r\n"; | |
| 1057 | + | |
| 1058 | + //sw.Start(); | |
| 1059 | + | |
| 1060 | + if (input_Mach_CD == "" || input_RealData == "") return; | |
| 1061 | + | |
| 1062 | + if (DBConnectionSingleton.Instance().SetCommand("HTSaveRealDataAll", | |
| 1063 | + DBConnectionSingleton.Instance().getParams("COMP_CD", "0001"), | |
| 1064 | + DBConnectionSingleton.Instance().getParams("MACH_CD", input_Mach_CD), | |
| 1065 | + DBConnectionSingleton.Instance().getParams("REAL_DATA", input_RealData))) | |
| 1066 | + { | |
| 1067 | + textBox_State.Text += "DBInsert Complete : " + input_Mach_CD + "\r\n"; | |
| 1068 | + textBox_State.Text += "DBInsert Complete : " + input_RealData + "\r\n"; | |
| 1069 | + } | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + } | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + private void simpleButton_All_Click(object sender, EventArgs e) | |
| 1081 | + { | |
| 1082 | + textBox_State.Text = ""; | |
| 1083 | + var lst = new List<string[,]>(); | |
| 1084 | + string[,] array; | |
| 1085 | + array = DataReadInputToInt64(textBox_Addr_1.Text, textBox_LENGTH_1.Text); | |
| 1086 | + if(array!=null) if (array.Length > 1) lst.Add(array); | |
| 1087 | + array = DataReadInputToInt64(textBox_Addr_2.Text, textBox_LENGTH_2.Text); | |
| 1088 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 1089 | + array = DataReadInput(textBox_Addr_2_2.Text, textBox_LENGTH_2_2.Text); | |
| 1090 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 1091 | + array = DataReadInput(textBox_Addr_3.Text, textBox_LENGTH_3.Text); | |
| 1092 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 1093 | + array = DataReadInput(textBox_Addr_4.Text, textBox_LENGTH_4.Text); | |
| 1094 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 1095 | + array = DataReadInputToInt64(textBox_Addr_5.Text, textBox_LENGTH_5.Text); | |
| 1096 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 1097 | + array = DataReadInputToBit(textBox_Addr_6.Text, textBox_LENGTH_6.Text); | |
| 1098 | + if (array != null) if (array.Length > 1) lst.Add(array); | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + DB_Input(lst); | |
| 1102 | + } | |
| 1103 | + | |
| 1104 | + private void timer_DBConnect_Tick(object sender, EventArgs e) | |
| 1105 | + { | |
| 1106 | + try | |
| 1107 | + { | |
| 1108 | + if (!DBConnectionSingleton.Instance().isConnect()) | |
| 1109 | + if (DBConnectionSingleton.Instance().Connect()) | |
| 1110 | + { | |
| 1111 | + textBox_State.Text += "DB_Connected\r\n"; | |
| 1112 | + panel_DBConnect.BackColor = Color.FromArgb(192, 255, 192); | |
| 1113 | + } | |
| 1114 | + else | |
| 1115 | + { | |
| 1116 | + panel_DBConnect.BackColor = Color.FromArgb(255, 192, 192); | |
| 1117 | + } | |
| 1118 | + } | |
| 1119 | + catch (Exception ex) | |
| 1120 | + { | |
| 1121 | + textBox_State.Text += "Connect Error : " + ex.Message + "\r\n"; | |
| 1122 | + } | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + if (DBConnectionSingleton.Instance().isConnect()) | |
| 1126 | + { | |
| 1127 | + | |
| 1128 | + All_Data_Insert(); | |
| 1129 | + } | |
| 1130 | + } | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + private void timer_Log_Tick(object sender, EventArgs e) | |
| 1134 | + { | |
| 1135 | + if (DBConnectionSingleton.Instance().SetCommand("HTInsertRealToLog")) | |
| 1136 | + { | |
| 1137 | + //textBox_State.Text += "DBInsert Complete : Log Insert\r\n"; | |
| 1138 | + } | |
| 1139 | + } | |
| 1140 | + | |
| 1141 | + private void toggleSwitch_Log_Toggled(object sender, EventArgs e) | |
| 1142 | + { | |
| 1143 | + timer_Log.Enabled = toggleSwitch_Log.IsOn; | |
| 1144 | + } | |
| 1145 | + | |
| 1146 | + private void simpleButton8_Click_1(object sender, EventArgs e) | |
| 1147 | + { | |
| 1148 | + } | |
| 1149 | + } | |
| 1150 | +} |
+++ ModbusTest/FormModbus.resx
... | ... | @@ -0,0 +1,132 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<root> | |
| 3 | + <!-- | |
| 4 | + Microsoft ResX Schema | |
| 5 | + | |
| 6 | + Version 2.0 | |
| 7 | + | |
| 8 | + The primary goals of this format is to allow a simple XML format | |
| 9 | + that is mostly human readable. The generation and parsing of the | |
| 10 | + various data types are done through the TypeConverter classes | |
| 11 | + associated with the data types. | |
| 12 | + | |
| 13 | + Example: | |
| 14 | + | |
| 15 | + ... ado.net/XML headers & schema ... | |
| 16 | + <resheader name="resmimetype">text/microsoft-resx</resheader> | |
| 17 | + <resheader name="version">2.0</resheader> | |
| 18 | + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |
| 19 | + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |
| 20 | + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |
| 21 | + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |
| 22 | + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |
| 23 | + <value>[base64 mime encoded serialized .NET Framework object]</value> | |
| 24 | + </data> | |
| 25 | + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |
| 26 | + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |
| 27 | + <comment>This is a comment</comment> | |
| 28 | + </data> | |
| 29 | + | |
| 30 | + There are any number of "resheader" rows that contain simple | |
| 31 | + name/value pairs. | |
| 32 | + | |
| 33 | + Each data row contains a name, and value. The row also contains a | |
| 34 | + type or mimetype. Type corresponds to a .NET class that support | |
| 35 | + text/value conversion through the TypeConverter architecture. | |
| 36 | + Classes that don't support this are serialized and stored with the | |
| 37 | + mimetype set. | |
| 38 | + | |
| 39 | + The mimetype is used for serialized objects, and tells the | |
| 40 | + ResXResourceReader how to depersist the object. This is currently not | |
| 41 | + extensible. For a given mimetype the value must be set accordingly: | |
| 42 | + | |
| 43 | + Note - application/x-microsoft.net.object.binary.base64 is the format | |
| 44 | + that the ResXResourceWriter will generate, however the reader can | |
| 45 | + read any of the formats listed below. | |
| 46 | + | |
| 47 | + mimetype: application/x-microsoft.net.object.binary.base64 | |
| 48 | + value : The object must be serialized with | |
| 49 | + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter | |
| 50 | + : and then encoded with base64 encoding. | |
| 51 | + | |
| 52 | + mimetype: application/x-microsoft.net.object.soap.base64 | |
| 53 | + value : The object must be serialized with | |
| 54 | + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |
| 55 | + : and then encoded with base64 encoding. | |
| 56 | + | |
| 57 | + mimetype: application/x-microsoft.net.object.bytearray.base64 | |
| 58 | + value : The object must be serialized into a byte array | |
| 59 | + : using a System.ComponentModel.TypeConverter | |
| 60 | + : and then encoded with base64 encoding. | |
| 61 | + --> | |
| 62 | + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |
| 63 | + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> | |
| 64 | + <xsd:element name="root" msdata:IsDataSet="true"> | |
| 65 | + <xsd:complexType> | |
| 66 | + <xsd:choice maxOccurs="unbounded"> | |
| 67 | + <xsd:element name="metadata"> | |
| 68 | + <xsd:complexType> | |
| 69 | + <xsd:sequence> | |
| 70 | + <xsd:element name="value" type="xsd:string" minOccurs="0" /> | |
| 71 | + </xsd:sequence> | |
| 72 | + <xsd:attribute name="name" use="required" type="xsd:string" /> | |
| 73 | + <xsd:attribute name="type" type="xsd:string" /> | |
| 74 | + <xsd:attribute name="mimetype" type="xsd:string" /> | |
| 75 | + <xsd:attribute ref="xml:space" /> | |
| 76 | + </xsd:complexType> | |
| 77 | + </xsd:element> | |
| 78 | + <xsd:element name="assembly"> | |
| 79 | + <xsd:complexType> | |
| 80 | + <xsd:attribute name="alias" type="xsd:string" /> | |
| 81 | + <xsd:attribute name="name" type="xsd:string" /> | |
| 82 | + </xsd:complexType> | |
| 83 | + </xsd:element> | |
| 84 | + <xsd:element name="data"> | |
| 85 | + <xsd:complexType> | |
| 86 | + <xsd:sequence> | |
| 87 | + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |
| 88 | + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |
| 89 | + </xsd:sequence> | |
| 90 | + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> | |
| 91 | + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |
| 92 | + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |
| 93 | + <xsd:attribute ref="xml:space" /> | |
| 94 | + </xsd:complexType> | |
| 95 | + </xsd:element> | |
| 96 | + <xsd:element name="resheader"> | |
| 97 | + <xsd:complexType> | |
| 98 | + <xsd:sequence> | |
| 99 | + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |
| 100 | + </xsd:sequence> | |
| 101 | + <xsd:attribute name="name" type="xsd:string" use="required" /> | |
| 102 | + </xsd:complexType> | |
| 103 | + </xsd:element> | |
| 104 | + </xsd:choice> | |
| 105 | + </xsd:complexType> | |
| 106 | + </xsd:element> | |
| 107 | + </xsd:schema> | |
| 108 | + <resheader name="resmimetype"> | |
| 109 | + <value>text/microsoft-resx</value> | |
| 110 | + </resheader> | |
| 111 | + <resheader name="version"> | |
| 112 | + <value>2.0</value> | |
| 113 | + </resheader> | |
| 114 | + <resheader name="reader"> | |
| 115 | + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
| 116 | + </resheader> | |
| 117 | + <resheader name="writer"> | |
| 118 | + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
| 119 | + </resheader> | |
| 120 | + <metadata name="timer_Connect.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
| 121 | + <value>17, 17</value> | |
| 122 | + </metadata> | |
| 123 | + <metadata name="timer_AutoInput.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
| 124 | + <value>149, 17</value> | |
| 125 | + </metadata> | |
| 126 | + <metadata name="timer_DBInsert.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
| 127 | + <value>291, 17</value> | |
| 128 | + </metadata> | |
| 129 | + <metadata name="timer_Log.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | |
| 130 | + <value>424, 17</value> | |
| 131 | + </metadata> | |
| 132 | +</root>(No newline at end of file) |
+++ ModbusTest/KHModbus.csproj
... | ... | @@ -0,0 +1,98 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
| 3 | + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |
| 4 | + <PropertyGroup> | |
| 5 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
| 6 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
| 7 | + <ProjectGuid>{2A789031-AEE6-436C-B5E0-AB764F55FCD2}</ProjectGuid> | |
| 8 | + <OutputType>WinExe</OutputType> | |
| 9 | + <RootNamespace>ModbusTest</RootNamespace> | |
| 10 | + <AssemblyName>ModbusTest</AssemblyName> | |
| 11 | + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | |
| 12 | + <FileAlignment>512</FileAlignment> | |
| 13 | + <Deterministic>true</Deterministic> | |
| 14 | + </PropertyGroup> | |
| 15 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
| 16 | + <PlatformTarget>AnyCPU</PlatformTarget> | |
| 17 | + <DebugSymbols>true</DebugSymbols> | |
| 18 | + <DebugType>full</DebugType> | |
| 19 | + <Optimize>false</Optimize> | |
| 20 | + <OutputPath>bin\Debug\</OutputPath> | |
| 21 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | |
| 22 | + <ErrorReport>prompt</ErrorReport> | |
| 23 | + <WarningLevel>4</WarningLevel> | |
| 24 | + </PropertyGroup> | |
| 25 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
| 26 | + <PlatformTarget>AnyCPU</PlatformTarget> | |
| 27 | + <DebugType>pdbonly</DebugType> | |
| 28 | + <Optimize>true</Optimize> | |
| 29 | + <OutputPath>bin\Release\</OutputPath> | |
| 30 | + <DefineConstants>TRACE</DefineConstants> | |
| 31 | + <ErrorReport>prompt</ErrorReport> | |
| 32 | + <WarningLevel>4</WarningLevel> | |
| 33 | + </PropertyGroup> | |
| 34 | + <ItemGroup> | |
| 35 | + <Reference Include="DevExpress.Data.v14.1, Version=14.1.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> | |
| 36 | + <Reference Include="DevExpress.Printing.v14.1.Core, Version=14.1.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> | |
| 37 | + <Reference Include="DevExpress.Sparkline.v14.1.Core, Version=14.1.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> | |
| 38 | + <Reference Include="DevExpress.Utils.v14.1, Version=14.1.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> | |
| 39 | + <Reference Include="DevExpress.XtraEditors.v14.1, Version=14.1.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" /> | |
| 40 | + <Reference Include="EasyModbus, Version=5.6.0.0, Culture=neutral, processorArchitecture=MSIL"> | |
| 41 | + <HintPath>..\packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll</HintPath> | |
| 42 | + </Reference> | |
| 43 | + <Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL"> | |
| 44 | + <HintPath>..\packages\NModbus4.2.1.0\lib\net40\NModbus4.dll</HintPath> | |
| 45 | + </Reference> | |
| 46 | + <Reference Include="System" /> | |
| 47 | + <Reference Include="System.Core" /> | |
| 48 | + <Reference Include="System.Data.Linq" /> | |
| 49 | + <Reference Include="System.Printing" /> | |
| 50 | + <Reference Include="System.Xml.Linq" /> | |
| 51 | + <Reference Include="System.Data.DataSetExtensions" /> | |
| 52 | + <Reference Include="Microsoft.CSharp" /> | |
| 53 | + <Reference Include="System.Data" /> | |
| 54 | + <Reference Include="System.Deployment" /> | |
| 55 | + <Reference Include="System.Drawing" /> | |
| 56 | + <Reference Include="System.Net.Http" /> | |
| 57 | + <Reference Include="System.Windows.Forms" /> | |
| 58 | + <Reference Include="System.Xml" /> | |
| 59 | + </ItemGroup> | |
| 60 | + <ItemGroup> | |
| 61 | + <Compile Include="DBConnectionSingleton.cs" /> | |
| 62 | + <Compile Include="FormModbus.cs"> | |
| 63 | + <SubType>Form</SubType> | |
| 64 | + </Compile> | |
| 65 | + <Compile Include="FormModbus.Designer.cs"> | |
| 66 | + <DependentUpon>FormModbus.cs</DependentUpon> | |
| 67 | + </Compile> | |
| 68 | + <Compile Include="Program.cs" /> | |
| 69 | + <Compile Include="Properties\AssemblyInfo.cs" /> | |
| 70 | + <Compile Include="SerialConnectionSingleton.cs" /> | |
| 71 | + <EmbeddedResource Include="FormModbus.resx"> | |
| 72 | + <DependentUpon>FormModbus.cs</DependentUpon> | |
| 73 | + </EmbeddedResource> | |
| 74 | + <EmbeddedResource Include="Properties\Resources.resx"> | |
| 75 | + <Generator>ResXFileCodeGenerator</Generator> | |
| 76 | + <LastGenOutput>Resources.Designer.cs</LastGenOutput> | |
| 77 | + <SubType>Designer</SubType> | |
| 78 | + </EmbeddedResource> | |
| 79 | + <Compile Include="Properties\Resources.Designer.cs"> | |
| 80 | + <AutoGen>True</AutoGen> | |
| 81 | + <DependentUpon>Resources.resx</DependentUpon> | |
| 82 | + </Compile> | |
| 83 | + <None Include="packages.config" /> | |
| 84 | + <None Include="Properties\Settings.settings"> | |
| 85 | + <Generator>SettingsSingleFileGenerator</Generator> | |
| 86 | + <LastGenOutput>Settings.Designer.cs</LastGenOutput> | |
| 87 | + </None> | |
| 88 | + <Compile Include="Properties\Settings.Designer.cs"> | |
| 89 | + <AutoGen>True</AutoGen> | |
| 90 | + <DependentUpon>Settings.settings</DependentUpon> | |
| 91 | + <DesignTimeSharedInput>True</DesignTimeSharedInput> | |
| 92 | + </Compile> | |
| 93 | + </ItemGroup> | |
| 94 | + <ItemGroup> | |
| 95 | + <None Include="App.config" /> | |
| 96 | + </ItemGroup> | |
| 97 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |
| 98 | +</Project>(No newline at end of file) |
+++ ModbusTest/Program.cs
... | ... | @@ -0,0 +1,25 @@ |
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Threading.Tasks; | |
| 5 | +using System.Windows.Forms; | |
| 6 | + | |
| 7 | +namespace KHModbus | |
| 8 | +{ | |
| 9 | + static class Program | |
| 10 | + { | |
| 11 | + /// <summary> | |
| 12 | + /// 해당 애플리케이션의 주 진입점입니다. | |
| 13 | + /// </summary> | |
| 14 | + [STAThread] | |
| 15 | + static void Main() | |
| 16 | + { | |
| 17 | + Application.EnableVisualStyles(); | |
| 18 | + Application.SetCompatibleTextRenderingDefault(false); | |
| 19 | + | |
| 20 | + DBConnectionSingleton.Instance(); | |
| 21 | + | |
| 22 | + Application.Run(new FormModbus()); | |
| 23 | + } | |
| 24 | + } | |
| 25 | +} |
+++ ModbusTest/Properties/AssemblyInfo.cs
... | ... | @@ -0,0 +1,36 @@ |
| 1 | +using System.Reflection; | |
| 2 | +using System.Runtime.CompilerServices; | |
| 3 | +using System.Runtime.InteropServices; | |
| 4 | + | |
| 5 | +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 | |
| 6 | +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 | |
| 7 | +// 이러한 특성 값을 변경하세요. | |
| 8 | +[assembly: AssemblyTitle("KHModbus")] | |
| 9 | +[assembly: AssemblyDescription("")] | |
| 10 | +[assembly: AssemblyConfiguration("")] | |
| 11 | +[assembly: AssemblyCompany("")] | |
| 12 | +[assembly: AssemblyProduct("KHModbus")] | |
| 13 | +[assembly: AssemblyCopyright("Copyright © 2022")] | |
| 14 | +[assembly: AssemblyTrademark("")] | |
| 15 | +[assembly: AssemblyCulture("")] | |
| 16 | + | |
| 17 | +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 | |
| 18 | +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 | |
| 19 | +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. | |
| 20 | +[assembly: ComVisible(false)] | |
| 21 | + | |
| 22 | +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. | |
| 23 | +[assembly: Guid("2a789031-aee6-436c-b5e0-ab764f55fcd2")] | |
| 24 | + | |
| 25 | +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. | |
| 26 | +// | |
| 27 | +// 주 버전 | |
| 28 | +// 부 버전 | |
| 29 | +// 빌드 번호 | |
| 30 | +// 수정 버전 | |
| 31 | +// | |
| 32 | +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 | |
| 33 | +// 기본값으로 할 수 있습니다. | |
| 34 | +// [assembly: AssemblyVersion("1.0.*")] | |
| 35 | +[assembly: AssemblyVersion("1.0.0.0")] | |
| 36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
+++ ModbusTest/Properties/Resources.Designer.cs
... | ... | @@ -0,0 +1,70 @@ |
| 1 | +//------------------------------------------------------------------------------ | |
| 2 | +// <auto-generated> | |
| 3 | +// 이 코드는 도구를 사용하여 생성되었습니다. | |
| 4 | +// 런타임 버전:4.0.30319.42000 | |
| 5 | +// | |
| 6 | +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 | |
| 7 | +// 이러한 변경 내용이 손실됩니다. | |
| 8 | +// </auto-generated> | |
| 9 | +//------------------------------------------------------------------------------ | |
| 10 | + | |
| 11 | + | |
| 12 | +namespace KHModbus.Properties | |
| 13 | +{ | |
| 14 | + /// <summary> | |
| 15 | + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. | |
| 16 | + /// </summary> | |
| 17 | + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder | |
| 18 | + // 클래스에서 자동으로 생성되었습니다. | |
| 19 | + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 | |
| 20 | + // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. | |
| 21 | + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] | |
| 22 | + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] | |
| 23 | + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | |
| 24 | + internal class Resources | |
| 25 | + { | |
| 26 | + | |
| 27 | + private static global::System.Resources.ResourceManager resourceMan; | |
| 28 | + | |
| 29 | + private static global::System.Globalization.CultureInfo resourceCulture; | |
| 30 | + | |
| 31 | + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | |
| 32 | + internal Resources() | |
| 33 | + { | |
| 34 | + } | |
| 35 | + | |
| 36 | + /// <summary> | |
| 37 | + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. | |
| 38 | + /// </summary> | |
| 39 | + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |
| 40 | + internal static global::System.Resources.ResourceManager ResourceManager | |
| 41 | + { | |
| 42 | + get | |
| 43 | + { | |
| 44 | + if ((resourceMan == null)) | |
| 45 | + { | |
| 46 | + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KHModbus.Properties.Resources", typeof(Resources).Assembly); | |
| 47 | + resourceMan = temp; | |
| 48 | + } | |
| 49 | + return resourceMan; | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + /// <summary> | |
| 54 | + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 | |
| 55 | + /// 재정의합니다. | |
| 56 | + /// </summary> | |
| 57 | + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |
| 58 | + internal static global::System.Globalization.CultureInfo Culture | |
| 59 | + { | |
| 60 | + get | |
| 61 | + { | |
| 62 | + return resourceCulture; | |
| 63 | + } | |
| 64 | + set | |
| 65 | + { | |
| 66 | + resourceCulture = value; | |
| 67 | + } | |
| 68 | + } | |
| 69 | + } | |
| 70 | +} |
+++ ModbusTest/Properties/Resources.resx
... | ... | @@ -0,0 +1,117 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<root> | |
| 3 | + <!-- | |
| 4 | + Microsoft ResX Schema | |
| 5 | + | |
| 6 | + Version 2.0 | |
| 7 | + | |
| 8 | + The primary goals of this format is to allow a simple XML format | |
| 9 | + that is mostly human readable. The generation and parsing of the | |
| 10 | + various data types are done through the TypeConverter classes | |
| 11 | + associated with the data types. | |
| 12 | + | |
| 13 | + Example: | |
| 14 | + | |
| 15 | + ... ado.net/XML headers & schema ... | |
| 16 | + <resheader name="resmimetype">text/microsoft-resx</resheader> | |
| 17 | + <resheader name="version">2.0</resheader> | |
| 18 | + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |
| 19 | + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |
| 20 | + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |
| 21 | + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |
| 22 | + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |
| 23 | + <value>[base64 mime encoded serialized .NET Framework object]</value> | |
| 24 | + </data> | |
| 25 | + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |
| 26 | + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |
| 27 | + <comment>This is a comment</comment> | |
| 28 | + </data> | |
| 29 | + | |
| 30 | + There are any number of "resheader" rows that contain simple | |
| 31 | + name/value pairs. | |
| 32 | + | |
| 33 | + Each data row contains a name, and value. The row also contains a | |
| 34 | + type or mimetype. Type corresponds to a .NET class that support | |
| 35 | + text/value conversion through the TypeConverter architecture. | |
| 36 | + Classes that don't support this are serialized and stored with the | |
| 37 | + mimetype set. | |
| 38 | + | |
| 39 | + The mimetype is used for serialized objects, and tells the | |
| 40 | + ResXResourceReader how to depersist the object. This is currently not | |
| 41 | + extensible. For a given mimetype the value must be set accordingly: | |
| 42 | + | |
| 43 | + Note - application/x-microsoft.net.object.binary.base64 is the format | |
| 44 | + that the ResXResourceWriter will generate, however the reader can | |
| 45 | + read any of the formats listed below. | |
| 46 | + | |
| 47 | + mimetype: application/x-microsoft.net.object.binary.base64 | |
| 48 | + value : The object must be serialized with | |
| 49 | + : System.Serialization.Formatters.Binary.BinaryFormatter | |
| 50 | + : and then encoded with base64 encoding. | |
| 51 | + | |
| 52 | + mimetype: application/x-microsoft.net.object.soap.base64 | |
| 53 | + value : The object must be serialized with | |
| 54 | + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |
| 55 | + : and then encoded with base64 encoding. | |
| 56 | + | |
| 57 | + mimetype: application/x-microsoft.net.object.bytearray.base64 | |
| 58 | + value : The object must be serialized into a byte array | |
| 59 | + : using a System.ComponentModel.TypeConverter | |
| 60 | + : and then encoded with base64 encoding. | |
| 61 | + --> | |
| 62 | + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |
| 63 | + <xsd:element name="root" msdata:IsDataSet="true"> | |
| 64 | + <xsd:complexType> | |
| 65 | + <xsd:choice maxOccurs="unbounded"> | |
| 66 | + <xsd:element name="metadata"> | |
| 67 | + <xsd:complexType> | |
| 68 | + <xsd:sequence> | |
| 69 | + <xsd:element name="value" type="xsd:string" minOccurs="0" /> | |
| 70 | + </xsd:sequence> | |
| 71 | + <xsd:attribute name="name" type="xsd:string" /> | |
| 72 | + <xsd:attribute name="type" type="xsd:string" /> | |
| 73 | + <xsd:attribute name="mimetype" type="xsd:string" /> | |
| 74 | + </xsd:complexType> | |
| 75 | + </xsd:element> | |
| 76 | + <xsd:element name="assembly"> | |
| 77 | + <xsd:complexType> | |
| 78 | + <xsd:attribute name="alias" type="xsd:string" /> | |
| 79 | + <xsd:attribute name="name" type="xsd:string" /> | |
| 80 | + </xsd:complexType> | |
| 81 | + </xsd:element> | |
| 82 | + <xsd:element name="data"> | |
| 83 | + <xsd:complexType> | |
| 84 | + <xsd:sequence> | |
| 85 | + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |
| 86 | + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |
| 87 | + </xsd:sequence> | |
| 88 | + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> | |
| 89 | + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |
| 90 | + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |
| 91 | + </xsd:complexType> | |
| 92 | + </xsd:element> | |
| 93 | + <xsd:element name="resheader"> | |
| 94 | + <xsd:complexType> | |
| 95 | + <xsd:sequence> | |
| 96 | + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |
| 97 | + </xsd:sequence> | |
| 98 | + <xsd:attribute name="name" type="xsd:string" use="required" /> | |
| 99 | + </xsd:complexType> | |
| 100 | + </xsd:element> | |
| 101 | + </xsd:choice> | |
| 102 | + </xsd:complexType> | |
| 103 | + </xsd:element> | |
| 104 | + </xsd:schema> | |
| 105 | + <resheader name="resmimetype"> | |
| 106 | + <value>text/microsoft-resx</value> | |
| 107 | + </resheader> | |
| 108 | + <resheader name="version"> | |
| 109 | + <value>2.0</value> | |
| 110 | + </resheader> | |
| 111 | + <resheader name="reader"> | |
| 112 | + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
| 113 | + </resheader> | |
| 114 | + <resheader name="writer"> | |
| 115 | + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
| 116 | + </resheader> | |
| 117 | +</root>(No newline at end of file) |
+++ ModbusTest/Properties/Settings.Designer.cs
... | ... | @@ -0,0 +1,29 @@ |
| 1 | +//------------------------------------------------------------------------------ | |
| 2 | +// <auto-generated> | |
| 3 | +// This code was generated by a tool. | |
| 4 | +// Runtime Version:4.0.30319.42000 | |
| 5 | +// | |
| 6 | +// Changes to this file may cause incorrect behavior and will be lost if | |
| 7 | +// the code is regenerated. | |
| 8 | +// </auto-generated> | |
| 9 | +//------------------------------------------------------------------------------ | |
| 10 | + | |
| 11 | + | |
| 12 | +namespace KHModbus.Properties | |
| 13 | +{ | |
| 14 | + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | |
| 15 | + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] | |
| 16 | + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase | |
| 17 | + { | |
| 18 | + | |
| 19 | + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); | |
| 20 | + | |
| 21 | + public static Settings Default | |
| 22 | + { | |
| 23 | + get | |
| 24 | + { | |
| 25 | + return defaultInstance; | |
| 26 | + } | |
| 27 | + } | |
| 28 | + } | |
| 29 | +} |
+++ ModbusTest/Properties/Settings.settings
... | ... | @@ -0,0 +1,7 @@ |
| 1 | +<?xml version='1.0' encoding='utf-8'?> | |
| 2 | +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> | |
| 3 | + <Profiles> | |
| 4 | + <Profile Name="(Default)" /> | |
| 5 | + </Profiles> | |
| 6 | + <Settings /> | |
| 7 | +</SettingsFile> |
+++ ModbusTest/SerialConnectionSingleton.cs
... | ... | @@ -0,0 +1,375 @@ |
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.IO.Ports; | |
| 4 | +using System.Linq; | |
| 5 | +using System.Text; | |
| 6 | +using System.Threading; | |
| 7 | +using System.Threading.Tasks; | |
| 8 | + | |
| 9 | +namespace KHModbus | |
| 10 | +{ | |
| 11 | + class SerialConnectionSingleton | |
| 12 | + { | |
| 13 | + private static SerialConnectionSingleton SerialConnection; | |
| 14 | + | |
| 15 | + public object lockSend = new object(); | |
| 16 | + | |
| 17 | + private SerialPort mSerialPort; | |
| 18 | + | |
| 19 | + List<byte> _readPacket; | |
| 20 | + ManualResetEvent _eventReset = new ManualResetEvent(false); | |
| 21 | + int responseLength; | |
| 22 | + bool isWatingResponse; | |
| 23 | + | |
| 24 | + public static SerialConnectionSingleton Instance() | |
| 25 | + { | |
| 26 | + if (SerialConnection == null) | |
| 27 | + { | |
| 28 | + SerialConnection = new SerialConnectionSingleton(); | |
| 29 | + } | |
| 30 | + return SerialConnection; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public void InitialModBus() | |
| 34 | + { | |
| 35 | + mSerialPort = new SerialPort(); | |
| 36 | + mSerialPort.PortName = "COM1"; | |
| 37 | + mSerialPort.BaudRate = 9600; | |
| 38 | + mSerialPort.Parity = Parity.None; | |
| 39 | + mSerialPort.StopBits = StopBits.One; | |
| 40 | + mSerialPort.DataBits = 8; | |
| 41 | + //_serialPort.ReadTimeout = 500; | |
| 42 | + SlaveNo = 1; | |
| 43 | + responseLength = 0; | |
| 44 | + isWatingResponse = false; | |
| 45 | + | |
| 46 | + _readPacket = new List<byte>(); | |
| 47 | + mSerialPort.DataReceived += DataReceived; | |
| 48 | + } | |
| 49 | + | |
| 50 | + private void DataReceived(object sender, SerialDataReceivedEventArgs e) | |
| 51 | + { | |
| 52 | + if (isWatingResponse) | |
| 53 | + { | |
| 54 | + Thread.Sleep(100); | |
| 55 | + SerialPort port = (SerialPort)sender; | |
| 56 | + // 현재까지 도착한 데이타 모두 읽기 | |
| 57 | + byte[] vs = new byte[responseLength]; | |
| 58 | + port.Read(vs, 0, responseLength); | |
| 59 | + _readPacket.AddRange(vs); | |
| 60 | + isWatingResponse = false; | |
| 61 | + _eventReset.Set(); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + | |
| 66 | + public bool IsOpen() | |
| 67 | + { | |
| 68 | + try | |
| 69 | + { | |
| 70 | + if(mSerialPort.IsOpen) | |
| 71 | + { | |
| 72 | + return true; | |
| 73 | + }else | |
| 74 | + { | |
| 75 | + return Open(); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + catch (Exception ex) | |
| 79 | + { | |
| 80 | + return false; | |
| 81 | + } | |
| 82 | + } | |
| 83 | + | |
| 84 | + public bool Open() | |
| 85 | + { | |
| 86 | + try | |
| 87 | + { | |
| 88 | + mSerialPort.Open(); | |
| 89 | + return true; | |
| 90 | + } | |
| 91 | + catch (Exception ex) | |
| 92 | + { | |
| 93 | + return false; | |
| 94 | + } | |
| 95 | + } | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + public byte[] ReadBit(byte functionCode, ushort startAddress, ushort numberOfBit) | |
| 100 | + { | |
| 101 | + lock (lockSend) | |
| 102 | + { | |
| 103 | + byte[] byteStartAddress = BitConverter.GetBytes(startAddress); | |
| 104 | + byte[] byteLength = BitConverter.GetBytes(numberOfBit); | |
| 105 | + List<byte> packet = new List<byte>() { SlaveNo, functionCode, byteStartAddress[1], byteStartAddress[0], byteLength[1], byteLength[0] }; | |
| 106 | + | |
| 107 | + packet.AddRange(BitConverter.GetBytes(ComputeCrc(packet.ToArray()))); | |
| 108 | + | |
| 109 | + _readPacket.Clear(); | |
| 110 | + | |
| 111 | + // slave, functionCode, length, (byte high, byte low)n + crc1 + crc2 | |
| 112 | + responseLength = 3 + numberOfBit / 8 + 2; | |
| 113 | + | |
| 114 | + isWatingResponse = true; | |
| 115 | + mSerialPort.Write(packet.ToArray(), 0, packet.Count); | |
| 116 | + | |
| 117 | + _eventReset.WaitOne(500); | |
| 118 | + _eventReset.Reset(); | |
| 119 | + | |
| 120 | + //byte[] readPacket = new byte[3 + length * 2 + 2]; | |
| 121 | + if (_readPacket.Count == 0) | |
| 122 | + { | |
| 123 | + return new byte[1] { 0 }; | |
| 124 | + } | |
| 125 | + | |
| 126 | + var crcCheck = _readPacket.Take(_readPacket.Count - 2).ToArray(); | |
| 127 | + byte[] computedReadCrc = BitConverter.GetBytes(ComputeCrc(crcCheck)); | |
| 128 | + if (_readPacket[_readPacket.Count - 2] != computedReadCrc[0] || _readPacket[_readPacket.Count - 1] != computedReadCrc[1]) | |
| 129 | + { | |
| 130 | + return new byte[1] { 0 }; | |
| 131 | + } | |
| 132 | + else | |
| 133 | + { | |
| 134 | + _readPacket.RemoveAt(0); | |
| 135 | + _readPacket.RemoveAt(0); | |
| 136 | + _readPacket.RemoveAt(0); | |
| 137 | + _readPacket.RemoveAt(_readPacket.Count - 1); | |
| 138 | + _readPacket.RemoveAt(_readPacket.Count - 1); | |
| 139 | + return _readPacket.ToArray(); | |
| 140 | + } | |
| 141 | + } | |
| 142 | + } | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + public string[,] DataReadHolding(string Addr, string Length) | |
| 147 | + { | |
| 148 | + byte[] Data = SerialConnectionSingleton.Instance().ReadWords(1, 4, Convert.ToUInt16(Addr), Convert.ToUInt16(Length)); | |
| 149 | + if (Data == null) return null; | |
| 150 | + | |
| 151 | + | |
| 152 | + ushort resultushort = 0; | |
| 153 | + if (Data.Length == 2) | |
| 154 | + { | |
| 155 | + resultushort = (ushort)((((byte)Data[0]) * 256) + ((byte)Data[1])); | |
| 156 | + } | |
| 157 | + | |
| 158 | + | |
| 159 | + string[,] result = new string[1, 2]; | |
| 160 | + | |
| 161 | + result[0, 0] = (Convert.ToInt32(Addr)).ToString(); | |
| 162 | + result[0, 1] = resultushort.ToString(); | |
| 163 | + | |
| 164 | + | |
| 165 | + return result; | |
| 166 | + } | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + public ushort ReadWords_To_ushort(byte SetSlaveNo, byte functionCode, ushort startAddress, ushort length) | |
| 171 | + { | |
| 172 | + | |
| 173 | + var resultBit = SerialConnectionSingleton.Instance().ReadWords(SetSlaveNo, functionCode, startAddress, length); | |
| 174 | + ushort resultushort = 0; | |
| 175 | + if (resultBit.Length == 2) | |
| 176 | + { | |
| 177 | + resultushort = (ushort)((((byte)resultBit[0]) * 256) + ((byte)resultBit[1])); | |
| 178 | + } | |
| 179 | + return resultushort; | |
| 180 | + } | |
| 181 | + | |
| 182 | + public int ReadWords_To_int(byte SetSlaveNo, byte functionCode, ushort startAddress, ushort length) | |
| 183 | + { | |
| 184 | + | |
| 185 | + var resultBit = SerialConnectionSingleton.Instance().ReadWords(SetSlaveNo, functionCode, startAddress, length); | |
| 186 | + int resultushort = 0; | |
| 187 | + if (resultBit.Length == 4) | |
| 188 | + { | |
| 189 | + resultushort = (int)((((int)resultBit[0]) * (256 * 256 * 256)) + (((int)resultBit[1]) * 65536) + (((int)resultBit[2]) * 256) + ((int)resultBit[3])); | |
| 190 | + } | |
| 191 | + return resultushort; | |
| 192 | + } | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + public byte[] ReadWords(byte SetSlaveNo, byte functionCode, ushort startAddress, ushort length) | |
| 197 | + { | |
| 198 | + lock (lockSend) | |
| 199 | + { | |
| 200 | + byte[] byteStartAddress = BitConverter.GetBytes(startAddress); | |
| 201 | + byte[] byteLength = BitConverter.GetBytes(length); | |
| 202 | + List<byte> packet = new List<byte>() { SetSlaveNo, functionCode, byteStartAddress[1], byteStartAddress[0], byteLength[1], byteLength[0] }; | |
| 203 | + | |
| 204 | + packet.AddRange(BitConverter.GetBytes(ComputeCrc(packet.ToArray()))); | |
| 205 | + | |
| 206 | + _readPacket.Clear(); | |
| 207 | + | |
| 208 | + // slave, functionCode, length, (byte high, byte low)n + crc1 + crc2 | |
| 209 | + responseLength = 3 + length * 2 + 2; | |
| 210 | + | |
| 211 | + isWatingResponse = true; | |
| 212 | + mSerialPort.Write(packet.ToArray(), 0, packet.Count); | |
| 213 | + | |
| 214 | + _eventReset.WaitOne(500); | |
| 215 | + _eventReset.Reset(); | |
| 216 | + | |
| 217 | + //byte[] readPacket = new byte[3 + length * 2 + 2]; | |
| 218 | + if (_readPacket.Count == 0) | |
| 219 | + { | |
| 220 | + return new byte[1] { 0 }; | |
| 221 | + } | |
| 222 | + | |
| 223 | + var crcCheck = _readPacket.Take(_readPacket.Count - 2).ToArray(); | |
| 224 | + byte[] computedReadCrc = BitConverter.GetBytes(ComputeCrc(crcCheck)); | |
| 225 | + if (_readPacket[_readPacket.Count - 2] != computedReadCrc[0] || _readPacket[_readPacket.Count - 1] != computedReadCrc[1]) | |
| 226 | + { | |
| 227 | + return new byte[1] { 0 }; | |
| 228 | + } | |
| 229 | + else | |
| 230 | + { | |
| 231 | + _readPacket.RemoveAt(0); | |
| 232 | + _readPacket.RemoveAt(0); | |
| 233 | + _readPacket.RemoveAt(0); | |
| 234 | + _readPacket.RemoveAt(_readPacket.Count - 1); | |
| 235 | + _readPacket.RemoveAt(_readPacket.Count - 1); | |
| 236 | + return _readPacket.ToArray(); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + } | |
| 240 | + | |
| 241 | + | |
| 242 | + //public byte[] ReadWords(byte functionCode, ushort startAddress, ushort length) | |
| 243 | + //{ | |
| 244 | + // lock (lockSend) | |
| 245 | + // { | |
| 246 | + // byte[] byteStartAddress = BitConverter.GetBytes(startAddress); | |
| 247 | + // byte[] byteLength = BitConverter.GetBytes(length); | |
| 248 | + // List<byte> packet = new List<byte>() { SlaveNo, functionCode, byteStartAddress[1], byteStartAddress[0], byteLength[1], byteLength[0] }; | |
| 249 | + | |
| 250 | + // packet.AddRange(BitConverter.GetBytes(ComputeCrc(packet.ToArray()))); | |
| 251 | + | |
| 252 | + // _readPacket.Clear(); | |
| 253 | + | |
| 254 | + // // slave, functionCode, length, (byte high, byte low)n + crc1 + crc2 | |
| 255 | + // responseLength = 3 + length * 2 + 2; | |
| 256 | + | |
| 257 | + // isWatingResponse = true; | |
| 258 | + // mSerialPort.Write(packet.ToArray(), 0, packet.Count); | |
| 259 | + | |
| 260 | + // _eventReset.WaitOne(500); | |
| 261 | + // _eventReset.Reset(); | |
| 262 | + | |
| 263 | + // //byte[] readPacket = new byte[3 + length * 2 + 2]; | |
| 264 | + // if (_readPacket.Count == 0) | |
| 265 | + // { | |
| 266 | + // return new byte[1] { 0 }; | |
| 267 | + // } | |
| 268 | + | |
| 269 | + // var crcCheck = _readPacket.Take(_readPacket.Count - 2).ToArray(); | |
| 270 | + // byte[] computedReadCrc = BitConverter.GetBytes(ComputeCrc(crcCheck)); | |
| 271 | + // if (_readPacket[_readPacket.Count - 2] != computedReadCrc[0] || _readPacket[_readPacket.Count - 1] != computedReadCrc[1]) | |
| 272 | + // { | |
| 273 | + // return new byte[1] { 0 }; | |
| 274 | + // } | |
| 275 | + // else | |
| 276 | + // { | |
| 277 | + // _readPacket.RemoveAt(0); | |
| 278 | + // _readPacket.RemoveAt(0); | |
| 279 | + // _readPacket.RemoveAt(0); | |
| 280 | + // _readPacket.RemoveAt(_readPacket.Count - 1); | |
| 281 | + // _readPacket.RemoveAt(_readPacket.Count - 1); | |
| 282 | + // return _readPacket.ToArray(); | |
| 283 | + // } | |
| 284 | + // } | |
| 285 | + //} | |
| 286 | + | |
| 287 | + public UInt16 ComputeCrc(byte[] data) | |
| 288 | + { | |
| 289 | + ushort crc = 0xFFFF; | |
| 290 | + | |
| 291 | + foreach (byte datum in data) | |
| 292 | + { | |
| 293 | + crc = (ushort)((crc >> 8) ^ CrcTable[(crc ^ datum) & 0xFF]); | |
| 294 | + } | |
| 295 | + | |
| 296 | + return crc; | |
| 297 | + } | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + private readonly ushort[] CrcTable = { | |
| 302 | + 0X0000, 0XC0C1, 0XC181, 0X0140, 0XC301, 0X03C0, 0X0280, 0XC241, | |
| 303 | + 0XC601, 0X06C0, 0X0780, 0XC741, 0X0500, 0XC5C1, 0XC481, 0X0440, | |
| 304 | + 0XCC01, 0X0CC0, 0X0D80, 0XCD41, 0X0F00, 0XCFC1, 0XCE81, 0X0E40, | |
| 305 | + 0X0A00, 0XCAC1, 0XCB81, 0X0B40, 0XC901, 0X09C0, 0X0880, 0XC841, | |
| 306 | + 0XD801, 0X18C0, 0X1980, 0XD941, 0X1B00, 0XDBC1, 0XDA81, 0X1A40, | |
| 307 | + 0X1E00, 0XDEC1, 0XDF81, 0X1F40, 0XDD01, 0X1DC0, 0X1C80, 0XDC41, | |
| 308 | + 0X1400, 0XD4C1, 0XD581, 0X1540, 0XD701, 0X17C0, 0X1680, 0XD641, | |
| 309 | + 0XD201, 0X12C0, 0X1380, 0XD341, 0X1100, 0XD1C1, 0XD081, 0X1040, | |
| 310 | + 0XF001, 0X30C0, 0X3180, 0XF141, 0X3300, 0XF3C1, 0XF281, 0X3240, | |
| 311 | + 0X3600, 0XF6C1, 0XF781, 0X3740, 0XF501, 0X35C0, 0X3480, 0XF441, | |
| 312 | + 0X3C00, 0XFCC1, 0XFD81, 0X3D40, 0XFF01, 0X3FC0, 0X3E80, 0XFE41, | |
| 313 | + 0XFA01, 0X3AC0, 0X3B80, 0XFB41, 0X3900, 0XF9C1, 0XF881, 0X3840, | |
| 314 | + 0X2800, 0XE8C1, 0XE981, 0X2940, 0XEB01, 0X2BC0, 0X2A80, 0XEA41, | |
| 315 | + 0XEE01, 0X2EC0, 0X2F80, 0XEF41, 0X2D00, 0XEDC1, 0XEC81, 0X2C40, | |
| 316 | + 0XE401, 0X24C0, 0X2580, 0XE541, 0X2700, 0XE7C1, 0XE681, 0X2640, | |
| 317 | + 0X2200, 0XE2C1, 0XE381, 0X2340, 0XE101, 0X21C0, 0X2080, 0XE041, | |
| 318 | + 0XA001, 0X60C0, 0X6180, 0XA141, 0X6300, 0XA3C1, 0XA281, 0X6240, | |
| 319 | + 0X6600, 0XA6C1, 0XA781, 0X6740, 0XA501, 0X65C0, 0X6480, 0XA441, | |
| 320 | + 0X6C00, 0XACC1, 0XAD81, 0X6D40, 0XAF01, 0X6FC0, 0X6E80, 0XAE41, | |
| 321 | + 0XAA01, 0X6AC0, 0X6B80, 0XAB41, 0X6900, 0XA9C1, 0XA881, 0X6840, | |
| 322 | + 0X7800, 0XB8C1, 0XB981, 0X7940, 0XBB01, 0X7BC0, 0X7A80, 0XBA41, | |
| 323 | + 0XBE01, 0X7EC0, 0X7F80, 0XBF41, 0X7D00, 0XBDC1, 0XBC81, 0X7C40, | |
| 324 | + 0XB401, 0X74C0, 0X7580, 0XB541, 0X7700, 0XB7C1, 0XB681, 0X7640, | |
| 325 | + 0X7200, 0XB2C1, 0XB381, 0X7340, 0XB101, 0X71C0, 0X7080, 0XB041, | |
| 326 | + 0X5000, 0X90C1, 0X9181, 0X5140, 0X9301, 0X53C0, 0X5280, 0X9241, | |
| 327 | + 0X9601, 0X56C0, 0X5780, 0X9741, 0X5500, 0X95C1, 0X9481, 0X5440, | |
| 328 | + 0X9C01, 0X5CC0, 0X5D80, 0X9D41, 0X5F00, 0X9FC1, 0X9E81, 0X5E40, | |
| 329 | + 0X5A00, 0X9AC1, 0X9B81, 0X5B40, 0X9901, 0X59C0, 0X5880, 0X9841, | |
| 330 | + 0X8801, 0X48C0, 0X4980, 0X8941, 0X4B00, 0X8BC1, 0X8A81, 0X4A40, | |
| 331 | + 0X4E00, 0X8EC1, 0X8F81, 0X4F40, 0X8D01, 0X4DC0, 0X4C80, 0X8C41, | |
| 332 | + 0X4400, 0X84C1, 0X8581, 0X4540, 0X8701, 0X47C0, 0X4680, 0X8641, | |
| 333 | + 0X8201, 0X42C0, 0X4380, 0X8341, 0X4100, 0X81C1, 0X8081, 0X4040 }; | |
| 334 | + | |
| 335 | + | |
| 336 | + public int BaudRate | |
| 337 | + { | |
| 338 | + get { return mSerialPort.BaudRate; } | |
| 339 | + set { mSerialPort.BaudRate = value; } | |
| 340 | + } | |
| 341 | + public Parity Parity | |
| 342 | + { | |
| 343 | + get { return mSerialPort.Parity; } | |
| 344 | + set { mSerialPort.Parity = value; } | |
| 345 | + } | |
| 346 | + public StopBits StopBits | |
| 347 | + { | |
| 348 | + get { return mSerialPort.StopBits; } | |
| 349 | + set { mSerialPort.StopBits = value; } | |
| 350 | + } | |
| 351 | + public int DataBits | |
| 352 | + { | |
| 353 | + get { return mSerialPort.DataBits; } | |
| 354 | + set { mSerialPort.DataBits = value; } | |
| 355 | + } | |
| 356 | + public string PortName | |
| 357 | + { | |
| 358 | + get { return mSerialPort.PortName; } | |
| 359 | + set { mSerialPort.PortName = value; } | |
| 360 | + } | |
| 361 | + public int ReadTimeout | |
| 362 | + { | |
| 363 | + get { return mSerialPort.ReadTimeout; } | |
| 364 | + set { mSerialPort.ReadTimeout = value; } | |
| 365 | + } | |
| 366 | + | |
| 367 | + private byte _slaveNo; | |
| 368 | + public byte SlaveNo | |
| 369 | + { | |
| 370 | + get { return _slaveNo; } | |
| 371 | + set { _slaveNo = value; } | |
| 372 | + } | |
| 373 | + | |
| 374 | + } | |
| 375 | +} |
+++ ModbusTest/packages.config
... | ... | @@ -0,0 +1,5 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<packages> | |
| 3 | + <package id="EasyModbusTCP" version="5.6.0" targetFramework="net45" /> | |
| 4 | + <package id="NModbus4" version="2.1.0" targetFramework="net45" /> | |
| 5 | +</packages>(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?