|
|
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.Data;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Net;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
using Mesnac.Action.ChemicalWeighing.MinAn;
|
|
|
using System.Xml.Serialization;
|
|
|
using System.Threading;
|
|
|
using DataBlockHelper.DBHelpers;
|
|
|
|
|
|
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
|
|
|
|
|
|
DbMCControl materialGridControl;
|
|
|
|
|
|
//keywords
|
|
|
|
|
|
IBaseControl keywords;
|
|
|
|
|
|
|
|
|
DB2119Helper DB2119;
|
|
|
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime); //必须要调用
|
|
|
|
|
|
materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView").FirstOrDefault();
|
|
|
ManualLogSelect("");
|
|
|
|
|
|
ControlImport();
|
|
|
SingleSelect();
|
|
|
BottomSelect(runtime);
|
|
|
|
|
|
DB2119 = new DB2119Helper();
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 控件获取导入
|
|
|
|
|
|
/// <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");
|
|
|
keywords = GetBaseControl("keywords");
|
|
|
// 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");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 单选框选择扫描
|
|
|
|
|
|
/// <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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 按钮事件
|
|
|
|
|
|
/// <summary>
|
|
|
/// 按钮选择事件
|
|
|
/// </summary>
|
|
|
/// <param name="runtime">运行时参数</param>
|
|
|
private void BottomSelect(RuntimeParameter runtime)
|
|
|
{
|
|
|
Focus.Focus();
|
|
|
|
|
|
DB2119Helper DB2119 = new DB2119Helper();
|
|
|
|
|
|
#region 水称称量按钮
|
|
|
|
|
|
if (StartMetage1 == runtime.Sender)
|
|
|
{
|
|
|
if (DB2119.Coolwater_A.Dos_Status)
|
|
|
{
|
|
|
MessageBox.Show("冷水称A正在排水!请稍后再称量");
|
|
|
return;
|
|
|
}
|
|
|
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, 1, 3, 1);
|
|
|
}
|
|
|
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称量已手动停止", 3, 1);
|
|
|
MessageBox.Show("冷水称A称量已停止!");
|
|
|
}
|
|
|
|
|
|
if (StartMetage2 == runtime.Sender)
|
|
|
{
|
|
|
if (DB2119.Hotwater_A.Dos_Status)
|
|
|
{
|
|
|
MessageBox.Show("热水称A正在排水!请稍后再称量");
|
|
|
return;
|
|
|
}
|
|
|
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, 1, 1, 1);
|
|
|
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称量已手动停止", 1, 1);
|
|
|
MessageBox.Show("热水称A称量已停止!");
|
|
|
}
|
|
|
|
|
|
if (StartMetage3 == runtime.Sender)
|
|
|
{
|
|
|
if (DB2119.Coolwater_B.Dos_Status)
|
|
|
{
|
|
|
MessageBox.Show("冷水称B正在排水!请稍后再称量");
|
|
|
return;
|
|
|
}
|
|
|
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, 1, 4, 1);
|
|
|
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称量已手动停止", 4, 1);
|
|
|
MessageBox.Show("冷水称B称量已停止!");
|
|
|
}
|
|
|
|
|
|
if (StartMetage4 == runtime.Sender)
|
|
|
{
|
|
|
if (DB2119.Hotwater_B.Dos_Status)
|
|
|
{
|
|
|
MessageBox.Show("热水称B正在排水!请稍后再称量");
|
|
|
return;
|
|
|
}
|
|
|
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, 1, 2, 1);
|
|
|
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称量已手动停止", 2, 1);
|
|
|
MessageBox.Show("热水称B称量已停止!");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 排水按钮
|
|
|
|
|
|
if (WaterOut1 == runtime.Sender)
|
|
|
{
|
|
|
|
|
|
if (DB2119.Coolwater_A.Dis_Status)
|
|
|
{
|
|
|
MessageBox.Show("冷水称A正在排水 请稍后");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (MessageBox.Show("冷水称A确认开始排水?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
switch (GelChooseA)
|
|
|
{
|
|
|
case 1:
|
|
|
if (SelectAddWaterControl(1) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅1已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.26.0", 1);
|
|
|
PlcControl("DB2119.28.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅1排水");
|
|
|
AdddWaterLogControl(1, 2);
|
|
|
ManualLogControl("冷水称A开始向糊化锅1排水");
|
|
|
break;
|
|
|
case 2:
|
|
|
if (SelectAddWaterControl(2) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅2已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.26.0", 2);
|
|
|
PlcControl("DB2119.28.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅2排水");
|
|
|
AdddWaterLogControl(2, 2);
|
|
|
ManualLogControl("冷水称A开始向糊化锅2排水");
|
|
|
break;
|
|
|
case 3:
|
|
|
if (SelectAddWaterControl(3) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅3已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.26.0", 3);
|
|
|
PlcControl("DB2119.28.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅3排水");
|
|
|
AdddWaterLogControl(3, 2);
|
|
|
ManualLogControl("冷水称A开始向糊化锅3排水");
|
|
|
break;
|
|
|
case 4:
|
|
|
if (SelectAddWaterControl(4) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅4已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.26.0", 4);
|
|
|
PlcControl("DB2119.28.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅4排水");
|
|
|
AdddWaterLogControl(4, 2);
|
|
|
ManualLogControl("冷水称A开始向糊化锅4排水");
|
|
|
break;
|
|
|
default:
|
|
|
MessageBox.Show("请选择一个糊化锅!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (WaterOut2 == runtime.Sender)
|
|
|
{
|
|
|
|
|
|
if (DB2119.Hotwater_A.Dis_Status)
|
|
|
{
|
|
|
MessageBox.Show("热水称A正在排水 请稍后");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (MessageBox.Show("热水称A确认开始排水?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
switch (GelChooseA)
|
|
|
{
|
|
|
case 1:
|
|
|
if (SelectAddWaterControl(1) == 0 || SelectAddWaterControl(1) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅1已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.6.0", 1);
|
|
|
PlcControl("DB2119.8.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅1排水");
|
|
|
AdddWaterLogControl(1, 1);
|
|
|
ManualLogControl("热水称A开始向糊化锅1排水");
|
|
|
break;
|
|
|
case 2:
|
|
|
if (SelectAddWaterControl(2) == 0 || SelectAddWaterControl(2) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅2已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.6.0", 2);
|
|
|
PlcControl("DB2119.8.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅2排水");
|
|
|
AdddWaterLogControl(2, 1);
|
|
|
ManualLogControl("热水称A开始向糊化锅2排水");
|
|
|
break;
|
|
|
case 3:
|
|
|
if (SelectAddWaterControl(3) == 0 || SelectAddWaterControl(3) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅3已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.6.0", 3);
|
|
|
PlcControl("DB2119.8.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅3排水");
|
|
|
AdddWaterLogControl(3, 1);
|
|
|
ManualLogControl("热水称A开始向糊化锅3排水");
|
|
|
break;
|
|
|
case 4:
|
|
|
if (SelectAddWaterControl(4) == 0 || SelectAddWaterControl(4) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅4已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.6.0", 4);
|
|
|
PlcControl("DB2119.8.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅4排水");
|
|
|
AdddWaterLogControl(4, 1);
|
|
|
ManualLogControl("热水称A开始向糊化锅4排水");
|
|
|
break;
|
|
|
default:
|
|
|
MessageBox.Show("请选择一个糊化锅!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (WaterOut3 == runtime.Sender)
|
|
|
{
|
|
|
if (DB2119.Coolwater_B.Dis_Status)
|
|
|
{
|
|
|
MessageBox.Show("冷水称B正在排水 请稍后");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (MessageBox.Show("冷水称B确认开始排水?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
switch (GelChooseB)
|
|
|
{
|
|
|
case 5:
|
|
|
if (SelectAddWaterControl(5) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅5已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.36.0", 1);
|
|
|
PlcControl("DB2119.38.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅5排水");
|
|
|
AdddWaterLogControl(5, 2);
|
|
|
ManualLogControl("冷水称B开始向糊化锅5排水");
|
|
|
break;
|
|
|
case 6:
|
|
|
if (SelectAddWaterControl(6) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅6已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.36.0", 2);
|
|
|
PlcControl("DB2119.38.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅6排水");
|
|
|
AdddWaterLogControl(6, 2);
|
|
|
ManualLogControl("冷水称B开始向糊化锅6排水");
|
|
|
break;
|
|
|
case 7:
|
|
|
if (SelectAddWaterControl(7) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅7已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.36.0", 3);
|
|
|
PlcControl("DB2119.38.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅7排水");
|
|
|
AdddWaterLogControl(7, 2);
|
|
|
ManualLogControl("冷水称B开始向糊化锅7排水");
|
|
|
break;
|
|
|
case 8:
|
|
|
if (SelectAddWaterControl(8) == 2)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅8已经加过冷水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.36.0", 4);
|
|
|
PlcControl("DB2119.38.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅8排水");
|
|
|
AdddWaterLogControl(8, 2);
|
|
|
ManualLogControl("冷水称B开始向糊化锅8排水");
|
|
|
break;
|
|
|
default:
|
|
|
MessageBox.Show("请选择一个糊化锅!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (WaterOut4 == runtime.Sender)
|
|
|
{
|
|
|
|
|
|
if (DB2119.Hotwater_B.Dis_Status)
|
|
|
{
|
|
|
MessageBox.Show("热水称B正在排水 请稍后");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (MessageBox.Show("热水称B确认开始排水?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
switch (GelChooseB)
|
|
|
{
|
|
|
case 5:
|
|
|
if (SelectAddWaterControl(5) == 0 || SelectAddWaterControl(5) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅5已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.16.0", 1);
|
|
|
PlcControl("DB2119.18.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅5排水");
|
|
|
AdddWaterLogControl(5, 1);
|
|
|
ManualLogControl("热水称B开始向糊化锅5排水");
|
|
|
break;
|
|
|
case 6:
|
|
|
if (SelectAddWaterControl(6) == 0 || SelectAddWaterControl(6) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅6已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.16.0", 2);
|
|
|
PlcControl("DB2119.18.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅6排水");
|
|
|
AdddWaterLogControl(6, 1);
|
|
|
ManualLogControl("热水称B开始向糊化锅6排水");
|
|
|
break;
|
|
|
case 7:
|
|
|
if (SelectAddWaterControl(7) == 0 || SelectAddWaterControl(7) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅7已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.16.0", 3);
|
|
|
PlcControl("DB2119.18.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅7排水");
|
|
|
AdddWaterLogControl(7, 1);
|
|
|
ManualLogControl("热水称B开始向糊化锅7排水");
|
|
|
break;
|
|
|
case 8:
|
|
|
if (SelectAddWaterControl(8) == 0 || SelectAddWaterControl(8) == 1)
|
|
|
{
|
|
|
if (MessageBox.Show("上次糊化锅8已经加过热水,确认再次添加?", "排水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
PlcControl("DB2119.16.0", 4);
|
|
|
PlcControl("DB2119.18.4", true);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅8排水");
|
|
|
AdddWaterLogControl(8, 1);
|
|
|
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;
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
WaterStopAction("DB2119.28.5", WaterStop1, "冷", "A");
|
|
|
//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;
|
|
|
//}
|
|
|
|
|
|
WaterStopAction("DB2119.8.5", WaterStop2, "热", "A");
|
|
|
|
|
|
//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;
|
|
|
//}
|
|
|
|
|
|
WaterStopAction("DB2119.38.5", WaterStop3, "冷", "B");
|
|
|
|
|
|
|
|
|
//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;
|
|
|
//}
|
|
|
|
|
|
WaterStopAction("DB2119.18.5", WaterStop4, "热", "B");
|
|
|
|
|
|
//MessageBox.Show("热水称B已停止排水");
|
|
|
//ManualLogControl("热水称B停止排水");
|
|
|
//MesnacServiceManager.Instance.LoggingService.Info("热水称B停止排水");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 螺旋控制按钮
|
|
|
|
|
|
if (SpiralOn1 == runtime.Sender)
|
|
|
{
|
|
|
if (MinAnPlc.Heir1)
|
|
|
{
|
|
|
DialogResult result1 = MessageBox.Show("1号罐正在上料", "温馨提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
if (result1 == DialogResult.OK)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
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:
|
|
|
if (valueSet > 350)
|
|
|
{
|
|
|
var record = FreeSqlUnit.Instance.Select<ManualLogEntity>()
|
|
|
.Where(x => x.valuekind == 3 && x.devicekind == 2 && x.deviceno == 1 && x.value > 350).ToList().LastOrDefault();
|
|
|
if(record == null) { return; }
|
|
|
if ((DateTime.Now - record.logtime).Value.TotalMinutes < 15)
|
|
|
{
|
|
|
if (MessageBox.Show("距离上次下料大于350KG不足15分钟 确认下料?", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
== DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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);
|
|
|
ManualLogControl("螺旋1启动向湿混机1", valueSet, 3, 1, 2);
|
|
|
break;
|
|
|
case 2:
|
|
|
if (valueSet > 350)
|
|
|
{
|
|
|
var record = FreeSqlUnit.Instance.Select<ManualLogEntity>()
|
|
|
.Where(x => x.valuekind == 3 && x.devicekind == 2 && x.deviceno == 2 && x.value > 350).ToList().LastOrDefault();
|
|
|
if (record == null) { return; }
|
|
|
if ((DateTime.Now - record.logtime).Value.TotalMinutes < 15)
|
|
|
{
|
|
|
if (MessageBox.Show("距离上次下料大于350KG不足15分钟 确认下料?", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
== DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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);
|
|
|
ManualLogControl("螺旋1启动向湿混机2", valueSet, 3, 2, 2);
|
|
|
break;
|
|
|
default:
|
|
|
MessageBox.Show("请选择一个湿混机!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (SpiralOn2 == runtime.Sender)
|
|
|
{
|
|
|
|
|
|
if (MinAnPlc.Heir2)
|
|
|
{
|
|
|
DialogResult result2 =
|
|
|
MessageBox.Show("2号罐正在上料", "温馨提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
if (result2 == DialogResult.OK)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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:
|
|
|
if (valueSet > 350)
|
|
|
{
|
|
|
var record = FreeSqlUnit.Instance.Select<ManualLogEntity>()
|
|
|
.Where(x => x.valuekind == 3 && x.devicekind == 2 && x.deviceno == 3 && x.value > 350).ToList().LastOrDefault();
|
|
|
if (record == null) { return; }
|
|
|
if ((DateTime.Now - record.logtime).Value.TotalMinutes < 15)
|
|
|
{
|
|
|
if (MessageBox.Show("距离上次下料大于350KG不足15分钟 确认下料?", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
== DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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, 3, 3, 2);
|
|
|
break;
|
|
|
case 4:
|
|
|
if (valueSet > 350)
|
|
|
{
|
|
|
var record = FreeSqlUnit.Instance.Select<ManualLogEntity>()
|
|
|
.Where(x => x.valuekind == 3 && x.devicekind == 2 && x.deviceno == 4 && x.value > 350).ToList().LastOrDefault();
|
|
|
if (record == null) { return; }
|
|
|
if ((DateTime.Now - record.logtime).Value.TotalMinutes < 15)
|
|
|
{
|
|
|
if (MessageBox.Show("距离上次下料大于350KG不足15分钟 确认下料?", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
== DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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, 3, 4, 2);
|
|
|
break;
|
|
|
default:
|
|
|
MessageBox.Show("请选择一个湿混机!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (SpiralOn3 == runtime.Sender)
|
|
|
{
|
|
|
|
|
|
if (MinAnPlc.Heir3)
|
|
|
{
|
|
|
DialogResult result3 =
|
|
|
MessageBox.Show("3号罐正在上料", "温馨提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
if (result3 == DialogResult.OK)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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:
|
|
|
if (valueSet > 350)
|
|
|
{
|
|
|
var record = FreeSqlUnit.Instance.Select<ManualLogEntity>()
|
|
|
.Where(x => x.valuekind == 3 && x.devicekind == 2 && x.deviceno == 5 && x.value > 350).ToList().LastOrDefault();
|
|
|
if (record == null) { return; }
|
|
|
if ((DateTime.Now - record.logtime).Value.TotalMinutes < 15)
|
|
|
{
|
|
|
if (MessageBox.Show("距离上次下料大于350KG不足15分钟 确认下料?", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
== DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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, 3, 5, 2);
|
|
|
break;
|
|
|
case 6:
|
|
|
if (valueSet > 350)
|
|
|
{
|
|
|
var record = FreeSqlUnit.Instance.Select<ManualLogEntity>()
|
|
|
.Where(x => x.valuekind == 3 && x.devicekind == 2 && x.deviceno == 6 && x.value > 350).ToList().LastOrDefault();
|
|
|
if (record == null) { return; }
|
|
|
if ((DateTime.Now - record.logtime).Value.TotalMinutes < 15)
|
|
|
{
|
|
|
if (MessageBox.Show("距离上次下料大于350KG不足15分钟 确认下料?", "螺旋启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
|
|
|
== DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
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, 3, 6, 2);
|
|
|
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已停止!");
|
|
|
}
|
|
|
|
|
|
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已停止!");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 日志查询 配置加载
|
|
|
|
|
|
//点击日志查询
|
|
|
if (WetRequest1 == runtime.Sender)
|
|
|
{
|
|
|
string key = keywords.MCValue.ToString();
|
|
|
ManualLogSelect(key);
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
FreeSqlUnit.Instance.Delete<ManualControlSetting>().Where("1 = 1").ExecuteAffrows();
|
|
|
|
|
|
ManualControlSetting[] settings = new ManualControlSetting[8];
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
{
|
|
|
settings[i] = new ManualControlSetting();
|
|
|
}
|
|
|
|
|
|
settings[0].SettingName = "WaterValue1";
|
|
|
settings[1].SettingName = "WaterValue2";
|
|
|
settings[2].SettingName = "WaterValue3";
|
|
|
settings[3].SettingName = "WaterValue4";
|
|
|
settings[4].SettingName = "SpiralValue1";
|
|
|
settings[5].SettingName = "SpiralValue2";
|
|
|
settings[6].SettingName = "SpiralValue3";
|
|
|
settings[7].SettingName = "SpiralValue4";
|
|
|
|
|
|
settings[0].Value = value1;
|
|
|
settings[1].Value = value2;
|
|
|
settings[2].Value = value3;
|
|
|
settings[3].Value = value4;
|
|
|
settings[4].Value = value5;
|
|
|
settings[5].Value = value6;
|
|
|
settings[6].Value = value7;
|
|
|
settings[7].Value = value8;
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(settings).ExecuteAffrows();
|
|
|
//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;
|
|
|
}
|
|
|
|
|
|
var table = FreeSqlUnit.Instance.Select<ManualControlSetting>().Where("1 = 1").ToList();
|
|
|
|
|
|
SetWaterValue1.MCValue = table.Where(x => x.SettingName == "WaterValue1").LastOrDefault().Value;
|
|
|
SetWaterValue2.MCValue = table.Where(x => x.SettingName == "WaterValue2").LastOrDefault().Value;
|
|
|
SetWaterValue3.MCValue = table.Where(x => x.SettingName == "WaterValue3").LastOrDefault().Value;
|
|
|
SetWaterValue4.MCValue = table.Where(x => x.SettingName == "WaterValue4").LastOrDefault().Value;
|
|
|
SetSpiralValue1.MCValue = table.Where(x => x.SettingName == "SpiralValue1").LastOrDefault().Value;
|
|
|
SetSpiralValue2.MCValue = table.Where(x => x.SettingName == "SpiralValue2").LastOrDefault().Value;
|
|
|
SetSpiralValue3.MCValue = table.Where(x => x.SettingName == "SpiralValue3").LastOrDefault().Value;
|
|
|
SetSpiralValue4.MCValue = table.Where(x => x.SettingName == "SpiralValue4").LastOrDefault().Value;
|
|
|
MesnacServiceManager.Instance.LoggingService.Info("配置已加载");
|
|
|
ManualLogControl("配置已加载 ");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region plc插入控制
|
|
|
|
|
|
private void PlcControl(string address, short binNo)
|
|
|
{
|
|
|
if (!PlcConnect.Instance.Write(address, binNo).IsSuccess)
|
|
|
{
|
|
|
if (PlcConnect.Instance.ReadInt16(address).Content == binNo)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
{
|
|
|
Thread.Sleep(100);
|
|
|
if (PlcConnect.Instance.Write(address, binNo).IsSuccess)
|
|
|
{
|
|
|
ManualLogControl("第 " + (i + 1) + " 次重发测试成功");
|
|
|
return;
|
|
|
}
|
|
|
ManualLogControl("第 " + (i + 1) + " 次重发测试失败");
|
|
|
}
|
|
|
MessageBox.Show(address + "写入失败!");
|
|
|
ManualLogControl("PLC写入失败!");
|
|
|
}
|
|
|
}
|
|
|
private void PlcControl(string address, bool state)
|
|
|
{
|
|
|
if (!PlcConnect.Instance.Write(address, state).IsSuccess)
|
|
|
{
|
|
|
if (PlcConnect.Instance.ReadBool(address).Content == state)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
{
|
|
|
Thread.Sleep(100);
|
|
|
if (PlcConnect.Instance.Write(address, state).IsSuccess)
|
|
|
{
|
|
|
ManualLogControl("第 " + (i + 1) + " 次重发测试成功");
|
|
|
return;
|
|
|
}
|
|
|
ManualLogControl("第 " + (i + 1) + " 次重发测试失败");
|
|
|
}
|
|
|
MessageBox.Show(address + "写入失败!");
|
|
|
ManualLogControl("PLC写入失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 控件获取
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 数据库日志控制
|
|
|
|
|
|
/// <summary>
|
|
|
/// 日志查询
|
|
|
/// </summary>
|
|
|
/// <param name="txt">查询关键字</param>
|
|
|
private void ManualLogSelect(string txt)
|
|
|
{
|
|
|
string sql = "select top 500 id, logtext, logtime, value from Manual_Log ";
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txt))
|
|
|
{
|
|
|
sql += $" where logtext like '%{txt}%'";
|
|
|
}
|
|
|
|
|
|
sql += " order by id desc";
|
|
|
DataTable table = DBHelp.GetTable(sql);
|
|
|
|
|
|
if (this.materialGridControl != null && this.materialGridControl.BaseControl != null)
|
|
|
{
|
|
|
this.materialGridControl.BaseControl.BindDataSource = null;
|
|
|
this.materialGridControl.BaseControl.BindDataSource = table;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<InitAction>.Warn("ManualContrlolAction 手动操作日志信息控件为Null...");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 日志插入
|
|
|
/// </summary>
|
|
|
/// <param name="logName">日志内容</param>
|
|
|
/// <param name="value">值</param>
|
|
|
/// <param name="valuekind">值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值</param>
|
|
|
/// <param name="deviceno">设备编号</param>
|
|
|
/// <param name="devicekind">设备类型 0无 1水称 2螺旋</param>
|
|
|
private void ManualLogControl(string logName, int value, int valuekind, int deviceno, int devicekind)
|
|
|
{
|
|
|
var Log = new ManualLogEntity()
|
|
|
{
|
|
|
logtext = logName,
|
|
|
logtime = DateTime.Now,
|
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
value = value,
|
|
|
deviceno = deviceno,
|
|
|
devicekind = devicekind,
|
|
|
valuekind = valuekind,
|
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
|
};
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
|
ManualLogSelect("");
|
|
|
}
|
|
|
|
|
|
private void ManualLogControl(string logName, int deviceno, int devicekind)
|
|
|
{
|
|
|
var Log = new ManualLogEntity()
|
|
|
{
|
|
|
logtext = logName,
|
|
|
logtime = DateTime.Now,
|
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
value = 0,
|
|
|
deviceno = deviceno,
|
|
|
devicekind = devicekind,
|
|
|
valuekind = 0,
|
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
|
};
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
|
ManualLogSelect("");
|
|
|
}
|
|
|
|
|
|
private void ManualLogControl(string logName)
|
|
|
{
|
|
|
var Log = new ManualLogEntity()
|
|
|
{
|
|
|
logtext = logName,
|
|
|
logtime = DateTime.Now,
|
|
|
userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
value = 0,
|
|
|
deviceno = 0,
|
|
|
devicekind = 0,
|
|
|
valuekind = 0,
|
|
|
createdate = DateTime.Now.ToString("yyyyMMdd")
|
|
|
};
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity();
|
|
|
|
|
|
ManualLogSelect("");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="deviceNo"></param>
|
|
|
/// <param name="isHot">1是热水 2是冷水 0为空</param>
|
|
|
private void AdddWaterLogControl(int deviceNo, int isHot)
|
|
|
{
|
|
|
var log = new AddWaterLog()
|
|
|
{
|
|
|
DeviceId = deviceNo,
|
|
|
Hot = isHot,
|
|
|
CreateTime = DateTime.Now,
|
|
|
};
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
private int SelectAddWaterControl(int deviceNo)
|
|
|
{
|
|
|
var list = FreeSqlUnit.Instance.Select<AddWaterLog>().Where(x => x.DeviceId == deviceNo).ToList();
|
|
|
if (list.Count == 0)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
return Convert.ToInt32(list.LastOrDefault().Hot);
|
|
|
}
|
|
|
|
|
|
private void WaterStopAction(string plcAddress, MCButton button, string h, string a)
|
|
|
{
|
|
|
//先读取plc地址
|
|
|
bool stopMe1 = PlcConnect.Instance.ReadBool(plcAddress).Content;
|
|
|
bool me1 = !stopMe1;
|
|
|
PlcControl(plcAddress, me1);
|
|
|
string txt = $"{h}水称{a}";
|
|
|
//如果Plc是1 就证明是点了停止称量
|
|
|
if (me1)
|
|
|
{
|
|
|
txt += "恢复";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
txt += "停止";
|
|
|
}
|
|
|
button.Text = txt;
|
|
|
|
|
|
|
|
|
txt = $"{h}水称{a}";
|
|
|
//如果Plc是1 就证明是点了停止称量
|
|
|
if (!me1)
|
|
|
{
|
|
|
txt += "恢复";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
txt += "停止";
|
|
|
}
|
|
|
|
|
|
MessageBox.Show(txt);
|
|
|
ManualLogControl(txt);
|
|
|
MesnacServiceManager.Instance.LoggingService.Info(txt);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|