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.
486 lines
16 KiB
C#
486 lines
16 KiB
C#
using DataBlockHelper.DBHelpers;
|
|
using DevExpress.DataAccess.Wizard.Presenters;
|
|
using DevExpress.XtraEditors.Filtering.Templates;
|
|
|
|
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.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Button = System.Windows.Forms.Button;
|
|
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();
|
|
MCLabelEntity LabelE = new MCLabelEntity();
|
|
MCComboBoxEntity ComboE = new MCComboBoxEntity();
|
|
MCRadioButtonEntity RadioE = new MCRadioButtonEntity();
|
|
ButtonEntity buttonE = new ButtonEntity();
|
|
|
|
DB2105Helper dB2105Helper = new DB2105Helper();
|
|
DB2104Helper dB2104Helper = new DB2104Helper();
|
|
Color color;
|
|
public Timer timer;
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
|
|
base.RunIni(runtime); //必须要调用
|
|
McControls = GetAllControls();
|
|
|
|
ControlsHelper.ControlImport<MCTextBox>(TextE, McControls);
|
|
|
|
// McControls.FirstOrDefault(x => x.Name == name)
|
|
|
|
//TextE.HALeftOrRight = McControls.FirstOrDefault(x => x.Name == "HALeftOrRight") as MCCombobox;
|
|
//TextE.HBLeftOrRight = McControls.FirstOrDefault(x => x.Name == "HBLeftOrRight") as MCCombobox;
|
|
//TextE.CALeftOrRight = McControls.FirstOrDefault(x => x.Name == "CALeftOrRight") as MCCombobox;
|
|
//TextE.CBLeftOrRight = McControls.FirstOrDefault(x => x.Name == "CBLeftOrRight") as MCCombobox;
|
|
|
|
|
|
ControlsHelper.ControlImport<MCCombobox>(ComboE, McControls);
|
|
ControlsHelper.ControlImport<MCLabel>(LabelE, McControls);
|
|
ControlsHelper.ControlImport<MCRadioButton>(RadioE, McControls);
|
|
ControlsHelper.ControlImport<Button>(buttonE, McControls);
|
|
|
|
|
|
// color = buttonE.GRepairMode;
|
|
|
|
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 = 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 = "开";
|
|
LabelE.RepairState.BackColor = Color.Red;
|
|
}
|
|
else
|
|
{
|
|
LabelE.RepairState.MCValue = "关";
|
|
LabelE.RepairState.BackColor = Color.LightGreen;
|
|
|
|
}
|
|
|
|
|
|
var index = ControlsHelper.SingleSelect(RadioE);
|
|
|
|
|
|
switch (index)
|
|
{
|
|
case 1:
|
|
ConvertBackColor(dB2105Helper.FeededPdG1);
|
|
break;
|
|
case 2:
|
|
ConvertBackColor(dB2105Helper.FeededPdG2);
|
|
break;
|
|
case 3:
|
|
ConvertBackColor(dB2105Helper.FeededPdG3);
|
|
break;
|
|
case 4:
|
|
ConvertBackColor(dB2105Helper.FeededPdG4);
|
|
break;
|
|
|
|
|
|
case 5:
|
|
ConvertBackColor(dB2105Helper.FeededPdG5);
|
|
break;
|
|
case 6:
|
|
ConvertBackColor(dB2105Helper.FeededPdG6);
|
|
break;
|
|
case 7:
|
|
ConvertBackColor(dB2105Helper.FeededPdG7);
|
|
break;
|
|
case 8:
|
|
ConvertBackColor(dB2105Helper.FeededPdG8);
|
|
break;
|
|
}
|
|
|
|
|
|
int dryIndex = ControlsHelper.DrySelect(RadioE);
|
|
if (dryIndex > 0)
|
|
{
|
|
var startOrStop = dB2105Helper.GetDryStartOrStop();
|
|
bool b = startOrStop[dryIndex - 1];
|
|
DryStartOrStopColoer(dryIndex,b);
|
|
|
|
|
|
DB2107Helper dB2107=new DB2107Helper();
|
|
bool spare = false;
|
|
switch (dryIndex)
|
|
{
|
|
case 1:
|
|
spare = dB2107.NormalStatus.RdyRpt_V1;
|
|
break;
|
|
case 2:
|
|
spare = dB2107.NormalStatus.RdyRpt_V2;
|
|
break;
|
|
case 3:
|
|
spare = dB2107.NormalStatus.RdyRpt_V3;
|
|
break;
|
|
case 4:
|
|
spare = dB2107.NormalStatus.RdyRpt_V4;
|
|
break;
|
|
}
|
|
|
|
DryPauseOrReplyColoer(dryIndex, spare);
|
|
|
|
|
|
}
|
|
|
|
//DryPauseOrReply
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
private void ConvertBackColor(bool b)
|
|
{
|
|
|
|
if (b)
|
|
{
|
|
buttonE.GRepairMode.BackColor = Color.Green;
|
|
buttonE.GRepairMode.Text = "糊化锅维修模式(开)";
|
|
}
|
|
else
|
|
{
|
|
buttonE.GRepairMode.BackColor = Color.Transparent;
|
|
buttonE.GRepairMode.Text = "糊化锅维修模式(关)";
|
|
}
|
|
}
|
|
|
|
|
|
private void DryStartOrStopColoer(int no,bool b)
|
|
{
|
|
if (b)
|
|
{
|
|
buttonE.DryStartOrStop.BackColor = Color.Green;
|
|
buttonE.DryStartOrStop.Text = $"干混机{no}(开)";
|
|
}
|
|
else
|
|
{
|
|
buttonE.DryStartOrStop.BackColor = Color.Transparent;
|
|
buttonE.DryStartOrStop.Text = $"干混机{no}(关)";
|
|
}
|
|
}
|
|
|
|
private void DryPauseOrReplyColoer(int no, bool b)
|
|
{
|
|
|
|
//暂停 0 恢复 1
|
|
|
|
|
|
if (b)
|
|
{
|
|
buttonE.DryPauseOrReply.BackColor = Color.Transparent;
|
|
buttonE.DryPauseOrReply.Text = $"干混机{no}(恢复排料)";
|
|
|
|
}
|
|
else
|
|
{
|
|
buttonE.DryPauseOrReply.BackColor = Color.Green;
|
|
buttonE.DryPauseOrReply.Text = $"干混机{no}(暂停排料)";
|
|
}
|
|
}
|
|
|
|
|
|
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);
|
|
ControlsHelper.GWInit(select, ComboE, TextE);
|
|
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;
|
|
ControlsHelper.DInit(ControlsHelper.DrySelect(RadioE), ComboE, TextE);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 控件从Plc初始化
|
|
/// </summary>
|
|
public void ControlInit()
|
|
{
|
|
|
|
ComboE.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
|
|
ComboE.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
|
|
|
|
TextE.ColdValueA.MCValue = dB2104Helper.GetAColWater.Set;
|
|
TextE.ColdValueB.MCValue = dB2104Helper.GetBColWater.Set;
|
|
TextE.HotValueA.MCValue = dB2104Helper.GetAHotWater.Set;
|
|
TextE.HotValueB.MCValue = dB2104Helper.GetBHotWater.Set;
|
|
TextE.ColdToleranceA.MCValue = dB2104Helper.GetAColWater.Tolerance;
|
|
TextE.ColdToleranceB.MCValue = dB2104Helper.GetBColWater.Tolerance;
|
|
TextE.HotToleranceA.MCValue = dB2104Helper.GetAHotWater.Tolerance;
|
|
TextE.HotToleranceB.MCValue = dB2104Helper.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();
|
|
|
|
string[] s = new string[8];
|
|
for (int i = 1; i <= 8; i++)
|
|
{
|
|
s[i - 1] = "产线" + i;
|
|
}
|
|
ComboE.PasteChooseWet.DataSource = s;
|
|
string[] s1 = new string[4];
|
|
for (int i = 1; i <= 4; i++)
|
|
{
|
|
s1[i - 1] = "产线" + i;
|
|
}
|
|
ComboE.PasteChooseDry.DataSource = s1;
|
|
|
|
var dataA = GetTableA();
|
|
var dataB = GetTableB();
|
|
ComboE.CALeftOrRight.DataSource = dataA.Copy();
|
|
ComboE.HALeftOrRight.DataSource = dataA.Copy();
|
|
ComboE.CBLeftOrRight.DataSource = dataB.Copy();
|
|
ComboE.HBLeftOrRight.DataSource = dataB.Copy();
|
|
|
|
var ha = dB2104Helper.GetAHotWater;
|
|
TextE.HADeviation.MCValue = ha.differ;
|
|
ComboE.HALeftOrRight.MCValue = ha.stand;
|
|
|
|
var hb = dB2104Helper.GetBHotWater;
|
|
TextE.HBDeviation.MCValue = hb.differ;
|
|
ComboE.HBLeftOrRight.MCValue = hb.stand;
|
|
|
|
var ca = dB2104Helper.GetAColWater;
|
|
TextE.CADeviation.MCValue = ca.differ;
|
|
ComboE.CALeftOrRight.MCValue = ca.stand;
|
|
|
|
var cb = dB2104Helper.GetBColWater;
|
|
TextE.CBDeviation.MCValue = cb.differ;
|
|
ComboE.CBLeftOrRight.MCValue = cb.stand;
|
|
|
|
if (!DB2105WriteHelper.GetWaterStatus()[0])
|
|
{
|
|
buttonE.CAOnOff.Text = "停止称量";
|
|
}
|
|
else
|
|
{
|
|
buttonE.CAOnOff.Text = "恢复称量";
|
|
}
|
|
|
|
if (!DB2105WriteHelper.GetWaterStatus()[1])
|
|
{
|
|
buttonE.HAOnOff.Text = "停止称量";
|
|
}
|
|
else
|
|
{
|
|
buttonE.HAOnOff.Text = "恢复称量";
|
|
}
|
|
|
|
if (!DB2105WriteHelper.GetWaterStatus()[2])
|
|
{
|
|
buttonE.CBOnOff.Text = "停止称量";
|
|
}
|
|
else
|
|
{
|
|
buttonE.CBOnOff.Text = "恢复称量";
|
|
}
|
|
|
|
if (!DB2105WriteHelper.GetWaterStatus()[3])
|
|
{
|
|
buttonE.HBOnOff.Text = "停止称量";
|
|
}
|
|
else
|
|
{
|
|
buttonE.HBOnOff.Text = "恢复称量";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private DataTable GetTableA()
|
|
{
|
|
var dataTable = GetDefaultTable();
|
|
DataRow dr = dataTable.NewRow();
|
|
|
|
dr[0] = "2";
|
|
dr[1] = "1,2";
|
|
dataTable.Rows.Add(dr);
|
|
dr = dataTable.NewRow();
|
|
dr[0] = "1";
|
|
dr[1] = "3,4";
|
|
dataTable.Rows.Add(dr);
|
|
|
|
return dataTable;
|
|
}
|
|
|
|
private DataTable GetDefaultTable()
|
|
{
|
|
DataTable dataTable = new DataTable();
|
|
dataTable.Columns.Add("CmbValue", typeof(string));
|
|
dataTable.Columns.Add("CmbDisplay", typeof(string));
|
|
return dataTable;
|
|
}
|
|
|
|
private DataTable GetTableB()
|
|
{
|
|
|
|
var dataTable = GetDefaultTable();
|
|
DataRow dr = dataTable.NewRow();
|
|
dr[0] = "2";
|
|
dr[1] = "5,6";
|
|
dataTable.Rows.Add(dr);
|
|
dr = dataTable.NewRow();
|
|
dr[0] = "1";
|
|
dr[1] = "7,8";
|
|
dataTable.Rows.Add(dr);
|
|
|
|
return dataTable;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|