From 25a475a47f0d328c60733bde07da9444de62c415 Mon Sep 17 00:00:00 2001 From: nodyang Date: Tue, 15 Aug 2023 08:43:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4plc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasePlcHelper.cs | 136 +------- .../ChemicalWeighingPlc/PlcPlanHelper.cs | 166 +--------- .../DeviceParamManage/InitDeviceParamInfo.cs | 95 +----- .../SelectDeviceParamInfo.cs | 14 +- .../DeviceParamManage/WriteDeviceParamInfo.cs | 16 +- .../FinishBatch/FinishBatchHelper.cs | 154 +-------- .../FinishBatch/FinishBatchService.cs | 161 +-------- .../FinishBatch/GHFinshBatchHelper.cs | 83 +---- .../Product/PptPlan/PlanDownloadAction.cs | 305 +----------------- .../Product/PptPlan/ProductionBudgetAction.cs | 84 +---- .../Product/PptPlan/ReloadPlanInfo.cs | 77 ----- .../Product/PptPlan/StopAction.cs | 2 +- .../Sys/SystemInitAutoAction.cs | 4 +- 13 files changed, 20 insertions(+), 1277 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs index d92b65a..1bb1dc7 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BasePlcHelper.cs @@ -957,130 +957,7 @@ namespace Mesnac.Action.ChemicalWeighing #endregion - #region 冠合上位机计划下传 - - public List dataKeyValues = new List(); - - - //下位机准备信号(上位机下传时读取) - /// - /// 下位机在线 - /// - public DataKeyValue GH_PC_ConfirmOnline = new DataKeyValue("Sign_Confirm_ConfirmOnline"); //下位机在线 - - /// - /// 下位机遥控 - /// - public DataKeyValue GH_PC_ConfirmRemote = new DataKeyValue("Sign_Confirm_ConfirmRemote"); //下位机遥控 - - /// - /// 下位机准备好 - /// - public DataKeyValue GH_PC_ConfirmReady = new DataKeyValue("Sign_Confirm_ConfirmReady"); //下位机准备好 - - /// - /// 下位机配方运行 - /// - public DataKeyValue GH_PC_ConfirmRun = new DataKeyValue("Sign_Confirm_ConfirmRun"); //下位机配方运行 - - /// - /// 调试模式允许 - /// - public DataKeyValue GH_PC_ConfirmForc = new DataKeyValue("Sign_Confirm_ConfirmForc"); // 调试模式允许 - - //配方编号、名称 - public DataKeyValue ChemicalWeighing_PC_RecipeCode = new DataKeyValue("Recipe_Code"); - - public DataKeyValue ChemicalWeighing_PC_RecipeName = new DataKeyValue("recipe_name"); - - //设定车数、格数、层数 - public DataKeyValue ChemicalWeighing_PC_SetCarNumber = new DataKeyValue("set_carnumber"); - public DataKeyValue ChemicalWeighing_PC_SetGeNumber = new DataKeyValue("set_genumber"); - - public DataKeyValue ChemicalWeighing_PC_SetLineNumber = new DataKeyValue("set_linenumber"); - - //混料速度 - public DataKeyValue ChemicalWeighing_PC_Hlsd1 = new DataKeyValue("hlsd1"); - public DataKeyValue ChemicalWeighing_PC_Hlsd2 = new DataKeyValue("hlsd2"); - - public DataKeyValue ChemicalWeighing_PC_Hlsd3 = new DataKeyValue("hlsd3"); - - //进料时间、混料时间 - public DataKeyValue ChemicalWeighing_PC_Jlsj = new DataKeyValue("jl_sj"); - - public DataKeyValue ChemicalWeighing_PC_Hlsj = new DataKeyValue("hl_sj"); - - //VCC、GFA、树脂进料、进料误差 - public DataKeyValue ChemicalWeighing_PC_VCCJl = new DataKeyValue("vcc_jl"); - public DataKeyValue ChemicalWeighing_PC_VCCJlWc = new DataKeyValue("vcc_jlwc"); - public DataKeyValue ChemicalWeighing_PC_GFAJl = new DataKeyValue("gfa_jl"); - public DataKeyValue ChemicalWeighing_PC_GFAJlWc = new DataKeyValue("gfa_jlwc"); - public DataKeyValue ChemicalWeighing_PC_SZJl = new DataKeyValue("sz_jl"); - public DataKeyValue ChemicalWeighing_PC_SZJlWc = new DataKeyValue("sz_jlwc"); - public DataKeyValue ChemicalWeighing_PC_VCC_2th = new DataKeyValue("vcc2th_jl"); - public DataKeyValue ChemicalWeighing_PC_GFA_2th = new DataKeyValue("GFA2th_jl"); - - //配方下传完成信号 - public DataKeyValue ChemicalWeighing_PC_RpFinished = new DataKeyValue("PlanDownLoad"); - - //计划完成车数 - public DataKeyValue ChemicalWeighing_PC_RecipeNum = new DataKeyValue("RecipeNum"); - - //计划编号PlanNo - public DataKeyValue ChemicalWeighing_PC_PlanNo = new DataKeyValue("PlanNo"); - - //计划终止 - public DataKeyValue ChemicalWeighing_PC_RpCancel = new DataKeyValue("RpCancel"); - public DataKeyValue TestWriteBool1 = new DataKeyValue("TestWriteBool1"); - public DataKeyValue TestWriteBool2 = new DataKeyValue("TestWriteBool2"); - - - #region 冠合存盘数据 - - /// - /// 存盘数据准备好 - /// - public DataKeyValue GH_PC_ConfirmSDReady = new DataKeyValue("Sign_Confirm_ConfirmSDReady"); - - /// - /// 配方编号 - /// - public DataKeyValue GH_PC_SaveCode = new DataKeyValue("SaveCode"); - - public DataKeyValue GH_PC_SaveFinishedNum = new DataKeyValue("SaveFinishedNum"); - public DataKeyValue GH_PC_SaveRow = new DataKeyValue("SaveRow"); - public DataKeyValue GH_PC_SaveCol = new DataKeyValue("SaveCol"); - public DataKeyValue GH_PC_SaveVCCSet = new DataKeyValue("SaveVCCSet"); - public DataKeyValue GH_PC_SaveVCCAct = new DataKeyValue("SaveVCCAct"); - public DataKeyValue GH_PC_SaveGFASet = new DataKeyValue("SaveGFASet"); - public DataKeyValue GH_PC_SaveGFAAct = new DataKeyValue("SaveGFAAct"); - public DataKeyValue GH_PC_Save3thSet = new DataKeyValue("Save3thSet"); - public DataKeyValue GH_PC_Save3thAct = new DataKeyValue("Save3thAct"); - public DataKeyValue GH_PC_SaveLevel = new DataKeyValue("SaveLevel"); - public DataKeyValue GH_PC_SaveFillTime = new DataKeyValue("SaveFillTime"); - public DataKeyValue GH_PC_SaveSpeed1 = new DataKeyValue("SaveSpeed1"); - public DataKeyValue GH_PC_SaveSpeed2 = new DataKeyValue("SaveSpeed2"); - public DataKeyValue GH_PC_SaveTime = new DataKeyValue("SaveTime"); - public DataKeyValue GH_PC_SavePlanId = new DataKeyValue("SavePlanId"); - public DataKeyValue GH_PC_SaveVCC2thSet = new DataKeyValue("SaveVCC2thSet"); - public DataKeyValue GH_PC_SaveVCC2thAct = new DataKeyValue("SaveVCC2thAct"); - public DataKeyValue GH_PC_SaveGFA2thSet = new DataKeyValue("SaveGFA2thSet"); - public DataKeyValue GH_PC_SaveGFA2thAct = new DataKeyValue("SaveGFA2thAct"); - - - - - - - /// - /// 存盘数据保存完成 - /// - public DataKeyValue ChemicalWeighing_PC_RpSaved = new DataKeyValue("RpSaved"); - - #endregion - - - #endregion + @@ -3156,14 +3033,6 @@ namespace Mesnac.Action.ChemicalWeighing public DataKeyValue Weter_M8Step9_setValue { get; set; } public DataKeyValue Weter_M8Step9_tolerance { get; set; } - - - - public DataKeyValue test { get; set; } - public DataKeyValue tst0 { get; set; } - public DataKeyValue tst1 { get; set; } - public DataKeyValue tst2 { get; set; } - #region 干混机报表参数 Add By wenjy 2023-08-08 15:40:00 #region 注释代码 /*/// @@ -3379,7 +3248,6 @@ namespace Mesnac.Action.ChemicalWeighing #endregion - - public DataKeyValue recipeName { get; set; } + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ChemicalWeighingPlc/PlcPlanHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ChemicalWeighingPlc/PlcPlanHelper.cs index f44015f..2ef836e 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ChemicalWeighingPlc/PlcPlanHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ChemicalWeighingPlc/PlcPlanHelper.cs @@ -39,170 +39,8 @@ namespace Mesnac.Action.ChemicalWeighing.ChemicalWeighingPlc #endregion - #region 冠合计划自动下传 - public static bool GHDownloadPlanData() - { - try - { - //查询PLC状态,确认是否可以下发计划 - if (!(BasePlcHelper.Instance.GH_PC_ConfirmOnline.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmRemote.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmReady.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmRun.NowValue.ToInt() == 0)) - { - ICSharpCode.Core.LoggingService.Debug("{生产计划-自动计划下传} 下位机信号未准备好..."); - } - else - { - //扫描计划表中的最先执行的计划 - List base_PlanListInfos = Product.PptPlan.GhPlanHelper.GetPlanEntityListByNum(1); - if (base_PlanListInfos != null && base_PlanListInfos.Count > 0) - { - if(base_PlanListInfos[0].run_Type == 1) //0-自动运行;1-手动运行,手动方式需要操作人点击“执行”按钮方可下达计划执行 - { - return false; - } - else - { - //写入配方数据 - //通过配方ID关联配方数据 - if (WriteRecipeInfoToPLC(base_PlanListInfos[0])) //配方下发成功 - { - //更新计划界面 - ICSharpCode.Core.LoggingService.Debug("{生产计划-自动计划下传} 自动计划下传成功..."); - } - else //配方下发失败 - { - ICSharpCode.Core.LoggingService.Error("{生产计划-自动计划下传} 自动计划下传失败..."); - } - } - } - } - return true; - } - catch (Exception ex) - { - return false; - } - } - - #endregion - public static bool WriteRecipeInfoToPLC(Product.PptPlan.entity.Base_PlanInfo base_PlanInfo) - { - try - { - Base_RecipeInfo info = Technical.PmtRecipe.RecipeHelper.GetRecipeById(base_PlanInfo.recipe_Id); - var plan_Id = Convert.ToInt32(base_PlanInfo.plan_Id); - - object[] recipeidArray = Mesnac.Basic.DataProcessor.ToSiemensPLCDataArray(plan_Id); - - //计划编号 - bool resultPlanNoPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, recipeidArray); - //配方编号 - bool resultFromPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, new object[] {int.Parse(base_PlanInfo.recipe_Id) }); - //配方名称,测试暂用配方编号代替 - bool writeResult = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeName, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //设定车数 - var writeResult1 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, new object[] { base_PlanInfo.car_Amount }); - //格数 - var writeResult2 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetGeNumber, new object[] { base_PlanInfo.grid_Amount }); - - //层数 - var writeResult3 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetLineNumber, new object[] { base_PlanInfo.line_Amount }); - - //通过配方编号获取物料信息、参数信息 - List recipeMaterials = Technical.PmtRecipe.RecipeHelper.GetRecipeMaterialInfoByRecipeId(info.recipeId); - - //罐1 - //VCC加料 - //Base_RecipeMaterial recipeMaterial = recipeMaterials.Where(x => x.materialName.Contains("VCC")).FirstOrDefault(); - Base_RecipeMaterial recipeMaterial = recipeMaterials[0]; - decimal vccJl = recipeMaterial.materialWeight; - var writeResult9 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJl, (float)vccJl); - - ////GFA加料 - //Base_RecipeMaterial recipeMaterial2 = recipeMaterials.Where(x => x.materialName.Contains("GFA")).FirstOrDefault(); - Base_RecipeMaterial recipeMaterial2 = recipeMaterials[1]; - decimal gfajl = recipeMaterial2.materialWeight; - var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJl, (float)gfajl); - - ////树脂加料 - //Base_RecipeMaterial recipeMaterial3 = recipeMaterials.Where(x => x.materialName.Contains("树脂")).FirstOrDefault(); - Base_RecipeMaterial recipeMaterial3 = recipeMaterials[2]; - decimal szjl = recipeMaterial3.materialWeight; - var writeResult11 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJl, (float)szjl); - - //罐A2次加料 - Base_RecipeMaterial recipeMaterial4 = recipeMaterials[3]; - decimal vcc2th = recipeMaterial4.materialWeight; - var writeResult20 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCC_2th, (float)vcc2th); - - //罐B2次加料 - Base_RecipeMaterial recipeMaterial5 = recipeMaterials[4]; - decimal gfa2th = recipeMaterial5.materialWeight; - var writeResult21 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFA_2th, (float)gfa2th); - - - //通过配方编号获取工艺参数信息 - List recipeCratParams = Technical.PmtRecipe.RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, string.Empty); - - //混料速度1 - Base_RecipeCratParam base_RecipeCratParam1 = recipeCratParams.Where(x => x.paramName.Contains("混料速度1")).FirstOrDefault(); - int hlsd1 = int.Parse(base_RecipeCratParam1.paramValue); - var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd1, new object[] { hlsd1 }); - - //混料速度2 - Base_RecipeCratParam base_RecipeCratParam2 = recipeCratParams.Where(x => x.paramName.Contains("混料速度2")).FirstOrDefault(); - int hlsd2 = int.Parse(base_RecipeCratParam2.paramValue); - var writeResult5 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd2, new object[] { hlsd2 }); - - //混料速度3 - Base_RecipeCratParam base_RecipeCratParam3 = recipeCratParams.Where(x => x.paramName.Contains("混料速度3")).FirstOrDefault(); - int hlsd3 = int.Parse(base_RecipeCratParam3.paramValue); - var writeResult6 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd3, new object[] { hlsd3 }); - - //进料时间 - Base_RecipeCratParam base_RecipeCratParam4 = recipeCratParams.Where(x => x.paramName.Contains("进料时间")).FirstOrDefault(); - int jlsj = int.Parse(base_RecipeCratParam4.paramValue); - var writeResult7 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Jlsj, new object[] { jlsj }); - - //混料时间 - Base_RecipeCratParam base_RecipeCratParam5 = recipeCratParams.Where(x => x.paramName.Contains("混料时间")).FirstOrDefault(); - int hlsj = int.Parse(base_RecipeCratParam5.paramValue); - var writeResult8 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsj, new object[] { hlsj }); - - //VCC加料误差 - Base_RecipeCratParam base_RecipeCratParam6 = recipeCratParams.Where(x => x.paramName.Contains("罐A加料误差")).FirstOrDefault(); - decimal vccjlwc = decimal.Parse(base_RecipeCratParam6.paramValue); - var writeResult12 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJlWc, (float)vccjlwc ); - - //GFA加料误差 - Base_RecipeCratParam base_RecipeCratParam7 = recipeCratParams.Where(x => x.paramName.Contains("罐B加料误差")).FirstOrDefault(); - decimal gfajlwc = decimal.Parse(base_RecipeCratParam7.paramValue); - var writeResult13 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJlWc, (float)gfajlwc); - - //树脂加料误差 - Base_RecipeCratParam base_RecipeCratParam8 = recipeCratParams.Where(x => x.paramName.Contains("树脂加料误差")).FirstOrDefault(); - decimal szjlwc = decimal.Parse(base_RecipeCratParam8.paramValue); - var writeResult14 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJlWc, (float)szjlwc); - - //配方下传完成 - var writeResult15 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, new object[] { true }); - //计划下传成功后需要修改计划状态为执行中 - base_PlanInfo.plan_State = 1; - base_PlanInfo.plan_beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - - Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(base_PlanInfo); - - if (GHAutoDownloadPlan != null) - { - GHAutoDownloadPlan(sender, System.EventArgs.Empty); - } - - return true; - } - catch (Exception ex) - { - return false; - } - } + + #region 下传计划列表至PLC diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/InitDeviceParamInfo.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/InitDeviceParamInfo.cs index 974e272..c7d5f00 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/InitDeviceParamInfo.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/InitDeviceParamInfo.cs @@ -15,100 +15,7 @@ namespace Mesnac.Action.ChemicalWeighing.DeviceParamManage public static bool IsFirstRun = true; //是否首次运行 public void Run(RuntimeParameter runtime) { - base.RunIni(runtime); //必须要调用 - if(IsFirstRun) - { - IsFirstRun = false; - ICSharpCode.Core.LoggingService.Debug("设备参数管理-窗体初始化业务..."); - - DataKeyValue ConFeq = new DataKeyValue("ConFeq"); - BasePlcHelper.Instance.dataKeyValues.Add(ConFeq); - DataKeyValue FanDelay = new DataKeyValue("FanDelay"); - BasePlcHelper.Instance.dataKeyValues.Add(FanDelay); - DataKeyValue DisSpeed = new DataKeyValue("DisSpeed"); - BasePlcHelper.Instance.dataKeyValues.Add(DisSpeed); - DataKeyValue DisTime = new DataKeyValue("DisTime"); - BasePlcHelper.Instance.dataKeyValues.Add(DisTime); - - DataKeyValue JZJDisDelay = new DataKeyValue("JZJDisDelay"); - BasePlcHelper.Instance.dataKeyValues.Add(JZJDisDelay); - DataKeyValue VccHighFrq = new DataKeyValue("VccHighFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(VccHighFrq); - DataKeyValue VccMidFrq = new DataKeyValue("VccMidFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(VccMidFrq); - DataKeyValue VccLoeFrq = new DataKeyValue("VccLoeFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(VccLoeFrq); - DataKeyValue VccHighWei = new DataKeyValue("VccHighWei"); - BasePlcHelper.Instance.dataKeyValues.Add(VccHighWei); - DataKeyValue VccLowWei = new DataKeyValue("VccLowWei"); - BasePlcHelper.Instance.dataKeyValues.Add(VccLowWei); - DataKeyValue VccJogWei = new DataKeyValue("VccJogWei"); - BasePlcHelper.Instance.dataKeyValues.Add(VccJogWei); - DataKeyValue VccExcWei = new DataKeyValue("VccExcWei"); - BasePlcHelper.Instance.dataKeyValues.Add(VccExcWei); - DataKeyValue VccTimeout = new DataKeyValue("VccTimeout"); - BasePlcHelper.Instance.dataKeyValues.Add(VccTimeout); - - DataKeyValue VccHco = new DataKeyValue("VccHco"); - BasePlcHelper.Instance.dataKeyValues.Add(VccHco); - DataKeyValue GFAHighFrq = new DataKeyValue("GFAHighFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(GFAHighFrq); - DataKeyValue GFAMidFrq = new DataKeyValue("GFAMidFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(GFAMidFrq); - DataKeyValue GFALoeFrq = new DataKeyValue("GFALoeFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(GFALoeFrq); - - DataKeyValue GFAHighWei = new DataKeyValue("GFAHighWei"); - BasePlcHelper.Instance.dataKeyValues.Add(GFAHighWei); - DataKeyValue GFALowWei = new DataKeyValue("GFALowWei"); - BasePlcHelper.Instance.dataKeyValues.Add(GFALowWei); - - DataKeyValue GFAJogWei = new DataKeyValue("GFAJogWei"); - BasePlcHelper.Instance.dataKeyValues.Add(GFAJogWei); - - DataKeyValue GFAExcWei = new DataKeyValue("GFAExcWei"); - BasePlcHelper.Instance.dataKeyValues.Add(GFAExcWei); - DataKeyValue GFATimeout = new DataKeyValue("GFATimeout"); - BasePlcHelper.Instance.dataKeyValues.Add(GFATimeout); - - DataKeyValue GFAHco = new DataKeyValue("GFAHco"); - BasePlcHelper.Instance.dataKeyValues.Add(GFAHco); - - DataKeyValue ResinHighFrq = new DataKeyValue("ResinHighFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinHighFrq); - DataKeyValue ResinMidFrq = new DataKeyValue("ResinMidFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinMidFrq); - DataKeyValue ResinLoeFrq = new DataKeyValue("ResinLoeFrq"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinLoeFrq); - - DataKeyValue ResinHighWei = new DataKeyValue("ResinHighWei"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinHighWei); - DataKeyValue ResinLowWei = new DataKeyValue("ResinLowWei"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinLowWei); - - DataKeyValue ResinJogWei = new DataKeyValue("ResinJogWei"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinJogWei); - - DataKeyValue ResinExcWei = new DataKeyValue("ResinExcWei"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinExcWei); - DataKeyValue ResinTimeout = new DataKeyValue("ResinTimeout"); - BasePlcHelper.Instance.dataKeyValues.Add(ResinTimeout); - - - } - foreach (var item in BasePlcHelper.Instance.dataKeyValues) - { - if (item.Name == "VccHighWei" || item.Name == "VccLowWei" || item.Name == "VccJogWei" || item.Name == "VccExcWei" || item.Name == "GFAHighWei" || item.Name == "GFALowWei" || item.Name == "GFAJogWei" || item.Name == "GFAExcWei" || item.Name == "ResinHighWei" || item.Name == "ResinLowWei" || item.Name == "ResinJogWei" || item.Name == "ResinExcWei") - { - TextBox comboBox = base.GetControlById(item.Name) as TextBox; - comboBox.Text = item.NowValue.ToFloat().ToString(); - } - else - { - TextBox comboBox = base.GetControlById(item.Name) as TextBox; - comboBox.Text = item.NowValue.ToInt().ToString(); - } - } + } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/SelectDeviceParamInfo.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/SelectDeviceParamInfo.cs index 479cc18..cd69a02 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/SelectDeviceParamInfo.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/SelectDeviceParamInfo.cs @@ -16,19 +16,7 @@ namespace Mesnac.Action.ChemicalWeighing.DeviceParamManage { base.RunIni(runtime); //必须要调用 this._runtime = runtime; - foreach (var item in BasePlcHelper.Instance.dataKeyValues) - { - if (item.Name == "VccHighWei" || item.Name == "VccLowWei" || item.Name == "VccJogWei"|| item.Name == "VccExcWei" || item.Name == "GFAHighWei" || item.Name == "GFALowWei" || item.Name == "GFAJogWei" || item.Name == "GFAExcWei" || item.Name == "ResinHighWei" || item.Name == "ResinLowWei" || item.Name == "ResinJogWei" || item.Name == "ResinExcWei") - { - TextBox comboBox = base.GetControlById(item.Name) as TextBox; - comboBox.Text = item.NowValue.ToFloat().ToString(); - } - else - { - TextBox comboBox = base.GetControlById(item.Name) as TextBox; - comboBox.Text = item.NowValue.ToInt().ToString(); - } - } + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/WriteDeviceParamInfo.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/WriteDeviceParamInfo.cs index e73a579..f279e21 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/WriteDeviceParamInfo.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/DeviceParamManage/WriteDeviceParamInfo.cs @@ -15,21 +15,7 @@ namespace Mesnac.Action.ChemicalWeighing.DeviceParamManage try { base.RunIni(runtime); //必须要调用 - foreach (var item in BasePlcHelper.Instance.dataKeyValues) - { - if (item.Name == "VccHighWei" || item.Name == "VccLowWei" || item.Name == "VccJogWei" || item.Name == "VccExcWei" || item.Name == "GFAHighWei" || item.Name == "GFALowWei" || item.Name == "GFAJogWei" || item.Name == "GFAExcWei" || item.Name == "ResinHighWei" || item.Name == "ResinLowWei" || item.Name == "ResinJogWei" || item.Name == "ResinExcWei") - { - TextBox comboBox = base.GetControlById(item.Name) as TextBox; - decimal WriteValue = decimal.Parse(comboBox.Text); - var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(item, (float)WriteValue); - } - else - { - TextBox comboBox = base.GetControlById(item.Name) as TextBox; - int WriteValue = int.Parse(comboBox.Text); - var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(item, new object[] { WriteValue }); - } - } + MessageBox.Show("修改成功!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs index f01e98a..fc0a40a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs @@ -359,159 +359,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch } #endregion - #region 冠合存盘数据保存 - /// - /// 冠合存盘数据保存 - /// - public static void SaveGHData() - { - try - { - #region 存盘信号读取 - if (BasePlcHelper.Instance.GH_PC_ConfirmSDReady.NowValue.ToInt() == 1) - { - Entity.RecordSaveDataInfo recordSaveDataInfo = new Entity.RecordSaveDataInfo(); - bool PlanId = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SavePlanId, out int[] GH_PC_SavePlanId); - bool SaveCode = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveCode, out int[] GH_PC_SaveCode); - bool SaveFinishedNum = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveFinishedNum, out int[] GH_PC_SaveFinishedNum); - bool SaveRow = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveRow, out int[] GH_PC_SaveRow); - bool SaveCol = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveCol, out int[] GH_PC_SaveCol); - bool SaveVCCSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCCSet, out int[] GH_PC_SaveVCCSet); - bool SaveVCCAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCCAct, out int[] GH_PC_SaveVCCAct); - bool SaveGFASet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFASet, out int[] GH_PC_SaveGFASet); - bool SaveGFAAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFAAct, out int[] GH_PC_SaveGFAAct); - bool Save3thSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_Save3thSet, out int[] GH_PC_Save3thSet); - bool Save3thAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_Save3thAct, out int[] GH_PC_Save3thAct); - - bool SaveLevel = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveLevel, out int[] GH_PC_SaveLevel); - bool SaveFillTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveFillTime, out int[] GH_PC_SaveFillTime); - bool SaveSpeed1 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveSpeed1, out int[] GH_PC_SaveSpeed1); - bool SaveSpeed2 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveSpeed2, out int[] GH_PC_SaveSpeed2); - bool SaveTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveTime, out int[] GH_PC_SaveTime); - bool SaveVCC2thSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCC2thSet, out int[] GH_PC_SaveVCC2thSet); - bool SaveVCC2thAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCC2thAct, out int[] GH_PC_SaveVCC2thAct); - bool SaveGFA2thSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFA2thSet, out int[] GH_PC_SaveGFA2thSet); - bool SaveGFA2thAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFA2thAct, out int[] GH_PC_SaveGFA2thAct); - - recordSaveDataInfo.PlanId = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString(); - recordSaveDataInfo.SaveCode = GH_PC_SaveCode[0].ToString(); - recordSaveDataInfo.SaveFinishedNum = GH_PC_SaveFinishedNum[0]; - recordSaveDataInfo.SaveRow = GH_PC_SaveRow[0]; - recordSaveDataInfo.SaveCol = GH_PC_SaveCol[0]; - recordSaveDataInfo.SaveVCCSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCSet); - recordSaveDataInfo.SaveVCCAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCAct); - recordSaveDataInfo.SaveGFASet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFASet); - recordSaveDataInfo.SaveGFAAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFAAct); - recordSaveDataInfo.Save3thSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thSet); - recordSaveDataInfo.Save3thAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thAct); - recordSaveDataInfo.SaveLevel = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveLevel); - recordSaveDataInfo.SaveFillTime = GH_PC_SaveFillTime[0]; - recordSaveDataInfo.SaveSpeed1 = GH_PC_SaveSpeed1[0]; - recordSaveDataInfo.SaveSpeed2 = GH_PC_SaveSpeed2[0]; - recordSaveDataInfo.SaveTime = GH_PC_SaveTime[0]; - recordSaveDataInfo.RecordTime = DateTime.Now; - recordSaveDataInfo.SaveVCC2thSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCC2thSet); - recordSaveDataInfo.SaveVCC2thAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCC2thAct); - recordSaveDataInfo.SaveGFA2thSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFA2thSet); - recordSaveDataInfo.SaveGFA2thAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFA2thAct); - //将实体保存至数据库 - SaveHelper.LotSaveHelper.InsertGHSaveData(recordSaveDataInfo); - #region 物料称量结果 - try - { - List MaterInfolist = MaterialManage.MaterialHelper.getMaterialList(); - Entity.LR_weigh tempLRweigh1 = new Entity.LR_weigh(); - tempLRweigh1.Plan_id = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString(); - tempLRweigh1.Equip_Code = "01"; - tempLRweigh1.Weight_ID = 1; - tempLRweigh1.Serial_Num = GH_PC_SaveFinishedNum[0]; - tempLRweigh1.Batch_Number = GH_PC_SaveCol[0].ToString(); - //获取包含所有物料对象的集合 - tempLRweigh1.Material_Code = MaterInfolist[0].materialId; - tempLRweigh1.Real_Weight = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCAct); - tempLRweigh1.Real_Error = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCSet) - tempLRweigh1.Real_Weight; - tempLRweigh1.Waste_Time = GH_PC_SaveTime[0]; - tempLRweigh1.Weight_Time = DateTime.Now.ToString(); - tempLRweigh1.Recipe_code = GH_PC_SaveCode[0].ToString(); - SaveHelper.LotSaveHelper.InsertLRweighData(tempLRweigh1); - - Entity.LR_weigh tempLRweigh2 = new Entity.LR_weigh(); - tempLRweigh2.Plan_id = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString(); - tempLRweigh2.Equip_Code = "01"; - tempLRweigh1.Weight_ID = 2; - tempLRweigh2.Serial_Num = GH_PC_SaveFinishedNum[0]; - tempLRweigh2.Batch_Number = GH_PC_SaveCol[0].ToString(); - //获取包含所有物料对象的集合 - tempLRweigh2.Material_Code = MaterInfolist[1].materialId; - tempLRweigh2.Real_Weight = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFAAct); - tempLRweigh2.Real_Error = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFASet) - tempLRweigh1.Real_Weight; - tempLRweigh2.Waste_Time = GH_PC_SaveTime[0]; - tempLRweigh2.Weight_Time = DateTime.Now.ToString(); - tempLRweigh2.Recipe_code = GH_PC_SaveCode[0].ToString(); - SaveHelper.LotSaveHelper.InsertLRweighData(tempLRweigh2); - - Entity.LR_weigh tempLRweigh3 = new Entity.LR_weigh(); - tempLRweigh3.Plan_id = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString(); - tempLRweigh3.Equip_Code = "01"; - tempLRweigh1.Weight_ID = 3; - tempLRweigh3.Serial_Num = GH_PC_SaveFinishedNum[0]; - tempLRweigh3.Batch_Number = GH_PC_SaveCol[0].ToString(); - //获取包含所有物料对象的集合 - tempLRweigh3.Material_Code = MaterInfolist[2].materialId; - tempLRweigh3.Real_Weight = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thAct); - tempLRweigh3.Real_Error = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thSet) - tempLRweigh1.Real_Weight; - tempLRweigh3.Waste_Time = GH_PC_SaveTime[0]; - tempLRweigh3.Weight_Time = DateTime.Now.ToString(); - tempLRweigh3.Recipe_code = GH_PC_SaveCode[0].ToString(); - SaveHelper.LotSaveHelper.InsertLRweighData(tempLRweigh3); - } - catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error(String.Format("物料称量存盘异常:{1}", ex.Message), ex); - } - #endregion - - //存盘数据保存完成,写入反馈信号 - ICSharpCode.Core.LoggingService.Debug("数据存盘_PLC物料数据写入数据库处理完毕!"); - bool result = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpSaved, new object[] { 1 }); - - if (!result) - { - ICSharpCode.Core.LoggingService.Debug("数据存盘后写入反馈信号失败!"); - } - //将车次与计划表中的数量比对,更新计划数量中的完成数量 - if (recordSaveDataInfo.PlanId != "") - { - Product.PptPlan.entity.Base_PlanInfo planInfo = Product.PptPlan.PlanHelper.getPlanInfoByPlanId(recordSaveDataInfo.PlanId); - //不相等则更新计划中的完成数量 - planInfo.real_Amount = recordSaveDataInfo.SaveFinishedNum * recordSaveDataInfo.SaveCol; - planInfo.update_Time = DateTime.Now; - if (planInfo.plan_Amount != recordSaveDataInfo.SaveFinishedNum * recordSaveDataInfo.SaveCol) - { - Product.PptPlan.PlanHelper.UpdatePlanInfo(planInfo); - } - else //本次计划完成 - { - planInfo.plan_endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - planInfo.plan_State = 2; - Product.PptPlan.PlanHelper.UpdatePlanInfo(planInfo); - - } - if (GHOnUpdatePlanStateFromPlc != null) - { - GHOnUpdatePlanStateFromPlc(sender, System.EventArgs.Empty); - } - } - - } - #endregion - } - catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error(String.Format("生产数据存盘异常:{1}", ex.Message), ex); - } - } - #endregion + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs index bd020d1..d2a9449 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs @@ -52,165 +52,8 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch #endregion - #region 启动服务 + - public void Start() - { - try - { - if (this.runState) - { - return; - } - lock (String.Empty) - { - Mesnac.Equips.Factory.Instance.SetMinHZReadDataEvent(ReadData); - this.runState = true; - } - } - catch(Exception ex) - { - ICSharpCode.Core.LoggingService.Error("自动更新计划状态服务异常:" + ex.Message, ex); - } - } - - #endregion - - #region 停止服务 - - public void Stop() - { - try - { - if (!this.runState) - { - return; - } - lock (String.Empty) - { - ICSharpCode.Core.LoggingService.Debug("开始停止生产数据存盘服务..."); - Mesnac.Equips.Factory.Instance.ClearMinHZReadDataEvent(ReadData); - ICSharpCode.Core.LoggingService.Debug("停止生产数据存盘服务完毕!"); - this.runState = false; - } - - } - catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error("停止生产数据存盘业务服务异常:" + ex.Message, ex); - } - } - - #endregion - - #region 事件处理 - - private void ReadData(object sender, Mesnac.Equips.ReadEventArgs e) - { - try - { - lock(String.Empty) - { - - #region 0、实时刷新自动保存报警 - - SaveHelper.AlarmSaveHelper.Instance.Save(); - - #endregion - - #region 1、自动下传计划 - ChemicalWeighingPlc.PlcPlanHelper.GHDownloadPlanData(); - //List msgList = new List(); - //ChemicalWeighingPlc.PlcPlanHelper.AutoDownloadPlanData(msgList); - - #endregion - - #region 2、将等待计划数写入PLC - - //ChemicalWeighingPlc.PlcPlanHelper.WaitPlanNumToPLC(); - - #endregion - - #region 3、更新计划状态 - - //ChemicalWeighingPlc.PlcPlanHelper.UpdatePlanStateFromPlc(); - - #endregion - - #region 4、HMI配方列表请求处理 - - //ChemicalWeighingPlc.PlcRecipeHelper.DownloadRecipeNameListToPLC(); - - #endregion - - #region 5、HMI计划添加请求处理 - - //ChemicalWeighingPlc.PlcPlanHelper.AutoAddPlan(); - - #endregion - - #region 6、HMI计划修改请求处理 - - //ChemicalWeighingPlc.PlcPlanHelper.ChangePlan(); - - #endregion - - #region 7、自动存盘处理 - - //FinishBatchHelper.SaveGHData(); - - //ReportDryMixerSaveHelper.Instance.Save(); - ReportWetMixerSaveHelper.Instance.SaveWetMixerReport(); - //ReportGelDoserSaveHelper.Instance.SaveGelDoserReport(); - #endregion - - #region 8、更新物料名称 - - //ChemicalWeighingPlc.PlcPlanHelper.UpdateMaterialNameToPlc(); - - #endregion - - #region 9、修改PC心跳信号 - - //ChemicalWeighingPlc.PlcPlanHelper.HeartBeatChange(); - - #endregion - - #region 10、自动换班 - - ChemicalWeighingPlc.PlcPlanHelper.shiftIDAutoChange(); - - #endregion - } - - } - catch(Exception ex) - { - ICSharpCode.Core.LoggingService.Error(ex.Message, ex); - } - finally - { - #region 6、设置PCok信号为空闲 - - //#region 保存存盘 - - //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_MixWeight_PC_PCok, new object[] { 1 }, false); - //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_Mix_PC_PCok, new object[] { 1 }, false); - //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_MillWeight_PC_PCok, new object[] { 1 }, false); - //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_Mill_PC_PCok, new object[] { 1 }, false); - - //#endregion - - //#region 配方交互 - - //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.Mix_RecipeDL_PC_PCok, new object[] { 1 }, false); - - //#endregion - - #endregion - } - } - - #endregion + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs index 7ea2c3d..8f8e78a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs @@ -8,87 +8,6 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch { public class GHFinshBatchHelper { - #region 冠合项目存盘数据 - /// - /// 冠合项目数据存盘 - /// - public static void SaveData() - { - try - { - #region 存盘信号读取 - if (BasePlcHelper.Instance.GH_PC_ConfirmSDReady.NowValue.ToInt() == 1) - { - Entity.RecordSaveDataInfo recordSaveDataInfo = new Entity.RecordSaveDataInfo(); - bool PlanId = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SavePlanId, out int[] GH_PC_SavePlanId); - bool SaveCode = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveCode, out int[] GH_PC_SaveCode); - bool SaveFinishedNum = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveFinishedNum, out int[] GH_PC_SaveFinishedNum); - bool SaveRow = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveRow, out int[] GH_PC_SaveRow); - bool SaveCol = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveCol, out int[] GH_PC_SaveCol); - bool SaveVCCSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCCSet, out int[] GH_PC_SaveVCCSet); - bool SaveVCCAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveVCCAct, out int[] GH_PC_SaveVCCAct); - bool SaveGFASet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFASet, out int[] GH_PC_SaveGFASet); - bool SaveGFAAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveGFAAct, out int[] GH_PC_SaveGFAAct); - bool Save3thSet = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_Save3thSet, out int[] GH_PC_Save3thSet); - bool Save3thAct = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_Save3thAct, out int[] GH_PC_Save3thAct); - bool SaveLevel = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveLevel, out int[] GH_PC_SaveLevel); - bool SaveFillTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveFillTime, out int[] GH_PC_SaveFillTime); - bool SaveSpeed1 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveSpeed1, out int[] GH_PC_SaveSpeed1); - bool SaveSpeed2 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveSpeed2, out int[] GH_PC_SaveSpeed2); - bool SaveTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_SaveTime, out int[] GH_PC_SaveTime); - recordSaveDataInfo.PlanId = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString(); - recordSaveDataInfo.SaveCode = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SavePlanId).ToString(); - recordSaveDataInfo.SaveFinishedNum = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveFinishedNum); - recordSaveDataInfo.SaveRow = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveRow); - recordSaveDataInfo.SaveCol = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveCol); - recordSaveDataInfo.SaveVCCSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCSet); - recordSaveDataInfo.SaveVCCAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveVCCAct); - recordSaveDataInfo.SaveGFASet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveGFASet); - recordSaveDataInfo.Save3thSet = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thSet); - recordSaveDataInfo.Save3thAct = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_Save3thAct); - recordSaveDataInfo.SaveLevel = Mesnac.Basic.DataProcessor.ToSiemensFloat(GH_PC_SaveLevel); - recordSaveDataInfo.SaveFillTime = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveFillTime); - recordSaveDataInfo.SaveSpeed1 = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveSpeed1); - recordSaveDataInfo.SaveSpeed2 = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveSpeed2); - recordSaveDataInfo.SaveTime = Mesnac.Basic.DataProcessor.ToSiemensInt32(GH_PC_SaveTime); - recordSaveDataInfo.RecordTime = DateTime.Now; - //将实体保存至数据库 - SaveHelper.LotSaveHelper.InsertGHSaveData(recordSaveDataInfo); - //存盘数据保存完成,写入反馈信号 - ICSharpCode.Core.LoggingService.Debug("数据存盘_PLC物料数据写入数据库处理完毕!"); - bool result = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpSaved, new object[] { 1 }); - if (!result) - { - ICSharpCode.Core.LoggingService.Debug("数据存盘后写入反馈信号失败!"); - } - //将车次与计划表中的数量比对,更新计划数量中的完成数量 - if (recordSaveDataInfo.PlanId != "") - { - Product.PptPlan.entity.Base_PlanInfo planInfo = Product.PptPlan.PlanHelper.getPlanInfoByPlanId(recordSaveDataInfo.PlanId); - //不相等则更新计划中的完成数量 - planInfo.real_Amount = recordSaveDataInfo.SaveFinishedNum; - planInfo.update_Time = DateTime.Now; - if (planInfo.real_Amount != recordSaveDataInfo.SaveFinishedNum) - { - Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(planInfo); - } - else //本次计划完成 - { - planInfo.plan_endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - planInfo.plan_State = 2; - Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(planInfo); - } - } - - } - #endregion - } - catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error(String.Format("数据存盘异常:{1}", ex.Message), ex); - } - } - - #endregion + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs index 3b14ccd..1ad7725 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/PlanDownloadAction.cs @@ -60,39 +60,7 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan return; } } - if (BasePlcHelper.Instance.GH_PC_ConfirmOnline.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmRemote.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmReady.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmRun.NowValue.ToInt() == 0) - //if(true) - { - //获取当前选中计划 - Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(this.selectedPlanId); - - //调试时注释 - if (WriteRecipeInfoToPLC(planInfo)) - //if(true) - { - ICSharpCode.Core.LoggingService.Debug("{生产计划-计划下传} 计划下传成功..."); - planInfo.plan_State = 1; - planInfo.plan_beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - Product.PptPlan.PlanHelper.UpdateBasePlanStateInfo(planInfo); - - } - else - { - MessageBox.Show("计划下传失败!!!"); - } - #region 触发事件 - - if (DownloadPlan != null) - { - DownloadPlan(runtime.BaseControl.MCRoot, System.EventArgs.Empty); - } - #endregion - } - else - { - MessageBox.Show("下位机信号未准备好!!!"); - return; - } + //判断下位机准备好信号,正式调试时需取消注释 /*if (!(BasePlcHelper.Instance.GH_PC_ConfirmRemote.NowValue.ToInt() == 1 && BasePlcHelper.Instance.GH_PC_ConfirmReady.NowValue.ToInt() == 1)) { @@ -126,201 +94,17 @@ 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 = intArrayToStr(res); - - return readRecipeId; - } + /// /// 读取plc计划执行状态 /// public void readPlanState() { - while (true) - { - 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 finishAmount = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, out int[] res); - - bool planNoResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, out int[] planNo); - - bool confirmRunResult = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.GH_PC_ConfirmRun, out int[] confirmRun); - - string planNoStr = intArrayToStr(planNo) == "" ? "030aabf32dbe4f4e8f9eb8bb65b59b69" : intArrayToStr(planNo); - - if (planNoStr != "") - { - //根据计划编号修改计划状态、完成数量 - Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(planNoStr); - planInfo.real_Amount = Convert.ToInt32(intArrayToStr(res)); - - if (planInfo.plan_Amount == planInfo.real_Amount) - { - planInfo.plan_State = 2; - PlanHelper.UpdateBasePlanInfo(planInfo); - - //判断完成信号,正式环境需要判断完成状态 - /*if (confirmRun[1] == 1) - { - ICSharpCode.Core.LoggingService.Info("{生产计划-计划下传} 计划" + planNoStr + "执行完成..."); - //判断下一计划的运行方式 - Base_PlanInfo nextPlanInfo = PlanHelper.getNextPlanInfoByOrder(planInfo.plan_order); - - if (nextPlanInfo.run_Type == 0) - { - writeToPlc(nextPlanInfo.recipe_Id, nextPlanInfo.plan_Id); - } - else - { - return; - } - }*/ - - ICSharpCode.Core.LoggingService.Info("{生产计划-计划下传} 计划" + planNoStr + "执行完成..."); - //判断下一计划的运行方式 - Base_PlanInfo nextPlanInfo = PlanHelper.getNextPlanInfoByPlanOrder(planInfo.plan_order); - - if (nextPlanInfo.run_Type == 0) - { - writeToPlc(nextPlanInfo.recipe_Id, nextPlanInfo.plan_Id); - } - else - { - return; - } - - } - else - { - planInfo.plan_State = 1; - PlanHelper.UpdateBasePlanInfo(planInfo); - } - } - - Thread.Sleep(1000 * 3); - } + } - public static bool WriteRecipeInfoToPLC(Product.PptPlan.entity.Base_PlanInfo base_PlanInfo) - { - try - { - Base_RecipeInfo info = Technical.PmtRecipe.RecipeHelper.GetRecipeById(base_PlanInfo.recipe_Id); - //配方编号 - var plan_Id = Convert.ToInt32(base_PlanInfo.plan_Id); - - object[] recipeidArray = Mesnac.Basic.DataProcessor.ToSiemensPLCDataArray(plan_Id); - - //计划编号 - bool resultPlanNoPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, recipeidArray); - - //配方编号 - bool resultFromPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //配方名称,测试暂用配方编号代替 - bool writeResult = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeName, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //设定车数 - var writeResult1 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, new object[] { base_PlanInfo.car_Amount }); - //格数 - var writeResult2 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetGeNumber, new object[] { base_PlanInfo.grid_Amount }); - - //层数 - var writeResult3 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetLineNumber, new object[] { base_PlanInfo.line_Amount }); - - //通过配方编号获取物料信息、参数信息 - List recipeMaterials = Technical.PmtRecipe.RecipeHelper.GetRecipeMaterialInfoByRecipeId(info.recipeId); - - //罐1 - //VCC加料 - //Base_RecipeMaterial recipeMaterial = recipeMaterials.Where(x => x.materialName.Contains("VCC")).FirstOrDefault(); - Base_RecipeMaterial recipeMaterial = recipeMaterials[0]; - decimal vccJl = recipeMaterial.materialWeight; - var writeResult9 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJl, (float)vccJl); - //罐2 - ////GFA加料 - //Base_RecipeMaterial recipeMaterial2 = recipeMaterials.Where(x => x.materialName.Contains("GFA")).FirstOrDefault(); - Base_RecipeMaterial recipeMaterial2 = recipeMaterials[1]; - decimal gfajl = recipeMaterial2.materialWeight; - var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJl, (float)gfajl); - //罐3 - ////树脂加料 - //Base_RecipeMaterial recipeMaterial3 = recipeMaterials.Where(x => x.materialName.Contains("树脂")).FirstOrDefault(); - Base_RecipeMaterial recipeMaterial3 = recipeMaterials[2]; - decimal szjl = recipeMaterial3.materialWeight; - var writeResult11 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJl, (float)szjl); - - //罐A2次加料 - Base_RecipeMaterial recipeMaterial4 = recipeMaterials[3]; - decimal vcc2th = recipeMaterial4.materialWeight; - var writeResult20 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCC_2th, (float)vcc2th); - - //罐B2次加料 - Base_RecipeMaterial recipeMaterial5 = recipeMaterials[4]; - decimal gfa2th = recipeMaterial5.materialWeight; - var writeResult21 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFA_2th, (float)gfa2th); - - //通过配方编号获取工艺参数信息 - List recipeCratParams = Technical.PmtRecipe.RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, string.Empty); - - //混料速度1 - Base_RecipeCratParam base_RecipeCratParam1 = recipeCratParams.Where(x => x.paramName.Contains("混料速度1")).FirstOrDefault(); - int hlsd1 = int.Parse(base_RecipeCratParam1.paramValue); - var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd1, new object[] { hlsd1 }); - - //混料速度2 - Base_RecipeCratParam base_RecipeCratParam2 = recipeCratParams.Where(x => x.paramName.Contains("混料速度2")).FirstOrDefault(); - int hlsd2 = int.Parse(base_RecipeCratParam2.paramValue); - var writeResult5 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd2, new object[] { hlsd2 }); - - //混料速度3 - Base_RecipeCratParam base_RecipeCratParam3 = recipeCratParams.Where(x => x.paramName.Contains("混料速度3")).FirstOrDefault(); - int hlsd3 = int.Parse(base_RecipeCratParam3.paramValue); - var writeResult6 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd3, new object[] { hlsd3 }); - - //进料时间 - Base_RecipeCratParam base_RecipeCratParam4 = recipeCratParams.Where(x => x.paramName.Contains("进料时间")).FirstOrDefault(); - int jlsj = int.Parse(base_RecipeCratParam4.paramValue); - var writeResult7 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Jlsj, new object[] { jlsj }); - - //混料时间 - Base_RecipeCratParam base_RecipeCratParam5 = recipeCratParams.Where(x => x.paramName.Contains("混料时间")).FirstOrDefault(); - int hlsj = int.Parse(base_RecipeCratParam5.paramValue); - var writeResult8 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsj, new object[] { hlsj }); - - //VCC加料误差 - Base_RecipeCratParam base_RecipeCratParam6 = recipeCratParams.Where(x => x.paramName.Contains("罐A加料误差")).FirstOrDefault(); - decimal vccjlwc = decimal.Parse(base_RecipeCratParam6.paramValue); - var writeResult12 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJlWc, (float)vccjlwc); - - //GFA加料误差 - Base_RecipeCratParam base_RecipeCratParam7 = recipeCratParams.Where(x => x.paramName.Contains("罐B加料误差")).FirstOrDefault(); - decimal gfajlwc = decimal.Parse(base_RecipeCratParam7.paramValue); - var writeResult13 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJlWc, (float)gfajlwc); - - //树脂加料误差 - Base_RecipeCratParam base_RecipeCratParam8 = recipeCratParams.Where(x => x.paramName.Contains("树脂加料误差")).FirstOrDefault(); - decimal szjlwc = decimal.Parse(base_RecipeCratParam8.paramValue); - var writeResult14 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJlWc, (float)szjlwc); - - //配方下传完成 - bool SaveTime = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, out int[] GH_PC_SaveTime); - object[] flag = new object[1] {1}; - var writeResult15 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, flag); - - return true; - } - catch (Exception ex) - { - ICSharpCode.Core.LoggingService.Error("{生产计划-计划下传} 计划下传失败..."+ ex); - return false; - } - } + /// /// 将配方数据写入PLC地址 @@ -335,86 +119,7 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan //通过计划编号获取选中计划 Base_PlanInfo planInfo = PlanHelper.getPlanInfoByPlanId(planId); - #region 下传配方参数 - - //配方编号info.recipeId - - string recipeName = info.recipeName; - - var plan_Id = Convert.ToInt32(planId); - - object[] recipeidArray = Mesnac.Basic.DataProcessor.ToSiemensPLCDataArray(plan_Id); - - //计划编号 - bool resultPlanNoPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, new object[] { recipeidArray }); - - //配方编号 - bool resultFromPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, recipeidArray); - - //配方名称 - bool writeResult = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeName, recipeName); - - //设定车数 - var writeResult1 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, new object[] { planInfo.car_Amount }); - - //格数 - var writeResult2 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetGeNumber, new object[] { planInfo.grid_Amount }); - - //层数 - var writeResult3 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetLineNumber, new object[] { planInfo.line_Amount }); - - //通过配方编号获取物料信息、参数信息 - List recipeMaterials = RecipeHelper.GetRecipeMaterialInfoByRecipeId(info.recipeId); - - //混料速度1 - var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd1, new object[] { 18 }); - - //混料速度2 - var writeResult5 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd2, new object[] { 20 }); - - //混料速度3 - var writeResult6 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd3, new object[] { 22 }); - - //进料时间 - var writeResult13 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Jlsj, new object[] { 12 }); - - //混料时间 - var writeResult14 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsj, new object[] { 17 }); - - //VCC加料 - Base_RecipeMaterial recipeMaterial = recipeMaterials.Where(x => x.materialId.Contains("202205280001")).FirstOrDefault(); - decimal vccJl = recipeMaterial.materialWeight; - var writeResult7 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJl, (float)vccJl); - - ////VCC加料误差 - List recipeCratParams1 = RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, "202205280001"); - Base_RecipeCratParam recipeCratParam = recipeCratParams1.Where(x => x.materialId.Equals(recipeMaterial.materialId) && x.paramName.Contains("VCC加料误差")).FirstOrDefault(); - decimal vccjlwc = Convert.ToDecimal(recipeCratParam.paramValue); - var writeResult8 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJlWc, (float)vccjlwc); - - ////GFA加料 - Base_RecipeMaterial recipeMaterial2 = recipeMaterials.Where(x => x.materialId.Contains("202205280002")).FirstOrDefault(); - decimal gfajl = recipeMaterial2.materialWeight; - var writeResult9 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJl, (float)gfajl); - - ////GFA加料误差 - List recipeCratParams2 = RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, "202205280002"); - Base_RecipeCratParam recipeCratParam2 = recipeCratParams2.Where(x => x.materialId.Equals(recipeMaterial2.materialId) && x.paramName.Contains("GFA加料误差")).FirstOrDefault(); - decimal gfajlwc = Convert.ToDecimal(recipeCratParam2.paramValue); - var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJlWc, (float)gfajlwc); - - ////树脂加料 - Base_RecipeMaterial recipeMaterial3 = recipeMaterials.Where(x => x.materialId.Contains("202205280003")).FirstOrDefault(); - decimal szjl = recipeMaterial3.materialWeight; - var writeResult11 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJl, (float)szjl); - - ////树脂加料误差 - List recipeCratParams3 = RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, "202205280003"); - Base_RecipeCratParam recipeCratParam3 = recipeCratParams3.Where(x => x.materialId.Equals(recipeMaterial3.materialId) && x.paramName.Contains("树脂加料误差")).FirstOrDefault(); - decimal szjlwc = Convert.ToDecimal(recipeCratParam3.paramValue); - var writeResult12 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJlWc, (float)szjlwc); - - #endregion + } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ProductionBudgetAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ProductionBudgetAction.cs index 5505e84..90574e4 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ProductionBudgetAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ProductionBudgetAction.cs @@ -98,89 +98,7 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan object[] recipeidArray = Mesnac.Basic.DataProcessor.ToSiemensPLCDataArray(plan_Id); - - bool resultPlanNoPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, new object[] { recipeidArray }); - - - //配方编号 - bool resultFromPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //配方名称,测试暂用配方编号代替 - bool writeResult = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeName, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //设定车数 - var writeResult1 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, new object[] { base_PlanInfo.car_Amount }); - //格数 - var writeResult2 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetGeNumber, new object[] { base_PlanInfo.grid_Amount }); - - //层数 - var writeResult3 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetLineNumber, new object[] { base_PlanInfo.line_Amount }); - - //通过配方编号获取物料信息、参数信息 - List recipeMaterials = Technical.PmtRecipe.RecipeHelper.GetRecipeMaterialInfoByRecipeId(info.recipeId); - - //VCC加料 - Base_RecipeMaterial recipeMaterial = recipeMaterials.Where(x => x.materialName.Contains("VCC")).FirstOrDefault(); - decimal vccJl = recipeMaterial.materialWeight; - var writeResult9 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJl, (float)vccJl); - - ////GFA加料 - Base_RecipeMaterial recipeMaterial2 = recipeMaterials.Where(x => x.materialName.Contains("GFA")).FirstOrDefault(); - decimal gfajl = recipeMaterial2.materialWeight; - var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJl, (float)gfajl); - - ////树脂加料 - Base_RecipeMaterial recipeMaterial3 = recipeMaterials.Where(x => x.materialName.Contains("树脂")).FirstOrDefault(); - decimal szjl = recipeMaterial3.materialWeight; - var writeResult11 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJl, (float)szjl); - - //通过配方编号获取工艺参数信息 - List recipeCratParams = Technical.PmtRecipe.RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, string.Empty); - - //混料速度1 - Base_RecipeCratParam base_RecipeCratParam1 = recipeCratParams.Where(x => x.paramName.Contains("混料速度1")).FirstOrDefault(); - int hlsd1 = int.Parse(base_RecipeCratParam1.paramValue); - var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd1, new object[] { hlsd1 }); - - //混料速度2 - Base_RecipeCratParam base_RecipeCratParam2 = recipeCratParams.Where(x => x.paramName.Contains("混料速度2")).FirstOrDefault(); - int hlsd2 = int.Parse(base_RecipeCratParam2.paramValue); - var writeResult5 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd2, new object[] { hlsd2 }); - - //混料速度3 - Base_RecipeCratParam base_RecipeCratParam3 = recipeCratParams.Where(x => x.paramName.Contains("混料速度3")).FirstOrDefault(); - int hlsd3 = int.Parse(base_RecipeCratParam3.paramValue); - var writeResult6 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd3, new object[] { hlsd3 }); - - //进料时间 - Base_RecipeCratParam base_RecipeCratParam4 = recipeCratParams.Where(x => x.paramName.Contains("进料时间")).FirstOrDefault(); - int jlsj = int.Parse(base_RecipeCratParam4.paramValue); - var writeResult7 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Jlsj, new object[] { jlsj }); - - //混料时间 - Base_RecipeCratParam base_RecipeCratParam5 = recipeCratParams.Where(x => x.paramName.Contains("混料时间")).FirstOrDefault(); - int hlsj = int.Parse(base_RecipeCratParam5.paramValue); - var writeResult8 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsj, new object[] { hlsj }); - - //VCC加料误差 - Base_RecipeCratParam base_RecipeCratParam6 = recipeCratParams.Where(x => x.paramName.Contains("VCC加料误差")).FirstOrDefault(); - decimal vccjlwc = decimal.Parse(base_RecipeCratParam6.paramValue); - var writeResult12 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJlWc, (float)vccjlwc); - - //GFA加料误差 - Base_RecipeCratParam base_RecipeCratParam7 = recipeCratParams.Where(x => x.paramName.Contains("GFA加料误差")).FirstOrDefault(); - decimal gfajlwc = decimal.Parse(base_RecipeCratParam7.paramValue); - var writeResult13 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJlWc, (float)gfajlwc); - - //树脂加料误差 - Base_RecipeCratParam base_RecipeCratParam8 = recipeCratParams.Where(x => x.paramName.Contains("树脂加料误差")).FirstOrDefault(); - decimal szjlwc = decimal.Parse(base_RecipeCratParam8.paramValue); - var writeResult14 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJlWc, (float)szjlwc); - - //配方下传完成 - object[] flag = Mesnac.Basic.DataProcessor.ToPLCDataArray("1"); - - var writeResult15 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, flag); - //计划下传成功后需要修改计划状态为执行中 - + return true; } catch (Exception ex) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ReloadPlanInfo.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ReloadPlanInfo.cs index 0ebc61b..da59c60 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ReloadPlanInfo.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/ReloadPlanInfo.cs @@ -89,83 +89,6 @@ namespace Mesnac.Action.ChemicalWeighing.Product { recipeidArray[i] = base_PlanInfo.plan_Id.Substring(i, 1); } - bool resultPlanNoPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_PlanNo, new object[] { recipeidArray }); - //配方编号 - bool resultFromPlc = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeCode, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //配方名称,测试暂用配方编号代替 - bool writeResult = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RecipeName, new object[] { int.Parse(base_PlanInfo.recipe_Id) }); - //设定车数 - var writeResult1 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetCarNumber, new object[] { base_PlanInfo.car_Amount }); - //格数 - var writeResult2 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetGeNumber, new object[] { base_PlanInfo.grid_Amount }); - - //层数 - var writeResult3 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SetLineNumber, new object[] { base_PlanInfo.line_Amount }); - - //通过配方编号获取物料信息、参数信息 - List recipeMaterials = Technical.PmtRecipe.RecipeHelper.GetRecipeMaterialInfoByRecipeId(info.recipeId); - - //VCC加料 - Base_RecipeMaterial recipeMaterial = recipeMaterials.Where(x => x.materialName.Contains("VCC")).FirstOrDefault(); - decimal vccJl = recipeMaterial.materialWeight; - var writeResult9 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJl, (float)vccJl); - - ////GFA加料 - Base_RecipeMaterial recipeMaterial2 = recipeMaterials.Where(x => x.materialName.Contains("GFA")).FirstOrDefault(); - decimal gfajl = recipeMaterial2.materialWeight; - var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJl, (float)gfajl); - - ////树脂加料 - Base_RecipeMaterial recipeMaterial3 = recipeMaterials.Where(x => x.materialName.Contains("树脂")).FirstOrDefault(); - decimal szjl = recipeMaterial3.materialWeight; - var writeResult11 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJl, (float)szjl); - - //通过配方编号获取工艺参数信息 - List recipeCratParams = Technical.PmtRecipe.RecipeHelper.GerCratParamListByRecipeAndMaterial(info.recipeId, string.Empty); - - //混料速度1 - Base_RecipeCratParam base_RecipeCratParam1 = recipeCratParams.Where(x => x.paramName.Contains("混料速度1")).FirstOrDefault(); - int hlsd1 = int.Parse(base_RecipeCratParam1.paramValue); - var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd1, new object[] { hlsd1 }); - - //混料速度2 - Base_RecipeCratParam base_RecipeCratParam2 = recipeCratParams.Where(x => x.paramName.Contains("混料速度2")).FirstOrDefault(); - int hlsd2 = int.Parse(base_RecipeCratParam2.paramValue); - var writeResult5 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd2, new object[] { hlsd2 }); - - //混料速度3 - Base_RecipeCratParam base_RecipeCratParam3 = recipeCratParams.Where(x => x.paramName.Contains("混料速度3")).FirstOrDefault(); - int hlsd3 = int.Parse(base_RecipeCratParam3.paramValue); - var writeResult6 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsd3, new object[] { hlsd3 }); - - //进料时间 - Base_RecipeCratParam base_RecipeCratParam4 = recipeCratParams.Where(x => x.paramName.Contains("进料时间")).FirstOrDefault(); - int jlsj = int.Parse(base_RecipeCratParam4.paramValue); - var writeResult7 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Jlsj, new object[] { jlsj }); - - //混料时间 - Base_RecipeCratParam base_RecipeCratParam5 = recipeCratParams.Where(x => x.paramName.Contains("混料时间")).FirstOrDefault(); - int hlsj = int.Parse(base_RecipeCratParam5.paramValue); - var writeResult8 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_Hlsj, new object[] { hlsj }); - - //VCC加料误差 - Base_RecipeCratParam base_RecipeCratParam6 = recipeCratParams.Where(x => x.paramName.Contains("VCC加料误差")).FirstOrDefault(); - decimal vccjlwc = decimal.Parse(base_RecipeCratParam6.paramValue); - var writeResult12 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_VCCJlWc, (float)vccjlwc); - - //GFA加料误差 - Base_RecipeCratParam base_RecipeCratParam7 = recipeCratParams.Where(x => x.paramName.Contains("GFA加料误差")).FirstOrDefault(); - decimal gfajlwc = decimal.Parse(base_RecipeCratParam7.paramValue); - var writeResult13 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_GFAJlWc, (float)gfajlwc); - - //树脂加料误差 - Base_RecipeCratParam base_RecipeCratParam8 = recipeCratParams.Where(x => x.paramName.Contains("树脂加料误差")).FirstOrDefault(); - decimal szjlwc = decimal.Parse(base_RecipeCratParam8.paramValue); - var writeResult14 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_SZJlWc, (float)szjlwc); - - //配方下传完成 - var writeResult15 = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpFinished, new object[] { true }); - //计划下传成功后需要修改计划状态为执行中 return true; } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/StopAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/StopAction.cs index fa85128..e0da90a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/StopAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Product/PptPlan/StopAction.cs @@ -209,7 +209,7 @@ namespace Mesnac.Action.ChemicalWeighing.Product.PptPlan #endregion //下传终止信号 - bool writeRpCancel = BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ChemicalWeighing_PC_RpCancel, new object[] { 1 }); + bool writeRpCancel = false; if (writeRpCancel) { diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Sys/SystemInitAutoAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Sys/SystemInitAutoAction.cs index 52f7420..657bf05 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Sys/SystemInitAutoAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Sys/SystemInitAutoAction.cs @@ -66,7 +66,7 @@ namespace Mesnac.Action.ChemicalWeighing.Sys //SetDateTimeFormat(); //首次运行启动更新计划状态和自动下传计划服务 - FinishBatch.FinishBatchService.Instance.Start(); + // FinishBatch.FinishBatchService.Instance.Start(); //首次运行时启动定时器运行服务,其中包含Socket通讯连接 Sys.TimerRunService.Instance.Start(); @@ -81,7 +81,7 @@ namespace Mesnac.Action.ChemicalWeighing.Sys protected void Workbench_ShutDown(object sender, EventArgs e) { - FinishBatch.FinishBatchService.Instance.Stop(); //停止生产记录存盘服务 + // FinishBatch.FinishBatchService.Instance.Stop(); //停止生产记录存盘服务 Sys.TimerRunService.Instance.Stop(); }