From 3a3322cdf26545a793b4809821b6f661b993ad48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Mon, 25 Mar 2024 11:16:32 +0800 Subject: [PATCH 1/2] fix --- ProductionSystem/Forms/HomeForm.cs | 344 ++++++++++++--------- ProductionSystem/Forms/SearchResultForm.cs | 7 +- ProductionSystem/Program.cs | 16 +- 3 files changed, 217 insertions(+), 150 deletions(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 1c73328..3bbfaab 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -65,18 +65,25 @@ namespace ProductionSystem.Forms { #region 各工序的采集点位 - Program.electricTestPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); - - - - Program.idlingPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Idling").ToList(); - Program.speedUp1Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SpeedUp1").ToList(); - Program.speedUp2Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SpeedUp2").ToList(); - Program.steady2Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Steady2").ToList(); - Program.speedUp3Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SpeedUp3").ToList(); - Program.steady3Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Steady3").ToList(); - Program.endoleadPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Endolead").ToList(); - Program.singleModelPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SingleModel").ToList(); + Program.BZ1 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); + Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ2").ToList(); + 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(); + Program.BZ6 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ6").ToList(); + Program.BZ7 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ7").ToList(); + Program.BZ8 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ8").ToList(); + + + + //Program.idlingPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Idling").ToList(); + //Program.speedUp1Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SpeedUp1").ToList(); + //Program.speedUp2Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SpeedUp2").ToList(); + //Program.steady2Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Steady2").ToList(); + //Program.speedUp3Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SpeedUp3").ToList(); + //Program.steady3Points = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Steady3").ToList(); + //Program.endoleadPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "Endolead").ToList(); + //Program.singleModelPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "SingleModel").ToList(); #endregion #region 曲线相关 @@ -646,13 +653,13 @@ namespace ProductionSystem.Forms M249.Val = OmronHelper.GetPlcVal(M249.DataType, M249.Address).val; #region 模拟一个值 - for (int i = 0; i < Program.electricTestPoints.Count; i++) - { - var electricReadResult = OmronHelper.GetPlcVal(Program.electricTestPoints[i].DataType, Program.electricTestPoints[i].Address); - Program.electricTestPoints[i].Val = electricReadResult.val; - } + + + + + + - SetMiddleData(Program.electricTestPoints, "BZ1"); //var electricPoint = Program.electricTestPoints.FirstOrDefault(m => m.Key == "M44"); //var electricStatus = OmronHelper.GetPlcVal(electricPoint.DataType, electricPoint.Address).val; //if (electricStatus == "1.000" || electricStatus == "2.000") @@ -666,37 +673,35 @@ namespace ProductionSystem.Forms { //空载 case "2.000": - GetIdlingPointsVal(); + BZ1(); break; //一段速 case "3.000": - GetSpeedUp1PointsVal(); + BZ1(); break; //二段升速 case "4.000": - GetSpeedUp2Points(); + BZ1(); break; //二段速稳定 case "5.000": - GetSpeedUp1PointsVal(); - GetSpeedUp2Points(); + BZ1(); break; //三段升速度 case "6.000": - GetSteady2Points(); + BZ1(); break; //三段速稳定 case "7.000": - GetSpeedUp3Points(); + BZ1(); break; //内漏 case "8.000": - GetEndoleadPoints(); - GetSteady2Points(); + BZ1(); break; //单驱 case "9.000": - GetSingleModelPoints(); + BZ1(); break; case "0.000"://设备待机 hasWriteStepNum = false; @@ -718,9 +723,7 @@ namespace ProductionSystem.Forms Program.timerEnable = false; break; case "10.000"://停机 - GetSteady2Points(); - GetSteady3Points(); - GetEndoleadPoints(); + BZ1(); if (!hasWriteCurveSeciont) { //AddCurveSection(stepChangeCount); @@ -915,149 +918,208 @@ namespace ProductionSystem.Forms /// /// 空载 /// - private void GetIdlingPointsVal() + //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); + // //} + //} + + + + + private void BZ1() { - //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); - //} + + GetPlc(Program.BZ1, "BZ1"); + } - + private void BZ2() + { - /// - /// 一段速 - /// - private void GetSpeedUp1PointsVal() + GetPlc(Program.BZ2, "BZ2"); + + } + + private void BZ3() + { + + GetPlc(Program.BZ3, "BZ3"); + + } + + private void BZ4() + { + + GetPlc(Program.BZ4, "BZ4"); + + } + + private void BZ5() + { + + GetPlc(Program.BZ5, "BZ5"); + + } + + private void BZ6() { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M263"); - for (int i = 0; i < Program.speedUp1Points.Count; i++) + + GetPlc(Program.BZ6, "BZ6"); + + } + + + private void GetPlc(List values,string txt) + { + var Bz1 = values; + for (int i = 0; i < Bz1.Count; i++) { - var speedUp1ReadResult = OmronHelper.GetPlcVal(Program.speedUp1Points[i].DataType, Program.speedUp1Points[i].Address); - Program.speedUp1Points[i].Val = speedUp1ReadResult.val; + var electricReadResult = OmronHelper.GetPlcVal(Bz1[i].DataType, Bz1[i].Address); + Bz1[i].Val = electricReadResult.val; } - //var speedUp1Status = Program.speedUp1Points.FirstOrDefault(m => m.Key == "M129").Val; - //if (speedUp1Status == "1.000" || speedUp1Status == "2.000") - //{ - // SetMiddleData(Program.speedUp1Points, "SpeedUp1", responsePoint, 3); - //} + + SetMiddleData(Bz1,txt); } + + + + /// + /// 一段速 + /// + //private void GetSpeedUp1PointsVal() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M263"); + // for (int i = 0; i < Program.speedUp1Points.Count; i++) + // { + // var speedUp1ReadResult = OmronHelper.GetPlcVal(Program.speedUp1Points[i].DataType, Program.speedUp1Points[i].Address); + // Program.speedUp1Points[i].Val = speedUp1ReadResult.val; + // } + // //var speedUp1Status = Program.speedUp1Points.FirstOrDefault(m => m.Key == "M129").Val; + // //if (speedUp1Status == "1.000" || speedUp1Status == "2.000") + // //{ + // // SetMiddleData(Program.speedUp1Points, "SpeedUp1", responsePoint, 3); + // //} + //} + /// /// 二段升速 /// - private void GetSpeedUp2Points() - { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M265"); - for (int i = 0; i < Program.speedUp2Points.Count; i++) - { - var speedUp2ReadResult = OmronHelper.GetPlcVal(Program.speedUp2Points[i].DataType, Program.speedUp2Points[i].Address); - Program.speedUp2Points[i].Val = speedUp2ReadResult.val; - } - //var speedUp2Status = Program.speedUp2Points.FirstOrDefault(m => m.Key == "M143").Val; - //if (speedUp2Status == "1.000" || speedUp2Status == "2.000") - //{ - // SetMiddleData(Program.speedUp2Points, "SpeedUp2", responsePoint, 3); - //} - } + //private void GetSpeedUp2Points() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M265"); + // for (int i = 0; i < Program.speedUp2Points.Count; i++) + // { + // var speedUp2ReadResult = OmronHelper.GetPlcVal(Program.speedUp2Points[i].DataType, Program.speedUp2Points[i].Address); + // Program.speedUp2Points[i].Val = speedUp2ReadResult.val; + // } + // //var speedUp2Status = Program.speedUp2Points.FirstOrDefault(m => m.Key == "M143").Val; + // //if (speedUp2Status == "1.000" || speedUp2Status == "2.000") + // //{ + // // SetMiddleData(Program.speedUp2Points, "SpeedUp2", responsePoint, 3); + // //} + //} /// /// 二段稳定 /// - private void GetSteady2Points() - { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M265"); - for (int i = 0; i < Program.steady2Points.Count; i++) - { - var steady2ReadResult = OmronHelper.GetPlcVal(Program.steady2Points[i].DataType, Program.steady2Points[i].Address); - Program.steady2Points[i].Val = steady2ReadResult.val; - } - var steady2Status = Program.steady2Points.FirstOrDefault(m => m.Key == "M182").Val; - if (steady2Status == "1.000" || steady2Status == "2.000") - { - SetMiddleData(Program.steady2Points, "Steady2", responsePoint, 4); - } - } + //private void GetSteady2Points() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M265"); + // for (int i = 0; i < Program.steady2Points.Count; i++) + // { + // var steady2ReadResult = OmronHelper.GetPlcVal(Program.steady2Points[i].DataType, Program.steady2Points[i].Address); + // Program.steady2Points[i].Val = steady2ReadResult.val; + // } + // var steady2Status = Program.steady2Points.FirstOrDefault(m => m.Key == "M182").Val; + // if (steady2Status == "1.000" || steady2Status == "2.000") + // { + // SetMiddleData(Program.steady2Points, "Steady2", responsePoint, 4); + // } + //} /// /// 三段升速 /// - private void GetSpeedUp3Points() - { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M267"); - for (int i = 0; i < Program.speedUp3Points.Count; i++) - { - var speedUp3PointsReadResult = OmronHelper.GetPlcVal(Program.speedUp3Points[i].DataType, Program.speedUp3Points[i].Address); - Program.speedUp3Points[i].Val = speedUp3PointsReadResult.val; - } - var speedUp3Status = Program.speedUp3Points.FirstOrDefault(m => m.Key == "M196").Val; - if (speedUp3Status == "1.000" || speedUp3Status == "2.000") - { - SetMiddleData(Program.speedUp3Points, "SpeedUp3", responsePoint, 3); - } - } + //private void GetSpeedUp3Points() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M267"); + // for (int i = 0; i < Program.speedUp3Points.Count; i++) + // { + // var speedUp3PointsReadResult = OmronHelper.GetPlcVal(Program.speedUp3Points[i].DataType, Program.speedUp3Points[i].Address); + // Program.speedUp3Points[i].Val = speedUp3PointsReadResult.val; + // } + // var speedUp3Status = Program.speedUp3Points.FirstOrDefault(m => m.Key == "M196").Val; + // if (speedUp3Status == "1.000" || speedUp3Status == "2.000") + // { + // SetMiddleData(Program.speedUp3Points, "SpeedUp3", responsePoint, 3); + // } + //} /// /// 三段稳定 /// - private void GetSteady3Points() - { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M267"); - for (int i = 0; i < Program.steady3Points.Count; i++) - { - var steady3PointsReadResult = OmronHelper.GetPlcVal(Program.steady3Points[i].DataType, Program.steady3Points[i].Address); - Program.steady3Points[i].Val = steady3PointsReadResult.val; - } - var steady3Status = Program.steady3Points.FirstOrDefault(m => m.Key == "M231").Val; - if (steady3Status == "1.000" || steady3Status == "2.000") - { - SetMiddleData(Program.steady3Points, "Steady3", responsePoint, 4); - } - } + //private void GetSteady3Points() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M267"); + // for (int i = 0; i < Program.steady3Points.Count; i++) + // { + // var steady3PointsReadResult = OmronHelper.GetPlcVal(Program.steady3Points[i].DataType, Program.steady3Points[i].Address); + // Program.steady3Points[i].Val = steady3PointsReadResult.val; + // } + // var steady3Status = Program.steady3Points.FirstOrDefault(m => m.Key == "M231").Val; + // if (steady3Status == "1.000" || steady3Status == "2.000") + // { + // SetMiddleData(Program.steady3Points, "Steady3", responsePoint, 4); + // } + //} /// /// 内漏 /// - private void GetEndoleadPoints() - { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M269"); - for (int i = 0; i < Program.endoleadPoints.Count; i++) - { - var endoleadPointsReadResult = OmronHelper.GetPlcVal(Program.endoleadPoints[i].DataType, Program.endoleadPoints[i].Address); - Program.endoleadPoints[i].Val = endoleadPointsReadResult.val; - } - var endoleadStatus = Program.endoleadPoints.FirstOrDefault(m => m.Key == "M239").Val; - if (endoleadStatus == "1.000" || endoleadStatus == "2.000") - { - SetMiddleData(Program.endoleadPoints, "Endolead", responsePoint, 3); - } - } + //private void GetEndoleadPoints() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M269"); + // for (int i = 0; i < Program.endoleadPoints.Count; i++) + // { + // var endoleadPointsReadResult = OmronHelper.GetPlcVal(Program.endoleadPoints[i].DataType, Program.endoleadPoints[i].Address); + // Program.endoleadPoints[i].Val = endoleadPointsReadResult.val; + // } + // var endoleadStatus = Program.endoleadPoints.FirstOrDefault(m => m.Key == "M239").Val; + // if (endoleadStatus == "1.000" || endoleadStatus == "2.000") + // { + // SetMiddleData(Program.endoleadPoints, "Endolead", responsePoint, 3); + // } + //} /// /// 单驱 /// - private void GetSingleModelPoints() - { - responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M271"); - for (int i = 0; i < Program.singleModelPoints.Count; i++) - { - var singleModelPointsReadResult = OmronHelper.GetPlcVal(Program.singleModelPoints[i].DataType, Program.singleModelPoints[i].Address); - Program.singleModelPoints[i].Val = singleModelPointsReadResult.val; - } - var singleModelStatus = Program.singleModelPoints.FirstOrDefault(m => m.Key == "M247").Val; - if (singleModelStatus == "1.000" || singleModelStatus == "2.000") - { - SetMiddleData(Program.singleModelPoints, "SingleModel", responsePoint, 3); - } - } + //private void GetSingleModelPoints() + //{ + // responsePoint = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M271"); + // for (int i = 0; i < Program.singleModelPoints.Count; i++) + // { + // var singleModelPointsReadResult = OmronHelper.GetPlcVal(Program.singleModelPoints[i].DataType, Program.singleModelPoints[i].Address); + // Program.singleModelPoints[i].Val = singleModelPointsReadResult.val; + // } + // var singleModelStatus = Program.singleModelPoints.FirstOrDefault(m => m.Key == "M247").Val; + // if (singleModelStatus == "1.000" || singleModelStatus == "2.000") + // { + // SetMiddleData(Program.singleModelPoints, "SingleModel", responsePoint, 3); + // } + //} #endregion /// diff --git a/ProductionSystem/Forms/SearchResultForm.cs b/ProductionSystem/Forms/SearchResultForm.cs index 38f877e..f0bc4dc 100644 --- a/ProductionSystem/Forms/SearchResultForm.cs +++ b/ProductionSystem/Forms/SearchResultForm.cs @@ -201,7 +201,12 @@ namespace ProductionSystem.Forms column.AppearanceHeader.Options.UseFont = true; column.Caption = plcPoints[i].PointName; var resultField = plcPoints[i].ResultField; - column.FieldName = resultField.Substring(0, 1).ToUpper() + resultField.Substring(1); + if (!string.IsNullOrEmpty(resultField) && resultField.Length>2) + { + column.FieldName = resultField.Substring(0, 1).ToUpper() + resultField.Substring(1); + } + + column.MinWidth = 250; column.Name = plcPoints[i].ResultField; column.Visible = true; diff --git a/ProductionSystem/Program.cs b/ProductionSystem/Program.cs index e5872fe..aa070fe 100644 --- a/ProductionSystem/Program.cs +++ b/ProductionSystem/Program.cs @@ -305,21 +305,21 @@ namespace ProductionSystem public static List speedUp2Points { get; set; } - public static List electricTestPoints { get; set; } + public static List BZ1 { get; set; } - public static List idlingPoints { get; set; } + public static List BZ2 { get; set; } - public static List speedUp1Points { get; set; } + public static List BZ3 { get; set; } - public static List steady2Points { get; set; } + public static List BZ4 { get; set; } - public static List speedUp3Points { get; set; } + public static List BZ5 { get; set; } - public static List steady3Points { get; set; } + public static List BZ6 { get; set; } - public static List endoleadPoints { get; set; } + public static List BZ7 { get; set; } - public static List singleModelPoints { get; set; } + public static List BZ8 { get; set; } #endregion /// From 88ccdec8fee48ea8aa32262948178d62d64173b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Mon, 25 Mar 2024 14:32:35 +0800 Subject: [PATCH 2/2] BZ2 --- ProductionSystem/Forms/HomeForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 3bbfaab..42f0734 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -66,7 +66,7 @@ namespace ProductionSystem.Forms #region 各工序的采集点位 Program.BZ1 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1").ToList(); - Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ2").ToList(); + Program.BZ2 = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "BZ1_DB").ToList(); 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();