From b71c61c333972122703be4678d09f33fdcd9a424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Thu, 11 Apr 2024 17:50:26 +0800 Subject: [PATCH] merge --- ProductionSystem/Forms/HomeForm.cs | 149 +++++++++++++++++------------ 1 file changed, 90 insertions(+), 59 deletions(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 0db5ac4..5eab489 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -746,13 +746,7 @@ namespace ProductionSystem.Forms // if(txtProductCode) //ClearMiddleData - if (txtProductCode.Text.Contains("暂无条码") || txtProductCode.Text== "12345889" || txtProductCode.Text=="") - { - - CleanMiddleData("BZ1"); - return; - } - + var d1300Value = GetPlcValue("D1300"); // d1300Value = "1"; @@ -1576,41 +1570,52 @@ namespace ProductionSystem.Forms { while (!cancellationTokenSource.IsCancellationRequested) { - GetPlc(Program.BZ1, "BZ1"); - GetPlc(Program.BZ2, "BZ2"); - GetPlc(Program.BZ3, "BZ3"); - GetPlc(Program.BZ4, "BZ4"); - GetPlc(Program.BZ5, "BZ5"); - GetPlc(Program.BZ6, "BZ6"); - GetPlc(Program.BZ7, "BZ7"); - GetPlc(Program.BZ8, "BZ8"); - - - // count++; - // if (count == 1) - // { - // - // count = 0; - // - // } - - Collect("BZ1"); - Collect("BZ2"); - Collect("BZ3"); - Collect("BZ4"); - Collect("BZ5"); - Collect("BZ6"); - Collect("BZ7"); - Collect("BZ8"); - - SetMiddleData("BZ1_DB"); - SetMiddleData("BZ2_DB"); - SetMiddleData("BZ3_DB"); - SetMiddleData("BZ4_DB"); - SetMiddleData("BZ5_DB"); - SetMiddleData("BZ6_DB"); - SetMiddleData("BZ7_DB"); - SetMiddleData("BZ8_DB"); + + string tiaoma = txtProductCode.Text.Replace("\r", "").Replace("\n", ""); + if (tiaoma.Contains("暂无条码") || tiaoma == "") + { + for (int i = 1; i < 9; i++) + { + CleanMiddleData("BZ"+i); + CleanMiddleDataDB($"BZ{i}_DB"); + } + + + } + else + { + + + + + GetPlc(Program.BZ1, "BZ1"); + GetPlc(Program.BZ2, "BZ2"); + GetPlc(Program.BZ3, "BZ3"); + GetPlc(Program.BZ4, "BZ4"); + GetPlc(Program.BZ5, "BZ5"); + GetPlc(Program.BZ6, "BZ6"); + GetPlc(Program.BZ7, "BZ7"); + GetPlc(Program.BZ8, "BZ8"); + + + Collect("BZ1"); + Collect("BZ2"); + Collect("BZ3"); + Collect("BZ4"); + Collect("BZ5"); + Collect("BZ6"); + Collect("BZ7"); + Collect("BZ8"); + + SetMiddleData("BZ1_DB"); + SetMiddleData("BZ2_DB"); + SetMiddleData("BZ3_DB"); + SetMiddleData("BZ4_DB"); + SetMiddleData("BZ5_DB"); + SetMiddleData("BZ6_DB"); + SetMiddleData("BZ7_DB"); + SetMiddleData("BZ8_DB"); + } Thread.Sleep(Program.ReadPlcRate); } @@ -1865,23 +1870,7 @@ namespace ProductionSystem.Forms //} #region 中间控件PLC值采集 - /// - /// 空载 - /// - //private void GetIdlingPointsVal() - //{ - // //responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M261"); - // //for (int i = 0; i < Program.idlingPoints.Count; i++) - // //{ - // // var idlingReadResult = OmronHelper.GetPlcVal(Program.idlingPoints[i].DataType, Program.idlingPoints[i].Address); - // // Program.idlingPoints[i].Val = idlingReadResult.val; - // //} - // //var idlingStatus = Program.idlingPoints.FirstOrDefault(m => m.Key == "M84").Val; - // //if (idlingStatus == "1.000" || idlingStatus == "2.000") - // //{ - // // SetMiddleData(Program.idlingPoints, "Idling", responsePoint, 3); - // //} - //} + @@ -2218,6 +2207,48 @@ namespace ProductionSystem.Forms } + private void CleanMiddleDataDB(string paraCategory) + { + try + { + var groupControls = middleFlowLayoutPanel.Controls.OfType().FirstOrDefault(m => m.Tag.ToString().Contains(paraCategory)); + //如果有GroupControl控件 + if (groupControls != null) + { + var layOutControl = groupControls.Controls.OfType().FirstOrDefault(m => m.Name.Contains(paraCategory)); + if (layOutControl != null) + { + var middleMyTestResultControls = layOutControl.Controls.OfType().ToList(); + if (middleMyTestResultControls.Any()) + { + for (int j = 0; j < middleMyTestResultControls.Count; j++) + { + if (middleMyTestResultControls[j].IsHandleCreated && !middleMyTestResultControls[j].IsDisposed) + { + + + + + + + this.Invoke(new Action(() => + { + SetColor(middleMyTestResultControls[j], -1, "0.000"); + })); + } + } + } + } + } + + } + catch (Exception ex) + { + LogHelper.Error(ex, $"给中间部分控件赋值时异常!"); + } + } + + /// /// 清空中间控件的数据 ///