|
|
|
@ -17,18 +17,24 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
int ManualModeIsOpen;
|
|
|
|
|
int ManualModeIsStart;
|
|
|
|
|
int AutoModeIsStart;
|
|
|
|
|
string DmName;
|
|
|
|
|
string DmName = "DM1GDP01";
|
|
|
|
|
public ElectronicMachinery()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
ManualModeIsOpen = GetDataNameValue("_ManualMode").NowValue.ToInt();
|
|
|
|
|
ManualModeIsStart = GetDataNameValue("_StartManual").NowValue.ToInt();
|
|
|
|
|
AutoModeIsStart = Plc.DM1GDP01_StartAuto.NowValue.ToInt();
|
|
|
|
|
|
|
|
|
|
StateMonitor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StateMonitor()
|
|
|
|
|
{
|
|
|
|
|
ManualModeIsOpen = GetDataToInt("_ManualMode");
|
|
|
|
|
ManualModeIsStart = GetDataToInt("_StartManual");
|
|
|
|
|
AutoModeIsStart = GetDataToInt("_StartAuto");
|
|
|
|
|
if (ManualModeIsOpen == 0)
|
|
|
|
|
{
|
|
|
|
|
ManualMode.Text = "切换手动模式";
|
|
|
|
|
ModeLable.Text = "自动模式";
|
|
|
|
|
if(ManualModeIsStart == 0)
|
|
|
|
|
if (AutoModeIsStart == 0)
|
|
|
|
|
{
|
|
|
|
|
OnOffControl.Text = "启动";
|
|
|
|
|
OnOffLable.Text = "状态:关";
|
|
|
|
@ -43,7 +49,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
{
|
|
|
|
|
ManualMode.Text = "切换自动模式";
|
|
|
|
|
ModeLable.Text = "手动模式";
|
|
|
|
|
if (AutoModeIsStart == 0)
|
|
|
|
|
if (ManualModeIsStart == 0)
|
|
|
|
|
{
|
|
|
|
|
OnOffControl.Text = "启动";
|
|
|
|
|
OnOffLable.Text = "状态:关";
|
|
|
|
@ -56,11 +62,21 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DataKeyValue GetDataNameValue(string dmValue)
|
|
|
|
|
private DataKeyValue GetDataNameValue(string dmValue)
|
|
|
|
|
{
|
|
|
|
|
return new DataKeyValue(DmName + dmValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int GetDataToInt(String dmValue)
|
|
|
|
|
{
|
|
|
|
|
return GetDataNameValue(dmValue).NowValue.ToInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetDataValue(String dmValue, int value)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue(dmValue), new Object[] { value });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DMChange_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (DMChange.Text)
|
|
|
|
@ -96,14 +112,15 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
DmName = "DM1GDS05";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
StateMonitor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ManualMode_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(ManualModeIsOpen == 0)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_ManualMode"), new Object[] { 1 });
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_AutoMode"), new Object[] { 0 });
|
|
|
|
|
SetDataValue("_ManualMode", 1);
|
|
|
|
|
SetDataValue("_AutoMode", 0 );
|
|
|
|
|
ManualMode.Text = "切换自动模式";
|
|
|
|
|
ModeLable.Text = "手动模式";
|
|
|
|
|
ManualModeIsOpen = 1;
|
|
|
|
@ -120,8 +137,8 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_ManualMode"), new Object[] { 0 });
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_AutoMode"), new Object[] { 1 });
|
|
|
|
|
SetDataValue("_ManualMode", 0);
|
|
|
|
|
SetDataValue("_AutoMode", 1);
|
|
|
|
|
ManualMode.Text = "切换手动模式";
|
|
|
|
|
ModeLable.Text = "自动模式";
|
|
|
|
|
ManualModeIsOpen = 0;
|
|
|
|
@ -144,16 +161,16 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
{
|
|
|
|
|
if (AutoModeIsStart == 0)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StartAuto"), new Object[] { 1 });
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StopAuto"), new Object[] { 0 });
|
|
|
|
|
SetDataValue("_StartAuto", 1);
|
|
|
|
|
SetDataValue("_StopAuto", 0);
|
|
|
|
|
OnOffControl.Text = "关闭";
|
|
|
|
|
OnOffLable.Text = "状态:开";
|
|
|
|
|
AutoModeIsStart = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StartAuto"), new Object[] { 0 });
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StopAuto"), new Object[] { 1 });
|
|
|
|
|
SetDataValue("_StartAuto", 0);
|
|
|
|
|
SetDataValue("_StopAuto", 1);
|
|
|
|
|
OnOffControl.Text = "启动";
|
|
|
|
|
OnOffLable.Text = "状态:关";
|
|
|
|
|
AutoModeIsStart = 0;
|
|
|
|
@ -163,16 +180,16 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
{
|
|
|
|
|
if (ManualModeIsStart == 0)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StartManual"), new Object[] { 1 });
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StopManual"), new Object[] { 0 });
|
|
|
|
|
SetDataValue("_StartManual", 1);
|
|
|
|
|
SetDataValue("_StopManual", 0);
|
|
|
|
|
OnOffControl.Text = "关闭";
|
|
|
|
|
OnOffLable.Text = "状态:开";
|
|
|
|
|
ManualModeIsStart = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StartManual"), new Object[] { 0 });
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_StopManual"), new Object[] { 1 });
|
|
|
|
|
SetDataValue("_StartManual", 0);
|
|
|
|
|
SetDataValue("_StopManual", 1);
|
|
|
|
|
OnOffControl.Text = "启动";
|
|
|
|
|
OnOffLable.Text = "状态:关";
|
|
|
|
|
ManualModeIsStart = 0;
|
|
|
|
@ -182,17 +199,17 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
|
|
|
|
|
|
|
|
|
|
private void AlarmReset_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_AlarmReset"), new Object[] { 1 });
|
|
|
|
|
SetDataValue("_AlarmReset", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Running_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_Running"), new Object[] { 1 });
|
|
|
|
|
SetDataValue("_Running", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Run_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Plc.PlcWriteByDataKey(GetDataNameValue("_Run"), new Object[] { 1 });
|
|
|
|
|
SetDataValue("_Run", 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|