From 5f26ee8eed659b63ed46e4cb04066403a276aa60 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 22 Jul 2022 11:13:28 +0000 Subject: [PATCH 1/3] Restyled by astyle --- MainForm.Designer.cs | 2324 ++++++++++++++-------------- MainForm.cs | 1916 +++++++++++------------ component/Mqtt/MqttClientHelper.cs | 454 +++--- component/Printer/PrinterHelper.cs | 214 +-- 4 files changed, 2459 insertions(+), 2449 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index e1ece8d..126f187 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -2,289 +2,292 @@ namespace Dgiot_dtu { - partial class MainForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +partial class MainForm +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); + components.Dispose(); } + base.Dispose(disposing); + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.buttonStartStop = new System.Windows.Forms.Button(); - this.textBoxLog = new System.Windows.Forms.TextBox(); - this.checkBoxReconnect = new System.Windows.Forms.CheckBox(); - this.checkBoxDisplayHex = new System.Windows.Forms.CheckBox(); - this.buttonClear = new System.Windows.Forms.Button(); - this.groupBoxSerialPort = new System.Windows.Forms.GroupBox(); - this.comboBoxParity = new System.Windows.Forms.ComboBox(); - this.label13 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.comboBoxStopBits = new System.Windows.Forms.ComboBox(); - this.comboBoxDataBits = new System.Windows.Forms.ComboBox(); - this.comboBoxBaudRate = new System.Windows.Forms.ComboBox(); - this.labelSerialPort = new System.Windows.Forms.Label(); - this.comboBoxSerialPort = new System.Windows.Forms.ComboBox(); - this.textBoxBridgePort = new System.Windows.Forms.TextBox(); - this.textBoxMqttPubTopic = new System.Windows.Forms.TextBox(); - this.label12 = new System.Windows.Forms.Label(); - this.textBoxMqttSubTopic = new System.Windows.Forms.TextBox(); - this.label11 = new System.Windows.Forms.Label(); - this.textBoxMqttPassword = new System.Windows.Forms.TextBox(); - this.label10 = new System.Windows.Forms.Label(); - this.textBoxMqttUserName = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.linkLabel2 = new System.Windows.Forms.LinkLabel(); - this.textToPayload = new System.Windows.Forms.TextBox(); - this.textBoxTcpClientLogin = new System.Windows.Forms.TextBox(); - this.textBoxMqttClientId = new System.Windows.Forms.TextBox(); - this.textBoxDgiotPort = new System.Windows.Forms.TextBox(); - this.textBoxUDPClientLogin = new System.Windows.Forms.TextBox(); - this.sendBridge = new System.Windows.Forms.Button(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.label16 = new System.Windows.Forms.Label(); - this.checkBoxBridge = new System.Windows.Forms.CheckBox(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label29 = new System.Windows.Forms.Label(); - this.comboBoxCmdProdxy = new System.Windows.Forms.ComboBox(); - this.label20 = new System.Windows.Forms.Label(); - this.comboBoxDtuAddr = new System.Windows.Forms.ComboBox(); - this.label30 = new System.Windows.Forms.Label(); - this.label21 = new System.Windows.Forms.Label(); - this.textBoxDgiotSever = new System.Windows.Forms.TextBox(); - this.label22 = new System.Windows.Forms.Label(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.textBoxOPCDACount = new System.Windows.Forms.TextBox(); - this.labelOPCDACount = new System.Windows.Forms.Label(); - this.labelSecond = new System.Windows.Forms.Label(); - this.labelOPCDAMonitor = new System.Windows.Forms.Label(); - this.textBoxOPCDAInterval = new System.Windows.Forms.TextBox(); - this.checkBoxOPCDA = new System.Windows.Forms.CheckBox(); - this.textBoxOPCDAHost = new System.Windows.Forms.TextBox(); - this.labelOPCDAHost = new System.Windows.Forms.Label(); - this.textBoxOpcIp = new System.Windows.Forms.TextBox(); - this.groupBox5 = new System.Windows.Forms.GroupBox(); - this.textBoxOPCUATopic = new System.Windows.Forms.TextBox(); - this.labelopcua = new System.Windows.Forms.Label(); - this.groupBox6 = new System.Windows.Forms.GroupBox(); - this.textBoxBACnetTopic = new System.Windows.Forms.TextBox(); - this.label23 = new System.Windows.Forms.Label(); - this.groupBox7 = new System.Windows.Forms.GroupBox(); - this.textBoxControlTopic = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.comboBoxBridge = new System.Windows.Forms.ComboBox(); - this.label7 = new System.Windows.Forms.Label(); - this.groupBox8 = new System.Windows.Forms.GroupBox(); - this.textBoxAccessTopic = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.groupBox10 = new System.Windows.Forms.GroupBox(); - this.label15 = new System.Windows.Forms.Label(); - this.radioButtonMqttClient = new System.Windows.Forms.RadioButton(); - this.radioButtonTcpClient = new System.Windows.Forms.RadioButton(); - this.radioButtonUDPClient = new System.Windows.Forms.RadioButton(); - this.groupBox12 = new System.Windows.Forms.GroupBox(); - this.textBoxPLCTopic = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.comboBoxLogLevel = new System.Windows.Forms.ComboBox(); - this.label32 = new System.Windows.Forms.Label(); - this.comboBoxLan = new System.Windows.Forms.ComboBox(); - this.label33 = new System.Windows.Forms.Label(); - this.treeView = new System.Windows.Forms.TreeView(); - this.label_devcietree = new System.Windows.Forms.Label(); - this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxCommonConfig = new System.Windows.Forms.GroupBox(); - this.buttonScan = new System.Windows.Forms.Button(); - this.groupBoxSerialPort.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.groupBox3.SuspendLayout(); - this.groupBox4.SuspendLayout(); - this.groupBox5.SuspendLayout(); - this.groupBox6.SuspendLayout(); - this.groupBox7.SuspendLayout(); - this.groupBox8.SuspendLayout(); - this.groupBox10.SuspendLayout(); - this.groupBox12.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.groupBoxCommonConfig.SuspendLayout(); - this.SuspendLayout(); - // - // buttonStartStop - // - this.buttonStartStop.Location = new System.Drawing.Point(151, 125); - this.buttonStartStop.Name = "buttonStartStop"; - this.buttonStartStop.Size = new System.Drawing.Size(53, 21); - this.buttonStartStop.TabIndex = 4; - this.buttonStartStop.Text = "Start"; - this.buttonStartStop.UseVisualStyleBackColor = true; - this.buttonStartStop.Click += new System.EventHandler(this.ButtonStartStopClick); - // - // textBoxLog - // - this.textBoxLog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(170)))), ((int)(((byte)(55))))); - this.textBoxLog.Location = new System.Drawing.Point(3, 233); - this.textBoxLog.Multiline = true; - this.textBoxLog.Name = "textBoxLog"; - this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxLog.Size = new System.Drawing.Size(289, 253); - this.textBoxLog.TabIndex = 9; - this.textBoxLog.TextChanged += new System.EventHandler(this.textBoxLog_TextChanged); - // - // checkBoxReconnect - // - this.checkBoxReconnect.AutoSize = true; - this.checkBoxReconnect.Location = new System.Drawing.Point(10, 129); - this.checkBoxReconnect.Name = "checkBoxReconnect"; - this.checkBoxReconnect.Size = new System.Drawing.Size(108, 16); - this.checkBoxReconnect.TabIndex = 5; - this.checkBoxReconnect.Text = "Auto Reconnect"; - this.checkBoxReconnect.UseVisualStyleBackColor = true; - this.checkBoxReconnect.CheckedChanged += new System.EventHandler(this.CheckBoxReconnectCheckedChanged); - // - // checkBoxDisplayHex - // - this.checkBoxDisplayHex.AutoSize = true; - this.checkBoxDisplayHex.Location = new System.Drawing.Point(306, 493); - this.checkBoxDisplayHex.Name = "checkBoxDisplayHex"; - this.checkBoxDisplayHex.Size = new System.Drawing.Size(42, 16); - this.checkBoxDisplayHex.TabIndex = 11; - this.checkBoxDisplayHex.Text = "Hex"; - this.checkBoxDisplayHex.UseVisualStyleBackColor = true; - this.checkBoxDisplayHex.CheckedChanged += new System.EventHandler(this.CheckBoxDisplayHexCheckedChanged); - // - // buttonClear - // - this.buttonClear.Location = new System.Drawing.Point(404, 490); - this.buttonClear.Name = "buttonClear"; - this.buttonClear.Size = new System.Drawing.Size(48, 21); - this.buttonClear.TabIndex = 12; - this.buttonClear.Text = "Clear"; - this.buttonClear.UseVisualStyleBackColor = true; - this.buttonClear.Click += new System.EventHandler(this.ButtonClearClick); - // - // groupBoxSerialPort - // - this.groupBoxSerialPort.Controls.Add(this.comboBoxParity); - this.groupBoxSerialPort.Controls.Add(this.label13); - this.groupBoxSerialPort.Controls.Add(this.label5); - this.groupBoxSerialPort.Controls.Add(this.label4); - this.groupBoxSerialPort.Controls.Add(this.label1); - this.groupBoxSerialPort.Controls.Add(this.comboBoxStopBits); - this.groupBoxSerialPort.Controls.Add(this.comboBoxDataBits); - this.groupBoxSerialPort.Controls.Add(this.comboBoxBaudRate); - this.groupBoxSerialPort.Controls.Add(this.labelSerialPort); - this.groupBoxSerialPort.Controls.Add(this.comboBoxSerialPort); - this.groupBoxSerialPort.Location = new System.Drawing.Point(293, 17); - this.groupBoxSerialPort.Name = "groupBoxSerialPort"; - this.groupBoxSerialPort.Size = new System.Drawing.Size(213, 111); - this.groupBoxSerialPort.TabIndex = 13; - this.groupBoxSerialPort.TabStop = false; - this.groupBoxSerialPort.Text = "Serial Port Capture"; - // - // comboBoxParity - // - this.comboBoxParity.FormattingEnabled = true; - this.comboBoxParity.Items.AddRange(new object[] { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.buttonStartStop = new System.Windows.Forms.Button(); + this.textBoxLog = new System.Windows.Forms.TextBox(); + this.checkBoxReconnect = new System.Windows.Forms.CheckBox(); + this.checkBoxDisplayHex = new System.Windows.Forms.CheckBox(); + this.buttonClear = new System.Windows.Forms.Button(); + this.groupBoxSerialPort = new System.Windows.Forms.GroupBox(); + this.comboBoxParity = new System.Windows.Forms.ComboBox(); + this.label13 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBoxStopBits = new System.Windows.Forms.ComboBox(); + this.comboBoxDataBits = new System.Windows.Forms.ComboBox(); + this.comboBoxBaudRate = new System.Windows.Forms.ComboBox(); + this.labelSerialPort = new System.Windows.Forms.Label(); + this.comboBoxSerialPort = new System.Windows.Forms.ComboBox(); + this.textBoxBridgePort = new System.Windows.Forms.TextBox(); + this.textBoxMqttPubTopic = new System.Windows.Forms.TextBox(); + this.label12 = new System.Windows.Forms.Label(); + this.textBoxMqttSubTopic = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.textBoxMqttPassword = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.textBoxMqttUserName = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.linkLabel2 = new System.Windows.Forms.LinkLabel(); + this.textToPayload = new System.Windows.Forms.TextBox(); + this.textBoxTcpClientLogin = new System.Windows.Forms.TextBox(); + this.textBoxMqttClientId = new System.Windows.Forms.TextBox(); + this.textBoxDgiotPort = new System.Windows.Forms.TextBox(); + this.textBoxUDPClientLogin = new System.Windows.Forms.TextBox(); + this.sendBridge = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.label16 = new System.Windows.Forms.Label(); + this.checkBoxBridge = new System.Windows.Forms.CheckBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.label29 = new System.Windows.Forms.Label(); + this.comboBoxCmdProdxy = new System.Windows.Forms.ComboBox(); + this.label20 = new System.Windows.Forms.Label(); + this.comboBoxDtuAddr = new System.Windows.Forms.ComboBox(); + this.label30 = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); + this.textBoxDgiotSever = new System.Windows.Forms.TextBox(); + this.label22 = new System.Windows.Forms.Label(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.textBoxOPCDACount = new System.Windows.Forms.TextBox(); + this.labelOPCDACount = new System.Windows.Forms.Label(); + this.labelSecond = new System.Windows.Forms.Label(); + this.labelOPCDAMonitor = new System.Windows.Forms.Label(); + this.textBoxOPCDAInterval = new System.Windows.Forms.TextBox(); + this.checkBoxOPCDA = new System.Windows.Forms.CheckBox(); + this.textBoxOPCDAHost = new System.Windows.Forms.TextBox(); + this.labelOPCDAHost = new System.Windows.Forms.Label(); + this.textBoxOpcIp = new System.Windows.Forms.TextBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.textBoxOPCUATopic = new System.Windows.Forms.TextBox(); + this.labelopcua = new System.Windows.Forms.Label(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.textBoxBACnetTopic = new System.Windows.Forms.TextBox(); + this.label23 = new System.Windows.Forms.Label(); + this.groupBox7 = new System.Windows.Forms.GroupBox(); + this.textBoxControlTopic = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.comboBoxBridge = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.groupBox8 = new System.Windows.Forms.GroupBox(); + this.textBoxAccessTopic = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.groupBox10 = new System.Windows.Forms.GroupBox(); + this.label15 = new System.Windows.Forms.Label(); + this.radioButtonMqttClient = new System.Windows.Forms.RadioButton(); + this.radioButtonTcpClient = new System.Windows.Forms.RadioButton(); + this.radioButtonUDPClient = new System.Windows.Forms.RadioButton(); + this.groupBox12 = new System.Windows.Forms.GroupBox(); + this.textBoxPLCTopic = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.comboBoxLogLevel = new System.Windows.Forms.ComboBox(); + this.label32 = new System.Windows.Forms.Label(); + this.comboBoxLan = new System.Windows.Forms.ComboBox(); + this.label33 = new System.Windows.Forms.Label(); + this.treeView = new System.Windows.Forms.TreeView(); + this.label_devcietree = new System.Windows.Forms.Label(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxCommonConfig = new System.Windows.Forms.GroupBox(); + this.buttonScan = new System.Windows.Forms.Button(); + this.groupBoxSerialPort.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox6.SuspendLayout(); + this.groupBox7.SuspendLayout(); + this.groupBox8.SuspendLayout(); + this.groupBox10.SuspendLayout(); + this.groupBox12.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.groupBoxCommonConfig.SuspendLayout(); + this.SuspendLayout(); + // + // buttonStartStop + // + this.buttonStartStop.Location = new System.Drawing.Point(151, 125); + this.buttonStartStop.Name = "buttonStartStop"; + this.buttonStartStop.Size = new System.Drawing.Size(53, 21); + this.buttonStartStop.TabIndex = 4; + this.buttonStartStop.Text = "Start"; + this.buttonStartStop.UseVisualStyleBackColor = true; + this.buttonStartStop.Click += new System.EventHandler(this.ButtonStartStopClick); + // + // textBoxLog + // + this.textBoxLog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(170)))), ((int)(((byte)(55))))); + this.textBoxLog.Location = new System.Drawing.Point(3, 233); + this.textBoxLog.Multiline = true; + this.textBoxLog.Name = "textBoxLog"; + this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxLog.Size = new System.Drawing.Size(289, 253); + this.textBoxLog.TabIndex = 9; + this.textBoxLog.TextChanged += new System.EventHandler(this.textBoxLog_TextChanged); + // + // checkBoxReconnect + // + this.checkBoxReconnect.AutoSize = true; + this.checkBoxReconnect.Location = new System.Drawing.Point(10, 129); + this.checkBoxReconnect.Name = "checkBoxReconnect"; + this.checkBoxReconnect.Size = new System.Drawing.Size(108, 16); + this.checkBoxReconnect.TabIndex = 5; + this.checkBoxReconnect.Text = "Auto Reconnect"; + this.checkBoxReconnect.UseVisualStyleBackColor = true; + this.checkBoxReconnect.CheckedChanged += new System.EventHandler(this.CheckBoxReconnectCheckedChanged); + // + // checkBoxDisplayHex + // + this.checkBoxDisplayHex.AutoSize = true; + this.checkBoxDisplayHex.Location = new System.Drawing.Point(306, 493); + this.checkBoxDisplayHex.Name = "checkBoxDisplayHex"; + this.checkBoxDisplayHex.Size = new System.Drawing.Size(42, 16); + this.checkBoxDisplayHex.TabIndex = 11; + this.checkBoxDisplayHex.Text = "Hex"; + this.checkBoxDisplayHex.UseVisualStyleBackColor = true; + this.checkBoxDisplayHex.CheckedChanged += new System.EventHandler(this.CheckBoxDisplayHexCheckedChanged); + // + // buttonClear + // + this.buttonClear.Location = new System.Drawing.Point(404, 490); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(48, 21); + this.buttonClear.TabIndex = 12; + this.buttonClear.Text = "Clear"; + this.buttonClear.UseVisualStyleBackColor = true; + this.buttonClear.Click += new System.EventHandler(this.ButtonClearClick); + // + // groupBoxSerialPort + // + this.groupBoxSerialPort.Controls.Add(this.comboBoxParity); + this.groupBoxSerialPort.Controls.Add(this.label13); + this.groupBoxSerialPort.Controls.Add(this.label5); + this.groupBoxSerialPort.Controls.Add(this.label4); + this.groupBoxSerialPort.Controls.Add(this.label1); + this.groupBoxSerialPort.Controls.Add(this.comboBoxStopBits); + this.groupBoxSerialPort.Controls.Add(this.comboBoxDataBits); + this.groupBoxSerialPort.Controls.Add(this.comboBoxBaudRate); + this.groupBoxSerialPort.Controls.Add(this.labelSerialPort); + this.groupBoxSerialPort.Controls.Add(this.comboBoxSerialPort); + this.groupBoxSerialPort.Location = new System.Drawing.Point(293, 17); + this.groupBoxSerialPort.Name = "groupBoxSerialPort"; + this.groupBoxSerialPort.Size = new System.Drawing.Size(213, 111); + this.groupBoxSerialPort.TabIndex = 13; + this.groupBoxSerialPort.TabStop = false; + this.groupBoxSerialPort.Text = "Serial Port Capture"; + // + // comboBoxParity + // + this.comboBoxParity.FormattingEnabled = true; + this.comboBoxParity.Items.AddRange(new object[] { "NONE", "Odd", "Even", "Mark", - "Space"}); - this.comboBoxParity.Location = new System.Drawing.Point(63, 59); - this.comboBoxParity.Name = "comboBoxParity"; - this.comboBoxParity.Size = new System.Drawing.Size(140, 20); - this.comboBoxParity.TabIndex = 14; - this.comboBoxParity.SelectedIndexChanged += new System.EventHandler(this.ComboBoxParity_SelectedIndexChanged); - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(5, 59); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(41, 12); - this.label13.TabIndex = 13; - this.label13.Text = "Parity"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(5, 86); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(53, 12); - this.label5.TabIndex = 12; - this.label5.Text = "stopBits"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(108, 86); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(53, 12); - this.label4.TabIndex = 12; - this.label4.Text = "dataBits"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 39); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 12); - this.label1.TabIndex = 12; - this.label1.Text = "Baud Rate"; - // - // comboBoxStopBits - // - this.comboBoxStopBits.FormattingEnabled = true; - this.comboBoxStopBits.Items.AddRange(new object[] { + "Space" + }); + this.comboBoxParity.Location = new System.Drawing.Point(63, 59); + this.comboBoxParity.Name = "comboBoxParity"; + this.comboBoxParity.Size = new System.Drawing.Size(140, 20); + this.comboBoxParity.TabIndex = 14; + this.comboBoxParity.SelectedIndexChanged += new System.EventHandler(this.ComboBoxParity_SelectedIndexChanged); + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(5, 59); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(41, 12); + this.label13.TabIndex = 13; + this.label13.Text = "Parity"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(5, 86); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(53, 12); + this.label5.TabIndex = 12; + this.label5.Text = "stopBits"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(108, 86); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(53, 12); + this.label4.TabIndex = 12; + this.label4.Text = "dataBits"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 39); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(59, 12); + this.label1.TabIndex = 12; + this.label1.Text = "Baud Rate"; + // + // comboBoxStopBits + // + this.comboBoxStopBits.FormattingEnabled = true; + this.comboBoxStopBits.Items.AddRange(new object[] { "1", "2", - "1.5"}); - this.comboBoxStopBits.Location = new System.Drawing.Point(64, 83); - this.comboBoxStopBits.Name = "comboBoxStopBits"; - this.comboBoxStopBits.Size = new System.Drawing.Size(41, 20); - this.comboBoxStopBits.TabIndex = 11; - this.comboBoxStopBits.SelectedIndexChanged += new System.EventHandler(this.ComboBoxStopBits_SelectedIndexChanged); - // - // comboBoxDataBits - // - this.comboBoxDataBits.FormattingEnabled = true; - this.comboBoxDataBits.Items.AddRange(new object[] { + "1.5" + }); + this.comboBoxStopBits.Location = new System.Drawing.Point(64, 83); + this.comboBoxStopBits.Name = "comboBoxStopBits"; + this.comboBoxStopBits.Size = new System.Drawing.Size(41, 20); + this.comboBoxStopBits.TabIndex = 11; + this.comboBoxStopBits.SelectedIndexChanged += new System.EventHandler(this.ComboBoxStopBits_SelectedIndexChanged); + // + // comboBoxDataBits + // + this.comboBoxDataBits.FormattingEnabled = true; + this.comboBoxDataBits.Items.AddRange(new object[] { "8", "7", "6", - "5"}); - this.comboBoxDataBits.Location = new System.Drawing.Point(164, 83); - this.comboBoxDataBits.Name = "comboBoxDataBits"; - this.comboBoxDataBits.Size = new System.Drawing.Size(39, 20); - this.comboBoxDataBits.TabIndex = 11; - this.comboBoxDataBits.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDataBits_SelectedIndexChanged); - // - // comboBoxBaudRate - // - this.comboBoxBaudRate.FormattingEnabled = true; - this.comboBoxBaudRate.Items.AddRange(new object[] { + "5" + }); + this.comboBoxDataBits.Location = new System.Drawing.Point(164, 83); + this.comboBoxDataBits.Name = "comboBoxDataBits"; + this.comboBoxDataBits.Size = new System.Drawing.Size(39, 20); + this.comboBoxDataBits.TabIndex = 11; + this.comboBoxDataBits.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDataBits_SelectedIndexChanged); + // + // comboBoxBaudRate + // + this.comboBoxBaudRate.FormattingEnabled = true; + this.comboBoxBaudRate.Items.AddRange(new object[] { "1200", "2400", "4800", @@ -292,500 +295,502 @@ private void InitializeComponent() "19200", "38400", "57600", - "115200"}); - this.comboBoxBaudRate.Location = new System.Drawing.Point(62, 37); - this.comboBoxBaudRate.Name = "comboBoxBaudRate"; - this.comboBoxBaudRate.Size = new System.Drawing.Size(141, 20); - this.comboBoxBaudRate.TabIndex = 11; - this.comboBoxBaudRate.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBaudRate_SelectedIndexChanged); - // - // labelSerialPort - // - this.labelSerialPort.AutoSize = true; - this.labelSerialPort.Location = new System.Drawing.Point(6, 17); - this.labelSerialPort.Name = "labelSerialPort"; - this.labelSerialPort.Size = new System.Drawing.Size(29, 12); - this.labelSerialPort.TabIndex = 10; - this.labelSerialPort.Text = "Port"; - // - // comboBoxSerialPort - // - this.comboBoxSerialPort.FormattingEnabled = true; - this.comboBoxSerialPort.Location = new System.Drawing.Point(62, 15); - this.comboBoxSerialPort.Name = "comboBoxSerialPort"; - this.comboBoxSerialPort.Size = new System.Drawing.Size(141, 20); - this.comboBoxSerialPort.TabIndex = 9; - this.comboBoxSerialPort.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSerialPort_SelectedIndexChanged); - // - // textBoxBridgePort - // - this.textBoxBridgePort.Location = new System.Drawing.Point(134, 97); - this.textBoxBridgePort.Name = "textBoxBridgePort"; - this.textBoxBridgePort.Size = new System.Drawing.Size(75, 21); - this.textBoxBridgePort.TabIndex = 7; - this.textBoxBridgePort.Text = "5080"; - this.textBoxBridgePort.TextChanged += new System.EventHandler(this.TextBoxBridgePort_TextChanged); - // - // textBoxMqttPubTopic - // - this.textBoxMqttPubTopic.Location = new System.Drawing.Point(80, 119); - this.textBoxMqttPubTopic.Name = "textBoxMqttPubTopic"; - this.textBoxMqttPubTopic.Size = new System.Drawing.Size(132, 21); - this.textBoxMqttPubTopic.TabIndex = 22; - this.textBoxMqttPubTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxMqttPubTopic.TextChanged += new System.EventHandler(this.TextBoxMqttPubTopic_TextChanged); - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(9, 119); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(53, 12); - this.label12.TabIndex = 21; - this.label12.Text = "PubTopic"; - // - // textBoxMqttSubTopic - // - this.textBoxMqttSubTopic.Location = new System.Drawing.Point(81, 95); - this.textBoxMqttSubTopic.Name = "textBoxMqttSubTopic"; - this.textBoxMqttSubTopic.Size = new System.Drawing.Size(132, 21); - this.textBoxMqttSubTopic.TabIndex = 20; - this.textBoxMqttSubTopic.Text = "$dg/device/{productId}/{deviceAddr}/properties"; - this.textBoxMqttSubTopic.TextChanged += new System.EventHandler(this.TextBoxMqttSubTopic_TextChanged); - // - // label11 - // - this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(9, 96); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(53, 12); - this.label11.TabIndex = 19; - this.label11.Text = "SubTopic"; - // - // textBoxMqttPassword - // - this.textBoxMqttPassword.Location = new System.Drawing.Point(81, 44); - this.textBoxMqttPassword.Name = "textBoxMqttPassword"; - this.textBoxMqttPassword.Size = new System.Drawing.Size(131, 21); - this.textBoxMqttPassword.TabIndex = 18; - this.textBoxMqttPassword.Text = "SzQ3MDU4ODMxNjQwNjYyNjkwOTg4"; - this.textBoxMqttPassword.TextChanged += new System.EventHandler(this.TextBoxMqttPassword_TextChanged); - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(8, 47); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(53, 12); - this.label10.TabIndex = 17; - this.label10.Text = "PassWord"; - // - // textBoxMqttUserName - // - this.textBoxMqttUserName.Location = new System.Drawing.Point(81, 20); - this.textBoxMqttUserName.Name = "textBoxMqttUserName"; - this.textBoxMqttUserName.Size = new System.Drawing.Size(131, 21); - this.textBoxMqttUserName.TabIndex = 16; - this.textBoxMqttUserName.Text = "fa82a59201"; - this.textBoxMqttUserName.TextChanged += new System.EventHandler(this.TextBoxMqttUserName_TextChanged); - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(6, 24); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(53, 12); - this.label9.TabIndex = 15; - this.label9.Text = "UserName"; - // - // linkLabel2 - // - this.linkLabel2.AutoSize = true; - this.linkLabel2.LinkColor = System.Drawing.Color.Silver; - this.linkLabel2.Location = new System.Drawing.Point(515, 449); - this.linkLabel2.Name = "linkLabel2"; - this.linkLabel2.Size = new System.Drawing.Size(41, 12); - this.linkLabel2.TabIndex = 16; - this.linkLabel2.TabStop = true; - this.linkLabel2.Text = "DG-IoT"; - this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel2_LinkClicked); - // - // textToPayload - // - this.textToPayload.Location = new System.Drawing.Point(127, 491); - this.textToPayload.Name = "textToPayload"; - this.textToPayload.Size = new System.Drawing.Size(169, 21); - this.textToPayload.TabIndex = 14; - this.textToPayload.Text = "12345678"; - this.textToPayload.TextChanged += new System.EventHandler(this.TextToPayload_TextChanged); - // - // textBoxTcpClientLogin - // - this.textBoxTcpClientLogin.Location = new System.Drawing.Point(79, 21); - this.textBoxTcpClientLogin.Name = "textBoxTcpClientLogin"; - this.textBoxTcpClientLogin.Size = new System.Drawing.Size(131, 21); - this.textBoxTcpClientLogin.TabIndex = 12; - this.textBoxTcpClientLogin.Text = "login"; - this.textBoxTcpClientLogin.TextChanged += new System.EventHandler(this.TextBoxTcpClientLogin_TextChanged); - // - // textBoxMqttClientId - // - this.textBoxMqttClientId.Location = new System.Drawing.Point(81, 71); - this.textBoxMqttClientId.Name = "textBoxMqttClientId"; - this.textBoxMqttClientId.Size = new System.Drawing.Size(131, 21); - this.textBoxMqttClientId.TabIndex = 12; - this.textBoxMqttClientId.Text = "devaddr"; - this.textBoxMqttClientId.TextChanged += new System.EventHandler(this.TextBoxMqttClientId_TextChanged); - // - // textBoxDgiotPort - // - this.textBoxDgiotPort.Location = new System.Drawing.Point(77, 46); - this.textBoxDgiotPort.Name = "textBoxDgiotPort"; - this.textBoxDgiotPort.Size = new System.Drawing.Size(133, 21); - this.textBoxDgiotPort.TabIndex = 7; - this.textBoxDgiotPort.Text = "1883"; - this.textBoxDgiotPort.TextChanged += new System.EventHandler(this.TextBoxDgiotPort_TextChanged); - // - // textBoxUDPClientLogin - // - this.textBoxUDPClientLogin.Location = new System.Drawing.Point(74, 21); - this.textBoxUDPClientLogin.Name = "textBoxUDPClientLogin"; - this.textBoxUDPClientLogin.Size = new System.Drawing.Size(136, 21); - this.textBoxUDPClientLogin.TabIndex = 12; - this.textBoxUDPClientLogin.Text = "login"; - this.textBoxUDPClientLogin.TextChanged += new System.EventHandler(this.TextBoxUDPClientLogin_TextChanged); - // - // sendBridge - // - this.sendBridge.Location = new System.Drawing.Point(350, 491); - this.sendBridge.Name = "sendBridge"; - this.sendBridge.Size = new System.Drawing.Size(47, 21); - this.sendBridge.TabIndex = 17; - this.sendBridge.Text = "Send"; - this.sendBridge.UseVisualStyleBackColor = true; - this.sendBridge.Click += new System.EventHandler(this.SendBridge_Click); - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.label16); - this.groupBox2.Controls.Add(this.textBoxTcpClientLogin); - this.groupBox2.Location = new System.Drawing.Point(571, 206); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(213, 53); - this.groupBox2.TabIndex = 18; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "TCP Client Channel"; - // - // label16 - // - this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(9, 21); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(35, 12); - this.label16.TabIndex = 13; - this.label16.Text = "login"; - // - // checkBoxBridge - // - this.checkBoxBridge.AutoSize = true; - this.checkBoxBridge.Location = new System.Drawing.Point(10, 99); - this.checkBoxBridge.Name = "checkBoxBridge"; - this.checkBoxBridge.Size = new System.Drawing.Size(90, 16); - this.checkBoxBridge.TabIndex = 23; - this.checkBoxBridge.Text = "Bridge Port"; - this.checkBoxBridge.UseVisualStyleBackColor = true; - this.checkBoxBridge.CheckedChanged += new System.EventHandler(this.CheckBoxBridge_CheckedChanged); - // - // groupBox3 - // - this.groupBox3.Controls.Add(this.label29); - this.groupBox3.Controls.Add(this.comboBoxCmdProdxy); - this.groupBox3.Controls.Add(this.textBoxMqttPubTopic); - this.groupBox3.Controls.Add(this.label12); - this.groupBox3.Controls.Add(this.label20); - this.groupBox3.Controls.Add(this.textBoxMqttClientId); - this.groupBox3.Controls.Add(this.textBoxMqttSubTopic); - this.groupBox3.Controls.Add(this.label11); - this.groupBox3.Controls.Add(this.textBoxMqttUserName); - this.groupBox3.Controls.Add(this.textBoxMqttPassword); - this.groupBox3.Controls.Add(this.label9); - this.groupBox3.Controls.Add(this.label10); - this.groupBox3.Location = new System.Drawing.Point(571, 15); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(217, 172); - this.groupBox3.TabIndex = 19; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Mqtt Client Channel"; - // - // label29 - // - this.label29.AutoSize = true; - this.label29.Location = new System.Drawing.Point(8, 142); - this.label29.Name = "label29"; - this.label29.Size = new System.Drawing.Size(59, 12); - this.label29.TabIndex = 37; - this.label29.Text = "cmd proxy"; - // - // comboBoxCmdProdxy - // - this.comboBoxCmdProdxy.FormattingEnabled = true; - this.comboBoxCmdProdxy.Items.AddRange(new object[] { - "ffmpeg"}); - this.comboBoxCmdProdxy.Location = new System.Drawing.Point(81, 146); - this.comboBoxCmdProdxy.Name = "comboBoxCmdProdxy"; - this.comboBoxCmdProdxy.Size = new System.Drawing.Size(131, 20); - this.comboBoxCmdProdxy.TabIndex = 36; - this.comboBoxCmdProdxy.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCmdProdxy_SelectedIndexChanged); - // - // label20 - // - this.label20.AutoSize = true; - this.label20.Location = new System.Drawing.Point(9, 72); - this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(53, 12); - this.label20.TabIndex = 13; - this.label20.Text = "Clientid"; - // - // comboBoxDtuAddr - // - this.comboBoxDtuAddr.FormattingEnabled = true; - this.comboBoxDtuAddr.Location = new System.Drawing.Point(77, 71); - this.comboBoxDtuAddr.Name = "comboBoxDtuAddr"; - this.comboBoxDtuAddr.Size = new System.Drawing.Size(132, 20); - this.comboBoxDtuAddr.TabIndex = 15; - this.comboBoxDtuAddr.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDtuAddr_SelectedIndexChanged); - // - // label30 - // - this.label30.AutoSize = true; - this.label30.Location = new System.Drawing.Point(9, 69); - this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(47, 12); - this.label30.TabIndex = 39; - this.label30.Text = "DtuAddr"; - // - // label21 - // - this.label21.AutoSize = true; - this.label21.Location = new System.Drawing.Point(9, 48); - this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(29, 12); - this.label21.TabIndex = 8; - this.label21.Text = "Port"; - // - // textBoxDgiotSever - // - this.textBoxDgiotSever.Location = new System.Drawing.Point(77, 19); - this.textBoxDgiotSever.Name = "textBoxDgiotSever"; - this.textBoxDgiotSever.Size = new System.Drawing.Size(133, 21); - this.textBoxDgiotSever.TabIndex = 5; - this.textBoxDgiotSever.Text = "pump.dgiotcloud.com"; - this.textBoxDgiotSever.TextChanged += new System.EventHandler(this.TextBoxDgiotSever_TextChanged); - // - // label22 - // - this.label22.AutoSize = true; - this.label22.Location = new System.Drawing.Point(9, 23); - this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(41, 12); - this.label22.TabIndex = 6; - this.label22.Text = "Server"; - // - // groupBox4 - // - this.groupBox4.Controls.Add(this.textBoxOPCDACount); - this.groupBox4.Controls.Add(this.labelOPCDACount); - this.groupBox4.Controls.Add(this.labelSecond); - this.groupBox4.Controls.Add(this.labelOPCDAMonitor); - this.groupBox4.Controls.Add(this.textBoxOPCDAInterval); - this.groupBox4.Controls.Add(this.checkBoxOPCDA); - this.groupBox4.Controls.Add(this.textBoxOPCDAHost); - this.groupBox4.Controls.Add(this.labelOPCDAHost); - this.groupBox4.Location = new System.Drawing.Point(294, 183); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(211, 75); - this.groupBox4.TabIndex = 18; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "OPC_DA Capture"; - // - // textBoxOPCDACount - // - this.textBoxOPCDACount.Location = new System.Drawing.Point(181, 47); - this.textBoxOPCDACount.Name = "textBoxOPCDACount"; - this.textBoxOPCDACount.Size = new System.Drawing.Size(27, 21); - this.textBoxOPCDACount.TabIndex = 52; - this.textBoxOPCDACount.Text = "30"; - this.textBoxOPCDACount.TextChanged += new System.EventHandler(this.TextBoxOPCDACount_TextChanged); - // - // labelOPCDACount - // - this.labelOPCDACount.AutoSize = true; - this.labelOPCDACount.Location = new System.Drawing.Point(129, 50); - this.labelOPCDACount.Name = "labelOPCDACount"; - this.labelOPCDACount.Size = new System.Drawing.Size(35, 12); - this.labelOPCDACount.TabIndex = 51; - this.labelOPCDACount.Text = "Count"; - // - // labelSecond - // - this.labelSecond.AutoSize = true; - this.labelSecond.Location = new System.Drawing.Point(86, 50); - this.labelSecond.Name = "labelSecond"; - this.labelSecond.Size = new System.Drawing.Size(41, 12); - this.labelSecond.TabIndex = 50; - this.labelSecond.Text = "Second"; - // - // labelOPCDAMonitor - // - this.labelOPCDAMonitor.AutoSize = true; - this.labelOPCDAMonitor.Location = new System.Drawing.Point(3, 49); - this.labelOPCDAMonitor.Name = "labelOPCDAMonitor"; - this.labelOPCDAMonitor.Size = new System.Drawing.Size(53, 12); - this.labelOPCDAMonitor.TabIndex = 49; - this.labelOPCDAMonitor.Text = "Interval"; - // - // textBoxOPCDAInterval - // - this.textBoxOPCDAInterval.Location = new System.Drawing.Point(58, 46); - this.textBoxOPCDAInterval.Name = "textBoxOPCDAInterval"; - this.textBoxOPCDAInterval.Size = new System.Drawing.Size(29, 21); - this.textBoxOPCDAInterval.TabIndex = 48; - this.textBoxOPCDAInterval.Text = "3"; - this.textBoxOPCDAInterval.TextChanged += new System.EventHandler(this.TextBoxOPCDAInterval_TextChanged); - // - // checkBoxOPCDA - // - this.checkBoxOPCDA.AutoSize = true; - this.checkBoxOPCDA.Location = new System.Drawing.Point(137, 22); - this.checkBoxOPCDA.Margin = new System.Windows.Forms.Padding(2); - this.checkBoxOPCDA.Name = "checkBoxOPCDA"; - this.checkBoxOPCDA.Size = new System.Drawing.Size(66, 16); - this.checkBoxOPCDA.TabIndex = 47; - this.checkBoxOPCDA.Text = "Monitor"; - this.checkBoxOPCDA.UseVisualStyleBackColor = true; - this.checkBoxOPCDA.CheckedChanged += new System.EventHandler(this.CheckBoxOPCDA_CheckedChanged); - // - // textBoxOPCDAHost - // - this.textBoxOPCDAHost.Location = new System.Drawing.Point(36, 19); - this.textBoxOPCDAHost.Name = "textBoxOPCDAHost"; - this.textBoxOPCDAHost.Size = new System.Drawing.Size(100, 21); - this.textBoxOPCDAHost.TabIndex = 46; - this.textBoxOPCDAHost.Text = "127.0.0.1"; - this.textBoxOPCDAHost.TextChanged += new System.EventHandler(this.TextBoxOPCDAHost_TextChanged); - // - // labelOPCDAHost - // - this.labelOPCDAHost.AutoSize = true; - this.labelOPCDAHost.Location = new System.Drawing.Point(6, 22); - this.labelOPCDAHost.Name = "labelOPCDAHost"; - this.labelOPCDAHost.Size = new System.Drawing.Size(29, 12); - this.labelOPCDAHost.TabIndex = 7; - this.labelOPCDAHost.Text = "Host"; - // - // textBoxOpcIp - // - this.textBoxOpcIp.Location = new System.Drawing.Point(6, 0); - this.textBoxOpcIp.Name = "textBoxOpcIp"; - this.textBoxOpcIp.Size = new System.Drawing.Size(100, 21); - this.textBoxOpcIp.TabIndex = 0; - // - // groupBox5 - // - this.groupBox5.Controls.Add(this.textBoxOPCUATopic); - this.groupBox5.Controls.Add(this.labelopcua); - this.groupBox5.Location = new System.Drawing.Point(293, 266); - this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(211, 45); - this.groupBox5.TabIndex = 19; - this.groupBox5.TabStop = false; - this.groupBox5.Text = "OPC_UA Capture"; - this.groupBox5.Enter += new System.EventHandler(this.groupBox5_Enter); - // - // textBoxOPCUATopic - // - this.textBoxOPCUATopic.Location = new System.Drawing.Point(35, 17); - this.textBoxOPCUATopic.Name = "textBoxOPCUATopic"; - this.textBoxOPCUATopic.ReadOnly = true; - this.textBoxOPCUATopic.Size = new System.Drawing.Size(168, 21); - this.textBoxOPCUATopic.TabIndex = 5; - this.textBoxOPCUATopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxOPCUATopic.TextChanged += new System.EventHandler(this.TextBoxOPCUATopic_TextChanged); - // - // labelopcua - // - this.labelopcua.AutoSize = true; - this.labelopcua.Location = new System.Drawing.Point(6, 19); - this.labelopcua.Name = "labelopcua"; - this.labelopcua.Size = new System.Drawing.Size(17, 12); - this.labelopcua.TabIndex = 6; - this.labelopcua.Text = "To"; - // - // groupBox6 - // - this.groupBox6.Controls.Add(this.textBoxBACnetTopic); - this.groupBox6.Controls.Add(this.label23); - this.groupBox6.Location = new System.Drawing.Point(293, 326); - this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(211, 42); - this.groupBox6.TabIndex = 20; - this.groupBox6.TabStop = false; - this.groupBox6.Text = "BACnet Capture"; - this.groupBox6.Enter += new System.EventHandler(this.groupBox6_Enter); - // - // textBoxBACnetTopic - // - this.textBoxBACnetTopic.Location = new System.Drawing.Point(31, 17); - this.textBoxBACnetTopic.Name = "textBoxBACnetTopic"; - this.textBoxBACnetTopic.ReadOnly = true; - this.textBoxBACnetTopic.Size = new System.Drawing.Size(169, 21); - this.textBoxBACnetTopic.TabIndex = 5; - this.textBoxBACnetTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxBACnetTopic.TextChanged += new System.EventHandler(this.TextBoxBACnetTopic_TextChanged); - // - // label23 - // - this.label23.AutoSize = true; - this.label23.Location = new System.Drawing.Point(7, 21); - this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(17, 12); - this.label23.TabIndex = 6; - this.label23.Text = "To"; - // - // groupBox7 - // - this.groupBox7.Controls.Add(this.textBoxControlTopic); - this.groupBox7.Controls.Add(this.label8); - this.groupBox7.Location = new System.Drawing.Point(293, 383); - this.groupBox7.Name = "groupBox7"; - this.groupBox7.Size = new System.Drawing.Size(211, 47); - this.groupBox7.TabIndex = 21; - this.groupBox7.TabStop = false; - this.groupBox7.Text = "Control Capture"; - // - // textBoxControlTopic - // - this.textBoxControlTopic.Location = new System.Drawing.Point(33, 17); - this.textBoxControlTopic.Name = "textBoxControlTopic"; - this.textBoxControlTopic.ReadOnly = true; - this.textBoxControlTopic.Size = new System.Drawing.Size(170, 21); - this.textBoxControlTopic.TabIndex = 5; - this.textBoxControlTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxControlTopic.TextChanged += new System.EventHandler(this.TextBoxControlTopic_TextChanged); - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(6, 21); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(17, 12); - this.label8.TabIndex = 6; - this.label8.Text = "To"; - // - // comboBoxBridge - // - this.comboBoxBridge.FormattingEnabled = true; - this.comboBoxBridge.Items.AddRange(new object[] { + "115200" + }); + this.comboBoxBaudRate.Location = new System.Drawing.Point(62, 37); + this.comboBoxBaudRate.Name = "comboBoxBaudRate"; + this.comboBoxBaudRate.Size = new System.Drawing.Size(141, 20); + this.comboBoxBaudRate.TabIndex = 11; + this.comboBoxBaudRate.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBaudRate_SelectedIndexChanged); + // + // labelSerialPort + // + this.labelSerialPort.AutoSize = true; + this.labelSerialPort.Location = new System.Drawing.Point(6, 17); + this.labelSerialPort.Name = "labelSerialPort"; + this.labelSerialPort.Size = new System.Drawing.Size(29, 12); + this.labelSerialPort.TabIndex = 10; + this.labelSerialPort.Text = "Port"; + // + // comboBoxSerialPort + // + this.comboBoxSerialPort.FormattingEnabled = true; + this.comboBoxSerialPort.Location = new System.Drawing.Point(62, 15); + this.comboBoxSerialPort.Name = "comboBoxSerialPort"; + this.comboBoxSerialPort.Size = new System.Drawing.Size(141, 20); + this.comboBoxSerialPort.TabIndex = 9; + this.comboBoxSerialPort.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSerialPort_SelectedIndexChanged); + // + // textBoxBridgePort + // + this.textBoxBridgePort.Location = new System.Drawing.Point(134, 97); + this.textBoxBridgePort.Name = "textBoxBridgePort"; + this.textBoxBridgePort.Size = new System.Drawing.Size(75, 21); + this.textBoxBridgePort.TabIndex = 7; + this.textBoxBridgePort.Text = "5080"; + this.textBoxBridgePort.TextChanged += new System.EventHandler(this.TextBoxBridgePort_TextChanged); + // + // textBoxMqttPubTopic + // + this.textBoxMqttPubTopic.Location = new System.Drawing.Point(80, 119); + this.textBoxMqttPubTopic.Name = "textBoxMqttPubTopic"; + this.textBoxMqttPubTopic.Size = new System.Drawing.Size(132, 21); + this.textBoxMqttPubTopic.TabIndex = 22; + this.textBoxMqttPubTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxMqttPubTopic.TextChanged += new System.EventHandler(this.TextBoxMqttPubTopic_TextChanged); + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(9, 119); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(53, 12); + this.label12.TabIndex = 21; + this.label12.Text = "PubTopic"; + // + // textBoxMqttSubTopic + // + this.textBoxMqttSubTopic.Location = new System.Drawing.Point(81, 95); + this.textBoxMqttSubTopic.Name = "textBoxMqttSubTopic"; + this.textBoxMqttSubTopic.Size = new System.Drawing.Size(132, 21); + this.textBoxMqttSubTopic.TabIndex = 20; + this.textBoxMqttSubTopic.Text = "$dg/device/{productId}/{deviceAddr}/properties"; + this.textBoxMqttSubTopic.TextChanged += new System.EventHandler(this.TextBoxMqttSubTopic_TextChanged); + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(9, 96); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(53, 12); + this.label11.TabIndex = 19; + this.label11.Text = "SubTopic"; + // + // textBoxMqttPassword + // + this.textBoxMqttPassword.Location = new System.Drawing.Point(81, 44); + this.textBoxMqttPassword.Name = "textBoxMqttPassword"; + this.textBoxMqttPassword.Size = new System.Drawing.Size(131, 21); + this.textBoxMqttPassword.TabIndex = 18; + this.textBoxMqttPassword.Text = "SzQ3MDU4ODMxNjQwNjYyNjkwOTg4"; + this.textBoxMqttPassword.TextChanged += new System.EventHandler(this.TextBoxMqttPassword_TextChanged); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(8, 47); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(53, 12); + this.label10.TabIndex = 17; + this.label10.Text = "PassWord"; + // + // textBoxMqttUserName + // + this.textBoxMqttUserName.Location = new System.Drawing.Point(81, 20); + this.textBoxMqttUserName.Name = "textBoxMqttUserName"; + this.textBoxMqttUserName.Size = new System.Drawing.Size(131, 21); + this.textBoxMqttUserName.TabIndex = 16; + this.textBoxMqttUserName.Text = "fa82a59201"; + this.textBoxMqttUserName.TextChanged += new System.EventHandler(this.TextBoxMqttUserName_TextChanged); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(6, 24); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(53, 12); + this.label9.TabIndex = 15; + this.label9.Text = "UserName"; + // + // linkLabel2 + // + this.linkLabel2.AutoSize = true; + this.linkLabel2.LinkColor = System.Drawing.Color.Silver; + this.linkLabel2.Location = new System.Drawing.Point(515, 449); + this.linkLabel2.Name = "linkLabel2"; + this.linkLabel2.Size = new System.Drawing.Size(41, 12); + this.linkLabel2.TabIndex = 16; + this.linkLabel2.TabStop = true; + this.linkLabel2.Text = "DG-IoT"; + this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel2_LinkClicked); + // + // textToPayload + // + this.textToPayload.Location = new System.Drawing.Point(127, 491); + this.textToPayload.Name = "textToPayload"; + this.textToPayload.Size = new System.Drawing.Size(169, 21); + this.textToPayload.TabIndex = 14; + this.textToPayload.Text = "12345678"; + this.textToPayload.TextChanged += new System.EventHandler(this.TextToPayload_TextChanged); + // + // textBoxTcpClientLogin + // + this.textBoxTcpClientLogin.Location = new System.Drawing.Point(79, 21); + this.textBoxTcpClientLogin.Name = "textBoxTcpClientLogin"; + this.textBoxTcpClientLogin.Size = new System.Drawing.Size(131, 21); + this.textBoxTcpClientLogin.TabIndex = 12; + this.textBoxTcpClientLogin.Text = "login"; + this.textBoxTcpClientLogin.TextChanged += new System.EventHandler(this.TextBoxTcpClientLogin_TextChanged); + // + // textBoxMqttClientId + // + this.textBoxMqttClientId.Location = new System.Drawing.Point(81, 71); + this.textBoxMqttClientId.Name = "textBoxMqttClientId"; + this.textBoxMqttClientId.Size = new System.Drawing.Size(131, 21); + this.textBoxMqttClientId.TabIndex = 12; + this.textBoxMqttClientId.Text = "devaddr"; + this.textBoxMqttClientId.TextChanged += new System.EventHandler(this.TextBoxMqttClientId_TextChanged); + // + // textBoxDgiotPort + // + this.textBoxDgiotPort.Location = new System.Drawing.Point(77, 46); + this.textBoxDgiotPort.Name = "textBoxDgiotPort"; + this.textBoxDgiotPort.Size = new System.Drawing.Size(133, 21); + this.textBoxDgiotPort.TabIndex = 7; + this.textBoxDgiotPort.Text = "1883"; + this.textBoxDgiotPort.TextChanged += new System.EventHandler(this.TextBoxDgiotPort_TextChanged); + // + // textBoxUDPClientLogin + // + this.textBoxUDPClientLogin.Location = new System.Drawing.Point(74, 21); + this.textBoxUDPClientLogin.Name = "textBoxUDPClientLogin"; + this.textBoxUDPClientLogin.Size = new System.Drawing.Size(136, 21); + this.textBoxUDPClientLogin.TabIndex = 12; + this.textBoxUDPClientLogin.Text = "login"; + this.textBoxUDPClientLogin.TextChanged += new System.EventHandler(this.TextBoxUDPClientLogin_TextChanged); + // + // sendBridge + // + this.sendBridge.Location = new System.Drawing.Point(350, 491); + this.sendBridge.Name = "sendBridge"; + this.sendBridge.Size = new System.Drawing.Size(47, 21); + this.sendBridge.TabIndex = 17; + this.sendBridge.Text = "Send"; + this.sendBridge.UseVisualStyleBackColor = true; + this.sendBridge.Click += new System.EventHandler(this.SendBridge_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label16); + this.groupBox2.Controls.Add(this.textBoxTcpClientLogin); + this.groupBox2.Location = new System.Drawing.Point(571, 206); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(213, 53); + this.groupBox2.TabIndex = 18; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "TCP Client Channel"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(9, 21); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(35, 12); + this.label16.TabIndex = 13; + this.label16.Text = "login"; + // + // checkBoxBridge + // + this.checkBoxBridge.AutoSize = true; + this.checkBoxBridge.Location = new System.Drawing.Point(10, 99); + this.checkBoxBridge.Name = "checkBoxBridge"; + this.checkBoxBridge.Size = new System.Drawing.Size(90, 16); + this.checkBoxBridge.TabIndex = 23; + this.checkBoxBridge.Text = "Bridge Port"; + this.checkBoxBridge.UseVisualStyleBackColor = true; + this.checkBoxBridge.CheckedChanged += new System.EventHandler(this.CheckBoxBridge_CheckedChanged); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.label29); + this.groupBox3.Controls.Add(this.comboBoxCmdProdxy); + this.groupBox3.Controls.Add(this.textBoxMqttPubTopic); + this.groupBox3.Controls.Add(this.label12); + this.groupBox3.Controls.Add(this.label20); + this.groupBox3.Controls.Add(this.textBoxMqttClientId); + this.groupBox3.Controls.Add(this.textBoxMqttSubTopic); + this.groupBox3.Controls.Add(this.label11); + this.groupBox3.Controls.Add(this.textBoxMqttUserName); + this.groupBox3.Controls.Add(this.textBoxMqttPassword); + this.groupBox3.Controls.Add(this.label9); + this.groupBox3.Controls.Add(this.label10); + this.groupBox3.Location = new System.Drawing.Point(571, 15); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(217, 172); + this.groupBox3.TabIndex = 19; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Mqtt Client Channel"; + // + // label29 + // + this.label29.AutoSize = true; + this.label29.Location = new System.Drawing.Point(8, 142); + this.label29.Name = "label29"; + this.label29.Size = new System.Drawing.Size(59, 12); + this.label29.TabIndex = 37; + this.label29.Text = "cmd proxy"; + // + // comboBoxCmdProdxy + // + this.comboBoxCmdProdxy.FormattingEnabled = true; + this.comboBoxCmdProdxy.Items.AddRange(new object[] { + "ffmpeg" + }); + this.comboBoxCmdProdxy.Location = new System.Drawing.Point(81, 146); + this.comboBoxCmdProdxy.Name = "comboBoxCmdProdxy"; + this.comboBoxCmdProdxy.Size = new System.Drawing.Size(131, 20); + this.comboBoxCmdProdxy.TabIndex = 36; + this.comboBoxCmdProdxy.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCmdProdxy_SelectedIndexChanged); + // + // label20 + // + this.label20.AutoSize = true; + this.label20.Location = new System.Drawing.Point(9, 72); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(53, 12); + this.label20.TabIndex = 13; + this.label20.Text = "Clientid"; + // + // comboBoxDtuAddr + // + this.comboBoxDtuAddr.FormattingEnabled = true; + this.comboBoxDtuAddr.Location = new System.Drawing.Point(77, 71); + this.comboBoxDtuAddr.Name = "comboBoxDtuAddr"; + this.comboBoxDtuAddr.Size = new System.Drawing.Size(132, 20); + this.comboBoxDtuAddr.TabIndex = 15; + this.comboBoxDtuAddr.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDtuAddr_SelectedIndexChanged); + // + // label30 + // + this.label30.AutoSize = true; + this.label30.Location = new System.Drawing.Point(9, 69); + this.label30.Name = "label30"; + this.label30.Size = new System.Drawing.Size(47, 12); + this.label30.TabIndex = 39; + this.label30.Text = "DtuAddr"; + // + // label21 + // + this.label21.AutoSize = true; + this.label21.Location = new System.Drawing.Point(9, 48); + this.label21.Name = "label21"; + this.label21.Size = new System.Drawing.Size(29, 12); + this.label21.TabIndex = 8; + this.label21.Text = "Port"; + // + // textBoxDgiotSever + // + this.textBoxDgiotSever.Location = new System.Drawing.Point(77, 19); + this.textBoxDgiotSever.Name = "textBoxDgiotSever"; + this.textBoxDgiotSever.Size = new System.Drawing.Size(133, 21); + this.textBoxDgiotSever.TabIndex = 5; + this.textBoxDgiotSever.Text = "pump.dgiotcloud.com"; + this.textBoxDgiotSever.TextChanged += new System.EventHandler(this.TextBoxDgiotSever_TextChanged); + // + // label22 + // + this.label22.AutoSize = true; + this.label22.Location = new System.Drawing.Point(9, 23); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(41, 12); + this.label22.TabIndex = 6; + this.label22.Text = "Server"; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.textBoxOPCDACount); + this.groupBox4.Controls.Add(this.labelOPCDACount); + this.groupBox4.Controls.Add(this.labelSecond); + this.groupBox4.Controls.Add(this.labelOPCDAMonitor); + this.groupBox4.Controls.Add(this.textBoxOPCDAInterval); + this.groupBox4.Controls.Add(this.checkBoxOPCDA); + this.groupBox4.Controls.Add(this.textBoxOPCDAHost); + this.groupBox4.Controls.Add(this.labelOPCDAHost); + this.groupBox4.Location = new System.Drawing.Point(294, 183); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(211, 75); + this.groupBox4.TabIndex = 18; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "OPC_DA Capture"; + // + // textBoxOPCDACount + // + this.textBoxOPCDACount.Location = new System.Drawing.Point(181, 47); + this.textBoxOPCDACount.Name = "textBoxOPCDACount"; + this.textBoxOPCDACount.Size = new System.Drawing.Size(27, 21); + this.textBoxOPCDACount.TabIndex = 52; + this.textBoxOPCDACount.Text = "30"; + this.textBoxOPCDACount.TextChanged += new System.EventHandler(this.TextBoxOPCDACount_TextChanged); + // + // labelOPCDACount + // + this.labelOPCDACount.AutoSize = true; + this.labelOPCDACount.Location = new System.Drawing.Point(129, 50); + this.labelOPCDACount.Name = "labelOPCDACount"; + this.labelOPCDACount.Size = new System.Drawing.Size(35, 12); + this.labelOPCDACount.TabIndex = 51; + this.labelOPCDACount.Text = "Count"; + // + // labelSecond + // + this.labelSecond.AutoSize = true; + this.labelSecond.Location = new System.Drawing.Point(86, 50); + this.labelSecond.Name = "labelSecond"; + this.labelSecond.Size = new System.Drawing.Size(41, 12); + this.labelSecond.TabIndex = 50; + this.labelSecond.Text = "Second"; + // + // labelOPCDAMonitor + // + this.labelOPCDAMonitor.AutoSize = true; + this.labelOPCDAMonitor.Location = new System.Drawing.Point(3, 49); + this.labelOPCDAMonitor.Name = "labelOPCDAMonitor"; + this.labelOPCDAMonitor.Size = new System.Drawing.Size(53, 12); + this.labelOPCDAMonitor.TabIndex = 49; + this.labelOPCDAMonitor.Text = "Interval"; + // + // textBoxOPCDAInterval + // + this.textBoxOPCDAInterval.Location = new System.Drawing.Point(58, 46); + this.textBoxOPCDAInterval.Name = "textBoxOPCDAInterval"; + this.textBoxOPCDAInterval.Size = new System.Drawing.Size(29, 21); + this.textBoxOPCDAInterval.TabIndex = 48; + this.textBoxOPCDAInterval.Text = "3"; + this.textBoxOPCDAInterval.TextChanged += new System.EventHandler(this.TextBoxOPCDAInterval_TextChanged); + // + // checkBoxOPCDA + // + this.checkBoxOPCDA.AutoSize = true; + this.checkBoxOPCDA.Location = new System.Drawing.Point(137, 22); + this.checkBoxOPCDA.Margin = new System.Windows.Forms.Padding(2); + this.checkBoxOPCDA.Name = "checkBoxOPCDA"; + this.checkBoxOPCDA.Size = new System.Drawing.Size(66, 16); + this.checkBoxOPCDA.TabIndex = 47; + this.checkBoxOPCDA.Text = "Monitor"; + this.checkBoxOPCDA.UseVisualStyleBackColor = true; + this.checkBoxOPCDA.CheckedChanged += new System.EventHandler(this.CheckBoxOPCDA_CheckedChanged); + // + // textBoxOPCDAHost + // + this.textBoxOPCDAHost.Location = new System.Drawing.Point(36, 19); + this.textBoxOPCDAHost.Name = "textBoxOPCDAHost"; + this.textBoxOPCDAHost.Size = new System.Drawing.Size(100, 21); + this.textBoxOPCDAHost.TabIndex = 46; + this.textBoxOPCDAHost.Text = "127.0.0.1"; + this.textBoxOPCDAHost.TextChanged += new System.EventHandler(this.TextBoxOPCDAHost_TextChanged); + // + // labelOPCDAHost + // + this.labelOPCDAHost.AutoSize = true; + this.labelOPCDAHost.Location = new System.Drawing.Point(6, 22); + this.labelOPCDAHost.Name = "labelOPCDAHost"; + this.labelOPCDAHost.Size = new System.Drawing.Size(29, 12); + this.labelOPCDAHost.TabIndex = 7; + this.labelOPCDAHost.Text = "Host"; + // + // textBoxOpcIp + // + this.textBoxOpcIp.Location = new System.Drawing.Point(6, 0); + this.textBoxOpcIp.Name = "textBoxOpcIp"; + this.textBoxOpcIp.Size = new System.Drawing.Size(100, 21); + this.textBoxOpcIp.TabIndex = 0; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.textBoxOPCUATopic); + this.groupBox5.Controls.Add(this.labelopcua); + this.groupBox5.Location = new System.Drawing.Point(293, 266); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(211, 45); + this.groupBox5.TabIndex = 19; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "OPC_UA Capture"; + this.groupBox5.Enter += new System.EventHandler(this.groupBox5_Enter); + // + // textBoxOPCUATopic + // + this.textBoxOPCUATopic.Location = new System.Drawing.Point(35, 17); + this.textBoxOPCUATopic.Name = "textBoxOPCUATopic"; + this.textBoxOPCUATopic.ReadOnly = true; + this.textBoxOPCUATopic.Size = new System.Drawing.Size(168, 21); + this.textBoxOPCUATopic.TabIndex = 5; + this.textBoxOPCUATopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxOPCUATopic.TextChanged += new System.EventHandler(this.TextBoxOPCUATopic_TextChanged); + // + // labelopcua + // + this.labelopcua.AutoSize = true; + this.labelopcua.Location = new System.Drawing.Point(6, 19); + this.labelopcua.Name = "labelopcua"; + this.labelopcua.Size = new System.Drawing.Size(17, 12); + this.labelopcua.TabIndex = 6; + this.labelopcua.Text = "To"; + // + // groupBox6 + // + this.groupBox6.Controls.Add(this.textBoxBACnetTopic); + this.groupBox6.Controls.Add(this.label23); + this.groupBox6.Location = new System.Drawing.Point(293, 326); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(211, 42); + this.groupBox6.TabIndex = 20; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "BACnet Capture"; + this.groupBox6.Enter += new System.EventHandler(this.groupBox6_Enter); + // + // textBoxBACnetTopic + // + this.textBoxBACnetTopic.Location = new System.Drawing.Point(31, 17); + this.textBoxBACnetTopic.Name = "textBoxBACnetTopic"; + this.textBoxBACnetTopic.ReadOnly = true; + this.textBoxBACnetTopic.Size = new System.Drawing.Size(169, 21); + this.textBoxBACnetTopic.TabIndex = 5; + this.textBoxBACnetTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxBACnetTopic.TextChanged += new System.EventHandler(this.TextBoxBACnetTopic_TextChanged); + // + // label23 + // + this.label23.AutoSize = true; + this.label23.Location = new System.Drawing.Point(7, 21); + this.label23.Name = "label23"; + this.label23.Size = new System.Drawing.Size(17, 12); + this.label23.TabIndex = 6; + this.label23.Text = "To"; + // + // groupBox7 + // + this.groupBox7.Controls.Add(this.textBoxControlTopic); + this.groupBox7.Controls.Add(this.label8); + this.groupBox7.Location = new System.Drawing.Point(293, 383); + this.groupBox7.Name = "groupBox7"; + this.groupBox7.Size = new System.Drawing.Size(211, 47); + this.groupBox7.TabIndex = 21; + this.groupBox7.TabStop = false; + this.groupBox7.Text = "Control Capture"; + // + // textBoxControlTopic + // + this.textBoxControlTopic.Location = new System.Drawing.Point(33, 17); + this.textBoxControlTopic.Name = "textBoxControlTopic"; + this.textBoxControlTopic.ReadOnly = true; + this.textBoxControlTopic.Size = new System.Drawing.Size(170, 21); + this.textBoxControlTopic.TabIndex = 5; + this.textBoxControlTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxControlTopic.TextChanged += new System.EventHandler(this.TextBoxControlTopic_TextChanged); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(6, 21); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(17, 12); + this.label8.TabIndex = 6; + this.label8.Text = "To"; + // + // comboBoxBridge + // + this.comboBoxBridge.FormattingEnabled = true; + this.comboBoxBridge.Items.AddRange(new object[] { "SerialPort,", "TcpServer,", "BACnet,", @@ -800,403 +805,404 @@ private void InitializeComponent() "PLC,", "Control,", "Access,", - "SqlServer"}); - this.comboBoxBridge.Location = new System.Drawing.Point(42, 491); - this.comboBoxBridge.Name = "comboBoxBridge"; - this.comboBoxBridge.Size = new System.Drawing.Size(76, 20); - this.comboBoxBridge.TabIndex = 13; - this.comboBoxBridge.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBridge_SelectedIndexChanged); - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(9, 495); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(17, 12); - this.label7.TabIndex = 18; - this.label7.Text = "To"; - // - // groupBox8 - // - this.groupBox8.Controls.Add(this.textBoxAccessTopic); - this.groupBox8.Controls.Add(this.label6); - this.groupBox8.Location = new System.Drawing.Point(293, 437); - this.groupBox8.Name = "groupBox8"; - this.groupBox8.Size = new System.Drawing.Size(211, 43); - this.groupBox8.TabIndex = 22; - this.groupBox8.TabStop = false; - this.groupBox8.Text = "Access Capture"; - this.groupBox8.Enter += new System.EventHandler(this.groupBox8_Enter); - // - // textBoxAccessTopic - // - this.textBoxAccessTopic.Location = new System.Drawing.Point(33, 17); - this.textBoxAccessTopic.Name = "textBoxAccessTopic"; - this.textBoxAccessTopic.ReadOnly = true; - this.textBoxAccessTopic.Size = new System.Drawing.Size(170, 21); - this.textBoxAccessTopic.TabIndex = 5; - this.textBoxAccessTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxAccessTopic.TextChanged += new System.EventHandler(this.TextBoxAccessTopic_TextChanged); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(6, 21); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(17, 12); - this.label6.TabIndex = 6; - this.label6.Text = "To"; - // - // groupBox10 - // - this.groupBox10.Controls.Add(this.label15); - this.groupBox10.Controls.Add(this.textBoxUDPClientLogin); - this.groupBox10.Location = new System.Drawing.Point(572, 274); - this.groupBox10.Name = "groupBox10"; - this.groupBox10.Size = new System.Drawing.Size(215, 46); - this.groupBox10.TabIndex = 19; - this.groupBox10.TabStop = false; - this.groupBox10.Text = "UDP Client Channel"; - // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(5, 25); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(35, 12); - this.label15.TabIndex = 13; - this.label15.Text = "login"; - // - // radioButtonMqttClient - // - this.radioButtonMqttClient.AutoSize = true; - this.radioButtonMqttClient.Checked = true; - this.radioButtonMqttClient.Location = new System.Drawing.Point(559, 78); - this.radioButtonMqttClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.radioButtonMqttClient.Name = "radioButtonMqttClient"; - this.radioButtonMqttClient.Size = new System.Drawing.Size(14, 13); - this.radioButtonMqttClient.TabIndex = 30; - this.radioButtonMqttClient.TabStop = true; - this.radioButtonMqttClient.UseVisualStyleBackColor = true; - this.radioButtonMqttClient.CheckedChanged += new System.EventHandler(this.RadioButtonMqttClient_CheckedChanged); - // - // radioButtonTcpClient - // - this.radioButtonTcpClient.AutoSize = true; - this.radioButtonTcpClient.Location = new System.Drawing.Point(553, 207); - this.radioButtonTcpClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.radioButtonTcpClient.Name = "radioButtonTcpClient"; - this.radioButtonTcpClient.Size = new System.Drawing.Size(14, 13); - this.radioButtonTcpClient.TabIndex = 31; - this.radioButtonTcpClient.UseVisualStyleBackColor = true; - this.radioButtonTcpClient.CheckedChanged += new System.EventHandler(this.RadioButtonTcpClient_CheckedChanged); - // - // radioButtonUDPClient - // - this.radioButtonUDPClient.AutoSize = true; - this.radioButtonUDPClient.Location = new System.Drawing.Point(553, 291); - this.radioButtonUDPClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.radioButtonUDPClient.Name = "radioButtonUDPClient"; - this.radioButtonUDPClient.Size = new System.Drawing.Size(14, 13); - this.radioButtonUDPClient.TabIndex = 32; - this.radioButtonUDPClient.UseVisualStyleBackColor = true; - this.radioButtonUDPClient.CheckedChanged += new System.EventHandler(this.RadioButtonUDPClient_CheckedChanged); - // - // groupBox12 - // - this.groupBox12.Controls.Add(this.textBoxPLCTopic); - this.groupBox12.Controls.Add(this.label2); - this.groupBox12.Location = new System.Drawing.Point(295, 130); - this.groupBox12.Name = "groupBox12"; - this.groupBox12.Size = new System.Drawing.Size(211, 44); - this.groupBox12.TabIndex = 19; - this.groupBox12.TabStop = false; - this.groupBox12.Text = "PLC Capture"; - // - // textBoxPLCTopic - // - this.textBoxPLCTopic.Location = new System.Drawing.Point(39, 15); - this.textBoxPLCTopic.Name = "textBoxPLCTopic"; - this.textBoxPLCTopic.ReadOnly = true; - this.textBoxPLCTopic.Size = new System.Drawing.Size(165, 21); - this.textBoxPLCTopic.TabIndex = 5; - this.textBoxPLCTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxPLCTopic.TextChanged += new System.EventHandler(this.TextBoxPLCTopic_TextChanged); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(4, 19); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(17, 12); - this.label2.TabIndex = 6; - this.label2.Text = "To"; - // - // pictureBox1 - // - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(511, -43); - this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(53, 512); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pictureBox1.TabIndex = 35; - this.pictureBox1.TabStop = false; - // - // comboBoxLogLevel - // - this.comboBoxLogLevel.FormattingEnabled = true; - this.comboBoxLogLevel.Location = new System.Drawing.Point(585, 491); - this.comboBoxLogLevel.Name = "comboBoxLogLevel"; - this.comboBoxLogLevel.Size = new System.Drawing.Size(56, 20); - this.comboBoxLogLevel.TabIndex = 36; - this.comboBoxLogLevel.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLogLevel_SelectedIndexChanged); - // - // label32 - // - this.label32.AutoSize = true; - this.label32.Location = new System.Drawing.Point(515, 495); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(59, 12); - this.label32.TabIndex = 37; - this.label32.Text = "Log Level"; - // - // comboBoxLan - // - this.comboBoxLan.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLan.FormattingEnabled = true; - this.comboBoxLan.Location = new System.Drawing.Point(712, 492); - this.comboBoxLan.Name = "comboBoxLan"; - this.comboBoxLan.Size = new System.Drawing.Size(71, 20); - this.comboBoxLan.TabIndex = 38; - this.comboBoxLan.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLan_SelectedIndexChanged); - // - // label33 - // - this.label33.AutoSize = true; - this.label33.Location = new System.Drawing.Point(649, 495); - this.label33.Name = "label33"; - this.label33.Size = new System.Drawing.Size(53, 12); - this.label33.TabIndex = 39; - this.label33.Text = "Language"; - // - // treeView - // - this.treeView.CheckBoxes = true; - this.treeView.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.treeView.LabelEdit = true; - this.treeView.Location = new System.Drawing.Point(3, 24); - this.treeView.Margin = new System.Windows.Forms.Padding(2); - this.treeView.Name = "treeView"; - this.treeView.Size = new System.Drawing.Size(287, 210); - this.treeView.TabIndex = 0; - this.treeView.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.AfterLabelEdit); - this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterCheck); - this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterSelect); - this.treeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.NodeMouseDoubleClick); - // - // label_devcietree - // - this.label_devcietree.Location = new System.Drawing.Point(7, 3); - this.label_devcietree.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label_devcietree.Name = "label_devcietree"; - this.label_devcietree.Size = new System.Drawing.Size(67, 15); - this.label_devcietree.TabIndex = 41; - this.label_devcietree.Text = "DeviceTree"; - // - // openFileDialog - // - this.openFileDialog.FileName = "openFileDialog"; - this.openFileDialog.Filter = "(*.txt)|*.txt"; - this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog_FileOk); - // - // groupBoxCommonConfig - // - this.groupBoxCommonConfig.Controls.Add(this.comboBoxDtuAddr); - this.groupBoxCommonConfig.Controls.Add(this.label22); - this.groupBoxCommonConfig.Controls.Add(this.label30); - this.groupBoxCommonConfig.Controls.Add(this.textBoxBridgePort); - this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotSever); - this.groupBoxCommonConfig.Controls.Add(this.label21); - this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotPort); - this.groupBoxCommonConfig.Controls.Add(this.checkBoxBridge); - this.groupBoxCommonConfig.Controls.Add(this.buttonStartStop); - this.groupBoxCommonConfig.Controls.Add(this.checkBoxReconnect); - this.groupBoxCommonConfig.Location = new System.Drawing.Point(569, 328); - this.groupBoxCommonConfig.Name = "groupBoxCommonConfig"; - this.groupBoxCommonConfig.Size = new System.Drawing.Size(219, 157); - this.groupBoxCommonConfig.TabIndex = 19; - this.groupBoxCommonConfig.TabStop = false; - this.groupBoxCommonConfig.Text = "Common Config"; - // - // buttonScan - // - this.buttonScan.Location = new System.Drawing.Point(457, 490); - this.buttonScan.Name = "buttonScan"; - this.buttonScan.Size = new System.Drawing.Size(53, 21); - this.buttonScan.TabIndex = 40; - this.buttonScan.Text = "Scan"; - this.buttonScan.UseVisualStyleBackColor = true; - this.buttonScan.Click += new System.EventHandler(this.ButtonScan_Click); - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(143)))), ((int)(((byte)(178))))); - this.ClientSize = new System.Drawing.Size(803, 521); - this.Controls.Add(this.buttonScan); - this.Controls.Add(this.groupBoxCommonConfig); - this.Controls.Add(this.groupBox8); - this.Controls.Add(this.buttonClear); - this.Controls.Add(this.groupBox7); - this.Controls.Add(this.groupBox6); - this.Controls.Add(this.groupBox5); - this.Controls.Add(this.groupBox4); - this.Controls.Add(this.groupBox12); - this.Controls.Add(this.groupBoxSerialPort); - this.Controls.Add(this.comboBoxLan); - this.Controls.Add(this.label33); - this.Controls.Add(this.groupBox3); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox10); - this.Controls.Add(this.radioButtonUDPClient); - this.Controls.Add(this.radioButtonTcpClient); - this.Controls.Add(this.radioButtonMqttClient); - this.Controls.Add(this.label_devcietree); - this.Controls.Add(this.treeView); - this.Controls.Add(this.label32); - this.Controls.Add(this.comboBoxLogLevel); - this.Controls.Add(this.label7); - this.Controls.Add(this.comboBoxBridge); - this.Controls.Add(this.checkBoxDisplayHex); - this.Controls.Add(this.sendBridge); - this.Controls.Add(this.textToPayload); - this.Controls.Add(this.linkLabel2); - this.Controls.Add(this.textBoxLog); - this.Controls.Add(this.pictureBox1); - this.ForeColor = System.Drawing.SystemColors.ControlText; - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "MainForm"; - this.Text = "dgiot_dtu"; - this.Load += new System.EventHandler(this.MainForm_Load); - this.Resize += new System.EventHandler(this.MainForm_Resize); - this.groupBoxSerialPort.ResumeLayout(false); - this.groupBoxSerialPort.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.groupBox3.ResumeLayout(false); - this.groupBox3.PerformLayout(); - this.groupBox4.ResumeLayout(false); - this.groupBox4.PerformLayout(); - this.groupBox5.ResumeLayout(false); - this.groupBox5.PerformLayout(); - this.groupBox6.ResumeLayout(false); - this.groupBox6.PerformLayout(); - this.groupBox7.ResumeLayout(false); - this.groupBox7.PerformLayout(); - this.groupBox8.ResumeLayout(false); - this.groupBox8.PerformLayout(); - this.groupBox10.ResumeLayout(false); - this.groupBox10.PerformLayout(); - this.groupBox12.ResumeLayout(false); - this.groupBox12.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.groupBoxCommonConfig.ResumeLayout(false); - this.groupBoxCommonConfig.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } + "SqlServer" + }); + this.comboBoxBridge.Location = new System.Drawing.Point(42, 491); + this.comboBoxBridge.Name = "comboBoxBridge"; + this.comboBoxBridge.Size = new System.Drawing.Size(76, 20); + this.comboBoxBridge.TabIndex = 13; + this.comboBoxBridge.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBridge_SelectedIndexChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(9, 495); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(17, 12); + this.label7.TabIndex = 18; + this.label7.Text = "To"; + // + // groupBox8 + // + this.groupBox8.Controls.Add(this.textBoxAccessTopic); + this.groupBox8.Controls.Add(this.label6); + this.groupBox8.Location = new System.Drawing.Point(293, 437); + this.groupBox8.Name = "groupBox8"; + this.groupBox8.Size = new System.Drawing.Size(211, 43); + this.groupBox8.TabIndex = 22; + this.groupBox8.TabStop = false; + this.groupBox8.Text = "Access Capture"; + this.groupBox8.Enter += new System.EventHandler(this.groupBox8_Enter); + // + // textBoxAccessTopic + // + this.textBoxAccessTopic.Location = new System.Drawing.Point(33, 17); + this.textBoxAccessTopic.Name = "textBoxAccessTopic"; + this.textBoxAccessTopic.ReadOnly = true; + this.textBoxAccessTopic.Size = new System.Drawing.Size(170, 21); + this.textBoxAccessTopic.TabIndex = 5; + this.textBoxAccessTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxAccessTopic.TextChanged += new System.EventHandler(this.TextBoxAccessTopic_TextChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 21); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(17, 12); + this.label6.TabIndex = 6; + this.label6.Text = "To"; + // + // groupBox10 + // + this.groupBox10.Controls.Add(this.label15); + this.groupBox10.Controls.Add(this.textBoxUDPClientLogin); + this.groupBox10.Location = new System.Drawing.Point(572, 274); + this.groupBox10.Name = "groupBox10"; + this.groupBox10.Size = new System.Drawing.Size(215, 46); + this.groupBox10.TabIndex = 19; + this.groupBox10.TabStop = false; + this.groupBox10.Text = "UDP Client Channel"; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(5, 25); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(35, 12); + this.label15.TabIndex = 13; + this.label15.Text = "login"; + // + // radioButtonMqttClient + // + this.radioButtonMqttClient.AutoSize = true; + this.radioButtonMqttClient.Checked = true; + this.radioButtonMqttClient.Location = new System.Drawing.Point(559, 78); + this.radioButtonMqttClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); + this.radioButtonMqttClient.Name = "radioButtonMqttClient"; + this.radioButtonMqttClient.Size = new System.Drawing.Size(14, 13); + this.radioButtonMqttClient.TabIndex = 30; + this.radioButtonMqttClient.TabStop = true; + this.radioButtonMqttClient.UseVisualStyleBackColor = true; + this.radioButtonMqttClient.CheckedChanged += new System.EventHandler(this.RadioButtonMqttClient_CheckedChanged); + // + // radioButtonTcpClient + // + this.radioButtonTcpClient.AutoSize = true; + this.radioButtonTcpClient.Location = new System.Drawing.Point(553, 207); + this.radioButtonTcpClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); + this.radioButtonTcpClient.Name = "radioButtonTcpClient"; + this.radioButtonTcpClient.Size = new System.Drawing.Size(14, 13); + this.radioButtonTcpClient.TabIndex = 31; + this.radioButtonTcpClient.UseVisualStyleBackColor = true; + this.radioButtonTcpClient.CheckedChanged += new System.EventHandler(this.RadioButtonTcpClient_CheckedChanged); + // + // radioButtonUDPClient + // + this.radioButtonUDPClient.AutoSize = true; + this.radioButtonUDPClient.Location = new System.Drawing.Point(553, 291); + this.radioButtonUDPClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); + this.radioButtonUDPClient.Name = "radioButtonUDPClient"; + this.radioButtonUDPClient.Size = new System.Drawing.Size(14, 13); + this.radioButtonUDPClient.TabIndex = 32; + this.radioButtonUDPClient.UseVisualStyleBackColor = true; + this.radioButtonUDPClient.CheckedChanged += new System.EventHandler(this.RadioButtonUDPClient_CheckedChanged); + // + // groupBox12 + // + this.groupBox12.Controls.Add(this.textBoxPLCTopic); + this.groupBox12.Controls.Add(this.label2); + this.groupBox12.Location = new System.Drawing.Point(295, 130); + this.groupBox12.Name = "groupBox12"; + this.groupBox12.Size = new System.Drawing.Size(211, 44); + this.groupBox12.TabIndex = 19; + this.groupBox12.TabStop = false; + this.groupBox12.Text = "PLC Capture"; + // + // textBoxPLCTopic + // + this.textBoxPLCTopic.Location = new System.Drawing.Point(39, 15); + this.textBoxPLCTopic.Name = "textBoxPLCTopic"; + this.textBoxPLCTopic.ReadOnly = true; + this.textBoxPLCTopic.Size = new System.Drawing.Size(165, 21); + this.textBoxPLCTopic.TabIndex = 5; + this.textBoxPLCTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxPLCTopic.TextChanged += new System.EventHandler(this.TextBoxPLCTopic_TextChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 19); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(17, 12); + this.label2.TabIndex = 6; + this.label2.Text = "To"; + // + // pictureBox1 + // + this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.Location = new System.Drawing.Point(511, -43); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(53, 512); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 35; + this.pictureBox1.TabStop = false; + // + // comboBoxLogLevel + // + this.comboBoxLogLevel.FormattingEnabled = true; + this.comboBoxLogLevel.Location = new System.Drawing.Point(585, 491); + this.comboBoxLogLevel.Name = "comboBoxLogLevel"; + this.comboBoxLogLevel.Size = new System.Drawing.Size(56, 20); + this.comboBoxLogLevel.TabIndex = 36; + this.comboBoxLogLevel.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLogLevel_SelectedIndexChanged); + // + // label32 + // + this.label32.AutoSize = true; + this.label32.Location = new System.Drawing.Point(515, 495); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(59, 12); + this.label32.TabIndex = 37; + this.label32.Text = "Log Level"; + // + // comboBoxLan + // + this.comboBoxLan.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLan.FormattingEnabled = true; + this.comboBoxLan.Location = new System.Drawing.Point(712, 492); + this.comboBoxLan.Name = "comboBoxLan"; + this.comboBoxLan.Size = new System.Drawing.Size(71, 20); + this.comboBoxLan.TabIndex = 38; + this.comboBoxLan.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLan_SelectedIndexChanged); + // + // label33 + // + this.label33.AutoSize = true; + this.label33.Location = new System.Drawing.Point(649, 495); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(53, 12); + this.label33.TabIndex = 39; + this.label33.Text = "Language"; + // + // treeView + // + this.treeView.CheckBoxes = true; + this.treeView.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.treeView.LabelEdit = true; + this.treeView.Location = new System.Drawing.Point(3, 24); + this.treeView.Margin = new System.Windows.Forms.Padding(2); + this.treeView.Name = "treeView"; + this.treeView.Size = new System.Drawing.Size(287, 210); + this.treeView.TabIndex = 0; + this.treeView.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.AfterLabelEdit); + this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterCheck); + this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterSelect); + this.treeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.NodeMouseDoubleClick); + // + // label_devcietree + // + this.label_devcietree.Location = new System.Drawing.Point(7, 3); + this.label_devcietree.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label_devcietree.Name = "label_devcietree"; + this.label_devcietree.Size = new System.Drawing.Size(67, 15); + this.label_devcietree.TabIndex = 41; + this.label_devcietree.Text = "DeviceTree"; + // + // openFileDialog + // + this.openFileDialog.FileName = "openFileDialog"; + this.openFileDialog.Filter = "(*.txt)|*.txt"; + this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog_FileOk); + // + // groupBoxCommonConfig + // + this.groupBoxCommonConfig.Controls.Add(this.comboBoxDtuAddr); + this.groupBoxCommonConfig.Controls.Add(this.label22); + this.groupBoxCommonConfig.Controls.Add(this.label30); + this.groupBoxCommonConfig.Controls.Add(this.textBoxBridgePort); + this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotSever); + this.groupBoxCommonConfig.Controls.Add(this.label21); + this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotPort); + this.groupBoxCommonConfig.Controls.Add(this.checkBoxBridge); + this.groupBoxCommonConfig.Controls.Add(this.buttonStartStop); + this.groupBoxCommonConfig.Controls.Add(this.checkBoxReconnect); + this.groupBoxCommonConfig.Location = new System.Drawing.Point(569, 328); + this.groupBoxCommonConfig.Name = "groupBoxCommonConfig"; + this.groupBoxCommonConfig.Size = new System.Drawing.Size(219, 157); + this.groupBoxCommonConfig.TabIndex = 19; + this.groupBoxCommonConfig.TabStop = false; + this.groupBoxCommonConfig.Text = "Common Config"; + // + // buttonScan + // + this.buttonScan.Location = new System.Drawing.Point(457, 490); + this.buttonScan.Name = "buttonScan"; + this.buttonScan.Size = new System.Drawing.Size(53, 21); + this.buttonScan.TabIndex = 40; + this.buttonScan.Text = "Scan"; + this.buttonScan.UseVisualStyleBackColor = true; + this.buttonScan.Click += new System.EventHandler(this.ButtonScan_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(143)))), ((int)(((byte)(178))))); + this.ClientSize = new System.Drawing.Size(803, 521); + this.Controls.Add(this.buttonScan); + this.Controls.Add(this.groupBoxCommonConfig); + this.Controls.Add(this.groupBox8); + this.Controls.Add(this.buttonClear); + this.Controls.Add(this.groupBox7); + this.Controls.Add(this.groupBox6); + this.Controls.Add(this.groupBox5); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.groupBox12); + this.Controls.Add(this.groupBoxSerialPort); + this.Controls.Add(this.comboBoxLan); + this.Controls.Add(this.label33); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox10); + this.Controls.Add(this.radioButtonUDPClient); + this.Controls.Add(this.radioButtonTcpClient); + this.Controls.Add(this.radioButtonMqttClient); + this.Controls.Add(this.label_devcietree); + this.Controls.Add(this.treeView); + this.Controls.Add(this.label32); + this.Controls.Add(this.comboBoxLogLevel); + this.Controls.Add(this.label7); + this.Controls.Add(this.comboBoxBridge); + this.Controls.Add(this.checkBoxDisplayHex); + this.Controls.Add(this.sendBridge); + this.Controls.Add(this.textToPayload); + this.Controls.Add(this.linkLabel2); + this.Controls.Add(this.textBoxLog); + this.Controls.Add(this.pictureBox1); + this.ForeColor = System.Drawing.SystemColors.ControlText; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "MainForm"; + this.Text = "dgiot_dtu"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.Resize += new System.EventHandler(this.MainForm_Resize); + this.groupBoxSerialPort.ResumeLayout(false); + this.groupBoxSerialPort.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); + this.groupBox6.ResumeLayout(false); + this.groupBox6.PerformLayout(); + this.groupBox7.ResumeLayout(false); + this.groupBox7.PerformLayout(); + this.groupBox8.ResumeLayout(false); + this.groupBox8.PerformLayout(); + this.groupBox10.ResumeLayout(false); + this.groupBox10.PerformLayout(); + this.groupBox12.ResumeLayout(false); + this.groupBox12.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.groupBoxCommonConfig.ResumeLayout(false); + this.groupBoxCommonConfig.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); - #endregion - private TreeView treeView; - private System.Windows.Forms.Button buttonStartStop; - private System.Windows.Forms.TextBox textBoxLog; - private System.Windows.Forms.CheckBox checkBoxReconnect; - private System.Windows.Forms.CheckBox checkBoxDisplayHex; - private System.Windows.Forms.Button buttonClear; - private System.Windows.Forms.GroupBox groupBoxSerialPort; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox comboBoxBaudRate; - private System.Windows.Forms.Label labelSerialPort; - private System.Windows.Forms.ComboBox comboBoxSerialPort; - private System.Windows.Forms.TextBox textBoxBridgePort; - private System.Windows.Forms.LinkLabel linkLabel2; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.ComboBox comboBoxDataBits; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.ComboBox comboBoxStopBits; - private System.Windows.Forms.TextBox textToPayload; - private System.Windows.Forms.Button sendBridge; - private System.Windows.Forms.TextBox textBoxMqttPassword; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.TextBox textBoxMqttUserName; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox textBoxMqttSubTopic; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.TextBox textBoxMqttPubTopic; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label16; - private System.Windows.Forms.TextBox textBoxTcpClientLogin; - private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.Label label20; - private System.Windows.Forms.TextBox textBoxMqttClientId; - private System.Windows.Forms.TextBox textBoxDgiotPort; - private System.Windows.Forms.Label label21; - private System.Windows.Forms.Label label22; - private System.Windows.Forms.CheckBox checkBoxBridge; - private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.GroupBox groupBox5; - private System.Windows.Forms.TextBox textBoxOPCUATopic; - private System.Windows.Forms.Label labelopcua; - private System.Windows.Forms.GroupBox groupBox6; - private System.Windows.Forms.TextBox textBoxBACnetTopic; - private System.Windows.Forms.Label label23; - private System.Windows.Forms.GroupBox groupBox7; - private System.Windows.Forms.TextBox textBoxControlTopic; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.ComboBox comboBoxBridge; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.GroupBox groupBox8; - private System.Windows.Forms.TextBox textBoxAccessTopic; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.GroupBox groupBox10; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.TextBox textBoxUDPClientLogin; - private System.Windows.Forms.RadioButton radioButtonMqttClient; - private System.Windows.Forms.RadioButton radioButtonTcpClient; - private System.Windows.Forms.RadioButton radioButtonUDPClient; - private System.Windows.Forms.GroupBox groupBox12; - private System.Windows.Forms.TextBox textBoxPLCTopic; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.ComboBox comboBoxParity; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Label label29; - private System.Windows.Forms.ComboBox comboBoxCmdProdxy; - private System.Windows.Forms.Label label30; - private System.Windows.Forms.ComboBox comboBoxDtuAddr; - private System.Windows.Forms.TextBox textBoxOpcIp; - private System.Windows.Forms.TextBox textBoxDgiotSever; - private System.Windows.Forms.ComboBox comboBoxLogLevel; - private System.Windows.Forms.Label label32; - private System.Windows.Forms.ComboBox comboBoxLan; - private System.Windows.Forms.Label label33; - private System.Windows.Forms.Label label_devcietree; - private TextBox textBoxOPCDAHost; - private Label labelOPCDAHost; - private OpenFileDialog openFileDialog; - private CheckBox checkBoxOPCDA; - private Label labelSecond; - private Label labelOPCDAMonitor; - private TextBox textBoxOPCDAInterval; - private GroupBox groupBoxCommonConfig; - private Label labelOPCDACount; - private TextBox textBoxOPCDACount; - private Button buttonScan; } + + #endregion + private TreeView treeView; + private System.Windows.Forms.Button buttonStartStop; + private System.Windows.Forms.TextBox textBoxLog; + private System.Windows.Forms.CheckBox checkBoxReconnect; + private System.Windows.Forms.CheckBox checkBoxDisplayHex; + private System.Windows.Forms.Button buttonClear; + private System.Windows.Forms.GroupBox groupBoxSerialPort; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBoxBaudRate; + private System.Windows.Forms.Label labelSerialPort; + private System.Windows.Forms.ComboBox comboBoxSerialPort; + private System.Windows.Forms.TextBox textBoxBridgePort; + private System.Windows.Forms.LinkLabel linkLabel2; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox comboBoxDataBits; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ComboBox comboBoxStopBits; + private System.Windows.Forms.TextBox textToPayload; + private System.Windows.Forms.Button sendBridge; + private System.Windows.Forms.TextBox textBoxMqttPassword; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox textBoxMqttUserName; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox textBoxMqttSubTopic; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox textBoxMqttPubTopic; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.TextBox textBoxTcpClientLogin; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.Label label20; + private System.Windows.Forms.TextBox textBoxMqttClientId; + private System.Windows.Forms.TextBox textBoxDgiotPort; + private System.Windows.Forms.Label label21; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.CheckBox checkBoxBridge; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.TextBox textBoxOPCUATopic; + private System.Windows.Forms.Label labelopcua; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.TextBox textBoxBACnetTopic; + private System.Windows.Forms.Label label23; + private System.Windows.Forms.GroupBox groupBox7; + private System.Windows.Forms.TextBox textBoxControlTopic; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.ComboBox comboBoxBridge; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.GroupBox groupBox8; + private System.Windows.Forms.TextBox textBoxAccessTopic; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.GroupBox groupBox10; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox textBoxUDPClientLogin; + private System.Windows.Forms.RadioButton radioButtonMqttClient; + private System.Windows.Forms.RadioButton radioButtonTcpClient; + private System.Windows.Forms.RadioButton radioButtonUDPClient; + private System.Windows.Forms.GroupBox groupBox12; + private System.Windows.Forms.TextBox textBoxPLCTopic; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.ComboBox comboBoxParity; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label29; + private System.Windows.Forms.ComboBox comboBoxCmdProdxy; + private System.Windows.Forms.Label label30; + private System.Windows.Forms.ComboBox comboBoxDtuAddr; + private System.Windows.Forms.TextBox textBoxOpcIp; + private System.Windows.Forms.TextBox textBoxDgiotSever; + private System.Windows.Forms.ComboBox comboBoxLogLevel; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.ComboBox comboBoxLan; + private System.Windows.Forms.Label label33; + private System.Windows.Forms.Label label_devcietree; + private TextBox textBoxOPCDAHost; + private Label labelOPCDAHost; + private OpenFileDialog openFileDialog; + private CheckBox checkBoxOPCDA; + private Label labelSecond; + private Label labelOPCDAMonitor; + private TextBox textBoxOPCDAInterval; + private GroupBox groupBoxCommonConfig; + private Label labelOPCDACount; + private TextBox textBoxOPCDACount; + private Button buttonScan; +} } diff --git a/MainForm.cs b/MainForm.cs index 3aa26aa..dfd87bf 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -4,1161 +4,1161 @@ namespace Dgiot_dtu { - using System; - using System.Collections.Generic; - using System.Configuration; - using System.Diagnostics; - using System.Drawing; - using System.Text.RegularExpressions; - using System.Windows.Forms; - using System.Drawing.Printing; - using System.Runtime.InteropServices; - public partial class MainForm : Form - { - private delegate void LogHandler(string text); - - private static string clientid = Guid.NewGuid().ToString().Substring(0, 10); - private static string productid = Guid.NewGuid().ToString().Substring(0, 10); - private static string devaddr = Guid.NewGuid().ToString().Substring(0, 10); - private static LogHelper logHelper = LogHelper.GetInstance(); - private static OPCDAHelper oPCDAHelper = OPCDAHelper.GetInstance(); - private static OPCDAViewHelper oPCDAViewHelper = OPCDAViewHelper.GetInstance(); - private static TcpClientHelper tcpClientHelper = TcpClientHelper.GetInstance(); - private static TcpServerHelper tcpServerHelper = TcpServerHelper.GetInstance(); - private static PrinterHelper printerHelper = PrinterHelper.GetInstance(); - private bool bIsRunning = false; - private float x = 0; // 当前窗体的宽度 - private float y = 0; // 当前窗体的高度 - private readonly string[] bridges = new string[] - { - "SerialPort", - "TcpServer", - "BACnet", - "OPCUA", - "MqttClient", - "MqttServer", - "TcpClient", - "TcpServer", - "UdpClient", - "UdpServer", - "PLC", - "Control", - "Access", - "SqlServer", - "Barcode_Printer" - }; - - private Configuration config; - - public MainForm() - { - InitializeComponent(); - config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - ConfigHelper.Init(config); - TreeViewHelper.Init(treeView); - LogHelper.Init(this); - FileHelper.Init(openFileDialog); - SetComboBox(); - - Text += " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Diagnostics; +using System.Drawing; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Drawing.Printing; +using System.Runtime.InteropServices; +public partial class MainForm : Form +{ + private delegate void LogHandler(string text); + + private static string clientid = Guid.NewGuid().ToString().Substring(0, 10); + private static string productid = Guid.NewGuid().ToString().Substring(0, 10); + private static string devaddr = Guid.NewGuid().ToString().Substring(0, 10); + private static LogHelper logHelper = LogHelper.GetInstance(); + private static OPCDAHelper oPCDAHelper = OPCDAHelper.GetInstance(); + private static OPCDAViewHelper oPCDAViewHelper = OPCDAViewHelper.GetInstance(); + private static TcpClientHelper tcpClientHelper = TcpClientHelper.GetInstance(); + private static TcpServerHelper tcpServerHelper = TcpServerHelper.GetInstance(); + private static PrinterHelper printerHelper = PrinterHelper.GetInstance(); + private bool bIsRunning = false; + private float x = 0; // 当前窗体的宽度 + private float y = 0; // 当前窗体的高度 + private readonly string[] bridges = new string[] + { + "SerialPort", + "TcpServer", + "BACnet", + "OPCUA", + "MqttClient", + "MqttServer", + "TcpClient", + "TcpServer", + "UdpClient", + "UdpServer", + "PLC", + "Control", + "Access", + "SqlServer", + "Barcode_Printer" + }; + + private Configuration config; + + public MainForm() + { + InitializeComponent(); + config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + ConfigHelper.Init(config); + TreeViewHelper.Init(treeView); + LogHelper.Init(this); + FileHelper.Init(openFileDialog); + SetComboBox(); - try - { - RestoreConfigs(config); - SaveAppConfig(); - } - catch (Exception ex) - { - Log("read config exception: " + ex.Message); - } - } + Text += " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version; - public void Log(string text) + try { - if (InvokeRequired) - { - Invoke(new LogHandler(Log), new object[] { text }); - return; - } - - // Truncate - if (textBoxLog.Text.Length > 4096) - { - textBoxLog.Text = textBoxLog.Text.Substring(textBoxLog.Text.Length - 4096); - } - - textBoxLog.Text += text + "\r\n"; - textBoxLog.SelectionStart = textBoxLog.Text.Length - 1; - textBoxLog.ScrollToCaret(); + RestoreConfigs(config); + SaveAppConfig(); + } + catch (Exception ex) + { + Log("read config exception: " + ex.Message); } + } - private void ToStop() + public void Log(string text) + { + if (InvokeRequired) { - try - { - buttonStartStop.Text = @"Start"; - bIsRunning = false; - MqttClientHelper.Stop(); - MqttServerHelper.Stop(); - TcpClientHelper.Stop(); - TcpServerHelper.Stop(); - UDPClientHelper.Stop(); - UDPServerHelper.Stop(); - } - catch (Exception e) - { - Log("stop server exception:" + e.Message); - return; - } + Invoke(new LogHandler(Log), new object[] { text }); + return; } - private void ButtonStartStopClick(object sender, EventArgs e) + // Truncate + if (textBoxLog.Text.Length > 4096) { - if (!bIsRunning) - { - bIsRunning = true; - try - { - MqttServerHelper.Start(); - MqttClientHelper.Start(); - TcpClientHelper.Start(); - TcpServerHelper.Start(); - UDPServerHelper.Start(); - UDPClientHelper.Start(); - } - catch (Exception error) - { - Log("star error " + error.ToString()); - return; - } + textBoxLog.Text = textBoxLog.Text.Substring(textBoxLog.Text.Length - 4096); + } - buttonStartStop.Text = @"Stop"; + textBoxLog.Text += text + "\r\n"; + textBoxLog.SelectionStart = textBoxLog.Text.Length - 1; + textBoxLog.ScrollToCaret(); + } - DgiotHelper.GetIps(); - SaveAppConfig(); - } - else - { - ToStop(); - } + private void ToStop() + { + try + { + buttonStartStop.Text = @"Start"; + bIsRunning = false; + MqttClientHelper.Stop(); + MqttServerHelper.Stop(); + TcpClientHelper.Stop(); + TcpServerHelper.Stop(); + UDPClientHelper.Stop(); + UDPServerHelper.Stop(); } - - private void ButtonScan_Click(object sender, EventArgs e) + catch (Exception e) { - OPCDAHelper.Start(); - BACnetHelper.Start(); - SerialPortHelper.Start(); + Log("stop server exception:" + e.Message); + return; } + } - private void SetComboBox() + private void ButtonStartStopClick(object sender, EventArgs e) + { + if (!bIsRunning) { - var arrPorts = SerialPortHelper.GetPorts(); - comboBoxSerialPort.Items.Clear(); - foreach (var port in arrPorts) + bIsRunning = true; + try { - comboBoxSerialPort.Items.Add(port); + MqttServerHelper.Start(); + MqttClientHelper.Start(); + TcpClientHelper.Start(); + TcpServerHelper.Start(); + UDPServerHelper.Start(); + UDPClientHelper.Start(); } - - if (arrPorts.Length > 0) + catch (Exception error) { - comboBoxSerialPort.SelectedIndex = 0; + Log("star error " + error.ToString()); + return; } - comboBoxBaudRate.SelectedIndex = 7; - comboBoxDataBits.SelectedIndex = 0; - comboBoxStopBits.SelectedIndex = 0; - comboBoxParity.SelectedIndex = 0; - comboBoxCmdProdxy.SelectedIndex = 0; + buttonStartStop.Text = @"Stop"; - comboBoxBridge.Items.Clear(); + DgiotHelper.GetIps(); + SaveAppConfig(); + } + else + { + ToStop(); + } + } - foreach (var bridge in bridges) - { - comboBoxBridge.Items.Add(bridge); - } + private void ButtonScan_Click(object sender, EventArgs e) + { + OPCDAHelper.Start(); + BACnetHelper.Start(); + SerialPortHelper.Start(); + } - if (bridges.Length > 0) - { - comboBoxBridge.SelectedIndex = 0; - } + private void SetComboBox() + { + var arrPorts = SerialPortHelper.GetPorts(); + comboBoxSerialPort.Items.Clear(); + foreach (var port in arrPorts) + { + comboBoxSerialPort.Items.Add(port); + } - comboBoxDtuAddr.Items.Clear(); - List macAddrs = DgiotHelper.GetMacByWmi(); - foreach (var mac in macAddrs) - { - devaddr = Regex.Replace(mac, @":", ""); - comboBoxDtuAddr.Items.Add(devaddr); - textBoxTcpClientLogin.Text = devaddr; - textBoxUDPClientLogin.Text = devaddr; - } + if (arrPorts.Length > 0) + { + comboBoxSerialPort.SelectedIndex = 0; + } - comboBoxDtuAddr.SelectedIndex = 0; + comboBoxBaudRate.SelectedIndex = 7; + comboBoxDataBits.SelectedIndex = 0; + comboBoxStopBits.SelectedIndex = 0; + comboBoxParity.SelectedIndex = 0; + comboBoxCmdProdxy.SelectedIndex = 0; - List loglevels = LogHelper.Levels(); - foreach (var level in loglevels) - { - comboBoxLogLevel.Items.Add(level); - } + comboBoxBridge.Items.Clear(); - if (loglevels.Count > 0) - { - comboBoxLogLevel.SelectedIndex = (int)LogHelper.Level.DEBUG; - } + foreach (var bridge in bridges) + { + comboBoxBridge.Items.Add(bridge); + } - comboBoxLan.Items.Add("简体中文"); - comboBoxLan.Items.Add("English"); - comboBoxLan.SelectedIndex = 0; + if (bridges.Length > 0) + { + comboBoxBridge.SelectedIndex = 0; } - private void RestoreConfigs(Configuration config) + comboBoxDtuAddr.Items.Clear(); + List macAddrs = DgiotHelper.GetMacByWmi(); + foreach (var mac in macAddrs) { - RestoreMqtt(); - RestoreTcp(); - RestoreUDP(); - RestoreCommonConfig(); - RestoreSerialPort(); - RestorePLC(); - RestoreOPCDA(); - RestoreOPCUA(); - RestoreBACnet(); - RestoreControl(); - RestoreAccess(); - Resh_Topic(); - Resh_Config(); + devaddr = Regex.Replace(mac, @":", ""); + comboBoxDtuAddr.Items.Add(devaddr); + textBoxTcpClientLogin.Text = devaddr; + textBoxUDPClientLogin.Text = devaddr; } - private void RestoreCommonConfig() + comboBoxDtuAddr.SelectedIndex = 0; + + List loglevels = LogHelper.Levels(); + foreach (var level in loglevels) { - if (ConfigHelper.Check("DtuAddr")) - { - var tmp = ConfigHelper.GetConfig("DtuAddr"); - comboBoxDtuAddr.SelectedIndex = comboBoxDtuAddr.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); - } + comboBoxLogLevel.Items.Add(level); + } - if (ConfigHelper.Check("DgiotSever")) - { - textBoxDgiotSever.Text = ConfigHelper.GetConfig("DgiotSever"); - } - else - { - ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); - } + if (loglevels.Count > 0) + { + comboBoxLogLevel.SelectedIndex = (int)LogHelper.Level.DEBUG; + } - if (ConfigHelper.Check("DgiotPort")) - { - textBoxDgiotPort.Text = ConfigHelper.GetConfig("DgiotPort"); - } - else - { - ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); - } + comboBoxLan.Items.Add("简体中文"); + comboBoxLan.Items.Add("English"); + comboBoxLan.SelectedIndex = 0; + } - if (ConfigHelper.Check("BridgePort")) - { - textBoxBridgePort.Text = ConfigHelper.GetConfig("BridgePort"); - } - else - { - ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); - } + private void RestoreConfigs(Configuration config) + { + RestoreMqtt(); + RestoreTcp(); + RestoreUDP(); + RestoreCommonConfig(); + RestoreSerialPort(); + RestorePLC(); + RestoreOPCDA(); + RestoreOPCUA(); + RestoreBACnet(); + RestoreControl(); + RestoreAccess(); + Resh_Topic(); + Resh_Config(); + } - if (ConfigHelper.Check("ReconnectChecked")) - { - checkBoxReconnect.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); - } - else - { - ConfigHelper.SetConfig("ReconnectChecked", DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); - } + private void RestoreCommonConfig() + { + if (ConfigHelper.Check("DtuAddr")) + { + var tmp = ConfigHelper.GetConfig("DtuAddr"); + comboBoxDtuAddr.SelectedIndex = comboBoxDtuAddr.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); + } - if (ConfigHelper.Check("LogLevel")) - { - var tmp = ConfigHelper.GetConfig("LogLevel"); - comboBoxLogLevel.SelectedIndex = comboBoxLogLevel.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); - } + if (ConfigHelper.Check("DgiotSever")) + { + textBoxDgiotSever.Text = ConfigHelper.GetConfig("DgiotSever"); + } + else + { + ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); + } - if (ConfigHelper.Check("ToPayload")) - { - textToPayload.Text = ConfigHelper.GetConfig("ToPayload"); - } - else - { - ConfigHelper.SetConfig("ToPayload", textToPayload.Text); - } + if (ConfigHelper.Check("DgiotPort")) + { + textBoxDgiotPort.Text = ConfigHelper.GetConfig("DgiotPort"); + } + else + { + ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); + } - if (ConfigHelper.Check("DisplayHex")) - { - checkBoxDisplayHex.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("DisplayHex")); - } - else - { - ConfigHelper.SetConfig("DisplayHex", DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); - } + if (ConfigHelper.Check("BridgePort")) + { + textBoxBridgePort.Text = ConfigHelper.GetConfig("BridgePort"); + } + else + { + ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); + } - if (ConfigHelper.Check("Bridge_Checked")) - { - checkBoxBridge.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("Bridge_Checked")); - } - else - { - ConfigHelper.SetConfig("Bridge_Checked", DgiotHelper.BoolTostr(checkBoxBridge.Checked)); - } + if (ConfigHelper.Check("ReconnectChecked")) + { + checkBoxReconnect.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); + } + else + { + ConfigHelper.SetConfig("ReconnectChecked", DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); } - private void RestoreMqtt() + if (ConfigHelper.Check("LogLevel")) { - if (ConfigHelper.Check("MqttUserName")) - { - textBoxMqttUserName.Text = ConfigHelper.GetConfig("MqttUserName"); - } - else - { - ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); - } + var tmp = ConfigHelper.GetConfig("LogLevel"); + comboBoxLogLevel.SelectedIndex = comboBoxLogLevel.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); + } - if (ConfigHelper.Check("MqttPassword")) - { - textBoxMqttPassword.Text = ConfigHelper.GetConfig("MqttPassword"); - } - else - { - ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); - } + if (ConfigHelper.Check("ToPayload")) + { + textToPayload.Text = ConfigHelper.GetConfig("ToPayload"); + } + else + { + ConfigHelper.SetConfig("ToPayload", textToPayload.Text); + } - if (ConfigHelper.Check("MqttClientId")) - { - textBoxMqttClientId.Text = ConfigHelper.GetConfig("MqttClientId"); - } - else - { - ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); - } + if (ConfigHelper.Check("DisplayHex")) + { + checkBoxDisplayHex.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("DisplayHex")); + } + else + { + ConfigHelper.SetConfig("DisplayHex", DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); + } - if (ConfigHelper.Check("MqttPubTopic")) - { - textBoxMqttPubTopic.Text = ConfigHelper.GetConfig("MqttPubTopic"); - } - else - { - ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); - } + if (ConfigHelper.Check("Bridge_Checked")) + { + checkBoxBridge.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("Bridge_Checked")); + } + else + { + ConfigHelper.SetConfig("Bridge_Checked", DgiotHelper.BoolTostr(checkBoxBridge.Checked)); + } + } - if (ConfigHelper.Check("MqttSubTopic")) - { - textBoxMqttSubTopic.Text = ConfigHelper.GetConfig("MqttSubTopic"); - } - else - { - ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); - } + private void RestoreMqtt() + { + if (ConfigHelper.Check("MqttUserName")) + { + textBoxMqttUserName.Text = ConfigHelper.GetConfig("MqttUserName"); + } + else + { + ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); + } - if (ConfigHelper.Check("CmdProdxy")) - { - var tmp = ConfigHelper.GetConfig("CmdProdxy"); - comboBoxCmdProdxy.SelectedIndex = comboBoxCmdProdxy.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); - } + if (ConfigHelper.Check("MqttPassword")) + { + textBoxMqttPassword.Text = ConfigHelper.GetConfig("MqttPassword"); + } + else + { + ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); + } - if (ConfigHelper.Check("MqttClient_Checked")) - { - radioButtonMqttClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); - } - else - { - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); - } + if (ConfigHelper.Check("MqttClientId")) + { + textBoxMqttClientId.Text = ConfigHelper.GetConfig("MqttClientId"); + } + else + { + ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); } - private void RestoreTcp() + if (ConfigHelper.Check("MqttPubTopic")) { - if (ConfigHelper.Check("TcpClientLogin")) - { - textBoxTcpClientLogin.Text = ConfigHelper.GetConfig("TcpClientLogin"); - } - else - { - ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); - } + textBoxMqttPubTopic.Text = ConfigHelper.GetConfig("MqttPubTopic"); + } + else + { + ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); + } - if (ConfigHelper.Check("TcpClient_Checked")) - { - radioButtonTcpClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("TcpClient_Checked")); - } - else - { - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); - } + if (ConfigHelper.Check("MqttSubTopic")) + { + textBoxMqttSubTopic.Text = ConfigHelper.GetConfig("MqttSubTopic"); + } + else + { + ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); } - private void RestoreUDP() + if (ConfigHelper.Check("CmdProdxy")) { - if (ConfigHelper.Check("UDPClientLogin")) - { - textBoxUDPClientLogin.Text = ConfigHelper.GetConfig("UDPClientLogin"); - } - else - { - ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); - } + var tmp = ConfigHelper.GetConfig("CmdProdxy"); + comboBoxCmdProdxy.SelectedIndex = comboBoxCmdProdxy.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); + } - if (ConfigHelper.Check("UDPClient_Checked")) - { - radioButtonUDPClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("UDPClient_Checked")); - } - else - { - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(radioButtonUDPClient.Checked)); - } + if (ConfigHelper.Check("MqttClient_Checked")) + { + radioButtonMqttClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); + } + else + { + ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); } + } - private void RestoreSerialPort() + private void RestoreTcp() + { + if (ConfigHelper.Check("TcpClientLogin")) { - if (ConfigHelper.Check("SerialPort")) - { - var tmp = ConfigHelper.GetConfig("SerialPort"); - comboBoxSerialPort.SelectedIndex = comboBoxSerialPort.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); - } + textBoxTcpClientLogin.Text = ConfigHelper.GetConfig("TcpClientLogin"); + } + else + { + ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); + } - if (ConfigHelper.Check("BaudRate")) - { - var tmp = ConfigHelper.GetConfig("BaudRate"); - comboBoxBaudRate.SelectedIndex = comboBoxBaudRate.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); - } + if (ConfigHelper.Check("TcpClient_Checked")) + { + radioButtonTcpClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("TcpClient_Checked")); + } + else + { + ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); + } + } - if (ConfigHelper.Check("DataBits")) - { - var tmp = ConfigHelper.GetConfig("DataBits"); - comboBoxDataBits.SelectedIndex = comboBoxDataBits.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); - } + private void RestoreUDP() + { + if (ConfigHelper.Check("UDPClientLogin")) + { + textBoxUDPClientLogin.Text = ConfigHelper.GetConfig("UDPClientLogin"); + } + else + { + ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); + } - if (ConfigHelper.Check("Parity")) - { - var tmp = ConfigHelper.GetConfig("Parity"); - comboBoxParity.SelectedIndex = comboBoxParity.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("Parity", comboBoxParity.Text); - } + if (ConfigHelper.Check("UDPClient_Checked")) + { + radioButtonUDPClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("UDPClient_Checked")); + } + else + { + ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(radioButtonUDPClient.Checked)); + } + } - if (ConfigHelper.Check("StopBits")) - { - var tmp = ConfigHelper.GetConfig("StopBits"); - comboBoxStopBits.SelectedIndex = comboBoxStopBits.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); - } + private void RestoreSerialPort() + { + if (ConfigHelper.Check("SerialPort")) + { + var tmp = ConfigHelper.GetConfig("SerialPort"); + comboBoxSerialPort.SelectedIndex = comboBoxSerialPort.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); } - private void RestorePLC() + if (ConfigHelper.Check("BaudRate")) { - if (ConfigHelper.Check("PLCTopic")) - { - textBoxPLCTopic.Text = ConfigHelper.GetConfig("PLCTopic"); - } - else - { - ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); - } + var tmp = ConfigHelper.GetConfig("BaudRate"); + comboBoxBaudRate.SelectedIndex = comboBoxBaudRate.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); } - private void RestoreOPCDA() + if (ConfigHelper.Check("DataBits")) { - if (ConfigHelper.Check("OPCDAHost")) - { - textBoxOPCDAHost.Text = ConfigHelper.GetConfig("OPCDAHost"); - } - else - { - ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); - } + var tmp = ConfigHelper.GetConfig("DataBits"); + comboBoxDataBits.SelectedIndex = comboBoxDataBits.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); + } - if (ConfigHelper.Check("OPCDAInterval")) - { - textBoxOPCDAInterval.Text = ConfigHelper.GetConfig("OPCDAInterval"); - } - else - { - ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); - } + if (ConfigHelper.Check("Parity")) + { + var tmp = ConfigHelper.GetConfig("Parity"); + comboBoxParity.SelectedIndex = comboBoxParity.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("Parity", comboBoxParity.Text); + } - if (ConfigHelper.Check("OPCDACount")) - { - textBoxOPCDACount.Text = ConfigHelper.GetConfig("OPCDACount"); - } - else - { - ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); - } + if (ConfigHelper.Check("StopBits")) + { + var tmp = ConfigHelper.GetConfig("StopBits"); + comboBoxStopBits.SelectedIndex = comboBoxStopBits.Items.IndexOf(tmp); + } + else + { + ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); + } + } - if (ConfigHelper.Check("OPCDACheck")) - { - checkBoxOPCDA.Text = ConfigHelper.GetConfig("OPCDACheck"); - } - else - { - ConfigHelper.SetConfig("OPCDACheck", checkBoxOPCDA.Text); - } + private void RestorePLC() + { + if (ConfigHelper.Check("PLCTopic")) + { + textBoxPLCTopic.Text = ConfigHelper.GetConfig("PLCTopic"); } + else + { + ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); + } + } - private void RestoreOPCUA() + private void RestoreOPCDA() + { + if (ConfigHelper.Check("OPCDAHost")) { - if (ConfigHelper.Check("OPCUATopic")) - { - textBoxOPCUATopic.Text = ConfigHelper.GetConfig("OPCUATopic"); - } - else - { - ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); - } + textBoxOPCDAHost.Text = ConfigHelper.GetConfig("OPCDAHost"); + } + else + { + ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); } - private void RestoreBACnet() + if (ConfigHelper.Check("OPCDAInterval")) { - if (ConfigHelper.Check("BACnetTopic")) - { - textBoxBACnetTopic.Text = ConfigHelper.GetConfig("BACnetTopic"); - } - else - { - ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); - } + textBoxOPCDAInterval.Text = ConfigHelper.GetConfig("OPCDAInterval"); + } + else + { + ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); } - private void RestoreControl() + if (ConfigHelper.Check("OPCDACount")) { - if (ConfigHelper.Check("ControlTopic")) - { - textBoxControlTopic.Text = ConfigHelper.GetConfig("ControlTopic"); - } - else - { - ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); - } + textBoxOPCDACount.Text = ConfigHelper.GetConfig("OPCDACount"); + } + else + { + ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); } - private void RestoreAccess() + if (ConfigHelper.Check("OPCDACheck")) { - if (ConfigHelper.Check("AccessTopic")) - { - textBoxAccessTopic.Text = ConfigHelper.GetConfig("AccessTopic"); - } - else - { - ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); - } + checkBoxOPCDA.Text = ConfigHelper.GetConfig("OPCDACheck"); } + else + { + ConfigHelper.SetConfig("OPCDACheck", checkBoxOPCDA.Text); + } + } - private void Resh_Config() + private void RestoreOPCUA() + { + if (ConfigHelper.Check("OPCUATopic")) + { + textBoxOPCUATopic.Text = ConfigHelper.GetConfig("OPCUATopic"); + } + else { - MqttClientHelper.Config(); - MqttServerHelper.Config(); - TcpClientHelper.Config(); - TcpServerHelper.Config(); - UDPClientHelper.Config(); - UDPServerHelper.Config(); + ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); + } + } - SerialPortHelper.Config(); - PLCHelper.Config(config.AppSettings.Settings); - OPCDAHelper.Config(); - OPCUAHelper.Config(config.AppSettings.Settings); - AccessHelper.Config(config.AppSettings.Settings); - SqlServerHelper.Config(config.AppSettings.Settings); + private void RestoreBACnet() + { + if (ConfigHelper.Check("BACnetTopic")) + { + textBoxBACnetTopic.Text = ConfigHelper.GetConfig("BACnetTopic"); } + else + { + ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); + } + } - private void Resh_Topic() + private void RestoreControl() + { + if (ConfigHelper.Check("ControlTopic")) { - devaddr = comboBoxDtuAddr.Text; - productid = textBoxMqttUserName.Text; - // clientid = DgiotHelper.Md5("Device" + this.textBoxMqttUserName.Text + devaddr).Substring(0, 10); - clientid = comboBoxDtuAddr.Text; - textBoxMqttClientId.Text = clientid; - textBoxMqttSubTopic.Text = "$dg/device/" + productid + "/" + devaddr + "/#"; - textBoxMqttPubTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxControlTopic.Text = ConfigHelper.GetConfig("ControlTopic"); + } + else + { + ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); + } + } - textBoxAccessTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxOPCUATopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxPLCTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxBACnetTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxControlTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + private void RestoreAccess() + { + if (ConfigHelper.Check("AccessTopic")) + { + textBoxAccessTopic.Text = ConfigHelper.GetConfig("AccessTopic"); } + else + { + ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); + } + } + + private void Resh_Config() + { + MqttClientHelper.Config(); + MqttServerHelper.Config(); + TcpClientHelper.Config(); + TcpServerHelper.Config(); + UDPClientHelper.Config(); + UDPServerHelper.Config(); + + SerialPortHelper.Config(); + PLCHelper.Config(config.AppSettings.Settings); + OPCDAHelper.Config(); + OPCUAHelper.Config(config.AppSettings.Settings); + AccessHelper.Config(config.AppSettings.Settings); + SqlServerHelper.Config(config.AppSettings.Settings); + } + + private void Resh_Topic() + { + devaddr = comboBoxDtuAddr.Text; + productid = textBoxMqttUserName.Text; + // clientid = DgiotHelper.Md5("Device" + this.textBoxMqttUserName.Text + devaddr).Substring(0, 10); + clientid = comboBoxDtuAddr.Text; + textBoxMqttClientId.Text = clientid; + textBoxMqttSubTopic.Text = "$dg/device/" + productid + "/" + devaddr + "/#"; + textBoxMqttPubTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + + textBoxAccessTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxOPCUATopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxPLCTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxBACnetTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxControlTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + } + + private void LinkLabel1LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://github.com/dgiot/dgiot_dtu"); + } + + private void ButtonClearClick(object sender, EventArgs e) + { + textBoxLog.Text = ""; + } + + private void LinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Process.Start("https://github.com/dgiot/dgiot_dtu"); + } + + private void SaveAppConfig() + { + config.Save(ConfigurationSaveMode.Full); + ConfigurationManager.RefreshSection("appSettings"); + } + + private void CheckBoxReconnectCheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("ReconnectChecked", DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); + } + + private void CheckBoxDisplayHexCheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("DisplayHex", DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); + LogHelper.Config(); + } + + private void RadioButtonMqttClient_CheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); + ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); + ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); + } + + private void RadioButtonTcpClient_CheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); + ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); + ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); + } + + private void RadioButtonUDPClient_CheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); + ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); + ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); + } + + private void TextToPayload_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("ToPayload", textToPayload.Text); + } + + private void TextBoxMqttClientId_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); + Resh_Topic(); + } + + private void TextBoxMqttUserName_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); + Resh_Topic(); + } + + private void TextBoxMqttPassword_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); + } + + private void TextBoxMqttSubTopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); + Resh_Topic(); + } + + private void TextBoxMqttPubTopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); + Resh_Topic(); + } + + private void TextBoxMqttServerPort_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("MqttServerPort", textBoxTcpClientLogin.Text); + } + + private void TextBoxTcpClientLogin_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); + } + + private void TextBoxUDPClientLogin_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); + } + + private void ComboBoxCmdProdxy_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); + } - private void LinkLabel1LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Process.Start("https://github.com/dgiot/dgiot_dtu"); - } + private void ComboBoxSerialPort_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); + } - private void ButtonClearClick(object sender, EventArgs e) - { - textBoxLog.Text = ""; - } + private void ComboBoxBaudRate_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); + } - private void LinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Process.Start("https://github.com/dgiot/dgiot_dtu"); - } + private void ComboBoxStopBits_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); + } - private void SaveAppConfig() - { - config.Save(ConfigurationSaveMode.Full); - ConfigurationManager.RefreshSection("appSettings"); - } + private void ComboBoxParity_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("Parity", comboBoxParity.Text); + } - private void CheckBoxReconnectCheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("ReconnectChecked", DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); - } + private void ComboBoxDataBits_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); + } - private void CheckBoxDisplayHexCheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DisplayHex", DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); - LogHelper.Config(); - } + private void TextBoxPLCTopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); + } - private void RadioButtonMqttClient_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); - } + private void CheckBoxOPCDA_CheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("OPCDACheck", DgiotHelper.BoolTostr(checkBoxOPCDA.Checked)); + OPCDAHelper.StartMonitor(); + } - private void RadioButtonTcpClient_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); - } + private void TextBoxOPCDAInterval_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); + } - private void RadioButtonUDPClient_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); - } + private void TextBoxOPCDAHost_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); + } - private void TextToPayload_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("ToPayload", textToPayload.Text); - } + private void TextBoxOPCDACount_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); + } - private void TextBoxMqttClientId_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); - Resh_Topic(); - } + private void TextBoxOPCUATopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); + Resh_Topic(); + } - private void TextBoxMqttUserName_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); - Resh_Topic(); - } + private void TextBoxBACnetTopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); + Resh_Topic(); + } - private void TextBoxMqttPassword_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); - } + private void TextBoxControlTopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); + Resh_Topic(); + } - private void TextBoxMqttSubTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); - Resh_Topic(); - } + private void TextBoxAccessTopic_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); + Resh_Topic(); + } - private void TextBoxMqttPubTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); - Resh_Topic(); - } + private void ComboBoxLogLevel_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); + LogHelper.SetLevel(comboBoxLogLevel.SelectedIndex); + } - private void TextBoxMqttServerPort_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttServerPort", textBoxTcpClientLogin.Text); - } + private void ComboBoxBridge_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("Bridge", comboBoxBridge.Text); + } - private void TextBoxTcpClientLogin_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); - } + private void TextBoxDgiotSever_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); + } - private void TextBoxUDPClientLogin_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); - } + private void TextBoxDgiotPort_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); + } - private void ComboBoxCmdProdxy_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); - } + private void TextBoxBridgePort_TextChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); + } - private void ComboBoxSerialPort_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); - } + private void ComboBoxDtuAddr_SelectedIndexChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); + } - private void ComboBoxBaudRate_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); - } + private void CheckBoxBridge_CheckedChanged(object sender, EventArgs e) + { + ConfigHelper.SetConfig("Bridge_Checked", DgiotHelper.BoolTostr(checkBoxBridge.Checked)); + } - private void ComboBoxStopBits_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); - } + private void SendBridge_Click(object sender, EventArgs e) + { - private void ComboBoxParity_SelectedIndexChanged(object sender, EventArgs e) + byte[] payload = LogHelper.Payload(textToPayload.Text.ToCharArray()); + LogHelper.Log(bridges[comboBoxBridge.SelectedIndex] + " send [" + LogHelper.Logdata(payload, 0, payload.Length) + "]"); + // PrinterHelper.SetTextData(textToPayload.Text); + PrinterHelper.PrintPage(textToPayload.Text); + if (bridges[comboBoxBridge.SelectedIndex] == "SerialPort") { - ConfigHelper.SetConfig("Parity", comboBoxParity.Text); } - - private void ComboBoxDataBits_SelectedIndexChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "TcpServer") { - ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); + TcpServerHelper.Write(payload, 0, payload.Length); } - - private void TextBoxPLCTopic_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "Barcode_Printer") { - ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); + TcpServerHelper.Write(payload, 0, payload.Length); } - - private void CheckBoxOPCDA_CheckedChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "PLC") { - ConfigHelper.SetConfig("OPCDACheck", DgiotHelper.BoolTostr(checkBoxOPCDA.Checked)); - OPCDAHelper.StartMonitor(); } - - private void TextBoxOPCDAInterval_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "OPCUA") { - ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); } - - private void TextBoxOPCDAHost_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "BACnet") { - ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); + BACnetHelper.Write(payload, 0, payload.Length); } - - private void TextBoxOPCDACount_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "Control") { - ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); } - - private void TextBoxOPCUATopic_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "Access") { - ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); - Resh_Topic(); } - - private void TextBoxBACnetTopic_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "SqlServer") { - ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); - Resh_Topic(); } - - private void TextBoxControlTopic_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "MqttClient") { - ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); - Resh_Topic(); + MqttClientHelper.Write(payload, 0, payload.Length); } - - private void TextBoxAccessTopic_TextChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "MqttServer") { - ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); - Resh_Topic(); + MqttServerHelper.Write(payload, 0, payload.Length); } - - private void ComboBoxLogLevel_SelectedIndexChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "TcpClient") { - ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); - LogHelper.SetLevel(comboBoxLogLevel.SelectedIndex); + TcpClientHelper.Write(payload, 0, payload.Length); } - - private void ComboBoxBridge_SelectedIndexChanged(object sender, EventArgs e) + else if (bridges[comboBoxBridge.SelectedIndex] == "UdpClient") { - ConfigHelper.SetConfig("Bridge", comboBoxBridge.Text); } - - private void TextBoxDgiotSever_TextChanged(object sender, EventArgs e) + else { - ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); } + } - private void TextBoxDgiotPort_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); - } + private void ComboBoxLan_SelectedIndexChanged(object sender, EventArgs e) + { + Language(comboBoxLan.SelectedItem.ToString()); + } - private void TextBoxBridgePort_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); - } + private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) + { + TreeViewHelper.TreeView_AfterSelect(e.Action, e.Node); + } - private void ComboBoxDtuAddr_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); - } + private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) + { + TreeViewHelper.TreeView_AfterCheck(e.Action, e.Node); + } - private void CheckBoxBridge_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("Bridge_Checked", DgiotHelper.BoolTostr(checkBoxBridge.Checked)); - } + private void NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + TreeViewHelper.NodeMouseDoubleClick(e.Button, e.Node); + } - private void SendBridge_Click(object sender, EventArgs e) + private void AfterLabelEdit(object sender, NodeLabelEditEventArgs e) + { + if (e.Label != null) { - - byte[] payload = LogHelper.Payload(textToPayload.Text.ToCharArray()); - LogHelper.Log(bridges[comboBoxBridge.SelectedIndex] + " send [" + LogHelper.Logdata(payload, 0, payload.Length) + "]"); - // PrinterHelper.SetTextData(textToPayload.Text); - PrinterHelper.PrintPage(textToPayload.Text); - if (bridges[comboBoxBridge.SelectedIndex] == "SerialPort") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "TcpServer") - { - TcpServerHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "Barcode_Printer") - { - TcpServerHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "PLC") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "OPCUA") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "BACnet") - { - BACnetHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "Control") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "Access") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "SqlServer") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "MqttClient") - { - MqttClientHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "MqttServer") - { - MqttServerHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "TcpClient") - { - TcpClientHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "UdpClient") + if (e.Label.Length > 0) { + if (TreeViewHelper.CheckLabelEdit(e.Label, e.Node)) + { + // Stop editing without canceling the label change. + e.Node.EndEdit(false); + } + else + { + /* Cancel the label edit action, inform the user, and + place the node in edit mode again. */ + e.CancelEdit = true; + e.Node.BeginEdit(); + } } else { + /* Cancel the label edit action, inform the user, and + place the node in edit mode again. */ + e.CancelEdit = true; + e.Node.BeginEdit(); } } + } - private void ComboBoxLan_SelectedIndexChanged(object sender, EventArgs e) + private void Language(string lan) + { + if (lan == "English") { - Language(comboBoxLan.SelectedItem.ToString()); + En(); } - - private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) + else { - TreeViewHelper.TreeView_AfterSelect(e.Action, e.Node); + Zh(); } + } - private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) - { - TreeViewHelper.TreeView_AfterCheck(e.Action, e.Node); - } + private void Zh() + { + sendBridge.Text = "发送"; + buttonClear.Text = "清除"; + buttonStartStop.Text = "连接"; + buttonScan.Text = "扫描"; + + checkBoxReconnect.Text = "自动重连"; + label33.Text = "语言"; + label32.Text = "日志级别"; + + label7.Text = "发至"; + label2.Text = "发至"; + labelopcua.Text = "发至"; + label23.Text = "发至"; + label8.Text = "发至"; + label6.Text = "发至"; + + groupBoxSerialPort.Text = "串口扫描"; + groupBox12.Text = "PLC扫描"; + groupBox4.Text = "OPC_DA扫描"; + labelOPCDAHost.Text = "主机"; + checkBoxOPCDA.Text = "主动上报"; + labelOPCDAMonitor.Text = "采集间隔"; + labelSecond.Text = "秒"; + labelOPCDACount.Text = "采集次数"; + groupBox5.Text = "OPC_UA扫描"; + groupBox6.Text = "BACnet扫描"; + groupBox7.Text = "窗体扫描"; + groupBox8.Text = "Access扫描"; + + labelSerialPort.Text = "端口"; + label1.Text = "波特率"; + label4.Text = "数据位"; + label13.Text = "校验位"; + label5.Text = "停止位"; + + groupBox3.Text = "Mqtt 客户端通道"; + label22.Text = "服务器地址"; + label21.Text = "服务器端口"; + label9.Text = "登录用户"; + label10.Text = "登录密码"; + label30.Text = "网关地址"; + label20.Text = "客户编号"; + label11.Text = "订阅主题"; + label12.Text = "发布主题"; + label29.Text = "命令代理"; + + groupBox2.Text = "TCP 客户端通道"; + label16.Text = "登录报文"; + + groupBox10.Text = "UDP 客户端通道"; + label15.Text = "登录报文"; + + label_devcietree.Text = "设备树"; + checkBoxBridge.Text = "桥接端口"; + groupBoxCommonConfig.Text = "公共配置"; + } - private void NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) - { - TreeViewHelper.NodeMouseDoubleClick(e.Button, e.Node); - } + private void En() + { + sendBridge.Text = "Send"; + buttonClear.Text = "Clear"; + buttonStartStop.Text = "Start"; + buttonScan.Text = "Scan"; + label32.Text = "Level"; + + checkBoxReconnect.Text = "Auto Reconnect"; + label33.Text = "Language"; + + label7.Text = "To"; + label2.Text = "To"; + labelopcua.Text = "To"; + label23.Text = "To"; + label8.Text = "To"; + label6.Text = "To"; + groupBoxSerialPort.Text = "Serial Port Capture"; + groupBox12.Text = "PLC Capture"; + groupBox4.Text = "OPC_DA Capture"; + labelOPCDAHost.Text = "Host"; + checkBoxOPCDA.Text = "Monitor"; + labelOPCDAMonitor.Text = "Interval"; + labelSecond.Text = "Second"; + labelOPCDACount.Text = "Count"; + + groupBox5.Text = "OPC_UA Capture"; + groupBox6.Text = "BACnet Capture"; + groupBox7.Text = "Control Capture"; + groupBox8.Text = "Access Capture"; + + labelSerialPort.Text = "Port"; + label1.Text = "Baud Rate"; + label4.Text = "dataBits"; + label13.Text = "Parity"; + label5.Text = "stopBits"; + labelOPCDAHost.Text = "Host"; + + groupBox3.Text = "Mqtt Client Channel"; + label22.Text = "Server"; + label21.Text = "Port"; + label9.Text = "UserName"; + label10.Text = "PassWord"; + label30.Text = "DtuAddr"; + label20.Text = "Clientid"; + label11.Text = "SubTopic"; + label12.Text = "PubTopic"; + label29.Text = "cmd proxy"; + + groupBox2.Text = "TCP Client Channel"; + label16.Text = "login"; + + groupBox10.Text = "UDP Client Channel"; + label15.Text = "login"; + + label_devcietree.Text = "DeviceTree"; + checkBoxBridge.Text = "Bridge Port"; + groupBoxCommonConfig.Text = "Common Config"; + } - private void AfterLabelEdit(object sender, NodeLabelEditEventArgs e) + private void MainForm_Load(object sender, EventArgs e) + { + x = Width; // 获取窗体的宽度 + y = Height; // 获取窗体的高度 + SetTag(this); // 调用方法 + } + + private void MainForm_Resize(object sender, EventArgs e) + { + if (x == 0) { - if (e.Label != null) - { - if (e.Label.Length > 0) - { - if (TreeViewHelper.CheckLabelEdit(e.Label, e.Node)) - { - // Stop editing without canceling the label change. - e.Node.EndEdit(false); - } - else - { - /* Cancel the label edit action, inform the user, and - place the node in edit mode again. */ - e.CancelEdit = true; - e.Node.BeginEdit(); - } - } - else - { - /* Cancel the label edit action, inform the user, and - place the node in edit mode again. */ - e.CancelEdit = true; - e.Node.BeginEdit(); - } - } + x = Width; } - private void Language(string lan) + if (y == 0) { - if (lan == "English") - { - En(); - } - else - { - Zh(); - } + y = Height; } - private void Zh() - { - sendBridge.Text = "发送"; - buttonClear.Text = "清除"; - buttonStartStop.Text = "连接"; - buttonScan.Text = "扫描"; - - checkBoxReconnect.Text = "自动重连"; - label33.Text = "语言"; - label32.Text = "日志级别"; - - label7.Text = "发至"; - label2.Text = "发至"; - labelopcua.Text = "发至"; - label23.Text = "发至"; - label8.Text = "发至"; - label6.Text = "发至"; - - groupBoxSerialPort.Text = "串口扫描"; - groupBox12.Text = "PLC扫描"; - groupBox4.Text = "OPC_DA扫描"; - labelOPCDAHost.Text = "主机"; - checkBoxOPCDA.Text = "主动上报"; - labelOPCDAMonitor.Text = "采集间隔"; - labelSecond.Text = "秒"; - labelOPCDACount.Text = "采集次数"; - groupBox5.Text = "OPC_UA扫描"; - groupBox6.Text = "BACnet扫描"; - groupBox7.Text = "窗体扫描"; - groupBox8.Text = "Access扫描"; - - labelSerialPort.Text = "端口"; - label1.Text = "波特率"; - label4.Text = "数据位"; - label13.Text = "校验位"; - label5.Text = "停止位"; - - groupBox3.Text = "Mqtt 客户端通道"; - label22.Text = "服务器地址"; - label21.Text = "服务器端口"; - label9.Text = "登录用户"; - label10.Text = "登录密码"; - label30.Text = "网关地址"; - label20.Text = "客户编号"; - label11.Text = "订阅主题"; - label12.Text = "发布主题"; - label29.Text = "命令代理"; - - groupBox2.Text = "TCP 客户端通道"; - label16.Text = "登录报文"; - - groupBox10.Text = "UDP 客户端通道"; - label15.Text = "登录报文"; - - label_devcietree.Text = "设备树"; - checkBoxBridge.Text = "桥接端口"; - groupBoxCommonConfig.Text = "公共配置"; - } - - private void En() - { - sendBridge.Text = "Send"; - buttonClear.Text = "Clear"; - buttonStartStop.Text = "Start"; - buttonScan.Text = "Scan"; - label32.Text = "Level"; - - checkBoxReconnect.Text = "Auto Reconnect"; - label33.Text = "Language"; - - label7.Text = "To"; - label2.Text = "To"; - labelopcua.Text = "To"; - label23.Text = "To"; - label8.Text = "To"; - label6.Text = "To"; - groupBoxSerialPort.Text = "Serial Port Capture"; - groupBox12.Text = "PLC Capture"; - groupBox4.Text = "OPC_DA Capture"; - labelOPCDAHost.Text = "Host"; - checkBoxOPCDA.Text = "Monitor"; - labelOPCDAMonitor.Text = "Interval"; - labelSecond.Text = "Second"; - labelOPCDACount.Text = "Count"; - - groupBox5.Text = "OPC_UA Capture"; - groupBox6.Text = "BACnet Capture"; - groupBox7.Text = "Control Capture"; - groupBox8.Text = "Access Capture"; - - labelSerialPort.Text = "Port"; - label1.Text = "Baud Rate"; - label4.Text = "dataBits"; - label13.Text = "Parity"; - label5.Text = "stopBits"; - labelOPCDAHost.Text = "Host"; - - groupBox3.Text = "Mqtt Client Channel"; - label22.Text = "Server"; - label21.Text = "Port"; - label9.Text = "UserName"; - label10.Text = "PassWord"; - label30.Text = "DtuAddr"; - label20.Text = "Clientid"; - label11.Text = "SubTopic"; - label12.Text = "PubTopic"; - label29.Text = "cmd proxy"; - - groupBox2.Text = "TCP Client Channel"; - label16.Text = "login"; - - groupBox10.Text = "UDP Client Channel"; - label15.Text = "login"; - - label_devcietree.Text = "DeviceTree"; - checkBoxBridge.Text = "Bridge Port"; - groupBoxCommonConfig.Text = "Common Config"; - } - - private void MainForm_Load(object sender, EventArgs e) - { - x = Width; // 获取窗体的宽度 - y = Height; // 获取窗体的高度 - SetTag(this); // 调用方法 - } - - private void MainForm_Resize(object sender, EventArgs e) - { - if (x == 0) + float newx = this.Width / x; // 窗体宽度缩放比例 + float newy = this.Height / y; // 窗体高度缩放比例 + SetControls(newx, newy, this); // 随窗体改变控件大小 + } + + /// + /// 将控件的宽,高,左边距,顶边距和字体大小暂存到tag属性中 + /// + /// 递归控件中的控件 + private void SetTag(Control cons) + { + foreach (Control con in cons.Controls) + { + if (con == null) { - x = Width; + continue; } - if (y == 0) + con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; + if (con.Controls.Count > 0) { - y = Height; + SetTag(con); } - - float newx = this.Width / x; // 窗体宽度缩放比例 - float newy = this.Height / y; // 窗体高度缩放比例 - SetControls(newx, newy, this); // 随窗体改变控件大小 } + } - /// - /// 将控件的宽,高,左边距,顶边距和字体大小暂存到tag属性中 - /// - /// 递归控件中的控件 - private void SetTag(Control cons) + // 根据窗体大小调整控件大小 + private void SetControls(float newx, float newy, Control cons) + { + // 遍历窗体中的控件,重新设置控件的值 + foreach (Control con in cons.Controls) { - foreach (Control con in cons.Controls) + if (con.Tag != null && con.Tag != "") { - if (con == null) - { - continue; - } - - con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; - if (con.Controls.Count > 0) - { - SetTag(con); - } + string[] mytag = con.Tag.ToString().Split(new char[] { ':' }); // 获取控件的Tag属性值,并分割后存储字符串数组 + float a = Convert.ToSingle(mytag[0]) * newx; // 根据窗体缩放比例确定控件的值,宽度 + con.Width = (int)a; // 宽度 + a = Convert.ToSingle(mytag[1]) * newy; // 高度 + con.Height = (int)a; + a = Convert.ToSingle(mytag[2]) * newx; // 左边距离 + con.Left = (int)a; + a = Convert.ToSingle(mytag[3]) * newy; // 上边缘距离 + con.Top = (int)a; + float currentSize = Convert.ToSingle(mytag[4]) * newy; // 字体大小 + con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); } - } - // 根据窗体大小调整控件大小 - private void SetControls(float newx, float newy, Control cons) - { - // 遍历窗体中的控件,重新设置控件的值 - foreach (Control con in cons.Controls) + if (con.Controls.Count > 0) { - if (con.Tag != null && con.Tag != "") - { - string[] mytag = con.Tag.ToString().Split(new char[] { ':' }); // 获取控件的Tag属性值,并分割后存储字符串数组 - float a = Convert.ToSingle(mytag[0]) * newx; // 根据窗体缩放比例确定控件的值,宽度 - con.Width = (int)a; // 宽度 - a = Convert.ToSingle(mytag[1]) * newy; // 高度 - con.Height = (int)a; - a = Convert.ToSingle(mytag[2]) * newx; // 左边距离 - con.Left = (int)a; - a = Convert.ToSingle(mytag[3]) * newy; // 上边缘距离 - con.Top = (int)a; - float currentSize = Convert.ToSingle(mytag[4]) * newy; // 字体大小 - con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); - } - - if (con.Controls.Count > 0) - { - SetControls(newx, newy, con); - } + SetControls(newx, newy, con); } } + } - private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) - { + private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) + { - } + } - private void textBoxLog_TextChanged(object sender, EventArgs e) - { + private void textBoxLog_TextChanged(object sender, EventArgs e) + { - } + } - private void groupBox5_Enter(object sender, EventArgs e) - { + private void groupBox5_Enter(object sender, EventArgs e) + { - } + } - private void groupBox6_Enter(object sender, EventArgs e) - { + private void groupBox6_Enter(object sender, EventArgs e) + { - } + } - private void groupBox8_Enter(object sender, EventArgs e) - { + private void groupBox8_Enter(object sender, EventArgs e) + { - } } } +} diff --git a/component/Mqtt/MqttClientHelper.cs b/component/Mqtt/MqttClientHelper.cs index cf5eb0d..cb7414e 100644 --- a/component/Mqtt/MqttClientHelper.cs +++ b/component/Mqtt/MqttClientHelper.cs @@ -4,288 +4,292 @@ namespace Dgiot_dtu { - using System; - using System.Collections.Generic; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using System.Web.Script.Serialization; - using MQTTnet; - using MQTTnet.Core; - using MQTTnet.Core.Client; - using MQTTnet.Core.Packets; - using MQTTnet.Core.Protocol; - - public class MqttClientHelper +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using System.Web.Script.Serialization; +using MQTTnet; +using MQTTnet.Core; +using MQTTnet.Core.Client; +using MQTTnet.Core.Packets; +using MQTTnet.Core.Protocol; + +public class MqttClientHelper +{ + private MqttClientHelper() { - private MqttClientHelper() - { - } + } - private static MqttClient mqttClient = null; - private static string server = "prod.iotn2n.com"; - private static int port = 1883; - private static string subtopic = "$dg/device/"; - private static string pubtopic = "$dg/thing/"; - private static string clientid = ""; - private static string username = "dgiot"; - private static string password = "dgiot"; - private static MqttClientHelper instance = null; - private static bool bIsRunning = false; - private static bool bIsCheck = false; - private static bool bAutoReconnect = false; - private static string dtuAddr = ""; - - public static MqttClientHelper GetInstance() + private static MqttClient mqttClient = null; + private static string server = "prod.iotn2n.com"; + private static int port = 1883; + private static string subtopic = "$dg/device/"; + private static string pubtopic = "$dg/thing/"; + private static string clientid = ""; + private static string username = "dgiot"; + private static string password = "dgiot"; + private static MqttClientHelper instance = null; + private static bool bIsRunning = false; + private static bool bIsCheck = false; + private static bool bAutoReconnect = false; + private static string dtuAddr = ""; + + public static MqttClientHelper GetInstance() + { + if (instance == null) { - if (instance == null) - { - instance = new MqttClientHelper(); - } - - return instance; + instance = new MqttClientHelper(); } - public static void Start() - { - Config(); - bIsRunning = true; - if (bIsCheck) - { - Task.Run(async () => { await ConnectMqttServerAsync(); }); - } - } + return instance; + } - public static void Stop() + public static void Start() + { + Config(); + bIsRunning = true; + if (bIsCheck) { - if (mqttClient != null) - { - bAutoReconnect = false; - bIsRunning = false; - Task.Run(async () => { await DisConnectMqttServerAsync(); }); - } + Task.Run(async () => { + await ConnectMqttServerAsync(); + }); } + } - public static void Config() + public static void Stop() + { + if (mqttClient != null) { - bAutoReconnect = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); - server = ConfigHelper.GetConfig("DgiotSever"); - LogHelper.Log("DgiotPort " + ConfigHelper.GetConfig("DgiotPort")); - port = int.Parse(ConfigHelper.GetConfig("DgiotPort")); - clientid = ConfigHelper.GetConfig("MqttClientId"); - username = ConfigHelper.GetConfig("MqttUserName"); - password = ConfigHelper.GetConfig("MqttPassword"); - pubtopic = ConfigHelper.GetConfig("MqttPubTopic"); - subtopic = ConfigHelper.GetConfig("MqttSubTopic"); - dtuAddr = ConfigHelper.GetConfig("DtuAddr"); - bIsCheck = DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); + bAutoReconnect = false; + bIsRunning = false; + Task.Run(async () => { + await DisConnectMqttServerAsync(); + }); } + } - public void Publish(byte[] payload) + public static void Config() + { + bAutoReconnect = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); + server = ConfigHelper.GetConfig("DgiotSever"); + LogHelper.Log("DgiotPort " + ConfigHelper.GetConfig("DgiotPort")); + port = int.Parse(ConfigHelper.GetConfig("DgiotPort")); + clientid = ConfigHelper.GetConfig("MqttClientId"); + username = ConfigHelper.GetConfig("MqttUserName"); + password = ConfigHelper.GetConfig("MqttPassword"); + pubtopic = ConfigHelper.GetConfig("MqttPubTopic"); + subtopic = ConfigHelper.GetConfig("MqttSubTopic"); + dtuAddr = ConfigHelper.GetConfig("DtuAddr"); + bIsCheck = DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); + } + + public void Publish(byte[] payload) + { + var appMsg = new MqttApplicationMessage(pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); + mqttClient.PublishAsync(appMsg); + } + + public static void Publish(string pubtopic, byte[] payload) + { + if (mqttClient != null && mqttClient.IsConnected) { var appMsg = new MqttApplicationMessage(pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); mqttClient.PublishAsync(appMsg); } + } - public static void Publish(string pubtopic, byte[] payload) + private static async Task ReConnectMqttServerAsync() + { + while (bIsRunning) { - if (mqttClient != null && mqttClient.IsConnected) + if (!bAutoReconnect) { - var appMsg = new MqttApplicationMessage(pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); - mqttClient.PublishAsync(appMsg); + break; } - } - private static async Task ReConnectMqttServerAsync() - { - while (bIsRunning) + Thread.Sleep(1000 * 10); + if (!mqttClient.IsConnected) { - if (!bAutoReconnect) - { - break; - } - - Thread.Sleep(1000 * 10); - if (!mqttClient.IsConnected) - { - await ConnectMqttServerAsync(); - } + await ConnectMqttServerAsync(); } } + } - private static async Task ConnectMqttServerAsync() + private static async Task ConnectMqttServerAsync() + { + if (mqttClient == null) { - if (mqttClient == null) - { - mqttClient = new MqttClientFactory().CreateMqttClient() as MqttClient; - mqttClient.ApplicationMessageReceived += MqttClient_ApplicationMessageReceived; - mqttClient.Connected += MqttClient_Connected; - mqttClient.Disconnected += MqttClient_Disconnected; - } - - try - { - var options = new MqttClientTcpOptions - { - Server = server, - ClientId = clientid, - UserName = username, - Password = password, - Port = port, - CleanSession = true - }; - - await DisConnectMqttServerAsync(); - await mqttClient.ConnectAsync(options); - await ReConnectMqttServerAsync(); - } - catch (Exception ex) - { - LogHelper.Log(ex.ToString()); - } + mqttClient = new MqttClientFactory().CreateMqttClient() as MqttClient; + mqttClient.ApplicationMessageReceived += MqttClient_ApplicationMessageReceived; + mqttClient.Connected += MqttClient_Connected; + mqttClient.Disconnected += MqttClient_Disconnected; } - private static async Task DisConnectMqttServerAsync() + try { - try + var options = new MqttClientTcpOptions { - await mqttClient.DisconnectAsync(); - } - catch (Exception ex) - { - LogHelper.Log(ex.ToString()); - } + Server = server, + ClientId = clientid, + UserName = username, + Password = password, + Port = port, + CleanSession = true + }; + + await DisConnectMqttServerAsync(); + await mqttClient.ConnectAsync(options); + await ReConnectMqttServerAsync(); + } + catch (Exception ex) + { + LogHelper.Log(ex.ToString()); } + } - /// - /// 服务器连接成功 - /// - /// - /// - private static void MqttClient_Connected(object sender, EventArgs e) + private static async Task DisConnectMqttServerAsync() + { + try { - LogHelper.Log("mqtt client:" + clientid + " connected"); + await mqttClient.DisconnectAsync(); + } + catch (Exception ex) + { + LogHelper.Log(ex.ToString()); + } + } - mqttClient.SubscribeAsync(new TopicFilter(subtopic, MqttQualityOfServiceLevel.AtLeastOnce)); + /// + /// 服务器连接成功 + /// + /// + /// + private static void MqttClient_Connected(object sender, EventArgs e) + { + LogHelper.Log("mqtt client:" + clientid + " connected"); + mqttClient.SubscribeAsync(new TopicFilter(subtopic, MqttQualityOfServiceLevel.AtLeastOnce)); - LogHelper.Log("mqtt client subscribe topic: " + subtopic); - } - /// - /// 断开服务器连接 - /// - /// - /// - private static void MqttClient_Disconnected(object sender, EventArgs e) + LogHelper.Log("mqtt client subscribe topic: " + subtopic); + } + + /// + /// 断开服务器连接 + /// + /// + /// + private static void MqttClient_Disconnected(object sender, EventArgs e) + { + if (bAutoReconnect) { - if (bAutoReconnect) - { - _ = ReConnectMqttServerAsync(); - } - else - { - LogHelper.Log("mqtt:" + clientid + " disconnected"); - } + _ = ReConnectMqttServerAsync(); } + else + { + LogHelper.Log("mqtt:" + clientid + " disconnected"); + } + } - /// - /// 接收到消息 - /// - /// - /// - private static void MqttClient_ApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs e) + /// + /// 接收到消息 + /// + /// + /// + private static void MqttClient_ApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs e) + { + Dictionary json = Get_payload(e.ApplicationMessage.Payload); + string topic = e.ApplicationMessage.Topic; + string data = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); + LogHelper.Log("mqtt recv:topic: " + e.ApplicationMessage.Topic.ToString() + " payload: " + data); + + Regex r_subtopic = new Regex(subtopic); // 定义一个Regex对象实例 + Match m_subtopic = r_subtopic.Match(e.ApplicationMessage.Topic); // 在字符串中匹配 + if (m_subtopic.Success) { - Dictionary json = Get_payload(e.ApplicationMessage.Payload); - string topic = e.ApplicationMessage.Topic; - string data = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); - LogHelper.Log("mqtt recv:topic: " + e.ApplicationMessage.Topic.ToString() + " payload: " + data); - - Regex r_subtopic = new Regex(subtopic); // 定义一个Regex对象实例 - Match m_subtopic = r_subtopic.Match(e.ApplicationMessage.Topic); // 在字符串中匹配 - if (m_subtopic.Success) - { - SerialPortHelper.Write(e.ApplicationMessage.Payload, 0, e.ApplicationMessage.Payload.Length); - } - if (topic.IndexOf("$dg/device/" + username + "/" + dtuAddr) == 0) + SerialPortHelper.Write(e.ApplicationMessage.Payload, 0, e.ApplicationMessage.Payload.Length); + } + if (topic.IndexOf("$dg/device/" + username + "/" + dtuAddr) == 0) + { + if (json.ContainsKey("cmd")) { - if (json.ContainsKey("cmd")) + if (json["cmd"].ToString() == "opc_items") + { + OPCDAHelper.Readitems(json); + } + else if (json["cmd"].ToString() == "opc_report") { - if (json["cmd"].ToString() == "opc_items") - { - OPCDAHelper.Readitems(json); - } - else if (json["cmd"].ToString() == "opc_report") - { - OPCDAHelper.Publishvalues(json); - } - else if (json["cmd"].ToString() == "printer") - { - PrinterHelper.PrintPage(json["data"].ToString()); - } + OPCDAHelper.Publishvalues(json); + } + else if (json["cmd"].ToString() == "printer") + { + PrinterHelper.PrintPage(json["data"].ToString()); } } + } - AccessHelper.Do_mdb(topic, json, clientid); + AccessHelper.Do_mdb(topic, json, clientid); - MqttServerHelper.Write(e.ApplicationMessage); - } + MqttServerHelper.Write(e.ApplicationMessage); + } - public static void Write(byte[] data, int offset, int len) + public static void Write(byte[] data, int offset, int len) + { + if (bIsCheck) { - if (bIsCheck) - { - var appMsg = new MqttApplicationMessage(pubtopic + clientid, Encoding.UTF8.GetBytes(LogHelper.Logdata(data, offset, len)), MqttQualityOfServiceLevel.AtLeastOnce, false); - LogHelper.Log("mqtt client publish:" + LogHelper.Logdata(data, offset, len)); - mqttClient.PublishAsync(appMsg); - } + var appMsg = new MqttApplicationMessage(pubtopic + clientid, Encoding.UTF8.GetBytes(LogHelper.Logdata(data, offset, len)), MqttQualityOfServiceLevel.AtLeastOnce, false); + LogHelper.Log("mqtt client publish:" + LogHelper.Logdata(data, offset, len)); + mqttClient.PublishAsync(appMsg); } + } - public static void Write(MqttApplicationMessage appMsg) + public static void Write(MqttApplicationMessage appMsg) + { + if (bIsCheck) { - if (bIsCheck) - { - mqttClient.PublishAsync(appMsg); - } + mqttClient.PublishAsync(appMsg); } + } - private static Dictionary Get_payload(byte[] payload) - { - string data = Encoding.UTF8.GetString(payload); - JavaScriptSerializer serializer = new JavaScriptSerializer(); - Dictionary json = (Dictionary)serializer.DeserializeObject(data); - return json; - } + private static Dictionary Get_payload(byte[] payload) + { + string data = Encoding.UTF8.GetString(payload); + JavaScriptSerializer serializer = new JavaScriptSerializer(); + Dictionary json = (Dictionary)serializer.DeserializeObject(data); + return json; + } - private static Dictionary Get_payload(byte[] payload, int offset, int len) - { - string data = Encoding.UTF8.GetString(payload, offset, len); - JavaScriptSerializer serializer = new JavaScriptSerializer(); - Dictionary json = (Dictionary)serializer.DeserializeObject(data); - return json; - } + private static Dictionary Get_payload(byte[] payload, int offset, int len) + { + string data = Encoding.UTF8.GetString(payload, offset, len); + JavaScriptSerializer serializer = new JavaScriptSerializer(); + Dictionary json = (Dictionary)serializer.DeserializeObject(data); + return json; + } - private static readonly DateTime BaseTime = new DateTime(1970, 1, 1); + private static readonly DateTime BaseTime = new DateTime(1970, 1, 1); - /// - /// 将unixtime转换为.NET的DateTime - /// - /// 秒数 - /// 转换后的时间 - public static DateTime FromUnixTime(long timeStamp) - { - return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime((timeStamp * 10000000) + BaseTime.Ticks)); - } + /// + /// 将unixtime转换为.NET的DateTime + /// + /// 秒数 + /// 转换后的时间 + public static DateTime FromUnixTime(long timeStamp) + { + return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime((timeStamp * 10000000) + BaseTime.Ticks)); + } - /// - /// 将.NET的DateTime转换为unix time - /// - /// 待转换的时间 - /// 转换后的unix time - public static long FromDateTime(DateTime dateTime) - { - return (TimeZone.CurrentTimeZone.ToUniversalTime(dateTime).Ticks - BaseTime.Ticks) / 10000000; - } + /// + /// 将.NET的DateTime转换为unix time + /// + /// 待转换的时间 + /// 转换后的unix time + public static long FromDateTime(DateTime dateTime) + { + return (TimeZone.CurrentTimeZone.ToUniversalTime(dateTime).Ticks - BaseTime.Ticks) / 10000000; } +} } \ No newline at end of file diff --git a/component/Printer/PrinterHelper.cs b/component/Printer/PrinterHelper.cs index eff9f27..d6c8dd8 100644 --- a/component/Printer/PrinterHelper.cs +++ b/component/Printer/PrinterHelper.cs @@ -4,135 +4,135 @@ namespace Dgiot_dtu { - using System; - using System.Configuration; - using System.Drawing; - using System.Drawing.Printing; - using System.Runtime.InteropServices; - using System.Windows.Forms; - using MQTTnet.Core.Client; - using MQTTnet.Core.Packets; - using MQTTnet.Core.Protocol; - using System.Collections.Generic; - - internal class PrinterHelper - { +using System; +using System.Configuration; +using System.Drawing; +using System.Drawing.Printing; +using System.Runtime.InteropServices; +using System.Windows.Forms; +using MQTTnet.Core.Client; +using MQTTnet.Core.Packets; +using MQTTnet.Core.Protocol; +using System.Collections.Generic; + +internal class PrinterHelper +{ - [DllImport("winspool.drv")] - public static extern bool SetDefaultPrinter(String Name); //调用win api将指定名称的打印机设置为默认打印 + [DllImport("winspool.drv")] + public static extern bool SetDefaultPrinter(String Name); //调用win api将指定名称的打印机设置为默认打印 - private static PrinterHelper instance = null; - private static bool bIsRunning = false; + private static PrinterHelper instance = null; + private static bool bIsRunning = false; - private static string textData = "C01010100005DGF0100189"; - private static PrintDocument fPrintDocument = new PrintDocument(); + private static string textData = "C01010100005DGF0100189"; + private static PrintDocument fPrintDocument = new PrintDocument(); - public static void Start(MqttClient mqttClient) - { + public static void Start(MqttClient mqttClient) + { - string Name = "ec71804a3d"; - mqttClient.SubscribeAsync(new TopicFilter("device/printer", MqttQualityOfServiceLevel.AtLeastOnce)); - LogHelper.Log("mqtt client subscribe topic: " + "device/" + Name + "/#"); - } + string Name = "ec71804a3d"; + mqttClient.SubscribeAsync(new TopicFilter("device/printer", MqttQualityOfServiceLevel.AtLeastOnce)); + LogHelper.Log("mqtt client subscribe topic: " + "device/" + Name + "/#"); + } - public static PrinterHelper GetInstance() + public static PrinterHelper GetInstance() + { + if (instance == null) { - if (instance == null) - { - instance = new PrinterHelper(); - } - - return instance; + instance = new PrinterHelper(); } - public static void Start(KeyValueConfigurationCollection config, bool bIsRunning) - { - Config(config); - PrinterHelper.bIsRunning = bIsRunning; - } + return instance; + } - public static void Stop() - { - PrinterHelper.bIsRunning = false; - } + public static void Start(KeyValueConfigurationCollection config, bool bIsRunning) + { + Config(config); + PrinterHelper.bIsRunning = bIsRunning; + } - public static void Config(KeyValueConfigurationCollection config) - { - } + public static void Stop() + { + PrinterHelper.bIsRunning = false; + } + public static void Config(KeyValueConfigurationCollection config) + { + } - Brush brushHeaderFont = new SolidBrush(Color.Black); - Pen LinePen = new Pen(Color.Black, 1); - public PrinterHelper() - { - InitPrint(); - } - /// - /// 初始化打印机 - /// - private void InitPrint() - { - - } - /// - /// 打印 - /// - public void Print() - { - } + Brush brushHeaderFont = new SolidBrush(Color.Black); + Pen LinePen = new Pen(Color.Black, 1); + public PrinterHelper() + { + InitPrint(); + } + /// + /// 初始化打印机 + /// + private void InitPrint() + { - public static void SetTextData(string data ) - { - textData = data; + } - } + /// + /// 打印 + /// + public void Print() + { + } - - public static void PrintPage(string json) - { - SetTextData(json); - PrintDialog PD = new PrintDialog(); - PageSettings pageSettings = new PageSettings(); - //pageSettings.PaperSize = new PaperSize("Size", 30, 40); - string Name = fPrintDocument.PrinterSettings.PrinterName; - System.Drawing.Printing.PrinterSettings Ps = new System.Drawing.Printing.PrinterSettings(); - //SetDefaultPrinter("Deli DL-888B(NEW)"); - fPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Size", 157, 118); //单位1/100英寸 - SetDefaultPrinter(Name); - PD.PrinterSettings = Ps; - fPrintDocument.PrintPage += document_PrintPage; - PD.Document = fPrintDocument; - fPrintDocument.Print(); - } + public static void SetTextData(string data ) + { + textData = data; - static void document_PrintPage(object sender, PrintPageEventArgs e) - { - int x1 = -5; - int y1 = 15; - double x2= (260 * 0.63)+x1; - double y2 = (140 * 0.63) + y1; - e.Graphics.DrawImage(PrinterHelper.Get_image(), x1, y1,(int)x2, (int)y2); - e.HasMorePages = false; - } + } - public static Image Get_image() - { - CodeLib.Barcode b = new CodeLib.Barcode(); - CodeLib.TYPE type = CodeLib.TYPE.CODE128B; - b.IncludeLabel = true; - string familyName = "宋体"; - Font Label = new Font(familyName, 40.0F); - b.LabelFont = Label; - CodeLib.AlignmentPositions Align = CodeLib.AlignmentPositions.CENTER; - b.Alignment = Align; - b.LabelPosition = CodeLib.LabelPositions.BOTTOMCENTER; - return b.Encode(type, textData, 523, 200); - } + + public static void PrintPage(string json) + { + SetTextData(json); + PrintDialog PD = new PrintDialog(); + PageSettings pageSettings = new PageSettings(); + //pageSettings.PaperSize = new PaperSize("Size", 30, 40); + string Name = fPrintDocument.PrinterSettings.PrinterName; + System.Drawing.Printing.PrinterSettings Ps = new System.Drawing.Printing.PrinterSettings(); + //SetDefaultPrinter("Deli DL-888B(NEW)"); + fPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Size", 157, 118); //单位1/100英寸 + SetDefaultPrinter(Name); + PD.PrinterSettings = Ps; + fPrintDocument.PrintPage += document_PrintPage; + PD.Document = fPrintDocument; + fPrintDocument.Print(); + } + + static void document_PrintPage(object sender, PrintPageEventArgs e) + { + int x1 = -5; + int y1 = 15; + double x2= (260 * 0.63)+x1; + double y2 = (140 * 0.63) + y1; + e.Graphics.DrawImage(PrinterHelper.Get_image(), x1, y1,(int)x2, (int)y2); + e.HasMorePages = false; + } + + public static Image Get_image() + { + CodeLib.Barcode b = new CodeLib.Barcode(); + CodeLib.TYPE type = CodeLib.TYPE.CODE128B; + b.IncludeLabel = true; + string familyName = "宋体"; + Font Label = new Font(familyName, 40.0F); + b.LabelFont = Label; + CodeLib.AlignmentPositions Align = CodeLib.AlignmentPositions.CENTER; + b.Alignment = Align; + b.LabelPosition = CodeLib.LabelPositions.BOTTOMCENTER; + return b.Encode(type, textData, 523, 200); } - } \ No newline at end of file +} +} \ No newline at end of file From 9f3f30dacd6726b6c799cb425f38c8b87d1cebe3 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 22 Jul 2022 11:13:30 +0000 Subject: [PATCH 2/3] Restyled by clang-format --- MainForm.Designer.cs | 2418 ++++++++++++++-------------- MainForm.cs | 1958 ++++++++++------------ component/Mqtt/MqttClientHelper.cs | 467 +++--- component/Printer/PrinterHelper.cs | 198 +-- 4 files changed, 2388 insertions(+), 2653 deletions(-) diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 126f187..e659fae 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -1,1208 +1,1228 @@ using System.Windows.Forms; -namespace Dgiot_dtu -{ -partial class MainForm -{ - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; +namespace Dgiot_dtu { +partial class MainForm { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; + /// otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); } + base.Dispose(disposing); + } - #region Windows Form Designer generated code +#region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.buttonStartStop = new System.Windows.Forms.Button(); - this.textBoxLog = new System.Windows.Forms.TextBox(); - this.checkBoxReconnect = new System.Windows.Forms.CheckBox(); - this.checkBoxDisplayHex = new System.Windows.Forms.CheckBox(); - this.buttonClear = new System.Windows.Forms.Button(); - this.groupBoxSerialPort = new System.Windows.Forms.GroupBox(); - this.comboBoxParity = new System.Windows.Forms.ComboBox(); - this.label13 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.comboBoxStopBits = new System.Windows.Forms.ComboBox(); - this.comboBoxDataBits = new System.Windows.Forms.ComboBox(); - this.comboBoxBaudRate = new System.Windows.Forms.ComboBox(); - this.labelSerialPort = new System.Windows.Forms.Label(); - this.comboBoxSerialPort = new System.Windows.Forms.ComboBox(); - this.textBoxBridgePort = new System.Windows.Forms.TextBox(); - this.textBoxMqttPubTopic = new System.Windows.Forms.TextBox(); - this.label12 = new System.Windows.Forms.Label(); - this.textBoxMqttSubTopic = new System.Windows.Forms.TextBox(); - this.label11 = new System.Windows.Forms.Label(); - this.textBoxMqttPassword = new System.Windows.Forms.TextBox(); - this.label10 = new System.Windows.Forms.Label(); - this.textBoxMqttUserName = new System.Windows.Forms.TextBox(); - this.label9 = new System.Windows.Forms.Label(); - this.linkLabel2 = new System.Windows.Forms.LinkLabel(); - this.textToPayload = new System.Windows.Forms.TextBox(); - this.textBoxTcpClientLogin = new System.Windows.Forms.TextBox(); - this.textBoxMqttClientId = new System.Windows.Forms.TextBox(); - this.textBoxDgiotPort = new System.Windows.Forms.TextBox(); - this.textBoxUDPClientLogin = new System.Windows.Forms.TextBox(); - this.sendBridge = new System.Windows.Forms.Button(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.label16 = new System.Windows.Forms.Label(); - this.checkBoxBridge = new System.Windows.Forms.CheckBox(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label29 = new System.Windows.Forms.Label(); - this.comboBoxCmdProdxy = new System.Windows.Forms.ComboBox(); - this.label20 = new System.Windows.Forms.Label(); - this.comboBoxDtuAddr = new System.Windows.Forms.ComboBox(); - this.label30 = new System.Windows.Forms.Label(); - this.label21 = new System.Windows.Forms.Label(); - this.textBoxDgiotSever = new System.Windows.Forms.TextBox(); - this.label22 = new System.Windows.Forms.Label(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.textBoxOPCDACount = new System.Windows.Forms.TextBox(); - this.labelOPCDACount = new System.Windows.Forms.Label(); - this.labelSecond = new System.Windows.Forms.Label(); - this.labelOPCDAMonitor = new System.Windows.Forms.Label(); - this.textBoxOPCDAInterval = new System.Windows.Forms.TextBox(); - this.checkBoxOPCDA = new System.Windows.Forms.CheckBox(); - this.textBoxOPCDAHost = new System.Windows.Forms.TextBox(); - this.labelOPCDAHost = new System.Windows.Forms.Label(); - this.textBoxOpcIp = new System.Windows.Forms.TextBox(); - this.groupBox5 = new System.Windows.Forms.GroupBox(); - this.textBoxOPCUATopic = new System.Windows.Forms.TextBox(); - this.labelopcua = new System.Windows.Forms.Label(); - this.groupBox6 = new System.Windows.Forms.GroupBox(); - this.textBoxBACnetTopic = new System.Windows.Forms.TextBox(); - this.label23 = new System.Windows.Forms.Label(); - this.groupBox7 = new System.Windows.Forms.GroupBox(); - this.textBoxControlTopic = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); - this.comboBoxBridge = new System.Windows.Forms.ComboBox(); - this.label7 = new System.Windows.Forms.Label(); - this.groupBox8 = new System.Windows.Forms.GroupBox(); - this.textBoxAccessTopic = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.groupBox10 = new System.Windows.Forms.GroupBox(); - this.label15 = new System.Windows.Forms.Label(); - this.radioButtonMqttClient = new System.Windows.Forms.RadioButton(); - this.radioButtonTcpClient = new System.Windows.Forms.RadioButton(); - this.radioButtonUDPClient = new System.Windows.Forms.RadioButton(); - this.groupBox12 = new System.Windows.Forms.GroupBox(); - this.textBoxPLCTopic = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.comboBoxLogLevel = new System.Windows.Forms.ComboBox(); - this.label32 = new System.Windows.Forms.Label(); - this.comboBoxLan = new System.Windows.Forms.ComboBox(); - this.label33 = new System.Windows.Forms.Label(); - this.treeView = new System.Windows.Forms.TreeView(); - this.label_devcietree = new System.Windows.Forms.Label(); - this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.groupBoxCommonConfig = new System.Windows.Forms.GroupBox(); - this.buttonScan = new System.Windows.Forms.Button(); - this.groupBoxSerialPort.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.groupBox3.SuspendLayout(); - this.groupBox4.SuspendLayout(); - this.groupBox5.SuspendLayout(); - this.groupBox6.SuspendLayout(); - this.groupBox7.SuspendLayout(); - this.groupBox8.SuspendLayout(); - this.groupBox10.SuspendLayout(); - this.groupBox12.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.groupBoxCommonConfig.SuspendLayout(); - this.SuspendLayout(); - // - // buttonStartStop - // - this.buttonStartStop.Location = new System.Drawing.Point(151, 125); - this.buttonStartStop.Name = "buttonStartStop"; - this.buttonStartStop.Size = new System.Drawing.Size(53, 21); - this.buttonStartStop.TabIndex = 4; - this.buttonStartStop.Text = "Start"; - this.buttonStartStop.UseVisualStyleBackColor = true; - this.buttonStartStop.Click += new System.EventHandler(this.ButtonStartStopClick); - // - // textBoxLog - // - this.textBoxLog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(107)))), ((int)(((byte)(170)))), ((int)(((byte)(55))))); - this.textBoxLog.Location = new System.Drawing.Point(3, 233); - this.textBoxLog.Multiline = true; - this.textBoxLog.Name = "textBoxLog"; - this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBoxLog.Size = new System.Drawing.Size(289, 253); - this.textBoxLog.TabIndex = 9; - this.textBoxLog.TextChanged += new System.EventHandler(this.textBoxLog_TextChanged); - // - // checkBoxReconnect - // - this.checkBoxReconnect.AutoSize = true; - this.checkBoxReconnect.Location = new System.Drawing.Point(10, 129); - this.checkBoxReconnect.Name = "checkBoxReconnect"; - this.checkBoxReconnect.Size = new System.Drawing.Size(108, 16); - this.checkBoxReconnect.TabIndex = 5; - this.checkBoxReconnect.Text = "Auto Reconnect"; - this.checkBoxReconnect.UseVisualStyleBackColor = true; - this.checkBoxReconnect.CheckedChanged += new System.EventHandler(this.CheckBoxReconnectCheckedChanged); - // - // checkBoxDisplayHex - // - this.checkBoxDisplayHex.AutoSize = true; - this.checkBoxDisplayHex.Location = new System.Drawing.Point(306, 493); - this.checkBoxDisplayHex.Name = "checkBoxDisplayHex"; - this.checkBoxDisplayHex.Size = new System.Drawing.Size(42, 16); - this.checkBoxDisplayHex.TabIndex = 11; - this.checkBoxDisplayHex.Text = "Hex"; - this.checkBoxDisplayHex.UseVisualStyleBackColor = true; - this.checkBoxDisplayHex.CheckedChanged += new System.EventHandler(this.CheckBoxDisplayHexCheckedChanged); - // - // buttonClear - // - this.buttonClear.Location = new System.Drawing.Point(404, 490); - this.buttonClear.Name = "buttonClear"; - this.buttonClear.Size = new System.Drawing.Size(48, 21); - this.buttonClear.TabIndex = 12; - this.buttonClear.Text = "Clear"; - this.buttonClear.UseVisualStyleBackColor = true; - this.buttonClear.Click += new System.EventHandler(this.ButtonClearClick); - // - // groupBoxSerialPort - // - this.groupBoxSerialPort.Controls.Add(this.comboBoxParity); - this.groupBoxSerialPort.Controls.Add(this.label13); - this.groupBoxSerialPort.Controls.Add(this.label5); - this.groupBoxSerialPort.Controls.Add(this.label4); - this.groupBoxSerialPort.Controls.Add(this.label1); - this.groupBoxSerialPort.Controls.Add(this.comboBoxStopBits); - this.groupBoxSerialPort.Controls.Add(this.comboBoxDataBits); - this.groupBoxSerialPort.Controls.Add(this.comboBoxBaudRate); - this.groupBoxSerialPort.Controls.Add(this.labelSerialPort); - this.groupBoxSerialPort.Controls.Add(this.comboBoxSerialPort); - this.groupBoxSerialPort.Location = new System.Drawing.Point(293, 17); - this.groupBoxSerialPort.Name = "groupBoxSerialPort"; - this.groupBoxSerialPort.Size = new System.Drawing.Size(213, 111); - this.groupBoxSerialPort.TabIndex = 13; - this.groupBoxSerialPort.TabStop = false; - this.groupBoxSerialPort.Text = "Serial Port Capture"; - // - // comboBoxParity - // - this.comboBoxParity.FormattingEnabled = true; - this.comboBoxParity.Items.AddRange(new object[] { - "NONE", - "Odd", - "Even", - "Mark", - "Space" - }); - this.comboBoxParity.Location = new System.Drawing.Point(63, 59); - this.comboBoxParity.Name = "comboBoxParity"; - this.comboBoxParity.Size = new System.Drawing.Size(140, 20); - this.comboBoxParity.TabIndex = 14; - this.comboBoxParity.SelectedIndexChanged += new System.EventHandler(this.ComboBoxParity_SelectedIndexChanged); - // - // label13 - // - this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(5, 59); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(41, 12); - this.label13.TabIndex = 13; - this.label13.Text = "Parity"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(5, 86); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(53, 12); - this.label5.TabIndex = 12; - this.label5.Text = "stopBits"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(108, 86); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(53, 12); - this.label4.TabIndex = 12; - this.label4.Text = "dataBits"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 39); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 12); - this.label1.TabIndex = 12; - this.label1.Text = "Baud Rate"; - // - // comboBoxStopBits - // - this.comboBoxStopBits.FormattingEnabled = true; - this.comboBoxStopBits.Items.AddRange(new object[] { - "1", - "2", - "1.5" - }); - this.comboBoxStopBits.Location = new System.Drawing.Point(64, 83); - this.comboBoxStopBits.Name = "comboBoxStopBits"; - this.comboBoxStopBits.Size = new System.Drawing.Size(41, 20); - this.comboBoxStopBits.TabIndex = 11; - this.comboBoxStopBits.SelectedIndexChanged += new System.EventHandler(this.ComboBoxStopBits_SelectedIndexChanged); - // - // comboBoxDataBits - // - this.comboBoxDataBits.FormattingEnabled = true; - this.comboBoxDataBits.Items.AddRange(new object[] { - "8", - "7", - "6", - "5" - }); - this.comboBoxDataBits.Location = new System.Drawing.Point(164, 83); - this.comboBoxDataBits.Name = "comboBoxDataBits"; - this.comboBoxDataBits.Size = new System.Drawing.Size(39, 20); - this.comboBoxDataBits.TabIndex = 11; - this.comboBoxDataBits.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDataBits_SelectedIndexChanged); - // - // comboBoxBaudRate - // - this.comboBoxBaudRate.FormattingEnabled = true; - this.comboBoxBaudRate.Items.AddRange(new object[] { - "1200", - "2400", - "4800", - "9600", - "19200", - "38400", - "57600", - "115200" - }); - this.comboBoxBaudRate.Location = new System.Drawing.Point(62, 37); - this.comboBoxBaudRate.Name = "comboBoxBaudRate"; - this.comboBoxBaudRate.Size = new System.Drawing.Size(141, 20); - this.comboBoxBaudRate.TabIndex = 11; - this.comboBoxBaudRate.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBaudRate_SelectedIndexChanged); - // - // labelSerialPort - // - this.labelSerialPort.AutoSize = true; - this.labelSerialPort.Location = new System.Drawing.Point(6, 17); - this.labelSerialPort.Name = "labelSerialPort"; - this.labelSerialPort.Size = new System.Drawing.Size(29, 12); - this.labelSerialPort.TabIndex = 10; - this.labelSerialPort.Text = "Port"; - // - // comboBoxSerialPort - // - this.comboBoxSerialPort.FormattingEnabled = true; - this.comboBoxSerialPort.Location = new System.Drawing.Point(62, 15); - this.comboBoxSerialPort.Name = "comboBoxSerialPort"; - this.comboBoxSerialPort.Size = new System.Drawing.Size(141, 20); - this.comboBoxSerialPort.TabIndex = 9; - this.comboBoxSerialPort.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSerialPort_SelectedIndexChanged); - // - // textBoxBridgePort - // - this.textBoxBridgePort.Location = new System.Drawing.Point(134, 97); - this.textBoxBridgePort.Name = "textBoxBridgePort"; - this.textBoxBridgePort.Size = new System.Drawing.Size(75, 21); - this.textBoxBridgePort.TabIndex = 7; - this.textBoxBridgePort.Text = "5080"; - this.textBoxBridgePort.TextChanged += new System.EventHandler(this.TextBoxBridgePort_TextChanged); - // - // textBoxMqttPubTopic - // - this.textBoxMqttPubTopic.Location = new System.Drawing.Point(80, 119); - this.textBoxMqttPubTopic.Name = "textBoxMqttPubTopic"; - this.textBoxMqttPubTopic.Size = new System.Drawing.Size(132, 21); - this.textBoxMqttPubTopic.TabIndex = 22; - this.textBoxMqttPubTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxMqttPubTopic.TextChanged += new System.EventHandler(this.TextBoxMqttPubTopic_TextChanged); - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(9, 119); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(53, 12); - this.label12.TabIndex = 21; - this.label12.Text = "PubTopic"; - // - // textBoxMqttSubTopic - // - this.textBoxMqttSubTopic.Location = new System.Drawing.Point(81, 95); - this.textBoxMqttSubTopic.Name = "textBoxMqttSubTopic"; - this.textBoxMqttSubTopic.Size = new System.Drawing.Size(132, 21); - this.textBoxMqttSubTopic.TabIndex = 20; - this.textBoxMqttSubTopic.Text = "$dg/device/{productId}/{deviceAddr}/properties"; - this.textBoxMqttSubTopic.TextChanged += new System.EventHandler(this.TextBoxMqttSubTopic_TextChanged); - // - // label11 - // - this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(9, 96); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(53, 12); - this.label11.TabIndex = 19; - this.label11.Text = "SubTopic"; - // - // textBoxMqttPassword - // - this.textBoxMqttPassword.Location = new System.Drawing.Point(81, 44); - this.textBoxMqttPassword.Name = "textBoxMqttPassword"; - this.textBoxMqttPassword.Size = new System.Drawing.Size(131, 21); - this.textBoxMqttPassword.TabIndex = 18; - this.textBoxMqttPassword.Text = "SzQ3MDU4ODMxNjQwNjYyNjkwOTg4"; - this.textBoxMqttPassword.TextChanged += new System.EventHandler(this.TextBoxMqttPassword_TextChanged); - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(8, 47); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(53, 12); - this.label10.TabIndex = 17; - this.label10.Text = "PassWord"; - // - // textBoxMqttUserName - // - this.textBoxMqttUserName.Location = new System.Drawing.Point(81, 20); - this.textBoxMqttUserName.Name = "textBoxMqttUserName"; - this.textBoxMqttUserName.Size = new System.Drawing.Size(131, 21); - this.textBoxMqttUserName.TabIndex = 16; - this.textBoxMqttUserName.Text = "fa82a59201"; - this.textBoxMqttUserName.TextChanged += new System.EventHandler(this.TextBoxMqttUserName_TextChanged); - // - // label9 - // - this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(6, 24); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(53, 12); - this.label9.TabIndex = 15; - this.label9.Text = "UserName"; - // - // linkLabel2 - // - this.linkLabel2.AutoSize = true; - this.linkLabel2.LinkColor = System.Drawing.Color.Silver; - this.linkLabel2.Location = new System.Drawing.Point(515, 449); - this.linkLabel2.Name = "linkLabel2"; - this.linkLabel2.Size = new System.Drawing.Size(41, 12); - this.linkLabel2.TabIndex = 16; - this.linkLabel2.TabStop = true; - this.linkLabel2.Text = "DG-IoT"; - this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel2_LinkClicked); - // - // textToPayload - // - this.textToPayload.Location = new System.Drawing.Point(127, 491); - this.textToPayload.Name = "textToPayload"; - this.textToPayload.Size = new System.Drawing.Size(169, 21); - this.textToPayload.TabIndex = 14; - this.textToPayload.Text = "12345678"; - this.textToPayload.TextChanged += new System.EventHandler(this.TextToPayload_TextChanged); - // - // textBoxTcpClientLogin - // - this.textBoxTcpClientLogin.Location = new System.Drawing.Point(79, 21); - this.textBoxTcpClientLogin.Name = "textBoxTcpClientLogin"; - this.textBoxTcpClientLogin.Size = new System.Drawing.Size(131, 21); - this.textBoxTcpClientLogin.TabIndex = 12; - this.textBoxTcpClientLogin.Text = "login"; - this.textBoxTcpClientLogin.TextChanged += new System.EventHandler(this.TextBoxTcpClientLogin_TextChanged); - // - // textBoxMqttClientId - // - this.textBoxMqttClientId.Location = new System.Drawing.Point(81, 71); - this.textBoxMqttClientId.Name = "textBoxMqttClientId"; - this.textBoxMqttClientId.Size = new System.Drawing.Size(131, 21); - this.textBoxMqttClientId.TabIndex = 12; - this.textBoxMqttClientId.Text = "devaddr"; - this.textBoxMqttClientId.TextChanged += new System.EventHandler(this.TextBoxMqttClientId_TextChanged); - // - // textBoxDgiotPort - // - this.textBoxDgiotPort.Location = new System.Drawing.Point(77, 46); - this.textBoxDgiotPort.Name = "textBoxDgiotPort"; - this.textBoxDgiotPort.Size = new System.Drawing.Size(133, 21); - this.textBoxDgiotPort.TabIndex = 7; - this.textBoxDgiotPort.Text = "1883"; - this.textBoxDgiotPort.TextChanged += new System.EventHandler(this.TextBoxDgiotPort_TextChanged); - // - // textBoxUDPClientLogin - // - this.textBoxUDPClientLogin.Location = new System.Drawing.Point(74, 21); - this.textBoxUDPClientLogin.Name = "textBoxUDPClientLogin"; - this.textBoxUDPClientLogin.Size = new System.Drawing.Size(136, 21); - this.textBoxUDPClientLogin.TabIndex = 12; - this.textBoxUDPClientLogin.Text = "login"; - this.textBoxUDPClientLogin.TextChanged += new System.EventHandler(this.TextBoxUDPClientLogin_TextChanged); - // - // sendBridge - // - this.sendBridge.Location = new System.Drawing.Point(350, 491); - this.sendBridge.Name = "sendBridge"; - this.sendBridge.Size = new System.Drawing.Size(47, 21); - this.sendBridge.TabIndex = 17; - this.sendBridge.Text = "Send"; - this.sendBridge.UseVisualStyleBackColor = true; - this.sendBridge.Click += new System.EventHandler(this.SendBridge_Click); - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.label16); - this.groupBox2.Controls.Add(this.textBoxTcpClientLogin); - this.groupBox2.Location = new System.Drawing.Point(571, 206); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(213, 53); - this.groupBox2.TabIndex = 18; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "TCP Client Channel"; - // - // label16 - // - this.label16.AutoSize = true; - this.label16.Location = new System.Drawing.Point(9, 21); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(35, 12); - this.label16.TabIndex = 13; - this.label16.Text = "login"; - // - // checkBoxBridge - // - this.checkBoxBridge.AutoSize = true; - this.checkBoxBridge.Location = new System.Drawing.Point(10, 99); - this.checkBoxBridge.Name = "checkBoxBridge"; - this.checkBoxBridge.Size = new System.Drawing.Size(90, 16); - this.checkBoxBridge.TabIndex = 23; - this.checkBoxBridge.Text = "Bridge Port"; - this.checkBoxBridge.UseVisualStyleBackColor = true; - this.checkBoxBridge.CheckedChanged += new System.EventHandler(this.CheckBoxBridge_CheckedChanged); - // - // groupBox3 - // - this.groupBox3.Controls.Add(this.label29); - this.groupBox3.Controls.Add(this.comboBoxCmdProdxy); - this.groupBox3.Controls.Add(this.textBoxMqttPubTopic); - this.groupBox3.Controls.Add(this.label12); - this.groupBox3.Controls.Add(this.label20); - this.groupBox3.Controls.Add(this.textBoxMqttClientId); - this.groupBox3.Controls.Add(this.textBoxMqttSubTopic); - this.groupBox3.Controls.Add(this.label11); - this.groupBox3.Controls.Add(this.textBoxMqttUserName); - this.groupBox3.Controls.Add(this.textBoxMqttPassword); - this.groupBox3.Controls.Add(this.label9); - this.groupBox3.Controls.Add(this.label10); - this.groupBox3.Location = new System.Drawing.Point(571, 15); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(217, 172); - this.groupBox3.TabIndex = 19; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Mqtt Client Channel"; - // - // label29 - // - this.label29.AutoSize = true; - this.label29.Location = new System.Drawing.Point(8, 142); - this.label29.Name = "label29"; - this.label29.Size = new System.Drawing.Size(59, 12); - this.label29.TabIndex = 37; - this.label29.Text = "cmd proxy"; - // - // comboBoxCmdProdxy - // - this.comboBoxCmdProdxy.FormattingEnabled = true; - this.comboBoxCmdProdxy.Items.AddRange(new object[] { - "ffmpeg" - }); - this.comboBoxCmdProdxy.Location = new System.Drawing.Point(81, 146); - this.comboBoxCmdProdxy.Name = "comboBoxCmdProdxy"; - this.comboBoxCmdProdxy.Size = new System.Drawing.Size(131, 20); - this.comboBoxCmdProdxy.TabIndex = 36; - this.comboBoxCmdProdxy.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCmdProdxy_SelectedIndexChanged); - // - // label20 - // - this.label20.AutoSize = true; - this.label20.Location = new System.Drawing.Point(9, 72); - this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(53, 12); - this.label20.TabIndex = 13; - this.label20.Text = "Clientid"; - // - // comboBoxDtuAddr - // - this.comboBoxDtuAddr.FormattingEnabled = true; - this.comboBoxDtuAddr.Location = new System.Drawing.Point(77, 71); - this.comboBoxDtuAddr.Name = "comboBoxDtuAddr"; - this.comboBoxDtuAddr.Size = new System.Drawing.Size(132, 20); - this.comboBoxDtuAddr.TabIndex = 15; - this.comboBoxDtuAddr.SelectedIndexChanged += new System.EventHandler(this.ComboBoxDtuAddr_SelectedIndexChanged); - // - // label30 - // - this.label30.AutoSize = true; - this.label30.Location = new System.Drawing.Point(9, 69); - this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(47, 12); - this.label30.TabIndex = 39; - this.label30.Text = "DtuAddr"; - // - // label21 - // - this.label21.AutoSize = true; - this.label21.Location = new System.Drawing.Point(9, 48); - this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(29, 12); - this.label21.TabIndex = 8; - this.label21.Text = "Port"; - // - // textBoxDgiotSever - // - this.textBoxDgiotSever.Location = new System.Drawing.Point(77, 19); - this.textBoxDgiotSever.Name = "textBoxDgiotSever"; - this.textBoxDgiotSever.Size = new System.Drawing.Size(133, 21); - this.textBoxDgiotSever.TabIndex = 5; - this.textBoxDgiotSever.Text = "pump.dgiotcloud.com"; - this.textBoxDgiotSever.TextChanged += new System.EventHandler(this.TextBoxDgiotSever_TextChanged); - // - // label22 - // - this.label22.AutoSize = true; - this.label22.Location = new System.Drawing.Point(9, 23); - this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(41, 12); - this.label22.TabIndex = 6; - this.label22.Text = "Server"; - // - // groupBox4 - // - this.groupBox4.Controls.Add(this.textBoxOPCDACount); - this.groupBox4.Controls.Add(this.labelOPCDACount); - this.groupBox4.Controls.Add(this.labelSecond); - this.groupBox4.Controls.Add(this.labelOPCDAMonitor); - this.groupBox4.Controls.Add(this.textBoxOPCDAInterval); - this.groupBox4.Controls.Add(this.checkBoxOPCDA); - this.groupBox4.Controls.Add(this.textBoxOPCDAHost); - this.groupBox4.Controls.Add(this.labelOPCDAHost); - this.groupBox4.Location = new System.Drawing.Point(294, 183); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(211, 75); - this.groupBox4.TabIndex = 18; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "OPC_DA Capture"; - // - // textBoxOPCDACount - // - this.textBoxOPCDACount.Location = new System.Drawing.Point(181, 47); - this.textBoxOPCDACount.Name = "textBoxOPCDACount"; - this.textBoxOPCDACount.Size = new System.Drawing.Size(27, 21); - this.textBoxOPCDACount.TabIndex = 52; - this.textBoxOPCDACount.Text = "30"; - this.textBoxOPCDACount.TextChanged += new System.EventHandler(this.TextBoxOPCDACount_TextChanged); - // - // labelOPCDACount - // - this.labelOPCDACount.AutoSize = true; - this.labelOPCDACount.Location = new System.Drawing.Point(129, 50); - this.labelOPCDACount.Name = "labelOPCDACount"; - this.labelOPCDACount.Size = new System.Drawing.Size(35, 12); - this.labelOPCDACount.TabIndex = 51; - this.labelOPCDACount.Text = "Count"; - // - // labelSecond - // - this.labelSecond.AutoSize = true; - this.labelSecond.Location = new System.Drawing.Point(86, 50); - this.labelSecond.Name = "labelSecond"; - this.labelSecond.Size = new System.Drawing.Size(41, 12); - this.labelSecond.TabIndex = 50; - this.labelSecond.Text = "Second"; - // - // labelOPCDAMonitor - // - this.labelOPCDAMonitor.AutoSize = true; - this.labelOPCDAMonitor.Location = new System.Drawing.Point(3, 49); - this.labelOPCDAMonitor.Name = "labelOPCDAMonitor"; - this.labelOPCDAMonitor.Size = new System.Drawing.Size(53, 12); - this.labelOPCDAMonitor.TabIndex = 49; - this.labelOPCDAMonitor.Text = "Interval"; - // - // textBoxOPCDAInterval - // - this.textBoxOPCDAInterval.Location = new System.Drawing.Point(58, 46); - this.textBoxOPCDAInterval.Name = "textBoxOPCDAInterval"; - this.textBoxOPCDAInterval.Size = new System.Drawing.Size(29, 21); - this.textBoxOPCDAInterval.TabIndex = 48; - this.textBoxOPCDAInterval.Text = "3"; - this.textBoxOPCDAInterval.TextChanged += new System.EventHandler(this.TextBoxOPCDAInterval_TextChanged); - // - // checkBoxOPCDA - // - this.checkBoxOPCDA.AutoSize = true; - this.checkBoxOPCDA.Location = new System.Drawing.Point(137, 22); - this.checkBoxOPCDA.Margin = new System.Windows.Forms.Padding(2); - this.checkBoxOPCDA.Name = "checkBoxOPCDA"; - this.checkBoxOPCDA.Size = new System.Drawing.Size(66, 16); - this.checkBoxOPCDA.TabIndex = 47; - this.checkBoxOPCDA.Text = "Monitor"; - this.checkBoxOPCDA.UseVisualStyleBackColor = true; - this.checkBoxOPCDA.CheckedChanged += new System.EventHandler(this.CheckBoxOPCDA_CheckedChanged); - // - // textBoxOPCDAHost - // - this.textBoxOPCDAHost.Location = new System.Drawing.Point(36, 19); - this.textBoxOPCDAHost.Name = "textBoxOPCDAHost"; - this.textBoxOPCDAHost.Size = new System.Drawing.Size(100, 21); - this.textBoxOPCDAHost.TabIndex = 46; - this.textBoxOPCDAHost.Text = "127.0.0.1"; - this.textBoxOPCDAHost.TextChanged += new System.EventHandler(this.TextBoxOPCDAHost_TextChanged); - // - // labelOPCDAHost - // - this.labelOPCDAHost.AutoSize = true; - this.labelOPCDAHost.Location = new System.Drawing.Point(6, 22); - this.labelOPCDAHost.Name = "labelOPCDAHost"; - this.labelOPCDAHost.Size = new System.Drawing.Size(29, 12); - this.labelOPCDAHost.TabIndex = 7; - this.labelOPCDAHost.Text = "Host"; - // - // textBoxOpcIp - // - this.textBoxOpcIp.Location = new System.Drawing.Point(6, 0); - this.textBoxOpcIp.Name = "textBoxOpcIp"; - this.textBoxOpcIp.Size = new System.Drawing.Size(100, 21); - this.textBoxOpcIp.TabIndex = 0; - // - // groupBox5 - // - this.groupBox5.Controls.Add(this.textBoxOPCUATopic); - this.groupBox5.Controls.Add(this.labelopcua); - this.groupBox5.Location = new System.Drawing.Point(293, 266); - this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(211, 45); - this.groupBox5.TabIndex = 19; - this.groupBox5.TabStop = false; - this.groupBox5.Text = "OPC_UA Capture"; - this.groupBox5.Enter += new System.EventHandler(this.groupBox5_Enter); - // - // textBoxOPCUATopic - // - this.textBoxOPCUATopic.Location = new System.Drawing.Point(35, 17); - this.textBoxOPCUATopic.Name = "textBoxOPCUATopic"; - this.textBoxOPCUATopic.ReadOnly = true; - this.textBoxOPCUATopic.Size = new System.Drawing.Size(168, 21); - this.textBoxOPCUATopic.TabIndex = 5; - this.textBoxOPCUATopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxOPCUATopic.TextChanged += new System.EventHandler(this.TextBoxOPCUATopic_TextChanged); - // - // labelopcua - // - this.labelopcua.AutoSize = true; - this.labelopcua.Location = new System.Drawing.Point(6, 19); - this.labelopcua.Name = "labelopcua"; - this.labelopcua.Size = new System.Drawing.Size(17, 12); - this.labelopcua.TabIndex = 6; - this.labelopcua.Text = "To"; - // - // groupBox6 - // - this.groupBox6.Controls.Add(this.textBoxBACnetTopic); - this.groupBox6.Controls.Add(this.label23); - this.groupBox6.Location = new System.Drawing.Point(293, 326); - this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(211, 42); - this.groupBox6.TabIndex = 20; - this.groupBox6.TabStop = false; - this.groupBox6.Text = "BACnet Capture"; - this.groupBox6.Enter += new System.EventHandler(this.groupBox6_Enter); - // - // textBoxBACnetTopic - // - this.textBoxBACnetTopic.Location = new System.Drawing.Point(31, 17); - this.textBoxBACnetTopic.Name = "textBoxBACnetTopic"; - this.textBoxBACnetTopic.ReadOnly = true; - this.textBoxBACnetTopic.Size = new System.Drawing.Size(169, 21); - this.textBoxBACnetTopic.TabIndex = 5; - this.textBoxBACnetTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxBACnetTopic.TextChanged += new System.EventHandler(this.TextBoxBACnetTopic_TextChanged); - // - // label23 - // - this.label23.AutoSize = true; - this.label23.Location = new System.Drawing.Point(7, 21); - this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(17, 12); - this.label23.TabIndex = 6; - this.label23.Text = "To"; - // - // groupBox7 - // - this.groupBox7.Controls.Add(this.textBoxControlTopic); - this.groupBox7.Controls.Add(this.label8); - this.groupBox7.Location = new System.Drawing.Point(293, 383); - this.groupBox7.Name = "groupBox7"; - this.groupBox7.Size = new System.Drawing.Size(211, 47); - this.groupBox7.TabIndex = 21; - this.groupBox7.TabStop = false; - this.groupBox7.Text = "Control Capture"; - // - // textBoxControlTopic - // - this.textBoxControlTopic.Location = new System.Drawing.Point(33, 17); - this.textBoxControlTopic.Name = "textBoxControlTopic"; - this.textBoxControlTopic.ReadOnly = true; - this.textBoxControlTopic.Size = new System.Drawing.Size(170, 21); - this.textBoxControlTopic.TabIndex = 5; - this.textBoxControlTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxControlTopic.TextChanged += new System.EventHandler(this.TextBoxControlTopic_TextChanged); - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(6, 21); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(17, 12); - this.label8.TabIndex = 6; - this.label8.Text = "To"; - // - // comboBoxBridge - // - this.comboBoxBridge.FormattingEnabled = true; - this.comboBoxBridge.Items.AddRange(new object[] { - "SerialPort,", - "TcpServer,", - "BACnet,", - "OPCDA,", - "OPCUA,", - "MqttClient,", - "MqttServer,", - "TcpClient,", - "TcpServer,", - "UdpClient,", - "UdpServer,", - "PLC,", - "Control,", - "Access,", - "SqlServer" - }); - this.comboBoxBridge.Location = new System.Drawing.Point(42, 491); - this.comboBoxBridge.Name = "comboBoxBridge"; - this.comboBoxBridge.Size = new System.Drawing.Size(76, 20); - this.comboBoxBridge.TabIndex = 13; - this.comboBoxBridge.SelectedIndexChanged += new System.EventHandler(this.ComboBoxBridge_SelectedIndexChanged); - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(9, 495); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(17, 12); - this.label7.TabIndex = 18; - this.label7.Text = "To"; - // - // groupBox8 - // - this.groupBox8.Controls.Add(this.textBoxAccessTopic); - this.groupBox8.Controls.Add(this.label6); - this.groupBox8.Location = new System.Drawing.Point(293, 437); - this.groupBox8.Name = "groupBox8"; - this.groupBox8.Size = new System.Drawing.Size(211, 43); - this.groupBox8.TabIndex = 22; - this.groupBox8.TabStop = false; - this.groupBox8.Text = "Access Capture"; - this.groupBox8.Enter += new System.EventHandler(this.groupBox8_Enter); - // - // textBoxAccessTopic - // - this.textBoxAccessTopic.Location = new System.Drawing.Point(33, 17); - this.textBoxAccessTopic.Name = "textBoxAccessTopic"; - this.textBoxAccessTopic.ReadOnly = true; - this.textBoxAccessTopic.Size = new System.Drawing.Size(170, 21); - this.textBoxAccessTopic.TabIndex = 5; - this.textBoxAccessTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxAccessTopic.TextChanged += new System.EventHandler(this.TextBoxAccessTopic_TextChanged); - // - // label6 - // - this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(6, 21); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(17, 12); - this.label6.TabIndex = 6; - this.label6.Text = "To"; - // - // groupBox10 - // - this.groupBox10.Controls.Add(this.label15); - this.groupBox10.Controls.Add(this.textBoxUDPClientLogin); - this.groupBox10.Location = new System.Drawing.Point(572, 274); - this.groupBox10.Name = "groupBox10"; - this.groupBox10.Size = new System.Drawing.Size(215, 46); - this.groupBox10.TabIndex = 19; - this.groupBox10.TabStop = false; - this.groupBox10.Text = "UDP Client Channel"; - // - // label15 - // - this.label15.AutoSize = true; - this.label15.Location = new System.Drawing.Point(5, 25); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(35, 12); - this.label15.TabIndex = 13; - this.label15.Text = "login"; - // - // radioButtonMqttClient - // - this.radioButtonMqttClient.AutoSize = true; - this.radioButtonMqttClient.Checked = true; - this.radioButtonMqttClient.Location = new System.Drawing.Point(559, 78); - this.radioButtonMqttClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.radioButtonMqttClient.Name = "radioButtonMqttClient"; - this.radioButtonMqttClient.Size = new System.Drawing.Size(14, 13); - this.radioButtonMqttClient.TabIndex = 30; - this.radioButtonMqttClient.TabStop = true; - this.radioButtonMqttClient.UseVisualStyleBackColor = true; - this.radioButtonMqttClient.CheckedChanged += new System.EventHandler(this.RadioButtonMqttClient_CheckedChanged); - // - // radioButtonTcpClient - // - this.radioButtonTcpClient.AutoSize = true; - this.radioButtonTcpClient.Location = new System.Drawing.Point(553, 207); - this.radioButtonTcpClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.radioButtonTcpClient.Name = "radioButtonTcpClient"; - this.radioButtonTcpClient.Size = new System.Drawing.Size(14, 13); - this.radioButtonTcpClient.TabIndex = 31; - this.radioButtonTcpClient.UseVisualStyleBackColor = true; - this.radioButtonTcpClient.CheckedChanged += new System.EventHandler(this.RadioButtonTcpClient_CheckedChanged); - // - // radioButtonUDPClient - // - this.radioButtonUDPClient.AutoSize = true; - this.radioButtonUDPClient.Location = new System.Drawing.Point(553, 291); - this.radioButtonUDPClient.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.radioButtonUDPClient.Name = "radioButtonUDPClient"; - this.radioButtonUDPClient.Size = new System.Drawing.Size(14, 13); - this.radioButtonUDPClient.TabIndex = 32; - this.radioButtonUDPClient.UseVisualStyleBackColor = true; - this.radioButtonUDPClient.CheckedChanged += new System.EventHandler(this.RadioButtonUDPClient_CheckedChanged); - // - // groupBox12 - // - this.groupBox12.Controls.Add(this.textBoxPLCTopic); - this.groupBox12.Controls.Add(this.label2); - this.groupBox12.Location = new System.Drawing.Point(295, 130); - this.groupBox12.Name = "groupBox12"; - this.groupBox12.Size = new System.Drawing.Size(211, 44); - this.groupBox12.TabIndex = 19; - this.groupBox12.TabStop = false; - this.groupBox12.Text = "PLC Capture"; - // - // textBoxPLCTopic - // - this.textBoxPLCTopic.Location = new System.Drawing.Point(39, 15); - this.textBoxPLCTopic.Name = "textBoxPLCTopic"; - this.textBoxPLCTopic.ReadOnly = true; - this.textBoxPLCTopic.Size = new System.Drawing.Size(165, 21); - this.textBoxPLCTopic.TabIndex = 5; - this.textBoxPLCTopic.Text = "$dg/thing/{productId}/{deviceAddr}/properties/report"; - this.textBoxPLCTopic.TextChanged += new System.EventHandler(this.TextBoxPLCTopic_TextChanged); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(4, 19); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(17, 12); - this.label2.TabIndex = 6; - this.label2.Text = "To"; - // - // pictureBox1 - // - this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); - this.pictureBox1.Location = new System.Drawing.Point(511, -43); - this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(53, 512); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; - this.pictureBox1.TabIndex = 35; - this.pictureBox1.TabStop = false; - // - // comboBoxLogLevel - // - this.comboBoxLogLevel.FormattingEnabled = true; - this.comboBoxLogLevel.Location = new System.Drawing.Point(585, 491); - this.comboBoxLogLevel.Name = "comboBoxLogLevel"; - this.comboBoxLogLevel.Size = new System.Drawing.Size(56, 20); - this.comboBoxLogLevel.TabIndex = 36; - this.comboBoxLogLevel.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLogLevel_SelectedIndexChanged); - // - // label32 - // - this.label32.AutoSize = true; - this.label32.Location = new System.Drawing.Point(515, 495); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(59, 12); - this.label32.TabIndex = 37; - this.label32.Text = "Log Level"; - // - // comboBoxLan - // - this.comboBoxLan.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxLan.FormattingEnabled = true; - this.comboBoxLan.Location = new System.Drawing.Point(712, 492); - this.comboBoxLan.Name = "comboBoxLan"; - this.comboBoxLan.Size = new System.Drawing.Size(71, 20); - this.comboBoxLan.TabIndex = 38; - this.comboBoxLan.SelectedIndexChanged += new System.EventHandler(this.ComboBoxLan_SelectedIndexChanged); - // - // label33 - // - this.label33.AutoSize = true; - this.label33.Location = new System.Drawing.Point(649, 495); - this.label33.Name = "label33"; - this.label33.Size = new System.Drawing.Size(53, 12); - this.label33.TabIndex = 39; - this.label33.Text = "Language"; - // - // treeView - // - this.treeView.CheckBoxes = true; - this.treeView.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.treeView.LabelEdit = true; - this.treeView.Location = new System.Drawing.Point(3, 24); - this.treeView.Margin = new System.Windows.Forms.Padding(2); - this.treeView.Name = "treeView"; - this.treeView.Size = new System.Drawing.Size(287, 210); - this.treeView.TabIndex = 0; - this.treeView.AfterLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.AfterLabelEdit); - this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterCheck); - this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterSelect); - this.treeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.NodeMouseDoubleClick); - // - // label_devcietree - // - this.label_devcietree.Location = new System.Drawing.Point(7, 3); - this.label_devcietree.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); - this.label_devcietree.Name = "label_devcietree"; - this.label_devcietree.Size = new System.Drawing.Size(67, 15); - this.label_devcietree.TabIndex = 41; - this.label_devcietree.Text = "DeviceTree"; - // - // openFileDialog - // - this.openFileDialog.FileName = "openFileDialog"; - this.openFileDialog.Filter = "(*.txt)|*.txt"; - this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog_FileOk); - // - // groupBoxCommonConfig - // - this.groupBoxCommonConfig.Controls.Add(this.comboBoxDtuAddr); - this.groupBoxCommonConfig.Controls.Add(this.label22); - this.groupBoxCommonConfig.Controls.Add(this.label30); - this.groupBoxCommonConfig.Controls.Add(this.textBoxBridgePort); - this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotSever); - this.groupBoxCommonConfig.Controls.Add(this.label21); - this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotPort); - this.groupBoxCommonConfig.Controls.Add(this.checkBoxBridge); - this.groupBoxCommonConfig.Controls.Add(this.buttonStartStop); - this.groupBoxCommonConfig.Controls.Add(this.checkBoxReconnect); - this.groupBoxCommonConfig.Location = new System.Drawing.Point(569, 328); - this.groupBoxCommonConfig.Name = "groupBoxCommonConfig"; - this.groupBoxCommonConfig.Size = new System.Drawing.Size(219, 157); - this.groupBoxCommonConfig.TabIndex = 19; - this.groupBoxCommonConfig.TabStop = false; - this.groupBoxCommonConfig.Text = "Common Config"; - // - // buttonScan - // - this.buttonScan.Location = new System.Drawing.Point(457, 490); - this.buttonScan.Name = "buttonScan"; - this.buttonScan.Size = new System.Drawing.Size(53, 21); - this.buttonScan.TabIndex = 40; - this.buttonScan.Text = "Scan"; - this.buttonScan.UseVisualStyleBackColor = true; - this.buttonScan.Click += new System.EventHandler(this.ButtonScan_Click); - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(143)))), ((int)(((byte)(178))))); - this.ClientSize = new System.Drawing.Size(803, 521); - this.Controls.Add(this.buttonScan); - this.Controls.Add(this.groupBoxCommonConfig); - this.Controls.Add(this.groupBox8); - this.Controls.Add(this.buttonClear); - this.Controls.Add(this.groupBox7); - this.Controls.Add(this.groupBox6); - this.Controls.Add(this.groupBox5); - this.Controls.Add(this.groupBox4); - this.Controls.Add(this.groupBox12); - this.Controls.Add(this.groupBoxSerialPort); - this.Controls.Add(this.comboBoxLan); - this.Controls.Add(this.label33); - this.Controls.Add(this.groupBox3); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox10); - this.Controls.Add(this.radioButtonUDPClient); - this.Controls.Add(this.radioButtonTcpClient); - this.Controls.Add(this.radioButtonMqttClient); - this.Controls.Add(this.label_devcietree); - this.Controls.Add(this.treeView); - this.Controls.Add(this.label32); - this.Controls.Add(this.comboBoxLogLevel); - this.Controls.Add(this.label7); - this.Controls.Add(this.comboBoxBridge); - this.Controls.Add(this.checkBoxDisplayHex); - this.Controls.Add(this.sendBridge); - this.Controls.Add(this.textToPayload); - this.Controls.Add(this.linkLabel2); - this.Controls.Add(this.textBoxLog); - this.Controls.Add(this.pictureBox1); - this.ForeColor = System.Drawing.SystemColors.ControlText; - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "MainForm"; - this.Text = "dgiot_dtu"; - this.Load += new System.EventHandler(this.MainForm_Load); - this.Resize += new System.EventHandler(this.MainForm_Resize); - this.groupBoxSerialPort.ResumeLayout(false); - this.groupBoxSerialPort.PerformLayout(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.groupBox3.ResumeLayout(false); - this.groupBox3.PerformLayout(); - this.groupBox4.ResumeLayout(false); - this.groupBox4.PerformLayout(); - this.groupBox5.ResumeLayout(false); - this.groupBox5.PerformLayout(); - this.groupBox6.ResumeLayout(false); - this.groupBox6.PerformLayout(); - this.groupBox7.ResumeLayout(false); - this.groupBox7.PerformLayout(); - this.groupBox8.ResumeLayout(false); - this.groupBox8.PerformLayout(); - this.groupBox10.ResumeLayout(false); - this.groupBox10.PerformLayout(); - this.groupBox12.ResumeLayout(false); - this.groupBox12.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.groupBoxCommonConfig.ResumeLayout(false); - this.groupBoxCommonConfig.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = + new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.buttonStartStop = new System.Windows.Forms.Button(); + this.textBoxLog = new System.Windows.Forms.TextBox(); + this.checkBoxReconnect = new System.Windows.Forms.CheckBox(); + this.checkBoxDisplayHex = new System.Windows.Forms.CheckBox(); + this.buttonClear = new System.Windows.Forms.Button(); + this.groupBoxSerialPort = new System.Windows.Forms.GroupBox(); + this.comboBoxParity = new System.Windows.Forms.ComboBox(); + this.label13 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBoxStopBits = new System.Windows.Forms.ComboBox(); + this.comboBoxDataBits = new System.Windows.Forms.ComboBox(); + this.comboBoxBaudRate = new System.Windows.Forms.ComboBox(); + this.labelSerialPort = new System.Windows.Forms.Label(); + this.comboBoxSerialPort = new System.Windows.Forms.ComboBox(); + this.textBoxBridgePort = new System.Windows.Forms.TextBox(); + this.textBoxMqttPubTopic = new System.Windows.Forms.TextBox(); + this.label12 = new System.Windows.Forms.Label(); + this.textBoxMqttSubTopic = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.textBoxMqttPassword = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.textBoxMqttUserName = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.linkLabel2 = new System.Windows.Forms.LinkLabel(); + this.textToPayload = new System.Windows.Forms.TextBox(); + this.textBoxTcpClientLogin = new System.Windows.Forms.TextBox(); + this.textBoxMqttClientId = new System.Windows.Forms.TextBox(); + this.textBoxDgiotPort = new System.Windows.Forms.TextBox(); + this.textBoxUDPClientLogin = new System.Windows.Forms.TextBox(); + this.sendBridge = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.label16 = new System.Windows.Forms.Label(); + this.checkBoxBridge = new System.Windows.Forms.CheckBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.label29 = new System.Windows.Forms.Label(); + this.comboBoxCmdProdxy = new System.Windows.Forms.ComboBox(); + this.label20 = new System.Windows.Forms.Label(); + this.comboBoxDtuAddr = new System.Windows.Forms.ComboBox(); + this.label30 = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); + this.textBoxDgiotSever = new System.Windows.Forms.TextBox(); + this.label22 = new System.Windows.Forms.Label(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.textBoxOPCDACount = new System.Windows.Forms.TextBox(); + this.labelOPCDACount = new System.Windows.Forms.Label(); + this.labelSecond = new System.Windows.Forms.Label(); + this.labelOPCDAMonitor = new System.Windows.Forms.Label(); + this.textBoxOPCDAInterval = new System.Windows.Forms.TextBox(); + this.checkBoxOPCDA = new System.Windows.Forms.CheckBox(); + this.textBoxOPCDAHost = new System.Windows.Forms.TextBox(); + this.labelOPCDAHost = new System.Windows.Forms.Label(); + this.textBoxOpcIp = new System.Windows.Forms.TextBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.textBoxOPCUATopic = new System.Windows.Forms.TextBox(); + this.labelopcua = new System.Windows.Forms.Label(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.textBoxBACnetTopic = new System.Windows.Forms.TextBox(); + this.label23 = new System.Windows.Forms.Label(); + this.groupBox7 = new System.Windows.Forms.GroupBox(); + this.textBoxControlTopic = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.comboBoxBridge = new System.Windows.Forms.ComboBox(); + this.label7 = new System.Windows.Forms.Label(); + this.groupBox8 = new System.Windows.Forms.GroupBox(); + this.textBoxAccessTopic = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.groupBox10 = new System.Windows.Forms.GroupBox(); + this.label15 = new System.Windows.Forms.Label(); + this.radioButtonMqttClient = new System.Windows.Forms.RadioButton(); + this.radioButtonTcpClient = new System.Windows.Forms.RadioButton(); + this.radioButtonUDPClient = new System.Windows.Forms.RadioButton(); + this.groupBox12 = new System.Windows.Forms.GroupBox(); + this.textBoxPLCTopic = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.comboBoxLogLevel = new System.Windows.Forms.ComboBox(); + this.label32 = new System.Windows.Forms.Label(); + this.comboBoxLan = new System.Windows.Forms.ComboBox(); + this.label33 = new System.Windows.Forms.Label(); + this.treeView = new System.Windows.Forms.TreeView(); + this.label_devcietree = new System.Windows.Forms.Label(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.groupBoxCommonConfig = new System.Windows.Forms.GroupBox(); + this.buttonScan = new System.Windows.Forms.Button(); + this.groupBoxSerialPort.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox6.SuspendLayout(); + this.groupBox7.SuspendLayout(); + this.groupBox8.SuspendLayout(); + this.groupBox10.SuspendLayout(); + this.groupBox12.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.groupBoxCommonConfig.SuspendLayout(); + this.SuspendLayout(); + // + // buttonStartStop + // + this.buttonStartStop.Location = new System.Drawing.Point(151, 125); + this.buttonStartStop.Name = "buttonStartStop"; + this.buttonStartStop.Size = new System.Drawing.Size(53, 21); + this.buttonStartStop.TabIndex = 4; + this.buttonStartStop.Text = "Start"; + this.buttonStartStop.UseVisualStyleBackColor = true; + this.buttonStartStop.Click += + new System.EventHandler(this.ButtonStartStopClick); + // + // textBoxLog + // + this.textBoxLog.BackColor = System.Drawing.Color.FromArgb( + ((int)(((byte)(107)))), ((int)(((byte)(170)))), ((int)(((byte)(55))))); + this.textBoxLog.Location = new System.Drawing.Point(3, 233); + this.textBoxLog.Multiline = true; + this.textBoxLog.Name = "textBoxLog"; + this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxLog.Size = new System.Drawing.Size(289, 253); + this.textBoxLog.TabIndex = 9; + this.textBoxLog.TextChanged += + new System.EventHandler(this.textBoxLog_TextChanged); + // + // checkBoxReconnect + // + this.checkBoxReconnect.AutoSize = true; + this.checkBoxReconnect.Location = new System.Drawing.Point(10, 129); + this.checkBoxReconnect.Name = "checkBoxReconnect"; + this.checkBoxReconnect.Size = new System.Drawing.Size(108, 16); + this.checkBoxReconnect.TabIndex = 5; + this.checkBoxReconnect.Text = "Auto Reconnect"; + this.checkBoxReconnect.UseVisualStyleBackColor = true; + this.checkBoxReconnect.CheckedChanged += + new System.EventHandler(this.CheckBoxReconnectCheckedChanged); + // + // checkBoxDisplayHex + // + this.checkBoxDisplayHex.AutoSize = true; + this.checkBoxDisplayHex.Location = new System.Drawing.Point(306, 493); + this.checkBoxDisplayHex.Name = "checkBoxDisplayHex"; + this.checkBoxDisplayHex.Size = new System.Drawing.Size(42, 16); + this.checkBoxDisplayHex.TabIndex = 11; + this.checkBoxDisplayHex.Text = "Hex"; + this.checkBoxDisplayHex.UseVisualStyleBackColor = true; + this.checkBoxDisplayHex.CheckedChanged += + new System.EventHandler(this.CheckBoxDisplayHexCheckedChanged); + // + // buttonClear + // + this.buttonClear.Location = new System.Drawing.Point(404, 490); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(48, 21); + this.buttonClear.TabIndex = 12; + this.buttonClear.Text = "Clear"; + this.buttonClear.UseVisualStyleBackColor = true; + this.buttonClear.Click += new System.EventHandler(this.ButtonClearClick); + // + // groupBoxSerialPort + // + this.groupBoxSerialPort.Controls.Add(this.comboBoxParity); + this.groupBoxSerialPort.Controls.Add(this.label13); + this.groupBoxSerialPort.Controls.Add(this.label5); + this.groupBoxSerialPort.Controls.Add(this.label4); + this.groupBoxSerialPort.Controls.Add(this.label1); + this.groupBoxSerialPort.Controls.Add(this.comboBoxStopBits); + this.groupBoxSerialPort.Controls.Add(this.comboBoxDataBits); + this.groupBoxSerialPort.Controls.Add(this.comboBoxBaudRate); + this.groupBoxSerialPort.Controls.Add(this.labelSerialPort); + this.groupBoxSerialPort.Controls.Add(this.comboBoxSerialPort); + this.groupBoxSerialPort.Location = new System.Drawing.Point(293, 17); + this.groupBoxSerialPort.Name = "groupBoxSerialPort"; + this.groupBoxSerialPort.Size = new System.Drawing.Size(213, 111); + this.groupBoxSerialPort.TabIndex = 13; + this.groupBoxSerialPort.TabStop = false; + this.groupBoxSerialPort.Text = "Serial Port Capture"; + // + // comboBoxParity + // + this.comboBoxParity.FormattingEnabled = true; + this.comboBoxParity.Items.AddRange( + new object[] { "NONE", "Odd", "Even", "Mark", "Space" }); + this.comboBoxParity.Location = new System.Drawing.Point(63, 59); + this.comboBoxParity.Name = "comboBoxParity"; + this.comboBoxParity.Size = new System.Drawing.Size(140, 20); + this.comboBoxParity.TabIndex = 14; + this.comboBoxParity.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxParity_SelectedIndexChanged); + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(5, 59); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(41, 12); + this.label13.TabIndex = 13; + this.label13.Text = "Parity"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(5, 86); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(53, 12); + this.label5.TabIndex = 12; + this.label5.Text = "stopBits"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(108, 86); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(53, 12); + this.label4.TabIndex = 12; + this.label4.Text = "dataBits"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 39); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(59, 12); + this.label1.TabIndex = 12; + this.label1.Text = "Baud Rate"; + // + // comboBoxStopBits + // + this.comboBoxStopBits.FormattingEnabled = true; + this.comboBoxStopBits.Items.AddRange(new object[] { "1", "2", "1.5" }); + this.comboBoxStopBits.Location = new System.Drawing.Point(64, 83); + this.comboBoxStopBits.Name = "comboBoxStopBits"; + this.comboBoxStopBits.Size = new System.Drawing.Size(41, 20); + this.comboBoxStopBits.TabIndex = 11; + this.comboBoxStopBits.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxStopBits_SelectedIndexChanged); + // + // comboBoxDataBits + // + this.comboBoxDataBits.FormattingEnabled = true; + this.comboBoxDataBits.Items.AddRange(new object[] { "8", "7", "6", "5" }); + this.comboBoxDataBits.Location = new System.Drawing.Point(164, 83); + this.comboBoxDataBits.Name = "comboBoxDataBits"; + this.comboBoxDataBits.Size = new System.Drawing.Size(39, 20); + this.comboBoxDataBits.TabIndex = 11; + this.comboBoxDataBits.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxDataBits_SelectedIndexChanged); + // + // comboBoxBaudRate + // + this.comboBoxBaudRate.FormattingEnabled = true; + this.comboBoxBaudRate.Items.AddRange( + new object[] { "1200", "2400", "4800", "9600", "19200", "38400", + "57600", "115200" }); + this.comboBoxBaudRate.Location = new System.Drawing.Point(62, 37); + this.comboBoxBaudRate.Name = "comboBoxBaudRate"; + this.comboBoxBaudRate.Size = new System.Drawing.Size(141, 20); + this.comboBoxBaudRate.TabIndex = 11; + this.comboBoxBaudRate.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxBaudRate_SelectedIndexChanged); + // + // labelSerialPort + // + this.labelSerialPort.AutoSize = true; + this.labelSerialPort.Location = new System.Drawing.Point(6, 17); + this.labelSerialPort.Name = "labelSerialPort"; + this.labelSerialPort.Size = new System.Drawing.Size(29, 12); + this.labelSerialPort.TabIndex = 10; + this.labelSerialPort.Text = "Port"; + // + // comboBoxSerialPort + // + this.comboBoxSerialPort.FormattingEnabled = true; + this.comboBoxSerialPort.Location = new System.Drawing.Point(62, 15); + this.comboBoxSerialPort.Name = "comboBoxSerialPort"; + this.comboBoxSerialPort.Size = new System.Drawing.Size(141, 20); + this.comboBoxSerialPort.TabIndex = 9; + this.comboBoxSerialPort.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxSerialPort_SelectedIndexChanged); + // + // textBoxBridgePort + // + this.textBoxBridgePort.Location = new System.Drawing.Point(134, 97); + this.textBoxBridgePort.Name = "textBoxBridgePort"; + this.textBoxBridgePort.Size = new System.Drawing.Size(75, 21); + this.textBoxBridgePort.TabIndex = 7; + this.textBoxBridgePort.Text = "5080"; + this.textBoxBridgePort.TextChanged += + new System.EventHandler(this.TextBoxBridgePort_TextChanged); + // + // textBoxMqttPubTopic + // + this.textBoxMqttPubTopic.Location = new System.Drawing.Point(80, 119); + this.textBoxMqttPubTopic.Name = "textBoxMqttPubTopic"; + this.textBoxMqttPubTopic.Size = new System.Drawing.Size(132, 21); + this.textBoxMqttPubTopic.TabIndex = 22; + this.textBoxMqttPubTopic.Text = + "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxMqttPubTopic.TextChanged += + new System.EventHandler(this.TextBoxMqttPubTopic_TextChanged); + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(9, 119); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(53, 12); + this.label12.TabIndex = 21; + this.label12.Text = "PubTopic"; + // + // textBoxMqttSubTopic + // + this.textBoxMqttSubTopic.Location = new System.Drawing.Point(81, 95); + this.textBoxMqttSubTopic.Name = "textBoxMqttSubTopic"; + this.textBoxMqttSubTopic.Size = new System.Drawing.Size(132, 21); + this.textBoxMqttSubTopic.TabIndex = 20; + this.textBoxMqttSubTopic.Text = + "$dg/device/{productId}/{deviceAddr}/properties"; + this.textBoxMqttSubTopic.TextChanged += + new System.EventHandler(this.TextBoxMqttSubTopic_TextChanged); + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(9, 96); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(53, 12); + this.label11.TabIndex = 19; + this.label11.Text = "SubTopic"; + // + // textBoxMqttPassword + // + this.textBoxMqttPassword.Location = new System.Drawing.Point(81, 44); + this.textBoxMqttPassword.Name = "textBoxMqttPassword"; + this.textBoxMqttPassword.Size = new System.Drawing.Size(131, 21); + this.textBoxMqttPassword.TabIndex = 18; + this.textBoxMqttPassword.Text = "SzQ3MDU4ODMxNjQwNjYyNjkwOTg4"; + this.textBoxMqttPassword.TextChanged += + new System.EventHandler(this.TextBoxMqttPassword_TextChanged); + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(8, 47); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(53, 12); + this.label10.TabIndex = 17; + this.label10.Text = "PassWord"; + // + // textBoxMqttUserName + // + this.textBoxMqttUserName.Location = new System.Drawing.Point(81, 20); + this.textBoxMqttUserName.Name = "textBoxMqttUserName"; + this.textBoxMqttUserName.Size = new System.Drawing.Size(131, 21); + this.textBoxMqttUserName.TabIndex = 16; + this.textBoxMqttUserName.Text = "fa82a59201"; + this.textBoxMqttUserName.TextChanged += + new System.EventHandler(this.TextBoxMqttUserName_TextChanged); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(6, 24); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(53, 12); + this.label9.TabIndex = 15; + this.label9.Text = "UserName"; + // + // linkLabel2 + // + this.linkLabel2.AutoSize = true; + this.linkLabel2.LinkColor = System.Drawing.Color.Silver; + this.linkLabel2.Location = new System.Drawing.Point(515, 449); + this.linkLabel2.Name = "linkLabel2"; + this.linkLabel2.Size = new System.Drawing.Size(41, 12); + this.linkLabel2.TabIndex = 16; + this.linkLabel2.TabStop = true; + this.linkLabel2.Text = "DG-IoT"; + this.linkLabel2.LinkClicked += + new System.Windows.Forms.LinkLabelLinkClickedEventHandler( + this.LinkLabel2_LinkClicked); + // + // textToPayload + // + this.textToPayload.Location = new System.Drawing.Point(127, 491); + this.textToPayload.Name = "textToPayload"; + this.textToPayload.Size = new System.Drawing.Size(169, 21); + this.textToPayload.TabIndex = 14; + this.textToPayload.Text = "12345678"; + this.textToPayload.TextChanged += + new System.EventHandler(this.TextToPayload_TextChanged); + // + // textBoxTcpClientLogin + // + this.textBoxTcpClientLogin.Location = new System.Drawing.Point(79, 21); + this.textBoxTcpClientLogin.Name = "textBoxTcpClientLogin"; + this.textBoxTcpClientLogin.Size = new System.Drawing.Size(131, 21); + this.textBoxTcpClientLogin.TabIndex = 12; + this.textBoxTcpClientLogin.Text = "login"; + this.textBoxTcpClientLogin.TextChanged += + new System.EventHandler(this.TextBoxTcpClientLogin_TextChanged); + // + // textBoxMqttClientId + // + this.textBoxMqttClientId.Location = new System.Drawing.Point(81, 71); + this.textBoxMqttClientId.Name = "textBoxMqttClientId"; + this.textBoxMqttClientId.Size = new System.Drawing.Size(131, 21); + this.textBoxMqttClientId.TabIndex = 12; + this.textBoxMqttClientId.Text = "devaddr"; + this.textBoxMqttClientId.TextChanged += + new System.EventHandler(this.TextBoxMqttClientId_TextChanged); + // + // textBoxDgiotPort + // + this.textBoxDgiotPort.Location = new System.Drawing.Point(77, 46); + this.textBoxDgiotPort.Name = "textBoxDgiotPort"; + this.textBoxDgiotPort.Size = new System.Drawing.Size(133, 21); + this.textBoxDgiotPort.TabIndex = 7; + this.textBoxDgiotPort.Text = "1883"; + this.textBoxDgiotPort.TextChanged += + new System.EventHandler(this.TextBoxDgiotPort_TextChanged); + // + // textBoxUDPClientLogin + // + this.textBoxUDPClientLogin.Location = new System.Drawing.Point(74, 21); + this.textBoxUDPClientLogin.Name = "textBoxUDPClientLogin"; + this.textBoxUDPClientLogin.Size = new System.Drawing.Size(136, 21); + this.textBoxUDPClientLogin.TabIndex = 12; + this.textBoxUDPClientLogin.Text = "login"; + this.textBoxUDPClientLogin.TextChanged += + new System.EventHandler(this.TextBoxUDPClientLogin_TextChanged); + // + // sendBridge + // + this.sendBridge.Location = new System.Drawing.Point(350, 491); + this.sendBridge.Name = "sendBridge"; + this.sendBridge.Size = new System.Drawing.Size(47, 21); + this.sendBridge.TabIndex = 17; + this.sendBridge.Text = "Send"; + this.sendBridge.UseVisualStyleBackColor = true; + this.sendBridge.Click += new System.EventHandler(this.SendBridge_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label16); + this.groupBox2.Controls.Add(this.textBoxTcpClientLogin); + this.groupBox2.Location = new System.Drawing.Point(571, 206); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(213, 53); + this.groupBox2.TabIndex = 18; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "TCP Client Channel"; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(9, 21); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(35, 12); + this.label16.TabIndex = 13; + this.label16.Text = "login"; + // + // checkBoxBridge + // + this.checkBoxBridge.AutoSize = true; + this.checkBoxBridge.Location = new System.Drawing.Point(10, 99); + this.checkBoxBridge.Name = "checkBoxBridge"; + this.checkBoxBridge.Size = new System.Drawing.Size(90, 16); + this.checkBoxBridge.TabIndex = 23; + this.checkBoxBridge.Text = "Bridge Port"; + this.checkBoxBridge.UseVisualStyleBackColor = true; + this.checkBoxBridge.CheckedChanged += + new System.EventHandler(this.CheckBoxBridge_CheckedChanged); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.label29); + this.groupBox3.Controls.Add(this.comboBoxCmdProdxy); + this.groupBox3.Controls.Add(this.textBoxMqttPubTopic); + this.groupBox3.Controls.Add(this.label12); + this.groupBox3.Controls.Add(this.label20); + this.groupBox3.Controls.Add(this.textBoxMqttClientId); + this.groupBox3.Controls.Add(this.textBoxMqttSubTopic); + this.groupBox3.Controls.Add(this.label11); + this.groupBox3.Controls.Add(this.textBoxMqttUserName); + this.groupBox3.Controls.Add(this.textBoxMqttPassword); + this.groupBox3.Controls.Add(this.label9); + this.groupBox3.Controls.Add(this.label10); + this.groupBox3.Location = new System.Drawing.Point(571, 15); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(217, 172); + this.groupBox3.TabIndex = 19; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Mqtt Client Channel"; + // + // label29 + // + this.label29.AutoSize = true; + this.label29.Location = new System.Drawing.Point(8, 142); + this.label29.Name = "label29"; + this.label29.Size = new System.Drawing.Size(59, 12); + this.label29.TabIndex = 37; + this.label29.Text = "cmd proxy"; + // + // comboBoxCmdProdxy + // + this.comboBoxCmdProdxy.FormattingEnabled = true; + this.comboBoxCmdProdxy.Items.AddRange(new object[] { "ffmpeg" }); + this.comboBoxCmdProdxy.Location = new System.Drawing.Point(81, 146); + this.comboBoxCmdProdxy.Name = "comboBoxCmdProdxy"; + this.comboBoxCmdProdxy.Size = new System.Drawing.Size(131, 20); + this.comboBoxCmdProdxy.TabIndex = 36; + this.comboBoxCmdProdxy.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxCmdProdxy_SelectedIndexChanged); + // + // label20 + // + this.label20.AutoSize = true; + this.label20.Location = new System.Drawing.Point(9, 72); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(53, 12); + this.label20.TabIndex = 13; + this.label20.Text = "Clientid"; + // + // comboBoxDtuAddr + // + this.comboBoxDtuAddr.FormattingEnabled = true; + this.comboBoxDtuAddr.Location = new System.Drawing.Point(77, 71); + this.comboBoxDtuAddr.Name = "comboBoxDtuAddr"; + this.comboBoxDtuAddr.Size = new System.Drawing.Size(132, 20); + this.comboBoxDtuAddr.TabIndex = 15; + this.comboBoxDtuAddr.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxDtuAddr_SelectedIndexChanged); + // + // label30 + // + this.label30.AutoSize = true; + this.label30.Location = new System.Drawing.Point(9, 69); + this.label30.Name = "label30"; + this.label30.Size = new System.Drawing.Size(47, 12); + this.label30.TabIndex = 39; + this.label30.Text = "DtuAddr"; + // + // label21 + // + this.label21.AutoSize = true; + this.label21.Location = new System.Drawing.Point(9, 48); + this.label21.Name = "label21"; + this.label21.Size = new System.Drawing.Size(29, 12); + this.label21.TabIndex = 8; + this.label21.Text = "Port"; + // + // textBoxDgiotSever + // + this.textBoxDgiotSever.Location = new System.Drawing.Point(77, 19); + this.textBoxDgiotSever.Name = "textBoxDgiotSever"; + this.textBoxDgiotSever.Size = new System.Drawing.Size(133, 21); + this.textBoxDgiotSever.TabIndex = 5; + this.textBoxDgiotSever.Text = "pump.dgiotcloud.com"; + this.textBoxDgiotSever.TextChanged += + new System.EventHandler(this.TextBoxDgiotSever_TextChanged); + // + // label22 + // + this.label22.AutoSize = true; + this.label22.Location = new System.Drawing.Point(9, 23); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(41, 12); + this.label22.TabIndex = 6; + this.label22.Text = "Server"; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.textBoxOPCDACount); + this.groupBox4.Controls.Add(this.labelOPCDACount); + this.groupBox4.Controls.Add(this.labelSecond); + this.groupBox4.Controls.Add(this.labelOPCDAMonitor); + this.groupBox4.Controls.Add(this.textBoxOPCDAInterval); + this.groupBox4.Controls.Add(this.checkBoxOPCDA); + this.groupBox4.Controls.Add(this.textBoxOPCDAHost); + this.groupBox4.Controls.Add(this.labelOPCDAHost); + this.groupBox4.Location = new System.Drawing.Point(294, 183); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(211, 75); + this.groupBox4.TabIndex = 18; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "OPC_DA Capture"; + // + // textBoxOPCDACount + // + this.textBoxOPCDACount.Location = new System.Drawing.Point(181, 47); + this.textBoxOPCDACount.Name = "textBoxOPCDACount"; + this.textBoxOPCDACount.Size = new System.Drawing.Size(27, 21); + this.textBoxOPCDACount.TabIndex = 52; + this.textBoxOPCDACount.Text = "30"; + this.textBoxOPCDACount.TextChanged += + new System.EventHandler(this.TextBoxOPCDACount_TextChanged); + // + // labelOPCDACount + // + this.labelOPCDACount.AutoSize = true; + this.labelOPCDACount.Location = new System.Drawing.Point(129, 50); + this.labelOPCDACount.Name = "labelOPCDACount"; + this.labelOPCDACount.Size = new System.Drawing.Size(35, 12); + this.labelOPCDACount.TabIndex = 51; + this.labelOPCDACount.Text = "Count"; + // + // labelSecond + // + this.labelSecond.AutoSize = true; + this.labelSecond.Location = new System.Drawing.Point(86, 50); + this.labelSecond.Name = "labelSecond"; + this.labelSecond.Size = new System.Drawing.Size(41, 12); + this.labelSecond.TabIndex = 50; + this.labelSecond.Text = "Second"; + // + // labelOPCDAMonitor + // + this.labelOPCDAMonitor.AutoSize = true; + this.labelOPCDAMonitor.Location = new System.Drawing.Point(3, 49); + this.labelOPCDAMonitor.Name = "labelOPCDAMonitor"; + this.labelOPCDAMonitor.Size = new System.Drawing.Size(53, 12); + this.labelOPCDAMonitor.TabIndex = 49; + this.labelOPCDAMonitor.Text = "Interval"; + // + // textBoxOPCDAInterval + // + this.textBoxOPCDAInterval.Location = new System.Drawing.Point(58, 46); + this.textBoxOPCDAInterval.Name = "textBoxOPCDAInterval"; + this.textBoxOPCDAInterval.Size = new System.Drawing.Size(29, 21); + this.textBoxOPCDAInterval.TabIndex = 48; + this.textBoxOPCDAInterval.Text = "3"; + this.textBoxOPCDAInterval.TextChanged += + new System.EventHandler(this.TextBoxOPCDAInterval_TextChanged); + // + // checkBoxOPCDA + // + this.checkBoxOPCDA.AutoSize = true; + this.checkBoxOPCDA.Location = new System.Drawing.Point(137, 22); + this.checkBoxOPCDA.Margin = new System.Windows.Forms.Padding(2); + this.checkBoxOPCDA.Name = "checkBoxOPCDA"; + this.checkBoxOPCDA.Size = new System.Drawing.Size(66, 16); + this.checkBoxOPCDA.TabIndex = 47; + this.checkBoxOPCDA.Text = "Monitor"; + this.checkBoxOPCDA.UseVisualStyleBackColor = true; + this.checkBoxOPCDA.CheckedChanged += + new System.EventHandler(this.CheckBoxOPCDA_CheckedChanged); + // + // textBoxOPCDAHost + // + this.textBoxOPCDAHost.Location = new System.Drawing.Point(36, 19); + this.textBoxOPCDAHost.Name = "textBoxOPCDAHost"; + this.textBoxOPCDAHost.Size = new System.Drawing.Size(100, 21); + this.textBoxOPCDAHost.TabIndex = 46; + this.textBoxOPCDAHost.Text = "127.0.0.1"; + this.textBoxOPCDAHost.TextChanged += + new System.EventHandler(this.TextBoxOPCDAHost_TextChanged); + // + // labelOPCDAHost + // + this.labelOPCDAHost.AutoSize = true; + this.labelOPCDAHost.Location = new System.Drawing.Point(6, 22); + this.labelOPCDAHost.Name = "labelOPCDAHost"; + this.labelOPCDAHost.Size = new System.Drawing.Size(29, 12); + this.labelOPCDAHost.TabIndex = 7; + this.labelOPCDAHost.Text = "Host"; + // + // textBoxOpcIp + // + this.textBoxOpcIp.Location = new System.Drawing.Point(6, 0); + this.textBoxOpcIp.Name = "textBoxOpcIp"; + this.textBoxOpcIp.Size = new System.Drawing.Size(100, 21); + this.textBoxOpcIp.TabIndex = 0; + // + // groupBox5 + // + this.groupBox5.Controls.Add(this.textBoxOPCUATopic); + this.groupBox5.Controls.Add(this.labelopcua); + this.groupBox5.Location = new System.Drawing.Point(293, 266); + this.groupBox5.Name = "groupBox5"; + this.groupBox5.Size = new System.Drawing.Size(211, 45); + this.groupBox5.TabIndex = 19; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "OPC_UA Capture"; + this.groupBox5.Enter += new System.EventHandler(this.groupBox5_Enter); + // + // textBoxOPCUATopic + // + this.textBoxOPCUATopic.Location = new System.Drawing.Point(35, 17); + this.textBoxOPCUATopic.Name = "textBoxOPCUATopic"; + this.textBoxOPCUATopic.ReadOnly = true; + this.textBoxOPCUATopic.Size = new System.Drawing.Size(168, 21); + this.textBoxOPCUATopic.TabIndex = 5; + this.textBoxOPCUATopic.Text = + "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxOPCUATopic.TextChanged += + new System.EventHandler(this.TextBoxOPCUATopic_TextChanged); + // + // labelopcua + // + this.labelopcua.AutoSize = true; + this.labelopcua.Location = new System.Drawing.Point(6, 19); + this.labelopcua.Name = "labelopcua"; + this.labelopcua.Size = new System.Drawing.Size(17, 12); + this.labelopcua.TabIndex = 6; + this.labelopcua.Text = "To"; + // + // groupBox6 + // + this.groupBox6.Controls.Add(this.textBoxBACnetTopic); + this.groupBox6.Controls.Add(this.label23); + this.groupBox6.Location = new System.Drawing.Point(293, 326); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(211, 42); + this.groupBox6.TabIndex = 20; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "BACnet Capture"; + this.groupBox6.Enter += new System.EventHandler(this.groupBox6_Enter); + // + // textBoxBACnetTopic + // + this.textBoxBACnetTopic.Location = new System.Drawing.Point(31, 17); + this.textBoxBACnetTopic.Name = "textBoxBACnetTopic"; + this.textBoxBACnetTopic.ReadOnly = true; + this.textBoxBACnetTopic.Size = new System.Drawing.Size(169, 21); + this.textBoxBACnetTopic.TabIndex = 5; + this.textBoxBACnetTopic.Text = + "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxBACnetTopic.TextChanged += + new System.EventHandler(this.TextBoxBACnetTopic_TextChanged); + // + // label23 + // + this.label23.AutoSize = true; + this.label23.Location = new System.Drawing.Point(7, 21); + this.label23.Name = "label23"; + this.label23.Size = new System.Drawing.Size(17, 12); + this.label23.TabIndex = 6; + this.label23.Text = "To"; + // + // groupBox7 + // + this.groupBox7.Controls.Add(this.textBoxControlTopic); + this.groupBox7.Controls.Add(this.label8); + this.groupBox7.Location = new System.Drawing.Point(293, 383); + this.groupBox7.Name = "groupBox7"; + this.groupBox7.Size = new System.Drawing.Size(211, 47); + this.groupBox7.TabIndex = 21; + this.groupBox7.TabStop = false; + this.groupBox7.Text = "Control Capture"; + // + // textBoxControlTopic + // + this.textBoxControlTopic.Location = new System.Drawing.Point(33, 17); + this.textBoxControlTopic.Name = "textBoxControlTopic"; + this.textBoxControlTopic.ReadOnly = true; + this.textBoxControlTopic.Size = new System.Drawing.Size(170, 21); + this.textBoxControlTopic.TabIndex = 5; + this.textBoxControlTopic.Text = + "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxControlTopic.TextChanged += + new System.EventHandler(this.TextBoxControlTopic_TextChanged); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(6, 21); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(17, 12); + this.label8.TabIndex = 6; + this.label8.Text = "To"; + // + // comboBoxBridge + // + this.comboBoxBridge.FormattingEnabled = true; + this.comboBoxBridge.Items.AddRange( + new object[] { "SerialPort,", "TcpServer,", "BACnet,", "OPCDA,", + "OPCUA,", "MqttClient,", "MqttServer,", "TcpClient,", + "TcpServer,", "UdpClient,", "UdpServer,", "PLC,", + "Control,", "Access,", "SqlServer" }); + this.comboBoxBridge.Location = new System.Drawing.Point(42, 491); + this.comboBoxBridge.Name = "comboBoxBridge"; + this.comboBoxBridge.Size = new System.Drawing.Size(76, 20); + this.comboBoxBridge.TabIndex = 13; + this.comboBoxBridge.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxBridge_SelectedIndexChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(9, 495); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(17, 12); + this.label7.TabIndex = 18; + this.label7.Text = "To"; + // + // groupBox8 + // + this.groupBox8.Controls.Add(this.textBoxAccessTopic); + this.groupBox8.Controls.Add(this.label6); + this.groupBox8.Location = new System.Drawing.Point(293, 437); + this.groupBox8.Name = "groupBox8"; + this.groupBox8.Size = new System.Drawing.Size(211, 43); + this.groupBox8.TabIndex = 22; + this.groupBox8.TabStop = false; + this.groupBox8.Text = "Access Capture"; + this.groupBox8.Enter += new System.EventHandler(this.groupBox8_Enter); + // + // textBoxAccessTopic + // + this.textBoxAccessTopic.Location = new System.Drawing.Point(33, 17); + this.textBoxAccessTopic.Name = "textBoxAccessTopic"; + this.textBoxAccessTopic.ReadOnly = true; + this.textBoxAccessTopic.Size = new System.Drawing.Size(170, 21); + this.textBoxAccessTopic.TabIndex = 5; + this.textBoxAccessTopic.Text = + "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxAccessTopic.TextChanged += + new System.EventHandler(this.TextBoxAccessTopic_TextChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 21); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(17, 12); + this.label6.TabIndex = 6; + this.label6.Text = "To"; + // + // groupBox10 + // + this.groupBox10.Controls.Add(this.label15); + this.groupBox10.Controls.Add(this.textBoxUDPClientLogin); + this.groupBox10.Location = new System.Drawing.Point(572, 274); + this.groupBox10.Name = "groupBox10"; + this.groupBox10.Size = new System.Drawing.Size(215, 46); + this.groupBox10.TabIndex = 19; + this.groupBox10.TabStop = false; + this.groupBox10.Text = "UDP Client Channel"; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(5, 25); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(35, 12); + this.label15.TabIndex = 13; + this.label15.Text = "login"; + // + // radioButtonMqttClient + // + this.radioButtonMqttClient.AutoSize = true; + this.radioButtonMqttClient.Checked = true; + this.radioButtonMqttClient.Location = new System.Drawing.Point(559, 78); + this.radioButtonMqttClient.Margin = + new System.Windows.Forms.Padding(2, 1, 2, 1); + this.radioButtonMqttClient.Name = "radioButtonMqttClient"; + this.radioButtonMqttClient.Size = new System.Drawing.Size(14, 13); + this.radioButtonMqttClient.TabIndex = 30; + this.radioButtonMqttClient.TabStop = true; + this.radioButtonMqttClient.UseVisualStyleBackColor = true; + this.radioButtonMqttClient.CheckedChanged += + new System.EventHandler(this.RadioButtonMqttClient_CheckedChanged); + // + // radioButtonTcpClient + // + this.radioButtonTcpClient.AutoSize = true; + this.radioButtonTcpClient.Location = new System.Drawing.Point(553, 207); + this.radioButtonTcpClient.Margin = + new System.Windows.Forms.Padding(2, 1, 2, 1); + this.radioButtonTcpClient.Name = "radioButtonTcpClient"; + this.radioButtonTcpClient.Size = new System.Drawing.Size(14, 13); + this.radioButtonTcpClient.TabIndex = 31; + this.radioButtonTcpClient.UseVisualStyleBackColor = true; + this.radioButtonTcpClient.CheckedChanged += + new System.EventHandler(this.RadioButtonTcpClient_CheckedChanged); + // + // radioButtonUDPClient + // + this.radioButtonUDPClient.AutoSize = true; + this.radioButtonUDPClient.Location = new System.Drawing.Point(553, 291); + this.radioButtonUDPClient.Margin = + new System.Windows.Forms.Padding(2, 1, 2, 1); + this.radioButtonUDPClient.Name = "radioButtonUDPClient"; + this.radioButtonUDPClient.Size = new System.Drawing.Size(14, 13); + this.radioButtonUDPClient.TabIndex = 32; + this.radioButtonUDPClient.UseVisualStyleBackColor = true; + this.radioButtonUDPClient.CheckedChanged += + new System.EventHandler(this.RadioButtonUDPClient_CheckedChanged); + // + // groupBox12 + // + this.groupBox12.Controls.Add(this.textBoxPLCTopic); + this.groupBox12.Controls.Add(this.label2); + this.groupBox12.Location = new System.Drawing.Point(295, 130); + this.groupBox12.Name = "groupBox12"; + this.groupBox12.Size = new System.Drawing.Size(211, 44); + this.groupBox12.TabIndex = 19; + this.groupBox12.TabStop = false; + this.groupBox12.Text = "PLC Capture"; + // + // textBoxPLCTopic + // + this.textBoxPLCTopic.Location = new System.Drawing.Point(39, 15); + this.textBoxPLCTopic.Name = "textBoxPLCTopic"; + this.textBoxPLCTopic.ReadOnly = true; + this.textBoxPLCTopic.Size = new System.Drawing.Size(165, 21); + this.textBoxPLCTopic.TabIndex = 5; + this.textBoxPLCTopic.Text = + "$dg/thing/{productId}/{deviceAddr}/properties/report"; + this.textBoxPLCTopic.TextChanged += + new System.EventHandler(this.TextBoxPLCTopic_TextChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 19); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(17, 12); + this.label2.TabIndex = 6; + this.label2.Text = "To"; + // + // pictureBox1 + // + this.pictureBox1.Image = + ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image"))); + this.pictureBox1.Location = new System.Drawing.Point(511, -43); + this.pictureBox1.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(53, 512); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; + this.pictureBox1.TabIndex = 35; + this.pictureBox1.TabStop = false; + // + // comboBoxLogLevel + // + this.comboBoxLogLevel.FormattingEnabled = true; + this.comboBoxLogLevel.Location = new System.Drawing.Point(585, 491); + this.comboBoxLogLevel.Name = "comboBoxLogLevel"; + this.comboBoxLogLevel.Size = new System.Drawing.Size(56, 20); + this.comboBoxLogLevel.TabIndex = 36; + this.comboBoxLogLevel.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxLogLevel_SelectedIndexChanged); + // + // label32 + // + this.label32.AutoSize = true; + this.label32.Location = new System.Drawing.Point(515, 495); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(59, 12); + this.label32.TabIndex = 37; + this.label32.Text = "Log Level"; + // + // comboBoxLan + // + this.comboBoxLan.DropDownStyle = + System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxLan.FormattingEnabled = true; + this.comboBoxLan.Location = new System.Drawing.Point(712, 492); + this.comboBoxLan.Name = "comboBoxLan"; + this.comboBoxLan.Size = new System.Drawing.Size(71, 20); + this.comboBoxLan.TabIndex = 38; + this.comboBoxLan.SelectedIndexChanged += + new System.EventHandler(this.ComboBoxLan_SelectedIndexChanged); + // + // label33 + // + this.label33.AutoSize = true; + this.label33.Location = new System.Drawing.Point(649, 495); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(53, 12); + this.label33.TabIndex = 39; + this.label33.Text = "Language"; + // + // treeView + // + this.treeView.CheckBoxes = true; + this.treeView.ImeMode = System.Windows.Forms.ImeMode.NoControl; + this.treeView.LabelEdit = true; + this.treeView.Location = new System.Drawing.Point(3, 24); + this.treeView.Margin = new System.Windows.Forms.Padding(2); + this.treeView.Name = "treeView"; + this.treeView.Size = new System.Drawing.Size(287, 210); + this.treeView.TabIndex = 0; + this.treeView.AfterLabelEdit += + new System.Windows.Forms.NodeLabelEditEventHandler(this.AfterLabelEdit); + this.treeView.AfterCheck += + new System.Windows.Forms.TreeViewEventHandler(this.TreeView_AfterCheck); + this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler( + this.TreeView_AfterSelect); + this.treeView.NodeMouseDoubleClick += + new System.Windows.Forms.TreeNodeMouseClickEventHandler( + this.NodeMouseDoubleClick); + // + // label_devcietree + // + this.label_devcietree.Location = new System.Drawing.Point(7, 3); + this.label_devcietree.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label_devcietree.Name = "label_devcietree"; + this.label_devcietree.Size = new System.Drawing.Size(67, 15); + this.label_devcietree.TabIndex = 41; + this.label_devcietree.Text = "DeviceTree"; + // + // openFileDialog + // + this.openFileDialog.FileName = "openFileDialog"; + this.openFileDialog.Filter = "(*.txt)|*.txt"; + this.openFileDialog.FileOk += new System.ComponentModel.CancelEventHandler( + this.openFileDialog_FileOk); + // + // groupBoxCommonConfig + // + this.groupBoxCommonConfig.Controls.Add(this.comboBoxDtuAddr); + this.groupBoxCommonConfig.Controls.Add(this.label22); + this.groupBoxCommonConfig.Controls.Add(this.label30); + this.groupBoxCommonConfig.Controls.Add(this.textBoxBridgePort); + this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotSever); + this.groupBoxCommonConfig.Controls.Add(this.label21); + this.groupBoxCommonConfig.Controls.Add(this.textBoxDgiotPort); + this.groupBoxCommonConfig.Controls.Add(this.checkBoxBridge); + this.groupBoxCommonConfig.Controls.Add(this.buttonStartStop); + this.groupBoxCommonConfig.Controls.Add(this.checkBoxReconnect); + this.groupBoxCommonConfig.Location = new System.Drawing.Point(569, 328); + this.groupBoxCommonConfig.Name = "groupBoxCommonConfig"; + this.groupBoxCommonConfig.Size = new System.Drawing.Size(219, 157); + this.groupBoxCommonConfig.TabIndex = 19; + this.groupBoxCommonConfig.TabStop = false; + this.groupBoxCommonConfig.Text = "Common Config"; + // + // buttonScan + // + this.buttonScan.Location = new System.Drawing.Point(457, 490); + this.buttonScan.Name = "buttonScan"; + this.buttonScan.Size = new System.Drawing.Size(53, 21); + this.buttonScan.TabIndex = 40; + this.buttonScan.Text = "Scan"; + this.buttonScan.UseVisualStyleBackColor = true; + this.buttonScan.Click += new System.EventHandler(this.ButtonScan_Click); + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.FromArgb( + ((int)(((byte)(60)))), ((int)(((byte)(143)))), ((int)(((byte)(178))))); + this.ClientSize = new System.Drawing.Size(803, 521); + this.Controls.Add(this.buttonScan); + this.Controls.Add(this.groupBoxCommonConfig); + this.Controls.Add(this.groupBox8); + this.Controls.Add(this.buttonClear); + this.Controls.Add(this.groupBox7); + this.Controls.Add(this.groupBox6); + this.Controls.Add(this.groupBox5); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.groupBox12); + this.Controls.Add(this.groupBoxSerialPort); + this.Controls.Add(this.comboBoxLan); + this.Controls.Add(this.label33); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox10); + this.Controls.Add(this.radioButtonUDPClient); + this.Controls.Add(this.radioButtonTcpClient); + this.Controls.Add(this.radioButtonMqttClient); + this.Controls.Add(this.label_devcietree); + this.Controls.Add(this.treeView); + this.Controls.Add(this.label32); + this.Controls.Add(this.comboBoxLogLevel); + this.Controls.Add(this.label7); + this.Controls.Add(this.comboBoxBridge); + this.Controls.Add(this.checkBoxDisplayHex); + this.Controls.Add(this.sendBridge); + this.Controls.Add(this.textToPayload); + this.Controls.Add(this.linkLabel2); + this.Controls.Add(this.textBoxLog); + this.Controls.Add(this.pictureBox1); + this.ForeColor = System.Drawing.SystemColors.ControlText; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "MainForm"; + this.Text = "dgiot_dtu"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.Resize += new System.EventHandler(this.MainForm_Resize); + this.groupBoxSerialPort.ResumeLayout(false); + this.groupBoxSerialPort.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox4.PerformLayout(); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); + this.groupBox6.ResumeLayout(false); + this.groupBox6.PerformLayout(); + this.groupBox7.ResumeLayout(false); + this.groupBox7.PerformLayout(); + this.groupBox8.ResumeLayout(false); + this.groupBox8.PerformLayout(); + this.groupBox10.ResumeLayout(false); + this.groupBox10.PerformLayout(); + this.groupBox12.ResumeLayout(false); + this.groupBox12.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.groupBoxCommonConfig.ResumeLayout(false); + this.groupBoxCommonConfig.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + } - } - - #endregion - private TreeView treeView; - private System.Windows.Forms.Button buttonStartStop; - private System.Windows.Forms.TextBox textBoxLog; - private System.Windows.Forms.CheckBox checkBoxReconnect; - private System.Windows.Forms.CheckBox checkBoxDisplayHex; - private System.Windows.Forms.Button buttonClear; - private System.Windows.Forms.GroupBox groupBoxSerialPort; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox comboBoxBaudRate; - private System.Windows.Forms.Label labelSerialPort; - private System.Windows.Forms.ComboBox comboBoxSerialPort; - private System.Windows.Forms.TextBox textBoxBridgePort; - private System.Windows.Forms.LinkLabel linkLabel2; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.ComboBox comboBoxDataBits; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.ComboBox comboBoxStopBits; - private System.Windows.Forms.TextBox textToPayload; - private System.Windows.Forms.Button sendBridge; - private System.Windows.Forms.TextBox textBoxMqttPassword; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.TextBox textBoxMqttUserName; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox textBoxMqttSubTopic; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.TextBox textBoxMqttPubTopic; - private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label16; - private System.Windows.Forms.TextBox textBoxTcpClientLogin; - private System.Windows.Forms.GroupBox groupBox3; - private System.Windows.Forms.Label label20; - private System.Windows.Forms.TextBox textBoxMqttClientId; - private System.Windows.Forms.TextBox textBoxDgiotPort; - private System.Windows.Forms.Label label21; - private System.Windows.Forms.Label label22; - private System.Windows.Forms.CheckBox checkBoxBridge; - private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.GroupBox groupBox5; - private System.Windows.Forms.TextBox textBoxOPCUATopic; - private System.Windows.Forms.Label labelopcua; - private System.Windows.Forms.GroupBox groupBox6; - private System.Windows.Forms.TextBox textBoxBACnetTopic; - private System.Windows.Forms.Label label23; - private System.Windows.Forms.GroupBox groupBox7; - private System.Windows.Forms.TextBox textBoxControlTopic; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.ComboBox comboBoxBridge; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.GroupBox groupBox8; - private System.Windows.Forms.TextBox textBoxAccessTopic; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.GroupBox groupBox10; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.TextBox textBoxUDPClientLogin; - private System.Windows.Forms.RadioButton radioButtonMqttClient; - private System.Windows.Forms.RadioButton radioButtonTcpClient; - private System.Windows.Forms.RadioButton radioButtonUDPClient; - private System.Windows.Forms.GroupBox groupBox12; - private System.Windows.Forms.TextBox textBoxPLCTopic; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.ComboBox comboBoxParity; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Label label29; - private System.Windows.Forms.ComboBox comboBoxCmdProdxy; - private System.Windows.Forms.Label label30; - private System.Windows.Forms.ComboBox comboBoxDtuAddr; - private System.Windows.Forms.TextBox textBoxOpcIp; - private System.Windows.Forms.TextBox textBoxDgiotSever; - private System.Windows.Forms.ComboBox comboBoxLogLevel; - private System.Windows.Forms.Label label32; - private System.Windows.Forms.ComboBox comboBoxLan; - private System.Windows.Forms.Label label33; - private System.Windows.Forms.Label label_devcietree; - private TextBox textBoxOPCDAHost; - private Label labelOPCDAHost; - private OpenFileDialog openFileDialog; - private CheckBox checkBoxOPCDA; - private Label labelSecond; - private Label labelOPCDAMonitor; - private TextBox textBoxOPCDAInterval; - private GroupBox groupBoxCommonConfig; - private Label labelOPCDACount; - private TextBox textBoxOPCDACount; - private Button buttonScan; +#endregion + private TreeView treeView; + private System.Windows.Forms.Button buttonStartStop; + private System.Windows.Forms.TextBox textBoxLog; + private System.Windows.Forms.CheckBox checkBoxReconnect; + private System.Windows.Forms.CheckBox checkBoxDisplayHex; + private System.Windows.Forms.Button buttonClear; + private System.Windows.Forms.GroupBox groupBoxSerialPort; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBoxBaudRate; + private System.Windows.Forms.Label labelSerialPort; + private System.Windows.Forms.ComboBox comboBoxSerialPort; + private System.Windows.Forms.TextBox textBoxBridgePort; + private System.Windows.Forms.LinkLabel linkLabel2; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox comboBoxDataBits; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ComboBox comboBoxStopBits; + private System.Windows.Forms.TextBox textToPayload; + private System.Windows.Forms.Button sendBridge; + private System.Windows.Forms.TextBox textBoxMqttPassword; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox textBoxMqttUserName; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox textBoxMqttSubTopic; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox textBoxMqttPubTopic; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.TextBox textBoxTcpClientLogin; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.Label label20; + private System.Windows.Forms.TextBox textBoxMqttClientId; + private System.Windows.Forms.TextBox textBoxDgiotPort; + private System.Windows.Forms.Label label21; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.CheckBox checkBoxBridge; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.TextBox textBoxOPCUATopic; + private System.Windows.Forms.Label labelopcua; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.TextBox textBoxBACnetTopic; + private System.Windows.Forms.Label label23; + private System.Windows.Forms.GroupBox groupBox7; + private System.Windows.Forms.TextBox textBoxControlTopic; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.ComboBox comboBoxBridge; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.GroupBox groupBox8; + private System.Windows.Forms.TextBox textBoxAccessTopic; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.GroupBox groupBox10; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox textBoxUDPClientLogin; + private System.Windows.Forms.RadioButton radioButtonMqttClient; + private System.Windows.Forms.RadioButton radioButtonTcpClient; + private System.Windows.Forms.RadioButton radioButtonUDPClient; + private System.Windows.Forms.GroupBox groupBox12; + private System.Windows.Forms.TextBox textBoxPLCTopic; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.ComboBox comboBoxParity; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label29; + private System.Windows.Forms.ComboBox comboBoxCmdProdxy; + private System.Windows.Forms.Label label30; + private System.Windows.Forms.ComboBox comboBoxDtuAddr; + private System.Windows.Forms.TextBox textBoxOpcIp; + private System.Windows.Forms.TextBox textBoxDgiotSever; + private System.Windows.Forms.ComboBox comboBoxLogLevel; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.ComboBox comboBoxLan; + private System.Windows.Forms.Label label33; + private System.Windows.Forms.Label label_devcietree; + private TextBox textBoxOPCDAHost; + private Label labelOPCDAHost; + private OpenFileDialog openFileDialog; + private CheckBox checkBoxOPCDA; + private Label labelSecond; + private Label labelOPCDAMonitor; + private TextBox textBoxOPCDAInterval; + private GroupBox groupBoxCommonConfig; + private Label labelOPCDACount; + private TextBox textBoxOPCDACount; + private Button buttonScan; } } - diff --git a/MainForm.cs b/MainForm.cs index dfd87bf..062dba7 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -2,8 +2,7 @@ // Copyright (c) PlaceholderCompany. All rights reserved. // -namespace Dgiot_dtu -{ +namespace Dgiot_dtu { using System; using System.Collections.Generic; using System.Configuration; @@ -13,1152 +12,935 @@ namespace Dgiot_dtu using System.Windows.Forms; using System.Drawing.Printing; using System.Runtime.InteropServices; -public partial class MainForm : Form -{ - private delegate void LogHandler(string text); - - private static string clientid = Guid.NewGuid().ToString().Substring(0, 10); - private static string productid = Guid.NewGuid().ToString().Substring(0, 10); - private static string devaddr = Guid.NewGuid().ToString().Substring(0, 10); - private static LogHelper logHelper = LogHelper.GetInstance(); - private static OPCDAHelper oPCDAHelper = OPCDAHelper.GetInstance(); - private static OPCDAViewHelper oPCDAViewHelper = OPCDAViewHelper.GetInstance(); - private static TcpClientHelper tcpClientHelper = TcpClientHelper.GetInstance(); - private static TcpServerHelper tcpServerHelper = TcpServerHelper.GetInstance(); - private static PrinterHelper printerHelper = PrinterHelper.GetInstance(); - private bool bIsRunning = false; - private float x = 0; // 当前窗体的宽度 - private float y = 0; // 当前窗体的高度 - private readonly string[] bridges = new string[] - { - "SerialPort", - "TcpServer", - "BACnet", - "OPCUA", - "MqttClient", - "MqttServer", - "TcpClient", - "TcpServer", - "UdpClient", - "UdpServer", - "PLC", - "Control", - "Access", - "SqlServer", - "Barcode_Printer" - }; - - private Configuration config; - - public MainForm() - { - InitializeComponent(); - config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - ConfigHelper.Init(config); - TreeViewHelper.Init(treeView); - LogHelper.Init(this); - FileHelper.Init(openFileDialog); - SetComboBox(); - - Text += " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version; - - try - { - RestoreConfigs(config); - SaveAppConfig(); - } - catch (Exception ex) - { - Log("read config exception: " + ex.Message); - } +public partial class MainForm : Form { + private delegate void LogHandler(string text); + + private static string clientid = Guid.NewGuid().ToString().Substring(0, 10); + private static string productid = Guid.NewGuid().ToString().Substring(0, 10); + private static string devaddr = Guid.NewGuid().ToString().Substring(0, 10); + private static LogHelper logHelper = LogHelper.GetInstance(); + private static OPCDAHelper oPCDAHelper = OPCDAHelper.GetInstance(); + private static OPCDAViewHelper oPCDAViewHelper = + OPCDAViewHelper.GetInstance(); + private static TcpClientHelper tcpClientHelper = + TcpClientHelper.GetInstance(); + private static TcpServerHelper tcpServerHelper = + TcpServerHelper.GetInstance(); + private static PrinterHelper printerHelper = PrinterHelper.GetInstance(); + private bool bIsRunning = false; + private float x = 0; // 当前窗体的宽度 + private float y = 0; // 当前窗体的高度 + private readonly string[] bridges = new string[] { + "SerialPort", "TcpServer", "BACnet", "OPCUA", "MqttClient", + "MqttServer", "TcpClient", "TcpServer", "UdpClient", "UdpServer", + "PLC", "Control", "Access", "SqlServer", "Barcode_Printer" + }; + + private Configuration config; + + public MainForm() { + InitializeComponent(); + config = + ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + ConfigHelper.Init(config); + TreeViewHelper.Init(treeView); + LogHelper.Init(this); + FileHelper.Init(openFileDialog); + SetComboBox(); + + Text += + " v" + System.Reflection.Assembly.GetEntryAssembly().GetName().Version; + + try { + RestoreConfigs(config); + SaveAppConfig(); + } catch (Exception ex) { + Log("read config exception: " + ex.Message); + } + } + + public void Log(string text) { + if (InvokeRequired) { + Invoke(new LogHandler(Log), new object[] { text }); + return; + } + + // Truncate + if (textBoxLog.Text.Length > 4096) { + textBoxLog.Text = + textBoxLog.Text.Substring(textBoxLog.Text.Length - 4096); + } + + textBoxLog.Text += text + "\r\n"; + textBoxLog.SelectionStart = textBoxLog.Text.Length - 1; + textBoxLog.ScrollToCaret(); + } + + private void ToStop() { + try { + buttonStartStop.Text = @"Start"; + bIsRunning = false; + MqttClientHelper.Stop(); + MqttServerHelper.Stop(); + TcpClientHelper.Stop(); + TcpServerHelper.Stop(); + UDPClientHelper.Stop(); + UDPServerHelper.Stop(); + } catch (Exception e) { + Log("stop server exception:" + e.Message); + return; + } + } + + private void ButtonStartStopClick(object sender, EventArgs e) { + if (!bIsRunning) { + bIsRunning = true; + try { + MqttServerHelper.Start(); + MqttClientHelper.Start(); + TcpClientHelper.Start(); + TcpServerHelper.Start(); + UDPServerHelper.Start(); + UDPClientHelper.Start(); + } catch (Exception error) { + Log("star error " + error.ToString()); + return; + } + + buttonStartStop.Text = @"Stop"; + + DgiotHelper.GetIps(); + SaveAppConfig(); + } else { + ToStop(); + } + } + + private void ButtonScan_Click(object sender, EventArgs e) { + OPCDAHelper.Start(); + BACnetHelper.Start(); + SerialPortHelper.Start(); + } + + private void SetComboBox() { + var arrPorts = SerialPortHelper.GetPorts(); + comboBoxSerialPort.Items.Clear(); + foreach (var port in arrPorts) { + comboBoxSerialPort.Items.Add(port); + } + + if (arrPorts.Length > 0) { + comboBoxSerialPort.SelectedIndex = 0; + } + + comboBoxBaudRate.SelectedIndex = 7; + comboBoxDataBits.SelectedIndex = 0; + comboBoxStopBits.SelectedIndex = 0; + comboBoxParity.SelectedIndex = 0; + comboBoxCmdProdxy.SelectedIndex = 0; + + comboBoxBridge.Items.Clear(); + + foreach (var bridge in bridges) { + comboBoxBridge.Items.Add(bridge); } - public void Log(string text) - { - if (InvokeRequired) - { - Invoke(new LogHandler(Log), new object[] { text }); - return; - } - - // Truncate - if (textBoxLog.Text.Length > 4096) - { - textBoxLog.Text = textBoxLog.Text.Substring(textBoxLog.Text.Length - 4096); - } - - textBoxLog.Text += text + "\r\n"; - textBoxLog.SelectionStart = textBoxLog.Text.Length - 1; - textBoxLog.ScrollToCaret(); + if (bridges.Length > 0) { + comboBoxBridge.SelectedIndex = 0; } - private void ToStop() - { - try - { - buttonStartStop.Text = @"Start"; - bIsRunning = false; - MqttClientHelper.Stop(); - MqttServerHelper.Stop(); - TcpClientHelper.Stop(); - TcpServerHelper.Stop(); - UDPClientHelper.Stop(); - UDPServerHelper.Stop(); - } - catch (Exception e) - { - Log("stop server exception:" + e.Message); - return; - } + comboBoxDtuAddr.Items.Clear(); + List macAddrs = DgiotHelper.GetMacByWmi(); + foreach (var mac in macAddrs) { + devaddr = Regex.Replace(mac, @":", ""); + comboBoxDtuAddr.Items.Add(devaddr); + textBoxTcpClientLogin.Text = devaddr; + textBoxUDPClientLogin.Text = devaddr; } - private void ButtonStartStopClick(object sender, EventArgs e) - { - if (!bIsRunning) - { - bIsRunning = true; - try - { - MqttServerHelper.Start(); - MqttClientHelper.Start(); - TcpClientHelper.Start(); - TcpServerHelper.Start(); - UDPServerHelper.Start(); - UDPClientHelper.Start(); - } - catch (Exception error) - { - Log("star error " + error.ToString()); - return; - } - - buttonStartStop.Text = @"Stop"; - - DgiotHelper.GetIps(); - SaveAppConfig(); - } - else - { - ToStop(); - } - } + comboBoxDtuAddr.SelectedIndex = 0; - private void ButtonScan_Click(object sender, EventArgs e) - { - OPCDAHelper.Start(); - BACnetHelper.Start(); - SerialPortHelper.Start(); + List loglevels = LogHelper.Levels(); + foreach (var level in loglevels) { + comboBoxLogLevel.Items.Add(level); } - private void SetComboBox() - { - var arrPorts = SerialPortHelper.GetPorts(); - comboBoxSerialPort.Items.Clear(); - foreach (var port in arrPorts) - { - comboBoxSerialPort.Items.Add(port); - } - - if (arrPorts.Length > 0) - { - comboBoxSerialPort.SelectedIndex = 0; - } - - comboBoxBaudRate.SelectedIndex = 7; - comboBoxDataBits.SelectedIndex = 0; - comboBoxStopBits.SelectedIndex = 0; - comboBoxParity.SelectedIndex = 0; - comboBoxCmdProdxy.SelectedIndex = 0; - - comboBoxBridge.Items.Clear(); - - foreach (var bridge in bridges) - { - comboBoxBridge.Items.Add(bridge); - } - - if (bridges.Length > 0) - { - comboBoxBridge.SelectedIndex = 0; - } - - comboBoxDtuAddr.Items.Clear(); - List macAddrs = DgiotHelper.GetMacByWmi(); - foreach (var mac in macAddrs) - { - devaddr = Regex.Replace(mac, @":", ""); - comboBoxDtuAddr.Items.Add(devaddr); - textBoxTcpClientLogin.Text = devaddr; - textBoxUDPClientLogin.Text = devaddr; - } - - comboBoxDtuAddr.SelectedIndex = 0; - - List loglevels = LogHelper.Levels(); - foreach (var level in loglevels) - { - comboBoxLogLevel.Items.Add(level); - } - - if (loglevels.Count > 0) - { - comboBoxLogLevel.SelectedIndex = (int)LogHelper.Level.DEBUG; - } - - comboBoxLan.Items.Add("简体中文"); - comboBoxLan.Items.Add("English"); - comboBoxLan.SelectedIndex = 0; + if (loglevels.Count > 0) { + comboBoxLogLevel.SelectedIndex = (int)LogHelper.Level.DEBUG; } - private void RestoreConfigs(Configuration config) - { - RestoreMqtt(); - RestoreTcp(); - RestoreUDP(); - RestoreCommonConfig(); - RestoreSerialPort(); - RestorePLC(); - RestoreOPCDA(); - RestoreOPCUA(); - RestoreBACnet(); - RestoreControl(); - RestoreAccess(); - Resh_Topic(); - Resh_Config(); - } + comboBoxLan.Items.Add("简体中文"); + comboBoxLan.Items.Add("English"); + comboBoxLan.SelectedIndex = 0; + } - private void RestoreCommonConfig() - { - if (ConfigHelper.Check("DtuAddr")) - { - var tmp = ConfigHelper.GetConfig("DtuAddr"); - comboBoxDtuAddr.SelectedIndex = comboBoxDtuAddr.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); - } + private void RestoreConfigs(Configuration config) { + RestoreMqtt(); + RestoreTcp(); + RestoreUDP(); + RestoreCommonConfig(); + RestoreSerialPort(); + RestorePLC(); + RestoreOPCDA(); + RestoreOPCUA(); + RestoreBACnet(); + RestoreControl(); + RestoreAccess(); + Resh_Topic(); + Resh_Config(); + } - if (ConfigHelper.Check("DgiotSever")) - { - textBoxDgiotSever.Text = ConfigHelper.GetConfig("DgiotSever"); - } - else - { - ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); - } - - if (ConfigHelper.Check("DgiotPort")) - { - textBoxDgiotPort.Text = ConfigHelper.GetConfig("DgiotPort"); - } - else - { - ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); - } - - if (ConfigHelper.Check("BridgePort")) - { - textBoxBridgePort.Text = ConfigHelper.GetConfig("BridgePort"); - } - else - { - ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); - } - - if (ConfigHelper.Check("ReconnectChecked")) - { - checkBoxReconnect.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); - } - else - { - ConfigHelper.SetConfig("ReconnectChecked", DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); - } - - if (ConfigHelper.Check("LogLevel")) - { - var tmp = ConfigHelper.GetConfig("LogLevel"); - comboBoxLogLevel.SelectedIndex = comboBoxLogLevel.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); - } - - if (ConfigHelper.Check("ToPayload")) - { - textToPayload.Text = ConfigHelper.GetConfig("ToPayload"); - } - else - { - ConfigHelper.SetConfig("ToPayload", textToPayload.Text); - } - - if (ConfigHelper.Check("DisplayHex")) - { - checkBoxDisplayHex.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("DisplayHex")); - } - else - { - ConfigHelper.SetConfig("DisplayHex", DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); - } - - if (ConfigHelper.Check("Bridge_Checked")) - { - checkBoxBridge.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("Bridge_Checked")); - } - else - { - ConfigHelper.SetConfig("Bridge_Checked", DgiotHelper.BoolTostr(checkBoxBridge.Checked)); - } + private void RestoreCommonConfig() { + if (ConfigHelper.Check("DtuAddr")) { + var tmp = ConfigHelper.GetConfig("DtuAddr"); + comboBoxDtuAddr.SelectedIndex = comboBoxDtuAddr.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); } - private void RestoreMqtt() - { - if (ConfigHelper.Check("MqttUserName")) - { - textBoxMqttUserName.Text = ConfigHelper.GetConfig("MqttUserName"); - } - else - { - ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); - } - - if (ConfigHelper.Check("MqttPassword")) - { - textBoxMqttPassword.Text = ConfigHelper.GetConfig("MqttPassword"); - } - else - { - ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); - } - - if (ConfigHelper.Check("MqttClientId")) - { - textBoxMqttClientId.Text = ConfigHelper.GetConfig("MqttClientId"); - } - else - { - ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); - } - - if (ConfigHelper.Check("MqttPubTopic")) - { - textBoxMqttPubTopic.Text = ConfigHelper.GetConfig("MqttPubTopic"); - } - else - { - ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); - } - - if (ConfigHelper.Check("MqttSubTopic")) - { - textBoxMqttSubTopic.Text = ConfigHelper.GetConfig("MqttSubTopic"); - } - else - { - ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); - } - - if (ConfigHelper.Check("CmdProdxy")) - { - var tmp = ConfigHelper.GetConfig("CmdProdxy"); - comboBoxCmdProdxy.SelectedIndex = comboBoxCmdProdxy.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); - } - - if (ConfigHelper.Check("MqttClient_Checked")) - { - radioButtonMqttClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); - } - else - { - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); - } - } - - private void RestoreTcp() - { - if (ConfigHelper.Check("TcpClientLogin")) - { - textBoxTcpClientLogin.Text = ConfigHelper.GetConfig("TcpClientLogin"); - } - else - { - ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); - } - - if (ConfigHelper.Check("TcpClient_Checked")) - { - radioButtonTcpClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("TcpClient_Checked")); - } - else - { - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); - } + if (ConfigHelper.Check("DgiotSever")) { + textBoxDgiotSever.Text = ConfigHelper.GetConfig("DgiotSever"); + } else { + ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); } - private void RestoreUDP() - { - if (ConfigHelper.Check("UDPClientLogin")) - { - textBoxUDPClientLogin.Text = ConfigHelper.GetConfig("UDPClientLogin"); - } - else - { - ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); - } - - if (ConfigHelper.Check("UDPClient_Checked")) - { - radioButtonUDPClient.Checked = DgiotHelper.StrTobool(ConfigHelper.GetConfig("UDPClient_Checked")); - } - else - { - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(radioButtonUDPClient.Checked)); - } + if (ConfigHelper.Check("DgiotPort")) { + textBoxDgiotPort.Text = ConfigHelper.GetConfig("DgiotPort"); + } else { + ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); } - private void RestoreSerialPort() - { - if (ConfigHelper.Check("SerialPort")) - { - var tmp = ConfigHelper.GetConfig("SerialPort"); - comboBoxSerialPort.SelectedIndex = comboBoxSerialPort.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); - } - - if (ConfigHelper.Check("BaudRate")) - { - var tmp = ConfigHelper.GetConfig("BaudRate"); - comboBoxBaudRate.SelectedIndex = comboBoxBaudRate.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); - } - - if (ConfigHelper.Check("DataBits")) - { - var tmp = ConfigHelper.GetConfig("DataBits"); - comboBoxDataBits.SelectedIndex = comboBoxDataBits.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); - } - - if (ConfigHelper.Check("Parity")) - { - var tmp = ConfigHelper.GetConfig("Parity"); - comboBoxParity.SelectedIndex = comboBoxParity.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("Parity", comboBoxParity.Text); - } - - if (ConfigHelper.Check("StopBits")) - { - var tmp = ConfigHelper.GetConfig("StopBits"); - comboBoxStopBits.SelectedIndex = comboBoxStopBits.Items.IndexOf(tmp); - } - else - { - ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); - } + if (ConfigHelper.Check("BridgePort")) { + textBoxBridgePort.Text = ConfigHelper.GetConfig("BridgePort"); + } else { + ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); } - private void RestorePLC() - { - if (ConfigHelper.Check("PLCTopic")) - { - textBoxPLCTopic.Text = ConfigHelper.GetConfig("PLCTopic"); - } - else - { - ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); - } + if (ConfigHelper.Check("ReconnectChecked")) { + checkBoxReconnect.Checked = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); + } else { + ConfigHelper.SetConfig("ReconnectChecked", + DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); } - private void RestoreOPCDA() - { - if (ConfigHelper.Check("OPCDAHost")) - { - textBoxOPCDAHost.Text = ConfigHelper.GetConfig("OPCDAHost"); - } - else - { - ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); - } - - if (ConfigHelper.Check("OPCDAInterval")) - { - textBoxOPCDAInterval.Text = ConfigHelper.GetConfig("OPCDAInterval"); - } - else - { - ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); - } - - if (ConfigHelper.Check("OPCDACount")) - { - textBoxOPCDACount.Text = ConfigHelper.GetConfig("OPCDACount"); - } - else - { - ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); - } - - if (ConfigHelper.Check("OPCDACheck")) - { - checkBoxOPCDA.Text = ConfigHelper.GetConfig("OPCDACheck"); - } - else - { - ConfigHelper.SetConfig("OPCDACheck", checkBoxOPCDA.Text); - } + if (ConfigHelper.Check("LogLevel")) { + var tmp = ConfigHelper.GetConfig("LogLevel"); + comboBoxLogLevel.SelectedIndex = comboBoxLogLevel.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); } - private void RestoreOPCUA() - { - if (ConfigHelper.Check("OPCUATopic")) - { - textBoxOPCUATopic.Text = ConfigHelper.GetConfig("OPCUATopic"); - } - else - { - ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); - } + if (ConfigHelper.Check("ToPayload")) { + textToPayload.Text = ConfigHelper.GetConfig("ToPayload"); + } else { + ConfigHelper.SetConfig("ToPayload", textToPayload.Text); } - private void RestoreBACnet() - { - if (ConfigHelper.Check("BACnetTopic")) - { - textBoxBACnetTopic.Text = ConfigHelper.GetConfig("BACnetTopic"); - } - else - { - ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); - } + if (ConfigHelper.Check("DisplayHex")) { + checkBoxDisplayHex.Checked = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("DisplayHex")); + } else { + ConfigHelper.SetConfig("DisplayHex", + DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); } - private void RestoreControl() - { - if (ConfigHelper.Check("ControlTopic")) - { - textBoxControlTopic.Text = ConfigHelper.GetConfig("ControlTopic"); - } - else - { - ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); - } + if (ConfigHelper.Check("Bridge_Checked")) { + checkBoxBridge.Checked = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("Bridge_Checked")); + } else { + ConfigHelper.SetConfig("Bridge_Checked", + DgiotHelper.BoolTostr(checkBoxBridge.Checked)); } + } - private void RestoreAccess() - { - if (ConfigHelper.Check("AccessTopic")) - { - textBoxAccessTopic.Text = ConfigHelper.GetConfig("AccessTopic"); - } - else - { - ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); - } + private void RestoreMqtt() { + if (ConfigHelper.Check("MqttUserName")) { + textBoxMqttUserName.Text = ConfigHelper.GetConfig("MqttUserName"); + } else { + ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); } - private void Resh_Config() - { - MqttClientHelper.Config(); - MqttServerHelper.Config(); - TcpClientHelper.Config(); - TcpServerHelper.Config(); - UDPClientHelper.Config(); - UDPServerHelper.Config(); - - SerialPortHelper.Config(); - PLCHelper.Config(config.AppSettings.Settings); - OPCDAHelper.Config(); - OPCUAHelper.Config(config.AppSettings.Settings); - AccessHelper.Config(config.AppSettings.Settings); - SqlServerHelper.Config(config.AppSettings.Settings); + if (ConfigHelper.Check("MqttPassword")) { + textBoxMqttPassword.Text = ConfigHelper.GetConfig("MqttPassword"); + } else { + ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); } - private void Resh_Topic() - { - devaddr = comboBoxDtuAddr.Text; - productid = textBoxMqttUserName.Text; - // clientid = DgiotHelper.Md5("Device" + this.textBoxMqttUserName.Text + devaddr).Substring(0, 10); - clientid = comboBoxDtuAddr.Text; - textBoxMqttClientId.Text = clientid; - textBoxMqttSubTopic.Text = "$dg/device/" + productid + "/" + devaddr + "/#"; - textBoxMqttPubTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - - textBoxAccessTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxOPCUATopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxPLCTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxBACnetTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; - textBoxControlTopic.Text = "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + if (ConfigHelper.Check("MqttClientId")) { + textBoxMqttClientId.Text = ConfigHelper.GetConfig("MqttClientId"); + } else { + ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); } - private void LinkLabel1LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Process.Start("https://github.com/dgiot/dgiot_dtu"); + if (ConfigHelper.Check("MqttPubTopic")) { + textBoxMqttPubTopic.Text = ConfigHelper.GetConfig("MqttPubTopic"); + } else { + ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); } - private void ButtonClearClick(object sender, EventArgs e) - { - textBoxLog.Text = ""; + if (ConfigHelper.Check("MqttSubTopic")) { + textBoxMqttSubTopic.Text = ConfigHelper.GetConfig("MqttSubTopic"); + } else { + ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); } - private void LinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Process.Start("https://github.com/dgiot/dgiot_dtu"); + if (ConfigHelper.Check("CmdProdxy")) { + var tmp = ConfigHelper.GetConfig("CmdProdxy"); + comboBoxCmdProdxy.SelectedIndex = comboBoxCmdProdxy.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); } - private void SaveAppConfig() - { - config.Save(ConfigurationSaveMode.Full); - ConfigurationManager.RefreshSection("appSettings"); + if (ConfigHelper.Check("MqttClient_Checked")) { + radioButtonMqttClient.Checked = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); + } else { + ConfigHelper.SetConfig( + "MqttClient_Checked", + DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); } + } - private void CheckBoxReconnectCheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("ReconnectChecked", DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); + private void RestoreTcp() { + if (ConfigHelper.Check("TcpClientLogin")) { + textBoxTcpClientLogin.Text = ConfigHelper.GetConfig("TcpClientLogin"); + } else { + ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); } - private void CheckBoxDisplayHexCheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DisplayHex", DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); - LogHelper.Config(); + if (ConfigHelper.Check("TcpClient_Checked")) { + radioButtonTcpClient.Checked = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("TcpClient_Checked")); + } else { + ConfigHelper.SetConfig( + "TcpClient_Checked", + DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); } + } - private void RadioButtonMqttClient_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); + private void RestoreUDP() { + if (ConfigHelper.Check("UDPClientLogin")) { + textBoxUDPClientLogin.Text = ConfigHelper.GetConfig("UDPClientLogin"); + } else { + ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); } - private void RadioButtonTcpClient_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); + if (ConfigHelper.Check("UDPClient_Checked")) { + radioButtonUDPClient.Checked = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("UDPClient_Checked")); + } else { + ConfigHelper.SetConfig( + "UDPClient_Checked", + DgiotHelper.BoolTostr(radioButtonUDPClient.Checked)); } + } - private void RadioButtonUDPClient_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); - ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); - ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); + private void RestoreSerialPort() { + if (ConfigHelper.Check("SerialPort")) { + var tmp = ConfigHelper.GetConfig("SerialPort"); + comboBoxSerialPort.SelectedIndex = comboBoxSerialPort.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); } - private void TextToPayload_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("ToPayload", textToPayload.Text); + if (ConfigHelper.Check("BaudRate")) { + var tmp = ConfigHelper.GetConfig("BaudRate"); + comboBoxBaudRate.SelectedIndex = comboBoxBaudRate.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); } - private void TextBoxMqttClientId_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); - Resh_Topic(); + if (ConfigHelper.Check("DataBits")) { + var tmp = ConfigHelper.GetConfig("DataBits"); + comboBoxDataBits.SelectedIndex = comboBoxDataBits.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); } - private void TextBoxMqttUserName_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); - Resh_Topic(); + if (ConfigHelper.Check("Parity")) { + var tmp = ConfigHelper.GetConfig("Parity"); + comboBoxParity.SelectedIndex = comboBoxParity.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("Parity", comboBoxParity.Text); } - private void TextBoxMqttPassword_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); - } - - private void TextBoxMqttSubTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); - Resh_Topic(); - } - - private void TextBoxMqttPubTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); - Resh_Topic(); - } - - private void TextBoxMqttServerPort_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("MqttServerPort", textBoxTcpClientLogin.Text); - } - - private void TextBoxTcpClientLogin_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); - } - - private void TextBoxUDPClientLogin_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); - } - - private void ComboBoxCmdProdxy_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); - } - - private void ComboBoxSerialPort_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); - } - - private void ComboBoxBaudRate_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); - } - - private void ComboBoxStopBits_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); - } - - private void ComboBoxParity_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("Parity", comboBoxParity.Text); - } - - private void ComboBoxDataBits_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); - } - - private void TextBoxPLCTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); - } - - private void CheckBoxOPCDA_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("OPCDACheck", DgiotHelper.BoolTostr(checkBoxOPCDA.Checked)); - OPCDAHelper.StartMonitor(); - } - - private void TextBoxOPCDAInterval_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); - } - - private void TextBoxOPCDAHost_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); - } - - private void TextBoxOPCDACount_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); - } - - private void TextBoxOPCUATopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); - Resh_Topic(); - } - - private void TextBoxBACnetTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); - Resh_Topic(); - } - - private void TextBoxControlTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); - Resh_Topic(); - } - - private void TextBoxAccessTopic_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); - Resh_Topic(); - } - - private void ComboBoxLogLevel_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); - LogHelper.SetLevel(comboBoxLogLevel.SelectedIndex); - } - - private void ComboBoxBridge_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("Bridge", comboBoxBridge.Text); - } - - private void TextBoxDgiotSever_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); - } - - private void TextBoxDgiotPort_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); - } - - private void TextBoxBridgePort_TextChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); - } - - private void ComboBoxDtuAddr_SelectedIndexChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); - } - - private void CheckBoxBridge_CheckedChanged(object sender, EventArgs e) - { - ConfigHelper.SetConfig("Bridge_Checked", DgiotHelper.BoolTostr(checkBoxBridge.Checked)); - } - - private void SendBridge_Click(object sender, EventArgs e) - { - - byte[] payload = LogHelper.Payload(textToPayload.Text.ToCharArray()); - LogHelper.Log(bridges[comboBoxBridge.SelectedIndex] + " send [" + LogHelper.Logdata(payload, 0, payload.Length) + "]"); - // PrinterHelper.SetTextData(textToPayload.Text); - PrinterHelper.PrintPage(textToPayload.Text); - if (bridges[comboBoxBridge.SelectedIndex] == "SerialPort") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "TcpServer") - { - TcpServerHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "Barcode_Printer") - { - TcpServerHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "PLC") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "OPCUA") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "BACnet") - { - BACnetHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "Control") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "Access") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "SqlServer") - { - } - else if (bridges[comboBoxBridge.SelectedIndex] == "MqttClient") - { - MqttClientHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "MqttServer") - { - MqttServerHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "TcpClient") - { - TcpClientHelper.Write(payload, 0, payload.Length); - } - else if (bridges[comboBoxBridge.SelectedIndex] == "UdpClient") - { - } - else - { - } - } - - private void ComboBoxLan_SelectedIndexChanged(object sender, EventArgs e) - { - Language(comboBoxLan.SelectedItem.ToString()); - } - - private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) - { - TreeViewHelper.TreeView_AfterSelect(e.Action, e.Node); - } - - private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) - { - TreeViewHelper.TreeView_AfterCheck(e.Action, e.Node); - } - - private void NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) - { - TreeViewHelper.NodeMouseDoubleClick(e.Button, e.Node); - } - - private void AfterLabelEdit(object sender, NodeLabelEditEventArgs e) - { - if (e.Label != null) - { - if (e.Label.Length > 0) - { - if (TreeViewHelper.CheckLabelEdit(e.Label, e.Node)) - { - // Stop editing without canceling the label change. - e.Node.EndEdit(false); - } - else - { - /* Cancel the label edit action, inform the user, and - place the node in edit mode again. */ - e.CancelEdit = true; - e.Node.BeginEdit(); - } - } - else - { - /* Cancel the label edit action, inform the user, and - place the node in edit mode again. */ - e.CancelEdit = true; - e.Node.BeginEdit(); - } - } - } - - private void Language(string lan) - { - if (lan == "English") - { - En(); - } - else - { - Zh(); - } - } - - private void Zh() - { - sendBridge.Text = "发送"; - buttonClear.Text = "清除"; - buttonStartStop.Text = "连接"; - buttonScan.Text = "扫描"; - - checkBoxReconnect.Text = "自动重连"; - label33.Text = "语言"; - label32.Text = "日志级别"; - - label7.Text = "发至"; - label2.Text = "发至"; - labelopcua.Text = "发至"; - label23.Text = "发至"; - label8.Text = "发至"; - label6.Text = "发至"; - - groupBoxSerialPort.Text = "串口扫描"; - groupBox12.Text = "PLC扫描"; - groupBox4.Text = "OPC_DA扫描"; - labelOPCDAHost.Text = "主机"; - checkBoxOPCDA.Text = "主动上报"; - labelOPCDAMonitor.Text = "采集间隔"; - labelSecond.Text = "秒"; - labelOPCDACount.Text = "采集次数"; - groupBox5.Text = "OPC_UA扫描"; - groupBox6.Text = "BACnet扫描"; - groupBox7.Text = "窗体扫描"; - groupBox8.Text = "Access扫描"; - - labelSerialPort.Text = "端口"; - label1.Text = "波特率"; - label4.Text = "数据位"; - label13.Text = "校验位"; - label5.Text = "停止位"; - - groupBox3.Text = "Mqtt 客户端通道"; - label22.Text = "服务器地址"; - label21.Text = "服务器端口"; - label9.Text = "登录用户"; - label10.Text = "登录密码"; - label30.Text = "网关地址"; - label20.Text = "客户编号"; - label11.Text = "订阅主题"; - label12.Text = "发布主题"; - label29.Text = "命令代理"; - - groupBox2.Text = "TCP 客户端通道"; - label16.Text = "登录报文"; - - groupBox10.Text = "UDP 客户端通道"; - label15.Text = "登录报文"; - - label_devcietree.Text = "设备树"; - checkBoxBridge.Text = "桥接端口"; - groupBoxCommonConfig.Text = "公共配置"; - } - - private void En() - { - sendBridge.Text = "Send"; - buttonClear.Text = "Clear"; - buttonStartStop.Text = "Start"; - buttonScan.Text = "Scan"; - label32.Text = "Level"; - - checkBoxReconnect.Text = "Auto Reconnect"; - label33.Text = "Language"; - - label7.Text = "To"; - label2.Text = "To"; - labelopcua.Text = "To"; - label23.Text = "To"; - label8.Text = "To"; - label6.Text = "To"; - groupBoxSerialPort.Text = "Serial Port Capture"; - groupBox12.Text = "PLC Capture"; - groupBox4.Text = "OPC_DA Capture"; - labelOPCDAHost.Text = "Host"; - checkBoxOPCDA.Text = "Monitor"; - labelOPCDAMonitor.Text = "Interval"; - labelSecond.Text = "Second"; - labelOPCDACount.Text = "Count"; - - groupBox5.Text = "OPC_UA Capture"; - groupBox6.Text = "BACnet Capture"; - groupBox7.Text = "Control Capture"; - groupBox8.Text = "Access Capture"; - - labelSerialPort.Text = "Port"; - label1.Text = "Baud Rate"; - label4.Text = "dataBits"; - label13.Text = "Parity"; - label5.Text = "stopBits"; - labelOPCDAHost.Text = "Host"; - - groupBox3.Text = "Mqtt Client Channel"; - label22.Text = "Server"; - label21.Text = "Port"; - label9.Text = "UserName"; - label10.Text = "PassWord"; - label30.Text = "DtuAddr"; - label20.Text = "Clientid"; - label11.Text = "SubTopic"; - label12.Text = "PubTopic"; - label29.Text = "cmd proxy"; - - groupBox2.Text = "TCP Client Channel"; - label16.Text = "login"; - - groupBox10.Text = "UDP Client Channel"; - label15.Text = "login"; - - label_devcietree.Text = "DeviceTree"; - checkBoxBridge.Text = "Bridge Port"; - groupBoxCommonConfig.Text = "Common Config"; - } - - private void MainForm_Load(object sender, EventArgs e) - { - x = Width; // 获取窗体的宽度 - y = Height; // 获取窗体的高度 - SetTag(this); // 调用方法 - } - - private void MainForm_Resize(object sender, EventArgs e) - { - if (x == 0) - { - x = Width; - } - - if (y == 0) - { - y = Height; - } - - float newx = this.Width / x; // 窗体宽度缩放比例 - float newy = this.Height / y; // 窗体高度缩放比例 - SetControls(newx, newy, this); // 随窗体改变控件大小 - } - - /// - /// 将控件的宽,高,左边距,顶边距和字体大小暂存到tag属性中 - /// - /// 递归控件中的控件 - private void SetTag(Control cons) - { - foreach (Control con in cons.Controls) - { - if (con == null) - { - continue; - } - - con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + ":" + con.Font.Size; - if (con.Controls.Count > 0) - { - SetTag(con); - } - } - } - - // 根据窗体大小调整控件大小 - private void SetControls(float newx, float newy, Control cons) - { - // 遍历窗体中的控件,重新设置控件的值 - foreach (Control con in cons.Controls) - { - if (con.Tag != null && con.Tag != "") - { - string[] mytag = con.Tag.ToString().Split(new char[] { ':' }); // 获取控件的Tag属性值,并分割后存储字符串数组 - float a = Convert.ToSingle(mytag[0]) * newx; // 根据窗体缩放比例确定控件的值,宽度 - con.Width = (int)a; // 宽度 - a = Convert.ToSingle(mytag[1]) * newy; // 高度 - con.Height = (int)a; - a = Convert.ToSingle(mytag[2]) * newx; // 左边距离 - con.Left = (int)a; - a = Convert.ToSingle(mytag[3]) * newy; // 上边缘距离 - con.Top = (int)a; - float currentSize = Convert.ToSingle(mytag[4]) * newy; // 字体大小 - con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); - } - - if (con.Controls.Count > 0) - { - SetControls(newx, newy, con); - } - } - } - - private void openFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e) - { - - } - - private void textBoxLog_TextChanged(object sender, EventArgs e) - { - - } - - private void groupBox5_Enter(object sender, EventArgs e) - { - - } - - private void groupBox6_Enter(object sender, EventArgs e) - { - - } - - private void groupBox8_Enter(object sender, EventArgs e) - { - - } + if (ConfigHelper.Check("StopBits")) { + var tmp = ConfigHelper.GetConfig("StopBits"); + comboBoxStopBits.SelectedIndex = comboBoxStopBits.Items.IndexOf(tmp); + } else { + ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); + } + } + + private void RestorePLC() { + if (ConfigHelper.Check("PLCTopic")) { + textBoxPLCTopic.Text = ConfigHelper.GetConfig("PLCTopic"); + } else { + ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); + } + } + + private void RestoreOPCDA() { + if (ConfigHelper.Check("OPCDAHost")) { + textBoxOPCDAHost.Text = ConfigHelper.GetConfig("OPCDAHost"); + } else { + ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); + } + + if (ConfigHelper.Check("OPCDAInterval")) { + textBoxOPCDAInterval.Text = ConfigHelper.GetConfig("OPCDAInterval"); + } else { + ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); + } + + if (ConfigHelper.Check("OPCDACount")) { + textBoxOPCDACount.Text = ConfigHelper.GetConfig("OPCDACount"); + } else { + ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); + } + + if (ConfigHelper.Check("OPCDACheck")) { + checkBoxOPCDA.Text = ConfigHelper.GetConfig("OPCDACheck"); + } else { + ConfigHelper.SetConfig("OPCDACheck", checkBoxOPCDA.Text); + } + } + + private void RestoreOPCUA() { + if (ConfigHelper.Check("OPCUATopic")) { + textBoxOPCUATopic.Text = ConfigHelper.GetConfig("OPCUATopic"); + } else { + ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); + } + } + + private void RestoreBACnet() { + if (ConfigHelper.Check("BACnetTopic")) { + textBoxBACnetTopic.Text = ConfigHelper.GetConfig("BACnetTopic"); + } else { + ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); + } + } + + private void RestoreControl() { + if (ConfigHelper.Check("ControlTopic")) { + textBoxControlTopic.Text = ConfigHelper.GetConfig("ControlTopic"); + } else { + ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); + } + } + + private void RestoreAccess() { + if (ConfigHelper.Check("AccessTopic")) { + textBoxAccessTopic.Text = ConfigHelper.GetConfig("AccessTopic"); + } else { + ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); + } + } + + private void Resh_Config() { + MqttClientHelper.Config(); + MqttServerHelper.Config(); + TcpClientHelper.Config(); + TcpServerHelper.Config(); + UDPClientHelper.Config(); + UDPServerHelper.Config(); + + SerialPortHelper.Config(); + PLCHelper.Config(config.AppSettings.Settings); + OPCDAHelper.Config(); + OPCUAHelper.Config(config.AppSettings.Settings); + AccessHelper.Config(config.AppSettings.Settings); + SqlServerHelper.Config(config.AppSettings.Settings); + } + + private void Resh_Topic() { + devaddr = comboBoxDtuAddr.Text; + productid = textBoxMqttUserName.Text; + // clientid = DgiotHelper.Md5("Device" + this.textBoxMqttUserName.Text + + // devaddr).Substring(0, 10); + clientid = comboBoxDtuAddr.Text; + textBoxMqttClientId.Text = clientid; + textBoxMqttSubTopic.Text = "$dg/device/" + productid + "/" + devaddr + "/#"; + textBoxMqttPubTopic.Text = + "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + + textBoxAccessTopic.Text = + "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxOPCUATopic.Text = + "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxPLCTopic.Text = + "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxBACnetTopic.Text = + "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + textBoxControlTopic.Text = + "$dg/thing/" + productid + "/" + devaddr + "/properties/report"; + } + + private void LinkLabel1LinkClicked(object sender, + LinkLabelLinkClickedEventArgs e) { + Process.Start("https://github.com/dgiot/dgiot_dtu"); + } + + private void ButtonClearClick(object sender, EventArgs e) { + textBoxLog.Text = ""; + } + + private void LinkLabel2_LinkClicked(object sender, + LinkLabelLinkClickedEventArgs e) { + Process.Start("https://github.com/dgiot/dgiot_dtu"); + } + + private void SaveAppConfig() { + config.Save(ConfigurationSaveMode.Full); + ConfigurationManager.RefreshSection("appSettings"); + } + + private void CheckBoxReconnectCheckedChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("ReconnectChecked", + DgiotHelper.BoolTostr(checkBoxReconnect.Checked)); + } + + private void CheckBoxDisplayHexCheckedChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("DisplayHex", + DgiotHelper.BoolTostr(checkBoxDisplayHex.Checked)); + LogHelper.Config(); + } + + private void RadioButtonMqttClient_CheckedChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig( + "MqttClient_Checked", + DgiotHelper.BoolTostr(radioButtonMqttClient.Checked)); + ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); + ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); + } + + private void RadioButtonTcpClient_CheckedChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("TcpClient_Checked", + DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); + ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); + ConfigHelper.SetConfig("UDPClient_Checked", DgiotHelper.BoolTostr(false)); + } + + private void RadioButtonUDPClient_CheckedChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("UDPClient_Checked", + DgiotHelper.BoolTostr(radioButtonTcpClient.Checked)); + ConfigHelper.SetConfig("TcpClient_Checked", DgiotHelper.BoolTostr(false)); + ConfigHelper.SetConfig("MqttClient_Checked", DgiotHelper.BoolTostr(false)); + } + + private void TextToPayload_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("ToPayload", textToPayload.Text); + } + + private void TextBoxMqttClientId_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("MqttClientId", comboBoxDtuAddr.Text); + Resh_Topic(); + } + + private void TextBoxMqttUserName_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("MqttUserName", textBoxMqttUserName.Text); + Resh_Topic(); + } + + private void TextBoxMqttPassword_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("MqttPassword", textBoxMqttPassword.Text); + } + + private void TextBoxMqttSubTopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("MqttSubTopic", textBoxMqttSubTopic.Text); + Resh_Topic(); + } + + private void TextBoxMqttPubTopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("MqttPubTopic", textBoxMqttPubTopic.Text); + Resh_Topic(); + } + + private void TextBoxMqttServerPort_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("MqttServerPort", textBoxTcpClientLogin.Text); + } + + private void TextBoxTcpClientLogin_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("TcpClientLogin", textBoxTcpClientLogin.Text); + } + + private void TextBoxUDPClientLogin_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("UDPClientLogin", textBoxUDPClientLogin.Text); + } + + private void ComboBoxCmdProdxy_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("CmdProdxy", comboBoxCmdProdxy.Text); + } + + private void ComboBoxSerialPort_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("SerialPort", comboBoxSerialPort.Text); + } + + private void ComboBoxBaudRate_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("BaudRate", comboBoxBaudRate.Text); + } + + private void ComboBoxStopBits_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("StopBits", comboBoxStopBits.Text); + } + + private void ComboBoxParity_SelectedIndexChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("Parity", comboBoxParity.Text); + } + + private void ComboBoxDataBits_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("DataBits", comboBoxDataBits.Text); + } + + private void TextBoxPLCTopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("PLCTopic", textBoxPLCTopic.Text); + } + + private void CheckBoxOPCDA_CheckedChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("OPCDACheck", + DgiotHelper.BoolTostr(checkBoxOPCDA.Checked)); + OPCDAHelper.StartMonitor(); + } + + private void TextBoxOPCDAInterval_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("OPCDAInterval", textBoxOPCDAInterval.Text); + } + + private void TextBoxOPCDAHost_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("OPCDAHost", textBoxOPCDAHost.Text); + } + + private void TextBoxOPCDACount_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("OPCDACount", textBoxOPCDACount.Text); + } + + private void TextBoxOPCUATopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("OPCUATopic", textBoxOPCUATopic.Text); + Resh_Topic(); + } + + private void TextBoxBACnetTopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("BACnetTopic", textBoxBACnetTopic.Text); + Resh_Topic(); + } + + private void TextBoxControlTopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("ControlTopic", textBoxControlTopic.Text); + Resh_Topic(); + } + + private void TextBoxAccessTopic_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("AccessTopic", textBoxAccessTopic.Text); + Resh_Topic(); + } + + private void ComboBoxLogLevel_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("LogLevel", comboBoxLogLevel.Text); + LogHelper.SetLevel(comboBoxLogLevel.SelectedIndex); + } + + private void ComboBoxBridge_SelectedIndexChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("Bridge", comboBoxBridge.Text); + } + + private void TextBoxDgiotSever_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("DgiotSever", textBoxDgiotSever.Text); + } + + private void TextBoxDgiotPort_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("DgiotPort", textBoxDgiotPort.Text); + } + + private void TextBoxBridgePort_TextChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("BridgePort", textBoxBridgePort.Text); + } + + private void ComboBoxDtuAddr_SelectedIndexChanged(object sender, + EventArgs e) { + ConfigHelper.SetConfig("DtuAddr", comboBoxDtuAddr.Text); + } + + private void CheckBoxBridge_CheckedChanged(object sender, EventArgs e) { + ConfigHelper.SetConfig("Bridge_Checked", + DgiotHelper.BoolTostr(checkBoxBridge.Checked)); + } + + private void SendBridge_Click(object sender, EventArgs e) { + + byte[] payload = LogHelper.Payload(textToPayload.Text.ToCharArray()); + LogHelper.Log(bridges[comboBoxBridge.SelectedIndex] + " send [" + + LogHelper.Logdata(payload, 0, payload.Length) + "]"); + // PrinterHelper.SetTextData(textToPayload.Text); + PrinterHelper.PrintPage(textToPayload.Text); + if (bridges[comboBoxBridge.SelectedIndex] == "SerialPort") { + } else if (bridges[comboBoxBridge.SelectedIndex] == "TcpServer") { + TcpServerHelper.Write(payload, 0, payload.Length); + } else if (bridges[comboBoxBridge.SelectedIndex] == "Barcode_Printer") { + TcpServerHelper.Write(payload, 0, payload.Length); + } else if (bridges[comboBoxBridge.SelectedIndex] == "PLC") { + } else if (bridges[comboBoxBridge.SelectedIndex] == "OPCUA") { + } else if (bridges[comboBoxBridge.SelectedIndex] == "BACnet") { + BACnetHelper.Write(payload, 0, payload.Length); + } else if (bridges[comboBoxBridge.SelectedIndex] == "Control") { + } else if (bridges[comboBoxBridge.SelectedIndex] == "Access") { + } else if (bridges[comboBoxBridge.SelectedIndex] == "SqlServer") { + } else if (bridges[comboBoxBridge.SelectedIndex] == "MqttClient") { + MqttClientHelper.Write(payload, 0, payload.Length); + } else if (bridges[comboBoxBridge.SelectedIndex] == "MqttServer") { + MqttServerHelper.Write(payload, 0, payload.Length); + } else if (bridges[comboBoxBridge.SelectedIndex] == "TcpClient") { + TcpClientHelper.Write(payload, 0, payload.Length); + } else if (bridges[comboBoxBridge.SelectedIndex] == "UdpClient") { + } else { + } + } + + private void ComboBoxLan_SelectedIndexChanged(object sender, EventArgs e) { + Language(comboBoxLan.SelectedItem.ToString()); + } + + private void TreeView_AfterSelect(object sender, TreeViewEventArgs e) { + TreeViewHelper.TreeView_AfterSelect(e.Action, e.Node); + } + + private void TreeView_AfterCheck(object sender, TreeViewEventArgs e) { + TreeViewHelper.TreeView_AfterCheck(e.Action, e.Node); + } + + private void NodeMouseDoubleClick(object sender, + TreeNodeMouseClickEventArgs e) { + TreeViewHelper.NodeMouseDoubleClick(e.Button, e.Node); + } + + private void AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { + if (e.Label != null) { + if (e.Label.Length > 0) { + if (TreeViewHelper.CheckLabelEdit(e.Label, e.Node)) { + // Stop editing without canceling the label change. + e.Node.EndEdit(false); + } else { + /* Cancel the label edit action, inform the user, and + place the node in edit mode again. */ + e.CancelEdit = true; + e.Node.BeginEdit(); + } + } else { + /* Cancel the label edit action, inform the user, and + place the node in edit mode again. */ + e.CancelEdit = true; + e.Node.BeginEdit(); + } + } + } + + private void Language(string lan) { + if (lan == "English") { + En(); + } else { + Zh(); + } + } + + private void Zh() { + sendBridge.Text = "发送"; + buttonClear.Text = "清除"; + buttonStartStop.Text = "连接"; + buttonScan.Text = "扫描"; + + checkBoxReconnect.Text = "自动重连"; + label33.Text = "语言"; + label32.Text = "日志级别"; + + label7.Text = "发至"; + label2.Text = "发至"; + labelopcua.Text = "发至"; + label23.Text = "发至"; + label8.Text = "发至"; + label6.Text = "发至"; + + groupBoxSerialPort.Text = "串口扫描"; + groupBox12.Text = "PLC扫描"; + groupBox4.Text = "OPC_DA扫描"; + labelOPCDAHost.Text = "主机"; + checkBoxOPCDA.Text = "主动上报"; + labelOPCDAMonitor.Text = "采集间隔"; + labelSecond.Text = "秒"; + labelOPCDACount.Text = "采集次数"; + groupBox5.Text = "OPC_UA扫描"; + groupBox6.Text = "BACnet扫描"; + groupBox7.Text = "窗体扫描"; + groupBox8.Text = "Access扫描"; + + labelSerialPort.Text = "端口"; + label1.Text = "波特率"; + label4.Text = "数据位"; + label13.Text = "校验位"; + label5.Text = "停止位"; + + groupBox3.Text = "Mqtt 客户端通道"; + label22.Text = "服务器地址"; + label21.Text = "服务器端口"; + label9.Text = "登录用户"; + label10.Text = "登录密码"; + label30.Text = "网关地址"; + label20.Text = "客户编号"; + label11.Text = "订阅主题"; + label12.Text = "发布主题"; + label29.Text = "命令代理"; + + groupBox2.Text = "TCP 客户端通道"; + label16.Text = "登录报文"; + + groupBox10.Text = "UDP 客户端通道"; + label15.Text = "登录报文"; + + label_devcietree.Text = "设备树"; + checkBoxBridge.Text = "桥接端口"; + groupBoxCommonConfig.Text = "公共配置"; + } + + private void En() { + sendBridge.Text = "Send"; + buttonClear.Text = "Clear"; + buttonStartStop.Text = "Start"; + buttonScan.Text = "Scan"; + label32.Text = "Level"; + + checkBoxReconnect.Text = "Auto Reconnect"; + label33.Text = "Language"; + + label7.Text = "To"; + label2.Text = "To"; + labelopcua.Text = "To"; + label23.Text = "To"; + label8.Text = "To"; + label6.Text = "To"; + groupBoxSerialPort.Text = "Serial Port Capture"; + groupBox12.Text = "PLC Capture"; + groupBox4.Text = "OPC_DA Capture"; + labelOPCDAHost.Text = "Host"; + checkBoxOPCDA.Text = "Monitor"; + labelOPCDAMonitor.Text = "Interval"; + labelSecond.Text = "Second"; + labelOPCDACount.Text = "Count"; + + groupBox5.Text = "OPC_UA Capture"; + groupBox6.Text = "BACnet Capture"; + groupBox7.Text = "Control Capture"; + groupBox8.Text = "Access Capture"; + + labelSerialPort.Text = "Port"; + label1.Text = "Baud Rate"; + label4.Text = "dataBits"; + label13.Text = "Parity"; + label5.Text = "stopBits"; + labelOPCDAHost.Text = "Host"; + + groupBox3.Text = "Mqtt Client Channel"; + label22.Text = "Server"; + label21.Text = "Port"; + label9.Text = "UserName"; + label10.Text = "PassWord"; + label30.Text = "DtuAddr"; + label20.Text = "Clientid"; + label11.Text = "SubTopic"; + label12.Text = "PubTopic"; + label29.Text = "cmd proxy"; + + groupBox2.Text = "TCP Client Channel"; + label16.Text = "login"; + + groupBox10.Text = "UDP Client Channel"; + label15.Text = "login"; + + label_devcietree.Text = "DeviceTree"; + checkBoxBridge.Text = "Bridge Port"; + groupBoxCommonConfig.Text = "Common Config"; + } + + private void MainForm_Load(object sender, EventArgs e) { + x = Width; // 获取窗体的宽度 + y = Height; // 获取窗体的高度 + SetTag(this); // 调用方法 + } + + private void MainForm_Resize(object sender, EventArgs e) { + if (x == 0) { + x = Width; + } + + if (y == 0) { + y = Height; + } + + float newx = this.Width / x; // 窗体宽度缩放比例 + float newy = this.Height / y; // 窗体高度缩放比例 + SetControls(newx, newy, this); // 随窗体改变控件大小 + } + + /// + /// 将控件的宽,高,左边距,顶边距和字体大小暂存到tag属性中 + /// + /// 递归控件中的控件 + private void SetTag(Control cons) { + foreach (Control con in cons.Controls) { + if (con == null) { + continue; + } + + con.Tag = con.Width + ":" + con.Height + ":" + con.Left + ":" + con.Top + + ":" + con.Font.Size; + if (con.Controls.Count > 0) { + SetTag(con); + } + } + } + + // 根据窗体大小调整控件大小 + private void SetControls(float newx, float newy, Control cons) { + // 遍历窗体中的控件,重新设置控件的值 + foreach (Control con in cons.Controls) { + if (con.Tag != null && con.Tag != "") { + string[] mytag = con.Tag.ToString().Split( + new char[] { ':' }); // 获取控件的Tag属性值,并分割后存储字符串数组 + float a = Convert.ToSingle(mytag[0]) * + newx; // 根据窗体缩放比例确定控件的值,宽度 + con.Width = (int)a; // 宽度 + a = Convert.ToSingle(mytag[1]) * newy; // 高度 + con.Height = (int)a; + a = Convert.ToSingle(mytag[2]) * newx; // 左边距离 + con.Left = (int)a; + a = Convert.ToSingle(mytag[3]) * newy; // 上边缘距离 + con.Top = (int)a; + float currentSize = Convert.ToSingle(mytag[4]) * newy; // 字体大小 + con.Font = + new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit); + } + + if (con.Controls.Count > 0) { + SetControls(newx, newy, con); + } + } + } + + private void openFileDialog_FileOk(object sender, + System.ComponentModel.CancelEventArgs e) {} + + private void textBoxLog_TextChanged(object sender, EventArgs e) {} + + private void groupBox5_Enter(object sender, EventArgs e) {} + + private void groupBox6_Enter(object sender, EventArgs e) {} + + private void groupBox8_Enter(object sender, EventArgs e) {} } } diff --git a/component/Mqtt/MqttClientHelper.cs b/component/Mqtt/MqttClientHelper.cs index cb7414e..aab0cc0 100644 --- a/component/Mqtt/MqttClientHelper.cs +++ b/component/Mqtt/MqttClientHelper.cs @@ -2,8 +2,7 @@ // Copyright (c) PlaceholderCompany. All rights reserved. // -namespace Dgiot_dtu -{ +namespace Dgiot_dtu { using System; using System.Collections.Generic; using System.Text; @@ -17,279 +16,241 @@ namespace Dgiot_dtu using MQTTnet.Core.Packets; using MQTTnet.Core.Protocol; -public class MqttClientHelper -{ - private MqttClientHelper() - { +public class MqttClientHelper { + private MqttClientHelper() {} + + private static MqttClient mqttClient = null; + private static string server = "prod.iotn2n.com"; + private static int port = 1883; + private static string subtopic = "$dg/device/"; + private static string pubtopic = "$dg/thing/"; + private static string clientid = ""; + private static string username = "dgiot"; + private static string password = "dgiot"; + private static MqttClientHelper instance = null; + private static bool bIsRunning = false; + private static bool bIsCheck = false; + private static bool bAutoReconnect = false; + private static string dtuAddr = ""; + + public static MqttClientHelper GetInstance() { + if (instance == null) { + instance = new MqttClientHelper(); } - private static MqttClient mqttClient = null; - private static string server = "prod.iotn2n.com"; - private static int port = 1883; - private static string subtopic = "$dg/device/"; - private static string pubtopic = "$dg/thing/"; - private static string clientid = ""; - private static string username = "dgiot"; - private static string password = "dgiot"; - private static MqttClientHelper instance = null; - private static bool bIsRunning = false; - private static bool bIsCheck = false; - private static bool bAutoReconnect = false; - private static string dtuAddr = ""; + return instance; + } - public static MqttClientHelper GetInstance() - { - if (instance == null) - { - instance = new MqttClientHelper(); - } - - return instance; + public static void Start() { + Config(); + bIsRunning = true; + if (bIsCheck) { + Task.Run(async () => { await ConnectMqttServerAsync(); }); } + } - public static void Start() - { - Config(); - bIsRunning = true; - if (bIsCheck) - { - Task.Run(async () => { - await ConnectMqttServerAsync(); - }); - } + public static void Stop() { + if (mqttClient != null) { + bAutoReconnect = false; + bIsRunning = false; + Task.Run(async () => { await DisConnectMqttServerAsync(); }); } - - public static void Stop() - { - if (mqttClient != null) - { - bAutoReconnect = false; - bIsRunning = false; - Task.Run(async () => { - await DisConnectMqttServerAsync(); - }); - } + } + + public static void Config() { + bAutoReconnect = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); + server = ConfigHelper.GetConfig("DgiotSever"); + LogHelper.Log("DgiotPort " + ConfigHelper.GetConfig("DgiotPort")); + port = int.Parse(ConfigHelper.GetConfig("DgiotPort")); + clientid = ConfigHelper.GetConfig("MqttClientId"); + username = ConfigHelper.GetConfig("MqttUserName"); + password = ConfigHelper.GetConfig("MqttPassword"); + pubtopic = ConfigHelper.GetConfig("MqttPubTopic"); + subtopic = ConfigHelper.GetConfig("MqttSubTopic"); + dtuAddr = ConfigHelper.GetConfig("DtuAddr"); + bIsCheck = + DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); + } + + public void Publish(byte[] payload) { + var appMsg = new MqttApplicationMessage( + pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); + mqttClient.PublishAsync(appMsg); + } + + public static void Publish(string pubtopic, byte[] payload) { + if (mqttClient != null && mqttClient.IsConnected) { + var appMsg = new MqttApplicationMessage( + pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); + mqttClient.PublishAsync(appMsg); } - - public static void Config() - { - bAutoReconnect = DgiotHelper.StrTobool(ConfigHelper.GetConfig("ReconnectChecked")); - server = ConfigHelper.GetConfig("DgiotSever"); - LogHelper.Log("DgiotPort " + ConfigHelper.GetConfig("DgiotPort")); - port = int.Parse(ConfigHelper.GetConfig("DgiotPort")); - clientid = ConfigHelper.GetConfig("MqttClientId"); - username = ConfigHelper.GetConfig("MqttUserName"); - password = ConfigHelper.GetConfig("MqttPassword"); - pubtopic = ConfigHelper.GetConfig("MqttPubTopic"); - subtopic = ConfigHelper.GetConfig("MqttSubTopic"); - dtuAddr = ConfigHelper.GetConfig("DtuAddr"); - bIsCheck = DgiotHelper.StrTobool(ConfigHelper.GetConfig("MqttClient_Checked")); - } - - public void Publish(byte[] payload) - { - var appMsg = new MqttApplicationMessage(pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); - mqttClient.PublishAsync(appMsg); - } - - public static void Publish(string pubtopic, byte[] payload) - { - if (mqttClient != null && mqttClient.IsConnected) - { - var appMsg = new MqttApplicationMessage(pubtopic, payload, MqttQualityOfServiceLevel.AtLeastOnce, false); - mqttClient.PublishAsync(appMsg); - } - } - - private static async Task ReConnectMqttServerAsync() - { - while (bIsRunning) - { - if (!bAutoReconnect) - { - break; - } - - Thread.Sleep(1000 * 10); - if (!mqttClient.IsConnected) - { - await ConnectMqttServerAsync(); - } - } - } - - private static async Task ConnectMqttServerAsync() - { - if (mqttClient == null) - { - mqttClient = new MqttClientFactory().CreateMqttClient() as MqttClient; - mqttClient.ApplicationMessageReceived += MqttClient_ApplicationMessageReceived; - mqttClient.Connected += MqttClient_Connected; - mqttClient.Disconnected += MqttClient_Disconnected; - } - - try - { - var options = new MqttClientTcpOptions - { - Server = server, - ClientId = clientid, - UserName = username, - Password = password, - Port = port, - CleanSession = true - }; - - await DisConnectMqttServerAsync(); - await mqttClient.ConnectAsync(options); - await ReConnectMqttServerAsync(); - } - catch (Exception ex) - { - LogHelper.Log(ex.ToString()); - } + } + + private static async Task ReConnectMqttServerAsync() { + while (bIsRunning) { + if (!bAutoReconnect) { + break; + } + + Thread.Sleep(1000 * 10); + if (!mqttClient.IsConnected) { + await ConnectMqttServerAsync(); + } } - - private static async Task DisConnectMqttServerAsync() - { - try - { - await mqttClient.DisconnectAsync(); - } - catch (Exception ex) - { - LogHelper.Log(ex.ToString()); - } + } + + private static async Task ConnectMqttServerAsync() { + if (mqttClient == null) { + mqttClient = new MqttClientFactory().CreateMqttClient() as MqttClient; + mqttClient.ApplicationMessageReceived += + MqttClient_ApplicationMessageReceived; + mqttClient.Connected += MqttClient_Connected; + mqttClient.Disconnected += MqttClient_Disconnected; } - /// - /// 服务器连接成功 - /// - /// - /// - private static void MqttClient_Connected(object sender, EventArgs e) - { - LogHelper.Log("mqtt client:" + clientid + " connected"); - - mqttClient.SubscribeAsync(new TopicFilter(subtopic, MqttQualityOfServiceLevel.AtLeastOnce)); - - - LogHelper.Log("mqtt client subscribe topic: " + subtopic); + try { + var options = + new MqttClientTcpOptions { Server = server, ClientId = clientid, + UserName = username, Password = password, + Port = port, CleanSession = true }; + + await DisConnectMqttServerAsync(); + await mqttClient.ConnectAsync(options); + await ReConnectMqttServerAsync(); + } catch (Exception ex) { + LogHelper.Log(ex.ToString()); } + } - /// - /// 断开服务器连接 - /// - /// - /// - private static void MqttClient_Disconnected(object sender, EventArgs e) - { - if (bAutoReconnect) - { - _ = ReConnectMqttServerAsync(); - } - else - { - LogHelper.Log("mqtt:" + clientid + " disconnected"); - } + private static async Task DisConnectMqttServerAsync() { + try { + await mqttClient.DisconnectAsync(); + } catch (Exception ex) { + LogHelper.Log(ex.ToString()); } - - /// - /// 接收到消息 - /// - /// - /// - private static void MqttClient_ApplicationMessageReceived(object sender, MqttApplicationMessageReceivedEventArgs e) - { - Dictionary json = Get_payload(e.ApplicationMessage.Payload); - string topic = e.ApplicationMessage.Topic; - string data = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); - LogHelper.Log("mqtt recv:topic: " + e.ApplicationMessage.Topic.ToString() + " payload: " + data); - - Regex r_subtopic = new Regex(subtopic); // 定义一个Regex对象实例 - Match m_subtopic = r_subtopic.Match(e.ApplicationMessage.Topic); // 在字符串中匹配 - if (m_subtopic.Success) - { - SerialPortHelper.Write(e.ApplicationMessage.Payload, 0, e.ApplicationMessage.Payload.Length); - } - if (topic.IndexOf("$dg/device/" + username + "/" + dtuAddr) == 0) - { - if (json.ContainsKey("cmd")) - { - if (json["cmd"].ToString() == "opc_items") - { - OPCDAHelper.Readitems(json); - } - else if (json["cmd"].ToString() == "opc_report") - { - OPCDAHelper.Publishvalues(json); - } - else if (json["cmd"].ToString() == "printer") - { - PrinterHelper.PrintPage(json["data"].ToString()); - } - } - } - - AccessHelper.Do_mdb(topic, json, clientid); - - MqttServerHelper.Write(e.ApplicationMessage); + } + + /// + /// 服务器连接成功 + /// + /// + /// + private static void MqttClient_Connected(object sender, EventArgs e) { + LogHelper.Log("mqtt client:" + clientid + " connected"); + + mqttClient.SubscribeAsync( + new TopicFilter(subtopic, MqttQualityOfServiceLevel.AtLeastOnce)); + + LogHelper.Log("mqtt client subscribe topic: " + subtopic); + } + + /// + /// 断开服务器连接 + /// + /// + /// + private static void MqttClient_Disconnected(object sender, EventArgs e) { + if (bAutoReconnect) { + _ = ReConnectMqttServerAsync(); + } else { + LogHelper.Log("mqtt:" + clientid + " disconnected"); } - - public static void Write(byte[] data, int offset, int len) - { - if (bIsCheck) - { - var appMsg = new MqttApplicationMessage(pubtopic + clientid, Encoding.UTF8.GetBytes(LogHelper.Logdata(data, offset, len)), MqttQualityOfServiceLevel.AtLeastOnce, false); - LogHelper.Log("mqtt client publish:" + LogHelper.Logdata(data, offset, len)); - mqttClient.PublishAsync(appMsg); - } + } + + /// + /// 接收到消息 + /// + /// + /// + private static void MqttClient_ApplicationMessageReceived( + object sender, MqttApplicationMessageReceivedEventArgs e) { + Dictionary json = Get_payload(e.ApplicationMessage.Payload); + string topic = e.ApplicationMessage.Topic; + string data = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); + LogHelper.Log("mqtt recv:topic: " + e.ApplicationMessage.Topic.ToString() + + " payload: " + data); + + Regex r_subtopic = new Regex(subtopic); // 定义一个Regex对象实例 + Match m_subtopic = + r_subtopic.Match(e.ApplicationMessage.Topic); // 在字符串中匹配 + if (m_subtopic.Success) { + SerialPortHelper.Write(e.ApplicationMessage.Payload, 0, + e.ApplicationMessage.Payload.Length); } - - public static void Write(MqttApplicationMessage appMsg) - { - if (bIsCheck) - { - mqttClient.PublishAsync(appMsg); + if (topic.IndexOf("$dg/device/" + username + "/" + dtuAddr) == 0) { + if (json.ContainsKey("cmd")) { + if (json["cmd"].ToString() == "opc_items") { + OPCDAHelper.Readitems(json); + } else if (json["cmd"].ToString() == "opc_report") { + OPCDAHelper.Publishvalues(json); + } else if (json["cmd"].ToString() == "printer") { + PrinterHelper.PrintPage(json["data"].ToString()); } + } } - private static Dictionary Get_payload(byte[] payload) - { - string data = Encoding.UTF8.GetString(payload); - JavaScriptSerializer serializer = new JavaScriptSerializer(); - Dictionary json = (Dictionary)serializer.DeserializeObject(data); - return json; - } - - private static Dictionary Get_payload(byte[] payload, int offset, int len) - { - string data = Encoding.UTF8.GetString(payload, offset, len); - JavaScriptSerializer serializer = new JavaScriptSerializer(); - Dictionary json = (Dictionary)serializer.DeserializeObject(data); - return json; - } + AccessHelper.Do_mdb(topic, json, clientid); - private static readonly DateTime BaseTime = new DateTime(1970, 1, 1); + MqttServerHelper.Write(e.ApplicationMessage); + } - /// - /// 将unixtime转换为.NET的DateTime - /// - /// 秒数 - /// 转换后的时间 - public static DateTime FromUnixTime(long timeStamp) - { - return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime((timeStamp * 10000000) + BaseTime.Ticks)); + public static void Write(byte[] data, int offset, int len) { + if (bIsCheck) { + var appMsg = new MqttApplicationMessage( + pubtopic + clientid, + Encoding.UTF8.GetBytes(LogHelper.Logdata(data, offset, len)), + MqttQualityOfServiceLevel.AtLeastOnce, false); + LogHelper.Log("mqtt client publish:" + + LogHelper.Logdata(data, offset, len)); + mqttClient.PublishAsync(appMsg); } + } - /// - /// 将.NET的DateTime转换为unix time - /// - /// 待转换的时间 - /// 转换后的unix time - public static long FromDateTime(DateTime dateTime) - { - return (TimeZone.CurrentTimeZone.ToUniversalTime(dateTime).Ticks - BaseTime.Ticks) / 10000000; + public static void Write(MqttApplicationMessage appMsg) { + if (bIsCheck) { + mqttClient.PublishAsync(appMsg); } + } + + private static Dictionary Get_payload(byte[] payload) { + string data = Encoding.UTF8.GetString(payload); + JavaScriptSerializer serializer = new JavaScriptSerializer(); + Dictionary json = + (Dictionary)serializer.DeserializeObject(data); + return json; + } + + private static Dictionary Get_payload(byte[] payload, + int offset, int len) { + string data = Encoding.UTF8.GetString(payload, offset, len); + JavaScriptSerializer serializer = new JavaScriptSerializer(); + Dictionary json = + (Dictionary)serializer.DeserializeObject(data); + return json; + } + + private static readonly DateTime BaseTime = new DateTime(1970, 1, 1); + + /// + /// 将unixtime转换为.NET的DateTime + /// + /// 秒数 + /// 转换后的时间 + public static DateTime FromUnixTime(long timeStamp) { + return TimeZone.CurrentTimeZone.ToLocalTime( + new DateTime((timeStamp * 10000000) + BaseTime.Ticks)); + } + + /// + /// 将.NET的DateTime转换为unix time + /// + /// 待转换的时间 + /// 转换后的unix time + public static long FromDateTime(DateTime dateTime) { + return (TimeZone.CurrentTimeZone.ToUniversalTime(dateTime).Ticks - + BaseTime.Ticks) / + 10000000; + } } } \ No newline at end of file diff --git a/component/Printer/PrinterHelper.cs b/component/Printer/PrinterHelper.cs index d6c8dd8..0c0d6ff 100644 --- a/component/Printer/PrinterHelper.cs +++ b/component/Printer/PrinterHelper.cs @@ -2,8 +2,7 @@ // Copyright (c) PlaceholderCompany. All rights reserved. // -namespace Dgiot_dtu -{ +namespace Dgiot_dtu { using System; using System.Configuration; using System.Drawing; @@ -15,124 +14,97 @@ namespace Dgiot_dtu using MQTTnet.Core.Protocol; using System.Collections.Generic; -internal class PrinterHelper -{ +internal class PrinterHelper { - [DllImport("winspool.drv")] - public static extern bool SetDefaultPrinter(String Name); //调用win api将指定名称的打印机设置为默认打印 + [DllImport("winspool.drv")] + public static extern bool + SetDefaultPrinter(String Name); //调用win api将指定名称的打印机设置为默认打印 - private static PrinterHelper instance = null; - private static bool bIsRunning = false; + private static PrinterHelper instance = null; + private static bool bIsRunning = false; - private static string textData = "C01010100005DGF0100189"; - private static PrintDocument fPrintDocument = new PrintDocument(); + private static string textData = "C01010100005DGF0100189"; + private static PrintDocument fPrintDocument = new PrintDocument(); + public static void Start(MqttClient mqttClient) { - public static void Start(MqttClient mqttClient) - { + string Name = "ec71804a3d"; + mqttClient.SubscribeAsync(new TopicFilter( + "device/printer", MqttQualityOfServiceLevel.AtLeastOnce)); + LogHelper.Log("mqtt client subscribe topic: " + "device/" + Name + "/#"); + } - string Name = "ec71804a3d"; - mqttClient.SubscribeAsync(new TopicFilter("device/printer", MqttQualityOfServiceLevel.AtLeastOnce)); - LogHelper.Log("mqtt client subscribe topic: " + "device/" + Name + "/#"); + public static PrinterHelper GetInstance() { + if (instance == null) { + instance = new PrinterHelper(); } - - - public static PrinterHelper GetInstance() - { - if (instance == null) - { - instance = new PrinterHelper(); - } - - return instance; - } - - public static void Start(KeyValueConfigurationCollection config, bool bIsRunning) - { - Config(config); - PrinterHelper.bIsRunning = bIsRunning; - } - - public static void Stop() - { - PrinterHelper.bIsRunning = false; - } - - public static void Config(KeyValueConfigurationCollection config) - { - } - - - - - Brush brushHeaderFont = new SolidBrush(Color.Black); - Pen LinePen = new Pen(Color.Black, 1); - public PrinterHelper() - { - InitPrint(); - } - /// - /// 初始化打印机 - /// - private void InitPrint() - { - - } - - /// - /// 打印 - /// - public void Print() - { - } - - public static void SetTextData(string data ) - { - textData = data; - - } - - - public static void PrintPage(string json) - { - SetTextData(json); - PrintDialog PD = new PrintDialog(); - PageSettings pageSettings = new PageSettings(); - //pageSettings.PaperSize = new PaperSize("Size", 30, 40); - string Name = fPrintDocument.PrinterSettings.PrinterName; - System.Drawing.Printing.PrinterSettings Ps = new System.Drawing.Printing.PrinterSettings(); - //SetDefaultPrinter("Deli DL-888B(NEW)"); - fPrintDocument.DefaultPageSettings.PaperSize = new PaperSize("Size", 157, 118); //单位1/100英寸 - SetDefaultPrinter(Name); - PD.PrinterSettings = Ps; - fPrintDocument.PrintPage += document_PrintPage; - PD.Document = fPrintDocument; - fPrintDocument.Print(); - } - - static void document_PrintPage(object sender, PrintPageEventArgs e) - { - int x1 = -5; - int y1 = 15; - double x2= (260 * 0.63)+x1; - double y2 = (140 * 0.63) + y1; - e.Graphics.DrawImage(PrinterHelper.Get_image(), x1, y1,(int)x2, (int)y2); - e.HasMorePages = false; - } - - public static Image Get_image() - { - CodeLib.Barcode b = new CodeLib.Barcode(); - CodeLib.TYPE type = CodeLib.TYPE.CODE128B; - b.IncludeLabel = true; - string familyName = "宋体"; - Font Label = new Font(familyName, 40.0F); - b.LabelFont = Label; - CodeLib.AlignmentPositions Align = CodeLib.AlignmentPositions.CENTER; - b.Alignment = Align; - b.LabelPosition = CodeLib.LabelPositions.BOTTOMCENTER; - return b.Encode(type, textData, 523, 200); - } + return instance; + } + + public static void Start(KeyValueConfigurationCollection config, + bool bIsRunning) { + Config(config); + PrinterHelper.bIsRunning = bIsRunning; + } + + public static void Stop() { PrinterHelper.bIsRunning = false; } + + public static void Config(KeyValueConfigurationCollection config) {} + + Brush brushHeaderFont = new SolidBrush(Color.Black); + Pen LinePen = new Pen(Color.Black, 1); + public PrinterHelper() { InitPrint(); } + /// + /// 初始化打印机 + /// + private void InitPrint() {} + + /// + /// 打印 + /// + public void Print() {} + + public static void SetTextData(string data) { textData = data; } + + public static void PrintPage(string json) { + SetTextData(json); + PrintDialog PD = new PrintDialog(); + PageSettings pageSettings = new PageSettings(); + // pageSettings.PaperSize = new PaperSize("Size", 30, 40); + string Name = fPrintDocument.PrinterSettings.PrinterName; + System.Drawing.Printing.PrinterSettings Ps = + new System.Drawing.Printing.PrinterSettings(); + // SetDefaultPrinter("Deli DL-888B(NEW)"); + fPrintDocument.DefaultPageSettings.PaperSize = + new PaperSize("Size", 157, 118); //单位1/100英寸 + SetDefaultPrinter(Name); + PD.PrinterSettings = Ps; + fPrintDocument.PrintPage += document_PrintPage; + PD.Document = fPrintDocument; + fPrintDocument.Print(); + } + + static void document_PrintPage(object sender, PrintPageEventArgs e) { + int x1 = -5; + int y1 = 15; + double x2 = (260 * 0.63) + x1; + double y2 = (140 * 0.63) + y1; + e.Graphics.DrawImage(PrinterHelper.Get_image(), x1, y1, (int)x2, (int)y2); + e.HasMorePages = false; + } + + public static Image Get_image() { + CodeLib.Barcode b = new CodeLib.Barcode(); + CodeLib.TYPE type = CodeLib.TYPE.CODE128B; + b.IncludeLabel = true; + string familyName = "宋体"; + Font Label = new Font(familyName, 40.0F); + b.LabelFont = Label; + CodeLib.AlignmentPositions Align = CodeLib.AlignmentPositions.CENTER; + b.Alignment = Align; + b.LabelPosition = CodeLib.LabelPositions.BOTTOMCENTER; + return b.Encode(type, textData, 523, 200); + } } } \ No newline at end of file From 36c50e9a069bb379aef645d6c06ac0b8c57b6cf6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 22 Jul 2022 11:13:31 +0000 Subject: [PATCH 3/3] Restyled by whitespace --- component/Printer/PrinterHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component/Printer/PrinterHelper.cs b/component/Printer/PrinterHelper.cs index 0c0d6ff..9c443f7 100644 --- a/component/Printer/PrinterHelper.cs +++ b/component/Printer/PrinterHelper.cs @@ -107,4 +107,4 @@ public static Image Get_image() { return b.Encode(type, textData, 523, 200); } } -} \ No newline at end of file +}