From 2b60edee673be53c62e62dac88909a6aa86d6f34 Mon Sep 17 00:00:00 2001 From: wenjy Date: Sat, 18 Jun 2022 20:18:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96plc=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasePlcHelper.cs | 11 +++- .../Product/PptPlan/PlanDownloadAction.cs | 57 +++++++++++++++---- 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs index c0499b3..0cb8f2e 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs @@ -842,8 +842,8 @@ namespace Mesnac.Action.ChemicalWeighing //下位机准备信号(上位机下传时读取) public DataKeyValue ChemicalWeighing_PC_ConfirmRemote = new DataKeyValue("ConfirmRemote"); - //下位机准备信号(上位机下传时读取) public DataKeyValue ChemicalWeighing_PC_ConfirmReady = new DataKeyValue("ConfirmReady"); + public DataKeyValue ChemicalWeighing_PC_ConfirmRun = new DataKeyValue("ConfirmRun"); //配方编号、名称 public DataKeyValue ChemicalWeighing_PC_RecipeCode = new DataKeyValue("Recipe_Code"); @@ -867,6 +867,15 @@ namespace Mesnac.Action.ChemicalWeighing public DataKeyValue ChemicalWeighing_PC_SZJl = new DataKeyValue("sz_jl"); public DataKeyValue ChemicalWeighing_PC_SZJlWc = new DataKeyValue("sz_jlwc"); + //配方下传完成信号 + public DataKeyValue ChemicalWeighing_PC_RpFinished = new DataKeyValue("PC_RpFinished"); + + //计划完成车数 + public DataKeyValue ChemicalWeighing_PC_RecipeNum = new DataKeyValue("RecipeNum"); + + //计划编号PlanNo + public DataKeyValue ChemicalWeighing_PC_PlanNo = new DataKeyValue("PlanNo"); + #endregion diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs index 4c75d5e..36a14ac 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs @@ -71,6 +71,7 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan { ICSharpCode.Core.LoggingService.Info("{生产计划-计划下传} 计划下传成功..."); //下传成功后下传RpFinished信号 + bool writeRpFinished = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, new object[] { true }); } else { @@ -82,26 +83,42 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan //执行完成后判断下一计划执行方式,自动方式则继续执行下发流程 } + /// + /// 读取PLC执行的配方编号 + /// + /// public string readRecipeId() { bool readResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, out int[] res); - string readRecipeId = ""; - - if (res.Length > 0) - { - for (int i = 0; i < res.Length; i++) - { - if (res[i] > 0) - { - readRecipeId = readRecipeId + res[i]; - } - } - } + string readRecipeId = intArrayToStr(res); return readRecipeId; } + /// + /// 读取plc计划执行状态 + /// + public void readPlanState() + { + var writeResult1 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, out int[] setAmount ); + + bool finishAmount = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeNum, out int[] res); + + bool planNoResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, out int[] planNo); + + string planNoStr = intArrayToStr(planNo); + + //根据计划编号修改计划状态、完成数量 + Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(planNoStr); + planInfo.real_Amount = Convert.ToInt32(intArrayToStr(res)); + planInfo.plan_State = 1; + string updateResult = PlanHelper.UpdateBasePlanInfo(planInfo); + + //读取完成信号 + + } + /// /// 将配方数据写入PLC地址 /// @@ -196,5 +213,21 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan #endregion } + + public string intArrayToStr(int[] array) + { + string str = ""; + if (array.Length > 0) + { + for (int i = 0; i < array.Length; i++) + { + if (array[i] > 0) + { + str = str + array[i]; + } + } + } + return str; + } } }