using DataBlockHelper.DBHelpers; using DataBlockHelper.Entity.DB2104Entity; using Mesnac.Action.ChemicalWeighing.AutoControl.DB; using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; using Mesnac.Action.ChemicalWeighing.LjMixManager; using Mesnac.Action.ChemicalWeighing.LjPlanning; using Mesnac.Action.ChemicalWeighing.MinAn; using Mesnac.Controls.Default; using Mesnac.Core.Service; using System; using System.Collections.Generic; using System.Windows.Forms; using static Mesnac.Action.ChemicalWeighing.AutoControl.AutoLogHelper; namespace Mesnac.Action.ChemicalWeighing.AutoControl { public static class PlcAutoWriteHelper { /// /// 干混公差控制 /// private static int TFlag = 0; #region 湿混糊化下传 public static void GelWetDownload(MCTextBoxEntity TextE, MCComboBoxEntity ComboE, MCRadioButtonEntity RadioE) { int b1 = Convert.ToInt32(ComboE.ChooseMaterial1.MCValue.ToString()); int b2 = Convert.ToInt32(ComboE.ChooseMaterial2.MCValue.ToString()); short bin1 = (short)StockMaterrialDbHelp.GetCodeById(b1); short bin2 = (short)StockMaterrialDbHelp.GetCodeById(b2); float MatTol1 = Convert.ToSingle(TextE.MaterialTolerance1.MCValue.ToString()); float MatTol2 = Convert.ToSingle(TextE.MaterialTolerance2.MCValue.ToString()); float MatWei1 = Convert.ToSingle(TextE.MaterialWeight1.MCValue.ToString()); float MatWei2 = Convert.ToSingle(TextE.MaterialWeight2.MCValue.ToString()); float GelSpeed = Convert.ToSingle(TextE.GelSpeedSet.MCValue.ToString()); float GelPosA = Convert.ToSingle(TextE.GelPosTimeA.MCValue.ToString()); float GelNagB = Convert.ToSingle(TextE.GelNagTimeB.MCValue.ToString()); short GelPosC = Convert.ToInt16(TextE.GelPosTimeC.MCValue.ToString()); short GelWater = Convert.ToInt16(TextE.GelWaterTime.MCValue.ToString()); short GelWait = Convert.ToInt16(TextE.GelWaitTime.MCValue.ToString()); short GelCloseHeat = Convert.ToInt16(TextE.GelCloseHeatTime.MCValue.ToString()); float GelDelayTime = Convert.ToSingle(TextE.GelOutDelayTime.MCValue.ToString()); if (b2 == -1) { if (MatTol1 < 0.1) { MessageBox.Show("公差不能小于0.1!"); return; } } else { if (MatTol1 < 0.1 || MatTol2 < 0.1) { MessageBox.Show("公差不能小于0.1!"); return; } } if(GelSpeed > 50) { MessageBox.Show("速度不能大于五十!"); return; } List recipes = new List(); RecipePlcView recipe1 = new RecipePlcView() { Bin = bin1, Set = MatWei1, Tolerance = MatTol1, }; RecipePlcView recipe2 = new RecipePlcView() { Bin = bin2, Set = MatWei2, Tolerance = MatTol2, }; recipes.Add(recipe1); recipes.Add(recipe2); List steps = new List(); Step step1 = new Step() { MixCode = 1, MixSpeed = GelSpeed }; Step step2 = new Step() { MixCode = 2, }; Step step3 = new Step() { MixCode = 3, MixTime = GelPosC, MixTemp = GelPosA, MixSpeed = GelNagB }; Step step4 = new Step() { MixCode = 4, }; Step step5 = new Step() { MixCode = 5, MixTime = GelWater }; Step step6 = new Step() { MixCode = 6, }; Step step7 = new Step() { MixCode = 5, MixTime = GelWait }; Step step8 = new Step() { MixCode = 7, MixTime = GelCloseHeat, MixTemp = GelDelayTime }; Step step9 = new Step(); steps.Add(step1); steps.Add(step2); steps.Add(step3); steps.Add(step4); steps.Add(step5); steps.Add(step6); steps.Add(step7); steps.Add(step8); steps.Add(step9); steps.Add(step9); float WetDryWei = Convert.ToSingle(TextE.WetDryWeight.MCValue.ToString()); short WetMix = Convert.ToInt16(TextE.WetMixTime.MCValue.ToString()); short WetOutDelay = Convert.ToInt16(TextE.WetOutDelayTime.MCValue.ToString()); List mixSteps = new List(); MixStep mixStep1 = new MixStep() { MixCode = 1, }; MixStep mixStep2 = new MixStep() { MixCode = 2, SetValue = WetDryWei }; MixStep mixStep3 = new MixStep() { MixCode = 3, MixTime = WetMix }; MixStep mixStep4 = new MixStep() { MixCode = 4, }; MixStep mixStep5 = new MixStep() { MixCode = 5, MixTime = WetOutDelay }; MixStep mixStep6 = new MixStep(); mixSteps.Add(mixStep1); mixSteps.Add(mixStep2); mixSteps.Add(mixStep3); mixSteps.Add(mixStep4); mixSteps.Add(mixStep5); mixSteps.Add(mixStep6); mixSteps.Add(mixStep6); mixSteps.Add(mixStep6); mixSteps.Add(mixStep6); mixSteps.Add(mixStep6); List materials = new List(); DeviceMaterrial deviceMaterial1 = new DeviceMaterrial() { DeviceId = ControlsHelper.SingleSelect(RadioE), MaterrialId = b1, Type = 2, Code = StockMaterrialDbHelp.GetCodeById(b1) }; DeviceMaterrial deviceMaterial2 = new DeviceMaterrial() { DeviceId = ControlsHelper.SingleSelect(RadioE), MaterrialId = b2, Type = 2, Code = StockMaterrialDbHelp.GetCodeById(b2) }; materials.Add(deviceMaterial1); materials.Add(deviceMaterial2); switch (ControlsHelper.SingleSelect(RadioE)) { case 1: LjPlanningPlcHelp.DownG1Recipe(recipes, steps); LjPlanningPlcHelp.DownM1Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 2: LjPlanningPlcHelp.DownG2Recipe(recipes, steps); LjPlanningPlcHelp.DownM2Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 3: LjPlanningPlcHelp.DownG3Recipe(recipes, steps); LjPlanningPlcHelp.DownM3Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 4: LjPlanningPlcHelp.DownG4Recipe(recipes, steps); LjPlanningPlcHelp.DownM4Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 5: LjPlanningPlcHelp.DownG5Recipe(recipes, steps); LjPlanningPlcHelp.DownM5Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 6: LjPlanningPlcHelp.DownG6Recipe(recipes, steps); LjPlanningPlcHelp.DownM6Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 7: LjPlanningPlcHelp.DownG7Recipe(recipes, steps); LjPlanningPlcHelp.DownM7Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; case 8: LjPlanningPlcHelp.DownG8Recipe(recipes, steps); LjPlanningPlcHelp.DownM8Recipe(mixSteps); DeviceMaterrialService.Save(materials); break; default: MessageBox.Show("请选择一条产线!"); return; } GWlog(recipes, steps, mixSteps, RadioE); //if (!GWComparePLC(recipes, steps, mixSteps, RadioE)) //{ // MessageBox.Show("湿混糊化产线下传数据不完整,请重新下传数据!"); //} MessageBox.Show("数据下传成功!"); } private static bool GWComparePLC(List recipes, List steps, List mixSteps, MCRadioButtonEntity RadioE) { var getGelatG1 = LjPlanningPlcHelp.GetGelatG1; var getWeterM1 = LjPlanningPlcHelp.GetWeterM1; var getGelatG2 = LjPlanningPlcHelp.GetGelatG2; var getWeterM2 = LjPlanningPlcHelp.GetWeterM2; var getGelatG3 = LjPlanningPlcHelp.GetGelatG3; var getWeterM3 = LjPlanningPlcHelp.GetWeterM3; var getGelatG4 = LjPlanningPlcHelp.GetGelatG4; var getWeterM4 = LjPlanningPlcHelp.GetWeterM4; var getGelatG5 = LjPlanningPlcHelp.GetGelatG5; var getWeterM5 = LjPlanningPlcHelp.GetWeterM5; var getGelatG6 = LjPlanningPlcHelp.GetGelatG6; var getWeterM6 = LjPlanningPlcHelp.GetWeterM6; var getGelatG7 = LjPlanningPlcHelp.GetGelatG7; var getWeterM7 = LjPlanningPlcHelp.GetWeterM7; var getGelatG8 = LjPlanningPlcHelp.GetGelatG8; var getWeterM8 = LjPlanningPlcHelp.GetWeterM8; string j1 = ControlsHelper.JsonSerialize(recipes); string j2 = ControlsHelper.JsonSerialize(steps); string j3 = ControlsHelper.JsonSerialize(mixSteps); switch (ControlsHelper.SingleSelect(RadioE)) { case 1: return j1 == ControlsHelper.JsonSerialize(getGelatG1.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG1.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM1); case 2: return j1 == ControlsHelper.JsonSerialize(getGelatG2.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG2.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM2); case 3: return j1 == ControlsHelper.JsonSerialize(getGelatG3.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG3.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM3); case 4: return j1 == ControlsHelper.JsonSerialize(getGelatG4.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG4.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM4); case 5: return j1 == ControlsHelper.JsonSerialize(getGelatG5.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG5.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM5); case 6: return j1 == ControlsHelper.JsonSerialize(getGelatG6.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG6.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM6); case 7: return j1 == ControlsHelper.JsonSerialize(getGelatG7.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG7.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM7); case 8: return j1 == ControlsHelper.JsonSerialize(getGelatG8.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getGelatG8.RecipeSteps) && j3 == ControlsHelper.JsonSerialize(getWeterM8); default: MessageBox.Show("未选择产线!"); return true; } } #endregion #region 干混下传 public static void DryDownload(MCTextBoxEntity TextE, MCComboBoxEntity ComboE, MCRadioButtonEntity RadioE) { List recipes = new List(); List steps = new List(); List materials = new List(); DryerGetValue(ComboE.DryM1, TextE.DryW1, TextE.DryT1, recipes, materials, RadioE); DryerGetValue(ComboE.DryM2, TextE.DryW2, TextE.DryT2, recipes, materials, RadioE); DryerGetValue(ComboE.DryM3, TextE.DryW3, TextE.DryT3, recipes, materials, RadioE); DryerGetValue(ComboE.DryM4, TextE.DryW4, TextE.DryT4, recipes, materials, RadioE); DryerGetValue(ComboE.DryM5, TextE.DryW5, TextE.DryT5, recipes, materials, RadioE); DryerGetValue(ComboE.DryM6, TextE.DryW6, TextE.DryT6, recipes, materials, RadioE); DryerGetValue(ComboE.DryM7, TextE.DryW7, TextE.DryT7, recipes, materials, RadioE); DryerGetValue(ComboE.DryM8, TextE.DryW8, TextE.DryT8, recipes, materials, RadioE); DryerGetValue(ComboE.DryM9, TextE.DryW9, TextE.DryT9, recipes, materials, RadioE); DryerGetValue(ComboE.DryM10, TextE.DryW10, TextE.DryT10, recipes, materials, RadioE); DryerGetValue(ComboE.DryM11, TextE.DryW11, TextE.DryT11, recipes, materials, RadioE); DryerGetValue(ComboE.DryM12, TextE.DryW12, TextE.DryT12, recipes, materials, RadioE); if (TFlag == 1) { MessageBox.Show("公差不能小于0.1!"); TFlag = 0; return; } short dryWaitTime = Convert.ToInt16(TextE.DryWaitTime.MCValue.ToString()); short dryOutDelayTime = Convert.ToInt16(TextE.DryOutDelayTime.MCValue.ToString()); float drySpeed1 = Convert.ToSingle(TextE.DrySpeed1.MCValue.ToString()); float drySpeed2 = Convert.ToSingle(TextE.DrySpeed2.MCValue.ToString()); float drySpeed3 = Convert.ToSingle(TextE.DrySpeed3.MCValue.ToString()); if (drySpeed1 > 50 || drySpeed2 > 50 || drySpeed3 > 50) { MessageBox.Show("速度值不能大于五十!"); return; } Step dryStep1 = new Step() { MixCode = 1, MixSpeed = drySpeed1, }; Step dryStep2 = new Step() { MixCode = 4, MixTime = dryWaitTime, MixSpeed = drySpeed2, }; Step dryStep3 = new Step() { MixCode = 6, MixTime = dryOutDelayTime, MixSpeed = drySpeed3, }; Step dryStep = new Step(); steps.Add(dryStep1); steps.Add(dryStep2); steps.Add(dryStep3); steps.Add(dryStep); steps.Add(dryStep); steps.Add(dryStep); steps.Add(dryStep); steps.Add(dryStep); steps.Add(dryStep); steps.Add(dryStep); switch (ControlsHelper.DrySelect(RadioE)) { case 1: LjPlanningPlcHelp.DownD1Recipe(recipes, steps); DeviceMaterrialService.Save(materials); break; case 2: LjPlanningPlcHelp.DownD2Recipe(recipes, steps); DeviceMaterrialService.Save(materials); break; case 3: LjPlanningPlcHelp.DownD3Recipe(recipes, steps); DeviceMaterrialService.Save(materials); break; case 4: LjPlanningPlcHelp.DownD4Recipe(recipes, steps); DeviceMaterrialService.Save(materials); break; } //if (!DYComparePLC(recipes, steps, RadioE)) //{ // MessageBox.Show("干混产线下传数据不完整,请重新下传数据!"); //} MessageBox.Show("数据下传成功!"); } private static bool DYComparePLC(List recipes, List steps, MCRadioButtonEntity RadioE) { var getDryerD1 = LjPlanningPlcHelp.GetDryerD1; var getDryerD2 = LjPlanningPlcHelp.GetDryerD2; var getDryerD3 = LjPlanningPlcHelp.GetDryerD3; var getDryerD4 = LjPlanningPlcHelp.GetDryerD4; string j1 = ControlsHelper.JsonSerialize(recipes); string j2 = ControlsHelper.JsonSerialize(steps); switch (ControlsHelper.DrySelect(RadioE)) { case 1: return j1 == ControlsHelper.JsonSerialize(getDryerD1.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getDryerD1.RecipeSteps); case 2: return j1 == ControlsHelper.JsonSerialize(getDryerD2.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getDryerD2.RecipeSteps); case 3: return j1 == ControlsHelper.JsonSerialize(getDryerD3.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getDryerD3.RecipeSteps); case 4: return j1 == ControlsHelper.JsonSerialize(getDryerD4.RecipePlcViews) && j2 == ControlsHelper.JsonSerialize(getDryerD4.RecipeSteps); default: MessageBox.Show("未选择产线!"); return true; } } #endregion #region 水称下传 public static void WaterDownload(MCTextBoxEntity TextE, MCComboBoxEntity ComboE) { WaterEntity HotA = new WaterEntity(); WaterEntity ColdA = new WaterEntity(); WaterEntity HotB = new WaterEntity(); WaterEntity ColdB = new WaterEntity(); float hotASet, hotBSet, coldASet, coldBSet, hotATol, hotBTol, coldATol, coldBTol; float cADeviation; ushort cALeftOrRight; float hADeviation; ushort hALeftOrRight; float cBDeviation; ushort cBLeftOrRight; float hBDeviation; ushort hBLeftOrRight; if (float.TryParse(Convert.ToString(TextE.HotValueA.MCValue), out hotASet) && float.TryParse(Convert.ToString(TextE.HotToleranceA.MCValue), out hotATol) && float.TryParse(Convert.ToString(TextE.HotValueB.MCValue), out hotBSet) && float.TryParse(Convert.ToString(TextE.HotToleranceB.MCValue), out hotBTol) && float.TryParse(Convert.ToString(TextE.ColdValueA.MCValue), out coldASet) && float.TryParse(Convert.ToString(TextE.ColdToleranceA.MCValue), out coldATol) && float.TryParse(Convert.ToString(TextE.ColdValueB.MCValue), out coldBSet) && float.TryParse(Convert.ToString(TextE.ColdToleranceB.MCValue), out coldBTol) && float.TryParse(Convert.ToString(TextE.CADeviation.MCValue), out cADeviation) && float.TryParse(Convert.ToString(TextE.HADeviation.MCValue), out hADeviation) && float.TryParse(Convert.ToString(TextE.CBDeviation.MCValue), out cBDeviation) && float.TryParse(Convert.ToString(TextE.HBDeviation.MCValue), out hBDeviation) ) { HotA.Set = hotASet; HotB.Set = hotBSet; ColdA.Set = coldASet; ColdB.Set = coldBSet; HotA.Tolerance = hotATol; HotB.Tolerance = hotBTol; ColdA.Tolerance = coldATol; ColdB.Tolerance = coldBTol; HotA.differ = hADeviation; HotB.differ = hBDeviation; ColdA.differ = cADeviation; ColdB.differ= cBDeviation; HotA.stand = Convert.ToInt16(ComboE.HALeftOrRight.MCValue); HotB.stand = Convert.ToInt16(ComboE.HBLeftOrRight.MCValue); ColdA.stand = Convert.ToInt16(ComboE.CALeftOrRight.MCValue); ColdB.stand = Convert.ToInt16(ComboE.CBLeftOrRight.MCValue); Db2104WriteHelper.WriteAHostWater(HotA); Db2104WriteHelper.WriteBHostWater(HotB); Db2104WriteHelper.WriteAColWater(ColdA); Db2104WriteHelper.WriteBColWater(ColdB); MesnacServiceManager.Instance.LoggingService.Info("水称数据下发成功!"); MessageBox.Show("水称数据下发成功"); } else { MesnacServiceManager.Instance.LoggingService.Info("输入数值的格式有误"); MessageBox.Show("输入数值的格式有误!"); return; } } #endregion #region 手动控制 #region 糊化锅手动下粉料 public static bool GelPowderDownload(MCRadioButtonEntity RadioE) { bool isReady; switch (ControlsHelper.SingleSelect(RadioE)) { case 1: isReady = DB2105WriteHelper.WriteG1Pd(); break; case 2: isReady = DB2105WriteHelper.WriteG2Pd(); break; case 3: isReady = DB2105WriteHelper.WriteG3Pd(); break; case 4: isReady = DB2105WriteHelper.WriteG4Pd(); break; case 5: isReady = DB2105WriteHelper.WriteG5Pd(); break; case 6: isReady = DB2105WriteHelper.WriteG6Pd(); break; case 7: isReady = DB2105WriteHelper.WriteG7Pd(); break; case 8: isReady = DB2105WriteHelper.WriteG8Pd(); break; default: isReady = false; MessageBox.Show("当前未选择产线!"); break; } return isReady; } #endregion #region 糊化锅手动加冷水 public static bool GelColdWaterDownload(MCRadioButtonEntity RadioE) { bool isReady; switch (ControlsHelper.SingleSelect(RadioE)) { case 1: isReady = DB2105WriteHelper.WriteG1Cw(); break; case 2: isReady = DB2105WriteHelper.WriteG2Cw(); break; case 3: isReady = DB2105WriteHelper.WriteG3Cw(); break; case 4: isReady = DB2105WriteHelper.WriteG4Cw(); break; case 5: isReady = DB2105WriteHelper.WriteG5Cw(); break; case 6: isReady = DB2105WriteHelper.WriteG6Cw(); break; case 7: isReady = DB2105WriteHelper.WriteG7Cw(); break; case 8: isReady = DB2105WriteHelper.WriteG8Cw(); break; default: isReady = false; MessageBox.Show("当前未选择产线!"); break; } return isReady; } #endregion #region 糊化锅手动加热水 public static bool GelHotWaterDownload(MCRadioButtonEntity RadioE) { bool isReady; switch (ControlsHelper.SingleSelect(RadioE)) { case 1: isReady = DB2105WriteHelper.WriteG1Hw(); break; case 2: isReady = DB2105WriteHelper.WriteG2Hw(); break; case 3: isReady = DB2105WriteHelper.WriteG3Hw(); break; case 4: isReady = DB2105WriteHelper.WriteG4Hw(); break; case 5: isReady = DB2105WriteHelper.WriteG5Hw(); break; case 6: isReady = DB2105WriteHelper.WriteG6Hw(); break; case 7: isReady = DB2105WriteHelper.WriteG7Hw(); break; case 8: isReady = DB2105WriteHelper.WriteG8Hw(); break; default: isReady = false; MessageBox.Show("当前未选择产线!"); break; } return isReady; } #endregion #region 湿混机手动下糊化料 public static bool WetGelatDownload(MCRadioButtonEntity RadioE) { bool isReady; switch (ControlsHelper.SingleSelect(RadioE)) { case 1: isReady = DB2105WriteHelper.WriteM1(); break; case 2: isReady = DB2105WriteHelper.WriteM2(); break; case 3: isReady = DB2105WriteHelper.WriteM3(); break; case 4: isReady = DB2105WriteHelper.WriteM4(); break; case 5: isReady = DB2105WriteHelper.WriteM5(); break; case 6: isReady = DB2105WriteHelper.WriteM6(); break; case 7: isReady = DB2105WriteHelper.WriteM7(); break; case 8: isReady = DB2105WriteHelper.WriteM8(); break; default: isReady = false; MessageBox.Show("当前未选择产线!"); break; } return isReady; } #endregion #region 湿混机手动下粉料 public static bool WetGelatDownload(MCTextBoxEntity TextE, MCRadioButtonEntity RadioE) { float t = Convert.ToSingle(TextE.ManualTolerance.MCValue.ToString()); float w = Convert.ToSingle(TextE.ManualWeight.MCValue.ToString()); if (t < 0.1) { MessageBox.Show("公差不能小于0.1!"); return false; } SetValue value = new SetValue() { Value = w, Toterance = t }; DB2105Helper dB2105= new DB2105Helper(); bool run = false; var singE = ControlsHelper.SingleSelect(RadioE); if (run == false) { switch (singE) { case 1: PowderDownSignel(MinAnPlc.Heir1, 1); DB2105WriteHelper.WriteSetValueL1(value); DB2105WriteHelper.WriteHNo(1, "L", true); // DB2105WriteHelper.WriteManScrewH1(); break; case 2: PowderDownSignel(MinAnPlc.Heir1, 1); DB2105WriteHelper.WriteSetValueR1(value); DB2105WriteHelper.WriteHNo(1, "R", true); // DB2105WriteHelper.WriteManScrewH2(); break; case 3: PowderDownSignel(MinAnPlc.Heir2, 2); DB2105WriteHelper.WriteSetValueL2(value); DB2105WriteHelper.WriteHNo(2, "L", true); // DB2105WriteHelper.WriteManScrewH3(); break; case 4: PowderDownSignel(MinAnPlc.Heir2, 2); DB2105WriteHelper.WriteSetValueR2(value); DB2105WriteHelper.WriteHNo(2, "R", true); // DB2105WriteHelper.WriteManScrewH4(); break; case 5: PowderDownSignel(MinAnPlc.Heir3, 3); DB2105WriteHelper.WriteSetValueL3(value); DB2105WriteHelper.WriteHNo(3, "L", true); //DB2105WriteHelper.WriteManScrewH5(); break; case 6: PowderDownSignel(MinAnPlc.Heir3, 3); DB2105WriteHelper.WriteSetValueR3(value); DB2105WriteHelper.WriteHNo(3, "R", true); // DB2105WriteHelper.WriteManScrewH6(); break; case 7: PowderDownSignel(MinAnPlc.Heir4, 4); DB2105WriteHelper.WriteSetValueL4(value); DB2105WriteHelper.WriteHNo(4, "L", true); // DB2105WriteHelper.WriteManScrewH7(); break; case 8: PowderDownSignel(MinAnPlc.Heir4, 4); DB2105WriteHelper.WriteSetValueR4(value); DB2105WriteHelper.WriteHNo(4, "R", true); //DB2105WriteHelper.WriteManScrewH8(); break; default: MessageBox.Show("当前未选择产线!"); return false; } ManualWeightLog(w, t, RadioE); return true; } return false; } public static bool WetSetWeight(SetValue value, MCRadioButtonEntity RadioE) { var singE = ControlsHelper.SingleSelect(RadioE); switch (singE) { case 1: DB2105WriteHelper.WriteSetValueL1(value); // DB2105WriteHelper.WriteManScrewH1(); break; case 2: DB2105WriteHelper.WriteSetValueR1(value); // DB2105WriteHelper.WriteManScrewH2(); break; case 3: DB2105WriteHelper.WriteSetValueL2(value); // DB2105WriteHelper.WriteManScrewH3(); break; case 4: DB2105WriteHelper.WriteSetValueR2(value); // DB2105WriteHelper.WriteManScrewH4(); break; case 5: DB2105WriteHelper.WriteSetValueL3(value); //DB2105WriteHelper.WriteManScrewH5(); break; case 6: DB2105WriteHelper.WriteSetValueR3(value); // DB2105WriteHelper.WriteManScrewH6(); break; case 7: DB2105WriteHelper.WriteSetValueL4(value); // DB2105WriteHelper.WriteManScrewH7(); break; case 8: DB2105WriteHelper.WriteSetValueR4(value); //DB2105WriteHelper.WriteManScrewH8(); break; default: MessageBox.Show("当前未选择产线!"); return false; } return true; } private static void ShowError() { string message = "称量未结束 请稍后"; MessageBox.Show(message); } #endregion public static void WetGelatStopDownload(MCRadioButtonEntity RadioE) { var singE = ControlsHelper.SingleSelect(RadioE); int no = (singE + 1) / 2; DB2105WriteHelper.WriteHNo(no, "S", true); } #endregion #region 产线启停 #region 产线启动 public static void LineStart(MCRadioButtonEntity RadioE) { switch (ControlsHelper.SingleSelect(RadioE)) { case 1: DB2105WriteHelper.WriteStartJob1(); break; case 2: DB2105WriteHelper.WriteStartJob2(); break; case 3: DB2105WriteHelper.WriteStartJob3(); break; case 4: DB2105WriteHelper.WriteStartJob4(); break; case 5: DB2105WriteHelper.WriteStartJob5(); break; case 6: DB2105WriteHelper.WriteStartJob6(); break; case 7: DB2105WriteHelper.WriteStartJob7(); break; case 8: DB2105WriteHelper.WriteStartJob8(); break; default: MessageBox.Show("请选择一条产线!"); return; } SingleLog("产线启动", RadioE); } #endregion #region 产线停止 public static void LineStop(MCRadioButtonEntity RadioE) { switch (ControlsHelper.SingleSelect(RadioE)) { case 1: DB2105WriteHelper.WriteStopJob1(); break; case 2: DB2105WriteHelper.WriteStopJob2(); break; case 3: DB2105WriteHelper.WriteStopJob3(); break; case 4: DB2105WriteHelper.WriteStopJob4(); break; case 5: DB2105WriteHelper.WriteStopJob5(); break; case 6: DB2105WriteHelper.WriteStopJob6(); break; case 7: DB2105WriteHelper.WriteStopJob7(); break; case 8: DB2105WriteHelper.WriteStopJob8(); break; default: MessageBox.Show("请选择一条产线!"); return; } SingleLog("产线停止", RadioE); } #endregion #endregion #region 维修模式 public static void RepairOnOff(MCLabelEntity LabelE, MCRadioButtonEntity RadioE) { if (LabelE.RepairState.MCValue.ToString() == "关") { if (MessageBox.Show("是否开启维修模式?", "维修模式确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } Db3000Helper.WriteModel(ControlsHelper.SingleSelect(RadioE), true); LabelE.RepairState.MCValue = "开"; SingleLog("维修模式开启", RadioE); MessageBox.Show("维修模式已开启"); } else { if (LabelE.RepairState.MCValue.ToString() == "开") { if (MessageBox.Show("是否关闭维修模式?", "维修模式确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } Db3000Helper.WriteModel(ControlsHelper.SingleSelect(RadioE), false); LabelE.RepairState.MCValue = "关"; SingleLog("维修模式关闭", RadioE); MessageBox.Show("维修模式已关闭"); } } } #endregion #region 湿混机物料封装 /// /// 干混机数据打包封装 /// /// 物料类型 /// 重量 /// 公差 /// 物料集合 /// 数据库物料记录 /// 产线选择单选框 private static void DryerGetValue(MCCombobox DryM, MCTextBox DryW, MCTextBox DryT, List recipes, List materials, MCRadioButtonEntity RadioE) { int b = Convert.ToInt32(DryM.MCValue.ToString()); short bin = (short)StockMaterrialDbHelp.GetCodeById(b); float w = Convert.ToSingle(DryW.MCValue.ToString()); float t = Convert.ToSingle(DryT.MCValue.ToString()); //验证公差不能小于0.1 if (b != -1 && t < 0.1) { TFlag = 1; } RecipePlcView recipe1 = new RecipePlcView() { Bin = bin, Set = w, Tolerance = t, }; recipes.Add(recipe1); DeviceMaterrial deviceMaterial1 = new DeviceMaterrial() { DeviceId = ControlsHelper.DrySelect(RadioE), MaterrialId = b, Type = 1, Code = StockMaterrialDbHelp.GetCodeById(b) }; materials.Add(deviceMaterial1); } #endregion #region 上料提示封装 private static void PowderDownSignel(bool minanResult, int num) { if (minanResult) { DialogResult result = MessageBox.Show(num + "号罐正在上料", "温馨提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { return; } } } #endregion } }