From 91bb746da12c3cf7a6c45f46d10cb0acdc8be55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sun, 7 Apr 2024 08:44:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5=E7=9A=84?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Forms/HomeForm.cs | 15 +++++++--- .../ExtendedControls/MyResultControl.cs | 30 +++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 97acd50..fbe3f9e 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -171,9 +171,7 @@ namespace ProductionSystem.Forms ShowMiddleData2(); - ShowMiddleData2(); - ShowMiddleData2(); - ShowMiddleData2(); + } @@ -573,15 +571,18 @@ namespace ProductionSystem.Forms testValPoint.Val = val; this.Invoke(new Action(() => { + topMyResultControls[i].SetForeColor(Color.Black); topMyResultControls[i].TestValText = testValPoint.Val; if (testValPoint.Val == "0.000") { topMyResultControls[i].TestValText = "停止"; + topMyResultControls[i].SetForeColor(Color.Red); } else if (testValPoint.Val == "1.000") { topMyResultControls[i].TestValText = "启动"; + topMyResultControls[i].SetForeColor(Color.Green); } })); //if (M249.Val != "0.000" && M249.Val != "10.000") @@ -803,7 +804,7 @@ namespace ProductionSystem.Forms private void ShowMiddleData2() { - Thread.Sleep(Program.ReadPlcRate); + GetPlc(Program.BZ1, "BZ1"); GetPlc(Program.BZ2, "BZ2"); @@ -812,6 +813,7 @@ namespace ProductionSystem.Forms GetPlc(Program.BZ5, "BZ5"); GetPlc(Program.BZ6, "BZ6"); + Thread.Sleep(Program.ReadPlcRate); } @@ -1223,6 +1225,11 @@ namespace ProductionSystem.Forms + + /// + /// 显示Db块的数据 + /// + /// private void SetMiddleData(string paraCategory) { try diff --git a/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs b/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs index e17cf4d..4b85262 100644 --- a/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs +++ b/ProductionSystem_UserControl/ExtendedControls/MyResultControl.cs @@ -33,23 +33,29 @@ namespace ProductionSystem_UserControl.ExtendedControls get { return txtTestVal.Text; } set { - if (txtTestVal.Text == "停止") - { - txtTestVal.ForeColor = Color.Red; - } - else if(txtTestVal.Text == "启动") - { - txtTestVal.ForeColor = Color.Green; - } - else - { - txtTestVal.ForeColor = Color.Black; - } + //if (txtTestVal.Text == "停止") + //{ + // txtTestVal.ForeColor = Color.Red; + //} + //else if(txtTestVal.Text == "启动") + //{ + // txtTestVal.ForeColor = Color.Green; + //} + //else + //{ + // txtTestVal.ForeColor = Color.Black; + //} _testValText = value; txtTestVal.Text = _testValText; } } + + public void SetForeColor(Color color) + { + this.txtTestVal.ForeColor = color; + } + //添加背景颜色 ///