dep_deliver
杨威 8 months ago
parent 7ba2510fb0
commit f2676d80f9

@ -0,0 +1,457 @@
using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity;
using Mesnac.Action.Base;
using Mesnac.Controls.ChemicalWeighing;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Dan
{
public class InitAction : ChemicalWeighingAction, IAction
{
MCCheckBox cbkA;
MCTextBox txtBoxA;
HslLanternSimple HslA;
MCCheckBox cbkB;
MCTextBox txtBoxB;
HslLanternSimple HslB;
MCCheckBox cbkC;
MCTextBox txtBoxC;
HslLanternSimple HslC;
MCCheckBox cbkD;
MCTextBox txtBoxD;
HslLanternSimple HslD;
MCCheckBox cbkE;
MCTextBox txtBoxE;
HslLanternSimple HslE;
MCCheckBox cbkF;
MCTextBox txtBoxF;
HslLanternSimple HslF;
MCCheckBox cbkG;
MCTextBox txtBoxG;
HslLanternSimple HslG;
MCCheckBox cbkH;
MCTextBox txtBoxH;
HslLanternSimple HslH;
MCCheckBox cbkI;
MCTextBox txtBoxI;
HslLanternSimple HslI;
MCCheckBox cbkJ;
MCTextBox txtBoxJ;
HslLanternSimple HslJ;
MCCheckBox cbkK;
MCTextBox txtBoxK;
HslLanternSimple HslK;
MCCheckBox cbkL;
MCTextBox txtBoxL;
HslLanternSimple HslL;
MCCheckBox cbkM;
MCTextBox txtBoxM;
HslLanternSimple HslM;
MCCheckBox cbkN;
MCTextBox txtBoxN;
HslLanternSimple HslN;
MCCheckBox cbkO;
MCTextBox txtBoxO;
HslLanternSimple HslO;
MCButton MCButton1;
List<Control> controll;
Timer timer;
public void Run(RuntimeParameter runtime)
{
RunIni(runtime);
controll = GetAllControls();
timer = new Timer();
timer.Interval = 1000;
timer.Enabled = true;
timer.Tick += GetPlcValue;//添加事件
MCButton1 = controll.FirstOrDefault(x => x.Name == "MCButton1") as MCButton;
MCButton1.Click += MCButton1_Click;
cbkA = controll.FirstOrDefault(x => x.Name == "cbkA") as MCCheckBox;
cbkB = controll.FirstOrDefault(x => x.Name == "cbkB") as MCCheckBox;
cbkC = controll.FirstOrDefault(x => x.Name == "cbkC") as MCCheckBox;
cbkD = controll.FirstOrDefault(x => x.Name == "cbkD") as MCCheckBox;
cbkE = controll.FirstOrDefault(x => x.Name == "cbkE") as MCCheckBox;
cbkF = controll.FirstOrDefault(x => x.Name == "cbkF") as MCCheckBox;
cbkG = controll.FirstOrDefault(x => x.Name == "cbkG") as MCCheckBox;
cbkH = controll.FirstOrDefault(x => x.Name == "cbkH") as MCCheckBox;
cbkI = controll.FirstOrDefault(x => x.Name == "cbkI") as MCCheckBox;
cbkJ = controll.FirstOrDefault(x => x.Name == "cbkJ") as MCCheckBox;
cbkK = controll.FirstOrDefault(x => x.Name == "cbkK") as MCCheckBox;
cbkL = controll.FirstOrDefault(x => x.Name == "cbkL") as MCCheckBox;
cbkM = controll.FirstOrDefault(x => x.Name == "cbkM") as MCCheckBox;
cbkN = controll.FirstOrDefault(x => x.Name == "cbkN") as MCCheckBox;
cbkO = controll.FirstOrDefault(x => x.Name == "cbkO") as MCCheckBox;
txtBoxA = controll.FirstOrDefault(x => x.Name == "txtBoxA") as MCTextBox;
txtBoxB = controll.FirstOrDefault(x => x.Name == "txtBoxB") as MCTextBox;
txtBoxC = controll.FirstOrDefault(x => x.Name == "txtBoxC") as MCTextBox;
txtBoxD = controll.FirstOrDefault(x => x.Name == "txtBoxD") as MCTextBox;
txtBoxE = controll.FirstOrDefault(x => x.Name == "txtBoxE") as MCTextBox;
txtBoxF = controll.FirstOrDefault(x => x.Name == "txtBoxF") as MCTextBox;
txtBoxG = controll.FirstOrDefault(x => x.Name == "txtBoxG") as MCTextBox;
txtBoxH = controll.FirstOrDefault(x => x.Name == "txtBoxH") as MCTextBox;
txtBoxI = controll.FirstOrDefault(x => x.Name == "txtBoxI") as MCTextBox;
txtBoxJ = controll.FirstOrDefault(x => x.Name == "txtBoxJ") as MCTextBox;
txtBoxK = controll.FirstOrDefault(x => x.Name == "txtBoxK") as MCTextBox;
txtBoxL = controll.FirstOrDefault(x => x.Name == "txtBoxL") as MCTextBox;
txtBoxM = controll.FirstOrDefault(x => x.Name == "txtBoxM") as MCTextBox;
txtBoxN = controll.FirstOrDefault(x => x.Name == "txtBoxN") as MCTextBox;
txtBoxO = controll.FirstOrDefault(x => x.Name == "txtBoxO") as MCTextBox;
HslA = controll.FirstOrDefault(x => x.Name == "HslA") as HslLanternSimple;
HslB = controll.FirstOrDefault(x => x.Name == "HslB") as HslLanternSimple;
HslC = controll.FirstOrDefault(x => x.Name == "HslC") as HslLanternSimple;
HslD = controll.FirstOrDefault(x => x.Name == "HslD") as HslLanternSimple;
HslE = controll.FirstOrDefault(x => x.Name == "HslE") as HslLanternSimple;
HslF = controll.FirstOrDefault(x => x.Name == "HslF") as HslLanternSimple;
HslG = controll.FirstOrDefault(x => x.Name == "HslG") as HslLanternSimple;
HslH = controll.FirstOrDefault(x => x.Name == "HslH") as HslLanternSimple;
HslI = controll.FirstOrDefault(x => x.Name == "HslI") as HslLanternSimple;
HslJ = controll.FirstOrDefault(x => x.Name == "HslJ") as HslLanternSimple;
HslK = controll.FirstOrDefault(x => x.Name == "HslK") as HslLanternSimple;
HslL = controll.FirstOrDefault(x => x.Name == "HslL") as HslLanternSimple;
HslM = controll.FirstOrDefault(x => x.Name == "HslM") as HslLanternSimple;
HslN = controll.FirstOrDefault(x => x.Name == "HslN") as HslLanternSimple;
HslO = controll.FirstOrDefault(x => x.Name == "HslO") as HslLanternSimple;
}
private void MCButton1_Click(object sender, EventArgs e)
{
Db2101WriteHelp db2101WriteHelp = new Db2101WriteHelp();
short val = 0;
Db2101Entity entityA = new Db2101Entity();
if (cbkA.Checked)
{
val = short.Parse(txtBoxA.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityA.time = val;
}
entityA.enable = cbkA.Checked;
Db2101Entity entityB = new Db2101Entity();
if (cbkB.Checked)
{
val = short.Parse(txtBoxB.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityB.time = val;
}
entityB.enable = cbkB.Checked;
Db2101Entity entityC = new Db2101Entity();
if (cbkC.Checked)
{
val = short.Parse(txtBoxC.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityC.time = val;
}
entityC.enable = cbkC.Checked;
Db2101Entity entityD = new Db2101Entity();
if (cbkD.Checked)
{
val = short.Parse(txtBoxD.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityD.time = val;
}
entityD.enable = cbkD.Checked;
Db2101Entity entityE = new Db2101Entity();
if (cbkE.Checked)
{
val = short.Parse(txtBoxE.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityE.time = val;
}
entityE.enable = cbkE.Checked;
Db2101Entity entityF = new Db2101Entity();
if (cbkF.Checked)
{
val = short.Parse(txtBoxF.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityF.time = val;
}
entityF.enable = cbkF.Checked;
Db2101Entity entityG = new Db2101Entity();
if (cbkG.Checked)
{
val = short.Parse(txtBoxG.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityG.time = val;
}
entityG.enable = cbkG.Checked;
Db2101Entity entityH = new Db2101Entity();
if (cbkH.Checked)
{
val = short.Parse(txtBoxH.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityH.time = val;
}
entityH.enable = cbkH.Checked;
Db2101Entity entityI = new Db2101Entity();
if (cbkI.Checked)
{
val = short.Parse(txtBoxI.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityI.time = val;
}
entityI.enable = cbkI.Checked;
Db2101Entity entityJ = new Db2101Entity();
if (cbkJ.Checked)
{
val = short.Parse(txtBoxJ.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityJ.time = val;
}
entityJ.enable = cbkJ.Checked;
Db2101Entity entityK = new Db2101Entity();
if (cbkK.Checked)
{
val = short.Parse(txtBoxK.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityK.time = val;
}
entityK.enable = cbkK.Checked;
Db2101Entity entityL = new Db2101Entity();
if (cbkL.Checked)
{
val = short.Parse(txtBoxL.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityL.time = val;
}
entityL.enable = cbkL.Checked;
Db2101Entity entityM = new Db2101Entity();
if (cbkM.Checked)
{
val = short.Parse(txtBoxM.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityM.time = val;
}
entityM.enable = cbkM.Checked;
Db2101Entity entityN = new Db2101Entity();
if (cbkN.Checked)
{
val = short.Parse(txtBoxN.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityN.time = val;
}
entityN.enable = cbkN.Checked;
Db2101Entity entityO = new Db2101Entity();
if (cbkO.Checked)
{
val = short.Parse(txtBoxO.MCValue.ToString());
if (val <= 0 || val > 100)
{
MessageBox.Show("冲氮气时间范围[1-100]");
return;
}
entityO.time = val;
}
entityO.enable = cbkO.Checked;
db2101WriteHelp.WriteA(entityA);
db2101WriteHelp.WriteB(entityB);
db2101WriteHelp.WriteC(entityC);
db2101WriteHelp.WriteD(entityD);
db2101WriteHelp.WriteE(entityE);
db2101WriteHelp.WriteF(entityF);
db2101WriteHelp.WriteG(entityG);
db2101WriteHelp.WriteH(entityH);
db2101WriteHelp.WriteI(entityI);
db2101WriteHelp.WriteJ(entityJ);
db2101WriteHelp.WriteK(entityK);
db2101WriteHelp.WriteL(entityL);
db2101WriteHelp.WriteM(entityM);
db2101WriteHelp.WriteN(entityN);
db2101WriteHelp.WriteO(entityO);
db2101WriteHelp.WriteStart();
MessageBox.Show("开始充氮气");
}
private void GetPlcValue(object sender, EventArgs e)
{
if (GetAllControls().Count == 0)
{
timer.Stop();
timer.Dispose();
timer = null;
}
Db2101Helper db=new Db2101Helper();
Ch(cbkA, txtBoxA, HslA, db.SiloA);
Ch(cbkB, txtBoxB, HslB, db.SiloB);
Ch(cbkC, txtBoxC, HslC, db.SiloC);
Ch(cbkD, txtBoxD, HslD, db.SiloD);
Ch(cbkE, txtBoxE, HslE, db.SiloE);
Ch(cbkF, txtBoxF, HslF, db.SiloF);
Ch(cbkG, txtBoxG, HslG, db.SiloG);
Ch(cbkH, txtBoxH, HslH, db.SiloH);
Ch(cbkI, txtBoxI, HslI, db.SiloI);
Ch(cbkJ, txtBoxJ, HslJ, db.SiloJ);
Ch(cbkK, txtBoxK, HslK, db.SiloK);
Ch(cbkL, txtBoxL, HslL, db.SiloL);
Ch(cbkM, txtBoxM, HslM, db.SiloM);
Ch(cbkN, txtBoxN, HslN, db.SiloN);
Ch(cbkO, txtBoxO, HslO, db.Siloo);
}
private void Ch(MCCheckBox cb,MCTextBox cTextBox,HslLanternSimple simple,Db2101Entity entity)
{
cb.Checked = entity.enable;
cTextBox.MCValue = entity.time;
if (entity.finished) {
simple.LanternBackground = System.Drawing.Color.Green;
}
else
{
simple.LanternBackground = System.Drawing.Color.Gray;
}
}
}
}

@ -257,6 +257,7 @@
<Compile Include="ChemicalWeighingPlc\PlcPlanHelper.cs" />
<Compile Include="ChemicalWeighingPlc\PlcRecipeHelper.cs" />
<Compile Include="ChemicalWeighingPlc\PlcStorageBinParaSetHelper.cs" />
<Compile Include="Dan\InitAction.cs" />
<Compile Include="DeviceParamManage\InitDeviceParamInfo.cs" />
<Compile Include="DeviceParamManage\SelectDeviceParamInfo.cs" />
<Compile Include="DeviceParamManage\WriteDeviceParamInfo.cs" />

@ -0,0 +1,130 @@
using DataBlockHelper.Entity;
using HslCommunication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.DBHelpers
{
public class Db2101Helper : DBHelper
{
public Db2101Helper()
{
OperateResult<byte[]> db = PlcConnect.Instance.Read("DB2101.0.0", 62);
bytes = db.Content;
}
public bool Start => PlcConnect.Instance.ByteTransform.TransBool(bytes, 0);
public Db2101Entity SiloA=>new Db2101Entity(2,bytes);
public Db2101Entity SiloB => new Db2101Entity(6, bytes);
public Db2101Entity SiloC => new Db2101Entity(10, bytes);
public Db2101Entity SiloD => new Db2101Entity(14, bytes);
public Db2101Entity SiloE => new Db2101Entity(18, bytes);
public Db2101Entity SiloF => new Db2101Entity(22, bytes);
public Db2101Entity SiloG => new Db2101Entity(26, bytes);
public Db2101Entity SiloH => new Db2101Entity(30, bytes);
public Db2101Entity SiloI => new Db2101Entity(34, bytes);
public Db2101Entity SiloJ => new Db2101Entity(38, bytes);
public Db2101Entity SiloK => new Db2101Entity(42, bytes);
public Db2101Entity SiloL => new Db2101Entity(46, bytes);
public Db2101Entity SiloM => new Db2101Entity(50, bytes);
public Db2101Entity SiloN => new Db2101Entity(54, bytes);
public Db2101Entity Siloo => new Db2101Entity(58, bytes);
}
public class Db2101WriteHelp
{
public Db2101WriteHelp() { }
public bool WriteStart()
{
PlcConnect.Instance.Write("DB2101.0.0", true);
return true;
}
public bool Write(int begin, Db2101Entity entity)
{
PlcConnect.Instance.Write($"DB2101.{begin}.0", entity.enable);
// PlcConnect.Instance.Write($"DB2101.{begin}.1", entity.finished);
PlcConnect.Instance.Write($"DB2101.{begin+2}.0", entity.time);
return true;
}
public bool WriteA(Db2101Entity entity)
{
return Write(2, entity);
}
public bool WriteB(Db2101Entity entity)
{
return Write(6, entity);
}
public bool WriteC(Db2101Entity entity)
{
return Write(10, entity);
}
public bool WriteD(Db2101Entity entity)
{
return Write(14, entity);
}
public bool WriteE(Db2101Entity entity)
{
return Write(18, entity);
}
public bool WriteF(Db2101Entity entity)
{
return Write(22, entity);
}
public bool WriteG(Db2101Entity entity)
{
return Write(26, entity);
}
public bool WriteH(Db2101Entity entity)
{
return Write(30, entity);
}
public bool WriteI(Db2101Entity entity)
{
return Write(34, entity);
}
public bool WriteJ(Db2101Entity entity)
{
return Write(38, entity);
}
public bool WriteK(Db2101Entity entity)
{
return Write(42, entity);
}
public bool WriteL(Db2101Entity entity)
{
return Write(46, entity);
}
public bool WriteM(Db2101Entity entity)
{
return Write(50, entity);
}
public bool WriteN(Db2101Entity entity)
{
return Write(54, entity);
}
public bool WriteO(Db2101Entity entity)
{
return Write(58, entity);
}
}
}

@ -59,6 +59,7 @@
<Compile Include="DBHelpers\DB191Helper.cs" />
<Compile Include="DBHelpers\DB191WriteHelper.cs" />
<Compile Include="DBHelpers\DB1Helper.cs" />
<Compile Include="DBHelpers\Db2101Helper.cs" />
<Compile Include="DBHelpers\DB2102Helper.cs" />
<Compile Include="DBHelpers\DB2103Helper.cs" />
<Compile Include="DBHelpers\DB2104Helper.cs" />
@ -85,6 +86,7 @@
<Compile Include="Entity\DB191Entity\ForConveyorStep.cs" />
<Compile Include="Entity\DB1Entity\ForAnaLogIn.cs" />
<Compile Include="Entity\DB1Entity\ForAnaLogOut.cs" />
<Compile Include="Entity\Db2101Entity.cs" />
<Compile Include="Entity\DB2102Entity\FOR_VALVE_DoubleEntity.cs" />
<Compile Include="Entity\DB2102Entity\FOR_VALVE_SingleEntity.cs" />
<Compile Include="Entity\DB2103Entity\FOR_MOTOREntity.cs" />

@ -0,0 +1,36 @@
using DataBlockHelper.DBHelpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace DataBlockHelper.Entity
{
public class Db2101Entity
{
public Db2101Entity() { }
public Db2101Entity(ushort startSet, byte[] bytes)
{
byte[] content = bytes.Skip(startSet).Take(4).ToArray();
var trans = PlcConnect.Instance.ByteTransform;
var a = content[0];
var b = content[1];
enable = a.GetBit(0);
finished = a.GetBit(1);
time= trans.TransInt16(content,2);
}
public bool enable { get; set; }
public bool finished { get; set; }
public short time { get; set; }
}
}

@ -25,7 +25,7 @@ namespace DataBlockHelper
//输送IP
// s7.IpAddress = "192.168.1.110";
//配料IP
s7.IpAddress = "172.18.4.110";
s7.Port = 102;

@ -28,7 +28,7 @@
<Runtime>
<Import assembly = "Data/Action/ChemicalWeighing/Mesnac.Action.ChemicalWeighing.dll">
<Action action="581699a771f1480a9145153685aa05ce" class="Mesnac.Action.ChemicalWeighing.Report.WetMixer.InitFormAction"/>
<Action action="3737e414f2ac49478fead12379554293" class="Mesnac.Action.ChemicalWeighing.Test.TestAction"/>
<Action action="3737e414f2ac49478fead12379554293" class="Mesnac.Action.ChemicalWeighing.Dan.InitAction"/>
</Import>
</Runtime>
</ActionService>

@ -36,6 +36,7 @@
<Node Name="LjLogForm" Text="榄菊生产日志" ToolTipText="LjLogForm" Tag="LjLogForm" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="DeliverPressureSetting" Text="输送压送罐参数设置" ToolTipText="DeliverPressureSetting" Tag="DeliverPressureSetting" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="DeliverControlBoard" Text="输送操作面板" ToolTipText="DeliverControlBoard" Tag="DeliverControlBoard" ImageIndex="3" SelectedImageIndex="3" />
<Node Name="FormDanQi" Text="氮气设置" ToolTipText="FormDanQi" Tag="FormDanQi" ImageIndex="3" SelectedImageIndex="3" />
</Node>
<Node Name="nodeDevice" Text="设备" ToolTipText="" Tag="nodeDevice" ImageIndex="2" SelectedImageIndex="2" />
<Node Name="nodeDataSource" Text="数据源" ToolTipText="" Tag="nodeDataSource" ImageIndex="6" SelectedImageIndex="6">

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save