Przeglądaj źródła

添加指令拼接功能

章政 7 lat temu
rodzic
commit
d9a8da3c87

+ 2 - 2
UAS_DeviceMonitor/CustomerControl/Button/ButtonAddRow.Designer.cs

@@ -30,9 +30,9 @@
         {
             this.SuspendLayout();
             // 
-            // ButtonSaveGrid
+            // ButtonAddRow
             // 
-            this.Click += new System.EventHandler(this.ButtonSaveGrid_Click);
+            this.Click += new System.EventHandler(this.ButtonAddRow_Click);
             this.ResumeLayout(false);
 
         }

+ 6 - 1
UAS_DeviceMonitor/CustomerControl/Button/ButtonAddRow.cs

@@ -29,10 +29,15 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
         }
 
         private void ButtonSaveGrid_Click(object sender, EventArgs e)
+        {
+
+        }
+
+        private void ButtonAddRow_Click(object sender, EventArgs e)
         {
             DataTable dt = (DataTable)grid.DataSource;
             if (dt != null)
-                SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, grid.InsertSQL);
+                dt.Rows.Add();
         }
     }
 }

+ 3 - 0
UAS_DeviceMonitor/CustomerControl/Button/ButtonSaveGrid.cs

@@ -32,7 +32,10 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
         {
             DataTable dt = (DataTable)grid.DataSource;
             if (dt != null)
+            {
                 SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, grid.InsertSQL);
+                XtraMessageBox.Show("保存成功");
+            }
         }
     }
 }

+ 42 - 0
UAS_DeviceMonitor/CustomerControl/GridViewWithSerialNum/GridViewWithSerialNum.Designer.cs

@@ -0,0 +1,42 @@
+namespace UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum
+{
+    partial class GridViewWithSerialNum
+    {
+        /// <summary> 
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region 组件设计器生成的代码
+
+        /// <summary> 
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
+            // 
+            // GridViewWithSerialNum
+            // 
+            this.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.GridViewWithSerialNum_CustomDrawRowIndicator);
+            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
+
+        }
+
+        #endregion
+    }
+}

+ 18 - 0
UAS_DeviceMonitor/CustomerControl/GridViewWithSerialNum/GridViewWithSerialNum.cs

@@ -0,0 +1,18 @@
+using DevExpress.XtraGrid.Views.Grid;
+
+namespace UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum
+{
+    public partial class GridViewWithSerialNum : GridView
+    {
+        public GridViewWithSerialNum()
+        {
+            InitializeComponent();
+            IndicatorWidth = 30;
+        }
+
+        private void GridViewWithSerialNum_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
+        {
+            e.Info.DisplayText = e.RowHandle.ToString();
+        }
+    }
+}

+ 123 - 0
UAS_DeviceMonitor/CustomerControl/GridViewWithSerialNum/GridViewWithSerialNum.resx

@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+</root>

+ 31 - 0
UAS_DeviceMonitor/DataOperate/ComboBoxData.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace UAS_DeviceMonitor.DataOperate
+{
+    class ComboBoxData
+    {
+        /// <summary>
+        /// 值
+        /// </summary>
+        public string Text { set; get; }
+
+        /// <summary>
+        /// 键
+        /// </summary>
+        public string Value { set; get; }
+
+        /// <summary>
+        /// 重写ToString()方法
+        /// </summary>
+        /// <author>PengZhen</author>
+        /// <time>2013-10-31 15:51:37</time>
+        /// <returns>返回ComboBox的值</returns>
+        public override string ToString()
+        {
+            return Text;
+        }
+    }
+}

+ 162 - 64
UAS_DeviceMonitor/Device/Command/FormNewCommand.Designer.cs

@@ -30,22 +30,34 @@
         {
             this.AddCommand = new DevExpress.XtraEditors.SimpleButton();
             this.CodeClientAddress = new DevExpress.XtraEditors.ComboBoxEdit();
-            this.comboBoxEdit2 = new DevExpress.XtraEditors.ComboBoxEdit();
-            this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
-            this.textEdit2 = new DevExpress.XtraEditors.TextEdit();
+            this.CodeFunction = new DevExpress.XtraEditors.ComboBoxEdit();
+            this.CodeAddress = new DevExpress.XtraEditors.TextEdit();
+            this.CodeLength = new DevExpress.XtraEditors.TextEdit();
             this.CodeClientAddress_label = new DevExpress.XtraEditors.LabelControl();
-            this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
-            this.labelControl3 = new DevExpress.XtraEditors.LabelControl();
-            this.labelControl4 = new DevExpress.XtraEditors.LabelControl();
+            this.CodeFunction_label = new DevExpress.XtraEditors.LabelControl();
+            this.CodeAddress_label = new DevExpress.XtraEditors.LabelControl();
+            this.CodeLength_label = new DevExpress.XtraEditors.LabelControl();
+            this.dc_name_label = new DevExpress.XtraEditors.LabelControl();
+            this.dc_code_label = new DevExpress.XtraEditors.LabelControl();
+            this.dc_name = new DevExpress.XtraEditors.TextEdit();
+            this.dc_code = new DevExpress.XtraEditors.TextEdit();
+            this.CodeComplement_label = new DevExpress.XtraEditors.LabelControl();
+            this.CodeEnd_label = new DevExpress.XtraEditors.LabelControl();
+            this.CodeEnd = new DevExpress.XtraEditors.ComboBoxEdit();
+            this.CodeComplement = new DevExpress.XtraEditors.ComboBoxEdit();
             ((System.ComponentModel.ISupportInitialize)(this.CodeClientAddress.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit2.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeFunction.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeAddress.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeLength.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dc_name.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dc_code.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeEnd.Properties)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeComplement.Properties)).BeginInit();
             this.SuspendLayout();
             // 
             // AddCommand
             // 
-            this.AddCommand.Location = new System.Drawing.Point(230, 118);
+            this.AddCommand.Location = new System.Drawing.Point(347, 133);
             this.AddCommand.Name = "AddCommand";
             this.AddCommand.Size = new System.Drawing.Size(75, 23);
             this.AddCommand.TabIndex = 0;
@@ -54,91 +66,169 @@
             // 
             // CodeClientAddress
             // 
-            this.CodeClientAddress.Location = new System.Drawing.Point(88, 65);
+            this.CodeClientAddress.Location = new System.Drawing.Point(75, 80);
             this.CodeClientAddress.Name = "CodeClientAddress";
             this.CodeClientAddress.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
             new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.CodeClientAddress.Size = new System.Drawing.Size(50, 20);
+            this.CodeClientAddress.Size = new System.Drawing.Size(63, 20);
             this.CodeClientAddress.TabIndex = 1;
             // 
-            // comboBoxEdit2
+            // CodeFunction
             // 
-            this.comboBoxEdit2.Location = new System.Drawing.Point(199, 65);
-            this.comboBoxEdit2.Name = "comboBoxEdit2";
-            this.comboBoxEdit2.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            this.CodeFunction.Location = new System.Drawing.Point(198, 80);
+            this.CodeFunction.Name = "CodeFunction";
+            this.CodeFunction.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
             new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.comboBoxEdit2.Size = new System.Drawing.Size(50, 20);
-            this.comboBoxEdit2.TabIndex = 2;
+            this.CodeFunction.Size = new System.Drawing.Size(63, 20);
+            this.CodeFunction.TabIndex = 2;
             // 
-            // textEdit1
+            // CodeAddress
             // 
-            this.textEdit1.Location = new System.Drawing.Point(307, 65);
-            this.textEdit1.Name = "textEdit1";
-            this.textEdit1.Size = new System.Drawing.Size(60, 20);
-            this.textEdit1.TabIndex = 3;
+            this.CodeAddress.Location = new System.Drawing.Point(318, 80);
+            this.CodeAddress.Name = "CodeAddress";
+            this.CodeAddress.Size = new System.Drawing.Size(60, 20);
+            this.CodeAddress.TabIndex = 3;
             // 
-            // textEdit2
+            // CodeLength
             // 
-            this.textEdit2.Location = new System.Drawing.Point(437, 65);
-            this.textEdit2.Name = "textEdit2";
-            this.textEdit2.Size = new System.Drawing.Size(60, 20);
-            this.textEdit2.TabIndex = 4;
+            this.CodeLength.Location = new System.Drawing.Point(447, 80);
+            this.CodeLength.Name = "CodeLength";
+            this.CodeLength.Size = new System.Drawing.Size(60, 20);
+            this.CodeLength.TabIndex = 4;
             // 
             // CodeClientAddress_label
             // 
-            this.CodeClientAddress_label.Location = new System.Drawing.Point(31, 68);
+            this.CodeClientAddress_label.Location = new System.Drawing.Point(18, 83);
             this.CodeClientAddress_label.Name = "CodeClientAddress_label";
             this.CodeClientAddress_label.Size = new System.Drawing.Size(48, 14);
             this.CodeClientAddress_label.TabIndex = 5;
             this.CodeClientAddress_label.Text = "从站地址";
             // 
-            // labelControl2
+            // CodeFunction_label
             // 
-            this.labelControl2.Location = new System.Drawing.Point(157, 68);
-            this.labelControl2.Name = "labelControl2";
-            this.labelControl2.Size = new System.Drawing.Size(36, 14);
-            this.labelControl2.TabIndex = 6;
-            this.labelControl2.Text = "命令码";
+            this.CodeFunction_label.Location = new System.Drawing.Point(144, 83);
+            this.CodeFunction_label.Name = "CodeFunction_label";
+            this.CodeFunction_label.Size = new System.Drawing.Size(36, 14);
+            this.CodeFunction_label.TabIndex = 6;
+            this.CodeFunction_label.Text = "命令码";
             // 
-            // labelControl3
+            // CodeAddress_label
             // 
-            this.labelControl3.Location = new System.Drawing.Point(265, 68);
-            this.labelControl3.Name = "labelControl3";
-            this.labelControl3.Size = new System.Drawing.Size(36, 14);
-            this.labelControl3.TabIndex = 7;
-            this.labelControl3.Text = "地址位";
+            this.CodeAddress_label.AccessibleDescription = "";
+            this.CodeAddress_label.Location = new System.Drawing.Point(276, 83);
+            this.CodeAddress_label.Name = "CodeAddress_label";
+            this.CodeAddress_label.Size = new System.Drawing.Size(36, 14);
+            this.CodeAddress_label.TabIndex = 7;
+            this.CodeAddress_label.Text = "地址位";
             // 
-            // labelControl4
+            // CodeLength_label
             // 
-            this.labelControl4.Location = new System.Drawing.Point(383, 68);
-            this.labelControl4.Name = "labelControl4";
-            this.labelControl4.Size = new System.Drawing.Size(48, 14);
-            this.labelControl4.TabIndex = 8;
-            this.labelControl4.Text = "操作位数";
+            this.CodeLength_label.Location = new System.Drawing.Point(393, 83);
+            this.CodeLength_label.Name = "CodeLength_label";
+            this.CodeLength_label.Size = new System.Drawing.Size(48, 14);
+            this.CodeLength_label.TabIndex = 8;
+            this.CodeLength_label.Text = "操作位数";
+            // 
+            // dc_name_label
+            // 
+            this.dc_name_label.Location = new System.Drawing.Point(144, 30);
+            this.dc_name_label.Name = "dc_name_label";
+            this.dc_name_label.Size = new System.Drawing.Size(48, 14);
+            this.dc_name_label.TabIndex = 12;
+            this.dc_name_label.Text = "指令名称";
+            // 
+            // dc_code_label
+            // 
+            this.dc_code_label.AccessibleDescription = "";
+            this.dc_code_label.Location = new System.Drawing.Point(18, 30);
+            this.dc_code_label.Name = "dc_code_label";
+            this.dc_code_label.Size = new System.Drawing.Size(48, 14);
+            this.dc_code_label.TabIndex = 11;
+            this.dc_code_label.Text = "指令编号";
+            // 
+            // dc_name
+            // 
+            this.dc_name.Location = new System.Drawing.Point(198, 27);
+            this.dc_name.Name = "dc_name";
+            this.dc_name.Size = new System.Drawing.Size(60, 20);
+            this.dc_name.TabIndex = 10;
+            // 
+            // dc_code
+            // 
+            this.dc_code.Location = new System.Drawing.Point(73, 27);
+            this.dc_code.Name = "dc_code";
+            this.dc_code.Size = new System.Drawing.Size(65, 20);
+            this.dc_code.TabIndex = 9;
+            // 
+            // CodeComplement_label
+            // 
+            this.CodeComplement_label.Location = new System.Drawing.Point(528, 83);
+            this.CodeComplement_label.Name = "CodeComplement_label";
+            this.CodeComplement_label.Size = new System.Drawing.Size(24, 14);
+            this.CodeComplement_label.TabIndex = 14;
+            this.CodeComplement_label.Text = "补码";
+            // 
+            // CodeEnd_label
+            // 
+            this.CodeEnd_label.Location = new System.Drawing.Point(646, 83);
+            this.CodeEnd_label.Name = "CodeEnd_label";
+            this.CodeEnd_label.Size = new System.Drawing.Size(36, 14);
+            this.CodeEnd_label.TabIndex = 16;
+            this.CodeEnd_label.Text = "结束位";
+            // 
+            // CodeEnd
+            // 
+            this.CodeEnd.Location = new System.Drawing.Point(700, 80);
+            this.CodeEnd.Name = "CodeEnd";
+            this.CodeEnd.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.CodeEnd.Size = new System.Drawing.Size(63, 20);
+            this.CodeEnd.TabIndex = 18;
+            // 
+            // CodeComplement
+            // 
+            this.CodeComplement.Location = new System.Drawing.Point(567, 80);
+            this.CodeComplement.Name = "CodeComplement";
+            this.CodeComplement.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.CodeComplement.Size = new System.Drawing.Size(63, 20);
+            this.CodeComplement.TabIndex = 17;
             // 
             // FormNewCommand
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(533, 165);
-            this.Controls.Add(this.labelControl4);
-            this.Controls.Add(this.labelControl3);
-            this.Controls.Add(this.labelControl2);
+            this.ClientSize = new System.Drawing.Size(766, 190);
+            this.Controls.Add(this.CodeEnd);
+            this.Controls.Add(this.CodeComplement);
+            this.Controls.Add(this.CodeEnd_label);
+            this.Controls.Add(this.CodeComplement_label);
+            this.Controls.Add(this.dc_name_label);
+            this.Controls.Add(this.dc_code_label);
+            this.Controls.Add(this.dc_name);
+            this.Controls.Add(this.dc_code);
+            this.Controls.Add(this.CodeLength_label);
+            this.Controls.Add(this.CodeAddress_label);
+            this.Controls.Add(this.CodeFunction_label);
             this.Controls.Add(this.CodeClientAddress_label);
-            this.Controls.Add(this.textEdit2);
-            this.Controls.Add(this.textEdit1);
-            this.Controls.Add(this.comboBoxEdit2);
+            this.Controls.Add(this.CodeLength);
+            this.Controls.Add(this.CodeAddress);
+            this.Controls.Add(this.CodeFunction);
             this.Controls.Add(this.CodeClientAddress);
             this.Controls.Add(this.AddCommand);
             this.FormBorderEffect = DevExpress.XtraEditors.FormBorderEffect.None;
             this.Name = "FormNewCommand";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
-            this.Text = "新增指令";
+            this.Text = " ";
             this.Load += new System.EventHandler(this.FormNewCommand_Load);
             ((System.ComponentModel.ISupportInitialize)(this.CodeClientAddress.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit2.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeFunction.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeAddress.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeLength.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dc_name.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.dc_code.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeEnd.Properties)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.CodeComplement.Properties)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -148,12 +238,20 @@
 
         private DevExpress.XtraEditors.SimpleButton AddCommand;
         private DevExpress.XtraEditors.ComboBoxEdit CodeClientAddress;
-        private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit2;
-        private DevExpress.XtraEditors.TextEdit textEdit1;
-        private DevExpress.XtraEditors.TextEdit textEdit2;
+        private DevExpress.XtraEditors.ComboBoxEdit CodeFunction;
+        private DevExpress.XtraEditors.TextEdit CodeAddress;
+        private DevExpress.XtraEditors.TextEdit CodeLength;
         private DevExpress.XtraEditors.LabelControl CodeClientAddress_label;
-        private DevExpress.XtraEditors.LabelControl labelControl2;
-        private DevExpress.XtraEditors.LabelControl labelControl3;
-        private DevExpress.XtraEditors.LabelControl labelControl4;
+        private DevExpress.XtraEditors.LabelControl CodeFunction_label;
+        private DevExpress.XtraEditors.LabelControl CodeAddress_label;
+        private DevExpress.XtraEditors.LabelControl CodeLength_label;
+        private DevExpress.XtraEditors.LabelControl dc_name_label;
+        private DevExpress.XtraEditors.LabelControl dc_code_label;
+        private DevExpress.XtraEditors.TextEdit dc_name;
+        private DevExpress.XtraEditors.TextEdit dc_code;
+        private DevExpress.XtraEditors.LabelControl CodeComplement_label;
+        private DevExpress.XtraEditors.LabelControl CodeEnd_label;
+        private DevExpress.XtraEditors.ComboBoxEdit CodeEnd;
+        private DevExpress.XtraEditors.ComboBoxEdit CodeComplement;
     }
 }

+ 23 - 2
UAS_DeviceMonitor/Device/Command/FormNewCommand.cs

@@ -1,24 +1,45 @@
 using System;
 using DevExpress.XtraEditors;
 using UAS_DeviceMonitor.Entity;
+using System.Data;
+using UAS_DeviceMonitor.DataOperate;
+using UAS_DeviceMonitor.PublicMethod;
 
 namespace UAS_DeviceMonitor.Device.Command
 {
     public partial class FormNewCommand : XtraForm
     {
+
+        string brand = "";
+
         public FormNewCommand()
         {
             InitializeComponent();
         }
 
-        private void FormNewCommand_Load(object sender, EventArgs e)
+        public FormNewCommand(string BrandCode, string BrandName)
         {
+            InitializeComponent();
+            brand = BrandCode;
+            Text = "新增指令(" + BrandName + ")";
+        }
 
+        private void FormNewCommand_Load(object sender, EventArgs e)
+        {
+            DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select * from CommandFunctionSetting where cfs_debrand='" + brand + "' order by cfs_id ", "select");
+            BaseUtil.FillComBoxEditWidthDataTable(CodeClientAddress, "cfs_name", "cfs_value", BaseUtil.ToDataTable(dt.Select("cfs_type='CA'")));
+            BaseUtil.FillComBoxEditWidthDataTable(CodeFunction, "cfs_name", "cfs_value", BaseUtil.ToDataTable(dt.Select("cfs_type='CF'")));
+            BaseUtil.FillComBoxEditWidthDataTable(CodeComplement, "cfs_name", "cfs_value", BaseUtil.ToDataTable(dt.Select("cfs_type='CC'")));
+            BaseUtil.FillComBoxEditWidthDataTable(CodeEnd, "cfs_name", "cfs_value", BaseUtil.ToDataTable(dt.Select("cfs_type='CE'")));
         }
 
         private void AddCommand_Click(object sender, EventArgs e)
         {
-            SystemInf.dh.ExecuteSql("insert into devicecommand(dc_id,dc_name,dc_code,dc_command) values (devicecommand_seq.nextval,'','','')", "insert");
+            string code = BaseUtil.GetComboxEditValue(CodeClientAddress.SelectedItem) + BaseUtil.GetComboxEditValue(CodeFunction.SelectedItem) + CodeAddress.Text + CodeLength.Text;
+            //添加指令的补码
+            code = code + BaseUtil.getLRC(code);
+            code = code + BaseUtil.GetComboxEditValue(CodeEnd.SelectedItem);
+            SystemInf.dh.ExecuteSql("insert into devicecommand(dc_id,dc_name,dc_code,dc_command,dc_brand) values (devicecommand_seq.nextval,'" + dc_name.Text + "','" + dc_code.Text + "','" + code + "','" + brand + "')", "insert");
             XtraMessageBox.Show("指令保存成功");
             Close();
         }

+ 54 - 17
UAS_DeviceMonitor/Main.Designer.cs

@@ -1,5 +1,7 @@
 using DevExpress.XtraEditors;
 using UAS_DeviceMonitor.CustomerControl.AutoDataGridControl;
+using UAS_DeviceMonitor.CustomerControl;
+using UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum;
 
 namespace UAS_DeviceMonitor
 {
@@ -47,7 +49,7 @@ namespace UAS_DeviceMonitor
             this.PageDeviceList = new DevExpress.XtraTab.XtraTabPage();
             this.PageControlDeviceList = new UAS_DeviceMonitor.CustomerControl.PagingControl.PageControl();
             this.GridDeviceList = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
-            this.GridViewDeviceList = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.GridViewDeviceList = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
             this.de_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_code = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_name = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -59,10 +61,12 @@ namespace UAS_DeviceMonitor
             this.de_address = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_wccode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageCommandSet = new DevExpress.XtraTab.XtraTabPage();
-            this.ButtonNewCommand = new SimpleButton();
-            this.ButtonSaveCommand = new UAS_DeviceMonitor.CustomerControl.Button.ButtonAddRow();
+            this.Brand_label = new DevExpress.XtraEditors.LabelControl();
+            this.Brand = new DevExpress.XtraEditors.ComboBoxEdit();
+            this.ButtonNewCommand = new DevExpress.XtraEditors.SimpleButton();
+            this.ButtonSaveCommand = new UAS_DeviceMonitor.CustomerControl.Button.ButtonSaveGrid();
             this.GridCommandSetting = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
-            this.GridViewCommandSet = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.GridViewCommandSet = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
             this.dc_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_code = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_name = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -71,7 +75,7 @@ namespace UAS_DeviceMonitor
             this.PageDeviceStatus = new DevExpress.XtraTab.XtraTabPage();
             this.PagePollingSetting = new DevExpress.XtraTab.XtraTabPage();
             this.GridPollingSetting = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
-            this.GridViewPollSetting = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.GridViewPollSetting = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
             this.dpc_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_decode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_plcode = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -85,7 +89,7 @@ namespace UAS_DeviceMonitor
             this.dpc_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PagePolling = new DevExpress.XtraTab.XtraTabPage();
             this.GridPolling = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
-            this.GridViewPolling = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.GridViewPolling = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
             this.pl_id = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_code = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_name = new DevExpress.XtraGrid.Columns.GridColumn();
@@ -99,6 +103,7 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridDeviceList)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceList)).BeginInit();
             this.PageCommandSet.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.Brand.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridCommandSetting)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewCommandSet)).BeginInit();
             this.PagePollingSetting.SuspendLayout();
@@ -288,6 +293,7 @@ namespace UAS_DeviceMonitor
             this.de_address,
             this.de_wccode});
             this.GridViewDeviceList.GridControl = this.GridDeviceList;
+            this.GridViewDeviceList.IndicatorWidth = 30;
             this.GridViewDeviceList.Name = "GridViewDeviceList";
             // 
             // de_id
@@ -373,6 +379,8 @@ namespace UAS_DeviceMonitor
             // 
             // PageCommandSet
             // 
+            this.PageCommandSet.Controls.Add(this.Brand_label);
+            this.PageCommandSet.Controls.Add(this.Brand);
             this.PageCommandSet.Controls.Add(this.ButtonNewCommand);
             this.PageCommandSet.Controls.Add(this.ButtonSaveCommand);
             this.PageCommandSet.Controls.Add(this.GridCommandSetting);
@@ -380,9 +388,30 @@ namespace UAS_DeviceMonitor
             this.PageCommandSet.PageVisible = false;
             this.PageCommandSet.Size = new System.Drawing.Size(1027, 577);
             this.PageCommandSet.Text = "xtraTabPage1";
+            this.PageCommandSet.VisibleChanged += new System.EventHandler(this.PageCommandSet_VisibleChanged);
+            // 
+            // Brand_label
+            // 
+            this.Brand_label.Appearance.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.Brand_label.Location = new System.Drawing.Point(8, 5);
+            this.Brand_label.Name = "Brand_label";
+            this.Brand_label.Size = new System.Drawing.Size(32, 21);
+            this.Brand_label.TabIndex = 5;
+            this.Brand_label.Text = "品牌";
+            // 
+            // Brand
+            // 
+            this.Brand.Location = new System.Drawing.Point(47, 6);
+            this.Brand.MenuManager = this.RibbonNav;
+            this.Brand.Name = "Brand";
+            this.Brand.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.Brand.Size = new System.Drawing.Size(100, 20);
+            this.Brand.TabIndex = 4;
             // 
             // ButtonNewCommand
             // 
+            this.ButtonNewCommand.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonNewCommand.Location = new System.Drawing.Point(886, 551);
             this.ButtonNewCommand.Name = "ButtonNewCommand";
             this.ButtonNewCommand.Size = new System.Drawing.Size(64, 23);
@@ -392,6 +421,7 @@ namespace UAS_DeviceMonitor
             // 
             // ButtonSaveCommand
             // 
+            this.ButtonSaveCommand.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSaveCommand.Grid = null;
             this.ButtonSaveCommand.Location = new System.Drawing.Point(956, 551);
             this.ButtonSaveCommand.Name = "ButtonSaveCommand";
@@ -401,18 +431,18 @@ namespace UAS_DeviceMonitor
             // 
             // GridCommandSetting
             // 
-            this.GridCommandSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-            | System.Windows.Forms.AnchorStyles.Left)
+            this.GridCommandSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
             this.GridCommandSetting.GetDataSQL = null;
             this.GridCommandSetting.ID = null;
             this.GridCommandSetting.InsertSQL = null;
-            this.GridCommandSetting.Location = new System.Drawing.Point(0, -1);
+            this.GridCommandSetting.Location = new System.Drawing.Point(0, 31);
             this.GridCommandSetting.MainView = this.GridViewCommandSet;
             this.GridCommandSetting.MenuManager = this.RibbonNav;
             this.GridCommandSetting.Name = "GridCommandSetting";
             this.GridCommandSetting.RowCount = 0;
-            this.GridCommandSetting.Size = new System.Drawing.Size(1027, 549);
+            this.GridCommandSetting.Size = new System.Drawing.Size(1027, 517);
             this.GridCommandSetting.TabIndex = 1;
             this.GridCommandSetting.TableName = null;
             this.GridCommandSetting.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
@@ -426,6 +456,7 @@ namespace UAS_DeviceMonitor
             this.dc_name,
             this.dc_command});
             this.GridViewCommandSet.GridControl = this.GridCommandSetting;
+            this.GridViewCommandSet.IndicatorWidth = 30;
             this.GridViewCommandSet.Name = "GridViewCommandSet";
             // 
             // dc_id
@@ -484,8 +515,8 @@ namespace UAS_DeviceMonitor
             // 
             // GridPollingSetting
             // 
-            this.GridPollingSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-            | System.Windows.Forms.AnchorStyles.Left)
+            this.GridPollingSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
             this.GridPollingSetting.GetDataSQL = null;
             this.GridPollingSetting.ID = null;
@@ -517,6 +548,7 @@ namespace UAS_DeviceMonitor
             this.dpc_status,
             this.dpc_remark});
             this.GridViewPollSetting.GridControl = this.GridPollingSetting;
+            this.GridViewPollSetting.IndicatorWidth = 30;
             this.GridViewPollSetting.Name = "GridViewPollSetting";
             this.GridViewPollSetting.OptionsSelection.MultiSelect = true;
             // 
@@ -644,6 +676,7 @@ namespace UAS_DeviceMonitor
             this.pl_dccode,
             this.pl_remark});
             this.GridViewPolling.GridControl = this.GridPolling;
+            this.GridViewPolling.IndicatorWidth = 30;
             this.GridViewPolling.Name = "GridViewPolling";
             // 
             // pl_id
@@ -713,6 +746,8 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridDeviceList)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceList)).EndInit();
             this.PageCommandSet.ResumeLayout(false);
+            this.PageCommandSet.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.Brand.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridCommandSetting)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewCommandSet)).EndInit();
             this.PagePollingSetting.ResumeLayout(false);
@@ -748,7 +783,6 @@ namespace UAS_DeviceMonitor
         private DevExpress.XtraBars.BarButtonItem ButtionPolling;
         private DevExpress.XtraTab.XtraTabPage PagePollingSetting;
         private DevExpress.XtraTab.XtraTabPage PagePolling;
-        private DevExpress.XtraGrid.Views.Grid.GridView GridViewDeviceList;
         private DevExpress.XtraGrid.Columns.GridColumn de_id;
         private DevExpress.XtraGrid.Columns.GridColumn de_code;
         private DevExpress.XtraGrid.Columns.GridColumn de_name;
@@ -761,15 +795,12 @@ namespace UAS_DeviceMonitor
         private DevExpress.XtraGrid.Columns.GridColumn de_wccode;
         private CustomerControl.PagingControl.PageControl PageControlDeviceList;
         private AutoDataGridControl GridCommandSetting;
-        private DevExpress.XtraGrid.Views.Grid.GridView GridViewCommandSet;
         private DevExpress.XtraGrid.Columns.GridColumn dc_id;
         private DevExpress.XtraGrid.Columns.GridColumn dc_code;
         private DevExpress.XtraGrid.Columns.GridColumn dc_name;
         private DevExpress.XtraGrid.Columns.GridColumn dc_command;
         private AutoDataGridControl GridPolling;
-        private DevExpress.XtraGrid.Views.Grid.GridView GridViewPolling;
         private AutoDataGridControl GridPollingSetting;
-        private DevExpress.XtraGrid.Views.Grid.GridView GridViewPollSetting;
         private DevExpress.XtraGrid.Columns.GridColumn pl_id;
         private DevExpress.XtraGrid.Columns.GridColumn pl_code;
         private DevExpress.XtraGrid.Columns.GridColumn pl_name;
@@ -787,7 +818,13 @@ namespace UAS_DeviceMonitor
         private DevExpress.XtraGrid.Columns.GridColumn dpc_status;
         private DevExpress.XtraGrid.Columns.GridColumn dpc_remark;
         private DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit dpc_enableCheckEdit;
-        private CustomerControl.Button.ButtonAddRow ButtonSaveCommand;
+        private CustomerControl.Button.ButtonSaveGrid ButtonSaveCommand;
         private SimpleButton ButtonNewCommand;
+        private GridViewWithSerialNum GridViewDeviceList;
+        private GridViewWithSerialNum GridViewCommandSet;
+        private GridViewWithSerialNum GridViewPolling;
+        private GridViewWithSerialNum GridViewPollSetting;
+        private LabelControl Brand_label;
+        private ComboBoxEdit Brand;
     }
 }

+ 14 - 2
UAS_DeviceMonitor/Main.cs

@@ -3,9 +3,9 @@ using DevExpress.XtraBars;
 using UAS_DeviceMonitor.DataOperate;
 using System.Data;
 using System.Text;
-using DevExpress.XtraTab;
 using UAS_DeviceMonitor.Entity;
 using UAS_DeviceMonitor.Device.Command;
+using UAS_DeviceMonitor.PublicMethod;
 
 namespace UAS_DeviceMonitor
 {
@@ -90,11 +90,23 @@ namespace UAS_DeviceMonitor
             e.Handled = true;
         }
 
+        #region PageCommandSet业务代码
+
         private void ButtonNewCommand_Click(object sender, EventArgs e)
         {
-            FormNewCommand fncmd = new FormNewCommand();
+            FormNewCommand fncmd = new FormNewCommand(BaseUtil.GetComboxEditValue(Brand.SelectedItem), Brand.Text);
             fncmd.ShowDialog();
             GridCommandSetting.RefreshData();
         }
+
+        private void PageCommandSet_VisibleChanged(object sender, EventArgs e)
+        {
+            if (PageCommandSet.PageVisible)
+            {
+                DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select * from devicebrand", "select");
+                BaseUtil.FillComBoxEditWidthDataTable(Brand, "db_name", "db_code", dt);
+            }
+        }
+        #endregion
     }
 }

+ 86 - 0
UAS_DeviceMonitor/PublicMethod/BaseUtil.cs

@@ -0,0 +1,86 @@
+using DevExpress.XtraEditors;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+using System.Xml;
+using UAS_DeviceMonitor.DataOperate;
+using UAS_DeviceMonitor.Entity;
+using UAS_DeviceMonitor.PublicMethod;
+using static System.Windows.Forms.Control;
+
+namespace UAS_DeviceMonitor.PublicMethod
+{
+    class BaseUtil
+    {
+        public static void FillComBoxEditWidthDataTable(ComboBoxEdit combo, string TextField, string ValueField, DataTable dt)
+        {
+            combo.Properties.Items.Clear();
+            ComboBoxData item = new ComboBoxData();
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                item.Value = dt.Rows[i][ValueField].ToString();
+                item.Text = dt.Rows[i][TextField].ToString();
+                combo.Properties.Items.Add(item);
+            }
+            combo.SelectedIndex = 0;
+        }
+
+        public static DataTable ToDataTable(DataRow[] rows)
+        {
+            if (rows == null || rows.Length == 0) return new DataTable();
+            DataTable tmp = rows[0].Table.Clone();  // 复制DataRow的表结构  
+            foreach (DataRow row in rows)
+                tmp.Rows.Add(row.ItemArray);  // 将DataRow添加到DataTable中  
+            return tmp;
+        }
+
+        public static string GetComboxEditValue(object comboxitem)
+        {
+            return (comboxitem as ComboBoxData).Value;
+        }
+
+        /// <summary>
+        /// 获取LRC
+        /// </summary>
+        /// <param name="SQL"></param>
+        public static string getLRC(string SENDMESSAGE)
+        {
+            string message = SENDMESSAGE.Trim();
+            if (message.Length % 2 != 0)
+            {
+                message = message + "0";
+            }
+
+            int LRC = 0x0;
+            for (int i = 0; i < message.Length; i = i + 2)
+            {
+                int inside = int.Parse(message.Substring(i, 1).ToString() + message.Substring(i + 1, 1).ToString(), System.Globalization.NumberStyles.HexNumber);
+                LRC += inside;
+            }
+            string _LRC = string.Format("{0:X2}", LRC);
+            string LRCre = "";
+            for (int i = 0; i < _LRC.Length; i++)
+            {
+                int index;
+                index = 0xF - int.Parse(_LRC.Substring(i, 1).ToString(), System.Globalization.NumberStyles.HexNumber);
+                LRCre += string.Format("{0:X}", index);
+            }
+
+            LRCre = string.Format("{0:X}", int.Parse(LRCre, System.Globalization.NumberStyles.HexNumber) + 1);
+
+            return LRCre;
+        }
+    }
+}

+ 11 - 0
UAS_DeviceMonitor/UAS_DeviceMonitor.csproj

@@ -78,12 +78,19 @@
     <Compile Include="CustomerControl\Button\ButtonSaveGrid.Designer.cs">
       <DependentUpon>ButtonSaveGrid.cs</DependentUpon>
     </Compile>
+    <Compile Include="CustomerControl\GridViewWithSerialNum\GridViewWithSerialNum.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="CustomerControl\GridViewWithSerialNum\GridViewWithSerialNum.Designer.cs">
+      <DependentUpon>GridViewWithSerialNum.cs</DependentUpon>
+    </Compile>
     <Compile Include="CustomerControl\PagingControl\PageControl.cs">
       <SubType>UserControl</SubType>
     </Compile>
     <Compile Include="CustomerControl\PagingControl\PageControl.Designer.cs">
       <DependentUpon>PageControl.cs</DependentUpon>
     </Compile>
+    <Compile Include="DataOperate\ComboBoxData.cs" />
     <Compile Include="DataOperate\DataHelper.cs" />
     <Compile Include="Device\Command\FormNewCommand.cs">
       <SubType>Form</SubType>
@@ -100,6 +107,7 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="PublicMethod\BaseUtil.cs" />
     <Compile Include="PublicMethod\LogManager.cs" />
     <Compile Include="PublicMethod\ModeBusTCPServer.cs" />
     <EmbeddedResource Include="CustomerControl\AutoDataGridControl\AutoDataGridControl.resx">
@@ -111,6 +119,9 @@
     <EmbeddedResource Include="CustomerControl\Button\ButtonSaveGrid.resx">
       <DependentUpon>ButtonSaveGrid.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="CustomerControl\GridViewWithSerialNum\GridViewWithSerialNum.resx">
+      <DependentUpon>GridViewWithSerialNum.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="CustomerControl\PagingControl\PageControl.resx">
       <DependentUpon>PageControl.cs</DependentUpon>
     </EmbeddedResource>