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/ManualControl/ManualControlAction.cs

1082 lines
39 KiB
C#

using DataBlockHelper;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.InterfaceDocking;
using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity;
using Mesnac.Basic;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
using Mesnac.Core.Service;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
class ManualControlAction : ChemicalWeighingAction, IAction
{
private List<DbMCControl> McControllist;
private byte GelChooseA;
private byte GelChooseB;
private byte WetChoose1;
private byte WetChoose2;
private byte WetChoose3;
private byte WetChoose4;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
#region 控件导入
McControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
IBaseControl StartMetage1 = GetBaseControl("StartMetage1");
IBaseControl StopMetage1 = GetBaseControl("StopMetage1");
IBaseControl StartMetage2 = GetBaseControl("StartMetage2");
IBaseControl StopMetage2 = GetBaseControl("StopMetage2");
IBaseControl StartMetage3 = GetBaseControl("StartMetage3");
IBaseControl StopMetage3 = GetBaseControl("StopMetage3");
IBaseControl StartMetage4 = GetBaseControl("StartMetage4");
IBaseControl StopMetage4 = GetBaseControl("StopMetage4");
IBaseControl WaterOut1 = GetBaseControl("WaterOut1");
IBaseControl WaterOut2 = GetBaseControl("WaterOut2");
IBaseControl WaterOut3 = GetBaseControl("WaterOut3");
IBaseControl WaterOut4 = GetBaseControl("WaterOut4");
1 year ago
IBaseControl WaterStop1 = GetBaseControl("WaterStop1");
IBaseControl WaterStop2 = GetBaseControl("WaterStop2");
IBaseControl WaterStop3 = GetBaseControl("WaterStop3");
IBaseControl WaterStop4 = GetBaseControl("WaterStop4");
IBaseControl SpiralOn1 = GetBaseControl("SpiralOn1");
IBaseControl SpiralOn2 = GetBaseControl("SpiralOn2");
IBaseControl SpiralOn3 = GetBaseControl("SpiralOn3");
IBaseControl SpiralOn4 = GetBaseControl("SpiralOn4");
IBaseControl SpiralOff1 = GetBaseControl("SpiralOff1");
IBaseControl SpiralOff2 = GetBaseControl("SpiralOff2");
IBaseControl SpiralOff3 = GetBaseControl("SpiralOff3");
IBaseControl SpiralOff4 = GetBaseControl("SpiralOff4");
IBaseControl Gel1 = GetBaseControl("Gel1");
IBaseControl Gel2 = GetBaseControl("Gel2");
IBaseControl Gel3 = GetBaseControl("Gel3");
IBaseControl Gel4 = GetBaseControl("Gel4");
IBaseControl Gel5 = GetBaseControl("Gel5");
IBaseControl Gel6 = GetBaseControl("Gel6");
IBaseControl Gel7 = GetBaseControl("Gel7");
IBaseControl Gel8 = GetBaseControl("Gel8");
IBaseControl Wet1 = GetBaseControl("Wet1");
IBaseControl Wet2 = GetBaseControl("Wet2");
IBaseControl Wet3 = GetBaseControl("Wet3");
IBaseControl Wet4 = GetBaseControl("Wet4");
IBaseControl Wet5 = GetBaseControl("Wet5");
IBaseControl Wet6 = GetBaseControl("Wet6");
IBaseControl Wet7 = GetBaseControl("Wet7");
IBaseControl Wet8 = GetBaseControl("Wet8");
IBaseControl SetWaterValue1 = GetBaseControl("SetWaterValue1");
IBaseControl SetWaterValue2 = GetBaseControl("SetWaterValue2");
IBaseControl SetWaterValue3 = GetBaseControl("SetWaterValue3");
IBaseControl SetWaterValue4 = GetBaseControl("SetWaterValue4");
IBaseControl SetSpiralValue1 = GetBaseControl("SetSpiralValue1");
IBaseControl SetSpiralValue2 = GetBaseControl("SetSpiralValue2");
IBaseControl SetSpiralValue3 = GetBaseControl("SetSpiralValue3");
IBaseControl SetSpiralValue4 = GetBaseControl("SetSpiralValue4");
IBaseControl FastSpiralValue1 = GetBaseControl("FastSpiralValue1");
IBaseControl FastSpiralValue2 = GetBaseControl("FastSpiralValue2");
IBaseControl FastSpiralValue3 = GetBaseControl("FastSpiralValue3");
IBaseControl FastSpiralValue4 = GetBaseControl("FastSpiralValue4");
IBaseControl PointSpiralValue1 = GetBaseControl("PointSpiralValue1");
IBaseControl PointSpiralValue2 = GetBaseControl("PointSpiralValue2");
IBaseControl PointSpiralValue3 = GetBaseControl("PointSpiralValue3");
IBaseControl PointSpiralValue4 = GetBaseControl("PointSpiralValue4");
IBaseControl FastSpeedSpiralValue1 = GetBaseControl("FastSpeedSpiralValue1");
IBaseControl FastSpeedSpiralValue2 = GetBaseControl("FastSpeedSpiralValue2");
IBaseControl FastSpeedSpiralValue3 = GetBaseControl("FastSpeedSpiralValue3");
IBaseControl FastSpeedSpiralValue4 = GetBaseControl("FastSpeedSpiralValue4");
IBaseControl LowSpeedSpiralValue1 = GetBaseControl("LowSpeedSpiralValue1");
IBaseControl LowSpeedSpiralValue2 = GetBaseControl("LowSpeedSpiralValue2");
IBaseControl LowSpeedSpiralValue3 = GetBaseControl("LowSpeedSpiralValue3");
IBaseControl LowSpeedSpiralValue4 = GetBaseControl("LowSpeedSpiralValue4");
IBaseControl PointSpeedSpiralValue1 = GetBaseControl("PointSpeedSpiralValue1");
IBaseControl PointSpeedSpiralValue2 = GetBaseControl("PointSpeedSpiralValue2");
IBaseControl PointSpeedSpiralValue3 = GetBaseControl("PointSpeedSpiralValue3");
IBaseControl PointSpeedSpiralValue4 = GetBaseControl("PointSpeedSpiralValue4");
IBaseControl WetRequest1 = GetBaseControl("WetRequest1");
IBaseControl WetRequest2 = GetBaseControl("WetRequest2");
IBaseControl WetRequest3 = GetBaseControl("WetRequest3");
IBaseControl WetRequest4 = GetBaseControl("WetRequest4");
IBaseControl WetRequest5 = GetBaseControl("WetRequest5");
IBaseControl WetRequest6 = GetBaseControl("WetRequest6");
IBaseControl WetRequest7 = GetBaseControl("WetRequest7");
IBaseControl WetRequest8 = GetBaseControl("WetRequest8");
#endregion
#region 单选判断
if (Convert.ToBoolean(Gel1.MCValue) == true)
{
GelChooseA = 1;
}
if (Convert.ToBoolean(Gel2.MCValue) == true)
{
GelChooseA = 2;
}
if (Convert.ToBoolean(Gel3.MCValue) == true)
{
GelChooseA = 3;
}
if (Convert.ToBoolean(Gel4.MCValue) == true)
{
GelChooseA = 4;
}
if (Convert.ToBoolean(Gel5.MCValue) == true)
{
GelChooseB = 5;
}
if (Convert.ToBoolean(Gel6.MCValue) == true)
{
GelChooseB = 6;
}
if (Convert.ToBoolean(Gel7.MCValue) == true)
{
GelChooseB = 7;
}
if (Convert.ToBoolean(Gel8.MCValue) == true)
{
GelChooseB = 8;
}
if (Convert.ToBoolean(Wet1.MCValue) == true)
{
WetChoose1 = 1;
}
if (Convert.ToBoolean(Wet2.MCValue) == true)
{
WetChoose1 = 2;
}
if (Convert.ToBoolean(Wet3.MCValue) == true)
{
WetChoose2 = 3;
}
if (Convert.ToBoolean(Wet4.MCValue) == true)
{
WetChoose2 = 4;
}
if (Convert.ToBoolean(Wet5.MCValue) == true)
{
WetChoose3 = 5;
}
if (Convert.ToBoolean(Wet6.MCValue) == true)
{
WetChoose3 = 6;
}
if (Convert.ToBoolean(Wet7.MCValue) == true)
{
WetChoose4 = 7;
}
if (Convert.ToBoolean(Wet8.MCValue) == true)
{
WetChoose4 = 8;
}
#endregion
#region 按钮选择
if (StartMetage1 == runtime.Sender)
{
float value;
if (float.TryParse(Convert.ToString(SetWaterValue1.MCValue), out value))
{
if (MessageBox.Show("冷水称A确认开始称量", "称量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始称量" + value);
ManualLogControl("冷水称A开始称量 " + value);
PlcConnect.Instance.Write("DB2119.20.0", Convert.ToUInt16(value));
PlcConnect.Instance.Write("DB2119.28.0", true);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("冷水称A输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage1 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.28.1", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A称量已手动停止");
ManualLogControl("冷水称A称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (StartMetage2 == runtime.Sender)
{
float value;
if (float.TryParse(Convert.ToString(SetWaterValue2.MCValue), out value))
{
if (MessageBox.Show("热水称A确认开始称量", "称量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始称量" + value);
ManualLogControl("热水称A开始称量 " + value);
PlcConnect.Instance.Write("DB2119.0.0", Convert.ToUInt16(value));
PlcConnect.Instance.Write("DB2119.8.0", true);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("热水称A输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage2 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.8.1", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A称量已手动停止");
ManualLogControl("热水称A称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (StartMetage3 == runtime.Sender)
{
float value;
if (float.TryParse(Convert.ToString(SetWaterValue3.MCValue), out value))
{
if (MessageBox.Show("冷水称B确认开始称量", "称量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始称量" + value);
ManualLogControl("冷水称B开始称量 " + value);
PlcConnect.Instance.Write("DB2119.30.0", Convert.ToUInt16(value));
PlcConnect.Instance.Write("DB2119.38.0", true);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("冷水称B输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage3 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.38.1", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B称量已手动停止");
ManualLogControl("冷水称B称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (StartMetage4 == runtime.Sender)
{
float value;
if (float.TryParse(Convert.ToString(SetWaterValue4.MCValue), out value))
{
if (MessageBox.Show("热水称B确认开始称量", "称量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始称量" + value);
ManualLogControl("热水称B开始称量 " + value);
PlcConnect.Instance.Write("DB2119.10.0", Convert.ToUInt16(value));
PlcConnect.Instance.Write("DB2119.18.0", true);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("热水称B输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage4 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.18.1", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B称量已手动停止");
ManualLogControl("热水称B称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (WaterOut1 == runtime.Sender)
{
if (MessageBox.Show("冷水称A确认开始排水", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
switch (GelChooseA)
{
case 1:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅1排水");
ManualLogControl("冷水称A开始向糊化锅1排水");
break;
case 2:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅2排水");
ManualLogControl("冷水称A开始向糊化锅2排水");
break;
case 3:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅3排水");
ManualLogControl("冷水称A开始向糊化锅3排水");
break;
case 4:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅4排水");
ManualLogControl("冷水称A开始向糊化锅4排水");
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
}
if (WaterOut2 == runtime.Sender)
{
if (MessageBox.Show("热水称A确认开始排水", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
switch (GelChooseA)
{
case 1:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅1排水");
ManualLogControl("热水称A开始向糊化锅1排水");
break;
case 2:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅2排水");
ManualLogControl("热水称A开始向糊化锅2排水");
break;
case 3:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅3排水");
ManualLogControl("热水称A开始向糊化锅3排水");
break;
case 4:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅4排水");
ManualLogControl("热水称A开始向糊化锅4排水");
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
}
if (WaterOut3 == runtime.Sender)
{
if (MessageBox.Show("冷水称B确认开始排水", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
switch (GelChooseB)
{
case 5:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅5排水");
ManualLogControl("冷水称B开始向糊化锅5排水");
break;
case 6:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅6排水");
ManualLogControl("冷水称B开始向糊化锅6排水");
break;
case 7:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅7排水");
ManualLogControl("冷水称B开始向糊化锅7排水");
break;
case 8:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅8排水");
ManualLogControl("冷水称B开始向糊化锅8排水");
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
}
if (WaterOut4 == runtime.Sender)
{
if (MessageBox.Show("热水称B确认开始排水", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
switch (GelChooseB)
{
case 5:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅5排水");
ManualLogControl("热水称B开始向糊化锅5排水");
break;
case 6:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅6排水");
ManualLogControl("热水称B开始向糊化锅6排水");
break;
case 7:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅7排水");
ManualLogControl("热水称B开始向糊化锅7排水");
break;
case 8:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅8排水");
ManualLogControl("热水称B开始向糊化锅8排水");
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
}
1 year ago
if (WaterStop1 == runtime.Sender)
{
switch (GelChooseA)
{
case 1:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.28.5", true);
break;
case 2:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.28.5", true);
break;
case 3:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.28.5", true);
break;
case 4:
PlcConnect.Instance.Write("DB2119.26.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.28.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("冷水称A已停止排水");
ManualLogControl("冷水称A停止排水");
1 year ago
MesnacServiceManager.Instance.LoggingService.Info("冷水称A停止排水");
}
if (WaterStop2 == runtime.Sender)
{
switch (GelChooseA)
{
case 1:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.8.5", true);
break;
case 2:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.8.5", true);
break;
case 3:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.8.5", true);
break;
case 4:
PlcConnect.Instance.Write("DB2119.6.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.8.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("热水称A已停止排水");
ManualLogControl("热水称A停止排水");
1 year ago
MesnacServiceManager.Instance.LoggingService.Info("热水称A停止排水");
}
if (WaterStop3 == runtime.Sender)
{
switch (GelChooseB)
{
case 5:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.38.5", true);
break;
case 6:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.38.5", true);
break;
case 7:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.38.5", true);
break;
case 8:
PlcConnect.Instance.Write("DB2119.36.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.38.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("冷水称B已停止排水");
ManualLogControl("冷水称B停止排水");
1 year ago
MesnacServiceManager.Instance.LoggingService.Info("冷水称B停止排水");
}
if (WaterStop4 == runtime.Sender)
{
switch (GelChooseB)
{
case 5:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.18.5", true);
break;
case 6:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.18.5", true);
break;
case 7:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(3));
PlcConnect.Instance.Write("DB2119.18.5", true);
break;
case 8:
PlcConnect.Instance.Write("DB2119.16.0", Convert.ToUInt16(4));
PlcConnect.Instance.Write("DB2119.18.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("热水称B已停止排水");
ManualLogControl("热水称B停止排水");
1 year ago
MesnacServiceManager.Instance.LoggingService.Info("热水称B停止排水");
}
if (SpiralOn1 == runtime.Sender)
{
float valueSet;
float valueFast;
float valuePoint;
float valueSpeedFast;
float valueSpeedLow;
float valueSpeedPoint;
if (float.TryParse(Convert.ToString(SetSpiralValue1.MCValue), out valueSet) &&
float.TryParse(Convert.ToString(FastSpiralValue1.MCValue), out valueFast) &&
float.TryParse(Convert.ToString(PointSpiralValue1.MCValue), out valuePoint) &&
float.TryParse(Convert.ToString(FastSpeedSpiralValue1.MCValue), out valueSpeedFast) &&
float.TryParse(Convert.ToString(LowSpeedSpiralValue1.MCValue), out valueSpeedLow) &&
float.TryParse(Convert.ToString(PointSpeedSpiralValue1.MCValue), out valueSpeedPoint))
{
if (MessageBox.Show("螺旋1确认启动", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("螺旋1输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
switch (WetChoose1)
{
case 1:
PlcConnect.Instance.Write("DB2119.40.0", Convert.ToUInt16(valueSet));
PlcConnect.Instance.Write("DB2119.44.0", Convert.ToUInt16(valueFast));
PlcConnect.Instance.Write("DB2119.46.0", Convert.ToUInt16(valuePoint));
PlcConnect.Instance.Write("DB2119.50.0", Convert.ToUInt16(valueSpeedFast));
PlcConnect.Instance.Write("DB2119.52.0", Convert.ToUInt16(valueSpeedLow));
PlcConnect.Instance.Write("DB2119.54.0", Convert.ToUInt16(valueSpeedPoint));
PlcConnect.Instance.Write("DB2119.58.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.60.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动向湿混机1 " + valueSet);
ManualLogControl("螺旋1启动向湿混机1" + valueSet);
break;
case 2:
PlcConnect.Instance.Write("DB2119.40.0", Convert.ToUInt16(valueSet));
PlcConnect.Instance.Write("DB2119.44.0", Convert.ToUInt16(valueFast));
PlcConnect.Instance.Write("DB2119.46.0", Convert.ToUInt16(valuePoint));
PlcConnect.Instance.Write("DB2119.50.0", Convert.ToUInt16(valueSpeedFast));
PlcConnect.Instance.Write("DB2119.52.0", Convert.ToUInt16(valueSpeedLow));
PlcConnect.Instance.Write("DB2119.54.0", Convert.ToUInt16(valueSpeedPoint));
PlcConnect.Instance.Write("DB2119.58.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.60.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动向湿混机2 " + valueSet);
ManualLogControl("螺旋1启动向湿混机2 " + valueSet);
break;
default:
MessageBox.Show("请选择一个湿混机!");
return;
}
}
if (SpiralOn2 == runtime.Sender)
{
float valueSet;
float valueFast;
float valuePoint;
float valueSpeedFast;
float valueSpeedLow;
float valueSpeedPoint;
if (float.TryParse(Convert.ToString(SetSpiralValue2.MCValue), out valueSet) &&
float.TryParse(Convert.ToString(FastSpiralValue2.MCValue), out valueFast) &&
float.TryParse(Convert.ToString(PointSpiralValue2.MCValue), out valuePoint) &&
float.TryParse(Convert.ToString(FastSpeedSpiralValue2.MCValue), out valueSpeedFast) &&
float.TryParse(Convert.ToString(LowSpeedSpiralValue2.MCValue), out valueSpeedLow) &&
float.TryParse(Convert.ToString(PointSpeedSpiralValue2.MCValue), out valueSpeedPoint))
{
if (MessageBox.Show("螺旋2确认启动", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("螺旋2输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
switch (WetChoose2)
{
case 3:
PlcConnect.Instance.Write("DB2119.62.0", Convert.ToUInt16(valueSet));
PlcConnect.Instance.Write("DB2119.66.0", Convert.ToUInt16(valueFast));
PlcConnect.Instance.Write("DB2119.68.0", Convert.ToUInt16(valuePoint));
PlcConnect.Instance.Write("DB2119.72.0", Convert.ToUInt16(valueSpeedFast));
PlcConnect.Instance.Write("DB2119.74.0", Convert.ToUInt16(valueSpeedLow));
PlcConnect.Instance.Write("DB2119.76.0", Convert.ToUInt16(valueSpeedPoint));
PlcConnect.Instance.Write("DB2119.80.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.82.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动向湿混机3 " + valueSet);
ManualLogControl("螺旋2启动向湿混机3 " + valueSet);
break;
case 4:
PlcConnect.Instance.Write("DB2119.62.0", Convert.ToUInt16(valueSet));
PlcConnect.Instance.Write("DB2119.66.0", Convert.ToUInt16(valueFast));
PlcConnect.Instance.Write("DB2119.68.0", Convert.ToUInt16(valuePoint));
PlcConnect.Instance.Write("DB2119.72.0", Convert.ToUInt16(valueSpeedFast));
PlcConnect.Instance.Write("DB2119.74.0", Convert.ToUInt16(valueSpeedLow));
PlcConnect.Instance.Write("DB2119.76.0", Convert.ToUInt16(valueSpeedPoint));
PlcConnect.Instance.Write("DB2119.80.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.82.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动向湿混机4 " + valueSet);
ManualLogControl("螺旋2启动向湿混机4 " + valueSet);
break;
default:
MessageBox.Show("请选择一个湿混机!");
return;
}
}
if (SpiralOn3 == runtime.Sender)
{
float valueSet;
float valueFast;
float valuePoint;
float valueSpeedFast;
float valueSpeedLow;
float valueSpeedPoint;
if (float.TryParse(Convert.ToString(SetSpiralValue3.MCValue), out valueSet) &&
float.TryParse(Convert.ToString(FastSpiralValue3.MCValue), out valueFast) &&
float.TryParse(Convert.ToString(PointSpiralValue3.MCValue), out valuePoint) &&
float.TryParse(Convert.ToString(FastSpeedSpiralValue3.MCValue), out valueSpeedFast) &&
float.TryParse(Convert.ToString(LowSpeedSpiralValue3.MCValue), out valueSpeedLow) &&
float.TryParse(Convert.ToString(PointSpeedSpiralValue3.MCValue), out valueSpeedPoint))
{
if (MessageBox.Show("螺旋3确认启动", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("螺旋3输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
switch (WetChoose3)
{
case 5:
PlcConnect.Instance.Write("DB2119.84.0", Convert.ToUInt16(valueSet));
PlcConnect.Instance.Write("DB2119.88.0", Convert.ToUInt16(valueFast));
PlcConnect.Instance.Write("DB2119.90.0", Convert.ToUInt16(valuePoint));
PlcConnect.Instance.Write("DB2119.94.0", Convert.ToUInt16(valueSpeedFast));
PlcConnect.Instance.Write("DB2119.96.0", Convert.ToUInt16(valueSpeedLow));
PlcConnect.Instance.Write("DB2119.98.0", Convert.ToUInt16(valueSpeedPoint));
PlcConnect.Instance.Write("DB2119.102.0", Convert.ToUInt16(1));
PlcConnect.Instance.Write("DB2119.104.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动向湿混机5 " + valueSet);
ManualLogControl("螺旋3启动向湿混机5 " + valueSet);
break;
case 6:
PlcConnect.Instance.Write("DB2119.84.0", Convert.ToUInt16(valueSet));
PlcConnect.Instance.Write("DB2119.88.0", Convert.ToUInt16(valueFast));
PlcConnect.Instance.Write("DB2119.90.0", Convert.ToUInt16(valuePoint));
PlcConnect.Instance.Write("DB2119.94.0", Convert.ToUInt16(valueSpeedFast));
PlcConnect.Instance.Write("DB2119.96.0", Convert.ToUInt16(valueSpeedLow));
PlcConnect.Instance.Write("DB2119.98.0", Convert.ToUInt16(valueSpeedPoint));
PlcConnect.Instance.Write("DB2119.102.0", Convert.ToUInt16(2));
PlcConnect.Instance.Write("DB2119.104.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动向湿混机6 " + valueSet);
ManualLogControl("螺旋3启动向湿混机6 " + valueSet);
break;
default:
MessageBox.Show("请选择一个湿混机!");
return;
}
}
if (SpiralOn4 == runtime.Sender)
{
MessageBox.Show("二期工程,敬请期待!");
//float valueSet;
//float valueFast;
//float valuePoint;
//float valueSpeedFast;
//float valueSpeedLow;
//float valueSpeedPoint;
//if (float.TryParse(Convert.ToString(SetSpiralValue4.MCValue), out valueSet) &&
// float.TryParse(Convert.ToString(FastSpiralValue4.MCValue), out valueFast) &&
// float.TryParse(Convert.ToString(PointSpiralValue4.MCValue), out valuePoint) &&
// float.TryParse(Convert.ToString(FastSpeedSpiralValue4.MCValue), out valueSpeedFast) &&
// float.TryParse(Convert.ToString(LowSpeedSpiralValue4.MCValue), out valueSpeedLow) &&
// float.TryParse(Convert.ToString(PointSpeedSpiralValue4.MCValue), out valueSpeedPoint))
//{
// if (MessageBox.Show("螺旋4确认启动", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
// {
// return;
// }
// MesnacServiceManager.Instance.LoggingService.Info("螺旋4启动");
//}
//else
//{
// MesnacServiceManager.Instance.LoggingService.Info("螺旋4输入数值的格式有误");
// MessageBox.Show("输入数值的格式有误!");
// return;
//}
//switch (WetChoose4)
//{
// case 7:
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSet));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueFast));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valuePoint));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSpeedFast));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSpeedLow));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSpeedPoint));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(1));
// PlcConnect.Instance.Write("DB2119..0", true);
// break;
// case 8:
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSet));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueFast));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valuePoint));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSpeedFast));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSpeedLow));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(valueSpeedPoint));
// PlcConnect.Instance.Write("DB2119..0", Convert.ToUInt16(2));
// PlcConnect.Instance.Write("DB2119..0", true);
// break;
// default: return;
//}
}
if (SpiralOff1 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.60.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1已手动停止");
ManualLogControl("螺旋1已手动停止");
MessageBox.Show("螺旋1已停止");
}
if (SpiralOff2 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.82.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2已手动停止");
ManualLogControl("螺旋2已手动停止");
MessageBox.Show("螺旋2已停止");
}
if (SpiralOff3 == runtime.Sender)
{
PlcConnect.Instance.Write("DB2119.104.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3已手动停止");
ManualLogControl("螺旋3已手动停止");
MessageBox.Show("螺旋3已停止");
}
if (SpiralOff4 == runtime.Sender)
{
MessageBox.Show("二期工程,敬请期待!");
//PlcConnect.Instance.Write("DB2119..1", true);
//MesnacServiceManager.Instance.LoggingService.Info("螺旋4已手动停止");
//MessageBox.Show("螺旋4已停止");
}
if (WetRequest1 == runtime.Sender)
{
if (MessageBox.Show("糊化机1确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "1",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest2 == runtime.Sender)
{
if (MessageBox.Show("糊化机2确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "2",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest3 == runtime.Sender)
{
if (MessageBox.Show("糊化机3确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "3",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest4 == runtime.Sender)
{
if (MessageBox.Show("糊化机4确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "4",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest5 == runtime.Sender)
{
if (MessageBox.Show("糊化机5确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "5",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest6 == runtime.Sender)
{
if (MessageBox.Show("糊化机6确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "6",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest7 == runtime.Sender)
{
if (MessageBox.Show("糊化机7确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "7",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
if (WetRequest8 == runtime.Sender)
{
if (MessageBox.Show("糊化机8确认下发请求", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
string id = System.Guid.NewGuid().ToString();
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
{
reqCode = id,
reqTime = DateTime.Now,
deviceNo = "8",
state = "1"
};
HttpResponse httpResponse = new HttpResponse();
ManualLogControl("糊化机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("糊化机8返回数据 " + returnTest);
}
1 year ago
#endregion
}
private IBaseControl GetBaseControl(string name)
{
return McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl;
}
private void ManualLogControl(string logName)
{
var Log = new ManualLogEntity()
{
logtext = logName,
logtime = DateTime.Now,
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName
};
FreeSqlUnit.Instance.Insert<ManualLogEntity>(Log).ExecuteIdentity();
}
}
}