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

256 lines
7.6 KiB
C#

using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity.DB2104Entity;
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 System;
using System.Collections.Generic;
using System.Windows.Forms;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using IAction = Mesnac.Action.Base.IAction;
using Mesnac.Core.Service;
using static Mesnac.Action.ChemicalWeighing.AutoControl.AutoLogHelper;
using static Mesnac.Action.ChemicalWeighing.AutoControl.PlcAutoWriteHelper;
using Mesnac.Controls.Default;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
internal class AutoControl : 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<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);
1 year ago
1 year ago
try
{
1 year ago
BottomSelect(runtime);
}
1 year ago
catch(Exception e)
{
1 year ago
MessageBox.Show("请检查输入内容格式是否正确!");
}
}
//按钮事件
private void BottomSelect(RuntimeParameter runtime)
{
1 year ago
#region 自动参数下传
#region 湿混机糊化机参数下传
if (ButtonE.Download == runtime.Sender)
{
if (MessageBox.Show("确认下传数据?", "下传确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
1 year ago
GelWetDownload(TextE, ComboE, RadioE);
}
1 year ago
#endregion
#region 水称参数下传
if (ButtonE.WaterDownload == runtime.Sender)
{
if (MessageBox.Show("确认下发水称数据?", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
WaterDownload(TextE,ComboE);
}
#endregion
#region 干混机参数下传
if(ButtonE.DryDownload == runtime.Sender)
{
if (MessageBox.Show("确认下传干混机数据?", "下传确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
DryDownload(TextE, ComboE, RadioE);
}
#endregion
#endregion
#region 手动控制
if (ButtonE.GelManualPowder == runtime.Sender)
{
if (MessageBox.Show("确认手动下粉料?", "下粉确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
1 year ago
bool isReady = GelPowderDownload(RadioE);
1 year ago
if (!isReady)
{
MessageBox.Show("信号未准备好!");
}
else
{
SingleLog("手动下粉料", RadioE);
MessageBox.Show("信号下达成功!");
}
}
if (ButtonE.GelManualColdWater == runtime.Sender)
{
if (MessageBox.Show("确认下冷水?", "下水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
1 year ago
bool isReady = GelColdWaterDownload(RadioE);
1 year ago
if (!isReady)
{
MessageBox.Show("信号未准备好!");
}
else
{
SingleLog("手动下冷水", RadioE);
MessageBox.Show("信号下达成功!");
}
1 year ago
}
if (ButtonE.GelManualHotWater == runtime.Sender)
{
if (MessageBox.Show("确认下热水?", "下水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
1 year ago
bool isReady = GelHotWaterDownload(RadioE);
1 year ago
if (!isReady)
{
MessageBox.Show("信号未准备好!");
}
else
{
SingleLog("手动下热水", RadioE);
MessageBox.Show("信号下达成功!");
}
}
if (ButtonE.WetManualGel == runtime.Sender)
{
if (MessageBox.Show("请使用手动加料?", "请使用手动加料", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
return;
1 year ago
1 year ago
//bool isReady = WetGelatDownload(RadioE);
//if (!isReady)
//{
// MessageBox.Show("信号未准备好!");
//}
//else
//{
// SingleLog("手动下糊化料", RadioE);
// MessageBox.Show("信号下达成功!");
//}
}
if (ButtonE.WetManualControl == runtime.Sender)
{
if (MessageBox.Show("确认下传数据?", "下传确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
WetGelatDownload(TextE, RadioE);
MessageBox.Show("数据下传成功!");
}
#endregion
#region 自动启停
if (ButtonE.LineStart == runtime.Sender)
{
if (MessageBox.Show("确认启动生产?", "启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
LineStart(RadioE);
MessageBox.Show("产线已启动!");
}
if (ButtonE.LineStop == runtime.Sender)
{
LineStop(RadioE);
MessageBox.Show("已经停止生产");
}
#endregion
#region 维修模式
if(ButtonE.RepairMode == runtime.Sender)
{
RepairOnOff(LabelE, RadioE);
}
#endregion
#region 粘贴数据
if(ButtonE.PasteWet == runtime.Sender)
{
int index = ComboE.PasteChooseWet.SelectedIndex + 1;
ControlsHelper.GWInit(index, ComboE, TextE);
}
if (ButtonE.PasteDry == runtime.Sender)
{
int index = ComboE.PasteChooseDry.SelectedIndex + 1;
ControlsHelper.DInit(index, ComboE, TextE);
}
#endregion
}
}
}