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/GelerWeterControl.cs

389 lines
14 KiB
C#

using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity.DB2104Entity;
using DataBlockHelper.Entity.DB2106Entity;
using Mesnac.Action.Base;
1 year ago
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
1 year ago
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
using Mesnac.Core.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Mesnac.Controls.Default;
using Button = System.Windows.Forms.Button;
1 year ago
using System.Data;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Steema.TeeChart.Functions;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
internal class GelerWeterControl : ChemicalWeighingAction, IAction
{
private List<Control> McControls;
RuntimeParameter _runtime;
GelerWeterControlsEntity ControlsEntity = new GelerWeterControlsEntity();
public static int choose;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
this._runtime = runtime;
McControls = GetAllControls();
ControlImport();
1 year ago
BottomSelect(runtime);
}
/// <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;
}
}
1 year ago
/// <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");
ControlsEntity.WetManualControl = GetButtonControl("WetManualControl");
ControlsEntity.Download = GetButtonControl("Download");
ControlsEntity.LineStart = GetButtonControl("LineStart");
ControlsEntity.LineStop = GetButtonControl("LineStop");
}
private void BottomSelect(RuntimeParameter runtime)
{
if(ControlsEntity.WetManualControl == runtime.Sender)
{
ManualAdd frm = new ManualAdd();
choose = SingleSelect();
DialogResult result = frm.ShowDialog();
this._runtime.BaseControl.MCEnabled = false;
if (result == DialogResult.OK)
{
frm.Dispose();
}
this._runtime.BaseControl.MCEnabled = true;
}
if (ControlsEntity.Download == runtime.Sender)
{
1 year ago
1 year ago
List<RecipePlcView> recipes = new List<RecipePlcView>();
int bin1 = Convert.ToInt32(ControlsEntity.ChooseMaterial1.MCValue.ToString());
int bin2 = Convert.ToInt32(ControlsEntity.ChooseMaterial2.MCValue.ToString());
if(bin1 == -1)
{
bin1 = 0;
}
if(bin2 == -1)
{
bin2 = 0;
}
1 year ago
RecipePlcView recipe1 = new RecipePlcView()
{
Bin = (ushort)bin1,
Set = Convert.ToSingle(ControlsEntity.MaterialWeight1.MCValue.ToString()),
Tolerance = Convert.ToSingle(ControlsEntity.MaterialTolerance1.MCValue.ToString()),
1 year ago
};
RecipePlcView recipe2 = new RecipePlcView()
{
Bin = (ushort)bin2,
Set = Convert.ToSingle(ControlsEntity.MaterialWeight2.MCValue.ToString()),
Tolerance = Convert.ToSingle(ControlsEntity.MaterialTolerance2.MCValue.ToString()),
1 year ago
};
recipes.Add(recipe1);
recipes.Add(recipe2);
List<Step> steps = new List<Step>();
Step step1 = new Step()
{
MixCode = 1,
MixSpeed = Convert.ToSingle(ControlsEntity.GelSpeedSet.MCValue.ToString())
1 year ago
};
Step step2 = new Step()
{
MixCode = 2,
1 year ago
};
Step step3 = new Step()
{
MixCode = 3,
MixTime = Convert.ToUInt16(ControlsEntity.GelPosTimeC.MCValue.ToString()),
MixTemp = Convert.ToSingle(ControlsEntity.GelPosTimeA.MCValue.ToString()),
MixSpeed = Convert.ToSingle(ControlsEntity.GelNagTimeB.MCValue.ToString())
1 year ago
};
Step step4 = new Step()
{
MixCode = 4,
1 year ago
};
Step step5 = new Step()
{
MixCode = 5,
MixTime = Convert.ToUInt16(ControlsEntity.GelWaterTime.MCValue.ToString())
1 year ago
};
Step step6 = new Step()
{
MixCode = 6,
1 year ago
};
Step step7 = new Step()
{
MixCode = 5,
MixTime = Convert.ToUInt16(ControlsEntity.GelWaitTime.MCValue.ToString())
1 year ago
};
Step step8 = new Step()
{
MixCode = 7,
MixTime = Convert.ToUInt16(ControlsEntity.GelCloseHeatTime.MCValue.ToString()),
MixTemp = Convert.ToSingle(ControlsEntity.GelOutDelayTime.MCValue.ToString())
1 year ago
};
steps.Add(step1);
steps.Add(step2);
steps.Add(step3);
steps.Add(step4);
steps.Add(step5);
steps.Add(step6);
steps.Add(step7);
steps.Add(step8);
1 year ago
List<MixStep> mixSteps = new List<MixStep>();
MixStep mixStep1 = new MixStep()
{
MixCode = 1,
1 year ago
};
MixStep mixStep2 = new MixStep()
{
MixCode = 2,
SetValue = Convert.ToSingle(ControlsEntity.WetDryWeight.MCValue.ToString())
1 year ago
};
MixStep mixStep3 = new MixStep()
{
MixCode = 3,
MixTime = Convert.ToUInt16(ControlsEntity.WetMixTime.MCValue.ToString())
1 year ago
};
MixStep mixStep4 = new MixStep()
{
MixCode = 4,
1 year ago
};
MixStep mixStep5 = new MixStep()
{
MixCode = 5,
MixTime = Convert.ToUInt16(ControlsEntity.WetOutDelayTime.MCValue.ToString()),
1 year ago
};
mixSteps.Add(mixStep1);
mixSteps.Add(mixStep2);
mixSteps.Add(mixStep3);
mixSteps.Add(mixStep4);
mixSteps.Add(mixStep5);
switch (SingleSelect())
{
case 1:
LjPlanningPlcHelp.DownG1Recipe(recipes, steps);
LjPlanningPlcHelp.DownM1Recipe(mixSteps);
break;
case 2:
LjPlanningPlcHelp.DownG2Recipe(recipes, steps);
LjPlanningPlcHelp.DownM2Recipe(mixSteps);
break;
case 3:
LjPlanningPlcHelp.DownG3Recipe(recipes, steps);
LjPlanningPlcHelp.DownM3Recipe(mixSteps);
break;
case 4:
LjPlanningPlcHelp.DownG4Recipe(recipes, steps);
LjPlanningPlcHelp.DownM4Recipe(mixSteps);
break;
case 5:
LjPlanningPlcHelp.DownG5Recipe(recipes, steps);
LjPlanningPlcHelp.DownM5Recipe(mixSteps);
break;
case 6:
LjPlanningPlcHelp.DownG6Recipe(recipes, steps);
LjPlanningPlcHelp.DownM6Recipe(mixSteps);
break;
case 7:
LjPlanningPlcHelp.DownG7Recipe(recipes, steps);
LjPlanningPlcHelp.DownM7Recipe(mixSteps);
break;
case 8:
LjPlanningPlcHelp.DownG8Recipe(recipes, steps);
LjPlanningPlcHelp.DownM8Recipe(mixSteps);
break;
default:
MessageBox.Show("请选择一条产线!");
return;
}
}
if (ControlsEntity.LineStart == runtime.Sender)
{
switch (SingleSelect())
{
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;
}
}
if (ControlsEntity.LineStop == runtime.Sender)
{
switch (SingleSelect())
{
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;
}
}
}
private IBaseControl GetBaseControl(string name)
{
return McControls.First(x => x.Name == name) as IBaseControl;
}
private Button GetButtonControl(string name)
{
return McControls.First(x => x.Name == name) as Button;
}
private MCCombobox GetComboBoxControl(string name)
{
return McControls.First(x => x.Name == name) as MCCombobox;
}
}
}