From 635547805094620e78b3770a7f87579609b6b264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Fri, 12 Apr 2024 14:39:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=A1=E7=A0=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=E9=87=87=E9=9B=86=E5=BE=97=E6=97=B6=E5=80=99=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=A1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionSystem/Forms/HomeFormInfo.cs | 43 +++++++++++-------- ProductionSystem/Untils/MFSerialInfo.cs | 1 - ProductionSystem/Untils/Tool/SitongTool.cs | 41 ++++++++++++------ .../DbModel/T_Product_Step.cs | 4 ++ .../ProductStepService.cs | 9 +++- 5 files changed, 63 insertions(+), 35 deletions(-) diff --git a/ProductionSystem/Forms/HomeFormInfo.cs b/ProductionSystem/Forms/HomeFormInfo.cs index 8db67f4..6339546 100644 --- a/ProductionSystem/Forms/HomeFormInfo.cs +++ b/ProductionSystem/Forms/HomeFormInfo.cs @@ -914,6 +914,12 @@ namespace ProductionSystem.Forms + private string GetCode() + { + var readM248 = OmronHelper.GetPlcVal(M248.DataType, M248.Address); + string plcTiaoMa = readM248.val.ToString().Replace("\r", "").Replace("\n", ""); + return plcTiaoMa; + } private void Step1() @@ -925,17 +931,20 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - + + step.ProductBarcode = GetCode(); - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ1_DB, Program.ProductType); + + var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ1_DB, Program.ProductType); //四通1 var stf1= model.STF1; int val = stf1.TargetVal.ToDouble().ToInt(); SitongTool sitongTool = new SitongTool(stf1.Com,val); var si1 = sitongTool.ToAction(); + sitongTool.Dispose(); step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = sitongTool.Val; @@ -950,6 +959,7 @@ namespace ProductionSystem.Forms var stf2 = model.STF2; sitongTool = new SitongTool(stf2.Com, stf2.TargetVal.ToDouble().ToInt()); var si2 = sitongTool.ToAction(); + sitongTool.Dispose(); step.Id = Guid.NewGuid().ToString("N"); step.ReturnValue = sitongTool.Val; @@ -1014,7 +1024,7 @@ namespace ProductionSystem.Forms }; - + step.ProductBarcode = GetCode(); var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ1_DB, Program.ProductType); @@ -1120,11 +1130,11 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - + step.ProductBarcode = GetCode(); - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ2_DB, Program.ProductType); + var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ2_DB, Program.ProductType); //四通1 var stf1= model.STF1; @@ -1263,11 +1273,11 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - + step.ProductBarcode = GetCode(); - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ3_DB, Program.ProductType); + var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ3_DB, Program.ProductType); //四通1 var stf1= model.STF1; @@ -1352,11 +1362,11 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - + step.ProductBarcode = GetCode(); - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ4_DB, Program.ProductType); + var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ4_DB, Program.ProductType); //四通1 var stf1= model.STF1; @@ -1423,11 +1433,11 @@ namespace ProductionSystem.Forms ProductType = Program.ProductType }; - + step.ProductBarcode = GetCode(); - var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ5_DB, Program.ProductType); + var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ5_DB, Program.ProductType); //四通1 var stf1= model.STF1; @@ -1477,7 +1487,7 @@ namespace ProductionSystem.Forms StepName = "BZ6_DB", ProductType = Program.ProductType }; - + step.ProductBarcode = GetCode(); @@ -1528,7 +1538,7 @@ namespace ProductionSystem.Forms - + step.ProductBarcode = GetCode(); var model = paraConfigService.GetParaTargetVal(ModeTypeEnum.BZ5_DB, Program.ProductType); @@ -2210,7 +2220,7 @@ namespace ProductionSystem.Forms //获取点位 var paraCode = middleMyTestResultControls[j].ParaCode; - var step = productStepService.QueryLatestStep(paraCategory, paraCode, Program.ProductType); + var step = productStepService.QueryLatestStep(paraCategory, paraCode, Program.ProductType,GetCode()); if (string.IsNullOrEmpty(testResultPoint) || string.IsNullOrEmpty(testValPoint)) { //进行sql 进行查询sql @@ -2287,12 +2297,7 @@ namespace ProductionSystem.Forms { if (middleMyTestResultControls[j].IsHandleCreated && !middleMyTestResultControls[j].IsDisposed) { - - - - - this.Invoke(new Action(() => { SetColor(middleMyTestResultControls[j], -1, "0.000"); diff --git a/ProductionSystem/Untils/MFSerialInfo.cs b/ProductionSystem/Untils/MFSerialInfo.cs index b34b3bb..b6cd1a1 100644 --- a/ProductionSystem/Untils/MFSerialInfo.cs +++ b/ProductionSystem/Untils/MFSerialInfo.cs @@ -66,7 +66,6 @@ namespace ProductionSystem.Untils { if (Exit) { - // Dispose(); break; } diff --git a/ProductionSystem/Untils/Tool/SitongTool.cs b/ProductionSystem/Untils/Tool/SitongTool.cs index 0d75d9e..e306b03 100644 --- a/ProductionSystem/Untils/Tool/SitongTool.cs +++ b/ProductionSystem/Untils/Tool/SitongTool.cs @@ -11,22 +11,46 @@ using DevExpress.XtraPrinting.BarCode; namespace ProductionSystem.Untils.Tool { - public class SitongTool + public class SitongTool:IDisposable { string com; int mo; + MfSerialInfo mfSerialInfo; + /// + /// 四通阀调试工具 + /// + /// 端口 + /// 模式 1 3 6 public SitongTool(string com, int mo) { this.com = com; this.mo = mo; + Write = mo.ToString(); + mfSerialInfo = new MfSerialInfo(0x2D, 0x2E, com, "19200"); } public string Val { get; set; } = "0"; public string Write { get; set; } + public void Dispose() + { + mfSerialInfo?.Dispose(); + } + + /// + /// 回复出场设计 + /// + + public void ResFactory() + { + //模式变成3 就是恢复出厂 + mo = 3; + ToAction(); + } + public bool ToAction() { var sendMes = ""; @@ -44,11 +68,7 @@ namespace ProductionSystem.Untils.Tool } int cou = 0; - XTrace.WriteLine("发送报文:{0}", sendMes); - - MfSerialInfo mfSerialInfo = new MfSerialInfo(0x2D, 0x2E,com, "19200"); - bool b = false; mfSerialInfo.MsgFunc += (x) => @@ -65,19 +85,17 @@ namespace ProductionSystem.Untils.Tool var intelLsb = me.GetIntelLsb(0, 4); XTrace.WriteLine("mode: {0}", intelLsb); + //获取最后返回的模式 Val = intelLsb.ToInt().ToString(); if (intelLsb.ToInt() == mo && !b) { b = true; mfSerialInfo.Exit = true; + return; } - - - - intelLsb = me.GetIntelLsb(8, 1); XTrace.WriteLine("Hold Torque Active: {0}", intelLsb); @@ -122,15 +140,12 @@ namespace ProductionSystem.Untils.Tool intelLsb = me.GetIntelLsb(40, 8); XTrace.WriteLine("MCV_Version_L: {0}", intelLsb); } - - - }; mfSerialInfo.SendMsg(sendMes,100,100); - mfSerialInfo.Dispose(); + return b; } } diff --git a/ProductionSystem_Model/DbModel/T_Product_Step.cs b/ProductionSystem_Model/DbModel/T_Product_Step.cs index a3f956b..f12c6d4 100644 --- a/ProductionSystem_Model/DbModel/T_Product_Step.cs +++ b/ProductionSystem_Model/DbModel/T_Product_Step.cs @@ -34,5 +34,9 @@ namespace ProductionSystem_Model.DbModel [SugarColumn(ColumnName = "product_type")] public string ProductType { get; set; } + + [SugarColumn(ColumnName = "product_barcode")] + + public string ProductBarcode { get; set; } } } diff --git a/ProductionSystem_Service/ProductStepService.cs b/ProductionSystem_Service/ProductStepService.cs index ead2db8..fe80b82 100644 --- a/ProductionSystem_Service/ProductStepService.cs +++ b/ProductionSystem_Service/ProductStepService.cs @@ -34,9 +34,14 @@ namespace ProductionSystem_Service /// /// /// - public T_Product_Step QueryLatestStep(string stepName,string equipmentName,string productType) + public T_Product_Step QueryLatestStep(string stepName,string equipmentName,string productType,string productCode) { - return db.Queryable().Where(m => m.StepName == stepName && m.EquipmentName == equipmentName && m.ProductType == productType).First(); + return db.Queryable(). + Where(m => m.StepName == stepName + && m.EquipmentName == equipmentName + && m.ProductType == productType) + .Where(x=>x.ProductBarcode==productCode) + .First(); } } }