diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 42f0734..d44b76a 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -36,6 +36,8 @@ namespace ProductionSystem.Forms private readonly PlcPointService _plcPointService = new PlcPointService(); private readonly ProductTypeService _productTypeService = new ProductTypeService(); + DataProductService dataProductService = new DataProductService(); + private static string iniFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemConfig.ini"); private bool topIsCanRound = true;//展示PLC采集数据时,是否可以进入下一次循环 private bool middleIsCanRound = true;//展示PLC采集数据时,是否可以进入下一次循环 @@ -59,6 +61,9 @@ namespace ProductionSystem.Forms Program.ProductType = usedProductType?.ProductTypeCode; //初始化中间的采集项目 InitMiddleTestItems(); + + + } private void HomeForm_Load(object sender, EventArgs e) @@ -66,7 +71,10 @@ namespace ProductionSystem.Forms #region 各工序的采集点位 Program.BZ1 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); - Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1_DB").ToList(); + Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ2").ToList(); + + var entity = Program.BZ2; + Program.BZ3 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ3").ToList(); Program.BZ4 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ4").ToList(); Program.BZ5 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ5").ToList(); @@ -154,6 +162,9 @@ namespace ProductionSystem.Forms }, cancellationTokenSource.Token); hslCurveHistory.RemoveAllCurve(); + + + SetMiddleData("BZ1_DB"); } /// @@ -461,7 +472,10 @@ namespace ProductionSystem.Forms Size = new Size(200, 29), TestResultPLCPointCode = testResult?.Key, TestValPLCPointCode = testVal?.Key, - TabIndex = j + TabIndex = j, + ParaCategory= paraCategorys[i].DicCode, + ParaCode= currentParaConfigs[j].ParaCode, + }; layoutControlItem.Control = myTestResultControl; layoutItemArr[j] = layoutControlItem; @@ -1195,6 +1209,69 @@ namespace ProductionSystem.Forms } } + + + + private void SetMiddleData(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) + { + var result = string.Empty; + var val = string.Empty; + var testResultPoint = middleMyTestResultControls[j].TestResultPLCPointCode; + var testValPoint = middleMyTestResultControls[j].TestValPLCPointCode; + + //获取点位 + var paraCode = middleMyTestResultControls[j].ParaCode; + + if (string.IsNullOrEmpty(testResultPoint) || string.IsNullOrEmpty(testValPoint)) + { + //进行sql 进行查询sql + + val=dataProductService.QueryDataProduct(paraCategory, paraCode); + } + + + + this.Invoke(new Action(() => + { + if (middleMyTestResultControls[j].LblItemText == "总状态") + { + result = val; + } + middleMyTestResultControls[j].TestResultText = result == "1.000" ? "OK" : (result == "2.000" ? "NG" : ""); + middleMyTestResultControls[j].TestResultForeColor = Color.White; + middleMyTestResultControls[j].TestResultBackColor = result == "1.000" ? Color.Green : (result == "2.000" ? Color.Red : Color.Gainsboro); + middleMyTestResultControls[j].TestValText = val; + })); + } + } + } + } + } + + } + catch (Exception ex) + { + LogHelper.Error(ex, $"给中间部分控件赋值时异常!"); + } + } + + /// /// 清空中间控件的数据 /// diff --git a/ProductionSystem_UserControl/ExtendedControls/MyTestResultControl.cs b/ProductionSystem_UserControl/ExtendedControls/MyTestResultControl.cs index 43d7f6e..d38e9d6 100644 --- a/ProductionSystem_UserControl/ExtendedControls/MyTestResultControl.cs +++ b/ProductionSystem_UserControl/ExtendedControls/MyTestResultControl.cs @@ -146,6 +146,13 @@ namespace ProductionSystem_UserControl.ExtendedControls get { return txtTestVal.Tag?.ToString(); } set { txtTestVal.Tag = value; } } + + + + + public string ParaCode { get; set; } + + public string ParaCategory { get; set; } #endregion }