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

1319 lines
57 KiB
C#

using DataBlockHelper;
using DevExpress.DataAccess.Native.Json;
using DevExpress.Utils.About;
using ICSharpCode.Core;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.InterfaceDocking;
using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity;
using Mesnac.Action.ChemicalWeighing.LjReport.DayWhiteEmbryo;
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.Net;
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 List<DbMCControl> _McControllist;
private byte GelChooseA;
private byte GelChooseB;
private byte WetChoose1;
private byte WetChoose2;
private byte WetChoose3;
private byte WetChoose4;
#region 控件属性定义
MCButton StartMetage1;
MCButton StopMetage1;
MCButton StartMetage2;
MCButton StopMetage2;
MCButton StartMetage3;
MCButton StopMetage3;
MCButton StartMetage4;
MCButton StopMetage4;
MCButton WaterOut1;
MCButton WaterOut2;
MCButton WaterOut3;
MCButton WaterOut4;
MCButton WaterStop1;
MCButton WaterStop2;
MCButton WaterStop3;
MCButton WaterStop4;
MCButton SpiralOn1;
MCButton SpiralOn2;
MCButton SpiralOn3;
MCButton SpiralOn4;
MCButton SpiralOff1;
MCButton SpiralOff2;
MCButton SpiralOff3;
MCButton SpiralOff4;
IBaseControl Gel1;
IBaseControl Gel2;
IBaseControl Gel3;
IBaseControl Gel4;
IBaseControl Gel5;
IBaseControl Gel6;
IBaseControl Gel7;
IBaseControl Gel8;
IBaseControl Wet1;
IBaseControl Wet2;
IBaseControl Wet3;
IBaseControl Wet4;
IBaseControl Wet5;
IBaseControl Wet6;
IBaseControl Wet7;
IBaseControl Wet8;
IBaseControl SetWaterValue1;
IBaseControl SetWaterValue2;
IBaseControl SetWaterValue3;
IBaseControl SetWaterValue4;
IBaseControl SetSpiralValue1;
IBaseControl SetSpiralValue2;
IBaseControl SetSpiralValue3;
IBaseControl SetSpiralValue4;
IBaseControl FastSpiralValue1;
IBaseControl FastSpiralValue2;
IBaseControl FastSpiralValue3;
IBaseControl FastSpiralValue4;
IBaseControl PointSpiralValue1;
IBaseControl PointSpiralValue2;
IBaseControl PointSpiralValue3;
IBaseControl PointSpiralValue4;
IBaseControl FastSpeedSpiralValue1;
IBaseControl FastSpeedSpiralValue2;
IBaseControl FastSpeedSpiralValue3;
IBaseControl FastSpeedSpiralValue4;
IBaseControl LowSpeedSpiralValue1;
IBaseControl LowSpeedSpiralValue2;
IBaseControl LowSpeedSpiralValue3;
IBaseControl LowSpeedSpiralValue4;
IBaseControl PointSpeedSpiralValue1;
IBaseControl PointSpeedSpiralValue2;
IBaseControl PointSpeedSpiralValue3;
IBaseControl PointSpeedSpiralValue4;
MCButton WetRequest1;
MCButton WetRequest2;
MCButton WetRequest3;
MCButton WetRequest4;
MCButton WetRequest5;
MCButton WetRequest6;
MCButton WetRequest7;
MCButton WetRequest8;
MCButton Focus;
MCButton SaveSetting;
MCButton LoadSetting;
#endregion
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
ControlImport();
SingleSelect();
BottomSelect(runtime);
}
/// <summary>
/// 控件导入
/// </summary>
private void ControlImport()
{
McControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
_McControllist = GetAllDbMCControlsByOption(DbOptionTypes.Modify);//获取所有待初始化控件
StartMetage1 = GetButtonControl("StartMetage1");
StopMetage1 = GetButtonControl("StopMetage1");
StartMetage2 = GetButtonControl("StartMetage2");
StopMetage2 = GetButtonControl("StopMetage2");
StartMetage3 = GetButtonControl("StartMetage3");
StopMetage3 = GetButtonControl("StopMetage3");
StartMetage4 = GetButtonControl("StartMetage4");
StopMetage4 = GetButtonControl("StopMetage4");
WaterOut1 = GetButtonControl("WaterOut1");
WaterOut2 = GetButtonControl("WaterOut2");
WaterOut3 = GetButtonControl("WaterOut3");
WaterOut4 = GetButtonControl("WaterOut4");
WaterStop1 = GetButtonControl("WaterStop1");
WaterStop2 = GetButtonControl("WaterStop2");
WaterStop3 = GetButtonControl("WaterStop3");
WaterStop4 = GetButtonControl("WaterStop4");
SpiralOn1 = GetButtonControl("SpiralOn1");
SpiralOn2 = GetButtonControl("SpiralOn2");
SpiralOn3 = GetButtonControl("SpiralOn3");
SpiralOn4 = GetButtonControl("SpiralOn4");
SpiralOff1 = GetButtonControl("SpiralOff1");
SpiralOff2 = GetButtonControl("SpiralOff2");
SpiralOff3 = GetButtonControl("SpiralOff3");
SpiralOff4 = GetButtonControl("SpiralOff4");
Gel1 = GetBaseControl("Gel1");
Gel2 = GetBaseControl("Gel2");
Gel3 = GetBaseControl("Gel3");
Gel4 = GetBaseControl("Gel4");
Gel5 = GetBaseControl("Gel5");
Gel6 = GetBaseControl("Gel6");
Gel7 = GetBaseControl("Gel7");
Gel8 = GetBaseControl("Gel8");
Wet1 = GetBaseControl("Wet1");
Wet2 = GetBaseControl("Wet2");
Wet3 = GetBaseControl("Wet3");
Wet4 = GetBaseControl("Wet4");
Wet5 = GetBaseControl("Wet5");
Wet6 = GetBaseControl("Wet6");
Wet7 = GetBaseControl("Wet7");
Wet8 = GetBaseControl("Wet8");
SetWaterValue1 = GetBaseControl("SetWaterValue1");
SetWaterValue2 = GetBaseControl("SetWaterValue2");
SetWaterValue3 = GetBaseControl("SetWaterValue3");
SetWaterValue4 = GetBaseControl("SetWaterValue4");
SetSpiralValue1 = GetBaseControl("SetSpiralValue1");
SetSpiralValue2 = GetBaseControl("SetSpiralValue2");
SetSpiralValue3 = GetBaseControl("SetSpiralValue3");
SetSpiralValue4 = GetBaseControl("SetSpiralValue4");
FastSpiralValue1 = GetBaseControl("FastSpiralValue1");
FastSpiralValue2 = GetBaseControl("FastSpiralValue2");
FastSpiralValue3 = GetBaseControl("FastSpiralValue3");
FastSpiralValue4 = GetBaseControl("FastSpiralValue4");
PointSpiralValue1 = GetBaseControl("PointSpiralValue1");
PointSpiralValue2 = GetBaseControl("PointSpiralValue2");
PointSpiralValue3 = GetBaseControl("PointSpiralValue3");
PointSpiralValue4 = GetBaseControl("PointSpiralValue4");
FastSpeedSpiralValue1 = GetBaseControl("FastSpeedSpiralValue1");
FastSpeedSpiralValue2 = GetBaseControl("FastSpeedSpiralValue2");
FastSpeedSpiralValue3 = GetBaseControl("FastSpeedSpiralValue3");
FastSpeedSpiralValue4 = GetBaseControl("FastSpeedSpiralValue4");
LowSpeedSpiralValue1 = GetBaseControl("LowSpeedSpiralValue1");
LowSpeedSpiralValue2 = GetBaseControl("LowSpeedSpiralValue2");
LowSpeedSpiralValue3 = GetBaseControl("LowSpeedSpiralValue3");
LowSpeedSpiralValue4 = GetBaseControl("LowSpeedSpiralValue4");
PointSpeedSpiralValue1 = GetBaseControl("PointSpeedSpiralValue1");
PointSpeedSpiralValue2 = GetBaseControl("PointSpeedSpiralValue2");
PointSpeedSpiralValue3 = GetBaseControl("PointSpeedSpiralValue3");
PointSpeedSpiralValue4 = GetBaseControl("PointSpeedSpiralValue4");
WetRequest1 = GetButtonControl("WetRequest1");
WetRequest2 = GetButtonControl("WetRequest2");
WetRequest3 = GetButtonControl("WetRequest3");
WetRequest4 = GetButtonControl("WetRequest4");
WetRequest5 = GetButtonControl("WetRequest5");
WetRequest6 = GetButtonControl("WetRequest6");
WetRequest7 = GetButtonControl("WetRequest7");
WetRequest8 = GetButtonControl("WetRequest8");
Focus = GetButtonControl("Focus");
SaveSetting = GetButtonControl("SaveSetting");
LoadSetting = GetButtonControl("LoadSetting");
}
/// <summary>
/// 单选框选择操作机台
/// </summary>
private void SingleSelect()
{
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;
}
}
/// <summary>
/// 按钮选择事件
/// </summary>
/// <param name="runtime">运行时参数</param>
private void BottomSelect(RuntimeParameter runtime)
{
Focus.Focus();
if (StartMetage1 == runtime.Sender)
{
short value;
if (short.TryParse(Convert.ToString(SetWaterValue1.MCValue), out value))
{
if (MessageBox.Show("冷水称A确认开始称量", "称量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
PlcControl("DB2119.20.0", value);
PlcControl("DB2119.28.0", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始称量" + value);
ManualLogControl("冷水称A开始称量 " + value);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("冷水称A输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage1 == runtime.Sender)
{
PlcControl("DB2119.28.1", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A称量已手动停止");
ManualLogControl("冷水称A称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (StartMetage2 == runtime.Sender)
{
short value;
if (short.TryParse(Convert.ToString(SetWaterValue2.MCValue), out value))
{
if (MessageBox.Show("热水称A确认开始称量", "称量确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
PlcControl("DB2119.0.0", value);
PlcControl("DB2119.8.0", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始称量" + value);
ManualLogControl("热水称A开始称量 " + value);
PlcControl("DB2119.0.0", value);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("热水称A输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage2 == runtime.Sender)
{
PlcControl("DB2119.8.1", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A称量已手动停止");
ManualLogControl("热水称A称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (StartMetage3 == runtime.Sender)
{
short value;
if (short.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);
PlcControl("DB2119.30.0", value);
PlcControl("DB2119.38.0", true);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("冷水称B输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage3 == runtime.Sender)
{
PlcControl("DB2119.38.1", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B称量已手动停止");
ManualLogControl("冷水称B称量已手动停止");
MessageBox.Show("称量已停止!");
}
if (StartMetage4 == runtime.Sender)
{
short value;
if (short.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);
PlcControl("DB2119.10.0", value);
PlcControl("DB2119.18.0", true);
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("热水称B输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
if (StopMetage4 == runtime.Sender)
{
PlcControl("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:
PlcControl("DB2119.26.0", 1);
PlcControl("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅1排水");
ManualLogControl("冷水称A开始向糊化锅1排水");
break;
case 2:
PlcControl("DB2119.26.0", 2);
PlcControl("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅2排水");
ManualLogControl("冷水称A开始向糊化锅2排水");
break;
case 3:
PlcControl("DB2119.26.0", 3);
PlcControl("DB2119.28.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅3排水");
ManualLogControl("冷水称A开始向糊化锅3排水");
break;
case 4:
PlcControl("DB2119.26.0", 4);
PlcControl("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:
PlcControl("DB2119.6.0", 1);
PlcControl("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅1排水");
ManualLogControl("热水称A开始向糊化锅1排水");
break;
case 2:
PlcControl("DB2119.6.0", 2);
PlcControl("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅2排水");
ManualLogControl("热水称A开始向糊化锅2排水");
break;
case 3:
PlcControl("DB2119.6.0", 3);
PlcControl("DB2119.8.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅3排水");
ManualLogControl("热水称A开始向糊化锅3排水");
break;
case 4:
PlcControl("DB2119.6.0", 4);
PlcControl("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:
PlcControl("DB2119.36.0", 1);
PlcControl("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅5排水");
ManualLogControl("冷水称B开始向糊化锅5排水");
break;
case 6:
PlcControl("DB2119.36.0", 2);
PlcControl("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅6排水");
ManualLogControl("冷水称B开始向糊化锅6排水");
break;
case 7:
PlcControl("DB2119.36.0", 3);
PlcControl("DB2119.38.4", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅7排水");
ManualLogControl("冷水称B开始向糊化锅7排水");
break;
case 8:
PlcControl("DB2119.36.0", 4);
PlcControl("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:
PlcControl("DB2119.16.0", 1);
PlcControl("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅5排水");
ManualLogControl("热水称B开始向糊化锅5排水");
break;
case 6:
PlcControl("DB2119.16.0", 2);
PlcControl("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅6排水");
ManualLogControl("热水称B开始向糊化锅6排水");
break;
case 7:
PlcControl("DB2119.16.0", 3);
PlcControl("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅7排水");
ManualLogControl("热水称B开始向糊化锅7排水");
break;
case 8:
PlcControl("DB2119.16.0", 4);
PlcControl("DB2119.18.4", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅8排水");
ManualLogControl("热水称B开始向糊化锅8排水");
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
}
if (WaterStop1 == runtime.Sender)
{
switch (GelChooseA)
{
case 1:
PlcControl("DB2119.26.0", 1);
PlcControl("DB2119.28.5", true);
break;
case 2:
PlcControl("DB2119.26.0", 2);
PlcControl("DB2119.28.5", true);
break;
case 3:
PlcControl("DB2119.26.0", 3);
PlcControl("DB2119.28.5", true);
break;
case 4:
PlcControl("DB2119.26.0", 4);
PlcControl("DB2119.28.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("冷水称A已停止排水");
ManualLogControl("冷水称A停止排水");
MesnacServiceManager.Instance.LoggingService.Info("冷水称A停止排水");
}
if (WaterStop2 == runtime.Sender)
{
switch (GelChooseA)
{
case 1:
PlcControl("DB2119.6.0", 1);
PlcControl("DB2119.8.5", true);
break;
case 2:
PlcControl("DB2119.6.0", 2);
PlcControl("DB2119.8.5", true);
break;
case 3:
PlcControl("DB2119.6.0", 3);
PlcControl("DB2119.8.5", true);
break;
case 4:
PlcControl("DB2119.6.0", 4);
PlcControl("DB2119.8.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("热水称A已停止排水");
ManualLogControl("热水称A停止排水");
MesnacServiceManager.Instance.LoggingService.Info("热水称A停止排水");
}
if (WaterStop3 == runtime.Sender)
{
switch (GelChooseB)
{
case 5:
PlcControl("DB2119.36.0", 1);
PlcControl("DB2119.38.5", true);
break;
case 6:
PlcControl("DB2119.36.0", 2);
PlcControl("DB2119.38.5", true);
break;
case 7:
PlcControl("DB2119.36.0", 3);
PlcControl("DB2119.38.5", true);
break;
case 8:
PlcControl("DB2119.36.0", 4);
PlcControl("DB2119.38.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("冷水称B已停止排水");
ManualLogControl("冷水称B停止排水");
MesnacServiceManager.Instance.LoggingService.Info("冷水称B停止排水");
}
if (WaterStop4 == runtime.Sender)
{
switch (GelChooseB)
{
case 5:
PlcControl("DB2119.16.0", 1);
PlcControl("DB2119.18.5", true);
break;
case 6:
PlcControl("DB2119.16.0", 2);
PlcControl("DB2119.18.5", true);
break;
case 7:
PlcControl("DB2119.16.0", 3);
PlcControl("DB2119.18.5", true);
break;
case 8:
PlcControl("DB2119.16.0", 4);
PlcControl("DB2119.18.5", true);
break;
default:
MessageBox.Show("请选择一个糊化锅!");
return;
}
MessageBox.Show("热水称B已停止排水");
ManualLogControl("热水称B停止排水");
MesnacServiceManager.Instance.LoggingService.Info("热水称B停止排水");
}
if (SpiralOn1 == runtime.Sender)
{
short valueSet;
short valueFast;
short valuePoint;
short valueSpeedFast;
short valueSpeedLow;
short valueSpeedPoint;
if (short.TryParse(Convert.ToString(SetSpiralValue1.MCValue), out valueSet) &&
short.TryParse(Convert.ToString(FastSpiralValue1.MCValue), out valueFast) &&
short.TryParse(Convert.ToString(PointSpiralValue1.MCValue), out valuePoint) &&
short.TryParse(Convert.ToString(FastSpeedSpiralValue1.MCValue), out valueSpeedFast) &&
short.TryParse(Convert.ToString(LowSpeedSpiralValue1.MCValue), out valueSpeedLow) &&
short.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:
PlcControl("DB2119.40.0", valueSet);
PlcControl("DB2119.44.0", valueFast);
PlcControl("DB2119.46.0", valuePoint);
PlcControl("DB2119.50.0", valueSpeedFast);
PlcControl("DB2119.52.0", valueSpeedLow);
PlcControl("DB2119.54.0", valueSpeedPoint);
PlcControl("DB2119.58.0", 1);
PlcControl("DB2119.60.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动向湿混机1 " + valueSet);
//DayWhiteEmbryoEntity
FreeSqlUnit.Instance.Insert<DayWhiteEmbryoEntity>(new DayWhiteEmbryoEntity()
{
CreateDate=DateTime.Now.ToString("yyyyMMdd"),
CreateTime=DateTime.Now,
DeviceId=1,
Weight=valueSet
}).ExecuteAffrows();
ManualLogControl("螺旋1启动向湿混机1" + valueSet);
break;
case 2:
PlcControl("DB2119.40.0", valueSet);
PlcControl("DB2119.44.0", valueFast);
PlcControl("DB2119.46.0", valuePoint);
PlcControl("DB2119.50.0", valueSpeedFast);
PlcControl("DB2119.52.0", valueSpeedLow);
PlcControl("DB2119.54.0", valueSpeedPoint);
PlcControl("DB2119.58.0", 2);
PlcControl("DB2119.60.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动向湿混机2 " + valueSet);
FreeSqlUnit.Instance.Insert<DayWhiteEmbryoEntity>(new DayWhiteEmbryoEntity()
{
CreateDate = DateTime.Now.ToString("yyyyMMdd"),
CreateTime = DateTime.Now,
DeviceId = 2,
Weight = valueSet
}).ExecuteAffrows();
ManualLogControl("螺旋1启动向湿混机2 " + valueSet);
break;
default:
MessageBox.Show("请选择一个湿混机!");
return;
}
}
if (SpiralOn2 == runtime.Sender)
{
short valueSet;
short valueFast;
short valuePoint;
short valueSpeedFast;
short valueSpeedLow;
short valueSpeedPoint;
if (short.TryParse(Convert.ToString(SetSpiralValue2.MCValue), out valueSet) &&
short.TryParse(Convert.ToString(FastSpiralValue2.MCValue), out valueFast) &&
short.TryParse(Convert.ToString(PointSpiralValue2.MCValue), out valuePoint) &&
short.TryParse(Convert.ToString(FastSpeedSpiralValue2.MCValue), out valueSpeedFast) &&
short.TryParse(Convert.ToString(LowSpeedSpiralValue2.MCValue), out valueSpeedLow) &&
short.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:
PlcControl("DB2119.62.0", valueSet);
PlcControl("DB2119.66.0", valueFast);
PlcControl("DB2119.68.0", valuePoint);
PlcControl("DB2119.72.0", valueSpeedFast);
PlcControl("DB2119.74.0", valueSpeedLow);
PlcControl("DB2119.76.0", valueSpeedPoint);
PlcControl("DB2119.80.0", 1);
PlcControl("DB2119.82.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动向湿混机3 " + valueSet);
ManualLogControl("螺旋2启动向湿混机3 " + valueSet);
FreeSqlUnit.Instance.Insert<DayWhiteEmbryoEntity>(new DayWhiteEmbryoEntity()
{
CreateDate = DateTime.Now.ToString("yyyyMMdd"),
CreateTime = DateTime.Now,
DeviceId = 3,
Weight = valueSet
}).ExecuteAffrows();
break;
case 4:
PlcControl("DB2119.62.0", valueSet);
PlcControl("DB2119.66.0", valueFast);
PlcControl("DB2119.68.0", valuePoint);
PlcControl("DB2119.72.0", valueSpeedFast);
PlcControl("DB2119.74.0", valueSpeedLow);
PlcControl("DB2119.76.0", valueSpeedPoint);
PlcControl("DB2119.80.0", 2);
PlcControl("DB2119.82.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动向湿混机4 " + valueSet);
ManualLogControl("螺旋2启动向湿混机4 " + valueSet);
FreeSqlUnit.Instance.Insert<DayWhiteEmbryoEntity>(new DayWhiteEmbryoEntity()
{
CreateDate = DateTime.Now.ToString("yyyyMMdd"),
CreateTime = DateTime.Now,
DeviceId = 4,
Weight = valueSet
}).ExecuteAffrows();
break;
default:
MessageBox.Show("请选择一个湿混机!");
return;
}
}
if (SpiralOn3 == runtime.Sender)
{
short valueSet;
short valueFast;
short valuePoint;
short valueSpeedFast;
short valueSpeedLow;
short valueSpeedPoint;
if (short.TryParse(Convert.ToString(SetSpiralValue3.MCValue), out valueSet) &&
short.TryParse(Convert.ToString(FastSpiralValue3.MCValue), out valueFast) &&
short.TryParse(Convert.ToString(PointSpiralValue3.MCValue), out valuePoint) &&
short.TryParse(Convert.ToString(FastSpeedSpiralValue3.MCValue), out valueSpeedFast) &&
short.TryParse(Convert.ToString(LowSpeedSpiralValue3.MCValue), out valueSpeedLow) &&
short.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:
PlcControl("DB2119.84.0", valueSet);
PlcControl("DB2119.88.0", valueFast);
PlcControl("DB2119.90.0", valuePoint);
PlcControl("DB2119.94.0", valueSpeedFast);
PlcControl("DB2119.96.0", valueSpeedLow);
PlcControl("DB2119.98.0", valueSpeedPoint);
PlcControl("DB2119.102.0", 1);
PlcControl("DB2119.104.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动向湿混机5 " + valueSet);
ManualLogControl("螺旋3启动向湿混机5 " + valueSet);
FreeSqlUnit.Instance.Insert<DayWhiteEmbryoEntity>(new DayWhiteEmbryoEntity()
{
CreateDate = DateTime.Now.ToString("yyyyMMdd"),
CreateTime = DateTime.Now,
DeviceId = 5,
Weight = valueSet
}).ExecuteAffrows();
break;
case 6:
PlcControl("DB2119.84.0", valueSet);
PlcControl("DB2119.88.0", valueFast);
PlcControl("DB2119.90.0", valuePoint);
PlcControl("DB2119.94.0", valueSpeedFast);
PlcControl("DB2119.96.0", valueSpeedLow);
PlcControl("DB2119.98.0", valueSpeedPoint);
PlcControl("DB2119.102.0", 2);
PlcControl("DB2119.104.0", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动向湿混机6 " + valueSet);
ManualLogControl("螺旋3启动向湿混机6 " + valueSet);
FreeSqlUnit.Instance.Insert<DayWhiteEmbryoEntity>(new DayWhiteEmbryoEntity()
{
CreateDate = DateTime.Now.ToString("yyyyMMdd"),
CreateTime = DateTime.Now,
DeviceId = 6,
Weight = valueSet
}).ExecuteAffrows();
break;
default:
MessageBox.Show("请选择一个湿混机!");
return;
}
}
if (SpiralOn4 == runtime.Sender)
{
MessageBox.Show("二期工程,敬请期待!");
//short valueSet;
//short valueFast;
//short valuePoint;
//short valueSpeedFast;
//short valueSpeedLow;
//short valueSpeedPoint;
//if (short.TryParse(Convert.ToString(SetSpiralValue4.MCValue), out valueSet) &&
// short.TryParse(Convert.ToString(FastSpiralValue4.MCValue), out valueFast) &&
// short.TryParse(Convert.ToString(PointSpiralValue4.MCValue), out valuePoint) &&
// short.TryParse(Convert.ToString(FastSpeedSpiralValue4.MCValue), out valueSpeedFast) &&
// short.TryParse(Convert.ToString(LowSpeedSpiralValue4.MCValue), out valueSpeedLow) &&
// short.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:
// PlcControl("DB2119..0", valueSet);
// PlcControl("DB2119..0", valueFast);
// PlcControl("DB2119..0", valuePoint);
// PlcControl("DB2119..0", valueSpeedFast);
// PlcControl("DB2119..0", valueSpeedLow);
// PlcControl("DB2119..0", valueSpeedPoint);
// PlcControl("DB2119..0", 1);
// PlcControl("DB2119..0", true);
// break;
// case 8:
// PlcControl("DB2119..0", valueSet);
// PlcControl("DB2119..0", valueFast);
// PlcControl("DB2119..0", valuePoint);
// PlcControl("DB2119..0", valueSpeedFast);
// PlcControl("DB2119..0", valueSpeedLow);
// PlcControl("DB2119..0", valueSpeedPoint);
// PlcControl("DB2119..0", 2);
// PlcControl("DB2119..0", true);
// break;
// default: return;
//}
}
if (SpiralOff1 == runtime.Sender)
{
PlcControl("DB2119.60.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1已手动停止");
ManualLogControl("螺旋1已手动停止");
MessageBox.Show("螺旋1已停止");
}
if (SpiralOff2 == runtime.Sender)
{
PlcControl("DB2119.82.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2已手动停止");
ManualLogControl("螺旋2已手动停止");
MessageBox.Show("螺旋2已停止");
}
1 year ago
if (SpiralOff3 == runtime.Sender)
{
PlcControl("DB2119.104.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3已手动停止");
ManualLogControl("螺旋3已手动停止");
MessageBox.Show("螺旋3已停止");
}
if (SpiralOff4 == runtime.Sender)
{
MessageBox.Show("二期工程,敬请期待!");
//PlcControl("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("湿混机1下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机1下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机1返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机1返回数据" + 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("湿混机2下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机2下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机2返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机2返回数据" + 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("湿混机3下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机3下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机3返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机3返回数据" + 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("湿混机4下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机4下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机4返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机4返回数据" + 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("湿混机5下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机5下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机5返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机5返回数据" + 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("湿混机6下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机6下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机6返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机6返回数据" + 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("湿混机7下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机7下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机7返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机7返回数据" + 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下发请求");
MesnacServiceManager.Instance.LoggingService.Info("湿混机8下发请求");
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
ManualLogControl("湿混机8返回数据 " + returnTest);
MesnacServiceManager.Instance.LoggingService.Info("湿混机8返回数据" + returnTest);
}
if(SaveSetting == runtime.Sender)
{
short value1;
short value2;
short value3;
short value4;
short value5;
short value6;
short value7;
short value8;
if (short.TryParse(Convert.ToString(SetWaterValue1.MCValue), out value1) &&
short.TryParse(Convert.ToString(SetWaterValue2.MCValue), out value2) &&
short.TryParse(Convert.ToString(SetWaterValue3.MCValue), out value3) &&
short.TryParse(Convert.ToString(SetWaterValue4.MCValue), out value4) &&
short.TryParse(Convert.ToString(SetSpiralValue1.MCValue), out value5) &&
short.TryParse(Convert.ToString(SetSpiralValue2.MCValue), out value6) &&
short.TryParse(Convert.ToString(SetSpiralValue3.MCValue), out value7) &&
short.TryParse(Convert.ToString(SetSpiralValue4.MCValue), out value8))
{
if (MessageBox.Show("是否保存当前配置?", "保存确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
Setting.Default.SetWaterValue1 = value1;
Setting.Default.SetWaterValue2 = value2;
Setting.Default.SetWaterValue3 = value3;
Setting.Default.SetWaterValue4 = value4;
Setting.Default.SetSpiralValue1 = value5;
Setting.Default.SetSpiralValue2 = value6;
Setting.Default.SetSpiralValue3 = value7;
Setting.Default.SetSpiralValue4 = value8;
MesnacServiceManager.Instance.LoggingService.Info("配置已保存");
ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8);
}
}
if (LoadSetting == runtime.Sender)
{
if (MessageBox.Show("是否加载上次保存的配置?", "加载确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
SetWaterValue1.MCValue = Setting.Default.SetWaterValue1;
SetWaterValue2.MCValue = Setting.Default.SetWaterValue2;
SetWaterValue3.MCValue = Setting.Default.SetWaterValue3;
SetWaterValue4.MCValue = Setting.Default.SetWaterValue4;
SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1;
SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2;
SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3;
SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4;
MesnacServiceManager.Instance.LoggingService.Info("配置已加载");
ManualLogControl("配置已加载 ");
}
}
private void PlcControl(string address, short binNo)
{
PlcConnect.Instance.Write(address, binNo);
}
private void PlcControl(string address, bool state)
{
PlcConnect.Instance.Write(address, state);
}
private IBaseControl GetBaseControl(string name)
{
return _McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl;
}
private MCButton GetButtonControl(string name)
{
return McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl as MCButton;
}
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();
}
}
}