瀏覽代碼

bug修改

WIN-GH9CEESPLTB\Administrator 1 月之前
父節點
當前提交
0b498a56f3

+ 1 - 0
MainForm/ClassFile/ProjectClass/GlobalContext.cs

@@ -40,6 +40,7 @@ namespace MainForm
         public static string MqttPassResultLogDir = MqttLogDir + @"过站结果\";    // mqtt日志 - 过站结果日志
         public static string MqttPassDetailLogDir = MqttLogDir + @"过站明细\";    // mqtt日志 - 过站明细日志
         public static string MqttFileUpLogDir = MqttLogDir + @"文件上传\";    // mqtt日志 - 文件上传日志
+        public static string MqttFileUpLogDir11 = MqttLogDir + @"1111aaa\";    // mqtt日志 - 文件上传日志
 
         public static string MqttServerPath = AppDomain.CurrentDomain.BaseDirectory + @"\ThingsMode\MqttServer.exe";
         public static string MqttServerName = "MqttServer";

+ 123 - 48
MainForm/FaForm/Form_Home.cs

@@ -170,6 +170,8 @@ namespace MainForm
             InitializeComponent();
             CheckForIllegalCrossThreadCalls = false; // 不检查跨线程访问
 
+
+
             _PLCLogNet = new LogNetDateTime(GlobalContext.PlcLogDir, GenerateMode.ByEveryDay); // 按天记录日志
             _IOTMqttLogNet = new LogNetDateTime(GlobalContext.MqttLogDir, GenerateMode.ByEveryDay); // 按天记录日志
             _AGVMqttLogNet = new LogNetDateTime(GlobalContext.MqttLogDir, GenerateMode.ByEveryDay); // 按天记录日志
@@ -387,6 +389,8 @@ namespace MainForm
                             {
                                 param.parameter.equipment.deviceCode = GlobalContext.s7_1_device_code; // 装备编码
                                 //param.parameter.equipment.stationCode = GlobalContext.s7_1_station;     // ⼯位Id
+                                xiaomiParm.stationCode = GlobalContext.s7_1_station;
+
                             }
 
                             if (GlobalContext.IsUsePLC8)
@@ -411,8 +415,8 @@ namespace MainForm
                             
                             XiaomiMqttClient_Extend.ParameterConfig(param);
                             //保存全局变量
-                            xiaomiParm.stationCode = param.parameter.equipment.deviceCode;
-                            xiaomiParm.deviceCode = param.parameter.equipment.stationCode;
+                            xiaomiParm.stationCode = param.parameter.equipment.stationCode;
+                            xiaomiParm.deviceCode = param.parameter.equipment.deviceCode;
                         }
                         else
                         {
@@ -3564,6 +3568,7 @@ namespace MainForm
             string tagBaseName = "g_OP30_MES"; //标签变量名称
             string tagMesCommName = "mesCommToPC"; //标签变量名称
             string tagAgvCommName = "agvCommFrmPC";
+            string tagiotComnName = "iotData";
             string tagBarsetName = "BarcodeSet";
 
             //s1PLCSignal_Old.Add("a1OEEPLC_FLAG", 0);             // PLC_FLAG 节拍接口
@@ -3573,10 +3578,8 @@ namespace MainForm
             // PLC数据字典 赋值 
             s3PLCData.Add("a3OEEType_left", 0); // 节拍类型(plc写入) 
             s3PLCData.Add("a3OEEPartNo_left", ""); // 物料码(物料码还未绑定载具SN时必填)
-            s3PLCData.Add("a3OEEVehicleCode_left", ""); // 载具SN
             s3PLCData.Add("a3OEEType_right", 0); // 节拍类型(plc写入) 
             s3PLCData.Add("a3OEEPartNo_right", ""); // 物料码(物料码还未绑定载具SN时必填)
-            s3PLCData.Add("a3OEEVehicleCode_right", ""); // 载具SN
 
             OP30_MesData_t stPLC_MesData; //PLC的MES数据
             (int, string) result;
@@ -3596,9 +3599,11 @@ namespace MainForm
                         Stopwatch stopwatch1 = new Stopwatch();
                         Stopwatch stopwatch2 = new Stopwatch();
                         stopwatch1.Start();
-
                         stopwatch2.Start();
 
+                        stPLC_MesData.Left.BarcodeSet.strCarrierBarcode = "A123456";
+                        stPLC_MesData.Left.iotData.BeatAction = 1;
+
                         #region 一次性读取所有数据
 
                         // 一次性读取所有数据
@@ -3619,11 +3624,8 @@ namespace MainForm
                             xmDeviceStateData.right = (xmDeviceStateInt_L < 0 || xmDeviceStateInt_L > 7)
                                 ? XiaomiDeviceState.Unknown
                                 : (XiaomiDeviceState)xmDeviceStateInt_R;
-                            s1PLCData["a1OEEPartNo"] =stPLC_MesData.Left.BarcodeSet.strProductBarcode; // 物料码(物料码还未绑定载具SN时必填)
-                            s1PLCData["a1OEEVehicleCode"] = stPLC_MesData.Left.BarcodeSet.strCarrierBarcode; // 载具SN
-                            s1PLCData["a1OEEType"] = stPLC_MesData.Left.iotData.BeatAction; // 节拍
-                            s1PLCData["a1OEEVehicleCode_right"] = stPLC_MesData.Right.BarcodeSet.strCarrierBarcode; // 载具SN
-                            s1PLCData["a1OEEType_right"] = stPLC_MesData.Right.iotData.BeatAction; // 节拍
+                            s3PLCData["a3OEEType_left"] = stPLC_MesData.Left.iotData.BeatAction; // 节拍
+                            s3PLCData["a3OEEType_right"] = stPLC_MesData.Right.iotData.BeatAction; // 节拍
                         }
 
                         #endregion 一次性读取所有数据
@@ -3640,6 +3642,9 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        stationCode = "[OP31]";
+                                        stationName = "点散热胶装备1";
+                                        stationNameStr = stationCode + stationName;
                                         uuid = Guid.NewGuid().ToString();//创建贯穿进出站的uuid
                                         ProgressState = true;
                                         Task.Run(() => S3进站(plcNo, stationNameStr, stPLC_MesData.Left,
@@ -3670,6 +3675,10 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        stationCode = "[OP31]";
+                                        stationName = "点散热胶装备1";
+                                        stationNameStr = stationCode + stationName;
+
                                         ProgressState = true;
                                         Task.Run(() => S3出站(plcNo, stationNameStr, stPLC_MesData.Left,
                                             tagBaseName + ".Left." + tagMesCommName, stationCode, stationName, "Left",
@@ -3701,6 +3710,11 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        uuid = Guid.NewGuid().ToString();//创建贯穿进出站的uuid
+                                        stationCode = "[OP32]";
+                                        stationName = "点散热胶装备2";
+                                        stationNameStr = stationCode + stationName;
+
                                         ProgressState = true;
                                         Task.Run(() => S3进站(plcNo, stationNameStr, stPLC_MesData.Right,
                                             tagBaseName + ".Right." + tagMesCommName,
@@ -3730,11 +3744,16 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        stationCode = "[OP32]";
+                                        stationName = "点散热胶装备2";
+                                        stationNameStr = stationCode + stationName;
+
                                         ProgressState = true;
                                         Task.Run(() => S3出站(plcNo, stationNameStr, stPLC_MesData.Right,
                                             tagBaseName + ".Right." + tagMesCommName, stationCode, stationName, "Right",
                                             out ProgressState));
                                         stPLC_MesData.Right.mesCommFrmPLC.cmd = 0;
+                                        uuid = "";
                                     }
                                 }
                             }
@@ -3753,8 +3772,8 @@ namespace MainForm
                         try
                         {
                             #region 左工位 节拍
-                            int a3OEEType_left = (int)s3PLCData["a3OEEType_left"];
-                            int a3OEETypeGOld_left = (int)s3PLCSignal_Old["a3OEEType_left"];
+                            int a3OEEType_left = Convert.ToInt32(s3PLCData["a3OEEType_left"]);
+                            int a3OEETypeGOld_left = Convert.ToInt32(s3PLCSignal_Old["a3OEEType_left"]);
                             //若设备紧急复原后节拍重置
                             if (a3OEEType_left == 1)
                             {
@@ -3765,12 +3784,18 @@ namespace MainForm
                             {
                                 stationNameStr = stationNameStr + "_Left";
                                 //节拍需要成双成对,有开始就要有结束,例如有1上料开始就必须有2上料结束
-                                if ((a3OEETypeGOld_left == 1 && a3OEEType_left != 2) || (a3OEETypeGOld_left == 3 && a3OEEType_left != 4) ||
-                                    (a3OEETypeGOld_left == 5 && a3OEEType_left != 6))
+                                if ((a3OEETypeGOld_left == 1 && a3OEEType_left != 2)  || (a3OEETypeGOld_left == 3 && a3OEEType_left != 4) 
+                                    || (a3OEETypeGOld_left == 5 && a3OEEType_left != 6))
                                 {
                                     //写入PLC
-                                    stPLC_MesData.Left.iotData.beatReturn = 2; //NG
-                                    WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName, 1, stPLC_MesData.Left.iotData);
+                                    IoT_DataSet_t iotData=new IoT_DataSet_t();
+                                    iotData.machineState = stPLC_MesData.Left.iotData.machineState;
+                                    iotData.work_type = stPLC_MesData.Left.iotData.work_type;
+                                    iotData.testStatus = stPLC_MesData.Left.iotData.testStatus;
+                                    iotData.BeatAction = stPLC_MesData.Left.iotData.BeatAction;
+                                    iotData.beatReturn = 2; //NG
+                                    iotData.fault_codes = stPLC_MesData.Left.iotData.fault_codes;
+                                    WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Left." + tagiotComnName, 1, iotData);
                                     AddMessage(LogType.Info,
                                         stationNameStr +
                                         $"_节拍接口-- 设备本次上传节拍[{a3OEEType_left}],未上传节拍[{a3OEETypeGOld_left}]的结束信号,请检查;总用时" +
@@ -3781,7 +3806,7 @@ namespace MainForm
                                 else
                                 {
                                     Task.Run(() =>
-                                        S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName,
+                                        S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagiotComnName, stPLC_MesData.Left.BarcodeSet.strCarrierBarcode.ToString(),
                                             stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
                                 }
                                 s3PLCSignal_Old["a3OEEType_left"] = s3PLCData["a3OEEType_left"];
@@ -3789,8 +3814,9 @@ namespace MainForm
                             #endregion 左工位 节拍
 
                             #region 右工位 节拍
-                            int a3OEEType_right = (int)s3PLCData["a3OEEType_right"];
-                            int a3OEETypeGOld_right = (int)s3PLCSignal_Old["a3OEEType_right"];
+                            int a3OEEType_right = Convert.ToInt32(s3PLCData["a3OEEType_right"]);
+                            int a3OEETypeGOld_right = Convert.ToInt32(s3PLCSignal_Old["a3OEEType_right"]);
+
                             //若设备紧急复原后节拍重置
                             if (a3OEEType_right == 1)
                             {
@@ -3805,8 +3831,14 @@ namespace MainForm
                                     (a3OEETypeGOld_right == 5 && a3OEEType_right != 6))
                                 {
                                     //写入PLC
-                                    stPLC_MesData.Right.iotData.beatReturn = 2; //NG
-                                    WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, 1, stPLC_MesData.Left.iotData);
+                                    IoT_DataSet_t iotData = new IoT_DataSet_t();
+                                    iotData.machineState = stPLC_MesData.Left.iotData.machineState;
+                                    iotData.work_type = stPLC_MesData.Left.iotData.work_type;
+                                    iotData.testStatus = stPLC_MesData.Left.iotData.testStatus;
+                                    iotData.BeatAction = stPLC_MesData.Left.iotData.BeatAction;
+                                    iotData.beatReturn = 2; //NG
+                                    iotData.fault_codes = stPLC_MesData.Left.iotData.fault_codes;
+                                    WriteResultToPlc(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, 1, iotData);
                                     AddMessage(LogType.Info,
                                         stationNameStr +
                                         $"_节拍接口-- 设备本次上传节拍[{a3OEEType_right}],未上传节拍[{a3OEETypeGOld_right}]的结束信号,请检查;总用时" +
@@ -3817,7 +3849,7 @@ namespace MainForm
                                 else
                                 {
                                     Task.Run(() =>
-                                        S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName,
+                                        S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName, stPLC_MesData.Right.BarcodeSet.strCarrierBarcode,
                                             stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
                                 }
                                 s3PLCSignal_Old["a3OEEType_right"] = s3PLCData["a3OEEType_right"];
@@ -5188,7 +5220,7 @@ namespace MainForm
         /// <param name="plcNo">PLC编号</param>
         private void ReadStation_S6(int plcNo)
         {
-            string stationCode = "[OP60]";
+            string stationCode = "[OP70]";
             string stationName = "组上盖板";
             string stationNameStr = stationCode + stationName;
             string tagBaseName = "g_OP60_MES"; //标签变量名称
@@ -5736,7 +5768,7 @@ namespace MainForm
         /// <param name="plcNo">PLC编号</param>
         private void ReadStation_S7(int plcNo)
         {
-            string stationCode = "[OP70]";
+            string stationCode = "[OP80]";
             string stationName = "上盖板锁螺丝";
             string stationNameStr = stationCode + stationName;
             string tagBaseName = "g_OP70_MES"; //标签变量名称
@@ -5828,6 +5860,8 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        stationCode = "[OP81]";
+                                        stationName = "上盖板锁螺丝1";
                                         uuid = Guid.NewGuid().ToString();//创建贯穿进出站的uuid
                                         ProgressState = true;
                                         Task.Run(() => S7进站(plcNo, stationNameStr, stPLC_MesData.Left,
@@ -5859,6 +5893,8 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        stationCode = "[OP81]";
+                                        stationName = "上盖板锁螺丝1";
                                         ProgressState = true;
                                         Task.Run(() => S7出站(plcNo, stationNameStr, stPLC_MesData.Left,
                                             tagBaseName + ".Left." + tagMesCommName, stationCode, stationName, "Left",
@@ -5890,6 +5926,9 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        uuid = Guid.NewGuid().ToString();//创建贯穿进出站的uuid
+                                        stationCode = "[OP82]";
+                                        stationName = "上盖板锁螺丝2";
                                         ProgressState = true;
                                         Task.Run(() => S7进站(plcNo, stationNameStr, stPLC_MesData.Right,
                                             tagBaseName + ".Right." + tagMesCommName,
@@ -5920,11 +5959,14 @@ namespace MainForm
                                 {
                                     if (!ProgressState)
                                     {
+                                        stationCode = "[OP82]";
+                                        stationName = "上盖板锁螺丝2";
                                         ProgressState = true;
                                         Task.Run(() => S7出站(plcNo, stationNameStr, stPLC_MesData.Right,
                                             tagBaseName + ".Right." + tagMesCommName, stationCode, stationName, "Right",
                                             out ProgressState));
                                         stPLC_MesData.Right.mesCommFrmPLC.cmd = 0;
+                                        uuid = "";
                                     }
                                 }
                             }
@@ -5972,7 +6014,7 @@ namespace MainForm
                                 else
                                 {
                                     Task.Run(() =>
-                                        S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName,
+                                        S7节拍接口(plcNo, stationNameStr, tagBaseName + ".Left." + tagMesCommName,
                                             stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
                                 }
                                 s7PLCSignal_Old["a7OEEType_left"] = s7PLCData["a7OEEType_left"];
@@ -6008,7 +6050,7 @@ namespace MainForm
                                 else
                                 {
                                     Task.Run(() =>
-                                        S3节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName,
+                                        S7节拍接口(plcNo, stationNameStr, tagBaseName + ".Right." + tagMesCommName,
                                             stPLC_MesData.Left.iotData)); // MreTasks[4].Set();
                                 }
                                 s7PLCSignal_Old["a7OEEType_right"] = s7PLCData["a7OEEType_right"];
@@ -6454,7 +6496,7 @@ namespace MainForm
         /// <param name="plcNo">PLC编号</param>
         private void ReadStation_S8(int plcNo)
         {
-            string stationCode = "[OP80]";
+            string stationCode = "[OP90]";
             string stationName = "NG下料";
             string stationNameStr = stationCode + stationName;
             string tagBaseName = "g_OP80_MES"; //标签变量名称
@@ -6978,7 +7020,7 @@ namespace MainForm
         /// <param name="plcNo">PLC编号</param>
         private void ReadStation_S9(int plcNo)
         {
-            string stationCode = "[OP90]";
+            string stationCode = "[OP100]";
             string stationName = "半成品下料";
             string stationNameStr = stationCode + stationName;
             string tagBaseName = "g_OP90_MES"; //标签变量名称
@@ -10377,7 +10419,7 @@ namespace MainForm
         /// </summary>
         /// <param name="plcNo">PLC编号</param>
         /// <param name="stationNameStr">工站全称</param>
-        private void S3节拍接口(int plcNo, string stationNameStr, string tagMesCommName, IoT_DataSet_t iot_data)
+        private void S3节拍接口(int plcNo, string stationNameStr, string tagMesCommName,string CarrierBarcode, IoT_DataSet_t iot_data)
         {
             Stopwatch stopwatch1 = new Stopwatch();
             Stopwatch stopwatch2 = new Stopwatch();
@@ -10386,11 +10428,8 @@ namespace MainForm
             try
             {
                 stopwatch1.Start();
-                string oEEType = ((int)s1PLCData["a3OEEType"]).ToString(); // 节拍类型(plc写入)
-                string a3OEEPartNo = (string)s1PLCData["a3OEEPartNo"]; // 物料码
-                a3OEEPartNo = a3OEEPartNo.Replace("\0", "");
-                string a3OEEVehicleCode = (string)s1PLCData["a3OEEVehicleCode"]; // 载具SN
-                a3OEEVehicleCode = a3OEEVehicleCode.Replace("\0", "");
+                string oEEType = iot_data.BeatAction.ToString(); // 节拍类型(plc写入)
+                string strProductBarcode = SQLHelper.GetProductBarcodeByCarrierCode(CarrierBarcode);//产品SN
 
                 bool actionBool = Enum.TryParse(oEEType, out XiaomiDeviceOEE deviceOEE);
                 if (!actionBool)
@@ -10406,48 +10445,66 @@ namespace MainForm
                     return;
                 }
                 //作业开始后要有物料和载具信息
-                if (string.IsNullOrEmpty(a3OEEPartNo) && string.IsNullOrEmpty(a3OEEVehicleCode) &&
+                if (string.IsNullOrEmpty(strProductBarcode) && string.IsNullOrEmpty(CarrierBarcode) &&
                     Convert.ToInt32(oEEType) > 2)
                 {
                     stopwatch2.Start();
                     //写入PLC
-                    iot_data.beatReturn = 2; //NG
+                    IoT_DataSet_t iotData = new IoT_DataSet_t();
+                    iotData.machineState = iot_data.machineState;
+                    iotData.work_type = iot_data.work_type;
+                    iotData.testStatus = iot_data.testStatus;
+                    iotData.BeatAction = iot_data.BeatAction;
+                    iotData.beatReturn = 2; //NG
+                    iotData.fault_codes = iot_data.fault_codes;
                     WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
                     stopwatch2.Stop();
                     AddMessage_Station(stationNameStr, LogType.Info,
-                        stationNameStr + $"_[{a3OEEVehicleCode}][{a3OEEPartNo}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
+                        stationNameStr + $"_[{CarrierBarcode}][{strProductBarcode}]上传节拍失败!物料码与载具SN不可都为空;总用时" +
                         stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
                     return;
                 }
-                else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(a3OEEPartNo))
+                else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(strProductBarcode))
                 {
                     stopwatch2.Start();
                     //写入PLC
-                    iot_data.beatReturn = 2; //NG
+                    IoT_DataSet_t iotData = new IoT_DataSet_t();
+                    iotData.machineState = iot_data.machineState;
+                    iotData.work_type = iot_data.work_type;
+                    iotData.testStatus = iot_data.testStatus;
+                    iotData.BeatAction = iot_data.BeatAction;
+                    iotData.beatReturn = 2; //NG
+                    iotData.fault_codes = iot_data.fault_codes;
                     WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
                     stopwatch2.Stop();
                     AddMessage_Station(stationNameStr, LogType.Info,
-                        stationNameStr + $"_[{a3OEEVehicleCode}][{a3OEEPartNo}]上传节拍失败!物料码不可为空;总用时" +
+                        stationNameStr + $"_[{CarrierBarcode}]上传节拍失败!物料码不可为空;总用时" +
                         stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
                     return;
                 }
-                else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(a3OEEVehicleCode))
+                else if (Convert.ToInt32(oEEType) > 2 && string.IsNullOrEmpty(CarrierBarcode))
                 {
                     stopwatch2.Start();
                     //写入PLC
-                    iot_data.beatReturn = 2; //NG
+                    IoT_DataSet_t iotData = new IoT_DataSet_t();
+                    iotData.machineState = iot_data.machineState;
+                    iotData.work_type = iot_data.work_type;
+                    iotData.testStatus = iot_data.testStatus;
+                    iotData.BeatAction = iot_data.BeatAction;
+                    iotData.beatReturn = 2; //NG
+                    iotData.fault_codes = iot_data.fault_codes;
                     WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
                     stopwatch2.Stop();
                     AddMessage_Station(stationNameStr, LogType.Info,
-                        stationNameStr + $"_[{a3OEEVehicleCode}][{a3OEEPartNo}]上传节拍失败!载具码不可为空;总用时" +
+                        stationNameStr + $"_上传节拍失败!载具码不可为空;总用时" +
                         stopwatch1.ElapsedMilliseconds + "ms;调用Iot用时" + stopwatch2.ElapsedMilliseconds + "ms");
                     return;
                 }
 
                 short _result = 0;
+                
                 // 上传OEE
-                (short, string) result = SaveOEEData(plcNo, stationNameStr, deviceOEE, a3OEEPartNo, a3OEEVehicleCode);
-
+                (short, string) result = SaveOEEData(plcNo, stationNameStr, deviceOEE, strProductBarcode, CarrierBarcode);
                 _result = result.Item1;
                 resultStr = result.Item2;
 
@@ -10455,7 +10512,13 @@ namespace MainForm
                 {
                     stopwatch2.Start();
                     //写入PLC
-                    iot_data.beatReturn = 1; //OK
+                    IoT_DataSet_t iotData = new IoT_DataSet_t();
+                    iotData.machineState = iot_data.machineState;
+                    iotData.work_type = iot_data.work_type;
+                    iotData.testStatus = iot_data.testStatus;
+                    iotData.BeatAction = iot_data.BeatAction;
+                    iotData.beatReturn = 1;//OK
+                    iotData.fault_codes = iot_data.fault_codes;
                     WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
                     OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍{iot_data.BeatAction}上传IOT成功!上传结果:" + resultStr);
                     stopwatch2.Stop();
@@ -10464,7 +10527,13 @@ namespace MainForm
                 {
                     stopwatch2.Start();
                     //写入PLC
-                    iot_data.beatReturn = 2; //NG
+                    IoT_DataSet_t iotData = new IoT_DataSet_t();
+                    iotData.machineState = iot_data.machineState;
+                    iotData.work_type = iot_data.work_type;
+                    iotData.testStatus = iot_data.testStatus;
+                    iotData.BeatAction = iot_data.BeatAction;
+                    iotData.beatReturn = 2; //NG
+                    iotData.fault_codes = iot_data.fault_codes;
                     WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
                     stopwatch2.Stop();
                     AddMessage_Station(stationNameStr, LogType.Error,
@@ -10482,7 +10551,13 @@ namespace MainForm
                 // MES_Flag
                 stopwatch2.Start();
                 //写入PLC
-                iot_data.beatReturn = 2; //NG
+                IoT_DataSet_t iotData = new IoT_DataSet_t();
+                iotData.machineState = iot_data.machineState;
+                iotData.work_type = iot_data.work_type;
+                iotData.testStatus = iot_data.testStatus;
+                iotData.BeatAction = iot_data.BeatAction;
+                iotData.beatReturn = 2; //NG
+                iotData.fault_codes = iot_data.fault_codes;
                 WriteResultToPlc(plcNo, stationNameStr, tagMesCommName, 1, iot_data);
                 stopwatch2.Stop();
             }

+ 47 - 21
MainForm/FaForm/Form_Home_SaveData.cs

@@ -901,47 +901,73 @@ namespace MainForm
                     try
                     {
                         StationInputBeginRequest oee = new StationInputBeginRequest();
-                        oee.action = deviceOEE.ToString();  // 节拍动作(XiaomiDeviceOEE)
+                        switch (deviceOEE.ToString())
+                        {
+                            /// 上料开始:beat_log/business/OEE/station_input_begin
+                            /// 上料结束:beat_log/business/OEE/station_input_end
+                            /// 作业开始:beat_log/business/OEE/station_work_begin
+                            /// 作业结束:beat_log/business/OEE/station_work_end
+                            /// 下料开始:beat_log/business/OEE/station_output_begin
+                            /// 下料结束:beat_log/business/OEE/station_output_end
+                            case "station_input_begin":
+                                oee.action = "beat_log/business/OEE/station_input_begin";   // 节拍动作(XiaomiDeviceOEE)
+                                break;
+                            case "station_input_end":
+                                oee.action = "beat_log/business/OEE/station_input_end";     // 节拍动作(XiaomiDeviceOEE)
+                                break;
+                            case "station_work_begin":
+                                oee.action = "beat_log/business/OEE/station_work_begin";    // 节拍动作(XiaomiDeviceOEE)
+                                break;
+                            case "station_work_end":
+                                oee.action = "beat_log/business/OEE/station_work_end";      // 节拍动作(XiaomiDeviceOEE)
+                                break;
+                            case "station_output_begin":
+                                oee.action = "beat_log/business/OEE/station_output_begin";  // 节拍动作(XiaomiDeviceOEE)
+                                break;
+                            case "station_output_end":
+                                oee.action = "beat_log/business/OEE/station_output_end";    // 节拍动作(XiaomiDeviceOEE)
+                                break;
+                        }
                         oee.beat_tm = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  // 节拍发⽣时间
                         oee.action_subject = oEEPartNo;            // 该动作操作的⽬标对象(SN) 
                         oee.action_subject_parent = oEEVSN;        // ⼤板SN/载具SN
                         switch (stationNameStr)
                         {
                             case "[OP10]壳体清洁上料":
-                                oee.action_location = GlobalContext.S1_station;
+                                oee.action_location = GlobalContext.S1_station+"_01-SLOT-01";
                                 break;
                             case "[OP20]上盖板上料装备":
-                                oee.action_location = GlobalContext.S2_station;
+                                oee.action_location = GlobalContext.S2_station+"_01-SLOT-01";
                                 break;
-                            case "[OP30]点散热胶装备_Left":
-                                oee.action_location = GlobalContext.s3_1_station;
+                            case "[OP31]点散热胶装备1_Left":
+                                oee.action_location = GlobalContext.s3_1_station+"_01-SLOT-01";
                                 break;
-                            case "[OP30]点散热胶装备_Right":
-                                oee.action_location = GlobalContext.s3_2_station;
+                            case "[OP32]点散热胶装备2_Right":
+                                oee.action_location = GlobalContext.s3_2_station+"_01-SLOT-02";
                                 break;
                             case "[OP40]胶线检测":
-                                oee.action_location = GlobalContext.s4_station;
+                                oee.action_location = GlobalContext.s4_station+"_01-SLOT-01";
                                 break;
                             case "[OP50]ADD板上料组装装备":
-                                oee.action_location = GlobalContext.s5_station;
+                                oee.action_location = GlobalContext.s5_station+"_01-SLOT-01";
                                 break;
-                            case "[OP60]组上盖板":
-                                oee.action_location = GlobalContext.s6_station;
+                            case "[OP70]组上盖板":
+                                oee.action_location = GlobalContext.s6_station+"_01-SLOT-01";
                                 break;
-                            case "[OP70]上盖板锁螺丝_Left":
-                                oee.action_location = GlobalContext.s7_1_station;
+                            case "[OP81]上盖板锁螺丝1_Left":
+                                oee.action_location = GlobalContext.s7_1_station+"_01-SLOT-01";
                                 break;
-                            case "[OP70]上盖板锁螺丝_Right":
-                                oee.action_location = GlobalContext.s7_2_station;
+                            case "[OP82]上盖板锁螺丝2_Right":
+                                oee.action_location = GlobalContext.s7_2_station+"_01-SLOT-02";
                                 break;
-                            case "[OP80]NG下料":
-                                oee.action_location = GlobalContext.s8_station;
+                            case "[OP90]NG下料":
+                                oee.action_location = GlobalContext.s8_station+"_01-SLOT-01";
                                 break;
-                            case "[OP90]半成品下料":
-                                oee.action_location = GlobalContext.s8_station;
+                            case "[OP100]半成品下料":
+                                oee.action_location = GlobalContext.s8_station+"_01-SLOT-01";
                                 break;
                         }
-                        oee.action_material = oee.action_location + "_1";  // 该动作的物料信息
+                        oee.action_material = "";  // 该动作的物料信息
                         oee.extra = extra;                    // 额外信息
                         oee.class_level_1 = class_level_1;    // 分类层级1
                         oee.class_level_2 = class_level_2;    // 分类层级2
@@ -965,7 +991,7 @@ namespace MainForm
                 return ((short)1, "异步上传中!");
             }
             else
-                return ((short)1, "未启用上传!");
+                return ((short)0, "未启用上传!");
         }
         #endregion 节拍数据
         #endregion 保存数据

+ 17 - 1
MainForm/FaForm/Form_MESTest.cs

@@ -469,6 +469,7 @@ namespace MainForm.FaForm
             string class_level_1 = txtClassLevel1.Text.Trim();   // 分类层级1
             string class_level_2 = txtClassLevel2.Text.Trim();   // 分类层级2
             string class_level_3 = txtClassLevel3.Text.Trim();   // 分类层级3
+            string station = "";
 
             if (string.IsNullOrEmpty(action))
                 return (999, "‘节拍动作’不可为空!");
@@ -517,7 +518,22 @@ namespace MainForm.FaForm
             request.beat_tm = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");  // 节拍发⽣时间(2022-06-01 14:27:57.283)
             request.action_subject = partSn;        // 该动作操作的⽬标对象(SN) 
             request.action_subject_parent = vSn;    // ⼤板SN/载具SN
-            request.action_location = Form_Home.xiaomiParm.stationCode + "01-SLOT-01";   // 该动作的位置信息(⼯位、槽位),如:F06-GSTPLA11_01-SLOT-01
+            if (Form_Home.xiaomiParm.stationCode=="")
+            {
+                if (cmbStationName_Iot.Text=="[OP30]点散热胶装备_Left")
+                    station=GlobalContext.s3_1_station+ "_01-SLOT-01";  
+                else if (cmbStationName_Iot.Text=="[OP30]点散热胶装备_Right")
+                    station=GlobalContext.s3_2_station+ "_01-SLOT-02";  
+                else if (cmbStationName_Iot.Text=="[OP70]上盖板锁螺丝_Left")
+                    station=GlobalContext.s7_1_station+ "_01-SLOT-01";  
+                else if (cmbStationName_Iot.Text=="[OP70]上盖板锁螺丝_Right")
+                    station=GlobalContext.s7_2_station+ "_01-SLOT-02";  
+            }
+            else
+            {
+                station = Form_Home.xiaomiParm.stationCode;   // 该动作的位置信息(⼯位、槽位),如:F06-GSTPLA11_01-SLOT-01
+            }
+            request.action_location=station; 
             request.action_material = vIndexSn;     // 该动作的物料信息
             request.extra = extra;                  // 额外信息
             request.class_level_1 = class_level_1;  // 分类层级1

+ 11 - 3
MainForm/FaForm/Form_Main.cs

@@ -116,9 +116,17 @@ namespace MainForm
                 #endregion 尝试关联启动“气密设备软件”与“电测设备软件”
 
                 //初始化目录
-                if (!Directory.Exists(GlobalContext.DBDir)) Directory.CreateDirectory(GlobalContext.DBDir);    // 判断路径是否存在,不存在则创建路径 
-                if (!Directory.Exists(GlobalContext.ProcessDataDir)) Directory.CreateDirectory(GlobalContext.ProcessDataDir);    // 判断路径是否存在,不存在则创建路径 
-                if (!Directory.Exists(GlobalContext.OneCheckDataDir)) Directory.CreateDirectory(GlobalContext.OneCheckDataDir);  // 判断路径是否存在,不存在则创建路径
+                //if (!Directory.Exists(GlobalContext.DBDir)) Directory.CreateDirectory(GlobalContext.DBDir);    // 判断路径是否存在,不存在则创建路径 
+                //if (!Directory.Exists(GlobalContext.ProcessDataDir)) Directory.CreateDirectory(GlobalContext.ProcessDataDir);    // 判断路径是否存在,不存在则创建路径 
+                //if (!Directory.Exists(GlobalContext.OneCheckDataDir)) Directory.CreateDirectory(GlobalContext.OneCheckDataDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttDeviceStateDir)) Directory.CreateDirectory(GlobalContext.MqttDeviceStateDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttInputBeginDir)) Directory.CreateDirectory(GlobalContext.MqttInputBeginDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttOperateLogDir)) Directory.CreateDirectory(GlobalContext.MqttOperateLogDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttAlarmLogDir)) Directory.CreateDirectory(GlobalContext.MqttAlarmLogDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttPassResultLogDir)) Directory.CreateDirectory(GlobalContext.MqttPassResultLogDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttPassDetailLogDir)) Directory.CreateDirectory(GlobalContext.MqttPassDetailLogDir);  // 判断路径是否存在,不存在则创建路径
+                if (!Directory.Exists(GlobalContext.MqttFileUpLogDir)) Directory.CreateDirectory(GlobalContext.MqttFileUpLogDir);  // 判断路径是否存在,不存在则创建路径
+
                 GlobalContext.UpdateData();
 
                 //创建窗体及事件