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.
388 lines
15 KiB
C#
388 lines
15 KiB
C#
using DataBlockHelper.DBHelpers;
|
|
using DevExpress.DataAccess.Wizard.Presenters;
|
|
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.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using IAction = Mesnac.Action.Base.IAction;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.AutoControl
|
|
{
|
|
public class InitAction : ChemicalWeighingAction, IAction
|
|
{
|
|
private List<Control> McControls;
|
|
Color backColor = Color.Transparent;
|
|
MCTextBoxEntity TextE = new MCTextBoxEntity();
|
|
ButtonEntity ButtonE = new ButtonEntity();
|
|
MCLabelEntity LabelE = new MCLabelEntity();
|
|
MCComboBoxEntity ComboE = new MCComboBoxEntity();
|
|
MCRadioButtonEntity RadioE = new MCRadioButtonEntity();
|
|
|
|
public Timer timer;
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
|
|
base.RunIni(runtime); //必须要调用
|
|
McControls = GetAllControls();
|
|
|
|
ControlsHelper.ControlImport<MCTextBox>(TextE, McControls);
|
|
ControlsHelper.ControlImport<System.Windows.Forms.Button>(ButtonE, McControls);
|
|
ControlsHelper.ControlImport<MCCombobox>(ComboE, McControls);
|
|
ControlsHelper.ControlImport<MCLabel>(LabelE, McControls);
|
|
ControlsHelper.ControlImport<MCRadioButton>(RadioE, McControls);
|
|
|
|
ControlInit();
|
|
|
|
RadioE.Line1.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line2.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line3.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line4.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line5.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line6.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line7.CheckedChanged += Mcradion_CheckedChanged;
|
|
RadioE.Line8.CheckedChanged += Mcradion_CheckedChanged;
|
|
|
|
RadioE.Dry1.CheckedChanged += DMcradion_CheckedChanged;
|
|
RadioE.Dry2.CheckedChanged += DMcradion_CheckedChanged;
|
|
RadioE.Dry3.CheckedChanged += DMcradion_CheckedChanged;
|
|
RadioE.Dry4.CheckedChanged += DMcradion_CheckedChanged;
|
|
|
|
RadioE.Line1.MCValue = true;
|
|
RadioE.Dry1.MCValue = true;
|
|
|
|
timer = new Timer();
|
|
timer.Interval = 1000;
|
|
timer.Enabled = true;
|
|
timer.Tick += new EventHandler(StateRefresh);//添加事件
|
|
}
|
|
|
|
#region 前端Timer状态刷新
|
|
|
|
private void StateRefresh(object sender, EventArgs e)
|
|
{
|
|
if (GetAllDbMCControlsByOption(DbOptionTypes.QueryAndModify).Count == 0)
|
|
{
|
|
timer.Stop();
|
|
timer.Dispose();
|
|
}
|
|
|
|
DB2105Helper dB2105Helper = new DB2105Helper();
|
|
|
|
var startJob = dB2105Helper.GetStartJob;
|
|
|
|
LabelE.State1.MCValue = ConvertOnOff(startJob[0].Val);
|
|
LabelE.State2.MCValue = ConvertOnOff(startJob[1].Val);
|
|
LabelE.State3.MCValue = ConvertOnOff(startJob[2].Val);
|
|
LabelE.State4.MCValue = ConvertOnOff(startJob[3].Val);
|
|
LabelE.State5.MCValue = ConvertOnOff(startJob[4].Val);
|
|
LabelE.State6.MCValue = ConvertOnOff(startJob[5].Val);
|
|
LabelE.State7.MCValue = ConvertOnOff(startJob[6].Val);
|
|
LabelE.State8.MCValue = ConvertOnOff(startJob[7].Val);
|
|
|
|
LabelE.State1.BackColor = ConvertColor(startJob[0].Val);
|
|
LabelE.State2.BackColor = ConvertColor(startJob[1].Val);
|
|
LabelE.State3.BackColor = ConvertColor(startJob[2].Val);
|
|
LabelE.State4.BackColor = ConvertColor(startJob[3].Val);
|
|
LabelE.State5.BackColor = ConvertColor(startJob[4].Val);
|
|
LabelE.State6.BackColor = ConvertColor(startJob[5].Val);
|
|
LabelE.State7.BackColor = ConvertColor(startJob[6].Val);
|
|
LabelE.State8.BackColor = ConvertColor(startJob[7].Val);
|
|
|
|
var rd = Db3000Helper.ReadModel();
|
|
|
|
if (rd[ControlsHelper.SingleSelect(RadioE) - 1])
|
|
{
|
|
LabelE.RepairState.MCValue = "开";
|
|
}
|
|
else
|
|
{
|
|
LabelE.RepairState.MCValue = "关";
|
|
}
|
|
}
|
|
|
|
private string ConvertOnOff(bool state)
|
|
{
|
|
if (state)
|
|
{
|
|
return "启动";
|
|
}
|
|
else
|
|
{
|
|
return "停止";
|
|
}
|
|
}
|
|
|
|
private Color ConvertColor(bool state)
|
|
{
|
|
if (state)
|
|
{
|
|
return Color.LightGreen;
|
|
}
|
|
else
|
|
{
|
|
return Color.Transparent;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region PLC读数刷新控件
|
|
|
|
private void Mcradion_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
MCRadioButton mCRadio = sender as MCRadioButton;
|
|
RadioE.Line1.BackColor = backColor;
|
|
RadioE.Line2.BackColor = backColor;
|
|
RadioE.Line3.BackColor = backColor;
|
|
RadioE.Line4.BackColor = backColor;
|
|
RadioE.Line5.BackColor = backColor;
|
|
RadioE.Line6.BackColor = backColor;
|
|
RadioE.Line7.BackColor = backColor;
|
|
RadioE.Line8.BackColor = backColor;
|
|
mCRadio.BackColor = Color.LightSkyBlue;
|
|
int select = ControlsHelper.SingleSelect(RadioE);
|
|
GWInit(select);
|
|
switch (select)
|
|
{
|
|
case 1:
|
|
case 2:
|
|
RadioE.Dry1.MCValue = true; break;
|
|
case 3:
|
|
case 4:
|
|
RadioE.Dry2.MCValue = true; break;
|
|
case 5:
|
|
case 6:
|
|
RadioE.Dry3.MCValue = true; break;
|
|
case 7:
|
|
case 8:
|
|
RadioE.Dry4.MCValue = true; break;
|
|
default: break;
|
|
}
|
|
}
|
|
|
|
private void DMcradion_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
MCRadioButton mCRadio = sender as MCRadioButton;
|
|
RadioE.Dry1.BackColor = backColor;
|
|
RadioE.Dry2.BackColor = backColor;
|
|
RadioE.Dry3.BackColor = backColor;
|
|
RadioE.Dry4.BackColor = backColor;
|
|
mCRadio.BackColor = Color.LightSkyBlue;
|
|
DInit(ControlsHelper.DrySelect(RadioE));
|
|
}
|
|
|
|
private void GWInit(int select)
|
|
{
|
|
|
|
var selected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().Where(x => x.DeviceId == select && 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 (select)
|
|
{
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void DInit(int select)
|
|
{
|
|
|
|
var drtSelected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().
|
|
Where(x => x.DeviceId == select && 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 (select)
|
|
{
|
|
case 1:
|
|
DryDataShow(getDryerD1);
|
|
break;
|
|
case 2:
|
|
DryDataShow(getDryerD2);
|
|
break;
|
|
case 3:
|
|
DryDataShow(getDryerD3);
|
|
break;
|
|
case 4:
|
|
DryDataShow(getDryerD4);
|
|
break;
|
|
default: return;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 控件从Plc初始化
|
|
/// </summary>
|
|
private void ControlInit()
|
|
{
|
|
|
|
ComboE.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
|
|
ComboE.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
|
|
|
|
|
|
DB2104Helper waterData = new DB2104Helper();
|
|
|
|
TextE.ColdValueA.MCValue = waterData.GetAColWater.Set;
|
|
TextE.ColdValueB.MCValue = waterData.GetBColWater.Set;
|
|
TextE.HotValueA.MCValue = waterData.GetAHotWater.Set;
|
|
TextE.HotValueB.MCValue = waterData.GetBHotWater.Set;
|
|
TextE.ColdToleranceA.MCValue = waterData.GetAColWater.Tolerance;
|
|
TextE.ColdToleranceB.MCValue = waterData.GetBColWater.Tolerance;
|
|
TextE.HotToleranceA.MCValue = waterData.GetAHotWater.Tolerance;
|
|
TextE.HotToleranceB.MCValue = waterData.GetBHotWater.Tolerance;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
private void GWDataShow(DryerView Gel, List<MixStep> Wet)
|
|
{
|
|
TextE.MaterialWeight1.MCValue = Gel.RecipePlcViews[0].Set;
|
|
TextE.MaterialWeight2.MCValue = Gel.RecipePlcViews[1].Set;
|
|
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
|
|
|
|
}
|
|
}
|