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/LjDeliverControlBoard/ControlBoardButtonAction.cs

203 lines
8.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DataBlockHelper.DBHelpers;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard.Entity;
using Mesnac.Action.ChemicalWeighing.Util;
using Mesnac.Controls.ChemicalWeighing;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard
{
public class ControlBoardButtonAction : ChemicalWeighingAction, IAction
{
DB191Helper DB191 = new DB191Helper();
List<Control> Controls;
MCButtonEntity ButtonE = new MCButtonEntity();
MCRadioButtonEntity RadioButtonE = new MCRadioButtonEntity();
public void Run(RuntimeParameter runtime)
{
RunIni(runtime);
Controls = GetAllControls();
SetAllControls();
ButtonSelect(runtime);
}
private void ButtonSelect(RuntimeParameter runtime)
{
if (runtime.Sender == ButtonE.BoardOnA)
{
if (!DB191.GetPanelOnOff()[0])
{
if (MessageBox.Show("确认要启动操作面板A", "操作面板启动确认", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
DB191WriteHelper.SetPanelOnOffA(true);
ButtonE.BoardOnA.Text = "关闭面板";
ButtonE.BoardOnA.BackColor = System.Drawing.Color.LightGreen;
}
else
{
DB191WriteHelper.SetPanelOnOffA(false);
ButtonE.BoardOnA.Text = "面板启用";
ButtonE.BoardOnA.BackColor = System.Drawing.Color.Yellow;
MessageBox.Show("面板已关闭");
}
}
if (runtime.Sender == ButtonE.BoardOnB)
{
if (!DB191.GetPanelOnOff()[1])
{
if (MessageBox.Show("确认要启动操作面板B", "操作面板启动确认", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
DB191WriteHelper.SetPanelOnOffB(true);
ButtonE.BoardOnB.Text = "关闭面板";
ButtonE.BoardOnB.BackColor = System.Drawing.Color.LightGreen;
}
else
{
DB191WriteHelper.SetPanelOnOffB(false);
ButtonE.BoardOnB.Text = "面板启用";
ButtonE.BoardOnB.BackColor = System.Drawing.Color.Yellow;
MessageBox.Show("面板已关闭");
}
}
if (runtime.Sender == ButtonE.BoardOnC)
{
if (!DB191.GetPanelOnOff()[2])
{
if (MessageBox.Show("确认要启动操作面板C", "操作面板启动确认", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
DB191WriteHelper.SetPanelOnOffC(true);
ButtonE.BoardOnC.Text = "关闭面板";
ButtonE.BoardOnC.BackColor = System.Drawing.Color.LightGreen;
}
else
{
DB191WriteHelper.SetPanelOnOffC(false);
ButtonE.BoardOnC.Text = "面板启用";
ButtonE.BoardOnC.BackColor = System.Drawing.Color.Yellow;
MessageBox.Show("面板已关闭");
}
}
if (runtime.Sender == ButtonE.DownLoadBoardA)
{
if (MessageBox.Show("确认下发A面板数据", "数据下发确认", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
switch (ControlsHelper.BottleSelectA(RadioButtonE))
{
case 1: DB191WriteHelper.SetVesselModeA(true, false); break;
case 2: DB191WriteHelper.SetVesselModeA(false, true); break;
case 3: DB191WriteHelper.SetVesselModeA(false, false); break;
default: MessageBox.Show("请先选择压送罐模式!"); return;
}
DB191WriteHelper.SetSiloGroupA(
Convert.ToBoolean(RadioButtonE.StoreGroupAA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupBA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupCA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupDA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupEA.MCValue)
);
DB191WriteHelper.SetSiloA(
Convert.ToBoolean(RadioButtonE.StoreAA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreBA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreCA.MCValue),
Convert.ToBoolean(RadioButtonE.StoreDA.MCValue)
);
}
if (runtime.Sender == ButtonE.DownLoadBoardB)
{
if (MessageBox.Show("确认下发B面板数据", "数据下发确认", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
switch (ControlsHelper.BottleSelectB(RadioButtonE))
{
case 1: DB191WriteHelper.SetVesselModeB(true, false); break;
case 2: DB191WriteHelper.SetVesselModeB(false, true); break;
case 3: DB191WriteHelper.SetVesselModeB(false, false); break;
default: MessageBox.Show("请先选择压送罐模式!"); return;
}
DB191WriteHelper.SetSiloGroupB(
Convert.ToBoolean(RadioButtonE.StoreGroupAB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupBB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupCB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupDB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupEB.MCValue)
);
DB191WriteHelper.SetSiloB(
Convert.ToBoolean(RadioButtonE.StoreAB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreBB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreCB.MCValue),
Convert.ToBoolean(RadioButtonE.StoreDB.MCValue)
);
}
if (runtime.Sender == ButtonE.DownLoadBoardC)
{
if (MessageBox.Show("确认下发C面板数据", "数据下发确认", MessageBoxButtons.YesNo) == DialogResult.No)
{
return;
}
switch (ControlsHelper.BottleSelectC(RadioButtonE))
{
case 1: DB191WriteHelper.SetVesselModeC(true, false); break;
case 2: DB191WriteHelper.SetVesselModeC(false, true); break;
case 3: DB191WriteHelper.SetVesselModeC(false, false); break;
default: MessageBox.Show("请先选择压送罐模式!"); return;
}
DB191WriteHelper.SetSiloGroupC(
Convert.ToBoolean(RadioButtonE.StoreGroupAC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupBC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupCC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupDC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreGroupEC.MCValue)
);
DB191WriteHelper.SetSiloC(
Convert.ToBoolean(RadioButtonE.StoreAC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreBC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreCC.MCValue),
Convert.ToBoolean(RadioButtonE.StoreDC.MCValue)
);
}
}
private void SetAllControls()
{
ControlsImprot.ControlImport<MCButton>(ButtonE, Controls);
ControlsImprot.ControlImport<MCRadioButton>(RadioButtonE, Controls);
}
}
}