WIN-GH9CEESPLTB\Administrator hai 4 meses
pai
achega
021060c423

+ 0 - 8
MainForm/ClassFile/XiaomiAPI_IOT/Extend/XiaomiMqttClient_DeviceStateData.cs

@@ -95,13 +95,5 @@ namespace MainForm.ClassFile.XiaomiAPI
             /// </summary>
             public string fault_tm { get; set; } = string.Empty;
         }
-        /// <summary>
-        /// 包含左右工位的设备
-        /// </summary>
-        public struct DeviceStateDataRequest2Station
-        {
-            public DeviceStateDataRequest left;
-            public DeviceStateDataRequest right;
-        }
     }
  }

+ 16 - 6
MainForm/ClassFile/XiaomiAPI_IOT/Extend/XiaomiMqttClient_StationInputBegin.cs

@@ -1,5 +1,7 @@
-using Newtonsoft.Json;
+using BZFAStandardLib;
+using Newtonsoft.Json;
 using System;
+using System.Threading.Tasks;
 
 namespace MainForm.ClassFile.XiaomiAPI
 {
@@ -30,7 +32,7 @@ namespace MainForm.ClassFile.XiaomiAPI
         /// <param name="msg">事件数据;Json</param>
         /// <param name="dataId">自定义事件Id;如:guid</param>
         /// <returns></returns>
-        public static (int, string) Write_StationInputBegin(StationInputBeginRequest request, string dataId = "")
+        public static (int, string) Write_StationInputBegin(StationInputBeginRequest request, string deviceCode = "")
         {
             int result = 0;
             string resultStr = "";
@@ -39,12 +41,19 @@ namespace MainForm.ClassFile.XiaomiAPI
             byte[] bytes = ToUTF8(msg);
 
             request.action = string.Format(StationInputBeginId, request.action);
-
             // 发送
-            if (string.IsNullOrEmpty(dataId))
-                result = Write(request.action, bytes);
+            if (string.IsNullOrEmpty(deviceCode))
+            {
+                bool isOk = Task.Run(() => { result = Write(request.action, bytes); }).Wait(10000);
+                if (!isOk)  // 无响应
+                    return (-999, "上位机调用Iot的dll无响应[方法名Write]!");
+            }
             else
-                result = WriteWithDataId(request.action, bytes, dataId);
+            {
+                bool isOk = Task.Run(() => { result = WriteWithDeviceCode(request.action, bytes, deviceCode); }).Wait(10000);
+                if (!isOk)  // 无响应
+                    return (-999, "上位机调用Iot的dll无响应[方法名WriteWithDeviceCode]!");
+            }
 
             var try1 = Enum.TryParse(result.ToString(), out XiaomiMqttResponse_ErrCode errCode);
             if (try1)
@@ -52,6 +61,7 @@ namespace MainForm.ClassFile.XiaomiAPI
             else
                 resultStr = XiaomiMqttResponse_ErrCode.ERR_UNKOWN.ToString();
 
+            FileOperate.NewTxtFile(GlobalContext.MqttInputBeginDir, "MQTT【节拍日志】提交:" + msg + "\r\n==>提交结果:" + resultStr + "");
             return (result, resultStr);
         }
 

+ 69 - 69
MainForm/FaForm/Form_Home.Designer.cs

@@ -30,13 +30,14 @@
         {
             this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form_Home));
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle41 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle43 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle44 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle42 = new System.Windows.Forms.DataGridViewCellStyle();
             this.panel1 = new System.Windows.Forms.Panel();
             this.groupBox3 = new System.Windows.Forms.GroupBox();
-            this.lblDeviceStates = new Sunny.UI.UILabel();
+            this.uiLabel3 = new Sunny.UI.UILabel();
+            this.uiLabel1 = new Sunny.UI.UILabel();
             this.uiLabel2 = new Sunny.UI.UILabel();
             this.txt_CurSupplierCode = new System.Windows.Forms.TextBox();
             this.label20 = new System.Windows.Forms.Label();
@@ -79,8 +80,7 @@
             this.colTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.colMessage = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.imageListState = new System.Windows.Forms.ImageList(this.components);
-            this.uiLabel1 = new Sunny.UI.UILabel();
-            this.uiLabel3 = new Sunny.UI.UILabel();
+            this.lblDeviceStates = new Sunny.UI.UILabel();
             this.panel1.SuspendLayout();
             this.groupBox3.SuspendLayout();
             this.panel2.SuspendLayout();
@@ -126,9 +126,9 @@
             // 
             // groupBox3
             // 
+            this.groupBox3.Controls.Add(this.lblDeviceStates);
             this.groupBox3.Controls.Add(this.uiLabel3);
             this.groupBox3.Controls.Add(this.uiLabel1);
-            this.groupBox3.Controls.Add(this.lblDeviceStates);
             this.groupBox3.Controls.Add(this.uiLabel2);
             this.groupBox3.Controls.Add(this.txt_CurSupplierCode);
             this.groupBox3.Controls.Add(this.label20);
@@ -147,31 +147,46 @@
             this.groupBox3.TabStop = false;
             this.groupBox3.Text = "当前加工订单信息";
             // 
-            // lblDeviceStates
+            // uiLabel3
             // 
-            this.lblDeviceStates.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.lblDeviceStates.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lblDeviceStates.ForeColor = System.Drawing.Color.Blue;
-            this.lblDeviceStates.Location = new System.Drawing.Point(1134, 48);
-            this.lblDeviceStates.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.lblDeviceStates.Name = "lblDeviceStates";
-            this.lblDeviceStates.Size = new System.Drawing.Size(261, 50);
-            this.lblDeviceStates.TabIndex = 97;
-            this.lblDeviceStates.Text = "未初始状态";
-            this.lblDeviceStates.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            this.uiLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.uiLabel3.Font = new System.Drawing.Font("微软雅黑", 10.8F);
+            this.uiLabel3.ForeColor = System.Drawing.Color.Blue;
+            this.uiLabel3.Location = new System.Drawing.Point(1206, 113);
+            this.uiLabel3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.uiLabel3.Name = "uiLabel3";
+            this.uiLabel3.Size = new System.Drawing.Size(261, 50);
+            this.uiLabel3.TabIndex = 99;
+            this.uiLabel3.Text = "未初始状态";
+            this.uiLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            this.uiLabel3.Visible = false;
+            // 
+            // uiLabel1
+            // 
+            this.uiLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 10.8F);
+            this.uiLabel1.ForeColor = System.Drawing.SystemColors.InfoText;
+            this.uiLabel1.Location = new System.Drawing.Point(1067, 50);
+            this.uiLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.uiLabel1.Name = "uiLabel1";
+            this.uiLabel1.Size = new System.Drawing.Size(240, 50);
+            this.uiLabel1.TabIndex = 98;
+            this.uiLabel1.Text = "设备状态:";
+            this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
             // 
             // uiLabel2
             // 
             this.uiLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.uiLabel2.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 10.8F);
             this.uiLabel2.ForeColor = System.Drawing.SystemColors.InfoText;
-            this.uiLabel2.Location = new System.Drawing.Point(976, 48);
+            this.uiLabel2.Location = new System.Drawing.Point(1067, 113);
             this.uiLabel2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.uiLabel2.Name = "uiLabel2";
-            this.uiLabel2.Size = new System.Drawing.Size(177, 50);
+            this.uiLabel2.Size = new System.Drawing.Size(240, 50);
             this.uiLabel2.TabIndex = 96;
             this.uiLabel2.Text = "设备状态:";
             this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            this.uiLabel2.Visible = false;
             // 
             // txt_CurSupplierCode
             // 
@@ -603,14 +618,14 @@
             this.systemLog.AllowUserToResizeRows = false;
             this.systemLog.BackgroundColor = System.Drawing.Color.White;
             this.systemLog.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
-            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle5.BackColor = System.Drawing.Color.WhiteSmoke;
-            dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.systemLog.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
+            dataGridViewCellStyle41.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle41.BackColor = System.Drawing.Color.WhiteSmoke;
+            dataGridViewCellStyle41.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle41.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle41.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle41.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle41.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.systemLog.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle41;
             this.systemLog.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.systemLog.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.colDate,
@@ -622,19 +637,19 @@
             this.systemLog.Location = new System.Drawing.Point(3, 32);
             this.systemLog.Name = "systemLog";
             this.systemLog.ReadOnly = true;
-            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle7.BackColor = System.Drawing.Color.WhiteSmoke;
-            dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.systemLog.RowHeadersDefaultCellStyle = dataGridViewCellStyle7;
+            dataGridViewCellStyle43.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle43.BackColor = System.Drawing.Color.WhiteSmoke;
+            dataGridViewCellStyle43.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle43.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle43.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle43.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle43.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.systemLog.RowHeadersDefaultCellStyle = dataGridViewCellStyle43;
             this.systemLog.RowHeadersVisible = false;
             this.systemLog.RowHeadersWidth = 51;
             this.systemLog.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
-            dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.systemLog.RowsDefaultCellStyle = dataGridViewCellStyle8;
+            dataGridViewCellStyle44.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.systemLog.RowsDefaultCellStyle = dataGridViewCellStyle44;
             this.systemLog.RowTemplate.Height = 27;
             this.systemLog.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.systemLog.Size = new System.Drawing.Size(1533, 435);
@@ -642,8 +657,8 @@
             // 
             // colDate
             // 
-            dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.colDate.DefaultCellStyle = dataGridViewCellStyle6;
+            dataGridViewCellStyle42.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.colDate.DefaultCellStyle = dataGridViewCellStyle42;
             this.colDate.HeaderText = "日期";
             this.colDate.MinimumWidth = 6;
             this.colDate.Name = "colDate";
@@ -677,33 +692,18 @@
             this.imageListState.Images.SetKeyName(1, "light_green.png");
             this.imageListState.Images.SetKeyName(2, "light_red.png");
             // 
-            // uiLabel1
-            // 
-            this.uiLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.uiLabel1.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.uiLabel1.ForeColor = System.Drawing.SystemColors.InfoText;
-            this.uiLabel1.Location = new System.Drawing.Point(976, 106);
-            this.uiLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.uiLabel1.Name = "uiLabel1";
-            this.uiLabel1.Size = new System.Drawing.Size(177, 50);
-            this.uiLabel1.TabIndex = 98;
-            this.uiLabel1.Text = "设备状态:";
-            this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
-            this.uiLabel1.Visible = false;
-            // 
-            // uiLabel3
+            // lblDeviceStates
             // 
-            this.uiLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-            this.uiLabel3.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.uiLabel3.ForeColor = System.Drawing.Color.Blue;
-            this.uiLabel3.Location = new System.Drawing.Point(1134, 106);
-            this.uiLabel3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.uiLabel3.Name = "uiLabel3";
-            this.uiLabel3.Size = new System.Drawing.Size(261, 50);
-            this.uiLabel3.TabIndex = 99;
-            this.uiLabel3.Text = "未初始状态";
-            this.uiLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
-            this.uiLabel3.Visible = false;
+            this.lblDeviceStates.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+            this.lblDeviceStates.Font = new System.Drawing.Font("微软雅黑", 10.8F);
+            this.lblDeviceStates.ForeColor = System.Drawing.Color.Blue;
+            this.lblDeviceStates.Location = new System.Drawing.Point(1205, 50);
+            this.lblDeviceStates.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.lblDeviceStates.Name = "lblDeviceStates";
+            this.lblDeviceStates.Size = new System.Drawing.Size(261, 50);
+            this.lblDeviceStates.TabIndex = 100;
+            this.lblDeviceStates.Text = "未初始状态";
+            this.lblDeviceStates.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
             // 
             // Form_Home
             // 
@@ -799,9 +799,9 @@
         private System.Windows.Forms.PictureBox picAgvHttp;
         private System.Windows.Forms.GroupBox groupBox15;
         private System.Windows.Forms.PictureBox picAgvMqtt;
-        private Sunny.UI.UILabel lblDeviceStates;
         private Sunny.UI.UILabel uiLabel2;
         private Sunny.UI.UILabel uiLabel3;
         private Sunny.UI.UILabel uiLabel1;
+        private Sunny.UI.UILabel lblDeviceStates;
     }
 }

+ 40 - 8
MainForm/FaForm/Form_Home.cs

@@ -317,7 +317,7 @@ namespace MainForm
                             if (GlobalContext.IsUsePLC3)
                             {
                                 param.parameter.equipment.deviceCode = GlobalContext.s3_1_device_code;  // 装备编码
-                                param.parameter.equipment.stationCode = GlobalContext.s3_1_station;     // ⼯位Id
+                                //param.parameter.equipment.stationCode = GlobalContext.s3_1_station;     // ⼯位Id
                             }
                             if (GlobalContext.IsUsePLC4)
                             {
@@ -337,7 +337,7 @@ namespace MainForm
                             if (GlobalContext.IsUsePLC7)
                             {
                                 param.parameter.equipment.deviceCode = GlobalContext.s7_1_device_code;  // 装备编码
-                                param.parameter.equipment.stationCode = GlobalContext.s7_1_station;     // ⼯位Id
+                                //param.parameter.equipment.stationCode = GlobalContext.s7_1_station;     // ⼯位Id
                             }
                             if (GlobalContext.IsUsePLC8)
                             {
@@ -439,6 +439,13 @@ namespace MainForm
                     //if (Funs.Count > 1)
                     //    DownLoadProductInfo(1);
 
+                    if (GlobalContext.IsUsePLC3 || GlobalContext.IsUsePLC7) {
+                        uiLabel1.Text = "设备状态(左):";
+                        uiLabel2.Text = "设备状态(右):";
+                        uiLabel3.Visible = true;
+                        uiLabel2.Visible = true;
+                    }
+
                     AddMessage(LogType.Info, "程序初始化完成");
                 }
                 catch (Exception ex)
@@ -1977,12 +1984,12 @@ namespace MainForm
             s1PLCSignal_Old.Add("a1OEEType", 0);          // 节拍类型(plc写入) 
 
             // PLC数据字典 赋值 
-            //s1PLCData.Add("a1OEEPLC_FLAG", 0);      // PLC_FLAG 节拍接口
             s1PLCData.Add("a1OEEType", 0);          // 节拍类型(plc写入) 
             s1PLCData.Add("a1OEEPartNo", "");       // 物料码(物料码还未绑定载具SN时必填)
             s1PLCData.Add("a1OEEVehicleCode", "");  // 载具SN
 
             OP10_MesData_t stPLC_MesData;        //PLC的MES数据
+            IoT_DataSet_t iot_data;
             (int, string) result;
 
             while (true)
@@ -2018,7 +2025,6 @@ namespace MainForm
                             s1PLCData["a1OEEPartNo"] = stPLC_MesData.BarcodeSet.strProductBarcode;  // 物料码(物料码还未绑定载具SN时必填)
                             s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.BarcodeSet.strCarrierBarcode;  // 载具SN
                             s1PLCData["a1OEEType"] = stPLC_MesData.iotData.BeatAction;  // 节拍
-
                         }
                         #endregion 一次性读取所有数据
                         stopwatch2.Stop();
@@ -2074,12 +2080,31 @@ namespace MainForm
                         #region 节拍接口
                         try
                         {
-                            int a1OEEPLC_FLAG = (int)s1PLCData["a1OEEType"];
-                            int a1OEEPLC_FLAGOld = (int)s1PLCSignal_Old["a1OEEType"];
-                            if (a1OEEPLC_FLAG != a1OEEPLC_FLAGOld)
+                            int a1OEEType = (int)s1PLCData["a1OEEType"];
+                            int a1OEETypeGOld = (int)s1PLCSignal_Old["a1OEEType"];
+                            //若设备紧急复原后节拍重置
+                            if (a1OEEType==1)
                             {
-                                if (a1OEEPLC_FLAG == 1)
+                                a1OEETypeGOld = 0;
+                            }
+                            if (a1OEEType != a1OEETypeGOld)
+                            {
+                                //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
+                                if ((a1OEETypeGOld==1 && a1OEEType!=2) || (a1OEETypeGOld == 3 && a1OEEType != 4) || (a1OEETypeGOld == 5 && a1OEEType != 6)) {
+                                    //写入PLC
+                                    iot_data.machineState = stPLC_MesData.iotData.machineState;
+                                    iot_data.work_type = stPLC_MesData.iotData.work_type;
+                                    iot_data.testStatus = stPLC_MesData.iotData.testStatus;
+                                    iot_data.BeatAction = stPLC_MesData.iotData.BeatAction;
+                                    iot_data.beatReturn = 2;//NG
+                                    iot_data.fault_codes = stPLC_MesData.iotData.fault_codes;
+                                    WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
+                                    AddMessage(LogType.Info, stationNameStr + $"_节拍接口-- 设备本次上传节拍[{a1OEEType}],未上传节拍[{a1OEETypeGOld}]的结束信号,请检查;总用时" + stopwatch1.ElapsedMilliseconds + "ms;写入用时" + stopwatch2.ElapsedMilliseconds + "ms");
+                                    return;
+                                }
+                                else {
                                     Task.Run(() => S1节拍接口(plcNo, stationNameStr, tagBaseName, stPLC_MesData));  // MreTasks[4].Set();
+                                }
 
                                 s1PLCSignal_Old["a1OEEType"] = s1PLCData["a1OEEType"];
                             }
@@ -2669,6 +2694,13 @@ namespace MainForm
                         else
                         {
                             //richTextBox1.AppendText("\n" + "读取成功");
+                            //int xmDeviceStateInt_L = stPLC_MesData.Left.iotData.machineState;
+                            //int xmDeviceStateInt_R = stPLC_MesData.Right.iotData.machineState;
+                            int xmDeviceStateInt_L = 1;
+                            int xmDeviceStateInt_R = 2;
+                            xmDeviceStateData.left = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7) ? XiaomiDeviceState.Unknown : (XiaomiDeviceState)xmDeviceStateInt_L;
+                            xmDeviceStateData.right = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7) ? XiaomiDeviceState.Unknown : (XiaomiDeviceState)xmDeviceStateInt_R;
+
                         }
                         #endregion 一次性读取所有数据
                         stopwatch2.Stop();

+ 1 - 1
MainForm/FaForm/Form_Home.resx

@@ -8367,7 +8367,7 @@
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
         ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACQ
-        PgAAAk1TRnQBSQFMAgEBAwEAAcgBCAHIAQgBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
+        PgAAAk1TRnQBSQFMAgEBAwEAAdABCAHQAQgBIAEAASABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGA
         AwABIAMAAQEBAAEgBgABQP8A/wA8AAP5Af8DzgH/A6gB/wOLAf8DeAH/A3EB/wNxAf8DeAH/A4sB/wOo
         Af8DzwH/A/kB/1AAAfcB+wH3Af8BuwHgAbYB/wGGAcgBfAH/AV0BtQFQAf8BQgGpATMB/wE5AaUBKQH/
         ATkBpQEpAf8BQwGqATQB/wFdAbYBUAH/AYUByAF7Af8BvAHhAbcB/wH3AfsB9wH/UAAB9gH1AfsB/wGw

+ 16 - 28
MainForm/FaForm/Form_Home_SaveData.cs

@@ -745,24 +745,29 @@ namespace MainForm
                 if (GlobalContext.IsUseIot && GlobalContext.IsMqttDeviceState)
                 {
                     DeviceStateDataRequest request = new DeviceStateDataRequest();
-                    DeviceStateDataRequest2Station request2 = new DeviceStateDataRequest2Station();
 
                     if (GlobalContext.IsUsePLC1)
                         request.station = GlobalContext.S1_station;    // 工位ID(可配置)
                     if (GlobalContext.IsUsePLC2)
                         request.station = GlobalContext.S2_station;    // 工位ID(可配置)
-                    if (GlobalContext.IsUsePLC3)
-                        request2.left.station = GlobalContext.s3_1_station;    // 工位ID(可配置)
-                        request2.right.station = GlobalContext.s3_2_station;  // ⼯位ID(可配置)
+                    if (GlobalContext.IsUsePLC3) {
+                        if (flag == "left")
+                            request.station = GlobalContext.s3_1_station;    // 工位ID(可配置)
+                        else
+                            request.station = GlobalContext.s3_2_station;  // ⼯位ID(可配置)
+                    }
                     if (GlobalContext.IsUsePLC4)
                         request.station = GlobalContext.s4_station;    // 工位ID(可配置)
                     if (GlobalContext.IsUsePLC5)
                         request.station = GlobalContext.s5_station;    // 工位ID(可配置)
                     if (GlobalContext.IsUsePLC6)
                         request.station = GlobalContext.s6_station;    // 工位ID(可配置)
-                    if (GlobalContext.IsUsePLC7)
-                        request2.left.station = GlobalContext.s7_1_station;  // ⼯位ID(可配置)
-                        request2.right.station = GlobalContext.s7_2_station;  // ⼯位ID(可配置)
+                    if (GlobalContext.IsUsePLC7) {
+                        if (flag == "left")
+                            request.station = GlobalContext.s7_1_station;  // ⼯位ID(可配置)
+                        else
+                            request.station = GlobalContext.s7_2_station;  // ⼯位ID(可配置)
+                    }
                     if (GlobalContext.IsUsePLC8)
                         request.station = GlobalContext.s8_station;  // ⼯位ID(可配置)
                     if (GlobalContext.IsUsePLC9)
@@ -776,27 +781,10 @@ namespace MainForm
                         request.fault_tm = fault_tm;      // 故障发⽣时间(需要实际的发生时间)
                     }
                     // 上传
-                    if (GlobalContext.IsUsePLC3 || GlobalContext.IsUsePLC7)
-                    {
-                        (int, string) iotResultL = XiaomiMqttClient_Extend.Write_DeviceStateData(request2.left);
-                        (int, string) iotResultR = XiaomiMqttClient_Extend.Write_DeviceStateData(request2.right);
-
-                        if (iotResultL.Item1 == 0 || iotResultR.Item1 == 0)
-                            result = 1;
-                        else 
-                            result = 2;
-
-                        msg = $"[{iotResultL.Item1}]{iotResultL.Item2};[{iotResultR.Item1}]{iotResultR.Item2}";
-                        SaveDeviceStateDataLog(iotResultL, request, dtNow);
-                        SaveDeviceStateDataLog(iotResultR, request, dtNow);
-                    }
-                    else
-                    {
-                       (int, string) iotResult = XiaomiMqttClient_Extend.Write_DeviceStateData(request);
-                       result = iotResult.Item1 == 0 ? 1 : 2;
-                       msg = $"[{iotResult.Item1}]{iotResult.Item2}";
-                       SaveDeviceStateDataLog(iotResult, request, dtNow);
-                    }
+                    (int, string) iotResult = XiaomiMqttClient_Extend.Write_DeviceStateData(request);
+                    result = iotResult.Item1 == 0 ? 1 : 2;
+                    msg = $"[{iotResult.Item1}]{iotResult.Item2}";
+                    SaveDeviceStateDataLog(iotResult, request, dtNow);
                 }
                 else
                     return (1, "OK;未启用上传Iot");