diff --git a/145Test/.vs/145Test/v16/.suo b/145Test/.vs/145Test/v16/.suo
new file mode 100644
index 0000000..7f0d603
Binary files /dev/null and b/145Test/.vs/145Test/v16/.suo differ
diff --git a/145Test/145Test.sln b/145Test/145Test.sln
new file mode 100644
index 0000000..492ed33
--- /dev/null
+++ b/145Test/145Test.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.33927.289
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "145Test", "145Test\145Test.csproj", "{7A170C19-16E4-4F39-A988-6B5DF6E90229}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7A170C19-16E4-4F39-A988-6B5DF6E90229}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A170C19-16E4-4F39-A988-6B5DF6E90229}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A170C19-16E4-4F39-A988-6B5DF6E90229}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7A170C19-16E4-4F39-A988-6B5DF6E90229}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {C2379D53-656D-4151-8411-D2562E3E13A5}
+ EndGlobalSection
+EndGlobal
diff --git a/145Test/145Test/145Test.csproj b/145Test/145Test/145Test.csproj
new file mode 100644
index 0000000..35af2ff
--- /dev/null
+++ b/145Test/145Test/145Test.csproj
@@ -0,0 +1,83 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7A170C19-16E4-4F39-A988-6B5DF6E90229}
+ WinExe
+ _145Test
+ 145Test
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.cs
+
+
+
+
+ Form1.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/145Test/145Test/App.config b/145Test/145Test/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/145Test/145Test/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/145Test/145Test/Form1.Designer.cs b/145Test/145Test/Form1.Designer.cs
new file mode 100644
index 0000000..edc1afa
--- /dev/null
+++ b/145Test/145Test/Form1.Designer.cs
@@ -0,0 +1,411 @@
+
+namespace _145Test
+{
+ partial class Form1
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows 窗体设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.txtIP = new System.Windows.Forms.TextBox();
+ this.txtPort = new System.Windows.Forms.TextBox();
+ this.btnConnect = new System.Windows.Forms.Button();
+ this.btnDisconnect = new System.Windows.Forms.Button();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.rtbData = new System.Windows.Forms.RichTextBox();
+ this.btnClear = new System.Windows.Forms.Button();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.chkCycleGet = new System.Windows.Forms.CheckBox();
+ this.txtInterval = new System.Windows.Forms.TextBox();
+ this.btnGetData = new System.Windows.Forms.Button();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.rtbSend = new System.Windows.Forms.RichTextBox();
+ this.timerGetData = new System.Windows.Forms.Timer(this.components);
+ this.groupBox4 = new System.Windows.Forms.GroupBox();
+ this.groupBox5 = new System.Windows.Forms.GroupBox();
+ this.rdoCloseLine = new System.Windows.Forms.RadioButton();
+ this.rdoOpenLine = new System.Windows.Forms.RadioButton();
+ this.btnSet = new System.Windows.Forms.Button();
+ this.cmbNum = new System.Windows.Forms.ComboBox();
+ this.cmbChooseLine = new System.Windows.Forms.ComboBox();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.groupBox3.SuspendLayout();
+ this.groupBox4.SuspendLayout();
+ this.groupBox5.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(39, 50);
+ this.label1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(34, 23);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "IP:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(39, 110);
+ this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(51, 23);
+ this.label2.TabIndex = 1;
+ this.label2.Text = "Port:";
+ //
+ // txtIP
+ //
+ this.txtIP.Location = new System.Drawing.Point(117, 41);
+ this.txtIP.Name = "txtIP";
+ this.txtIP.Size = new System.Drawing.Size(175, 32);
+ this.txtIP.TabIndex = 2;
+ //
+ // txtPort
+ //
+ this.txtPort.Location = new System.Drawing.Point(117, 101);
+ this.txtPort.Name = "txtPort";
+ this.txtPort.Size = new System.Drawing.Size(175, 32);
+ this.txtPort.TabIndex = 3;
+ this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress);
+ //
+ // btnConnect
+ //
+ this.btnConnect.Location = new System.Drawing.Point(32, 164);
+ this.btnConnect.Name = "btnConnect";
+ this.btnConnect.Size = new System.Drawing.Size(105, 46);
+ this.btnConnect.TabIndex = 4;
+ this.btnConnect.Text = "连接";
+ this.btnConnect.UseVisualStyleBackColor = true;
+ this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
+ //
+ // btnDisconnect
+ //
+ this.btnDisconnect.Location = new System.Drawing.Point(204, 164);
+ this.btnDisconnect.Name = "btnDisconnect";
+ this.btnDisconnect.Size = new System.Drawing.Size(103, 46);
+ this.btnDisconnect.TabIndex = 5;
+ this.btnDisconnect.Text = "断开";
+ this.btnDisconnect.UseVisualStyleBackColor = true;
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.rtbData);
+ this.groupBox1.Controls.Add(this.btnClear);
+ this.groupBox1.Location = new System.Drawing.Point(706, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(349, 444);
+ this.groupBox1.TabIndex = 6;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "数据展示";
+ //
+ // rtbData
+ //
+ this.rtbData.Location = new System.Drawing.Point(6, 79);
+ this.rtbData.Name = "rtbData";
+ this.rtbData.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
+ this.rtbData.Size = new System.Drawing.Size(337, 359);
+ this.rtbData.TabIndex = 7;
+ this.rtbData.Text = "";
+ //
+ // btnClear
+ //
+ this.btnClear.Location = new System.Drawing.Point(240, 27);
+ this.btnClear.Name = "btnClear";
+ this.btnClear.Size = new System.Drawing.Size(103, 46);
+ this.btnClear.TabIndex = 6;
+ this.btnClear.Text = "清空";
+ this.btnClear.UseVisualStyleBackColor = true;
+ this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.label1);
+ this.groupBox2.Controls.Add(this.label2);
+ this.groupBox2.Controls.Add(this.btnDisconnect);
+ this.groupBox2.Controls.Add(this.txtIP);
+ this.groupBox2.Controls.Add(this.btnConnect);
+ this.groupBox2.Controls.Add(this.txtPort);
+ this.groupBox2.Location = new System.Drawing.Point(12, 12);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(341, 227);
+ this.groupBox2.TabIndex = 7;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "建立连接";
+ //
+ // groupBox3
+ //
+ this.groupBox3.Controls.Add(this.cmbNum);
+ this.groupBox3.Controls.Add(this.rtbSend);
+ this.groupBox3.Controls.Add(this.label5);
+ this.groupBox3.Controls.Add(this.label4);
+ this.groupBox3.Controls.Add(this.label6);
+ this.groupBox3.Controls.Add(this.label3);
+ this.groupBox3.Controls.Add(this.chkCycleGet);
+ this.groupBox3.Controls.Add(this.txtInterval);
+ this.groupBox3.Controls.Add(this.btnGetData);
+ this.groupBox3.Location = new System.Drawing.Point(359, 12);
+ this.groupBox3.Name = "groupBox3";
+ this.groupBox3.Size = new System.Drawing.Size(341, 444);
+ this.groupBox3.TabIndex = 8;
+ this.groupBox3.TabStop = false;
+ this.groupBox3.Text = "数据获取";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(302, 396);
+ this.label4.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(16, 23);
+ this.label4.TabIndex = 6;
+ this.label4.Text = "s";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(28, 396);
+ this.label3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(99, 23);
+ this.label3.TabIndex = 6;
+ this.label3.Text = "时间间隔:";
+ //
+ // chkCycleGet
+ //
+ this.chkCycleGet.AutoSize = true;
+ this.chkCycleGet.Location = new System.Drawing.Point(32, 347);
+ this.chkCycleGet.Name = "chkCycleGet";
+ this.chkCycleGet.Size = new System.Drawing.Size(113, 27);
+ this.chkCycleGet.TabIndex = 9;
+ this.chkCycleGet.Text = "周期获取";
+ this.chkCycleGet.UseVisualStyleBackColor = true;
+ this.chkCycleGet.CheckedChanged += new System.EventHandler(this.chkCycleGet_CheckedChanged);
+ //
+ // txtInterval
+ //
+ this.txtInterval.Location = new System.Drawing.Point(148, 387);
+ this.txtInterval.Name = "txtInterval";
+ this.txtInterval.Size = new System.Drawing.Size(145, 32);
+ this.txtInterval.TabIndex = 7;
+ this.txtInterval.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInterval_KeyPress);
+ //
+ // btnGetData
+ //
+ this.btnGetData.Location = new System.Drawing.Point(102, 248);
+ this.btnGetData.Name = "btnGetData";
+ this.btnGetData.Size = new System.Drawing.Size(154, 46);
+ this.btnGetData.TabIndex = 8;
+ this.btnGetData.Text = "获取数据";
+ this.btnGetData.UseVisualStyleBackColor = true;
+ this.btnGetData.Click += new System.EventHandler(this.btnGetData_Click);
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(40, 67);
+ this.label5.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(78, 23);
+ this.label5.TabIndex = 6;
+ this.label5.Text = "串口号:";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(40, 127);
+ this.label6.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(99, 23);
+ this.label6.TabIndex = 7;
+ this.label6.Text = "发送数据:";
+ //
+ // rtbSend
+ //
+ this.rtbSend.Location = new System.Drawing.Point(158, 124);
+ this.rtbSend.Name = "rtbSend";
+ this.rtbSend.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
+ this.rtbSend.Size = new System.Drawing.Size(135, 103);
+ this.rtbSend.TabIndex = 10;
+ this.rtbSend.Text = "";
+ //
+ // timerGetData
+ //
+ this.timerGetData.Tick += new System.EventHandler(this.timerGetData_Tick);
+ //
+ // groupBox4
+ //
+ this.groupBox4.Controls.Add(this.cmbChooseLine);
+ this.groupBox4.Controls.Add(this.btnSet);
+ this.groupBox4.Controls.Add(this.groupBox5);
+ this.groupBox4.Location = new System.Drawing.Point(12, 245);
+ this.groupBox4.Name = "groupBox4";
+ this.groupBox4.Size = new System.Drawing.Size(341, 211);
+ this.groupBox4.TabIndex = 9;
+ this.groupBox4.TabStop = false;
+ this.groupBox4.Text = "继电控制";
+ //
+ // groupBox5
+ //
+ this.groupBox5.Controls.Add(this.rdoCloseLine);
+ this.groupBox5.Controls.Add(this.rdoOpenLine);
+ this.groupBox5.Location = new System.Drawing.Point(6, 31);
+ this.groupBox5.Name = "groupBox5";
+ this.groupBox5.Size = new System.Drawing.Size(329, 79);
+ this.groupBox5.TabIndex = 0;
+ this.groupBox5.TabStop = false;
+ this.groupBox5.Text = "操作命令";
+ //
+ // rdoCloseLine
+ //
+ this.rdoCloseLine.AutoSize = true;
+ this.rdoCloseLine.Location = new System.Drawing.Point(185, 34);
+ this.rdoCloseLine.Name = "rdoCloseLine";
+ this.rdoCloseLine.Size = new System.Drawing.Size(70, 27);
+ this.rdoCloseLine.TabIndex = 3;
+ this.rdoCloseLine.TabStop = true;
+ this.rdoCloseLine.Text = "关闭";
+ this.rdoCloseLine.UseVisualStyleBackColor = true;
+ //
+ // rdoOpenLine
+ //
+ this.rdoOpenLine.AutoSize = true;
+ this.rdoOpenLine.Location = new System.Drawing.Point(61, 34);
+ this.rdoOpenLine.Name = "rdoOpenLine";
+ this.rdoOpenLine.Size = new System.Drawing.Size(70, 27);
+ this.rdoOpenLine.TabIndex = 2;
+ this.rdoOpenLine.TabStop = true;
+ this.rdoOpenLine.Text = "打开";
+ this.rdoOpenLine.UseVisualStyleBackColor = true;
+ //
+ // btnSet
+ //
+ this.btnSet.Location = new System.Drawing.Point(215, 140);
+ this.btnSet.Name = "btnSet";
+ this.btnSet.Size = new System.Drawing.Size(103, 46);
+ this.btnSet.TabIndex = 6;
+ this.btnSet.Text = "设置";
+ this.btnSet.UseVisualStyleBackColor = true;
+ this.btnSet.Click += new System.EventHandler(this.btnSet_Click);
+ //
+ // cmbNum
+ //
+ this.cmbNum.FormattingEnabled = true;
+ this.cmbNum.Items.AddRange(new object[] {
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7"});
+ this.cmbNum.Location = new System.Drawing.Point(158, 59);
+ this.cmbNum.Name = "cmbNum";
+ this.cmbNum.Size = new System.Drawing.Size(135, 31);
+ this.cmbNum.TabIndex = 11;
+ //
+ // cmbChooseLine
+ //
+ this.cmbChooseLine.FormattingEnabled = true;
+ this.cmbChooseLine.Items.AddRange(new object[] {
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6"});
+ this.cmbChooseLine.Location = new System.Drawing.Point(19, 149);
+ this.cmbChooseLine.Name = "cmbChooseLine";
+ this.cmbChooseLine.Size = new System.Drawing.Size(172, 31);
+ this.cmbChooseLine.TabIndex = 10;
+ this.cmbChooseLine.Text = "请选择线路:";
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 23F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1064, 468);
+ this.Controls.Add(this.groupBox4);
+ this.Controls.Add(this.groupBox3);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.groupBox1);
+ this.Font = new System.Drawing.Font("方正楷体简体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.Margin = new System.Windows.Forms.Padding(6);
+ this.Name = "Form1";
+ this.Text = "145Test";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.groupBox3.ResumeLayout(false);
+ this.groupBox3.PerformLayout();
+ this.groupBox4.ResumeLayout(false);
+ this.groupBox5.ResumeLayout(false);
+ this.groupBox5.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox txtIP;
+ private System.Windows.Forms.TextBox txtPort;
+ private System.Windows.Forms.Button btnConnect;
+ private System.Windows.Forms.Button btnDisconnect;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.RichTextBox rtbData;
+ private System.Windows.Forms.Button btnClear;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.GroupBox groupBox3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.CheckBox chkCycleGet;
+ private System.Windows.Forms.TextBox txtInterval;
+ private System.Windows.Forms.Button btnGetData;
+ private System.Windows.Forms.RichTextBox rtbSend;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Timer timerGetData;
+ private System.Windows.Forms.GroupBox groupBox4;
+ private System.Windows.Forms.Button btnSet;
+ private System.Windows.Forms.GroupBox groupBox5;
+ public System.Windows.Forms.RadioButton rdoCloseLine;
+ public System.Windows.Forms.RadioButton rdoOpenLine;
+ private System.Windows.Forms.ComboBox cmbNum;
+ public System.Windows.Forms.ComboBox cmbChooseLine;
+ }
+}
+
diff --git a/145Test/145Test/Form1.cs b/145Test/145Test/Form1.cs
new file mode 100644
index 0000000..9c653cd
--- /dev/null
+++ b/145Test/145Test/Form1.cs
@@ -0,0 +1,1273 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace _145Test
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+
+ for (int i = 0; i < gDevConnSerialHandleBufLen; i++)
+ {
+ gDevConnSerialHandleBuf[i] = new DevSerialRecvHandle();
+ }
+ }
+
+ public class DevSerialRecvHandle
+ {
+ public const ushort gBuffLen = 2048;
+ public enum DevDataHandleFlag
+ {
+ IDILING,
+ RECVING,
+ HANDLING,
+ }
+ public byte[] gDevConnectRecvHandleBuff = new byte[gBuffLen];
+ public DevDataHandleFlag gDevConnectRecvHandleFlag = DevDataHandleFlag.IDILING;
+ public uint gDevConnectRecvHandleCount = 0;
+ }
+ public DevSerialRecvHandle[] gDevConnSerialHandleBuf = new DevSerialRecvHandle[20];
+
+ //数据分割
+ byte[] gDevConnSerialRecvBuff = new byte[2048 * 40];
+ int gDevConnSerialRecvBuffLen = 2048 * 40;
+ int gDevConnSerialHandleBufLen = 20;
+ int gDevConnSerialRecvBufHandleLocation = 0;
+ int gDevConnSerialRecvBufLocation = 0;
+
+ //校验位计算定义
+ byte g_checkCode;
+ List g_crc8CheckBuffer = new List();
+ List g_checkBuffer = new List();
+
+ //通信定义
+ Socket g_socketWatch;
+ Socket g_socketSend;
+
+ //Socket连接状态
+ bool g_flagReceive;
+ bool waitReConnect = false;
+
+ //流水号定义
+ ushort g_serialDataVictory;
+ ushort g_serialDataNoSupport;
+ ushort g_serialDataError;
+ ushort g_serialSyncTime;
+ ushort g_serialControlTransparentData;
+ ushort g_serialSetLine;
+
+ //终端返回结果
+ int g_terminalResult;
+
+ long g_sqlSyncTime;
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+ txtIP.Text = "192.168.1.238";
+ txtPort.Text = "7503";
+
+ rdoOpenLine.Checked = true;
+ cmbChooseLine.SelectedIndex = 0;
+ cmbNum.SelectedIndex = 0;
+
+ //流水号赋初始值
+ g_serialDataVictory = 0;
+ g_serialDataNoSupport = 0;
+ g_serialDataError = 0;
+ g_serialSyncTime = 0;
+ g_serialControlTransparentData = 0;
+ g_serialSetLine = 0;
+
+ g_timerControlTransparentData.Enabled = true;
+ g_timerControlTransparentData.Interval = 5000;
+ g_timerControlTransparentData.AutoReset = false;
+ g_timerControlTransparentData.Elapsed += new System.Timers.ElapsedEventHandler(methodControlTransparentData);
+
+ g_timerSetLine.Enabled = true;
+ g_timerSetLine.Interval = 20000;
+ g_timerSetLine.AutoReset = false;
+ g_timerSetLine.Elapsed += new System.Timers.ElapsedEventHandler(methodSetCycle);
+ }
+
+ private void btnConnect_Click(object sender, EventArgs e)
+ {
+ txtIP.Enabled = false;
+ txtPort.Enabled = false;
+
+ try
+ {
+ //在服务器端创建一个负责IP地址和端口号的Socket
+ g_socketWatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ IPAddress ip2 = IPAddress.Any;
+ //创建端口号对象
+ Console.WriteLine("创建端口号对象");
+ IPEndPoint point = new IPEndPoint(ip2, int.Parse(txtPort.Text));
+ //监听
+ g_socketWatch.Bind(point);
+ g_socketWatch.Listen(10);
+
+ Thread trdConnect = new Thread(ListenConnect);
+ trdConnect.IsBackground = true;
+ trdConnect.Start(g_socketWatch);
+
+
+ Thread trdDataSplit = new Thread(DataSplit);
+ trdDataSplit.IsBackground = true;
+ trdDataSplit.Start();
+
+ Thread trdDataAnalysis = new Thread(DataAnalysis);
+ trdDataAnalysis.IsBackground = true;
+ trdDataAnalysis.Start();
+
+ btnConnect.Enabled = false;
+ }
+ catch (Exception ee)
+ {
+ Console.WriteLine("LinkError:" + ee.Message);
+ btnConnect.Enabled = true;
+ rtbData.AppendText(DateTime.Now+"\nLinkError:" + ee.Message+"\n");
+ }
+ }
+
+ //连接监听
+ private void ListenConnect(object o)
+ {
+ while (true)
+ {
+ if (g_flagReceive == false || g_socketSend == null || !g_socketSend.Connected)
+ {
+ g_flagReceive = false;
+ bool result = WaitReConnect(txtIP.Text, int.Parse(txtPort.Text));
+ if (result)
+ {
+ g_flagReceive = true;
+
+ Thread thReceive = new Thread(DataReceive);
+ thReceive.IsBackground = true;
+ thReceive.Start();
+ }
+ else
+ {
+ g_flagReceive = false;
+ }
+ }
+ Thread.Sleep(1);
+ }
+ }
+
+ private bool Connect(string ip, int port)
+ {
+ if (g_flagReceive == true)
+ {
+ Console.WriteLine("连接中,无需再连接!");
+ return true;
+ }
+
+ g_socketSend = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ try
+ {
+ g_socketSend.IOControl(IOControlCode.KeepAliveValues, GetKeepAliveData(), null);
+ g_socketSend.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
+
+ IPEndPoint point = new IPEndPoint(IPAddress.Parse(ip), port);
+ g_socketSend.Connect(point);
+
+ g_flagReceive = true;
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("服务器没有开启" + "\r\n");
+ waitReConnect = false;
+ return false;
+ }
+
+ Console.WriteLine("已连接服务器" + "\r\n");
+ waitReConnect = true;
+ g_flagReceive = true;
+ return true;
+ }
+
+ private byte[] GetKeepAliveData()
+ {
+ uint dummy = 0;
+ byte[] inOptionValues = new byte[Marshal.SizeOf(dummy) * 3];
+ BitConverter.GetBytes((uint)1).CopyTo(inOptionValues, 0);
+ BitConverter.GetBytes((uint)3000).CopyTo(inOptionValues, Marshal.SizeOf(dummy));//keep-alive间隔
+ BitConverter.GetBytes((uint)500).CopyTo(inOptionValues, Marshal.SizeOf(dummy) * 2);// 尝试间隔
+ return inOptionValues;
+ }
+
+ private bool WaitReConnect(string ip, int port)
+ {
+ waitReConnect = false;
+ Console.WriteLine("开始进行三次握手!");
+
+ try
+ {
+ //进行三次握手
+ for (int i = 0; i < 3; i++)
+ {
+ waitReConnect = Connect(ip, port);
+ DateTime _time = DateTime.Now;
+ while ((DateTime.Now - _time).TotalSeconds < 5 && !waitReConnect)
+ {
+ Thread.Sleep(1);
+ }
+ //如果连接上了就返回true
+ if (waitReConnect)
+ {
+ Console.WriteLine("连接成功");
+ rtbData.AppendText(DateTime.Now + "\n连接成功!\n");
+
+ return true;
+ }
+
+ if (g_flagReceive == true)
+ {
+ Console.WriteLine("连接中,无需再连接!");
+ return true;
+ }
+
+ Console.WriteLine("超时5秒重连!");
+ rtbData.AppendText(DateTime.Now + "\n超时5秒重连!\n");
+
+ g_flagReceive = false;
+ g_socketSend = null;
+ }
+ Console.WriteLine("3次都没有超时重连成功");
+
+ g_flagReceive = false;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
+
+ return false;
+ }
+
+ public void ConnectDispose()
+ {
+ g_flagReceive = false;
+
+ Console.WriteLine("通信连接已断开!");
+ rtbData.AppendText(DateTime.Now + "\n通信连接已断开!\n");
+
+ if (g_socketSend == null)
+ {
+ return;
+ }
+
+ if (g_socketSend.Connected)
+ {
+ g_socketSend.Close();
+ g_socketSend.Dispose();
+ }
+
+ btnConnect.Enabled = true;
+ }
+
+ //数据接收
+ private void DataReceive(object o)
+ {
+ byte[] byteRead1;
+ int number = 0;
+ try
+ {
+ while (true)
+ {
+ byteRead1 = new byte[g_socketSend.ReceiveBufferSize];
+ number = g_socketSend.Receive(byteRead1);
+
+ byte[] byteRead = new byte[number];
+ for (int i = 0; i < number; i++)
+ {
+ byteRead[i] = byteRead1[i];
+
+ gDevConnSerialRecvBuff[gDevConnSerialRecvBufLocation] = byteRead1[i];
+ gDevConnSerialRecvBufLocation++;
+ gDevConnSerialRecvBufLocation %= (40 * 2048);
+ }
+
+ //rtbData.AppendText(DateTime.Now + "\n接收原始数据:" + BitConverter.ToString(byteRead)+"\n");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("DataReceive:" + ex.Message);
+ ConnectDispose();
+ }
+ }
+
+ public void DataSplit()
+ {
+ int i;
+ while (true)
+ {
+ if (gDevConnSerialRecvBufHandleLocation == gDevConnSerialRecvBufLocation)
+ {
+ Thread.Sleep(1); // 无数据处理时,进入睡眠态,以防止过多的占用CPU
+ continue;
+ }
+ if (gDevConnSerialRecvBuff[gDevConnSerialRecvBufHandleLocation] == 0x7f)
+ {
+ for (i = 0; i < gDevConnSerialHandleBufLen; i++)
+ {
+ if (gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag == DevSerialRecvHandle.DevDataHandleFlag.RECVING)
+ {
+ if (gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount < 18)
+ { // 18为数据包最小单位长度
+ /* 该帧数据错误,将该帧数据变成空闲态,并清空内部长度 */
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag = DevSerialRecvHandle.DevDataHandleFlag.IDILING;
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount = 0;
+ break;
+ }
+ else
+ {
+ /* 将数据保存在帧数据中,表示一帧数据的完成 */
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleBuff[gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount] = gDevConnSerialRecvBuff[gDevConnSerialRecvBufHandleLocation];
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount++;
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag = DevSerialRecvHandle.DevDataHandleFlag.HANDLING;
+ break;
+ }
+ }
+ }
+ if ((i < gDevConnSerialHandleBufLen) && (gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag == DevSerialRecvHandle.DevDataHandleFlag.HANDLING))
+ {
+ gDevConnSerialRecvBufHandleLocation++; // 数据处理完成的跳出之一,因此该字节处理完成,且为完成一帧数据获取的跳出
+ gDevConnSerialRecvBufHandleLocation = gDevConnSerialRecvBufHandleLocation % gDevConnSerialRecvBuffLen;
+ continue;
+ }
+ for (i = 0; i < gDevConnSerialHandleBufLen; i++)
+ {
+ /* 上面的逻辑排除了接收态,所以只剩空闲态 */
+ if (gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag == DevSerialRecvHandle.DevDataHandleFlag.IDILING)
+ {
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleBuff[gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount] = gDevConnSerialRecvBuff[gDevConnSerialRecvBufHandleLocation];
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount++;
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount = gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount % DevSerialRecvHandle.gBuffLen;
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag = DevSerialRecvHandle.DevDataHandleFlag.RECVING;
+ break;
+ }
+ }
+ /* 如果没有空闲态,则进行提示输出 */
+ if (i >= gDevConnSerialHandleBufLen)
+ {
+ //TipsTextBox.AppendText(DateTime.Now.ToString() + ":\r\n" + "接收内存不足\r\n");
+ }
+ }
+ else
+ {
+ for (i = 0; i < gDevConnSerialHandleBufLen; i++)
+ {
+ if (gDevConnSerialHandleBuf[i].gDevConnectRecvHandleFlag == DevSerialRecvHandle.DevDataHandleFlag.RECVING)
+ {
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleBuff[gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount] = gDevConnSerialRecvBuff[gDevConnSerialRecvBufHandleLocation];
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount++;
+ gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount = gDevConnSerialHandleBuf[i].gDevConnectRecvHandleCount % DevSerialRecvHandle.gBuffLen;
+ break;
+ }
+ }
+ }
+ gDevConnSerialRecvBufHandleLocation++; // 数据处理完成的跳出之一,因此该字节处理完成
+ gDevConnSerialRecvBufHandleLocation = gDevConnSerialRecvBufHandleLocation % gDevConnSerialRecvBuffLen;
+ }
+ }
+
+ private void DataAnalysis()
+ {
+ while (true)
+ {
+ int k;
+ List data = new List();
+ for (int ii = 0; ii < gDevConnSerialHandleBufLen; ii++)
+ {
+ if (gDevConnSerialHandleBuf[ii].gDevConnectRecvHandleFlag == DevSerialRecvHandle.DevDataHandleFlag.HANDLING)
+ {
+ data.Clear();
+ for (k = 0; k < gDevConnSerialHandleBuf[ii].gDevConnectRecvHandleCount; k++)
+ {
+ data.Add(gDevConnSerialHandleBuf[ii].gDevConnectRecvHandleBuff[k]);
+ }
+ byte[] newDataTemp = data.ToArray();
+
+ gDevConnSerialHandleBuf[ii].gDevConnectRecvHandleCount = 0;
+ gDevConnSerialHandleBuf[ii].gDevConnectRecvHandleFlag = DevSerialRecvHandle.DevDataHandleFlag.IDILING;
+
+ Console.WriteLine(BitConverter.ToString(newDataTemp));
+ //EveryDayLog.Write("接收分割数据:" + BitConverter.ToString(newDataTemp));
+
+ try
+ {
+ //数据处理
+ if (newDataTemp.Length > 18)
+ {
+ #region 转义
+ int j = 0;
+ for (int i = 0; i < newDataTemp.Length; i++)
+ {
+ if (newDataTemp[i] == 0x7e && newDataTemp[i + 1] == 0x01)
+ {
+ newDataTemp[j] = 0x7e;
+ i++;
+ }
+ else if (newDataTemp[i] == 0x7e && newDataTemp[i + 1] == 0x02)
+ {
+ newDataTemp[j] = 0x7f;
+ i++;
+ }
+ else
+ {
+ newDataTemp[j] = newDataTemp[i];
+ }
+
+ j++;
+ }
+
+ byte[] dataTemp = new byte[j];
+ for (int i = 0; i < j; i++)
+ {
+ dataTemp[i] = newDataTemp[i];
+ }
+ #endregion
+
+ byte newCheckCode;
+ g_checkBuffer.Clear();
+
+ //进行CRC校验,判断消息是否错误
+ for (int i = 1; i < dataTemp.Length - 2; i++)
+ {
+ g_checkBuffer.Add(dataTemp[i]);
+ }
+ newCheckCode = CRC(g_checkBuffer.ToArray());
+
+ if (newCheckCode == dataTemp[dataTemp.Length - 2]) //CRC校验通过
+ {
+ //判断终端设备类型或终端设备id是否存在
+ if (dataTemp[3] != 0x00 || dataTemp[4] != 0x00 || dataTemp[5] != 0x00 || dataTemp[6] != 0xc8 || dataTemp[7] != 0x00 || dataTemp[8] != 0x00 || dataTemp[9] != 0x00 || dataTemp[10] != 0x02)
+ {
+ //终端设备类型或终端设备id不存在
+ //平台通用应答——不支持
+ Console.WriteLine("终端设备类型或终端设备id不存在!");
+ TerminalAnswerUnsup(new byte[] { dataTemp[1], dataTemp[2] }, new byte[2] { dataTemp[15], dataTemp[16] });
+ }
+ else
+ {
+ //终端通用应答
+ if (dataTemp[1] == 0x00 && dataTemp[2] == 0x00)
+ {
+ //平台接收心跳
+ if (dataTemp[19] == 0x80 && dataTemp[20] == 0x01)
+ {
+ Console.WriteLine("接收到心跳数据!");
+ }
+
+ //时间同步
+ if (dataTemp[19] == 0x80 && dataTemp[20] == 0x02)
+ {
+ g_terminalResult = dataTemp[21];
+ Console.WriteLine("时间同步结果为:" + g_terminalResult + "/" + DateTime.Now);
+ }
+
+ //平台请求透传数据
+ if (dataTemp[19] == 0x80 && dataTemp[20] == 0x03)
+ {
+ g_terminalResult = dataTemp[21];
+ g_flagControlTransparentData = true;
+ g_timerControlTransparentData.Stop();
+
+ Console.WriteLine("请求透传数据结果为:" + g_terminalResult + "/" + DateTime.Now);
+ }
+ }
+
+ //接收时间同步
+ if (dataTemp[1] == 0x00 && dataTemp[2] == 0x02)
+ {
+ g_messageId[0] = 0x80;
+ g_messageId[1] = 0x02;
+
+ //消息体流水号
+ byte[] messageBodySerialNumbeReturnSyncTime = new byte[2];
+ messageBodySerialNumbeReturnSyncTime[0] = (byte)((g_serialSyncTime & 0xFF00) >> 8);
+ messageBodySerialNumbeReturnSyncTime[1] = (byte)((g_serialSyncTime & 0x00FF));
+
+ //消息体
+ g_sqlSyncTime = Convert.ToInt64(DateTime.Now.ToString("yyyyMMddHHmmss"));
+ ulong datetime = (ulong)g_sqlSyncTime;
+ byte[] time = new byte[8];
+ time[0] = (byte)((byte)(datetime >> 56) & 0xff);
+ time[1] = (byte)((byte)(datetime >> 48) & 0xff);
+ time[2] = (byte)((byte)(datetime >> 40) & 0xff);
+ time[3] = (byte)((byte)(datetime >> 32) & 0xff);
+ time[4] = (byte)((byte)(datetime >> 24) & 0xff);
+ time[5] = (byte)((byte)(datetime >> 16) & 0xff);
+ time[6] = (byte)((byte)(datetime >> 8) & 0xff);
+ time[7] = (byte)((byte)datetime & 0xff);
+
+ //消息体属性
+ ushort datalen = (ushort)(time.Length);
+ g_messageBodyProperty = Property(datalen);
+
+ //校验码
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.AddRange(g_messageId);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentType);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentId);
+ g_crc8CheckBuffer.AddRange(g_messageBodyProperty);
+ g_crc8CheckBuffer.AddRange(g_versionNumber);
+ g_crc8CheckBuffer.AddRange(messageBodySerialNumbeReturnSyncTime);
+ g_crc8CheckBuffer.AddRange(time);
+ g_checkCode = CRC(g_crc8CheckBuffer.ToArray());
+
+ List buffer = Transform(g_crc8CheckBuffer, g_checkCode, g_flagBit);
+
+ try
+ {
+ if (g_flagReceive == true)
+ {
+ //通过IP地址找到对应的Socket
+ g_socketSend.Send(buffer.ToArray());
+
+ Console.WriteLine(BitConverter.ToString(buffer.ToArray()));
+
+ //流水号+1
+ g_serialSyncTime++;
+ }
+ else
+ {
+ Console.WriteLine("连接已断开!");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("ReturnSyncTimeError:" + ex.ToString());
+ g_socketSend.Close();
+ g_flagReceive = false;
+ ConnectDispose();
+ }
+ }
+
+ //接收透传数据
+ if (dataTemp[1] == 0x00 && dataTemp[2] == 0x03)
+ {
+ string g_sqlDeviceName = "透传数据";
+ string acquisitionInterface;
+ if (dataTemp[17] == 0x00)
+ {
+ acquisitionInterface = "UART";
+ }
+ else if (dataTemp[17] == 0x01)
+ {
+ acquisitionInterface = "SPI";
+ }
+ else if (dataTemp[17] == 0x02)
+ {
+ acquisitionInterface = "IIC";
+ }
+ else if (dataTemp[17] == 0x03)
+ {
+ acquisitionInterface = "CAN";
+ }
+ else if (dataTemp[17] == 0x04)
+ {
+ acquisitionInterface = "ETH";
+ }
+ else
+ {
+ acquisitionInterface = "ADC";
+ }
+
+ int interfaceNumber = dataTemp[18];
+ int spaceNum = 0;
+
+ string transparentTransmissionData = BitConverter.ToString(dataTemp, 19, dataTemp.Length - 21);
+ string[] transparentTransmissionData1 = transparentTransmissionData.Split('-');
+ string transparentTransmissionData2 = "";
+ for (int i = 0; i < transparentTransmissionData1.Length; i++)
+ {
+ transparentTransmissionData2 += transparentTransmissionData1[i];
+ }
+ Console.WriteLine(transparentTransmissionData1.Length);
+ Console.WriteLine(spaceNum);
+ Console.WriteLine("设备名称:" + g_sqlDeviceName + "\r" + "采集接口:" + acquisitionInterface + "\r" + "接口号:" + interfaceNumber + "\r" + "透传数据:" + transparentTransmissionData2);
+ rtbData.AppendText(DateTime.Now + "\n设备名称:" + g_sqlDeviceName + "\n采集接口:" + acquisitionInterface + "\n接口号:" + interfaceNumber + "\n透传数据:" + transparentTransmissionData2 + "\n");
+
+ //平台通用应答
+ TerminalAnswerVic(new byte[2] { dataTemp[1], dataTemp[2] }, new byte[2] { dataTemp[15], dataTemp[16] });
+ }
+ }
+ }
+ else
+ {
+ //CRC校验未通过,平台通用应答回复消息错误
+ Console.WriteLine("CRC校验未通过!");
+ TerminalAnswerErr(new byte[2] { dataTemp[1], dataTemp[2] }, new byte[2] { dataTemp[15], dataTemp[16] });
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.Write("解析数据出错:" + ex.Message);
+ }
+ }
+ }
+ Thread.Sleep(1);
+ }
+ }
+
+
+ #region 平台通用应答合集
+ private void TerminalAnswerVic(byte[] messageId, byte[] serialNumber)
+ {
+ messageId[0] = 0x80;
+ messageId[1] = 0x00;
+
+ //消息体流水号
+ byte[] messageBodySerialNumbeDataReturnVictory = new byte[2];
+ messageBodySerialNumbeDataReturnVictory[0] = (byte)((g_serialDataVictory & 0xFF00) >> 8);
+ messageBodySerialNumbeDataReturnVictory[1] = (byte)((g_serialDataVictory & 0x00FF));
+
+ //消息体
+ byte[] messageBodyTerSerial = new byte[2];
+ messageBodyTerSerial[0] = serialNumber[0];
+ messageBodyTerSerial[1] = serialNumber[1];
+ byte[] messageBodyTerId = new byte[2];
+ messageBodyTerId[0] = messageId[0];
+ messageBodyTerId[1] = messageId[1];
+ byte messageBodyResult = 0x00;
+
+ //消息体属性
+ ushort datalen = (ushort)(messageBodyTerSerial.Length + messageBodyTerId.Length + 1);
+ g_messageBodyProperty = Property(datalen);
+
+ //校验码
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.AddRange(messageId);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentType);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentId);
+ g_crc8CheckBuffer.AddRange(g_messageBodyProperty);
+ g_crc8CheckBuffer.AddRange(g_versionNumber);
+ g_crc8CheckBuffer.AddRange(messageBodySerialNumbeDataReturnVictory);
+ g_crc8CheckBuffer.AddRange(messageBodyTerSerial);
+ g_crc8CheckBuffer.AddRange(messageBodyTerId);
+ g_crc8CheckBuffer.Add(messageBodyResult);
+ g_checkCode = CRC(g_crc8CheckBuffer.ToArray());
+
+ List buffer = Transform(g_crc8CheckBuffer, g_checkCode, g_flagBit);
+
+ try
+ {
+ if (g_flagReceive == true)
+ {
+ //通过IP地址找到对应的Socket
+ g_socketSend.Send(buffer.ToArray());
+
+ //Console.WriteLine(BitConverter.ToString(buffer.ToArray()));
+
+ //流水号+1
+ g_serialDataVictory++;
+ }
+ else
+ {
+ Console.WriteLine("连接已断开!");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("DataReturnVictoryError:" + ex.ToString());
+
+ g_flagReceive = false;
+ ConnectDispose();
+ }
+ }
+
+ private void TerminalAnswerErr(byte[] messageId, byte[] serialNumber)
+ {
+ Thread.Sleep(100);
+
+ messageId[0] = 0x80;
+ messageId[1] = 0x00;
+
+ //消息体流水号
+ byte[] messageBodySerialNumberDataReturnMessError = new byte[2];
+ messageBodySerialNumberDataReturnMessError[0] = (byte)((g_serialDataError & 0xFF00) >> 8);
+ messageBodySerialNumberDataReturnMessError[1] = (byte)((g_serialDataError & 0x00FF));
+
+ //消息体
+ byte[] messageBodyTerSerial = new byte[2];
+ messageBodyTerSerial[0] = serialNumber[0];
+ messageBodyTerSerial[1] = serialNumber[1];
+ byte[] messageBodyTerId = new byte[2];
+ messageBodyTerId[0] = messageId[0];
+ messageBodyTerId[1] = messageId[1];
+ byte messageBodyResult = 0x02; //消息错误
+
+ //消息体属性
+ ushort datalen = (ushort)(messageBodyTerSerial.Length + messageBodyTerId.Length + 1);
+ g_messageBodyProperty = Property(datalen);
+
+ //校验码
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.AddRange(messageId);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentType);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentId);
+ g_crc8CheckBuffer.AddRange(g_messageBodyProperty);
+ g_crc8CheckBuffer.AddRange(g_versionNumber);
+ g_crc8CheckBuffer.AddRange(messageBodySerialNumberDataReturnMessError);
+ g_crc8CheckBuffer.AddRange(messageBodyTerSerial);
+ g_crc8CheckBuffer.AddRange(messageBodyTerId);
+ g_crc8CheckBuffer.Add(messageBodyResult);
+ g_checkCode = CRC(g_crc8CheckBuffer.ToArray());
+
+ List buffer = Transform(g_crc8CheckBuffer, g_checkCode, g_flagBit);
+
+ try
+ {
+ if (g_flagReceive == true)
+ {
+ //通过IP地址找到对应的Socket
+ g_socketSend.Send(buffer.ToArray());
+
+ //流水号+1
+ g_serialDataError++;
+ }
+ else
+ {
+ Console.WriteLine("连接已断开!");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("DataReturnMessErrorError:" + ex.ToString());
+
+ g_flagReceive = false;
+ ConnectDispose();
+ }
+ }
+
+ private void TerminalAnswerUnsup(byte[] messageId, byte[] serialNumber)
+ {
+ Thread.Sleep(100);
+
+ messageId[0] = 0x80;
+ messageId[1] = 0x00;
+
+ //消息体流水号
+ byte[] messageBodySerialNumberDataReturnNoSupport = new byte[2];
+ messageBodySerialNumberDataReturnNoSupport[0] = (byte)((g_serialDataNoSupport & 0xFF00) >> 8);
+ messageBodySerialNumberDataReturnNoSupport[1] = (byte)(g_serialDataNoSupport & 0x00FF);
+
+ //消息体
+ byte[] messageBodyTerSerial = new byte[2];
+ messageBodyTerSerial[0] = serialNumber[0];
+ messageBodyTerSerial[1] = serialNumber[1];
+
+ byte[] messageBodyTerId = new byte[2];
+ messageBodyTerId[0] = messageId[0];
+ messageBodyTerId[1] = messageId[1];
+
+ byte messageBodyResult = 0x03; //不支持
+
+ //消息体属性
+ ushort datalen = (ushort)(messageBodyTerSerial.Length + messageBodyTerId.Length + 1);
+ g_messageBodyProperty = Property(datalen);
+
+ //校验码
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.AddRange(messageId);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentType);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentId);
+ g_crc8CheckBuffer.AddRange(g_messageBodyProperty);
+ g_crc8CheckBuffer.AddRange(g_versionNumber);
+ g_crc8CheckBuffer.AddRange(messageBodySerialNumberDataReturnNoSupport);
+ g_crc8CheckBuffer.AddRange(messageBodyTerSerial);
+ g_crc8CheckBuffer.AddRange(messageBodyTerId);
+ g_crc8CheckBuffer.Add(messageBodyResult);
+ g_checkCode = CRC(g_crc8CheckBuffer.ToArray());
+
+ List buffer = Transform(g_crc8CheckBuffer, g_checkCode, g_flagBit);
+
+ try
+ {
+ if (g_flagReceive == true)
+ {
+ //通过IP地址找到对应的Socket
+ g_socketSend.Send(buffer.ToArray());
+
+ //Console.WriteLine(BitConverter.ToString(buffer.ToArray()));
+
+ //流水号+1
+ g_serialDataNoSupport++;
+ }
+ else
+ {
+ Console.WriteLine("连接已断开!");
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("DataReturnNoSupportError:" + ex.ToString());
+
+ g_flagReceive = false;
+ ConnectDispose();
+ }
+ }
+ #endregion
+
+
+ #region CRC校验
+ ///
+ /// CRC8位校验表
+ ///
+ private static byte[] CRC8Table = new byte[]
+ {
+ 0,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65,
+ 157,195,33,127,252,162,64,30, 95,1,227,189,62,96,130,220,
+ 35,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98,
+ 190,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255,
+ 70,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7,
+ 219,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154,
+ 101,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36,
+ 248,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185,
+ 140,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205,
+ 17,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80,
+ 175,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238,
+ 50,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115,
+ 202,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139,
+ 87,9,235,181,54,104,138,212,149,203, 41,119,244,170,72,22,
+ 233,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168,
+ 116,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53
+ };
+
+ public static byte CRC(byte[] buffer)
+ {
+ return CRC(buffer, 0, buffer.Length);
+ }
+
+ public static byte CRC(byte[] buffer, int off, int len)
+ {
+ byte crc = 0;
+ if (buffer == null)
+ {
+ throw new ArgumentNullException("buffer");
+ }
+ if (off < 0 || len < 0 || off + len > buffer.Length)
+ {
+ throw new ArgumentOutOfRangeException();
+ }
+
+ for (int i = off; i < len; i++)
+ {
+ crc = CRC8Table[crc ^ buffer[i]];
+ }
+ return crc;
+ }
+ #endregion
+
+
+ #region 转义
+ public static List Transform(List tBuffer, byte code, byte flag)
+ {
+ int j = 0;
+ tBuffer.Add(code);
+ int length = tBuffer.ToArray().Length;
+ byte[] newAnswer = tBuffer.ToArray();
+ for (int i = 0; i < length; i++)
+ {
+ if (newAnswer[i] == 0x7e || newAnswer[i] == 0x7f)
+ {
+ j++;
+ }
+ }
+ byte[] newSendBuffer = new byte[length + j];
+ for (int i = 0; i < length; i++)
+ {
+ newSendBuffer[i] = newAnswer[i];
+ }
+ for (int i = 0; i < length + j; i++)
+ {
+ if (newSendBuffer[i] == 0x7e)
+ {
+ for (int k = length + j - 1; k > i + 1; k--)
+ {
+ newSendBuffer[k] = newSendBuffer[k - 1];
+ }
+ newSendBuffer[i + 1] = 0x01;
+ }
+ if (newSendBuffer[i] == 0x7f)
+ {
+ newSendBuffer[i] = 0x7e;
+ for (int k = length + j - 1; k > i + 1; k--)
+ {
+ newSendBuffer[k] = newSendBuffer[k - 1];
+ }
+ newSendBuffer[i + 1] = 0x02;
+ }
+ }
+ List buffer = new List();
+ buffer.Add(flag);
+ for (int i = 0; i < newSendBuffer.Length; i++)
+ {
+ buffer.Add(newSendBuffer[i]);
+ }
+ buffer.Add(flag);
+ return buffer;
+ }
+ #endregion
+
+
+ //定义指令
+ byte g_flagBit = 0x7f;
+ byte[] g_messageId = new byte[2];
+ byte[] g_terminalEquipmentType = new byte[4] { 0x00, 0x00, 0x00, 0xc8 };
+ byte[] g_terminalEquipmentId = new byte[4] { 0x00, 0x00, 0x00, 0x02 };
+ byte[] g_messageBodyProperty = new byte[2];
+ byte[] g_versionNumber = new byte[2] { 0x00, 0x01 };
+
+ //消息体属性
+ byte[] Property(ushort length)
+ {
+ length |= 0x0c00;
+ byte[] BodyProperty = new byte[2];
+ BodyProperty[0] = (byte)((length & 0xff00) >> 8);
+ BodyProperty[1] = (byte)(length & 0x00ff);
+ return BodyProperty;
+ }
+
+
+ #region 定时器配置
+ public bool g_flagControlTransparentData = true;
+
+ public System.Timers.Timer g_timerControlTransparentData = new System.Timers.Timer();
+
+ private void methodControlTransparentData(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ if (g_flagControlTransparentData == false)
+ {
+ Console.WriteLine("下位机未响应,请重新点击发送!");
+ btnGetData.Enabled = true;
+ }
+ }
+ #endregion
+
+
+ private void btnGetData_Click(object sender, EventArgs e)
+ {
+ btnGetData.Enabled = false;
+ g_flagControlTransparentData = false;
+
+ if (g_socketSend == null)
+ {
+ btnGetData.Enabled = true;
+ return;
+ }
+
+ //消息ID
+ g_messageId[0] = 0x80;
+ g_messageId[1] = 0x03;
+
+ //消息体流水号
+ byte[] messageBodySerialNumberControlTransparentData = new byte[2];
+ messageBodySerialNumberControlTransparentData[0] = (byte)((g_serialControlTransparentData & 0xFF00) >> 8);
+ messageBodySerialNumberControlTransparentData[1] = (byte)(g_serialControlTransparentData & 0x00FF);
+
+ //采集接口&接口号
+ byte inter = 0x00; //UART
+
+ byte interNo = (byte)cmbNum.SelectedIndex;
+
+ //指令
+ byte instruction = 0x02;
+
+ //数据
+ if (rtbSend.Text == "")
+ rtbSend.Text = "Requset Data,Num:" + cmbNum.SelectedIndex;
+
+ byte[] controlData = StringToBytes(StringToHex(rtbSend.Text));
+
+ //消息体属性
+ ushort datalen = (ushort)(3+ controlData.Length);
+ g_messageBodyProperty = Property(datalen);
+
+ //校验码
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.AddRange(g_messageId);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentType);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentId);
+ g_crc8CheckBuffer.AddRange(g_messageBodyProperty);
+ g_crc8CheckBuffer.AddRange(g_versionNumber);
+ g_crc8CheckBuffer.AddRange(messageBodySerialNumberControlTransparentData);
+ g_crc8CheckBuffer.Add(inter);
+ g_crc8CheckBuffer.Add(interNo);
+ g_crc8CheckBuffer.Add(instruction);
+ g_crc8CheckBuffer.AddRange(controlData);
+ g_checkCode = CRC(g_crc8CheckBuffer.ToArray());
+
+ List buffer = Transform(g_crc8CheckBuffer, g_checkCode, g_flagBit);
+
+ try
+ {
+ if (g_flagReceive == true)
+ {
+ //通过IP地址找到对应的Socket
+ g_socketSend.Send(buffer.ToArray());
+
+ g_timerControlTransparentData.Start();
+ //流水号+1
+ g_serialControlTransparentData++;
+ }
+ else
+ {
+ Console.WriteLine("连接已断开!");
+ }
+ }
+ catch (Exception ex)
+ {
+ btnGetData.Enabled = true;
+ Console.WriteLine("ControlTransparentDataError:" + ex.ToString());
+
+ g_flagReceive = false;
+ ConnectDispose();
+ }
+ }
+
+ ///
+ /// 普通字符串转16进制
+ /// AB 转 61 62
+ ///
+ ///
+ public static string StringToHex(string data)
+ {
+ byte[] b = Encoding.UTF8.GetBytes(data); ;
+ string result = string.Empty;
+ for (int i = 0; i < b.Length; i++)
+ {
+ result += Convert.ToString(b[i], 16).ToUpper();
+ }
+ return result;
+ }
+
+ ///
+ /// 将字符串形式的多位字节信息转换为对应的字节数组
+ /// ABCD 转 0xAB 0xCD
+ ///
+ ///
+ ///
+ public static byte[] StringToBytes(string s)
+ {
+ string[] str = s.Split(' ');
+ int n = str.Length;
+
+ byte[] cmdBytes = null;
+ int p = 0;
+
+
+ for (int k = 0; k < n; k++)
+ {
+ int sLen = str[k].Length;
+ int bytesLen = sLen / 2;
+ int position = 0;
+ byte[] bytes = new byte[bytesLen];
+ for (int i = 0; i < bytesLen; i++)
+ {
+ string abyte = str[k].Substring(position, 2);
+ bytes[i] = Convert.ToByte(abyte, 16);
+ position += 2;
+ }
+
+ if (position >= 2)
+ {
+ byte[] cmdBytes2 = new byte[p + bytesLen];
+ if (cmdBytes != null)
+ {
+ Array.Copy(cmdBytes, 0, cmdBytes2, 0, p);
+ }
+ Array.Copy(bytes, 0, cmdBytes2, p, bytesLen);
+ cmdBytes = cmdBytes2;
+ p += bytesLen;
+ }
+ }
+
+ return cmdBytes;
+ }
+
+ private void chkCycleGet_CheckedChanged(object sender, EventArgs e)
+ {
+ if(chkCycleGet.Checked)
+ {
+ if(txtInterval.Text=="")
+ {
+ txtInterval.Text = "60";
+ }
+ txtInterval.Enabled = false;
+
+ this.Invoke(new MethodInvoker(delegate
+ {
+ timerGetData.Interval = int.Parse(txtInterval.Text) * 1000;
+ timerGetData.Enabled = true;
+ timerGetData.Start();
+ }));
+ }
+ else
+ {
+ txtInterval.Enabled = true;
+
+ this.Invoke(new MethodInvoker(delegate
+ {
+ timerGetData.Enabled = false;
+ timerGetData.Stop();
+ }));
+ }
+ }
+
+ private void timerGetData_Tick(object sender, EventArgs e)
+ {
+ btnGetData_Click(null, null);
+ }
+
+ #region 定时器设置
+ public System.Timers.Timer g_timerSetLine = new System.Timers.Timer();
+
+ public bool g_flagSetLine = true;
+
+ private void methodSetCycle(object sender, System.Timers.ElapsedEventArgs e)
+ {
+ if (g_flagSetLine == false)
+ {
+ Console.WriteLine("下位机未响应,请重新点击发送!");
+ btnSet.Enabled = true;
+ }
+ }
+ #endregion
+
+ private void btnSet_Click(object sender, EventArgs e)
+ {
+ btnSet.Enabled = false;
+ g_flagSetLine = false;
+
+ if (g_socketSend == null)
+ {
+ btnSet.Enabled = true;
+ return;
+ }
+
+ //消息ID
+ g_messageId[0] = 0x80;
+ g_messageId[1] = 0x0c;
+
+ //消息体流水号
+ byte[] messageBodySerialNumberSetLine = new byte[2];
+ messageBodySerialNumberSetLine[0] = (byte)((g_serialSetLine & 0xFF00) >> 8);
+ messageBodySerialNumberSetLine[1] = (byte)(g_serialSetLine & 0x00FF);
+
+ //消息体
+ byte[] setLineMessageId = new byte[2] { 0x01, 0x01 };
+
+ byte setLineNumber;
+ byte setLineInstruction;
+ byte setLineMode = 0x00;
+ byte[] setLineWorkTime = new byte[4] { 0x00, 0x00, 0x00, 0x00 };
+ byte[] setLineStopTime = new byte[4] { 0x00, 0x00, 0x00, 0x00 };
+ byte[] setLineUploadTime = new byte[4] { 0x00, 0x00, 0x00, 0x00 };
+
+ string state;
+ if (rdoOpenLine.Checked)
+ {
+ setLineInstruction = 0x01;
+ state = "开启";
+ }
+ else
+ {
+ setLineInstruction = 0x00;
+ state = "关闭";
+ }
+
+ setLineNumber = (byte)(cmbChooseLine.SelectedIndex + 1);
+
+ //消息体属性
+ ushort datalen = (ushort)(setLineMessageId.Length + setLineWorkTime.Length + setLineStopTime.Length + setLineUploadTime.Length + 3);
+ g_messageBodyProperty = Property(datalen);
+
+ //校验码
+ g_crc8CheckBuffer.Clear();
+ g_crc8CheckBuffer.AddRange(g_messageId);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentType);
+ g_crc8CheckBuffer.AddRange(g_terminalEquipmentId);
+ g_crc8CheckBuffer.AddRange(g_messageBodyProperty);
+ g_crc8CheckBuffer.AddRange(g_versionNumber);
+ g_crc8CheckBuffer.AddRange(messageBodySerialNumberSetLine);
+ g_crc8CheckBuffer.AddRange(setLineMessageId);
+ g_crc8CheckBuffer.Add(setLineNumber);
+ g_crc8CheckBuffer.Add(setLineInstruction);
+ g_crc8CheckBuffer.Add(setLineMode);
+ g_crc8CheckBuffer.AddRange(setLineWorkTime);
+ g_crc8CheckBuffer.AddRange(setLineStopTime);
+ g_crc8CheckBuffer.AddRange(setLineUploadTime);
+ g_checkCode = CRC(g_crc8CheckBuffer.ToArray());
+
+ List buffer = Transform(g_crc8CheckBuffer, g_checkCode, g_flagBit);
+
+ try
+ {
+ if (g_flagReceive == true)
+ {
+ //通过IP地址找到对应的Socket
+ g_socketSend.Send(buffer.ToArray());
+
+ g_timerSetLine.Start();
+ //流水号+1
+ g_serialSetLine++;
+ }
+ else
+ {
+ Console.WriteLine("连接已断开!");
+ }
+ }
+ catch (Exception ex)
+ {
+ btnSet.Enabled = true;
+ Console.WriteLine("SetLineStateError:" + ex.ToString());
+
+ g_flagReceive = false;
+ ConnectDispose();
+ }
+ }
+
+ private void btnClear_Click(object sender, EventArgs e)
+ {
+ rtbData.Clear();
+ }
+
+ private void txtPort_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
+ {
+ e.Handled = true;
+ }
+ }
+
+ private void txtInterval_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+}
diff --git a/145Test/145Test/Form1.resx b/145Test/145Test/Form1.resx
new file mode 100644
index 0000000..6fc675e
--- /dev/null
+++ b/145Test/145Test/Form1.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/145Test/145Test/Program.cs b/145Test/145Test/Program.cs
new file mode 100644
index 0000000..4ac3acd
--- /dev/null
+++ b/145Test/145Test/Program.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace _145Test
+{
+ static class Program
+ {
+ ///
+ /// 应用程序的主入口点。
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/145Test/145Test/Properties/AssemblyInfo.cs b/145Test/145Test/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..ea19f4f
--- /dev/null
+++ b/145Test/145Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("145Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("145Test")]
+[assembly: AssemblyCopyright("Copyright © 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("7a170c19-16e4-4f39-a988-6b5df6e90229")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/145Test/145Test/Properties/Resources.Designer.cs b/145Test/145Test/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..b49c014
--- /dev/null
+++ b/145Test/145Test/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+
+namespace _145Test.Properties
+{
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("_145Test.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/145Test/145Test/Properties/Resources.resx b/145Test/145Test/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/145Test/145Test/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/145Test/145Test/Properties/Settings.Designer.cs b/145Test/145Test/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..d0ed887
--- /dev/null
+++ b/145Test/145Test/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace _145Test.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/145Test/145Test/Properties/Settings.settings b/145Test/145Test/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/145Test/145Test/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/145Test/145Test/bin/Debug/145Test.exe b/145Test/145Test/bin/Debug/145Test.exe
new file mode 100644
index 0000000..4ee5a1e
Binary files /dev/null and b/145Test/145Test/bin/Debug/145Test.exe differ
diff --git a/145Test/145Test/bin/Debug/145Test.exe.config b/145Test/145Test/bin/Debug/145Test.exe.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/145Test/145Test/bin/Debug/145Test.exe.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/145Test/145Test/bin/Debug/145Test.pdb b/145Test/145Test/bin/Debug/145Test.pdb
new file mode 100644
index 0000000..6fe34a1
Binary files /dev/null and b/145Test/145Test/bin/Debug/145Test.pdb differ
diff --git a/145Test/145Test/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/145Test/145Test/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs
new file mode 100644
index 0000000..3871b18
--- /dev/null
+++ b/145Test/145Test/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs
@@ -0,0 +1,4 @@
+//
+using System;
+using System.Reflection;
+[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
diff --git a/145Test/145Test/obj/Debug/145Test.csproj.AssemblyReference.cache b/145Test/145Test/obj/Debug/145Test.csproj.AssemblyReference.cache
new file mode 100644
index 0000000..30fe406
Binary files /dev/null and b/145Test/145Test/obj/Debug/145Test.csproj.AssemblyReference.cache differ
diff --git a/145Test/145Test/obj/Debug/145Test.csproj.CoreCompileInputs.cache b/145Test/145Test/obj/Debug/145Test.csproj.CoreCompileInputs.cache
new file mode 100644
index 0000000..4a5524a
--- /dev/null
+++ b/145Test/145Test/obj/Debug/145Test.csproj.CoreCompileInputs.cache
@@ -0,0 +1 @@
+8069502011d0681850e57a53d5a1673222f430a6
diff --git a/145Test/145Test/obj/Debug/145Test.csproj.FileListAbsolute.txt b/145Test/145Test/obj/Debug/145Test.csproj.FileListAbsolute.txt
new file mode 100644
index 0000000..78ddbc4
--- /dev/null
+++ b/145Test/145Test/obj/Debug/145Test.csproj.FileListAbsolute.txt
@@ -0,0 +1,10 @@
+F:\Code\145Test\145Test\bin\Debug\145Test.exe.config
+F:\Code\145Test\145Test\bin\Debug\145Test.exe
+F:\Code\145Test\145Test\bin\Debug\145Test.pdb
+F:\Code\145Test\145Test\obj\Debug\145Test.csproj.AssemblyReference.cache
+F:\Code\145Test\145Test\obj\Debug\_145Test.Form1.resources
+F:\Code\145Test\145Test\obj\Debug\_145Test.Properties.Resources.resources
+F:\Code\145Test\145Test\obj\Debug\145Test.csproj.GenerateResource.cache
+F:\Code\145Test\145Test\obj\Debug\145Test.csproj.CoreCompileInputs.cache
+F:\Code\145Test\145Test\obj\Debug\145Test.exe
+F:\Code\145Test\145Test\obj\Debug\145Test.pdb
diff --git a/145Test/145Test/obj/Debug/145Test.csproj.GenerateResource.cache b/145Test/145Test/obj/Debug/145Test.csproj.GenerateResource.cache
new file mode 100644
index 0000000..0f27ca6
Binary files /dev/null and b/145Test/145Test/obj/Debug/145Test.csproj.GenerateResource.cache differ
diff --git a/145Test/145Test/obj/Debug/145Test.exe b/145Test/145Test/obj/Debug/145Test.exe
new file mode 100644
index 0000000..4ee5a1e
Binary files /dev/null and b/145Test/145Test/obj/Debug/145Test.exe differ
diff --git a/145Test/145Test/obj/Debug/145Test.pdb b/145Test/145Test/obj/Debug/145Test.pdb
new file mode 100644
index 0000000..6fe34a1
Binary files /dev/null and b/145Test/145Test/obj/Debug/145Test.pdb differ
diff --git a/145Test/145Test/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/145Test/145Test/obj/Debug/DesignTimeResolveAssemblyReferences.cache
new file mode 100644
index 0000000..f7baf5e
Binary files /dev/null and b/145Test/145Test/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ
diff --git a/145Test/145Test/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/145Test/145Test/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
new file mode 100644
index 0000000..2dc9004
Binary files /dev/null and b/145Test/145Test/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/145Test/145Test/obj/Debug/_145Test.Form1.resources b/145Test/145Test/obj/Debug/_145Test.Form1.resources
new file mode 100644
index 0000000..6c05a97
Binary files /dev/null and b/145Test/145Test/obj/Debug/_145Test.Form1.resources differ
diff --git a/145Test/145Test/obj/Debug/_145Test.Properties.Resources.resources b/145Test/145Test/obj/Debug/_145Test.Properties.Resources.resources
new file mode 100644
index 0000000..6c05a97
Binary files /dev/null and b/145Test/145Test/obj/Debug/_145Test.Properties.Resources.resources differ