From 31029e7022355a474789a653e978649ee473641c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sat, 13 Apr 2024 16:55:03 +0800 Subject: [PATCH] bug --- ProductionSystem/Forms/HomeFormInfo.cs | 105 +++++++++++++++++++------ ProductionSystem/Untils/Tool/TmTool.cs | 2 +- 2 files changed, 81 insertions(+), 26 deletions(-) diff --git a/ProductionSystem/Forms/HomeFormInfo.cs b/ProductionSystem/Forms/HomeFormInfo.cs index 5fd35ca..ac2d49c 100644 --- a/ProductionSystem/Forms/HomeFormInfo.cs +++ b/ProductionSystem/Forms/HomeFormInfo.cs @@ -36,6 +36,7 @@ using ProductionSystem_Model.DbModel; using NewLife.Reflection; using System.Collections; using System.Globalization; +using NewLife.Caching; namespace ProductionSystem.Forms { @@ -736,15 +737,22 @@ namespace ProductionSystem.Forms middleIsCanRound = false; Thread.Sleep(Program.ReadPlcRate); - var d1004 = D1004(); - if (d1004 == 0) return; + var d1004 = D1004; + if (d1004==false) return; var d1300Value = GetPlcValue("D1300"); // d1300Value = "1"; //步骤1水泵1空载 - if (d1300Value.ToDouble().ToInt()==1) + if (d1300Value.ToDouble().ToInt()==1 && D1004 ) { - Step1(); + string name = GetCode() + ":Step1"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step1(); + } + + } @@ -753,11 +761,19 @@ namespace ProductionSystem.Forms //步骤2水泵2空载 var d1302Value = GetPlcValue("D1302"); // d1302Value = "1"; - if (d1302Value.ToDouble().ToInt() == 1) + if (d1302Value.ToDouble().ToInt() == 1 && D1004 ) { // 上位机将四通阀运行到模式1,停止水泵1;启动水泵2运行致设定转速,反馈PLC=1或2(可以/不可以测试) + + string name = GetCode() + ":Step2"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step2(); + } + + - Step2(); } @@ -768,9 +784,15 @@ namespace ProductionSystem.Forms //步骤3水泵3空载去停止 - if (d1304Value.ToDouble().ToInt() == 1) + if (d1304Value.ToDouble().ToInt() == 1 && D1004 ) { - Step3(); + + string name =GetCode() + ":Step3"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step3(); + } } @@ -780,19 +802,31 @@ namespace ProductionSystem.Forms var d1312 = GetPlcValue("D1312"); - if (d1312.ToDouble().ToInt() == 1) + if (d1312.ToDouble().ToInt() == 1 && D1004 ) { - StepGaoYa(); + string name = GetCode() + ":Step4"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step4(); + } + } //步骤5模式1内漏 var d1308 = GetPlcValue("D1308"); - if (d1308.ToDouble().ToInt() == 1) + if (d1308.ToDouble().ToInt() == 1 && D1004 ) { - Step5(); + string name = GetCode() + ":Step5"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step5(); + } + } @@ -800,19 +834,30 @@ namespace ProductionSystem.Forms var d1310 = GetPlcValue("D1310"); // d1310 = "1"; - if (d1310.ToDouble().ToInt() == 1) + if (d1310.ToDouble().ToInt() == 1 && D1004 ) { - Step6(); - + string name = GetCode() + ":Step6"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step6(); + } + } //步骤7外露模式 var d1306Value = GetPlcValue("D1306"); // d1306Value = "1"; - if(d1306Value.ToDouble().ToInt() ==1) + if(d1306Value.ToDouble().ToInt() ==1 && D1004 ) { - Step7(); + string name = GetCode() + ":Step7"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step7(); + } + } @@ -821,9 +866,15 @@ namespace ProductionSystem.Forms var d1314 = GetPlcValue("D1314"); // d1314 = "1"; - if (d1314.ToDouble().ToInt() ==1) + if (d1314.ToDouble().ToInt() ==1 && D1004 ) { - Step8(); + string name = GetCode() + ":Step8"; + if (!_cache.ContainsKey(name)) + { + _cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(1)); + Step8(); + } + } @@ -862,7 +913,7 @@ namespace ProductionSystem.Forms - private void StepGaoYa() + private void Step4() { //上位机检测电子膨胀阀1,电子膨胀阀2在常开状态,不在最大值状态时,膨胀阀运行致常开状态,并反馈PLC=1或2(可以/不可以测试) @@ -981,6 +1032,7 @@ namespace ProductionSystem.Forms var writeResult = OmronHelper.WriteToPlc(point.DataType, point.Address, $"{1}"); } + ICache _cache=Cache.Default; private int count = 0; private void ShowMiddleData2() @@ -1165,11 +1217,14 @@ namespace ProductionSystem.Forms } - public int D1004() - { - //1 0 - var entity= Program.CommandPointKeyValues.FirstOrDefault(m => m.Key =="D1004"); - return OmronHelper.GetPlcVal(entity.DataType, entity.Address).val.ToDouble().ToInt(); + public bool D1004 + { + get + { + var entity= Program.CommandPointKeyValues.FirstOrDefault(m => m.Key =="D1004"); + return OmronHelper.GetPlcVal(entity.DataType, entity.Address).val.ToDouble().ToInt() == 1; + } + } ///// diff --git a/ProductionSystem/Untils/Tool/TmTool.cs b/ProductionSystem/Untils/Tool/TmTool.cs index c334a65..de53f32 100644 --- a/ProductionSystem/Untils/Tool/TmTool.cs +++ b/ProductionSystem/Untils/Tool/TmTool.cs @@ -37,7 +37,7 @@ namespace ProductionSystem.Untils.Tool /// /// 四通阀 - /// + /// r /// /// /// 回复出厂