Parcourir la source

合并功能界面

callm il y a 3 semaines
Parent
commit
b1c6147eb7

+ 8 - 0
UAS_MES_ZKLH/.workbuddy/memory/2026-09-17.md

@@ -114,3 +114,11 @@
 
 ### 待确认
 - PDF 分支也套用了同样的编号截取规则,若 PDF 文件名规则不同需回退。
+
+### Make_PLCMonitor 与 Make_PartDry 合并(2026-09-22)
+- 按需求"把Make_PLCMonitor和Make_PartDry功能合并,界面也合并",保留 Make_PartDry 作为合并后页面(业务主功能为零件烘烤,PLC温度为辅助),删除 Make_PLCMonitor。
+- Make_PartDry.cs 现包含:SN录入与批次区(StepCode='DRY'、批次前缀'PD'、InsertSN/GenBatchCode/开始/结束烘烤/批次查询)+ PLC区(连接/断开/立即读取/定时轮询/自动重连 TryReconnect、InsertTempLog 写 TEMPLOG、ReadRtuRegisters/ReadTcpRegisters、CalcCRC16)。
+- 关键修复保留:DVP_D_OFFSET=0x1000(D141→0x108D),默认协议 ModbusTCP(rdoTCP.Checked=true),默认 IP 192.168.1.150、端口 502、站号 1、间隔 2 秒、温度小数位 1。
+- Designer 合并布局:grpConnect(PLC连接设置) → grpData(烘烤温度 D141/D142) → grpSN(SN录入与批次) → grpdata2(批次数据 DGV) → lblStatus/OperatResult,ClientSize 1604x1515,Tag="Make!PartDry"。
+- csproj 已移除 Make_PLCMonitor 的 Compile/EmbeddedResource 条目;三个源文件(.cs/.Designer.cs/.resx)已删除。
+- 待办:若 CS$SYSNAVATION 已注册 'Make.Make_PLCMonitor' 菜单,需删除该条;确认 TEMPLOG_SEQ/SINGLEBOARD_SEQ 序列名。

+ 0 - 475
UAS_MES_ZKLH/FunctionCode/Make/Make_PLCMonitor.Designer.cs

@@ -1,475 +0,0 @@
-namespace UAS_MES_NEW.Make
-{
-    partial class Make_PLCMonitor
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.components = new System.ComponentModel.Container();
-            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Make_PLCMonitor));
-            this.grpConnect = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
-            this.lblIp = new System.Windows.Forms.Label();
-            this.ip = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.lblPort = new System.Windows.Forms.Label();
-            this.port = new System.Windows.Forms.NumericUpDown();
-            this.lblUnit = new System.Windows.Forms.Label();
-            this.unitid = new System.Windows.Forms.NumericUpDown();
-            this.lblInterval = new System.Windows.Forms.Label();
-            this.interval = new System.Windows.Forms.NumericUpDown();
-            this.btnConnect = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.btnDisconnect = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.rdoRTU = new System.Windows.Forms.RadioButton();
-            this.rdoTCP = new System.Windows.Forms.RadioButton();
-            this.grpData = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
-            this.lblD141 = new System.Windows.Forms.Label();
-            this.lblD141Value = new System.Windows.Forms.Label();
-            this.lblD142 = new System.Windows.Forms.Label();
-            this.lblD142Value = new System.Windows.Forms.Label();
-            this.lblDecimals = new System.Windows.Forms.Label();
-            this.decimals = new System.Windows.Forms.NumericUpDown();
-            this.btnReadNow = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.lblRecord = new System.Windows.Forms.Label();
-            this.OperatResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
-            this.lblStatus = new System.Windows.Forms.Label();
-            this.timer1 = new System.Windows.Forms.Timer(this.components);
-            this.grpConnect.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.port)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.unitid)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.interval)).BeginInit();
-            this.grpData.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.decimals)).BeginInit();
-            this.SuspendLayout();
-            // 
-            // grpConnect
-            // 
-            this.grpConnect.BorderColor = System.Drawing.Color.Black;
-            this.grpConnect.Controls.Add(this.lblIp);
-            this.grpConnect.Controls.Add(this.ip);
-            this.grpConnect.Controls.Add(this.lblPort);
-            this.grpConnect.Controls.Add(this.port);
-            this.grpConnect.Controls.Add(this.lblUnit);
-            this.grpConnect.Controls.Add(this.unitid);
-            this.grpConnect.Controls.Add(this.lblInterval);
-            this.grpConnect.Controls.Add(this.interval);
-            this.grpConnect.Controls.Add(this.btnConnect);
-            this.grpConnect.Controls.Add(this.btnDisconnect);
-            this.grpConnect.Controls.Add(this.rdoRTU);
-            this.grpConnect.Controls.Add(this.rdoTCP);
-            this.grpConnect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.grpConnect.Location = new System.Drawing.Point(32, 30);
-            this.grpConnect.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.grpConnect.Name = "grpConnect";
-            this.grpConnect.Size = new System.Drawing.Size(1540, 200);
-            this.grpConnect.TabIndex = 0;
-            this.grpConnect.TabStop = false;
-            this.grpConnect.Text = "连接设置(Modbus TCP)";
-            this.grpConnect.TextColor = System.Drawing.Color.Black;
-            // 
-            // lblIp
-            // 
-            this.lblIp.AutoSize = true;
-            this.lblIp.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblIp.Location = new System.Drawing.Point(32, 50);
-            this.lblIp.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblIp.Name = "lblIp";
-            this.lblIp.Size = new System.Drawing.Size(138, 52);
-            this.lblIp.TabIndex = 0;
-            this.lblIp.Text = "IP地址";
-            // 
-            // ip
-            // 
-            this.ip.AllPower = null;
-            this.ip.BackColor = System.Drawing.Color.White;
-            this.ip.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ip.ID = null;
-            this.ip.Location = new System.Drawing.Point(220, 52);
-            this.ip.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.ip.Name = "ip";
-            this.ip.Power = null;
-            this.ip.Size = new System.Drawing.Size(320, 53);
-            this.ip.Str = null;
-            this.ip.Str1 = null;
-            this.ip.Str2 = null;
-            this.ip.TabIndex = 1;
-            // 
-            // lblPort
-            // 
-            this.lblPort.AutoSize = true;
-            this.lblPort.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblPort.Location = new System.Drawing.Point(620, 50);
-            this.lblPort.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblPort.Name = "lblPort";
-            this.lblPort.Size = new System.Drawing.Size(102, 52);
-            this.lblPort.TabIndex = 2;
-            this.lblPort.Text = "端口";
-            // 
-            // port
-            // 
-            this.port.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.port.Location = new System.Drawing.Point(730, 52);
-            this.port.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.port.Maximum = new decimal(new int[] {
-            65535,
-            0,
-            0,
-            0});
-            this.port.Name = "port";
-            this.port.Size = new System.Drawing.Size(160, 53);
-            this.port.TabIndex = 3;
-            // 
-            // lblUnit
-            // 
-            this.lblUnit.AutoSize = true;
-            this.lblUnit.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblUnit.Location = new System.Drawing.Point(970, 50);
-            this.lblUnit.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblUnit.Name = "lblUnit";
-            this.lblUnit.Size = new System.Drawing.Size(102, 52);
-            this.lblUnit.TabIndex = 4;
-            this.lblUnit.Text = "站号";
-            // 
-            // unitid
-            // 
-            this.unitid.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.unitid.Location = new System.Drawing.Point(1080, 52);
-            this.unitid.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.unitid.Maximum = new decimal(new int[] {
-            247,
-            0,
-            0,
-            0});
-            this.unitid.Name = "unitid";
-            this.unitid.Size = new System.Drawing.Size(140, 53);
-            this.unitid.TabIndex = 5;
-            // 
-            // lblInterval
-            // 
-            this.lblInterval.AutoSize = true;
-            this.lblInterval.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblInterval.Location = new System.Drawing.Point(1290, 50);
-            this.lblInterval.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblInterval.Name = "lblInterval";
-            this.lblInterval.Size = new System.Drawing.Size(168, 52);
-            this.lblInterval.TabIndex = 6;
-            this.lblInterval.Text = "间隔(秒)";
-            // 
-            // interval
-            // 
-            this.interval.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.interval.Location = new System.Drawing.Point(1440, 52);
-            this.interval.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.interval.Maximum = new decimal(new int[] {
-            3600,
-            0,
-            0,
-            0});
-            this.interval.Minimum = new decimal(new int[] {
-            1,
-            0,
-            0,
-            0});
-            this.interval.Name = "interval";
-            this.interval.Size = new System.Drawing.Size(90, 53);
-            this.interval.TabIndex = 7;
-            this.interval.Value = new decimal(new int[] {
-            1,
-            0,
-            0,
-            0});
-            // 
-            // btnConnect
-            // 
-            this.btnConnect.AllPower = null;
-            this.btnConnect.BackColor = System.Drawing.Color.Transparent;
-            this.btnConnect.DownImage = ((System.Drawing.Image)(resources.GetObject("btnConnect.DownImage")));
-            this.btnConnect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnConnect.Image = null;
-            this.btnConnect.IsShowBorder = true;
-            this.btnConnect.Location = new System.Drawing.Point(220, 125);
-            this.btnConnect.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.btnConnect.MoveImage = ((System.Drawing.Image)(resources.GetObject("btnConnect.MoveImage")));
-            this.btnConnect.Name = "btnConnect";
-            this.btnConnect.NormalImage = ((System.Drawing.Image)(resources.GetObject("btnConnect.NormalImage")));
-            this.btnConnect.Power = null;
-            this.btnConnect.Size = new System.Drawing.Size(160, 52);
-            this.btnConnect.TabIndex = 8;
-            this.btnConnect.Text = "连接";
-            this.btnConnect.UseVisualStyleBackColor = true;
-            this.btnConnect.Click += new System.EventHandler(this.Connect_Click);
-            // 
-            // btnDisconnect
-            // 
-            this.btnDisconnect.AllPower = null;
-            this.btnDisconnect.BackColor = System.Drawing.Color.Transparent;
-            this.btnDisconnect.DownImage = ((System.Drawing.Image)(resources.GetObject("btnDisconnect.DownImage")));
-            this.btnDisconnect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnDisconnect.Image = null;
-            this.btnDisconnect.IsShowBorder = true;
-            this.btnDisconnect.Location = new System.Drawing.Point(420, 125);
-            this.btnDisconnect.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.btnDisconnect.MoveImage = ((System.Drawing.Image)(resources.GetObject("btnDisconnect.MoveImage")));
-            this.btnDisconnect.Name = "btnDisconnect";
-            this.btnDisconnect.NormalImage = ((System.Drawing.Image)(resources.GetObject("btnDisconnect.NormalImage")));
-            this.btnDisconnect.Power = null;
-            this.btnDisconnect.Size = new System.Drawing.Size(160, 52);
-            this.btnDisconnect.TabIndex = 9;
-            this.btnDisconnect.Text = "断开";
-            this.btnDisconnect.UseVisualStyleBackColor = true;
-            this.btnDisconnect.Click += new System.EventHandler(this.Disconnect_Click);
-            // 
-            // rdoRTU
-            // 
-            this.rdoRTU.AutoSize = true;
-            this.rdoRTU.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.rdoRTU.Location = new System.Drawing.Point(660, 130);
-            this.rdoRTU.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.rdoRTU.Name = "rdoRTU";
-            this.rdoRTU.Size = new System.Drawing.Size(388, 45);
-            this.rdoRTU.TabIndex = 10;
-            this.rdoRTU.Text = "ModbusRTU(串口透传)";
-            this.rdoRTU.UseVisualStyleBackColor = true;
-            // 
-            // rdoTCP
-            // 
-            this.rdoTCP.AutoSize = true;
-            this.rdoTCP.Checked = true;
-            this.rdoTCP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.rdoTCP.Location = new System.Drawing.Point(1080, 130);
-            this.rdoTCP.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.rdoTCP.Name = "rdoTCP";
-            this.rdoTCP.Size = new System.Drawing.Size(234, 45);
-            this.rdoTCP.TabIndex = 11;
-            this.rdoTCP.TabStop = true;
-            this.rdoTCP.Text = "ModbusTCP";
-            this.rdoTCP.UseVisualStyleBackColor = true;
-            // 
-            // grpData
-            // 
-            this.grpData.BorderColor = System.Drawing.Color.Black;
-            this.grpData.Controls.Add(this.lblD141);
-            this.grpData.Controls.Add(this.lblD141Value);
-            this.grpData.Controls.Add(this.lblD142);
-            this.grpData.Controls.Add(this.lblD142Value);
-            this.grpData.Controls.Add(this.lblDecimals);
-            this.grpData.Controls.Add(this.decimals);
-            this.grpData.Controls.Add(this.btnReadNow);
-            this.grpData.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.grpData.Location = new System.Drawing.Point(32, 260);
-            this.grpData.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.grpData.Name = "grpData";
-            this.grpData.Size = new System.Drawing.Size(1540, 380);
-            this.grpData.TabIndex = 1;
-            this.grpData.TabStop = false;
-            this.grpData.Text = "温度数据(台达PLC)";
-            this.grpData.TextColor = System.Drawing.Color.Black;
-            // 
-            // lblD141
-            // 
-            this.lblD141.AutoSize = true;
-            this.lblD141.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblD141.Location = new System.Drawing.Point(32, 55);
-            this.lblD141.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblD141.Name = "lblD141";
-            this.lblD141.Size = new System.Drawing.Size(328, 52);
-            this.lblD141.TabIndex = 0;
-            this.lblD141.Text = "1#舱温度 (D141)";
-            // 
-            // lblD141Value
-            // 
-            this.lblD141Value.Font = new System.Drawing.Font("微软雅黑", 40F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblD141Value.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
-            this.lblD141Value.Location = new System.Drawing.Point(32, 115);
-            this.lblD141Value.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblD141Value.Name = "lblD141Value";
-            this.lblD141Value.Size = new System.Drawing.Size(560, 110);
-            this.lblD141Value.TabIndex = 1;
-            this.lblD141Value.Text = "--";
-            // 
-            // lblD142
-            // 
-            this.lblD142.AutoSize = true;
-            this.lblD142.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblD142.Location = new System.Drawing.Point(820, 55);
-            this.lblD142.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblD142.Name = "lblD142";
-            this.lblD142.Size = new System.Drawing.Size(328, 52);
-            this.lblD142.TabIndex = 2;
-            this.lblD142.Text = "2#舱温度 (D142)";
-            // 
-            // lblD142Value
-            // 
-            this.lblD142Value.Font = new System.Drawing.Font("微软雅黑", 40F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblD142Value.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
-            this.lblD142Value.Location = new System.Drawing.Point(820, 115);
-            this.lblD142Value.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblD142Value.Name = "lblD142Value";
-            this.lblD142Value.Size = new System.Drawing.Size(560, 110);
-            this.lblD142Value.TabIndex = 3;
-            this.lblD142Value.Text = "--";
-            // 
-            // lblDecimals
-            // 
-            this.lblDecimals.AutoSize = true;
-            this.lblDecimals.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblDecimals.Location = new System.Drawing.Point(32, 290);
-            this.lblDecimals.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblDecimals.Name = "lblDecimals";
-            this.lblDecimals.Size = new System.Drawing.Size(222, 52);
-            this.lblDecimals.TabIndex = 4;
-            this.lblDecimals.Text = "温度小数位";
-            // 
-            // decimals
-            // 
-            this.decimals.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.decimals.Location = new System.Drawing.Point(220, 292);
-            this.decimals.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.decimals.Maximum = new decimal(new int[] {
-            3,
-            0,
-            0,
-            0});
-            this.decimals.Name = "decimals";
-            this.decimals.Size = new System.Drawing.Size(120, 53);
-            this.decimals.TabIndex = 5;
-            // 
-            // btnReadNow
-            // 
-            this.btnReadNow.AllPower = null;
-            this.btnReadNow.BackColor = System.Drawing.Color.Transparent;
-            this.btnReadNow.DownImage = ((System.Drawing.Image)(resources.GetObject("btnReadNow.DownImage")));
-            this.btnReadNow.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnReadNow.Image = null;
-            this.btnReadNow.IsShowBorder = true;
-            this.btnReadNow.Location = new System.Drawing.Point(820, 285);
-            this.btnReadNow.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.btnReadNow.MoveImage = ((System.Drawing.Image)(resources.GetObject("btnReadNow.MoveImage")));
-            this.btnReadNow.Name = "btnReadNow";
-            this.btnReadNow.NormalImage = ((System.Drawing.Image)(resources.GetObject("btnReadNow.NormalImage")));
-            this.btnReadNow.Power = null;
-            this.btnReadNow.Size = new System.Drawing.Size(200, 52);
-            this.btnReadNow.TabIndex = 6;
-            this.btnReadNow.Text = "立即读取";
-            this.btnReadNow.UseVisualStyleBackColor = true;
-            this.btnReadNow.Click += new System.EventHandler(this.ReadNow_Click);
-            // 
-            // lblRecord
-            // 
-            this.lblRecord.AutoSize = true;
-            this.lblRecord.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblRecord.Location = new System.Drawing.Point(32, 670);
-            this.lblRecord.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblRecord.Name = "lblRecord";
-            this.lblRecord.Size = new System.Drawing.Size(102, 52);
-            this.lblRecord.TabIndex = 2;
-            this.lblRecord.Text = "记录";
-            // 
-            // OperatResult
-            // 
-            this.OperatResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OperatResult.Location = new System.Drawing.Point(32, 725);
-            this.OperatResult.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.OperatResult.Name = "OperatResult";
-            this.OperatResult.Size = new System.Drawing.Size(1540, 330);
-            this.OperatResult.TabIndex = 3;
-            this.OperatResult.Text = "";
-            // 
-            // lblStatus
-            // 
-            this.lblStatus.AutoSize = true;
-            this.lblStatus.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblStatus.ForeColor = System.Drawing.Color.Blue;
-            this.lblStatus.Location = new System.Drawing.Point(32, 1075);
-            this.lblStatus.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.lblStatus.Name = "lblStatus";
-            this.lblStatus.Size = new System.Drawing.Size(142, 52);
-            this.lblStatus.TabIndex = 4;
-            this.lblStatus.Text = "状态:";
-            // 
-            // timer1
-            // 
-            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
-            // 
-            // Make_PLCMonitor
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1604, 1140);
-            this.Controls.Add(this.lblStatus);
-            this.Controls.Add(this.OperatResult);
-            this.Controls.Add(this.lblRecord);
-            this.Controls.Add(this.grpData);
-            this.Controls.Add(this.grpConnect);
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.Name = "Make_PLCMonitor";
-            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
-            this.Tag = "Make!PLCMonitor";
-            this.Text = "PLC温度监控";
-            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Make_PLCMonitor_FormClosing);
-            this.Load += new System.EventHandler(this.Make_PLCMonitor_Load);
-            this.SizeChanged += new System.EventHandler(this.Make_PLCMonitor_SizeChanged);
-            this.grpConnect.ResumeLayout(true);
-            this.grpConnect.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.port)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.unitid)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.interval)).EndInit();
-            this.grpData.ResumeLayout(true);
-            this.grpData.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.decimals)).EndInit();
-            this.ResumeLayout(true);
-            this.PerformLayout();
-
-        }
-
-        #endregion
-
-        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpConnect;
-        private System.Windows.Forms.Label lblIp;
-        private CustomControl.TextBoxWithIcon.EnterTextBox ip;
-        private System.Windows.Forms.Label lblPort;
-        private System.Windows.Forms.NumericUpDown port;
-        private System.Windows.Forms.Label lblUnit;
-        private System.Windows.Forms.NumericUpDown unitid;
-        private System.Windows.Forms.Label lblInterval;
-        private System.Windows.Forms.NumericUpDown interval;
-        private CustomControl.ButtonUtil.NormalButton btnConnect;
-        private CustomControl.ButtonUtil.NormalButton btnDisconnect;
-        private System.Windows.Forms.RadioButton rdoRTU;
-        private System.Windows.Forms.RadioButton rdoTCP;
-        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpData;
-        private System.Windows.Forms.Label lblD141;
-        private System.Windows.Forms.Label lblD141Value;
-        private System.Windows.Forms.Label lblD142;
-        private System.Windows.Forms.Label lblD142Value;
-        private System.Windows.Forms.Label lblDecimals;
-        private System.Windows.Forms.NumericUpDown decimals;
-        private CustomControl.ButtonUtil.NormalButton btnReadNow;
-        private System.Windows.Forms.Label lblRecord;
-        private CustomControl.RichText.RichTextAutoBottom OperatResult;
-        private System.Windows.Forms.Label lblStatus;
-        private System.Windows.Forms.Timer timer1;
-    }
-}

+ 0 - 425
UAS_MES_ZKLH/FunctionCode/Make/Make_PLCMonitor.cs

@@ -1,425 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Net.Sockets;
-using System.Text;
-using System.Windows.Forms;
-using UAS_MES_NEW.DataOperate;
-using UAS_MES_NEW.Entity;
-using UAS_MES_NEW.PublicMethod;
-
-namespace UAS_MES_NEW.Make
-{
-    public partial class Make_PLCMonitor : Form
-    {
-        AutoSizeFormClass asc = new AutoSizeFormClass();
-        DataHelper dh;
-
-        // Modbus TCP 连接对象(保持长连接,断线自动重连)
-        TcpClient plcClient;
-        NetworkStream plcStream;
-        bool connected = false;
-        ushort transactionId = 0;
-        readonly object readLock = new object();
-
-        // 台达PLC数据寄存器:D寄存器对应Modbus保持寄存器(功能码0x03)
-        // ETH-DVP-2P模块手册寄存器表:D0~4095 的Modbus地址 = 0x1000 + D编号
-        // 如 D141 → 0x1000+141 = 0x108D;D4096以上是另一段(0x9000起),当前用不到
-        const int D141_ADDR = 141;
-        const int DVP_D_OFFSET = 0x1000;
-        const int READ_COUNT = 2;
-
-        // 温度记录表:每次采集往里插一条(1#舱、2#舱各一条)
-        // TL_ID 用序列 TEMPLOG_SEQ,TL_DATE 取sysdate,TL_DEVICEID 存舱号,TL_TP 存换算后的温度值
-        const string TempLogTable = "TEMPLOG";
-        const string TempLogSeq = "TEMPLOG_SEQ";
-
-        public Make_PLCMonitor()
-        {
-            InitializeComponent();
-        }
-
-        private void Make_PLCMonitor_Load(object sender, EventArgs e)
-        {
-            asc.controllInitializeSize(this);
-            dh = SystemInf.dh;
-            ip.Text = "192.168.1.150";
-            port.Value = 502;
-            unitid.Value = 1;
-            interval.Value = 2;
-            decimals.Value = 1;
-            SetStatus("未连接");
-        }
-
-        /// <summary>
-        /// 连接串口转网口模块(Modbus TCP)
-        /// </summary>
-        private void Connect_Click(object sender, EventArgs e)
-        {
-            try
-            {
-                ClosePlc();
-                plcClient = new TcpClient();
-                IAsyncResult ar = plcClient.BeginConnect(ip.Text.Trim(), (int)port.Value, null, null);
-                if (!ar.AsyncWaitHandle.WaitOne(3000))
-                {
-                    ClosePlc();
-                    SetStatus("连接超时");
-                    MessageBox.Show("连接PLC超时,请检查IP和端口!");
-                    return;
-                }
-                plcClient.EndConnect(ar);
-                plcClient.ReceiveTimeout = 5000;
-                plcClient.SendTimeout = 5000;
-                plcStream = plcClient.GetStream();
-                connected = true;
-                SetStatus("已连接 " + ip.Text.Trim() + ":" + port.Value);
-                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 已连接 " + ip.Text.Trim() + ":" + port.Value + ",站号" + unitid.Value + "\n");
-                timer1.Interval = (int)interval.Value * 1000;
-                timer1.Start();
-                // 连接成功后立即读一次
-                ReadNow_Click(null, null);
-            }
-            catch (Exception ex)
-            {
-                ClosePlc();
-                SetStatus("连接失败:" + ex.Message);
-                MessageBox.Show("连接失败:" + ex.Message);
-            }
-        }
-
-        /// <summary>
-        /// 断开连接
-        /// </summary>
-        private void Disconnect_Click(object sender, EventArgs e)
-        {
-            timer1.Stop();
-            ClosePlc();
-            SetStatus("未连接");
-            OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 已断开连接\n");
-        }
-
-        /// <summary>
-        /// 立即读取一次
-        /// </summary>
-        private void ReadNow_Click(object sender, EventArgs e)
-        {
-            if (!connected)
-            {
-                SetStatus("未连接");
-                return;
-            }
-            try
-            {
-                // D寄存器地址要加台达DVP的0x1000偏移:D141→0x108D, D142→0x108E
-                int[] values = ReadRegisters((ushort)(DVP_D_OFFSET + D141_ADDR), READ_COUNT);
-                ShowValues(values);
-                InsertTempLog(values);
-                SetStatus("读取成功 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
-            }
-            catch (Exception ex)
-            {
-                // 读取失败:断开连接,等待下一次重连
-                timer1.Stop();
-                ClosePlc();
-                connected = false;
-                string mode = rdoTCP.Checked ? "ModbusTCP" : "ModbusRTU(透传)";
-                SetStatus("读取失败:" + ex.Message);
-                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 读取失败(" + mode + "):" + ex.Message + "\n");
-                if (ex.Message.Contains("超时") || ex.Message.Contains("没有正确答复") || ex.Message.Contains("连接已断开"))
-                {
-                    OperatResult.AppendText("[提示] 如果RTU(透传)模式一直超时,请尝试切换到ModbusTCP模式;反之亦然。同时确认模块透传设置、PLC串口参数(9600/8/N/1)和站号。\n");
-                }
-                // 自动重连
-                TryReconnect();
-            }
-        }
-
-        /// <summary>
-        /// 定时获取数据
-        /// </summary>
-        private void timer1_Tick(object sender, EventArgs e)
-        {
-            if (!connected)
-            {
-                TryReconnect();
-                return;
-            }
-            ReadNow_Click(null, null);
-        }
-
-        /// <summary>
-        /// 尝试重新连接(不打断界面,仅更新状态)
-        /// </summary>
-        private void TryReconnect()
-        {
-            try
-            {
-                ClosePlc();
-                plcClient = new TcpClient();
-                IAsyncResult ar = plcClient.BeginConnect(ip.Text.Trim(), (int)port.Value, null, null);
-                if (!ar.AsyncWaitHandle.WaitOne(3000))
-                {
-                    ClosePlc();
-                    SetStatus("重连超时,继续重试...");
-                    return;
-                }
-                plcClient.EndConnect(ar);
-                plcClient.ReceiveTimeout = 5000;
-                plcClient.SendTimeout = 5000;
-                plcStream = plcClient.GetStream();
-                connected = true;
-                SetStatus("重连成功 " + DateTime.Now.ToString("HH:mm:ss"));
-                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 重连成功\n");
-            }
-            catch
-            {
-                ClosePlc();
-                SetStatus("重连失败,继续重试...");
-            }
-        }
-
-        /// <summary>
-        /// 把本次采集的温度写入TEMPLOG表,1#舱、2#舱各一条
-        /// TL_ID=序列TEMPLOG_SEQ,TL_DATE=sysdate,TL_DEVICEID=舱号,TL_TP=换算后的温度
-        /// </summary>
-        private void InsertTempLog(int[] values)
-        {
-            if (values == null || values.Length < 2) return;
-            try
-            {
-                int d = (int)decimals.Value;
-                double v1 = values[0] / Math.Pow(10, d);
-                double v2 = values[1] / Math.Pow(10, d);
-                string v1s = v1.ToString("0.###");
-                string v2s = v2.ToString("0.###");
-                dh.ExecuteSql("insert into " + TempLogTable + "(TL_ID,TL_DATE,TL_DEVICEID,TL_TP)values(" + TempLogSeq + ".nextval,sysdate,'1#'," + v1s + ")", "insert");
-                dh.ExecuteSql("insert into " + TempLogTable + "(TL_ID,TL_DATE,TL_DEVICEID,TL_TP)values(" + TempLogSeq + ".nextval,sysdate,'2#'," + v2s + ")", "insert");
-            }
-            catch (Exception ex)
-            {
-                // 插入失败不影响采集显示,只记录
-                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 写入" + TempLogTable + "失败:" + ex.Message + "\n");
-            }
-        }
-
-        /// <summary>
-        /// 显示温度值,并根据小数位设置换算(台达一般存实际值x10)
-        /// </summary>
-        private void ShowValues(int[] values)
-        {
-            if (values == null || values.Length < 2) return;
-            int d = (int)decimals.Value;
-            double v1 = values[0] / Math.Pow(10, d);
-            double v2 = values[1] / Math.Pow(10, d);
-            string fmt = d > 0 ? "F" + d : "F0";
-            lblD141Value.Text = v1.ToString(fmt);
-            lblD142Value.Text = v2.ToString(fmt);
-            OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 1#舱(D141)=" + values[0] + "  2#舱(D142)=" + values[1] + "\n");
-        }
-
-        /// <summary>
-        /// Modbus TCP 读保持寄存器(功能码0x03)
-        /// </summary>
-        /// <summary>
-        /// 读保持寄存器(功能码0x03),按界面选择的协议分发:
-        /// ModbusRTU(串口透传):模块把TCP数据原样转发到串口,要发带CRC16的RTU裸帧
-        /// ModbusTCP:模块/PLC本身是标准Modbus TCP服务端,发带MBAP头的帧
-        /// </summary>
-        private int[] ReadRegisters(ushort startAddr, ushort count)
-        {
-            if (rdoTCP.Checked)
-            {
-                return ReadTcpRegisters(startAddr, count);
-            }
-            return ReadRtuRegisters(startAddr, count);
-        }
-
-        /// <summary>
-        /// Modbus RTU over TCP(串口透传模式):站号+功能码+数据+CRC16
-        /// </summary>
-        private int[] ReadRtuRegisters(ushort startAddr, ushort count)
-        {
-            lock (readLock)
-            {
-                if (!connected || plcStream == null)
-                {
-                    throw new Exception("未连接PLC");
-                }
-                byte unit = (byte)unitid.Value;
-                byte[] req = new byte[8];
-                req[0] = unit;
-                // 功能码0x03 读保持寄存器
-                req[1] = 0x03;
-                req[2] = (byte)(startAddr >> 8);
-                req[3] = (byte)(startAddr & 0xFF);
-                req[4] = (byte)(count >> 8);
-                req[5] = (byte)(count & 0xFF);
-                ushort crc = CalcCRC16(req, 6);
-                // Modbus RTU CRC低字节在前
-                req[6] = (byte)(crc & 0xFF);
-                req[7] = (byte)((crc >> 8) & 0xFF);
-                plcStream.Write(req, 0, req.Length);
-
-                // 响应:站号+功能码+字节数
-                byte[] head = ReadBytes(plcStream, 3);
-                if (head[0] != unit)
-                {
-                    throw new Exception("响应站号不匹配(收到0x" + head[0].ToString("X2") + "),请检查站号设置");
-                }
-                if ((head[1] & 0x80) != 0)
-                {
-                    byte[] rest = ReadBytes(plcStream, 3);
-                    throw new Exception("PLC返回异常码 0x" + rest[0].ToString("X2"));
-                }
-                int byteCount = head[2];
-                byte[] rest2 = ReadBytes(plcStream, byteCount + 2);
-                // CRC校验:响应最后2字节是CRC
-                byte[] full = new byte[3 + byteCount + 2];
-                Array.Copy(head, 0, full, 0, 3);
-                Array.Copy(rest2, 0, full, 3, byteCount + 2);
-                ushort calcCrc = CalcCRC16(full, full.Length - 2);
-                ushort recvCrc = (ushort)(full[full.Length - 2] | (full[full.Length - 1] << 8));
-                if (calcCrc != recvCrc)
-                {
-                    throw new Exception("响应CRC校验失败,串口参数(波特率/校验位)可能与PLC不一致");
-                }
-                int[] values = new int[count];
-                for (int i = 0; i < count; i++)
-                {
-                    values[i] = (rest2[i * 2] << 8) | rest2[i * 2 + 1];
-                }
-                return values;
-            }
-        }
-
-        /// <summary>
-        /// Modbus TCP 读保持寄存器(功能码0x03),带MBAP头
-        /// </summary>
-        private int[] ReadTcpRegisters(ushort startAddr, ushort count)
-        {
-            lock (readLock)
-            {
-                if (!connected || plcStream == null)
-                {
-                    throw new Exception("未连接PLC");
-                }
-                transactionId++;
-                byte[] req = new byte[12];
-                // MBAP头:事务标识、协议标识0、长度6、单元标识符
-                req[0] = (byte)(transactionId >> 8);
-                req[1] = (byte)(transactionId & 0xFF);
-                req[2] = 0x00;
-                req[3] = 0x00;
-                req[4] = 0x00;
-                req[5] = 0x06;
-                req[6] = (byte)unitid.Value;
-                // 功能码0x03 读保持寄存器
-                req[7] = 0x03;
-                req[8] = (byte)(startAddr >> 8);
-                req[9] = (byte)(startAddr & 0xFF);
-                req[10] = (byte)(count >> 8);
-                req[11] = (byte)(count & 0xFF);
-                plcStream.Write(req, 0, req.Length);
-
-                byte[] head = ReadBytes(plcStream, 9);
-                if ((head[7] & 0x80) != 0)
-                {
-                    byte[] ec = ReadBytes(plcStream, 1);
-                    throw new Exception("PLC返回异常码 0x" + (ec.Length > 0 ? ec[0] : 0).ToString("X2"));
-                }
-                int byteCount = head[8];
-                byte[] data = ReadBytes(plcStream, byteCount);
-                int[] values = new int[count];
-                for (int i = 0; i < count; i++)
-                {
-                    values[i] = (data[i * 2] << 8) | data[i * 2 + 1];
-                }
-                return values;
-            }
-        }
-
-        /// <summary>
-        /// Modbus RTU CRC16校验
-        /// </summary>
-        private ushort CalcCRC16(byte[] data, int length)
-        {
-            ushort crc = 0xFFFF;
-            for (int i = 0; i < length; i++)
-            {
-                crc ^= data[i];
-                for (int j = 0; j < 8; j++)
-                {
-                    if ((crc & 0x0001) != 0)
-                    {
-                        crc = (ushort)((crc >> 1) ^ 0xA001);
-                    }
-                    else
-                    {
-                        crc = (ushort)(crc >> 1);
-                    }
-                }
-            }
-            return crc;
-        }
-
-        /// <summary>
-        /// 从流中读满指定长度,读不满视为连接异常
-        /// </summary>
-        private byte[] ReadBytes(NetworkStream stream, int length)
-        {
-            byte[] buffer = new byte[length];
-            int read = 0;
-            while (read < length)
-            {
-                int n = stream.Read(buffer, read, length - read);
-                if (n <= 0)
-                {
-                    throw new Exception("连接已断开");
-                }
-                read += n;
-            }
-            return buffer;
-        }
-
-        /// <summary>
-        /// 关闭PLC连接
-        /// </summary>
-        private void ClosePlc()
-        {
-            try
-            {
-                if (plcStream != null)
-                {
-                    plcStream.Close();
-                    plcStream = null;
-                }
-                if (plcClient != null)
-                {
-                    plcClient.Close();
-                    plcClient = null;
-                }
-            }
-            catch { }
-            connected = false;
-        }
-
-        private void SetStatus(string text)
-        {
-            lblStatus.Text = "状态:" + text;
-        }
-
-        private void Make_PLCMonitor_FormClosing(object sender, FormClosingEventArgs e)
-        {
-            timer1.Stop();
-            ClosePlc();
-        }
-
-        private void Make_PLCMonitor_SizeChanged(object sender, EventArgs e)
-        {
-            asc.controlAutoSize(this);
-        }
-    }
-}

+ 0 - 238
UAS_MES_ZKLH/FunctionCode/Make/Make_PLCMonitor.resx

@@ -1,238 +0,0 @@
-<?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>
-  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
-  <data name="btnConnect.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFfSURBVFhH5dhNTsJgFIXhM2WiCxL2oAEHrJKhQSYM
-        JIgzjSLIX0sRKPSPtl+Lo2uOgVbWcJu8CzhP8nVwISIAUAFwA+AWQFNh3M39lZMHrgDUu91uyxjji8KP
-        u7mfDgCuiVLt958fkjSTie3I62iqLu7m/sHgpQ2gRpSG6/nmc2bL23imtuHMkp0f5ADuidIMoljev+bq
-        o8PpH4NmcIjlY7JQHx0KlPCQyHBqqY8OJUqcyGhuq48OBUoUJzJeLNVHhwLlkKQysRz10eECZbpcqe8C
-        JU6NzJ1v9dGhQElSI9Zqoz46lCgmE3u9VR8dCpTUZOJsXPXRoUTJclltd+qjQ4FislzW7l59dChR8lw2
-        e099dDijNA5xYnZBKFvPVxv3x0lanA5qT71eOzsexQsjcf1AXdzN/XQ4H5l4fqs/djqtIIzC/Pgj2uJu
-        7i/Okf8O11UAd6c3pS3u5v6/w/UvTaFspAxAMh4AAAAASUVORK5CYII=
-</value>
-  </data>
-  <data name="btnConnect.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAF3SURBVFhH5djbSgJRFMbxHsP7wBfYT7jvu46QDIoI
-        C4QNQRAIgVBRSdpxpgZN83wYx5nZOjNqrvgEd73DGvhfzdX3g32ztohoS0iVElLtCakehVQdhmE39qfg
-        AZBtIdX70Y0TjsJ4SQw/7MZ+OAip0kDJnD3UdJAsyXIjKvWm7MJu7M+X6lpIlQWK3ZhEq8pgRvfdKdvK
-        /Rk1/XglpHKA0ulPF3Tb0eyDAzzWKL3pgq7bmn1wMChdPadiK2QfHAxKW8/pqhmwDw4GpRXOqdAI2AcH
-        g9IME7qs++yDg0H5DhK6qE3YBweD0vATOq967IODQfnyE1KOxz44GJTaJKb855h9cDAoVS+mU9tlHxwM
-        iuPFdGK57IPDH8o4ouO3EfvgYFA+xhEdvg7ZB4cNil3uhquc5dLBy5Bt2P/U0+Z0kN0tOhqHlpzt0v7z
-        gF3Yjf1w2ByZ0jjD7RSs8K7l/+Ant7Ab+8058t/hOiOkquBNMQy7sX99uP4F5D4U8hdr4uMAAAAASUVO
-        RK5CYII=
-</value>
-  </data>
-  <data name="btnConnect.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGpSURBVFhH5dg/ayJBGMfxB4YFXTARBAvBQhAsBEEQ
-        ZLnNzFu4I6aYV5kyF9tgbad1jrsYY9T4Z3fcnV2f45e38Sx8q6l+n2IWhpiZjDFVY8wPY8xPY4wVGHZj
-        fxUepLW+0Vrfz+fzR+fclgV+2I39cNBa31Icx/FisXi6XpnL8io27F8ul89xHN9RFEWTPM+ToihZet57
-        F0XRA43HYwsp7wvxwQEeNBqNbFmWnOW5+OAADxoOh7YoS3ZZJj44wIMGg4H1RcGpu4gPDvCgfr9vvfd8
-        TlPxwQEe1Ov1bO49H8+J+OAAD+p2uxaXzNfpJD44wIM6nY69ZDnvDkfxwQEe1G637SXLeLs/iA8O8KBW
-        q2XdJePNbi8+OMCDms2mxe9o/bkTHxzgQY1GwybO8WrzKT44wIPq9bpNUsdv64344AAPqtVq9pw6/vv+
-        IT44wIPCMJzsvg7Jv/UH/1m9iw3794ejC8PwgSqVyt3LbPZ8SpLvg9e3lbiwG/vhAA8KguA2CIL739Pp
-        42a73eNQWtiN/XCAB+GhVilVVUrFSqlfSikrMOzG/u+H6/+yQ4jdXN8e9AAAAABJRU5ErkJggg==
-</value>
-  </data>
-  <data name="btnDisconnect.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFfSURBVFhH5dhNTsJgFIXhM2WiCxL2oAEHrJKhQSYM
-        JIgzjSLIX0sRKPSPtl+Lo2uOgVbWcJu8CzhP8nVwISIAUAFwA+AWQFNh3M39lZMHrgDUu91uyxjji8KP
-        u7mfDgCuiVLt958fkjSTie3I62iqLu7m/sHgpQ2gRpSG6/nmc2bL23imtuHMkp0f5ADuidIMoljev+bq
-        o8PpH4NmcIjlY7JQHx0KlPCQyHBqqY8OJUqcyGhuq48OBUoUJzJeLNVHhwLlkKQysRz10eECZbpcqe8C
-        JU6NzJ1v9dGhQElSI9Zqoz46lCgmE3u9VR8dCpTUZOJsXPXRoUTJclltd+qjQ4FislzW7l59dChR8lw2
-        e099dDijNA5xYnZBKFvPVxv3x0lanA5qT71eOzsexQsjcf1AXdzN/XQ4H5l4fqs/djqtIIzC/Pgj2uJu
-        7i/Okf8O11UAd6c3pS3u5v6/w/UvTaFspAxAMh4AAAAASUVORK5CYII=
-</value>
-  </data>
-  <data name="btnDisconnect.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAF3SURBVFhH5djbSgJRFMbxHsP7wBfYT7jvu46QDIoI
-        C4QNQRAIgVBRSdpxpgZN83wYx5nZOjNqrvgEd73DGvhfzdX3g32ztohoS0iVElLtCakehVQdhmE39qfg
-        AZBtIdX70Y0TjsJ4SQw/7MZ+OAip0kDJnD3UdJAsyXIjKvWm7MJu7M+X6lpIlQWK3ZhEq8pgRvfdKdvK
-        /Rk1/XglpHKA0ulPF3Tb0eyDAzzWKL3pgq7bmn1wMChdPadiK2QfHAxKW8/pqhmwDw4GpRXOqdAI2AcH
-        g9IME7qs++yDg0H5DhK6qE3YBweD0vATOq967IODQfnyE1KOxz44GJTaJKb855h9cDAoVS+mU9tlHxwM
-        iuPFdGK57IPDH8o4ouO3EfvgYFA+xhEdvg7ZB4cNil3uhquc5dLBy5Bt2P/U0+Z0kN0tOhqHlpzt0v7z
-        gF3Yjf1w2ByZ0jjD7RSs8K7l/+Ant7Ab+8058t/hOiOkquBNMQy7sX99uP4F5D4U8hdr4uMAAAAASUVO
-        RK5CYII=
-</value>
-  </data>
-  <data name="btnDisconnect.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGpSURBVFhH5dg/ayJBGMfxB4YFXTARBAvBQhAsBEEQ
-        ZLnNzFu4I6aYV5kyF9tgbad1jrsYY9T4Z3fcnV2f45e38Sx8q6l+n2IWhpiZjDFVY8wPY8xPY4wVGHZj
-        fxUepLW+0Vrfz+fzR+fclgV+2I39cNBa31Icx/FisXi6XpnL8io27F8ul89xHN9RFEWTPM+ToihZet57
-        F0XRA43HYwsp7wvxwQEeNBqNbFmWnOW5+OAADxoOh7YoS3ZZJj44wIMGg4H1RcGpu4gPDvCgfr9vvfd8
-        TlPxwQEe1Ov1bO49H8+J+OAAD+p2uxaXzNfpJD44wIM6nY69ZDnvDkfxwQEe1G637SXLeLs/iA8O8KBW
-        q2XdJePNbi8+OMCDms2mxe9o/bkTHxzgQY1GwybO8WrzKT44wIPq9bpNUsdv64344AAPqtVq9pw6/vv+
-        IT44wIPCMJzsvg7Jv/UH/1m9iw3794ejC8PwgSqVyt3LbPZ8SpLvg9e3lbiwG/vhAA8KguA2CIL739Pp
-        42a73eNQWtiN/XCAB+GhVilVVUrFSqlfSikrMOzG/u+H6/+yQ4jdXN8e9AAAAABJRU5ErkJggg==
-</value>
-  </data>
-  <data name="btnReadNow.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFfSURBVFhH5dhNTsJgFIXhM2WiCxL2oAEHrJKhQSYM
-        JIgzjSLIX0sRKPSPtl+Lo2uOgVbWcJu8CzhP8nVwISIAUAFwA+AWQFNh3M39lZMHrgDUu91uyxjji8KP
-        u7mfDgCuiVLt958fkjSTie3I62iqLu7m/sHgpQ2gRpSG6/nmc2bL23imtuHMkp0f5ADuidIMoljev+bq
-        o8PpH4NmcIjlY7JQHx0KlPCQyHBqqY8OJUqcyGhuq48OBUoUJzJeLNVHhwLlkKQysRz10eECZbpcqe8C
-        JU6NzJ1v9dGhQElSI9Zqoz46lCgmE3u9VR8dCpTUZOJsXPXRoUTJclltd+qjQ4FislzW7l59dChR8lw2
-        e099dDijNA5xYnZBKFvPVxv3x0lanA5qT71eOzsexQsjcf1AXdzN/XQ4H5l4fqs/djqtIIzC/Pgj2uJu
-        7i/Okf8O11UAd6c3pS3u5v6/w/UvTaFspAxAMh4AAAAASUVORK5CYII=
-</value>
-  </data>
-  <data name="btnReadNow.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAF3SURBVFhH5djbSgJRFMbxHsP7wBfYT7jvu46QDIoI
-        C4QNQRAIgVBRSdpxpgZN83wYx5nZOjNqrvgEd73DGvhfzdX3g32ztohoS0iVElLtCakehVQdhmE39qfg
-        AZBtIdX70Y0TjsJ4SQw/7MZ+OAip0kDJnD3UdJAsyXIjKvWm7MJu7M+X6lpIlQWK3ZhEq8pgRvfdKdvK
-        /Rk1/XglpHKA0ulPF3Tb0eyDAzzWKL3pgq7bmn1wMChdPadiK2QfHAxKW8/pqhmwDw4GpRXOqdAI2AcH
-        g9IME7qs++yDg0H5DhK6qE3YBweD0vATOq967IODQfnyE1KOxz44GJTaJKb855h9cDAoVS+mU9tlHxwM
-        iuPFdGK57IPDH8o4ouO3EfvgYFA+xhEdvg7ZB4cNil3uhquc5dLBy5Bt2P/U0+Z0kN0tOhqHlpzt0v7z
-        gF3Yjf1w2ByZ0jjD7RSs8K7l/+Ant7Ab+8058t/hOiOkquBNMQy7sX99uP4F5D4U8hdr4uMAAAAASUVO
-        RK5CYII=
-</value>
-  </data>
-  <data name="btnReadNow.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-    <value>
-        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
-        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGpSURBVFhH5dg/ayJBGMfxB4YFXTARBAvBQhAsBEEQ
-        ZLnNzFu4I6aYV5kyF9tgbad1jrsYY9T4Z3fcnV2f45e38Sx8q6l+n2IWhpiZjDFVY8wPY8xPY4wVGHZj
-        fxUepLW+0Vrfz+fzR+fclgV+2I39cNBa31Icx/FisXi6XpnL8io27F8ul89xHN9RFEWTPM+ToihZet57
-        F0XRA43HYwsp7wvxwQEeNBqNbFmWnOW5+OAADxoOh7YoS3ZZJj44wIMGg4H1RcGpu4gPDvCgfr9vvfd8
-        TlPxwQEe1Ov1bO49H8+J+OAAD+p2uxaXzNfpJD44wIM6nY69ZDnvDkfxwQEe1G637SXLeLs/iA8O8KBW
-        q2XdJePNbi8+OMCDms2mxe9o/bkTHxzgQY1GwybO8WrzKT44wIPq9bpNUsdv64344AAPqtVq9pw6/vv+
-        IT44wIPCMJzsvg7Jv/UH/1m9iw3794ejC8PwgSqVyt3LbPZ8SpLvg9e3lbiwG/vhAA8KguA2CIL739Pp
-        42a73eNQWtiN/XCAB+GhVilVVUrFSqlfSikrMOzG/u+H6/+yQ4jdXN8e9AAAAABJRU5ErkJggg==
-</value>
-  </data>
-  <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>17, 17</value>
-  </metadata>
-</root>

+ 445 - 90
UAS_MES_ZKLH/FunctionCode/Make/Make_PartDry.Designer.cs

@@ -28,6 +28,28 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            this.grpConnect = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.lblIp = new System.Windows.Forms.Label();
+            this.ip = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.lblPort = new System.Windows.Forms.Label();
+            this.port = new System.Windows.Forms.NumericUpDown();
+            this.lblUnit = new System.Windows.Forms.Label();
+            this.unitid = new System.Windows.Forms.NumericUpDown();
+            this.lblInterval = new System.Windows.Forms.Label();
+            this.interval = new System.Windows.Forms.NumericUpDown();
+            this.btnConnect = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.btnDisconnect = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.rdoRTU = new System.Windows.Forms.RadioButton();
+            this.rdoTCP = new System.Windows.Forms.RadioButton();
+            this.grpData = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.lblD141 = new System.Windows.Forms.Label();
+            this.lblD141Value = new System.Windows.Forms.Label();
+            this.lblD142 = new System.Windows.Forms.Label();
+            this.lblD142Value = new System.Windows.Forms.Label();
+            this.lblDecimals = new System.Windows.Forms.Label();
+            this.decimals = new System.Windows.Forms.NumericUpDown();
+            this.btnReadNow = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.grpSN = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.lblSN = new System.Windows.Forms.Label();
             this.sncode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
@@ -35,21 +57,322 @@
             this.lblBatchCode = new System.Windows.Forms.Label();
             this.btnStart = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.btnEnd = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.grpQuery = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.lblQuery = new System.Windows.Forms.Label();
             this.txtQueryBatch = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.btnQuery = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.grpData = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.grpdata2 = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.DGV = new System.Windows.Forms.DataGridView();
             this.lblStatus = new System.Windows.Forms.Label();
-            this.grpSN.SuspendLayout();
-            this.grpQuery.SuspendLayout();
+            this.OperatResult = new UAS_MES_NEW.CustomControl.RichText.RichTextAutoBottom();
+            this.timer1 = new System.Windows.Forms.Timer(this.components);
+            this.grpConnect.SuspendLayout();
             this.grpData.SuspendLayout();
+            this.grpSN.SuspendLayout();
+            this.grpdata2.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.port)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.unitid)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.interval)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.decimals)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.DGV)).BeginInit();
             this.SuspendLayout();
-            // 
+            //
+            // grpConnect
+            //
+            this.grpConnect.BorderColor = System.Drawing.Color.Black;
+            this.grpConnect.Controls.Add(this.lblIp);
+            this.grpConnect.Controls.Add(this.ip);
+            this.grpConnect.Controls.Add(this.lblPort);
+            this.grpConnect.Controls.Add(this.port);
+            this.grpConnect.Controls.Add(this.lblUnit);
+            this.grpConnect.Controls.Add(this.unitid);
+            this.grpConnect.Controls.Add(this.lblInterval);
+            this.grpConnect.Controls.Add(this.interval);
+            this.grpConnect.Controls.Add(this.btnConnect);
+            this.grpConnect.Controls.Add(this.btnDisconnect);
+            this.grpConnect.Controls.Add(this.rdoRTU);
+            this.grpConnect.Controls.Add(this.rdoTCP);
+            this.grpConnect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.grpConnect.Location = new System.Drawing.Point(32, 30);
+            this.grpConnect.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.grpConnect.Name = "grpConnect";
+            this.grpConnect.Size = new System.Drawing.Size(1540, 185);
+            this.grpConnect.TabIndex = 0;
+            this.grpConnect.TabStop = false;
+            this.grpConnect.Text = "PLC连接设置(Modbus)";
+            this.grpConnect.TextColor = System.Drawing.Color.Black;
+            //
+            // lblIp
+            //
+            this.lblIp.AutoSize = true;
+            this.lblIp.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblIp.Location = new System.Drawing.Point(32, 40);
+            this.lblIp.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblIp.Name = "lblIp";
+            this.lblIp.Size = new System.Drawing.Size(122, 52);
+            this.lblIp.TabIndex = 0;
+            this.lblIp.Text = "IP地址";
+            //
+            // ip
+            //
+            this.ip.AllPower = null;
+            this.ip.BackColor = System.Drawing.Color.White;
+            this.ip.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ip.ID = null;
+            this.ip.Location = new System.Drawing.Point(190, 42);
+            this.ip.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.ip.Name = "ip";
+            this.ip.Power = null;
+            this.ip.Size = new System.Drawing.Size(300, 55);
+            this.ip.Str = null;
+            this.ip.Str1 = null;
+            this.ip.Str2 = null;
+            this.ip.TabIndex = 1;
+            //
+            // lblPort
+            //
+            this.lblPort.AutoSize = true;
+            this.lblPort.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblPort.Location = new System.Drawing.Point(540, 40);
+            this.lblPort.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblPort.Name = "lblPort";
+            this.lblPort.Size = new System.Drawing.Size(82, 52);
+            this.lblPort.TabIndex = 2;
+            this.lblPort.Text = "端口";
+            //
+            // port
+            //
+            this.port.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.port.Location = new System.Drawing.Point(645, 42);
+            this.port.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.port.Maximum = new decimal(new int[] {
+            65535,
+            0,
+            0,
+            0});
+            this.port.Name = "port";
+            this.port.Size = new System.Drawing.Size(130, 51);
+            this.port.TabIndex = 3;
+            //
+            // lblUnit
+            //
+            this.lblUnit.AutoSize = true;
+            this.lblUnit.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblUnit.Location = new System.Drawing.Point(830, 40);
+            this.lblUnit.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblUnit.Name = "lblUnit";
+            this.lblUnit.Size = new System.Drawing.Size(82, 52);
+            this.lblUnit.TabIndex = 4;
+            this.lblUnit.Text = "站号";
+            //
+            // unitid
+            //
+            this.unitid.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.unitid.Location = new System.Drawing.Point(935, 42);
+            this.unitid.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.unitid.Maximum = new decimal(new int[] {
+            247,
+            0,
+            0,
+            0});
+            this.unitid.Name = "unitid";
+            this.unitid.Size = new System.Drawing.Size(120, 51);
+            this.unitid.TabIndex = 5;
+            //
+            // lblInterval
+            //
+            this.lblInterval.AutoSize = true;
+            this.lblInterval.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblInterval.Location = new System.Drawing.Point(1110, 40);
+            this.lblInterval.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblInterval.Name = "lblInterval";
+            this.lblInterval.Size = new System.Drawing.Size(122, 52);
+            this.lblInterval.TabIndex = 6;
+            this.lblInterval.Text = "间隔(秒)";
+            //
+            // interval
+            //
+            this.interval.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.interval.Location = new System.Drawing.Point(1260, 42);
+            this.interval.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.interval.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            0});
+            this.interval.Maximum = new decimal(new int[] {
+            3600,
+            0,
+            0,
+            0});
+            this.interval.Name = "interval";
+            this.interval.Size = new System.Drawing.Size(100, 51);
+            this.interval.TabIndex = 7;
+            //
+            // btnConnect
+            //
+            this.btnConnect.AllPower = null;
+            this.btnConnect.BackColor = System.Drawing.Color.Transparent;
+            this.btnConnect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.btnConnect.IsShowBorder = true;
+            this.btnConnect.Location = new System.Drawing.Point(190, 110);
+            this.btnConnect.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.btnConnect.Name = "btnConnect";
+            this.btnConnect.Power = null;
+            this.btnConnect.Size = new System.Drawing.Size(150, 50);
+            this.btnConnect.TabIndex = 8;
+            this.btnConnect.Text = "连接";
+            this.btnConnect.UseVisualStyleBackColor = true;
+            this.btnConnect.Click += new System.EventHandler(this.Connect_Click);
+            //
+            // btnDisconnect
+            //
+            this.btnDisconnect.AllPower = null;
+            this.btnDisconnect.BackColor = System.Drawing.Color.Transparent;
+            this.btnDisconnect.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.btnDisconnect.IsShowBorder = true;
+            this.btnDisconnect.Location = new System.Drawing.Point(370, 110);
+            this.btnDisconnect.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.btnDisconnect.Name = "btnDisconnect";
+            this.btnDisconnect.Power = null;
+            this.btnDisconnect.Size = new System.Drawing.Size(150, 50);
+            this.btnDisconnect.TabIndex = 9;
+            this.btnDisconnect.Text = "断开";
+            this.btnDisconnect.UseVisualStyleBackColor = true;
+            this.btnDisconnect.Click += new System.EventHandler(this.Disconnect_Click);
+            //
+            // rdoRTU
+            //
+            this.rdoRTU.AutoSize = true;
+            this.rdoRTU.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.rdoRTU.Location = new System.Drawing.Point(580, 115);
+            this.rdoRTU.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.rdoRTU.Name = "rdoRTU";
+            this.rdoRTU.Size = new System.Drawing.Size(320, 45);
+            this.rdoRTU.TabIndex = 10;
+            this.rdoRTU.Text = "ModbusRTU(串口透传)";
+            this.rdoRTU.UseVisualStyleBackColor = true;
+            //
+            // rdoTCP
+            //
+            this.rdoTCP.AutoSize = true;
+            this.rdoTCP.Checked = true;
+            this.rdoTCP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.rdoTCP.Location = new System.Drawing.Point(940, 115);
+            this.rdoTCP.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.rdoTCP.Name = "rdoTCP";
+            this.rdoTCP.Size = new System.Drawing.Size(200, 45);
+            this.rdoTCP.TabIndex = 11;
+            this.rdoTCP.TabStop = true;
+            this.rdoTCP.Text = "ModbusTCP";
+            this.rdoTCP.UseVisualStyleBackColor = true;
+            //
+            // grpData
+            //
+            this.grpData.BorderColor = System.Drawing.Color.Black;
+            this.grpData.Controls.Add(this.lblD141);
+            this.grpData.Controls.Add(this.lblD141Value);
+            this.grpData.Controls.Add(this.lblD142);
+            this.grpData.Controls.Add(this.lblD142Value);
+            this.grpData.Controls.Add(this.lblDecimals);
+            this.grpData.Controls.Add(this.decimals);
+            this.grpData.Controls.Add(this.btnReadNow);
+            this.grpData.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.grpData.Location = new System.Drawing.Point(32, 245);
+            this.grpData.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.grpData.Name = "grpData";
+            this.grpData.Size = new System.Drawing.Size(1540, 235);
+            this.grpData.TabIndex = 1;
+            this.grpData.TabStop = false;
+            this.grpData.Text = "烘烤温度(台达PLC)";
+            this.grpData.TextColor = System.Drawing.Color.Black;
+            //
+            // lblD141
+            //
+            this.lblD141.AutoSize = true;
+            this.lblD141.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblD141.Location = new System.Drawing.Point(32, 50);
+            this.lblD141.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblD141.Name = "lblD141";
+            this.lblD141.Size = new System.Drawing.Size(262, 52);
+            this.lblD141.TabIndex = 0;
+            this.lblD141.Text = "1#舱温度 (D141)";
+            //
+            // lblD141Value
+            //
+            this.lblD141Value.Font = new System.Drawing.Font("微软雅黑", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblD141Value.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
+            this.lblD141Value.Location = new System.Drawing.Point(330, 28);
+            this.lblD141Value.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblD141Value.Name = "lblD141Value";
+            this.lblD141Value.Size = new System.Drawing.Size(320, 85);
+            this.lblD141Value.TabIndex = 1;
+            this.lblD141Value.Text = "--";
+            //
+            // lblD142
+            //
+            this.lblD142.AutoSize = true;
+            this.lblD142.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblD142.Location = new System.Drawing.Point(820, 50);
+            this.lblD142.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblD142.Name = "lblD142";
+            this.lblD142.Size = new System.Drawing.Size(262, 52);
+            this.lblD142.TabIndex = 2;
+            this.lblD142.Text = "2#舱温度 (D142)";
+            //
+            // lblD142Value
+            //
+            this.lblD142Value.Font = new System.Drawing.Font("微软雅黑", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblD142Value.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
+            this.lblD142Value.Location = new System.Drawing.Point(1118, 28);
+            this.lblD142Value.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblD142Value.Name = "lblD142Value";
+            this.lblD142Value.Size = new System.Drawing.Size(320, 85);
+            this.lblD142Value.TabIndex = 3;
+            this.lblD142Value.Text = "--";
+            //
+            // lblDecimals
+            //
+            this.lblDecimals.AutoSize = true;
+            this.lblDecimals.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.lblDecimals.Location = new System.Drawing.Point(32, 155);
+            this.lblDecimals.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.lblDecimals.Name = "lblDecimals";
+            this.lblDecimals.Size = new System.Drawing.Size(162, 52);
+            this.lblDecimals.TabIndex = 4;
+            this.lblDecimals.Text = "温度小数位";
+            //
+            // decimals
+            //
+            this.decimals.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.decimals.Location = new System.Drawing.Point(220, 157);
+            this.decimals.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.decimals.Maximum = new decimal(new int[] {
+            3,
+            0,
+            0,
+            0});
+            this.decimals.Name = "decimals";
+            this.decimals.Size = new System.Drawing.Size(110, 51);
+            this.decimals.TabIndex = 5;
+            //
+            // btnReadNow
+            //
+            this.btnReadNow.AllPower = null;
+            this.btnReadNow.BackColor = System.Drawing.Color.Transparent;
+            this.btnReadNow.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.btnReadNow.IsShowBorder = true;
+            this.btnReadNow.Location = new System.Drawing.Point(420, 152);
+            this.btnReadNow.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.btnReadNow.Name = "btnReadNow";
+            this.btnReadNow.Power = null;
+            this.btnReadNow.Size = new System.Drawing.Size(180, 50);
+            this.btnReadNow.TabIndex = 6;
+            this.btnReadNow.Text = "立即读取";
+            this.btnReadNow.UseVisualStyleBackColor = true;
+            this.btnReadNow.Click += new System.EventHandler(this.ReadNow_Click);
+            //
             // grpSN
-            // 
+            //
             this.grpSN.BorderColor = System.Drawing.Color.Black;
             this.grpSN.Controls.Add(this.lblSN);
             this.grpSN.Controls.Add(this.sncode);
@@ -57,73 +380,76 @@
             this.grpSN.Controls.Add(this.lblBatchCode);
             this.grpSN.Controls.Add(this.btnStart);
             this.grpSN.Controls.Add(this.btnEnd);
+            this.grpSN.Controls.Add(this.lblQuery);
+            this.grpSN.Controls.Add(this.txtQueryBatch);
+            this.grpSN.Controls.Add(this.btnQuery);
             this.grpSN.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.grpSN.Location = new System.Drawing.Point(32, 30);
+            this.grpSN.Location = new System.Drawing.Point(32, 510);
             this.grpSN.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.grpSN.Name = "grpSN";
-            this.grpSN.Size = new System.Drawing.Size(1540, 210);
-            this.grpSN.TabIndex = 0;
+            this.grpSN.Size = new System.Drawing.Size(1540, 310);
+            this.grpSN.TabIndex = 2;
             this.grpSN.TabStop = false;
-            this.grpSN.Text = "SN录入";
+            this.grpSN.Text = "SN录入与批次";
             this.grpSN.TextColor = System.Drawing.Color.Black;
-            // 
+            //
             // lblSN
-            // 
+            //
             this.lblSN.AutoSize = true;
             this.lblSN.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblSN.Location = new System.Drawing.Point(32, 50);
+            this.lblSN.Location = new System.Drawing.Point(32, 45);
             this.lblSN.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.lblSN.Name = "lblSN";
             this.lblSN.Size = new System.Drawing.Size(62, 52);
             this.lblSN.TabIndex = 0;
             this.lblSN.Text = "SN";
-            // 
+            //
             // sncode
-            // 
+            //
             this.sncode.AllPower = null;
             this.sncode.BackColor = System.Drawing.Color.White;
             this.sncode.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.sncode.ID = null;
-            this.sncode.Location = new System.Drawing.Point(120, 45);
+            this.sncode.Location = new System.Drawing.Point(110, 40);
             this.sncode.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.sncode.Name = "sncode";
             this.sncode.Power = null;
-            this.sncode.Size = new System.Drawing.Size(480, 59);
+            this.sncode.Size = new System.Drawing.Size(460, 59);
             this.sncode.Str = null;
             this.sncode.Str1 = null;
             this.sncode.Str2 = null;
             this.sncode.TabIndex = 1;
             this.sncode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.sncode_KeyDown);
-            // 
+            //
             // lblBatch
-            // 
+            //
             this.lblBatch.AutoSize = true;
             this.lblBatch.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblBatch.Location = new System.Drawing.Point(700, 50);
+            this.lblBatch.Location = new System.Drawing.Point(640, 45);
             this.lblBatch.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.lblBatch.Name = "lblBatch";
             this.lblBatch.Size = new System.Drawing.Size(142, 52);
             this.lblBatch.TabIndex = 2;
             this.lblBatch.Text = "当前批次";
-            // 
+            //
             // lblBatchCode
-            // 
+            //
             this.lblBatchCode.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.lblBatchCode.ForeColor = System.Drawing.Color.Blue;
-            this.lblBatchCode.Location = new System.Drawing.Point(870, 50);
+            this.lblBatchCode.Location = new System.Drawing.Point(810, 45);
             this.lblBatchCode.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.lblBatchCode.Name = "lblBatchCode";
-            this.lblBatchCode.Size = new System.Drawing.Size(620, 52);
+            this.lblBatchCode.Size = new System.Drawing.Size(680, 52);
             this.lblBatchCode.TabIndex = 3;
             this.lblBatchCode.Text = "";
-            // 
+            //
             // btnStart
-            // 
+            //
             this.btnStart.AllPower = null;
             this.btnStart.BackColor = System.Drawing.Color.Transparent;
             this.btnStart.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.btnStart.IsShowBorder = true;
-            this.btnStart.Location = new System.Drawing.Point(120, 130);
+            this.btnStart.Location = new System.Drawing.Point(110, 120);
             this.btnStart.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.btnStart.Name = "btnStart";
             this.btnStart.Power = null;
@@ -132,14 +458,14 @@
             this.btnStart.Text = "开始烘烤";
             this.btnStart.UseVisualStyleBackColor = true;
             this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
-            // 
+            //
             // btnEnd
-            // 
+            //
             this.btnEnd.AllPower = null;
             this.btnEnd.BackColor = System.Drawing.Color.Transparent;
             this.btnEnd.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.btnEnd.IsShowBorder = true;
-            this.btnEnd.Location = new System.Drawing.Point(400, 130);
+            this.btnEnd.Location = new System.Drawing.Point(370, 120);
             this.btnEnd.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.btnEnd.Name = "btnEnd";
             this.btnEnd.Power = null;
@@ -148,41 +474,25 @@
             this.btnEnd.Text = "结束烘烤";
             this.btnEnd.UseVisualStyleBackColor = true;
             this.btnEnd.Click += new System.EventHandler(this.btnEnd_Click);
-            // 
-            // grpQuery
-            // 
-            this.grpQuery.BorderColor = System.Drawing.Color.Black;
-            this.grpQuery.Controls.Add(this.lblQuery);
-            this.grpQuery.Controls.Add(this.txtQueryBatch);
-            this.grpQuery.Controls.Add(this.btnQuery);
-            this.grpQuery.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.grpQuery.Location = new System.Drawing.Point(32, 270);
-            this.grpQuery.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.grpQuery.Name = "grpQuery";
-            this.grpQuery.Size = new System.Drawing.Size(1540, 150);
-            this.grpQuery.TabIndex = 1;
-            this.grpQuery.TabStop = false;
-            this.grpQuery.Text = "按批次查询";
-            this.grpQuery.TextColor = System.Drawing.Color.Black;
-            // 
+            //
             // lblQuery
-            // 
+            //
             this.lblQuery.AutoSize = true;
             this.lblQuery.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblQuery.Location = new System.Drawing.Point(32, 45);
+            this.lblQuery.Location = new System.Drawing.Point(32, 205);
             this.lblQuery.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.lblQuery.Name = "lblQuery";
             this.lblQuery.Size = new System.Drawing.Size(122, 52);
-            this.lblQuery.TabIndex = 0;
-            this.lblQuery.Text = "批次号";
-            // 
+            this.lblQuery.TabIndex = 6;
+            this.lblQuery.Text = "批次查询";
+            //
             // txtQueryBatch
-            // 
+            //
             this.txtQueryBatch.AllPower = null;
             this.txtQueryBatch.BackColor = System.Drawing.Color.White;
             this.txtQueryBatch.Font = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.txtQueryBatch.ID = null;
-            this.txtQueryBatch.Location = new System.Drawing.Point(180, 47);
+            this.txtQueryBatch.Location = new System.Drawing.Point(180, 207);
             this.txtQueryBatch.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.txtQueryBatch.Name = "txtQueryBatch";
             this.txtQueryBatch.Power = null;
@@ -190,40 +500,40 @@
             this.txtQueryBatch.Str = null;
             this.txtQueryBatch.Str1 = null;
             this.txtQueryBatch.Str2 = null;
-            this.txtQueryBatch.TabIndex = 1;
-            // 
+            this.txtQueryBatch.TabIndex = 7;
+            //
             // btnQuery
-            // 
+            //
             this.btnQuery.AllPower = null;
             this.btnQuery.BackColor = System.Drawing.Color.Transparent;
             this.btnQuery.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.btnQuery.IsShowBorder = true;
-            this.btnQuery.Location = new System.Drawing.Point(640, 47);
+            this.btnQuery.Location = new System.Drawing.Point(640, 205);
             this.btnQuery.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.btnQuery.Name = "btnQuery";
             this.btnQuery.Power = null;
             this.btnQuery.Size = new System.Drawing.Size(160, 52);
-            this.btnQuery.TabIndex = 2;
+            this.btnQuery.TabIndex = 8;
             this.btnQuery.Text = "查询";
             this.btnQuery.UseVisualStyleBackColor = true;
             this.btnQuery.Click += new System.EventHandler(this.btnQuery_Click);
-            // 
-            // grpData
-            // 
-            this.grpData.BorderColor = System.Drawing.Color.Black;
-            this.grpData.Controls.Add(this.DGV);
-            this.grpData.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.grpData.Location = new System.Drawing.Point(32, 450);
-            this.grpData.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.grpData.Name = "grpData";
-            this.grpData.Size = new System.Drawing.Size(1540, 600);
-            this.grpData.TabIndex = 2;
-            this.grpData.TabStop = false;
-            this.grpData.Text = "批次数据";
-            this.grpData.TextColor = System.Drawing.Color.Black;
-            // 
+            //
+            // grpdata2
+            //
+            this.grpdata2.BorderColor = System.Drawing.Color.Black;
+            this.grpdata2.Controls.Add(this.DGV);
+            this.grpdata2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.grpdata2.Location = new System.Drawing.Point(32, 850);
+            this.grpdata2.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.grpdata2.Name = "grpdata2";
+            this.grpdata2.Size = new System.Drawing.Size(1540, 420);
+            this.grpdata2.TabIndex = 3;
+            this.grpdata2.TabStop = false;
+            this.grpdata2.Text = "批次数据";
+            this.grpdata2.TextColor = System.Drawing.Color.Black;
+            //
             // DGV
-            // 
+            //
             this.DGV.AllowUserToAddRows = false;
             this.DGV.AllowUserToDeleteRows = false;
             this.DGV.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
@@ -237,43 +547,66 @@
             this.DGV.RowHeadersVisible = false;
             this.DGV.RowTemplate.Height = 37;
             this.DGV.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
-            this.DGV.Size = new System.Drawing.Size(1490, 520);
+            this.DGV.Size = new System.Drawing.Size(1490, 340);
             this.DGV.TabIndex = 0;
-            // 
+            //
             // lblStatus
-            // 
+            //
             this.lblStatus.AutoSize = true;
             this.lblStatus.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.lblStatus.ForeColor = System.Drawing.Color.Blue;
-            this.lblStatus.Location = new System.Drawing.Point(32, 1075);
+            this.lblStatus.Location = new System.Drawing.Point(32, 1288);
             this.lblStatus.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.lblStatus.Name = "lblStatus";
             this.lblStatus.Size = new System.Drawing.Size(102, 52);
-            this.lblStatus.TabIndex = 3;
+            this.lblStatus.TabIndex = 4;
             this.lblStatus.Text = "状态:";
-            // 
+            //
+            // OperatResult
+            //
+            this.OperatResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.OperatResult.Location = new System.Drawing.Point(200, 1290);
+            this.OperatResult.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.OperatResult.Name = "OperatResult";
+            this.OperatResult.Size = new System.Drawing.Size(1372, 200);
+            this.OperatResult.TabIndex = 5;
+            this.OperatResult.Text = "";
+            //
+            // timer1
+            //
+            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
+            //
             // Make_PartDry
-            // 
+            //
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1604, 1140);
+            this.ClientSize = new System.Drawing.Size(1604, 1515);
             this.Controls.Add(this.lblStatus);
-            this.Controls.Add(this.grpData);
-            this.Controls.Add(this.grpQuery);
+            this.Controls.Add(this.OperatResult);
+            this.Controls.Add(this.grpdata2);
             this.Controls.Add(this.grpSN);
+            this.Controls.Add(this.grpData);
+            this.Controls.Add(this.grpConnect);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
             this.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.Name = "Make_PartDry";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Tag = "Make!PartDry";
             this.Text = "零件烘烤";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Make_PartDry_FormClosing);
             this.Load += new System.EventHandler(this.Make_PartDry_Load);
             this.SizeChanged += new System.EventHandler(this.Make_PartDry_SizeChanged);
+            this.grpConnect.ResumeLayout(true);
+            this.grpConnect.PerformLayout();
+            this.grpData.ResumeLayout(true);
+            this.grpData.PerformLayout();
             this.grpSN.ResumeLayout(true);
             this.grpSN.PerformLayout();
-            this.grpQuery.ResumeLayout(true);
-            this.grpQuery.PerformLayout();
-            this.grpData.ResumeLayout(true);
+            this.grpdata2.ResumeLayout(true);
+            ((System.ComponentModel.ISupportInitialize)(this.port)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.unitid)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.interval)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.decimals)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.DGV)).EndInit();
             this.ResumeLayout(true);
             this.PerformLayout();
@@ -281,6 +614,27 @@
 
         #endregion
 
+        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpConnect;
+        private System.Windows.Forms.Label lblIp;
+        private CustomControl.TextBoxWithIcon.EnterTextBox ip;
+        private System.Windows.Forms.Label lblPort;
+        private System.Windows.Forms.NumericUpDown port;
+        private System.Windows.Forms.Label lblUnit;
+        private System.Windows.Forms.NumericUpDown unitid;
+        private System.Windows.Forms.Label lblInterval;
+        private System.Windows.Forms.NumericUpDown interval;
+        private CustomControl.ButtonUtil.NormalButton btnConnect;
+        private CustomControl.ButtonUtil.NormalButton btnDisconnect;
+        private System.Windows.Forms.RadioButton rdoRTU;
+        private System.Windows.Forms.RadioButton rdoTCP;
+        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpData;
+        private System.Windows.Forms.Label lblD141;
+        private System.Windows.Forms.Label lblD141Value;
+        private System.Windows.Forms.Label lblD142;
+        private System.Windows.Forms.Label lblD142Value;
+        private System.Windows.Forms.Label lblDecimals;
+        private System.Windows.Forms.NumericUpDown decimals;
+        private CustomControl.ButtonUtil.NormalButton btnReadNow;
         private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpSN;
         private System.Windows.Forms.Label lblSN;
         private CustomControl.TextBoxWithIcon.EnterTextBox sncode;
@@ -288,12 +642,13 @@
         private System.Windows.Forms.Label lblBatchCode;
         private CustomControl.ButtonUtil.NormalButton btnStart;
         private CustomControl.ButtonUtil.NormalButton btnEnd;
-        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpQuery;
         private System.Windows.Forms.Label lblQuery;
         private CustomControl.TextBoxWithIcon.EnterTextBox txtQueryBatch;
         private CustomControl.ButtonUtil.NormalButton btnQuery;
-        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpData;
+        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder grpdata2;
         private System.Windows.Forms.DataGridView DGV;
         private System.Windows.Forms.Label lblStatus;
+        private CustomControl.RichText.RichTextAutoBottom OperatResult;
+        private System.Windows.Forms.Timer timer1;
     }
 }

+ 392 - 1
UAS_MES_ZKLH/FunctionCode/Make/Make_PartDry.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
 using System.Drawing;
+using System.Net.Sockets;
 using System.Text;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
@@ -17,12 +18,32 @@ namespace UAS_MES_NEW.Make
         DataHelper dh;
         DataTable dt;
 
+        // ============ 零件烘烤批次相关 ============
         // 工序类型:烘烤页面固定写DRY,写入SB_STEPCODE用于和零件清洗区分
         const string StepCode = "DRY";
 
         // 当前批次号:结束烘烤后置空,下一个录入的SN会生成新的批次号
         string currentBatch = "";
 
+        // ============ PLC温度采集相关(Modbus) ============
+        // Modbus 连接对象(保持长连接,断线自动重连)
+        TcpClient plcClient;
+        NetworkStream plcStream;
+        bool plcConnected = false;
+        ushort transactionId = 0;
+        readonly object readLock = new object();
+
+        // 台达PLC数据寄存器:D寄存器对应Modbus保持寄存器(功能码0x03)
+        // ETH-DVP-2P模块手册寄存器表:D0~4095 的Modbus地址 = 0x1000 + D编号
+        // 如 D141 → 0x1000+141 = 0x108D;D4096以上是另一段(0x9000起),当前用不到
+        const int D141_ADDR = 141;
+        const int DVP_D_OFFSET = 0x1000;
+        const int READ_COUNT = 2;
+
+        // 温度记录表:每次采集往里插一条(1#舱、2#舱各一条)
+        const string TempLogTable = "TEMPLOG";
+        const string TempLogSeq = "TEMPLOG_SEQ";
+
         public Make_PartDry()
         {
             InitializeComponent();
@@ -32,6 +53,13 @@ namespace UAS_MES_NEW.Make
         {
             asc.controllInitializeSize(this);
             dh = SystemInf.dh;
+            // PLC连接参数默认值(ETH-DVP-2P模块默认IP,端口固定502)
+            ip.Text = "192.168.1.150";
+            port.Value = 502;
+            unitid.Value = 1;
+            interval.Value = 2;
+            decimals.Value = 1;
+            SetStatus("未连接PLC,请录入SN或先连接设备");
             // 恢复未结束的批次(比如中途退出页面的情况)
             object b = dh.getFieldDataByCondition("SINGLEBOARD", "max(SB_BATCHCODE)", "SB_STEPCODE='" + StepCode + "' and SB_ENDTIME is null");
             currentBatch = b == null ? "" : b.ToString();
@@ -44,10 +72,11 @@ namespace UAS_MES_NEW.Make
                 lblBatchCode.Text = currentBatch;
                 LoadBatchData(currentBatch);
             }
-            SetStatus("就绪,请录入SN");
             sncode.Focus();
         }
 
+        #region 零件烘烤:SN录入与批次管理
+
         /// <summary>
         /// 录入框回车:插入SN到SINGLEBOARD,本批次共用同一个批次号
         /// </summary>
@@ -176,11 +205,373 @@ namespace UAS_MES_NEW.Make
             DGV.DataSource = dt;
         }
 
+        #endregion
+
+        #region PLC温度采集(Modbus)
+
+        /// <summary>
+        /// 连接串口转网口模块(ETH-DVP-2P,Modbus TCP)
+        /// </summary>
+        private void Connect_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                ClosePlc();
+                plcClient = new TcpClient();
+                IAsyncResult ar = plcClient.BeginConnect(ip.Text.Trim(), (int)port.Value, null, null);
+                if (!ar.AsyncWaitHandle.WaitOne(3000))
+                {
+                    ClosePlc();
+                    SetStatus("PLC连接超时");
+                    MessageBox.Show("连接PLC超时,请检查IP和端口!");
+                    return;
+                }
+                plcClient.EndConnect(ar);
+                plcClient.ReceiveTimeout = 5000;
+                plcClient.SendTimeout = 5000;
+                plcStream = plcClient.GetStream();
+                plcConnected = true;
+                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 已连接 " + ip.Text.Trim() + ":" + port.Value + ",站号" + unitid.Value + "\n");
+                SetStatus("已连接PLC " + ip.Text.Trim() + ":" + port.Value);
+                timer1.Interval = (int)interval.Value * 1000;
+                timer1.Start();
+                // 连接成功后立即读一次
+                ReadNow_Click(null, null);
+            }
+            catch (Exception ex)
+            {
+                ClosePlc();
+                SetStatus("PLC连接失败:" + ex.Message);
+                MessageBox.Show("连接失败:" + ex.Message);
+            }
+        }
+
+        /// <summary>
+        /// 断开PLC连接
+        /// </summary>
+        private void Disconnect_Click(object sender, EventArgs e)
+        {
+            timer1.Stop();
+            ClosePlc();
+            SetStatus("PLC已断开");
+            OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 已断开连接\n");
+        }
+
+        /// <summary>
+        /// 立即读取一次温度
+        /// </summary>
+        private void ReadNow_Click(object sender, EventArgs e)
+        {
+            if (!plcConnected)
+            {
+                SetStatus("未连接PLC");
+                return;
+            }
+            try
+            {
+                // D寄存器地址要加台达DVP的0x1000偏移:D141→0x108D, D142→0x108E
+                int[] values = ReadRegisters((ushort)(DVP_D_OFFSET + D141_ADDR), READ_COUNT);
+                ShowValues(values);
+                InsertTempLog(values);
+                SetStatus("读取成功 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
+            }
+            catch (Exception ex)
+            {
+                // 读取失败:断开连接,等待下一次重连
+                timer1.Stop();
+                ClosePlc();
+                plcConnected = false;
+                string mode = rdoTCP.Checked ? "ModbusTCP" : "ModbusRTU(透传)";
+                SetStatus("读取失败:" + ex.Message);
+                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 读取失败(" + mode + "):" + ex.Message + "\n");
+                if (ex.Message.Contains("超时") || ex.Message.Contains("没有正确答复") || ex.Message.Contains("连接已断开"))
+                {
+                    OperatResult.AppendText("[提示] 如果RTU(透传)模式一直超时,请尝试切换到ModbusTCP模式;反之亦然。同时确认模块透传设置、PLC串口参数(9600/8/N/1)和站号。\n");
+                }
+                // 自动重连
+                TryReconnect();
+            }
+        }
+
+        /// <summary>
+        /// 定时获取温度数据
+        /// </summary>
+        private void timer1_Tick(object sender, EventArgs e)
+        {
+            if (!plcConnected)
+            {
+                TryReconnect();
+                return;
+            }
+            ReadNow_Click(null, null);
+        }
+
+        /// <summary>
+        /// 尝试重新连接(不打断界面,仅更新状态)
+        /// </summary>
+        private void TryReconnect()
+        {
+            try
+            {
+                ClosePlc();
+                plcClient = new TcpClient();
+                IAsyncResult ar = plcClient.BeginConnect(ip.Text.Trim(), (int)port.Value, null, null);
+                if (!ar.AsyncWaitHandle.WaitOne(3000))
+                {
+                    ClosePlc();
+                    SetStatus("PLC重连超时,继续重试...");
+                    return;
+                }
+                plcClient.EndConnect(ar);
+                plcClient.ReceiveTimeout = 5000;
+                plcClient.SendTimeout = 5000;
+                plcStream = plcClient.GetStream();
+                plcConnected = true;
+                SetStatus("PLC重连成功 " + DateTime.Now.ToString("HH:mm:ss"));
+                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 重连成功\n");
+            }
+            catch
+            {
+                ClosePlc();
+                SetStatus("PLC重连失败,继续重试...");
+            }
+        }
+
+        /// <summary>
+        /// 把本次采集的温度写入TEMPLOG表,1#舱、2#舱各一条
+        /// TL_ID=序列TEMPLOG_SEQ,TL_DATE=sysdate,TL_DEVICEID=舱号,TL_TP=换算后的温度
+        /// </summary>
+        private void InsertTempLog(int[] values)
+        {
+            if (values == null || values.Length < 2) return;
+            try
+            {
+                int d = (int)decimals.Value;
+                double v1 = values[0] / Math.Pow(10, d);
+                double v2 = values[1] / Math.Pow(10, d);
+                string v1s = v1.ToString("0.###");
+                string v2s = v2.ToString("0.###");
+                dh.ExecuteSql("insert into " + TempLogTable + "(TL_ID,TL_DATE,TL_DEVICEID,TL_TP)values(" + TempLogSeq + ".nextval,sysdate,'1#'," + v1s + ")", "insert");
+                dh.ExecuteSql("insert into " + TempLogTable + "(TL_ID,TL_DATE,TL_DEVICEID,TL_TP)values(" + TempLogSeq + ".nextval,sysdate,'2#'," + v2s + ")", "insert");
+            }
+            catch (Exception ex)
+            {
+                // 插入失败不影响采集显示,只记录
+                OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 写入" + TempLogTable + "失败:" + ex.Message + "\n");
+            }
+        }
+
+        /// <summary>
+        /// 显示温度值,并根据小数位设置换算(台达一般存实际值x10)
+        /// </summary>
+        private void ShowValues(int[] values)
+        {
+            if (values == null || values.Length < 2) return;
+            int d = (int)decimals.Value;
+            double v1 = values[0] / Math.Pow(10, d);
+            double v2 = values[1] / Math.Pow(10, d);
+            string fmt = d > 0 ? "F" + d : "F0";
+            lblD141Value.Text = v1.ToString(fmt);
+            lblD142Value.Text = v2.ToString(fmt);
+            OperatResult.AppendText("[" + DateTime.Now.ToString("HH:mm:ss") + "] 1#舱(D141)=" + values[0] + "  2#舱(D142)=" + values[1] + "\n");
+        }
+
+        /// <summary>
+        /// 读保持寄存器(功能码0x03),按界面选择的协议分发:
+        /// ModbusRTU(串口透传):模块把TCP数据原样转发到串口,要发带CRC16的RTU裸帧
+        /// ModbusTCP:模块/PLC本身是标准Modbus TCP服务端,发带MBAP头的帧
+        /// </summary>
+        private int[] ReadRegisters(ushort startAddr, ushort count)
+        {
+            if (rdoTCP.Checked)
+            {
+                return ReadTcpRegisters(startAddr, count);
+            }
+            return ReadRtuRegisters(startAddr, count);
+        }
+
+        /// <summary>
+        /// Modbus RTU over TCP(串口透传模式):站号+功能码+数据+CRC16
+        /// </summary>
+        private int[] ReadRtuRegisters(ushort startAddr, ushort count)
+        {
+            lock (readLock)
+            {
+                if (!plcConnected || plcStream == null)
+                {
+                    throw new Exception("未连接PLC");
+                }
+                byte unit = (byte)unitid.Value;
+                byte[] req = new byte[8];
+                req[0] = unit;
+                // 功能码0x03 读保持寄存器
+                req[1] = 0x03;
+                req[2] = (byte)(startAddr >> 8);
+                req[3] = (byte)(startAddr & 0xFF);
+                req[4] = (byte)(count >> 8);
+                req[5] = (byte)(count & 0xFF);
+                ushort crc = CalcCRC16(req, 6);
+                // Modbus RTU CRC低字节在前
+                req[6] = (byte)(crc & 0xFF);
+                req[7] = (byte)((crc >> 8) & 0xFF);
+                plcStream.Write(req, 0, req.Length);
+
+                // 响应:站号+功能码+字节数
+                byte[] head = ReadBytes(plcStream, 3);
+                if (head[0] != unit)
+                {
+                    throw new Exception("响应站号不匹配(收到0x" + head[0].ToString("X2") + "),请检查站号设置");
+                }
+                if ((head[1] & 0x80) != 0)
+                {
+                    byte[] rest = ReadBytes(plcStream, 3);
+                    throw new Exception("PLC返回异常码 0x" + rest[0].ToString("X2"));
+                }
+                int byteCount = head[2];
+                byte[] rest2 = ReadBytes(plcStream, byteCount + 2);
+                // CRC校验:响应最后2字节是CRC
+                byte[] full = new byte[3 + byteCount + 2];
+                Array.Copy(head, 0, full, 0, 3);
+                Array.Copy(rest2, 0, full, 3, byteCount + 2);
+                ushort calcCrc = CalcCRC16(full, full.Length - 2);
+                ushort recvCrc = (ushort)(full[full.Length - 2] | (full[full.Length - 1] << 8));
+                if (calcCrc != recvCrc)
+                {
+                    throw new Exception("响应CRC校验失败,串口参数(波特率/校验位)可能与PLC不一致");
+                }
+                int[] values = new int[count];
+                for (int i = 0; i < count; i++)
+                {
+                    values[i] = (rest2[i * 2] << 8) | rest2[i * 2 + 1];
+                }
+                return values;
+            }
+        }
+
+        /// <summary>
+        /// Modbus TCP 读保持寄存器(功能码0x03),带MBAP头
+        /// </summary>
+        private int[] ReadTcpRegisters(ushort startAddr, ushort count)
+        {
+            lock (readLock)
+            {
+                if (!plcConnected || plcStream == null)
+                {
+                    throw new Exception("未连接PLC");
+                }
+                transactionId++;
+                byte[] req = new byte[12];
+                // MBAP头:事务标识、协议标识0、长度6、单元标识符
+                req[0] = (byte)(transactionId >> 8);
+                req[1] = (byte)(transactionId & 0xFF);
+                req[2] = 0x00;
+                req[3] = 0x00;
+                req[4] = 0x00;
+                req[5] = 0x06;
+                req[6] = (byte)unitid.Value;
+                // 功能码0x03 读保持寄存器
+                req[7] = 0x03;
+                req[8] = (byte)(startAddr >> 8);
+                req[9] = (byte)(startAddr & 0xFF);
+                req[10] = (byte)(count >> 8);
+                req[11] = (byte)(count & 0xFF);
+                plcStream.Write(req, 0, req.Length);
+
+                byte[] head = ReadBytes(plcStream, 9);
+                if ((head[7] & 0x80) != 0)
+                {
+                    byte[] ec = ReadBytes(plcStream, 1);
+                    throw new Exception("PLC返回异常码 0x" + (ec.Length > 0 ? ec[0] : 0).ToString("X2"));
+                }
+                int byteCount = head[8];
+                byte[] data = ReadBytes(plcStream, byteCount);
+                int[] values = new int[count];
+                for (int i = 0; i < count; i++)
+                {
+                    values[i] = (data[i * 2] << 8) | data[i * 2 + 1];
+                }
+                return values;
+            }
+        }
+
+        /// <summary>
+        /// Modbus RTU CRC16校验
+        /// </summary>
+        private ushort CalcCRC16(byte[] data, int length)
+        {
+            ushort crc = 0xFFFF;
+            for (int i = 0; i < length; i++)
+            {
+                crc ^= data[i];
+                for (int j = 0; j < 8; j++)
+                {
+                    if ((crc & 0x0001) != 0)
+                    {
+                        crc = (ushort)((crc >> 1) ^ 0xA001);
+                    }
+                    else
+                    {
+                        crc = (ushort)(crc >> 1);
+                    }
+                }
+            }
+            return crc;
+        }
+
+        /// <summary>
+        /// 从流中读满指定长度,读不满视为连接异常
+        /// </summary>
+        private byte[] ReadBytes(NetworkStream stream, int length)
+        {
+            byte[] buffer = new byte[length];
+            int read = 0;
+            while (read < length)
+            {
+                int n = stream.Read(buffer, read, length - read);
+                if (n <= 0)
+                {
+                    throw new Exception("连接已断开");
+                }
+                read += n;
+            }
+            return buffer;
+        }
+
+        /// <summary>
+        /// 关闭PLC连接
+        /// </summary>
+        private void ClosePlc()
+        {
+            try
+            {
+                if (plcStream != null)
+                {
+                    plcStream.Close();
+                    plcStream = null;
+                }
+                if (plcClient != null)
+                {
+                    plcClient.Close();
+                    plcClient = null;
+                }
+            }
+            catch { }
+            plcConnected = false;
+        }
+
+        #endregion
+
         private void SetStatus(string text)
         {
             lblStatus.Text = "状态:" + text;
         }
 
+        private void Make_PartDry_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            timer1.Stop();
+            ClosePlc();
+        }
+
         private void Make_PartDry_SizeChanged(object sender, EventArgs e)
         {
             asc.controlAutoSize(this);

+ 0 - 9
UAS_MES_ZKLH/UAS_MES_ZKLH.csproj

@@ -794,12 +794,6 @@
     <Compile Include="FunctionCode\Make\Make_CollectNetCode.Designer.cs">
       <DependentUpon>Make_CollectNetCode.cs</DependentUpon>
     </Compile>
-    <Compile Include="FunctionCode\Make\Make_PLCMonitor.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="FunctionCode\Make\Make_PLCMonitor.Designer.cs">
-      <DependentUpon>Make_PLCMonitor.cs</DependentUpon>
-    </Compile>
     <Compile Include="FunctionCode\Make\Make_PartClean.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -1742,9 +1736,6 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_CollectNetCode.resx">
       <DependentUpon>Make_CollectNetCode.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="FunctionCode\Make\Make_PLCMonitor.resx">
-      <DependentUpon>Make_PLCMonitor.cs</DependentUpon>
-    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_PartClean.resx">
       <DependentUpon>Make_PartClean.cs</DependentUpon>
     </EmbeddedResource>