You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/RefreshAction.cs

297 lines
19 KiB
C#

using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
public class RefreshAction : ChemicalWeighingAction, IAction
{
GelerWeterControlsEntity ControlsEntity = new GelerWeterControlsEntity();
private List<Control> McControls;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
McControls = GetAllControls();
ControlImport();
ControlInitFromPLC();
}
/// <summary>
/// 控件从Plc初始化
/// </summary>
private void ControlInitFromPLC()
{
//switch (SingleSelect())
//{
// case 1:
// LjPlanningPlcHelp.GetGelatG1.
//}
ControlsEntity.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
ControlsEntity.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
var selected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().Where(x => x.DeviceId == SingleSelect()).ToList();
if (selected.Count != 0)
{
ControlsEntity.ChooseMaterial1.SelectedValue = selected[0].MaterrialId;
ControlsEntity.ChooseMaterial2.SelectedValue = selected[1].MaterrialId;
}
else
{
ControlsEntity.ChooseMaterial1.SelectedIndex = -1;
ControlsEntity.ChooseMaterial2.SelectedIndex = -1;
}
switch (SingleSelect())
{
case 1:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG1.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM1[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM1[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM1[4].MixTime;
break;
case 2:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG2.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM2[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM2[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM2[4].MixTime;
break;
case 3:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG3.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM3[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM3[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM3[4].MixTime;
break;
case 4:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG4.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM4[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM4[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM4[4].MixTime;
break;
case 5:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG5.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM5[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM5[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM5[4].MixTime;
break;
case 6:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG6.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM6[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM6[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM6[4].MixTime;
break;
case 7:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG7.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM7[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM7[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM7[4].MixTime;
break;
case 8:
ControlsEntity.MaterialWeight1.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipePlcViews[0].Set;
ControlsEntity.MaterialWeight2.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipePlcViews[1].Set;
ControlsEntity.MaterialTolerance1.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipePlcViews[0].Tolerance;
ControlsEntity.MaterialTolerance2.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipePlcViews[1].Tolerance;
ControlsEntity.GelSpeedSet.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[0].MixSpeed;
ControlsEntity.GelPosTimeA.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[2].MixTemp;
ControlsEntity.GelNagTimeB.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[2].MixSpeed;
ControlsEntity.GelPosTimeC.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[2].MixTime;
ControlsEntity.GelWaterTime.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[4].MixTime;
ControlsEntity.GelWaitTime.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[6].MixTime;
ControlsEntity.GelCloseHeatTime.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[7].MixTime;
ControlsEntity.GelOutDelayTime.MCValue = LjPlanningPlcHelp.GetGelatG8.RecipeSteps[7].MixTemp;
ControlsEntity.WetDryWeight.MCValue = LjPlanningPlcHelp.GetWeterM8[1].SetValue;
ControlsEntity.WetMixTime.MCValue = LjPlanningPlcHelp.GetWeterM8[2].MixTime;
ControlsEntity.WetOutDelayTime.MCValue = LjPlanningPlcHelp.GetWeterM8[4].MixTime;
break;
default:
return;
}
}
/// <summary>
/// 单选选择
/// </summary>
/// <returns>返回单选的产线号 如果未选择返回0</returns>
private int SingleSelect()
{
if (Convert.ToBoolean(ControlsEntity.Line1.MCValue) == true)
{
return 1;
}
else if (Convert.ToBoolean(ControlsEntity.Line2.MCValue) == true)
{
return 2;
}
else if (Convert.ToBoolean(ControlsEntity.Line3.MCValue) == true)
{
return 3;
}
else if (Convert.ToBoolean(ControlsEntity.Line4.MCValue) == true)
{
return 4;
}
else if (Convert.ToBoolean(ControlsEntity.Line5.MCValue) == true)
{
return 5;
}
else if (Convert.ToBoolean(ControlsEntity.Line6.MCValue) == true)
{
return 6;
}
else if (Convert.ToBoolean(ControlsEntity.Line7.MCValue) == true)
{
return 7;
}
else if (Convert.ToBoolean(ControlsEntity.Line8.MCValue) == true)
{
return 8;
}
else
{
return 0;
}
}
/// <summary>
/// 控件导入
/// </summary>
private void ControlImport()
{
ControlsEntity.Line1 = GetBaseControl("Line1");
ControlsEntity.Line2 = GetBaseControl("Line2");
ControlsEntity.Line3 = GetBaseControl("Line3");
ControlsEntity.Line4 = GetBaseControl("Line4");
ControlsEntity.Line5 = GetBaseControl("Line5");
ControlsEntity.Line6 = GetBaseControl("Line6");
ControlsEntity.Line7 = GetBaseControl("Line7");
ControlsEntity.Line8 = GetBaseControl("Line8");
ControlsEntity.ChooseMaterial1 = GetComboBoxControl("ChooseMaterial1");
ControlsEntity.ChooseMaterial2 = GetComboBoxControl("ChooseMaterial2");
ControlsEntity.MaterialWeight1 = GetBaseControl("MaterialWeight1");
ControlsEntity.MaterialWeight2 = GetBaseControl("MaterialWeight2");
ControlsEntity.MaterialTolerance1 = GetBaseControl("MaterialTolerance1");
ControlsEntity.MaterialTolerance2 = GetBaseControl("MaterialTolerance2");
ControlsEntity.GelSpeedSet = GetBaseControl("GelSpeedSet");
ControlsEntity.GelPosTimeA = GetBaseControl("GelPosTimeA");
ControlsEntity.GelNagTimeB = GetBaseControl("GelNagTimeB");
ControlsEntity.GelPosTimeC = GetBaseControl("GelPosTimeC");
ControlsEntity.GelWaterTime = GetBaseControl("GelWaterTime");
ControlsEntity.GelWaitTime = GetBaseControl("GelWaitTime");
ControlsEntity.GelCloseHeatTime = GetBaseControl("GelCloseHeatTime");
ControlsEntity.GelOutDelayTime = GetBaseControl("GelOutDelayTime");
ControlsEntity.WetDryWeight = GetBaseControl("WetDryWeight");
ControlsEntity.WetMixTime = GetBaseControl("WetMixTime");
ControlsEntity.WetOutDelayTime = GetBaseControl("WetOutDelayTime");
}
private IBaseControl GetBaseControl(string name)
{
return McControls.First(x => x.Name == name) as IBaseControl;
}
private MCCombobox GetComboBoxControl(string name)
{
return McControls.First(x => x.Name == name) as MCCombobox;
}
}
}