diff --git a/Datasheet.Designer.cs b/Datasheet.Designer.cs index 644cdb1..88f6a46 100644 --- a/Datasheet.Designer.cs +++ b/Datasheet.Designer.cs @@ -31,6 +31,11 @@ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Datasheet)); this.DGV_Device = new System.Windows.Forms.DataGridView(); + this.Label_DeviceNameLabel = new System.Windows.Forms.Label(); + this.Label_DescriptionLabel = new System.Windows.Forms.Label(); + this.Label_DeviceName = new System.Windows.Forms.Label(); + this.Label_Description = new System.Windows.Forms.Label(); + this.Button_StartStop = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.DGV_Device)).BeginInit(); this.SuspendLayout(); // @@ -42,29 +47,87 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.DGV_Device.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.DGV_Device.Location = new System.Drawing.Point(13, 60); + this.DGV_Device.Location = new System.Drawing.Point(13, 68); this.DGV_Device.MultiSelect = false; this.DGV_Device.Name = "DGV_Device"; this.DGV_Device.RowHeadersVisible = false; - this.DGV_Device.Size = new System.Drawing.Size(567, 378); + this.DGV_Device.Size = new System.Drawing.Size(567, 420); this.DGV_Device.TabIndex = 0; // + // Label_DeviceNameLabel + // + this.Label_DeviceNameLabel.AutoSize = true; + this.Label_DeviceNameLabel.Location = new System.Drawing.Point(13, 13); + this.Label_DeviceNameLabel.Name = "Label_DeviceNameLabel"; + this.Label_DeviceNameLabel.Size = new System.Drawing.Size(92, 13); + this.Label_DeviceNameLabel.TabIndex = 1; + this.Label_DeviceNameLabel.Text = "Имя устройства:"; + // + // Label_DescriptionLabel + // + this.Label_DescriptionLabel.AutoSize = true; + this.Label_DescriptionLabel.Location = new System.Drawing.Point(13, 31); + this.Label_DescriptionLabel.Name = "Label_DescriptionLabel"; + this.Label_DescriptionLabel.Size = new System.Drawing.Size(60, 13); + this.Label_DescriptionLabel.TabIndex = 2; + this.Label_DescriptionLabel.Text = "Описание:"; + // + // Label_DeviceName + // + this.Label_DeviceName.AutoSize = true; + this.Label_DeviceName.Location = new System.Drawing.Point(104, 13); + this.Label_DeviceName.Name = "Label_DeviceName"; + this.Label_DeviceName.Size = new System.Drawing.Size(35, 13); + this.Label_DeviceName.TabIndex = 3; + this.Label_DeviceName.Text = "label3"; + // + // Label_Description + // + this.Label_Description.AutoSize = true; + this.Label_Description.Location = new System.Drawing.Point(72, 31); + this.Label_Description.Name = "Label_Description"; + this.Label_Description.Size = new System.Drawing.Size(35, 13); + this.Label_Description.TabIndex = 4; + this.Label_Description.Text = "label4"; + // + // Button_StartStop + // + this.Button_StartStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.Button_StartStop.Location = new System.Drawing.Point(505, 13); + this.Button_StartStop.Name = "Button_StartStop"; + this.Button_StartStop.Size = new System.Drawing.Size(75, 23); + this.Button_StartStop.TabIndex = 5; + this.Button_StartStop.Text = "Старт"; + this.Button_StartStop.UseVisualStyleBackColor = true; + this.Button_StartStop.Click += new System.EventHandler(this.Button_StartStop_Click); + // // Datasheet // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 450); + this.ClientSize = new System.Drawing.Size(592, 500); + this.Controls.Add(this.Button_StartStop); + this.Controls.Add(this.Label_Description); + this.Controls.Add(this.Label_DeviceName); + this.Controls.Add(this.Label_DescriptionLabel); + this.Controls.Add(this.Label_DeviceNameLabel); this.Controls.Add(this.DGV_Device); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Datasheet"; this.Text = "Datasheet"; ((System.ComponentModel.ISupportInitialize)(this.DGV_Device)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion private System.Windows.Forms.DataGridView DGV_Device; + private System.Windows.Forms.Label Label_DeviceNameLabel; + private System.Windows.Forms.Label Label_DescriptionLabel; + private System.Windows.Forms.Label Label_DeviceName; + private System.Windows.Forms.Label Label_Description; + private System.Windows.Forms.Button Button_StartStop; } } \ No newline at end of file diff --git a/Datasheet.cs b/Datasheet.cs index 846e4b3..ddf2941 100644 --- a/Datasheet.cs +++ b/Datasheet.cs @@ -15,6 +15,7 @@ namespace Gidrolock_Modbus_Scanner { public partial class Datasheet : Form { + bool isPolling = false; bool isAwaitingResponse = false; bool isProcessingResponse = false; byte[] message = new byte[255]; @@ -36,6 +37,9 @@ namespace Gidrolock_Modbus_Scanner InitializeComponent(); + Label_DeviceName.Text = device.name; + Label_Description.Text = device.description; + DGV_Device.SelectionMode = DataGridViewSelectionMode.FullRowSelect; DGV_Device.MultiSelect = false; DGV_Device.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders; @@ -72,10 +76,16 @@ namespace Gidrolock_Modbus_Scanner { while (!closed) { - for (int i = 0; i < entries.Count; i++) + if (isPolling) { - activeEntryIndex = i; - await PollForEntry(entries[i]); + for (int i = 0; i < entries.Count; i++) + { + // TODO: figure out how to get the checkbox value out of DataGridView cells; + // holy fuck DGV is awful + activeEntryIndex = i; + await PollForEntry(entries[i]); + + } } } } @@ -112,33 +122,26 @@ namespace Gidrolock_Modbus_Scanner isAwaitingResponse = false; try - { - - byte length = e.message[2]; - Console.WriteLine("Data length is:" + length); - byte[] data = new byte[length]; - for (int i = 0; i < length; i++) - data[i] = e.message[i + 3]; - - Console.WriteLine("Data after processing in Datasheet.cs: " + Modbus.ByteArrayToString(data)); + { + Console.WriteLine("Data after processing in Datasheet.cs: " + Modbus.ByteArrayToString(e.Data)); switch (entries[activeEntryIndex].dataType) { case ("bool"): - DGV_Device.Rows[activeEntryIndex].Cells[2].Value = data[0] > 0x00 ? "true" : "false"; + DGV_Device.Rows[activeEntryIndex].Cells[2].Value = e.Data[0] > 0x00 ? "true" : "false"; break; case ("uint16"): - Array.Reverse(data); // BitConverter.ToUInt is is little endian, I guess, so we need to flip the array - ushort test = BitConverter.ToUInt16(data, 0); + Array.Reverse(e.Data); // BitConverter.ToUInt is is little endian, I guess, so we need to flip the array + ushort test = BitConverter.ToUInt16(e.Data, 0); Console.WriteLine("ushort parsed value: " + test); DGV_Device.Rows[activeEntryIndex].Cells[2].Value = test; break; case ("uint32"): - Array.Reverse(data); - DGV_Device.Rows[activeEntryIndex].Cells[2].Value = BitConverter.ToUInt32(data, 0); + Array.Reverse(e.Data); + DGV_Device.Rows[activeEntryIndex].Cells[2].Value = BitConverter.ToUInt32(e.Data, 0); break; case ("utf8"): - DGV_Device.Rows[activeEntryIndex].Cells[2].Value = System.Text.Encoding.UTF8.GetString(data); + DGV_Device.Rows[activeEntryIndex].Cells[2].Value = System.Text.Encoding.UTF8.GetString(e.Data); break; default: MessageBox.Show("Wrong data type set for entry " + entries[activeEntryIndex].name); @@ -156,6 +159,12 @@ namespace Gidrolock_Modbus_Scanner } } + + private void Button_StartStop_Click(object sender, EventArgs e) + { + isPolling = !isPolling; + Button_StartStop.Text = (isPolling ? "Стоп" : "Старт"); + } } } \ No newline at end of file diff --git a/Main.Designer.cs b/Main.Designer.cs index 09fad74..020a814 100644 --- a/Main.Designer.cs +++ b/Main.Designer.cs @@ -29,6 +29,41 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(App)); + this.Button_Connect = new System.Windows.Forms.Button(); + this.TextBox_Log = new System.Windows.Forms.TextBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.panel6 = new System.Windows.Forms.Panel(); + this.UpDown_Value = new System.Windows.Forms.NumericUpDown(); + this.label6 = new System.Windows.Forms.Label(); + this.panel5 = new System.Windows.Forms.Panel(); + this.UpDown_RegLength = new System.Windows.Forms.NumericUpDown(); + this.label5 = new System.Windows.Forms.Label(); + this.Button_SendCommand = new System.Windows.Forms.Button(); + this.panel3 = new System.Windows.Forms.Panel(); + this.UpDown_RegAddress = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.panel4 = new System.Windows.Forms.Panel(); + this.CBox_Function = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.Label_ConfigTip = new System.Windows.Forms.Label(); + this.Button_LoadConfig = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.Label_ConfPath = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.Radio_Ethernet = new System.Windows.Forms.RadioButton(); + this.Radio_SerialPort = new System.Windows.Forms.RadioButton(); + this.GBox_Ethernet = new System.Windows.Forms.GroupBox(); + this.panel16 = new System.Windows.Forms.Panel(); + this.TBox_Port = new System.Windows.Forms.TextBox(); + this.label16 = new System.Windows.Forms.Label(); + this.panel17 = new System.Windows.Forms.Panel(); + this.TBox_Timeout = new System.Windows.Forms.TextBox(); + this.label17 = new System.Windows.Forms.Label(); + this.panel18 = new System.Windows.Forms.Panel(); + this.TBox_IP = new System.Windows.Forms.TextBox(); + this.label18 = new System.Windows.Forms.Label(); this.GBox_Serial = new System.Windows.Forms.GroupBox(); this.panel11 = new System.Windows.Forms.Panel(); this.CBox_Parity = new System.Windows.Forms.ComboBox(); @@ -51,41 +86,20 @@ this.panel1 = new System.Windows.Forms.Panel(); this.CBox_Ports = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); - this.Button_Connect = new System.Windows.Forms.Button(); - this.TextBox_Log = new System.Windows.Forms.TextBox(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.panel6 = new System.Windows.Forms.Panel(); - this.UpDown_Value = new System.Windows.Forms.NumericUpDown(); - this.label6 = new System.Windows.Forms.Label(); - this.panel5 = new System.Windows.Forms.Panel(); - this.UpDown_RegLength = new System.Windows.Forms.NumericUpDown(); - this.label5 = new System.Windows.Forms.Label(); - this.Button_SendCommand = new System.Windows.Forms.Button(); - this.panel3 = new System.Windows.Forms.Panel(); - this.UpDown_RegAddress = new System.Windows.Forms.NumericUpDown(); - this.label3 = new System.Windows.Forms.Label(); - this.panel4 = new System.Windows.Forms.Panel(); - this.CBox_Function = new System.Windows.Forms.ComboBox(); - this.label4 = new System.Windows.Forms.Label(); - this.GBox_Ethernet = new System.Windows.Forms.GroupBox(); - this.panel16 = new System.Windows.Forms.Panel(); - this.TBox_Port = new System.Windows.Forms.TextBox(); - this.label16 = new System.Windows.Forms.Label(); - this.panel17 = new System.Windows.Forms.Panel(); - this.TBox_Timeout = new System.Windows.Forms.TextBox(); - this.label17 = new System.Windows.Forms.Label(); - this.panel18 = new System.Windows.Forms.Panel(); - this.TBox_IP = new System.Windows.Forms.TextBox(); - this.label18 = new System.Windows.Forms.Label(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.Radio_Ethernet = new System.Windows.Forms.RadioButton(); - this.Radio_SerialPort = new System.Windows.Forms.RadioButton(); - this.Label_ConfigTip = new System.Windows.Forms.Label(); - this.Button_LoadConfig = new System.Windows.Forms.Button(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.Label_ConfPath = new System.Windows.Forms.Label(); - this.button1 = new System.Windows.Forms.Button(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.groupBox2.SuspendLayout(); + this.panel6.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.UpDown_Value)).BeginInit(); + this.panel5.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegLength)).BeginInit(); + this.panel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegAddress)).BeginInit(); + this.panel4.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.GBox_Ethernet.SuspendLayout(); + this.panel16.SuspendLayout(); + this.panel17.SuspendLayout(); + this.panel18.SuspendLayout(); this.GBox_Serial.SuspendLayout(); this.panel11.SuspendLayout(); this.panel10.SuspendLayout(); @@ -95,22 +109,339 @@ this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.UpDown_ModbusID)).BeginInit(); this.panel1.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.panel6.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.UpDown_Value)).BeginInit(); - this.panel5.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegLength)).BeginInit(); - this.panel3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegAddress)).BeginInit(); - this.panel4.SuspendLayout(); - this.GBox_Ethernet.SuspendLayout(); - this.panel16.SuspendLayout(); - this.panel17.SuspendLayout(); - this.panel18.SuspendLayout(); - this.groupBox4.SuspendLayout(); - this.groupBox1.SuspendLayout(); this.SuspendLayout(); // + // Button_Connect + // + this.Button_Connect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Button_Connect.Location = new System.Drawing.Point(402, 238); + this.Button_Connect.Name = "Button_Connect"; + this.Button_Connect.Size = new System.Drawing.Size(108, 25); + this.Button_Connect.TabIndex = 4; + this.Button_Connect.Text = "Подключиться"; + this.Button_Connect.UseVisualStyleBackColor = true; + this.Button_Connect.Click += new System.EventHandler(this.ButtonConnect_Click); + // + // TextBox_Log + // + this.TextBox_Log.Location = new System.Drawing.Point(12, 269); + this.TextBox_Log.Multiline = true; + this.TextBox_Log.Name = "TextBox_Log"; + this.TextBox_Log.ReadOnly = true; + this.TextBox_Log.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.TextBox_Log.Size = new System.Drawing.Size(498, 118); + this.TextBox_Log.TabIndex = 1; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.panel6); + this.groupBox2.Controls.Add(this.panel5); + this.groupBox2.Controls.Add(this.Button_SendCommand); + this.groupBox2.Controls.Add(this.panel3); + this.groupBox2.Controls.Add(this.panel4); + this.groupBox2.Location = new System.Drawing.Point(12, 393); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(498, 63); + this.groupBox2.TabIndex = 5; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Команды"; + // + // panel6 + // + this.panel6.Controls.Add(this.UpDown_Value); + this.panel6.Controls.Add(this.label6); + this.panel6.Location = new System.Drawing.Point(337, 20); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(75, 43); + this.panel6.TabIndex = 4; + // + // UpDown_Value + // + this.UpDown_Value.Location = new System.Drawing.Point(6, 17); + this.UpDown_Value.Name = "UpDown_Value"; + this.UpDown_Value.Size = new System.Drawing.Size(66, 20); + this.UpDown_Value.TabIndex = 1; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(3, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(55, 13); + this.label6.TabIndex = 0; + this.label6.Text = "Значение"; + // + // panel5 + // + this.panel5.Controls.Add(this.UpDown_RegLength); + this.panel5.Controls.Add(this.label5); + this.panel5.Location = new System.Drawing.Point(259, 20); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(75, 43); + this.panel5.TabIndex = 3; + // + // UpDown_RegLength + // + this.UpDown_RegLength.Location = new System.Drawing.Point(6, 17); + this.UpDown_RegLength.Name = "UpDown_RegLength"; + this.UpDown_RegLength.Size = new System.Drawing.Size(66, 20); + this.UpDown_RegLength.TabIndex = 1; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(3, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(40, 13); + this.label5.TabIndex = 0; + this.label5.Text = "Длина"; + // + // Button_SendCommand + // + this.Button_SendCommand.Location = new System.Drawing.Point(415, 35); + this.Button_SendCommand.Name = "Button_SendCommand"; + this.Button_SendCommand.Size = new System.Drawing.Size(77, 23); + this.Button_SendCommand.TabIndex = 4; + this.Button_SendCommand.Text = "Отправить"; + this.Button_SendCommand.UseVisualStyleBackColor = true; + this.Button_SendCommand.Click += new System.EventHandler(this.Button_SendCommand_Click); + // + // panel3 + // + this.panel3.Controls.Add(this.UpDown_RegAddress); + this.panel3.Controls.Add(this.label3); + this.panel3.Location = new System.Drawing.Point(162, 20); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(91, 43); + this.panel3.TabIndex = 2; + // + // UpDown_RegAddress + // + this.UpDown_RegAddress.Location = new System.Drawing.Point(6, 17); + this.UpDown_RegAddress.Name = "UpDown_RegAddress"; + this.UpDown_RegAddress.Size = new System.Drawing.Size(82, 20); + this.UpDown_RegAddress.TabIndex = 1; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(3, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 13); + this.label3.TabIndex = 0; + this.label3.Text = "Адрес"; + // + // panel4 + // + this.panel4.Controls.Add(this.CBox_Function); + this.panel4.Controls.Add(this.label4); + this.panel4.Location = new System.Drawing.Point(0, 20); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(156, 43); + this.panel4.TabIndex = 0; + // + // CBox_Function + // + this.CBox_Function.FormattingEnabled = true; + this.CBox_Function.Location = new System.Drawing.Point(6, 17); + this.CBox_Function.Name = "CBox_Function"; + this.CBox_Function.Size = new System.Drawing.Size(147, 21); + this.CBox_Function.TabIndex = 1; + this.CBox_Function.Text = "01 - Read Coil"; + this.CBox_Function.SelectedIndexChanged += new System.EventHandler(this.OnSelectedFunctionChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(3, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(53, 13); + this.label4.TabIndex = 0; + this.label4.Text = "Функция"; + // + // Label_ConfigTip + // + this.Label_ConfigTip.AutoSize = true; + this.Label_ConfigTip.Location = new System.Drawing.Point(8, 16); + this.Label_ConfigTip.Name = "Label_ConfigTip"; + this.Label_ConfigTip.Size = new System.Drawing.Size(94, 13); + this.Label_ConfigTip.TabIndex = 10; + this.Label_ConfigTip.Text = "Выбранный путь:"; + // + // Button_LoadConfig + // + this.Button_LoadConfig.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Button_LoadConfig.Location = new System.Drawing.Point(415, 43); + this.Button_LoadConfig.Name = "Button_LoadConfig"; + this.Button_LoadConfig.Size = new System.Drawing.Size(77, 25); + this.Button_LoadConfig.TabIndex = 11; + this.Button_LoadConfig.Text = "Файл"; + this.Button_LoadConfig.UseVisualStyleBackColor = true; + this.Button_LoadConfig.Click += new System.EventHandler(this.LoadConfig); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.Label_ConfPath); + this.groupBox1.Controls.Add(this.button1); + this.groupBox1.Controls.Add(this.Button_LoadConfig); + this.groupBox1.Controls.Add(this.Label_ConfigTip); + this.groupBox1.Location = new System.Drawing.Point(12, 158); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(498, 74); + this.groupBox1.TabIndex = 13; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Конфигурация"; + // + // Label_ConfPath + // + this.Label_ConfPath.Location = new System.Drawing.Point(9, 29); + this.Label_ConfPath.Name = "Label_ConfPath"; + this.Label_ConfPath.Size = new System.Drawing.Size(400, 39); + this.Label_ConfPath.TabIndex = 14; + this.Label_ConfPath.Text = "Файл не выбран."; + this.Label_ConfPath.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(415, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(77, 25); + this.button1.TabIndex = 13; + this.button1.Text = "Папка"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.LoadFolder); + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(13, 238); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(383, 25); + this.progressBar1.TabIndex = 14; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.Radio_Ethernet); + this.groupBox4.Controls.Add(this.Radio_SerialPort); + this.groupBox4.Location = new System.Drawing.Point(349, 85); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(161, 65); + this.groupBox4.TabIndex = 17; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "Режим"; + // + // Radio_Ethernet + // + this.Radio_Ethernet.AutoSize = true; + this.Radio_Ethernet.Location = new System.Drawing.Point(7, 37); + this.Radio_Ethernet.Name = "Radio_Ethernet"; + this.Radio_Ethernet.Size = new System.Drawing.Size(65, 17); + this.Radio_Ethernet.TabIndex = 1; + this.Radio_Ethernet.TabStop = true; + this.Radio_Ethernet.Text = "Ethernet"; + this.Radio_Ethernet.UseVisualStyleBackColor = true; + // + // Radio_SerialPort + // + this.Radio_SerialPort.AutoSize = true; + this.Radio_SerialPort.Location = new System.Drawing.Point(7, 20); + this.Radio_SerialPort.Name = "Radio_SerialPort"; + this.Radio_SerialPort.Size = new System.Drawing.Size(102, 17); + this.Radio_SerialPort.TabIndex = 0; + this.Radio_SerialPort.TabStop = true; + this.Radio_SerialPort.Text = "Серийный порт"; + this.Radio_SerialPort.UseVisualStyleBackColor = true; + // + // GBox_Ethernet + // + this.GBox_Ethernet.Controls.Add(this.panel16); + this.GBox_Ethernet.Controls.Add(this.panel17); + this.GBox_Ethernet.Controls.Add(this.panel18); + this.GBox_Ethernet.Location = new System.Drawing.Point(12, 85); + this.GBox_Ethernet.Name = "GBox_Ethernet"; + this.GBox_Ethernet.Size = new System.Drawing.Size(334, 65); + this.GBox_Ethernet.TabIndex = 16; + this.GBox_Ethernet.TabStop = false; + this.GBox_Ethernet.Text = "Ethernet"; + // + // panel16 + // + this.panel16.Controls.Add(this.TBox_Port); + this.panel16.Controls.Add(this.label16); + this.panel16.Location = new System.Drawing.Point(175, 19); + this.panel16.Name = "panel16"; + this.panel16.Size = new System.Drawing.Size(75, 43); + this.panel16.TabIndex = 3; + // + // TBox_Port + // + this.TBox_Port.Location = new System.Drawing.Point(6, 17); + this.TBox_Port.Name = "TBox_Port"; + this.TBox_Port.Size = new System.Drawing.Size(66, 20); + this.TBox_Port.TabIndex = 1; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(3, 0); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(32, 13); + this.label16.TabIndex = 0; + this.label16.Text = "Порт"; + // + // panel17 + // + this.panel17.Controls.Add(this.TBox_Timeout); + this.panel17.Controls.Add(this.label17); + this.panel17.Location = new System.Drawing.Point(253, 19); + this.panel17.Name = "panel17"; + this.panel17.Size = new System.Drawing.Size(75, 43); + this.panel17.TabIndex = 2; + // + // TBox_Timeout + // + this.TBox_Timeout.Location = new System.Drawing.Point(6, 17); + this.TBox_Timeout.Name = "TBox_Timeout"; + this.TBox_Timeout.Size = new System.Drawing.Size(66, 20); + this.TBox_Timeout.TabIndex = 2; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(3, 0); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(74, 13); + this.label17.TabIndex = 0; + this.label17.Text = "Таймаут, сек"; + // + // panel18 + // + this.panel18.Controls.Add(this.TBox_IP); + this.panel18.Controls.Add(this.label18); + this.panel18.Location = new System.Drawing.Point(0, 19); + this.panel18.Name = "panel18"; + this.panel18.Size = new System.Drawing.Size(172, 43); + this.panel18.TabIndex = 0; + // + // TBox_IP + // + this.TBox_IP.Location = new System.Drawing.Point(6, 17); + this.TBox_IP.Name = "TBox_IP"; + this.TBox_IP.Size = new System.Drawing.Size(163, 20); + this.TBox_IP.TabIndex = 1; + // + // label18 + // + this.label18.AutoSize = true; + this.label18.Location = new System.Drawing.Point(3, 0); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(50, 13); + this.label18.TabIndex = 0; + this.label18.Text = "IP адрес"; + // // GBox_Serial // this.GBox_Serial.Controls.Add(this.panel11); @@ -119,10 +450,10 @@ this.GBox_Serial.Controls.Add(this.panel7); this.GBox_Serial.Controls.Add(this.panel2); this.GBox_Serial.Controls.Add(this.panel1); - this.GBox_Serial.Location = new System.Drawing.Point(12, 92); + this.GBox_Serial.Location = new System.Drawing.Point(12, 12); this.GBox_Serial.Name = "GBox_Serial"; - this.GBox_Serial.Size = new System.Drawing.Size(490, 65); - this.GBox_Serial.TabIndex = 0; + this.GBox_Serial.Size = new System.Drawing.Size(498, 67); + this.GBox_Serial.TabIndex = 15; this.GBox_Serial.TabStop = false; this.GBox_Serial.Text = "Серийный порт"; // @@ -266,7 +597,7 @@ // this.panel2.Controls.Add(this.UpDown_ModbusID); this.panel2.Controls.Add(this.label2); - this.panel2.Location = new System.Drawing.Point(415, 19); + this.panel2.Location = new System.Drawing.Point(417, 19); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(75, 43); this.panel2.TabIndex = 2; @@ -304,7 +635,6 @@ this.CBox_Ports.Size = new System.Drawing.Size(65, 21); this.CBox_Ports.TabIndex = 1; this.CBox_Ports.Text = "COM1"; - this.CBox_Ports.MouseClick += new System.Windows.Forms.MouseEventHandler(this.CBox_Ports_Click); // // label1 // @@ -315,358 +645,50 @@ this.label1.TabIndex = 0; this.label1.Text = "Порт"; // - // Button_Connect - // - this.Button_Connect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.Button_Connect.Location = new System.Drawing.Point(402, 235); - this.Button_Connect.Name = "Button_Connect"; - this.Button_Connect.Size = new System.Drawing.Size(100, 25); - this.Button_Connect.TabIndex = 4; - this.Button_Connect.Text = "Подключиться"; - this.Button_Connect.UseVisualStyleBackColor = true; - this.Button_Connect.Click += new System.EventHandler(this.ButtonConnect_Click); - // - // TextBox_Log - // - this.TextBox_Log.Location = new System.Drawing.Point(12, 269); - this.TextBox_Log.Multiline = true; - this.TextBox_Log.Name = "TextBox_Log"; - this.TextBox_Log.ReadOnly = true; - this.TextBox_Log.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.TextBox_Log.Size = new System.Drawing.Size(490, 118); - this.TextBox_Log.TabIndex = 1; - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.panel6); - this.groupBox2.Controls.Add(this.panel5); - this.groupBox2.Controls.Add(this.Button_SendCommand); - this.groupBox2.Controls.Add(this.panel3); - this.groupBox2.Controls.Add(this.panel4); - this.groupBox2.Location = new System.Drawing.Point(12, 393); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(490, 63); - this.groupBox2.TabIndex = 5; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Команды"; - // - // panel6 - // - this.panel6.Controls.Add(this.UpDown_Value); - this.panel6.Controls.Add(this.label6); - this.panel6.Location = new System.Drawing.Point(337, 20); - this.panel6.Name = "panel6"; - this.panel6.Size = new System.Drawing.Size(75, 43); - this.panel6.TabIndex = 4; - // - // UpDown_Value - // - this.UpDown_Value.Location = new System.Drawing.Point(6, 17); - this.UpDown_Value.Name = "UpDown_Value"; - this.UpDown_Value.Size = new System.Drawing.Size(66, 20); - this.UpDown_Value.TabIndex = 1; - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(3, 0); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(55, 13); - this.label6.TabIndex = 0; - this.label6.Text = "Значение"; - // - // panel5 - // - this.panel5.Controls.Add(this.UpDown_RegLength); - this.panel5.Controls.Add(this.label5); - this.panel5.Location = new System.Drawing.Point(259, 20); - this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(75, 43); - this.panel5.TabIndex = 3; - // - // UpDown_RegLength - // - this.UpDown_RegLength.Location = new System.Drawing.Point(6, 17); - this.UpDown_RegLength.Name = "UpDown_RegLength"; - this.UpDown_RegLength.Size = new System.Drawing.Size(66, 20); - this.UpDown_RegLength.TabIndex = 1; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(3, 0); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(40, 13); - this.label5.TabIndex = 0; - this.label5.Text = "Длина"; - // - // Button_SendCommand - // - this.Button_SendCommand.Location = new System.Drawing.Point(415, 35); - this.Button_SendCommand.Name = "Button_SendCommand"; - this.Button_SendCommand.Size = new System.Drawing.Size(71, 23); - this.Button_SendCommand.TabIndex = 4; - this.Button_SendCommand.Text = "Отправить"; - this.Button_SendCommand.UseVisualStyleBackColor = true; - this.Button_SendCommand.Click += new System.EventHandler(this.Button_SendCommand_Click); - // - // panel3 - // - this.panel3.Controls.Add(this.UpDown_RegAddress); - this.panel3.Controls.Add(this.label3); - this.panel3.Location = new System.Drawing.Point(162, 20); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(91, 43); - this.panel3.TabIndex = 2; - // - // UpDown_RegAddress - // - this.UpDown_RegAddress.Location = new System.Drawing.Point(6, 17); - this.UpDown_RegAddress.Name = "UpDown_RegAddress"; - this.UpDown_RegAddress.Size = new System.Drawing.Size(82, 20); - this.UpDown_RegAddress.TabIndex = 1; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 0); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 13); - this.label3.TabIndex = 0; - this.label3.Text = "Адрес"; - // - // panel4 - // - this.panel4.Controls.Add(this.CBox_Function); - this.panel4.Controls.Add(this.label4); - this.panel4.Location = new System.Drawing.Point(0, 20); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(156, 43); - this.panel4.TabIndex = 0; - // - // CBox_Function - // - this.CBox_Function.FormattingEnabled = true; - this.CBox_Function.Location = new System.Drawing.Point(6, 17); - this.CBox_Function.Name = "CBox_Function"; - this.CBox_Function.Size = new System.Drawing.Size(147, 21); - this.CBox_Function.TabIndex = 1; - this.CBox_Function.Text = "01 - Read Coil"; - this.CBox_Function.SelectedIndexChanged += new System.EventHandler(this.OnSelectedFunctionChanged); - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(3, 0); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(53, 13); - this.label4.TabIndex = 0; - this.label4.Text = "Функция"; - // - // GBox_Ethernet - // - this.GBox_Ethernet.Controls.Add(this.panel16); - this.GBox_Ethernet.Controls.Add(this.panel17); - this.GBox_Ethernet.Controls.Add(this.panel18); - this.GBox_Ethernet.Location = new System.Drawing.Point(12, 162); - this.GBox_Ethernet.Name = "GBox_Ethernet"; - this.GBox_Ethernet.Size = new System.Drawing.Size(334, 65); - this.GBox_Ethernet.TabIndex = 6; - this.GBox_Ethernet.TabStop = false; - this.GBox_Ethernet.Text = "Ethernet"; - // - // panel16 - // - this.panel16.Controls.Add(this.TBox_Port); - this.panel16.Controls.Add(this.label16); - this.panel16.Location = new System.Drawing.Point(175, 19); - this.panel16.Name = "panel16"; - this.panel16.Size = new System.Drawing.Size(75, 43); - this.panel16.TabIndex = 3; - // - // TBox_Port - // - this.TBox_Port.Location = new System.Drawing.Point(6, 17); - this.TBox_Port.Name = "TBox_Port"; - this.TBox_Port.Size = new System.Drawing.Size(66, 20); - this.TBox_Port.TabIndex = 1; - // - // label16 - // - this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(3, 0); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(32, 13); - this.label16.TabIndex = 0; - this.label16.Text = "Порт"; - // - // panel17 - // - this.panel17.Controls.Add(this.TBox_Timeout); - this.panel17.Controls.Add(this.label17); - this.panel17.Location = new System.Drawing.Point(253, 19); - this.panel17.Name = "panel17"; - this.panel17.Size = new System.Drawing.Size(75, 43); - this.panel17.TabIndex = 2; - // - // TBox_Timeout - // - this.TBox_Timeout.Location = new System.Drawing.Point(6, 17); - this.TBox_Timeout.Name = "TBox_Timeout"; - this.TBox_Timeout.Size = new System.Drawing.Size(66, 20); - this.TBox_Timeout.TabIndex = 2; - // - // label17 - // - this.label17.AutoSize = true; - this.label17.Location = new System.Drawing.Point(3, 0); - this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(74, 13); - this.label17.TabIndex = 0; - this.label17.Text = "Таймаут, сек"; - // - // panel18 - // - this.panel18.Controls.Add(this.TBox_IP); - this.panel18.Controls.Add(this.label18); - this.panel18.Location = new System.Drawing.Point(0, 19); - this.panel18.Name = "panel18"; - this.panel18.Size = new System.Drawing.Size(172, 43); - this.panel18.TabIndex = 0; - // - // TBox_IP - // - this.TBox_IP.Location = new System.Drawing.Point(6, 17); - this.TBox_IP.Name = "TBox_IP"; - this.TBox_IP.Size = new System.Drawing.Size(163, 20); - this.TBox_IP.TabIndex = 1; - // - // label18 - // - this.label18.AutoSize = true; - this.label18.Location = new System.Drawing.Point(3, 0); - this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(50, 13); - this.label18.TabIndex = 0; - this.label18.Text = "IP адрес"; - // - // groupBox4 - // - this.groupBox4.Controls.Add(this.Radio_Ethernet); - this.groupBox4.Controls.Add(this.Radio_SerialPort); - this.groupBox4.Location = new System.Drawing.Point(348, 162); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(154, 65); - this.groupBox4.TabIndex = 7; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "Режим"; - // - // Radio_Ethernet - // - this.Radio_Ethernet.AutoSize = true; - this.Radio_Ethernet.Location = new System.Drawing.Point(7, 37); - this.Radio_Ethernet.Name = "Radio_Ethernet"; - this.Radio_Ethernet.Size = new System.Drawing.Size(65, 17); - this.Radio_Ethernet.TabIndex = 1; - this.Radio_Ethernet.TabStop = true; - this.Radio_Ethernet.Text = "Ethernet"; - this.Radio_Ethernet.UseVisualStyleBackColor = true; - this.Radio_Ethernet.CheckedChanged += new System.EventHandler(this.Radio_Ethernet_CheckedChanged); - // - // Radio_SerialPort - // - this.Radio_SerialPort.AutoSize = true; - this.Radio_SerialPort.Location = new System.Drawing.Point(7, 20); - this.Radio_SerialPort.Name = "Radio_SerialPort"; - this.Radio_SerialPort.Size = new System.Drawing.Size(102, 17); - this.Radio_SerialPort.TabIndex = 0; - this.Radio_SerialPort.TabStop = true; - this.Radio_SerialPort.Text = "Серийный порт"; - this.Radio_SerialPort.UseVisualStyleBackColor = true; - this.Radio_SerialPort.CheckedChanged += new System.EventHandler(this.Radio_SerialPort_CheckedChanged); - // - // Label_ConfigTip - // - this.Label_ConfigTip.AutoSize = true; - this.Label_ConfigTip.Location = new System.Drawing.Point(8, 16); - this.Label_ConfigTip.Name = "Label_ConfigTip"; - this.Label_ConfigTip.Size = new System.Drawing.Size(94, 13); - this.Label_ConfigTip.TabIndex = 10; - this.Label_ConfigTip.Text = "Выбранный путь:"; - // - // Button_LoadConfig - // - this.Button_LoadConfig.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.Button_LoadConfig.Location = new System.Drawing.Point(415, 43); - this.Button_LoadConfig.Name = "Button_LoadConfig"; - this.Button_LoadConfig.Size = new System.Drawing.Size(69, 25); - this.Button_LoadConfig.TabIndex = 11; - this.Button_LoadConfig.Text = "Файл"; - this.Button_LoadConfig.UseVisualStyleBackColor = true; - this.Button_LoadConfig.Click += new System.EventHandler(this.LoadConfig); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.Label_ConfPath); - this.groupBox1.Controls.Add(this.button1); - this.groupBox1.Controls.Add(this.Button_LoadConfig); - this.groupBox1.Controls.Add(this.Label_ConfigTip); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(490, 74); - this.groupBox1.TabIndex = 13; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Конфигурация"; - // - // Label_ConfPath - // - this.Label_ConfPath.Location = new System.Drawing.Point(9, 29); - this.Label_ConfPath.Name = "Label_ConfPath"; - this.Label_ConfPath.Size = new System.Drawing.Size(400, 39); - this.Label_ConfPath.TabIndex = 14; - this.Label_ConfPath.Text = "Файл не выбран."; - this.Label_ConfPath.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(415, 12); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(69, 25); - this.button1.TabIndex = 13; - this.button1.Text = "Папка"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.LoadFolder); - // - // progressBar1 - // - this.progressBar1.Location = new System.Drawing.Point(13, 235); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(383, 25); - this.progressBar1.TabIndex = 14; - // // App // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(514, 467); - this.Controls.Add(this.progressBar1); - this.Controls.Add(this.groupBox1); + this.ClientSize = new System.Drawing.Size(522, 467); this.Controls.Add(this.groupBox4); this.Controls.Add(this.GBox_Ethernet); + this.Controls.Add(this.GBox_Serial); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox2); this.Controls.Add(this.TextBox_Log); - this.Controls.Add(this.GBox_Serial); this.Controls.Add(this.Button_Connect); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.Name = "App"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.Text = "Gidrolock Modbus Scanner"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.App_FormClosed); this.Load += new System.EventHandler(this.Form1_Load); + this.groupBox2.ResumeLayout(false); + this.panel6.ResumeLayout(false); + this.panel6.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.UpDown_Value)).EndInit(); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegLength)).EndInit(); + this.panel3.ResumeLayout(false); + this.panel3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegAddress)).EndInit(); + this.panel4.ResumeLayout(false); + this.panel4.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + this.GBox_Ethernet.ResumeLayout(false); + this.panel16.ResumeLayout(false); + this.panel16.PerformLayout(); + this.panel17.ResumeLayout(false); + this.panel17.PerformLayout(); + this.panel18.ResumeLayout(false); + this.panel18.PerformLayout(); this.GBox_Serial.ResumeLayout(false); this.panel11.ResumeLayout(false); this.panel11.PerformLayout(); @@ -683,43 +705,12 @@ ((System.ComponentModel.ISupportInitialize)(this.UpDown_ModbusID)).EndInit(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.panel6.ResumeLayout(false); - this.panel6.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.UpDown_Value)).EndInit(); - this.panel5.ResumeLayout(false); - this.panel5.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegLength)).EndInit(); - this.panel3.ResumeLayout(false); - this.panel3.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.UpDown_RegAddress)).EndInit(); - this.panel4.ResumeLayout(false); - this.panel4.PerformLayout(); - this.GBox_Ethernet.ResumeLayout(false); - this.panel16.ResumeLayout(false); - this.panel16.PerformLayout(); - this.panel17.ResumeLayout(false); - this.panel17.PerformLayout(); - this.panel18.ResumeLayout(false); - this.panel18.PerformLayout(); - this.groupBox4.ResumeLayout(false); - this.groupBox4.PerformLayout(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion - - private System.Windows.Forms.GroupBox GBox_Serial; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.NumericUpDown UpDown_ModbusID; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.ComboBox CBox_Ports; - private System.Windows.Forms.Label label1; private System.Windows.Forms.Button Button_Connect; private System.Windows.Forms.TextBox TextBox_Log; private System.Windows.Forms.GroupBox groupBox2; @@ -736,40 +727,47 @@ private System.Windows.Forms.Panel panel6; private System.Windows.Forms.NumericUpDown UpDown_Value; private System.Windows.Forms.Label label6; - private System.Windows.Forms.Panel panel7; - private System.Windows.Forms.ComboBox CBox_BaudRate; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Panel panel8; - private System.Windows.Forms.ComboBox CBox_DataBits; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.Panel panel10; - private System.Windows.Forms.ComboBox CBox_StopBits; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Panel panel9; - private System.Windows.Forms.ComboBox comboBox1; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.Panel panel11; - private System.Windows.Forms.ComboBox CBox_Parity; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.GroupBox GBox_Ethernet; - private System.Windows.Forms.Panel panel16; - private System.Windows.Forms.Label label16; - private System.Windows.Forms.Panel panel17; - private System.Windows.Forms.Label label17; - private System.Windows.Forms.Panel panel18; - private System.Windows.Forms.Label label18; - private System.Windows.Forms.TextBox TBox_Port; - private System.Windows.Forms.TextBox TBox_Timeout; - private System.Windows.Forms.TextBox TBox_IP; - private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.RadioButton Radio_Ethernet; - private System.Windows.Forms.RadioButton Radio_SerialPort; private System.Windows.Forms.Label Label_ConfigTip; private System.Windows.Forms.Button Button_LoadConfig; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label Label_ConfPath; private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.RadioButton Radio_Ethernet; + private System.Windows.Forms.RadioButton Radio_SerialPort; + private System.Windows.Forms.GroupBox GBox_Ethernet; + private System.Windows.Forms.Panel panel16; + private System.Windows.Forms.TextBox TBox_Port; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Panel panel17; + private System.Windows.Forms.TextBox TBox_Timeout; + private System.Windows.Forms.Label label17; + private System.Windows.Forms.Panel panel18; + private System.Windows.Forms.TextBox TBox_IP; + private System.Windows.Forms.Label label18; + private System.Windows.Forms.GroupBox GBox_Serial; + private System.Windows.Forms.Panel panel11; + private System.Windows.Forms.ComboBox CBox_Parity; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Panel panel10; + private System.Windows.Forms.ComboBox CBox_StopBits; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Panel panel8; + private System.Windows.Forms.Panel panel9; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.ComboBox CBox_DataBits; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Panel panel7; + private System.Windows.Forms.ComboBox CBox_BaudRate; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.NumericUpDown UpDown_ModbusID; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.ComboBox CBox_Ports; + private System.Windows.Forms.Label label1; } } diff --git a/Main.cs b/Main.cs index 88cff07..c3386af 100644 --- a/Main.cs +++ b/Main.cs @@ -43,6 +43,8 @@ namespace Gidrolock_Modbus_Scanner string[] configs; public byte[] latestMessage; + + DateTime dateTime; #region Initialization public App() { @@ -57,14 +59,14 @@ namespace Gidrolock_Modbus_Scanner this.UpDown_ModbusID.Value = 30; TextBox_Log.Text = "Приложение готово к работе."; - CBox_Function.Items.Add("01 - Read Coil"); - CBox_Function.Items.Add("02 - Read Discrete Input"); - CBox_Function.Items.Add("03 - Read Holding Register"); - CBox_Function.Items.Add("04 - Read Input Register"); - CBox_Function.Items.Add("05 - Write Single Coil"); - CBox_Function.Items.Add("06 - Write Single Register"); - CBox_Function.Items.Add("0F - Write Multiple Coils"); - CBox_Function.Items.Add("10 - Write Multiple Registers"); + CBox_Function.Items.Add("01 Read Coil"); + CBox_Function.Items.Add("02 Read Discrete Input"); + CBox_Function.Items.Add("03 Read Holding Register"); + CBox_Function.Items.Add("04 Read Input Register"); + CBox_Function.Items.Add("05 Write Single Coil"); + CBox_Function.Items.Add("06 Write Single Register"); + CBox_Function.Items.Add("0F Write Multiple Coils"); + CBox_Function.Items.Add("10 Write Multiple Registers"); CBox_Function.SelectedItem = CBox_Function.Items[0]; CBox_BaudRate.Items.Add("110"); @@ -231,6 +233,7 @@ namespace Gidrolock_Modbus_Scanner private async void ButtonConnect_Click(object sender, EventArgs e) { + progressBar1.Value = 0; if (path == String.Empty) { MessageBox.Show("Выберите конфигурацию для подключения и опроса устройства."); @@ -264,6 +267,17 @@ namespace Gidrolock_Modbus_Scanner /* - Checking - */ if (selectedPath == SelectedPath.File) { + AddLog("Попытка подключиться к устройству " + device.name); + try + { + datasheet = new Datasheet((byte)UpDown_ModbusID.Value); + datasheet.Show(); + } + catch (Exception err) + { + MessageBox.Show(err.Message); + } + var fileContent = string.Empty; var filePath = string.Empty; //Read the contents of the file into a stream @@ -273,6 +287,7 @@ namespace Gidrolock_Modbus_Scanner { fileContent = reader.ReadToEnd(); } + progressBar1.Value = 100; try { @@ -334,24 +349,11 @@ namespace Gidrolock_Modbus_Scanner // if device returns a coherent reply, go through expected values associated with the key } - - - AddLog("Попытка подключиться к устройству " + device.name); - try - { - datasheet = new Datasheet((byte)UpDown_ModbusID.Value); - datasheet.Show(); - } - catch (Exception err) - { - MessageBox.Show(err.Message); - } /* if (Radio_SerialPort.Checked) await SendMessageAsync(FunctionCode.InputRegister, 200, 6); //else EthernetParse(); */ - } async void EthernetParse() @@ -389,13 +391,14 @@ namespace Gidrolock_Modbus_Scanner void OnResponseReceived(object sender, ModbusResponseEventArgs e) { isAwaitingResponse = false; - TextBox_Log.Invoke((MethodInvoker)delegate { AddLog("Получен ответ: " + Modbus.ByteArrayToString(e.message)); }); - TextBox_Log.Invoke((MethodInvoker)delegate { AddLog("UTF8: " + Encoding.UTF8.GetString(e.message)); }); + TextBox_Log.Invoke((MethodInvoker)delegate { AddLog("Получен ответ: " + Modbus.ByteArrayToString(e.Message)); }); + TextBox_Log.Invoke((MethodInvoker)delegate { AddLog("UTF-8: " + e.Text); }); } void AddLog(string message) { - TextBox_Log.AppendText(Environment.NewLine + message); + dateTime = DateTime.Now; + TextBox_Log.AppendText(Environment.NewLine + "[" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + "] " + message); } private async void Button_SendCommand_Click(object sender, EventArgs e) @@ -483,6 +486,11 @@ namespace Gidrolock_Modbus_Scanner } UpdatePathLabel(); } + + private void CBox_Ports_Click(object sender, MouseEventArgs e) + { + + } } } diff --git a/Modbus.cs b/Modbus.cs index e970dc5..cd635d0 100644 --- a/Modbus.cs +++ b/Modbus.cs @@ -3,6 +3,7 @@ using System.IO.Ports; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using static System.Net.Mime.MediaTypeNames; namespace Gidrolock_Modbus_Scanner { @@ -208,7 +209,7 @@ namespace Gidrolock_Modbus_Scanner port.DiscardInBuffer(); - ResponseReceived.Invoke(null, new ModbusResponseEventArgs(message)); + ResponseReceived.Invoke(null, new ModbusResponseEventArgs(message, data, Encoding.UTF8.GetString(data))); } catch (Exception err) { @@ -220,10 +221,14 @@ namespace Gidrolock_Modbus_Scanner public class ModbusResponseEventArgs : EventArgs { - public byte[] message { get; set; } - public ModbusResponseEventArgs(byte[] message) + public byte[] Message { get; set; } + public byte[] Data { get; set; } + public string Text { get; set; } + public ModbusResponseEventArgs(byte[] message, byte[] data, string text) { - this.message = message; + this.Message = message; + this.Data = data; + this.Text = text; } }