add - 自动状态改变显示

wangsr
wangsr 1 year ago
parent 5ad4008138
commit f96ab5dfec

@ -41,14 +41,15 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.Entity
public IBaseControl WetOutDelayTime { get; set; }
public IBaseControl ManualWeight { get; set; }
public IBaseControl ManualTolerance { get; set; }
public IBaseControl State1 { get; set; }
public IBaseControl State2 { get; set; }
public IBaseControl State3 { get; set; }
public IBaseControl State4 { get; set; }
public IBaseControl State5 { get; set; }
public IBaseControl State6 { get; set; }
public IBaseControl State7 { get; set; }
public IBaseControl State8 { get; set; }
public MCLabel State1 { get; set; }
public MCLabel State2 { get; set; }
public MCLabel State3 { get; set; }
public MCLabel State4 { get; set; }
public MCLabel State5 { get; set; }
public MCLabel State6 { get; set; }
public MCLabel State7 { get; set; }
public MCLabel State8 { get; set; }
public Button WetManualControl { get; set; }
public Button Download { get; set; }

@ -7,18 +7,12 @@ using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
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;
using System.Data;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Steema.TeeChart.Functions;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
@ -63,20 +57,40 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
int bin1 = Convert.ToInt32(ControlsEntity.ChooseMaterial1.MCValue.ToString());
int bin2 = Convert.ToInt32(ControlsEntity.ChooseMaterial2.MCValue.ToString());
List<RecipePlcView> recipes = new List<RecipePlcView>();
float t1 = Convert.ToSingle(ControlsEntity.MaterialTolerance1.MCValue.ToString());
float t2 = Convert.ToSingle(ControlsEntity.MaterialTolerance2.MCValue.ToString());
if(bin2 == -1)
{
if (t1 < 0.1)
{
MessageBox.Show("公差不能小于0.1");
return;
}
}
else
{
if (t1 < 0.1 || t2 < 0.1)
{
MessageBox.Show("公差不能小于0.1");
return;
}
}
RecipePlcView recipe1 = new RecipePlcView()
{
Bin = (short)StockMaterrialDbHelp.GetCodeById(bin1),
Set = Convert.ToSingle(ControlsEntity.MaterialWeight1.MCValue.ToString()),
Tolerance = Convert.ToSingle(ControlsEntity.MaterialTolerance1.MCValue.ToString()),
Tolerance = t1,
};
RecipePlcView recipe2 = new RecipePlcView()
{
Bin = (short)StockMaterrialDbHelp.GetCodeById(bin2),
Set = Convert.ToSingle(ControlsEntity.MaterialWeight2.MCValue.ToString()),
Tolerance = Convert.ToSingle(ControlsEntity.MaterialTolerance2.MCValue.ToString()),
Tolerance = t2,
};
recipes.Add(recipe1);
@ -451,10 +465,18 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
return;
}
float t = Convert.ToSingle(ControlsEntity.ManualTolerance.MCValue.ToString());
if (t < 0.1)
{
MessageBox.Show("公差不能小于0.1");
return;
}
SetValue value = new SetValue()
{
Value = Convert.ToSingle(ControlsEntity.ManualWeight.MCValue.ToString()),
Toterance = Convert.ToSingle(ControlsEntity.ManualTolerance.MCValue.ToString())
Toterance = t
};
switch (SingleSelect())

@ -1,4 +1,5 @@
using DevExpress.DataAccess.Wizard.Presenters;
using DataBlockHelper.DBHelpers;
using DevExpress.DataAccess.Wizard.Presenters;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
@ -51,9 +52,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
timer = new Timer();
timer.Interval = 1000;
timer.Enabled = true;
//timer.Tick += new EventHandler(StateRefresh);//添加事件
timer.Tick += new EventHandler(StateRefresh);//添加事件
}
#region 前端状态
private void StateRefresh(object sender, EventArgs e)
{
if (GetAllDbMCControlsByOption(DbOptionTypes.QueryAndModify).Count == 0)
@ -62,7 +65,51 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
timer.Dispose();
}
DB2105Helper dB2105Helper = new DB2105Helper();
var startJob = dB2105Helper.GetStartJob;
ControlsEntity.State1.MCValue = ConvertOnOff(startJob[0].Val);
ControlsEntity.State2.MCValue = ConvertOnOff(startJob[1].Val);
ControlsEntity.State3.MCValue = ConvertOnOff(startJob[2].Val);
ControlsEntity.State4.MCValue = ConvertOnOff(startJob[3].Val);
ControlsEntity.State5.MCValue = ConvertOnOff(startJob[4].Val);
ControlsEntity.State6.MCValue = ConvertOnOff(startJob[5].Val);
ControlsEntity.State7.MCValue = ConvertOnOff(startJob[6].Val);
ControlsEntity.State8.MCValue = ConvertOnOff(startJob[7].Val);
ControlsEntity.State1.BackColor = ConvertColor(startJob[0].Val);
ControlsEntity.State2.BackColor = ConvertColor(startJob[1].Val);
ControlsEntity.State3.BackColor = ConvertColor(startJob[2].Val);
ControlsEntity.State4.BackColor = ConvertColor(startJob[3].Val);
ControlsEntity.State5.BackColor = ConvertColor(startJob[4].Val);
ControlsEntity.State6.BackColor = ConvertColor(startJob[5].Val);
ControlsEntity.State7.BackColor = ConvertColor(startJob[6].Val);
ControlsEntity.State8.BackColor = ConvertColor(startJob[7].Val);
}
private string ConvertOnOff(bool state)
{
if (state)
{
return "启动";
}
else
{
return "停止";
}
}
private Color ConvertColor(bool state)
{
if (state)
{
return Color.LightGreen;
}
else
{
return Color.Transparent;
}
}
private void Mcradion_CheckedChanged(object sender, EventArgs e)
@ -76,9 +123,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
ControlsEntity.Line6.BackColor = backColor;
ControlsEntity.Line7.BackColor = backColor;
ControlsEntity.Line8.BackColor = backColor;
mCRadio.BackColor = Color.LightGreen;
mCRadio.BackColor = Color.LightSkyBlue;
}
#endregion
/// <summary>
/// 控件从Plc初始化
/// </summary>
@ -179,8 +228,17 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
ControlsEntity.Line7 = GetMCRadioButtonControl("Line7");
ControlsEntity.Line8 = GetMCRadioButtonControl("Line8");
ControlsEntity.State1 = GetBaseControl("State1") as MCLabel;
ControlsEntity.State2 = GetBaseControl("State2") as MCLabel;
ControlsEntity.State3 = GetBaseControl("State3") as MCLabel;
ControlsEntity.State4 = GetBaseControl("State4") as MCLabel;
ControlsEntity.State5 = GetBaseControl("State5") as MCLabel;
ControlsEntity.State6 = GetBaseControl("State6") as MCLabel;
ControlsEntity.State7 = GetBaseControl("State7") as MCLabel;
ControlsEntity.State8 = GetBaseControl("State8") as MCLabel;
ControlsEntity.ChooseMaterial1 = GetBaseControl("ChooseMaterial1") as MCCombobox;
ControlsEntity.ChooseMaterial2 = GetBaseControl("ChooseMaterial2") as MCCombobox;;
ControlsEntity.ChooseMaterial2 = GetBaseControl("ChooseMaterial2") as MCCombobox;
ControlsEntity.MaterialWeight1 = GetBaseControl("MaterialWeight1");
ControlsEntity.MaterialWeight2 = GetBaseControl("MaterialWeight2");

@ -12,7 +12,7 @@ namespace DataBlockHelper.DBHelpers
{
public DB2105Helper()
{
this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 52).Content;
this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 126).Content;
}
public List<PlanEntity> Plan => new PlanArrayManager(4, 0, 12, bytes).GetList();
public bool[] Status => new FourBoolArrayManager(48, bytes).GetList();

@ -77,8 +77,7 @@
</Object>
<Object type="System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="GroupBox34" children="Controls">
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State8" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -91,34 +90,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">825, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">807, 61</Property>
<Property name="Name">State8</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel37" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">776, 61</Property>
<Property name="Name">MCLabel37</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State7" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -131,34 +109,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">715, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">697, 61</Property>
<Property name="Name">State7</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel39" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">666, 61</Property>
<Property name="Name">MCLabel39</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State6" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -171,34 +128,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">605, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">587, 61</Property>
<Property name="Name">State6</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel41" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">556, 61</Property>
<Property name="Name">MCLabel41</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State5" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -211,34 +147,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">495, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">477, 61</Property>
<Property name="Name">State5</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel43" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">446, 61</Property>
<Property name="Name">MCLabel43</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State4" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -251,34 +166,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">385, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">367, 61</Property>
<Property name="Name">State4</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel45" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">336, 61</Property>
<Property name="Name">MCLabel45</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State3" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -291,34 +185,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">275, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">257, 61</Property>
<Property name="Name">State3</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel47" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">226, 61</Property>
<Property name="Name">MCLabel47</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State2" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -331,34 +204,13 @@
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">165, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">147, 61</Property>
<Property name="Name">State2</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel49" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">116, 61</Property>
<Property name="Name">MCLabel49</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="State1" children="Controls">
<Property name="Format">
</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
@ -371,30 +223,10 @@
<Property name="DbOptionType">QueryAndModify</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text"></Property>
<Property name="Location">55, 61</Property>
<Property name="Text">停止</Property>
<Property name="Location">37, 61</Property>
<Property name="Name">State1</Property>
<Property name="Size">24, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel52" children="Controls">
<Property name="Format">
</Property>
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="MCKey" />
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="Text">状态:</Property>
<Property name="Location">6, 61</Property>
<Property name="Name">MCLabel52</Property>
<Property name="Size">56, 16</Property>
<Property name="Size">40, 16</Property>
</Object>
<Object type="Mesnac.Controls.Default.MCRadioButton, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="Line4" children="Controls">
<Property name="ClickActionList">

Loading…
Cancel
Save