From c4b9956e26c8a116c116d872ffc04381aba1f5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Tue, 19 Mar 2024 18:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Forms/HomeForm.cs | 61 +++++++++++-------- ProductionSystem/Untils/DoSomething.cs | 2 +- .../Untils/System/BindDropDownHelper.cs | 23 ++++++- ProductionSystem_Service/DbContext.cs | 8 +-- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/ProductionSystem/Forms/HomeForm.cs b/ProductionSystem/Forms/HomeForm.cs index 2176268..1c73328 100644 --- a/ProductionSystem/Forms/HomeForm.cs +++ b/ProductionSystem/Forms/HomeForm.cs @@ -65,7 +65,10 @@ namespace ProductionSystem.Forms { #region 各工序的采集点位 - Program.electricTestPoints = Program.MiddlePointKeyValues.Where(m => m.ParaCategory == "ElectricTest").ToList(); + 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(); @@ -101,22 +104,22 @@ namespace ProductionSystem.Forms #endregion #region 页面第一次加载的时候,读取一遍PLC数据 - //空载 - GetIdlingPointsVal(); - //一段速 - GetSpeedUp1PointsVal(); - //二段升速 - GetSpeedUp2Points(); - //二段速稳定 - GetSteady2Points(); - //三段升速 - GetSpeedUp3Points(); - //三段速稳定 - GetSteady3Points(); - //内漏 - GetEndoleadPoints(); - //单驱 - GetSingleModelPoints(); + ////空载 + //GetIdlingPointsVal(); + ////一段速 + //GetSpeedUp1PointsVal(); + ////二段升速 + //GetSpeedUp2Points(); + ////二段速稳定 + //GetSteady2Points(); + ////三段升速 + //GetSpeedUp3Points(); + ////三段速稳定 + //GetSteady3Points(); + ////内漏 + //GetEndoleadPoints(); + ////单驱 + //GetSingleModelPoints(); #endregion //PLC心跳监测 @@ -492,8 +495,8 @@ namespace ProductionSystem.Forms continue; } //条码值 - var readM248 = OmronHelper.GetPlcVal(M248.DataType, M248.Address); - UpdateControlContent(txtProductCode, readM248.val); + //var readM248 = OmronHelper.GetPlcVal(M248.DataType, M248.Address); + //UpdateControlContent(txtProductCode, readM248.val); #region 顶部采集项目赋值 if (Program.TopPointKeyValues.Count > 0) @@ -642,20 +645,23 @@ namespace ProductionSystem.Forms var M249 = Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == "M249"); M249.Val = OmronHelper.GetPlcVal(M249.DataType, M249.Address).val; - #region 电检一直采集 + #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; } - 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") - { - SetMiddleData(Program.electricTestPoints, "ElectricTest"); - } + + 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") + //{ + // SetMiddleData(Program.electricTestPoints, "ElectricTest"); + //} #endregion + M249.Val = "23234234234234"; switch (M249.Val) { //空载 @@ -924,6 +930,9 @@ namespace ProductionSystem.Forms //} } + + + /// /// 一段速 /// diff --git a/ProductionSystem/Untils/DoSomething.cs b/ProductionSystem/Untils/DoSomething.cs index 2f43383..304e05c 100644 --- a/ProductionSystem/Untils/DoSomething.cs +++ b/ProductionSystem/Untils/DoSomething.cs @@ -37,7 +37,7 @@ namespace ProductionSystem.Untils while (true) { Thread.Sleep(Program.ReadPlcRate); - DataChange(); + // DataChange(); } }); } diff --git a/ProductionSystem/Untils/System/BindDropDownHelper.cs b/ProductionSystem/Untils/System/BindDropDownHelper.cs index ea5b459..24e40f8 100644 --- a/ProductionSystem/Untils/System/BindDropDownHelper.cs +++ b/ProductionSystem/Untils/System/BindDropDownHelper.cs @@ -5,6 +5,8 @@ using DevExpress.XtraEditors.Repository; using ProductionSystem_Model.Enum; using ProductionSystem_Service; using SqlSugar; + +using System; using System.Collections.Generic; using System.IO.Ports; using System.Linq; @@ -362,7 +364,26 @@ namespace ProductionSystem.Untils.System var defaultSelected = list.FirstOrDefault(m => m.IsUsed); if (defaultSelected != null) { - cmbEdit.SelectedItem = new ListItem { Value = defaultSelected.ProductTypeCode, Text = defaultSelected.ProductTypeName }; + try + + { + + // cmbEdit.SelectedIndex = 0; + //cmbEdit.Invoke((MethodInvoker)delegate { + // cmbEdit.SelectedItem = new ListItem { Value = defaultSelected.ProductTypeCode, Text = defaultSelected.ProductTypeName }; + // // 进行操作 + //}); + + // + } + catch (Exception ex) + { + + + } + + + } else { diff --git a/ProductionSystem_Service/DbContext.cs b/ProductionSystem_Service/DbContext.cs index 8905845..f36c534 100644 --- a/ProductionSystem_Service/DbContext.cs +++ b/ProductionSystem_Service/DbContext.cs @@ -40,10 +40,10 @@ namespace ProductionSystem_Service { //(A)全局生效配置点 //调试SQL事件,可以删掉 - //db.Aop.OnLogExecuting = (sql, pars) => - //{ - // Console.WriteLine(sql);//输出sql,查看执行sql - //}; + db.Aop.OnLogExecuting = (sql, pars) => + { + Console.WriteLine(sql);//输出sql,查看执行sql + }; db.Aop.OnError = (exp) => { LogHelper.Error(exp, exp.Sql);