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.
319 lines
12 KiB
C#
319 lines
12 KiB
C#
using DataBlockHelper.Entity.DB2106Entity;
|
|
using HslCommunication.Instrument.DLT;
|
|
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.LjMixManager;
|
|
using Mesnac.Action.ChemicalWeighing.LjPlanning;
|
|
using Mesnac.Controls.Base;
|
|
using Mesnac.Controls.Default;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.AutoControl
|
|
{
|
|
public class RefreshAction : ChemicalWeighingAction, IAction
|
|
{
|
|
private List<Control> McControls;
|
|
MCTextBoxEntity TextE = new MCTextBoxEntity();
|
|
ButtonEntity ButtonE = new ButtonEntity();
|
|
MCLabelEntity LabelE = new MCLabelEntity();
|
|
MCComboBoxEntity ComboE = new MCComboBoxEntity();
|
|
MCRadioButtonEntity RadioE = new MCRadioButtonEntity();
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
|
|
base.RunIni(runtime); //必须要调用
|
|
|
|
McControls = GetAllControls();
|
|
|
|
ControlsHelper.ControlImport(TextE, ButtonE, ComboE, LabelE, RadioE, McControls);
|
|
|
|
ControlInitFromPLC();
|
|
|
|
}
|
|
|
|
|
|
|
|
#region 控件初始化
|
|
|
|
/// <summary>
|
|
/// 控件从Plc初始化
|
|
/// </summary>
|
|
private void ControlInitFromPLC()
|
|
{
|
|
//switch (SingleSelect())
|
|
//{
|
|
// case 1:
|
|
// LjPlanningPlcHelp.GetGelatG1.
|
|
//}
|
|
ComboE.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
|
|
ComboE.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
|
|
|
|
var selected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().Where(x => x.DeviceId == SingleSelect() && x.Type == 2).ToList();
|
|
|
|
if (selected.Count != 0)
|
|
{
|
|
ComboE.ChooseMaterial1.SelectedValue = selected[0].MaterrialId;
|
|
ComboE.ChooseMaterial2.SelectedValue = selected[1].MaterrialId;
|
|
}
|
|
else
|
|
{
|
|
ComboE.ChooseMaterial1.SelectedIndex = 0;
|
|
ComboE.ChooseMaterial2.SelectedIndex = 0;
|
|
}
|
|
|
|
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;
|
|
|
|
switch (SingleSelect())
|
|
{
|
|
case 1:
|
|
GWDataShow(getGelatG1, getWeterM1);
|
|
break;
|
|
case 2:
|
|
GWDataShow(getGelatG2, getWeterM2);
|
|
break;
|
|
case 3:
|
|
GWDataShow(getGelatG3, getWeterM3);
|
|
break;
|
|
case 4:
|
|
GWDataShow(getGelatG4, getWeterM4);
|
|
break;
|
|
case 5:
|
|
GWDataShow(getGelatG5, getWeterM5);
|
|
break;
|
|
case 6:
|
|
GWDataShow(getGelatG6, getWeterM6);
|
|
break;
|
|
case 7:
|
|
GWDataShow(getGelatG7, getWeterM7);
|
|
break;
|
|
case 8:
|
|
GWDataShow(getGelatG8, getWeterM8);
|
|
break;
|
|
default:
|
|
return;
|
|
|
|
}
|
|
|
|
ComboE.DryM1.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM2.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM3.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM4.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM5.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM6.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM7.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM8.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM9.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM10.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM11.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
ComboE.DryM12.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
|
|
|
|
var drtSelected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().
|
|
Where(x => x.DeviceId == DrySelect() && x.Type == 1).ToList();
|
|
|
|
if (drtSelected.Count != 0)
|
|
{
|
|
ComboE.DryM1.SelectedValue = drtSelected[0].MaterrialId;
|
|
ComboE.DryM2.SelectedValue = drtSelected[1].MaterrialId;
|
|
ComboE.DryM3.SelectedValue = drtSelected[2].MaterrialId;
|
|
ComboE.DryM4.SelectedValue = drtSelected[3].MaterrialId;
|
|
ComboE.DryM5.SelectedValue = drtSelected[4].MaterrialId;
|
|
ComboE.DryM6.SelectedValue = drtSelected[5].MaterrialId;
|
|
ComboE.DryM7.SelectedValue = drtSelected[6].MaterrialId;
|
|
ComboE.DryM8.SelectedValue = drtSelected[7].MaterrialId;
|
|
ComboE.DryM9.SelectedValue = drtSelected[8].MaterrialId;
|
|
ComboE.DryM10.SelectedValue = drtSelected[9].MaterrialId;
|
|
ComboE.DryM11.SelectedValue = drtSelected[10].MaterrialId;
|
|
ComboE.DryM12.SelectedValue = drtSelected[11].MaterrialId;
|
|
}
|
|
else
|
|
{
|
|
ComboE.DryM1.SelectedIndex = 0;
|
|
ComboE.DryM2.SelectedIndex = 0;
|
|
ComboE.DryM3.SelectedIndex = 0;
|
|
ComboE.DryM4.SelectedIndex = 0;
|
|
ComboE.DryM5.SelectedIndex = 0;
|
|
ComboE.DryM6.SelectedIndex = 0;
|
|
ComboE.DryM7.SelectedIndex = 0;
|
|
ComboE.DryM8.SelectedIndex = 0;
|
|
ComboE.DryM9.SelectedIndex = 0;
|
|
ComboE.DryM10.SelectedIndex = 0;
|
|
ComboE.DryM11.SelectedIndex = 0;
|
|
ComboE.DryM12.SelectedIndex = 0;
|
|
}
|
|
|
|
var getDryerD1 = LjPlanningPlcHelp.GetDryerD1;
|
|
var getDryerD2 = LjPlanningPlcHelp.GetDryerD2;
|
|
var getDryerD3 = LjPlanningPlcHelp.GetDryerD3;
|
|
var getDryerD4 = LjPlanningPlcHelp.GetDryerD4;
|
|
|
|
switch (DrySelect())
|
|
{
|
|
case 1:
|
|
DryDataShow(getDryerD1);
|
|
break;
|
|
case 2:
|
|
DryDataShow(getDryerD2);
|
|
break;
|
|
case 3:
|
|
DryDataShow(getDryerD3);
|
|
break;
|
|
case 4:
|
|
DryDataShow(getDryerD4);
|
|
break;
|
|
default: return;
|
|
}
|
|
|
|
}
|
|
|
|
private void DryDataShow(DryerView Dry)
|
|
{
|
|
TextE.DryW1.MCValue = Dry.RecipePlcViews[0].Set;
|
|
TextE.DryW2.MCValue = Dry.RecipePlcViews[1].Set;
|
|
TextE.DryW3.MCValue = Dry.RecipePlcViews[2].Set;
|
|
TextE.DryW4.MCValue = Dry.RecipePlcViews[3].Set;
|
|
TextE.DryW5.MCValue = Dry.RecipePlcViews[4].Set;
|
|
TextE.DryW6.MCValue = Dry.RecipePlcViews[5].Set;
|
|
TextE.DryW7.MCValue = Dry.RecipePlcViews[6].Set;
|
|
TextE.DryW8.MCValue = Dry.RecipePlcViews[7].Set;
|
|
TextE.DryW9.MCValue = Dry.RecipePlcViews[8].Set;
|
|
TextE.DryW10.MCValue = Dry.RecipePlcViews[9].Set;
|
|
TextE.DryW11.MCValue = Dry.RecipePlcViews[10].Set;
|
|
TextE.DryW12.MCValue = Dry.RecipePlcViews[11].Set;
|
|
|
|
TextE.DryT1.MCValue = Dry.RecipePlcViews[0].Tolerance;
|
|
TextE.DryT2.MCValue = Dry.RecipePlcViews[1].Tolerance;
|
|
TextE.DryT3.MCValue = Dry.RecipePlcViews[2].Tolerance;
|
|
TextE.DryT4.MCValue = Dry.RecipePlcViews[3].Tolerance;
|
|
TextE.DryT5.MCValue = Dry.RecipePlcViews[4].Tolerance;
|
|
TextE.DryT6.MCValue = Dry.RecipePlcViews[5].Tolerance;
|
|
TextE.DryT7.MCValue = Dry.RecipePlcViews[6].Tolerance;
|
|
TextE.DryT8.MCValue = Dry.RecipePlcViews[7].Tolerance;
|
|
TextE.DryT9.MCValue = Dry.RecipePlcViews[8].Tolerance;
|
|
TextE.DryT10.MCValue = Dry.RecipePlcViews[9].Tolerance;
|
|
TextE.DryT11.MCValue = Dry.RecipePlcViews[10].Tolerance;
|
|
TextE.DryT12.MCValue = Dry.RecipePlcViews[11].Tolerance;
|
|
}
|
|
|
|
private void GWDataShow(DryerView Gel, List<MixStep> Wet)
|
|
{
|
|
TextE.MaterialWeight1.MCValue = Gel.RecipePlcViews[0].Set;
|
|
TextE.MaterialWeight2.MCValue = Gel.RecipePlcViews[1].Set;
|
|
//TextE.MaterialTolerance1.MCValue = Gel.RecipePlcViews[0].Tolerance;
|
|
//TextE.MaterialTolerance2.MCValue = Gel.RecipePlcViews[1].Tolerance;
|
|
TextE.GelSpeedSet.MCValue = Gel.RecipeSteps[0].MixSpeed;
|
|
TextE.GelPosTimeA.MCValue = Gel.RecipeSteps[2].MixTemp;
|
|
TextE.GelNagTimeB.MCValue = Gel.RecipeSteps[2].MixSpeed;
|
|
TextE.GelPosTimeC.MCValue = Gel.RecipeSteps[2].MixTime;
|
|
TextE.GelWaterTime.MCValue = Gel.RecipeSteps[4].MixTime;
|
|
TextE.GelWaitTime.MCValue = Gel.RecipeSteps[6].MixTime;
|
|
TextE.GelCloseHeatTime.MCValue = Gel.RecipeSteps[7].MixTime;
|
|
TextE.GelOutDelayTime.MCValue = Gel.RecipeSteps[7].MixTemp;
|
|
TextE.WetDryWeight.MCValue = Wet[1].SetValue;
|
|
TextE.WetMixTime.MCValue = Wet[2].MixTime;
|
|
TextE.WetOutDelayTime.MCValue = Wet[4].MixTime;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 辅助类
|
|
|
|
/// <summary>
|
|
/// 单选选择
|
|
/// </summary>
|
|
/// <returns>返回单选的产线号 如果未选择返回0</returns>
|
|
private int SingleSelect()
|
|
{
|
|
if (Convert.ToBoolean(RadioE.Line1.MCValue) == true)
|
|
{
|
|
return 1;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line2.MCValue) == true)
|
|
{
|
|
return 2;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line3.MCValue) == true)
|
|
{
|
|
return 3;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line4.MCValue) == true)
|
|
{
|
|
return 4;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line5.MCValue) == true)
|
|
{
|
|
return 5;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line6.MCValue) == true)
|
|
{
|
|
return 6;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line7.MCValue) == true)
|
|
{
|
|
return 7;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Line8.MCValue) == true)
|
|
{
|
|
return 8;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单混机单选选择
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int DrySelect()
|
|
{
|
|
if (Convert.ToBoolean(RadioE.Dry1.MCValue) == true)
|
|
{
|
|
return 1;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Dry2.MCValue) == true)
|
|
{
|
|
return 2;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Dry3.MCValue) == true)
|
|
{
|
|
return 3;
|
|
}
|
|
else if (Convert.ToBoolean(RadioE.Dry4.MCValue) == true)
|
|
{
|
|
return 4;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|