Browse Source

10扫码改造

WIN-GH9CEESPLTB\Administrator 1 month ago
parent
commit
b919b9c712

+ 3 - 0
MainForm/FaForm/BandBarodeDialog.cs

@@ -76,6 +76,9 @@ namespace MainForm.FaForm
         {
             // 定时器触发,表示输入已经完成
             _inputTimer.Stop();
+            //模拟点击
+            Barcode.Focus();
+
             // 处理条码
             string pcbcode = Barcode.Text.Trim();
             if (!string.IsNullOrEmpty(pcbcode))

+ 19 - 3
MainForm/FaForm/BandBarodeDialog_S1.cs

@@ -36,6 +36,11 @@ namespace MainForm.FaForm
         public BandBarodeDialog_S1()
         {
             InitializeComponent();
+            //置顶
+            this.TopMost = true;
+            // 设置窗口相对于父窗口居中
+            this.StartPosition = FormStartPosition.CenterParent;
+            this.Shown += MainForm_Shown;
         }
 
 
@@ -50,6 +55,10 @@ namespace MainForm.FaForm
             //GetBarcode.TextChanged += GetBarcode_TextChanged;
 
             //Form_Home.StopWhile = true;
+            ProductBarcode.Text = "";
+            CarrierBarcode.Text = "";
+            Form_Home._strCarrierBarcode = "";
+            Form_Home._strProductBarcode = "";
 
             home.FunsEip.Add(GlobalContext.IsUsePLCNow,
                         new Inovance_EIP(GlobalContext.PC1Address, GlobalContext.Machine1Address)); //OP10 壳体清洁上料装备
@@ -88,6 +97,7 @@ namespace MainForm.FaForm
 
             // 定时器触发,表示输入已经完成
             _inputTimer.Stop();
+            //模拟点击
             GetBarcode.Focus();
 
             //收到PLC确认反馈,关闭弹窗
@@ -113,8 +123,8 @@ namespace MainForm.FaForm
             {
                 CommandFromPLC CommandToPlC = new CommandFromPLC();
                 CommandToPlC.cmd = 0;
-                CommandToPlC.cmdParam = 0;
-                CommandToPlC.cmdResult = 1;
+                CommandToPlC.cmdParam = 2;
+                CommandToPlC.cmdResult = 0;
                 (nRet, strRet) = home.WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, CommandToPlC);
 
                 if (nRet != 0)
@@ -156,7 +166,7 @@ namespace MainForm.FaForm
                             .Read_SingleTag<OP10_MesData_t>(tagBaseName, 1, out stPLC_MesData, this); //读取单个结构体数据
                 if (result.Item1==0)
                 {
-                    if (stPLC_MesData.mesCommFrmPLC.cmdParam==2)
+                    if (stPLC_MesData.mesCommFrmPLC.cmdParam==3)
                     {
                         closeWin();
                     };
@@ -164,6 +174,12 @@ namespace MainForm.FaForm
 
             }
         }
+
+        private void MainForm_Shown(object sender, EventArgs e)
+        {
+            // 将焦点设置到 textBox1
+            GetBarcode.Focus();
+        }
     }
 
 }

+ 34 - 20
MainForm/FaForm/Form_Home.cs

@@ -2928,7 +2928,7 @@ namespace MainForm
         #region S1
 
         /// <summary>
-        /// [S1] 壳体清洁上料装备
+        /// [S1] 壳体清洁上料装备(10扫码改造注释(临时))
         /// </summary>
         /// <param name="plcNo">PLC编号</param>
         //private void ReadStation_S1(int plcNo)
@@ -3146,7 +3146,7 @@ namespace MainForm
 
 
         /// <summary>
-        /// [S1] 壳体清洁上料装备(临时方案)
+        /// [S1] 壳体清洁上料装备(10扫码改造注释(临时))
         /// </summary>
         /// <param name="plcNo">PLC编号</param>
         private void ReadStation_S1(int plcNo)
@@ -3268,8 +3268,8 @@ namespace MainForm
 
                                         CommandFromPLC CommandToPlC = new CommandFromPLC();
                                         CommandToPlC.cmd = 0;
-                                        CommandToPlC.cmdParam = 0;
-                                        CommandToPlC.cmdResult = 110;
+                                        CommandToPlC.cmdParam = 5;
+                                        CommandToPlC.cmdResult = 0;
                                         WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, CommandToPlC);
                                         return;
                                     }
@@ -3279,13 +3279,12 @@ namespace MainForm
 
                                         CommandFromPLC CommandToPlC = new CommandFromPLC();
                                         CommandToPlC.cmd = 0;
-                                        CommandToPlC.cmdParam = 0;
-                                        CommandToPlC.cmdResult = 1;
+                                        CommandToPlC.cmdParam = 4;
+                                        CommandToPlC.cmdResult = 0;
                                         WriteResultToPlc(plcNo, stationNameStr, tagBaseName + "." + tagMesCommName, 1, CommandToPlC);
                                     }
-                                    AddMessage(LogType.Info, $"载具码:{_strCarrierBarcode},产品码:{_strProductBarcode}");
-                                    _strCarrierBarcode = "";
-                                    _strProductBarcode = "";
+                                    AddMessage(LogType.Info, $"载具码:{_strCarrierBarcode},产品码:{_strCarrierBarcode}");
+        
                                     //StopWhile = false;//开启while循环
                                 }
                             }
@@ -3438,8 +3437,15 @@ namespace MainForm
             {
                 stopwatch1.Start();
                 AddMessage(LogType.Info, stationNameStr + "_进站开始");
-                string sn = (string)stPLC_MesData.BarcodeSet.strProductBarcode; // 产品SN(物料码),现在PLC只有OP10和OP50返回
+                //10扫码改造注释(临时)
+                //string sn = (string)stPLC_MesData.BarcodeSet.strProductBarcode; // 产品SN(物料码),现在PLC只有OP10和OP50返回
                 string CarrierBarcode = (string)stPLC_MesData.BarcodeSet.strCarrierBarcode; // 载具条码;
+                string sn = _strProductBarcode;
+                if (string.IsNullOrEmpty(CarrierBarcode))
+                {
+                    //获取手持扫码枪的载具码
+                    CarrierBarcode = _strCarrierBarcode;
+                }
                 string MachineId = GlobalContext.S1_MachineId; // 装备ID(可配置)
                 string StationId = GlobalContext.S1_StationId; // 工位ID(可配置)
                 int a1Result = (int)stPLC_MesData.iotData.testStatus; // 产品结果
@@ -3457,15 +3463,17 @@ namespace MainForm
                 // sn = sn.Substring(sn.Length - 11, 4) + sn.Substring(sn.Length - 5, 5);
                 AddMessage(LogType.Info, $"载具码:{CarrierBarcode};产品码:{sn}");
                 //绑定载具和产品
-                ResponseMessage message = new ResponseMessage();
-                message = SQLHelper.InsertCarrierBind(CarrierBarcode, sn);
-                if (message.result == false)
-                {
-                    AddMessage(LogType.Error, stationNameStr + "_载具码与产品码绑定失败,错误:" + message.text);
-                    ProgressState = false;
-                    Thread.Sleep(10000);
-                    return;
-                }
+
+                //测试注释(临时)
+                //ResponseMessage message = new ResponseMessage();
+                //message = SQLHelper.InsertCarrierBind(CarrierBarcode, sn);
+                //if (message.result == false)
+                //{
+                //    AddMessage(LogType.Error, stationNameStr + "_载具码与产品码绑定失败,错误:" + message.text);
+                //    ProgressState = false;
+                //    Thread.Sleep(10000);
+                //    return;
+                //}
 
                 // 产品SN进站
                 List<TestItem> item = new List<TestItem>();
@@ -5709,6 +5717,7 @@ namespace MainForm
                         batch_num
                         , mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "01-SLOT-01", MachineId, StationId,
                         PartBarcode, paramJson);
+                    uuid = "";
                 }
                 else if (stPLC_MesData.mesCommFrmPLC.cmdParam == 1)
                 {
@@ -5766,7 +5775,6 @@ namespace MainForm
                 stationNameStr + "_出站接口;总用时" + stopwatch1.ElapsedMilliseconds + "ms;写入用时" +
                 stopwatch2.ElapsedMilliseconds + "ms");
             ProgressState = false;
-            uuid = "";
         }
 
         private int S5_PCB进出站(OP50_MesData_t stPLC_MesData, int plcNo, string stationNameStr, string tagBaseName,
@@ -6101,6 +6109,12 @@ namespace MainForm
                 }
                 sn = ProductBarcode;
                 AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
+                if (ProductBarcode != "")
+                {
+                    MessageBox.Show($"产品码:{sn}线外螺丝机过站后点击确认", "提示",
+                    MessageBoxButtons.OK,
+                    MessageBoxIcon.Information);
+                }
 
                 // 产品SN(物料码)校验
                 List<TestItem> item = new List<TestItem>();