add - 手动控制程序 添加日志 完善代码

dep_nodyang
wangsr 1 year ago
parent ac92eb3529
commit bcd9ccae26

@ -1,9 +1,14 @@
using DataBlockHelper;
using HslCommunication;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
using Mesnac.Basic;
using Mesnac.Controls.Base;
using Mesnac.Core.Service;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
@ -14,11 +19,41 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
List<DbMCControl> McControllist;
OperateResult<byte[]> Read;
byte[] content;
System.Timers.Timer timer;
byte[] content;
DbMCControl materialGridControl;
Timer timer;
int flag = 0;
IBaseControl WaterActualValue1;
IBaseControl WaterActualValue2;
IBaseControl WaterActualValue3;
IBaseControl WaterActualValue4;
IBaseControl WaterMetValue1;
IBaseControl WaterMetValue2;
IBaseControl WaterMetValue3;
IBaseControl WaterMetValue4;
IBaseControl SpiralActValue1;
IBaseControl SpiralActValue2;
IBaseControl SpiralActValue3;
IBaseControl SpiralActValue4;
IBaseControl MetageState1;
IBaseControl MetageState2;
IBaseControl MetageState3;
IBaseControl MetageState4;
IBaseControl WaterOutState1;
IBaseControl WaterOutState2;
IBaseControl WaterOutState3;
IBaseControl WaterOutState4;
IBaseControl SpiralState1;
IBaseControl SpiralState2;
IBaseControl SpiralState3;
IBaseControl SpiralState4;
bool State1;
bool State2;
@ -29,47 +64,82 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
base.RunIni(runtime); //必须要调用的
//ReadFromPlc();
InitTimer();
//InitTimer();
//timer.Start();
McControllist = GetAllDbMCControlsByOption(DbOptionTypes.InitData);
WaterActualValue1 = GetBaseControl("WaterActualValue1");
WaterActualValue2 = GetBaseControl("WaterActualValue2");
WaterActualValue3 = GetBaseControl("WaterActualValue3");
WaterActualValue4 = GetBaseControl("WaterActualValue4");
WaterMetValue1 = GetBaseControl("WaterMetValue1");
WaterMetValue2 = GetBaseControl("WaterMetValue2");
WaterMetValue3 = GetBaseControl("WaterMetValue3");
WaterMetValue4 = GetBaseControl("WaterMetValue4");
SpiralActValue1 = GetBaseControl("SpiralActValue1");
SpiralActValue2 = GetBaseControl("SpiralActValue2");
SpiralActValue3 = GetBaseControl("SpiralActValue3");
SpiralActValue4 = GetBaseControl("SpiralActValue4");
MetageState1 = GetBaseControl("MetageState1");
MetageState2 = GetBaseControl("MetageState2");
MetageState3 = GetBaseControl("MetageState3");
MetageState4 = GetBaseControl("MetageState4");
WaterOutState1 = GetBaseControl("WaterOutState1");
WaterOutState2 = GetBaseControl("WaterOutState2");
WaterOutState3 = GetBaseControl("WaterOutState3");
WaterOutState4 = GetBaseControl("WaterOutState4");
SpiralState1 = GetBaseControl("SpiralState1");
SpiralState2 = GetBaseControl("SpiralState2");
SpiralState3 = GetBaseControl("SpiralState3");
SpiralState4 = GetBaseControl("SpiralState4");
materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView").FirstOrDefault();
DataTable table = DBHelp.GetTable(@"select top 100 id, logtext, logtime from Manual_Log order by id desc");
if (this.materialGridControl != null && this.materialGridControl.BaseControl != null)
{
this.materialGridControl.BaseControl.BindDataSource = null;
this.materialGridControl.BaseControl.BindDataSource = table;
}
else
{
ICSharpCode.Core.LoggingService<InitAction>.Warn("手动操作日志信息控件为Null...");
}
timer.Start();
timer = new Timer();
timer.Interval = 1000;
timer.Enabled = true;
timer.Tick += new EventHandler(ReadFromPlc);//添加事件
}
private void ReadFromPlc(Object sender, System.Timers.ElapsedEventArgs e)
private void ReadFromPlc(object sender, EventArgs e)
{
flag += 1;
if(flag > 10)
{
flag = 0;
DataTable table = DBHelp.GetTable(@"select top 100 id, logtext, logtime from Manual_Log order by id desc");
if (this.materialGridControl != null && this.materialGridControl.BaseControl != null)
{
this.materialGridControl.BaseControl.BindDataSource = null;
this.materialGridControl.BaseControl.BindDataSource = table;
}
else
{
ICSharpCode.Core.LoggingService<InitAction>.Warn("手动操作日志信息控件为Null...");
}
}
McControllist = GetAllDbMCControlsByOption(DbOptionTypes.InitData);//获取所有待初始化控件
IBaseControl WaterActualValue1 = GetBaseControl("WaterActualValue1");
IBaseControl WaterActualValue2 = GetBaseControl("WaterActualValue2");
IBaseControl WaterActualValue3 = GetBaseControl("WaterActualValue3");
IBaseControl WaterActualValue4 = GetBaseControl("WaterActualValue4");
IBaseControl WaterMetValue1 = GetBaseControl("WaterMetValue1");
IBaseControl WaterMetValue2 = GetBaseControl("WaterMetValue2");
IBaseControl WaterMetValue3 = GetBaseControl("WaterMetValue3");
IBaseControl WaterMetValue4 = GetBaseControl("WaterMetValue4");
IBaseControl SpiralActValue1 = GetBaseControl("SpiralActValue1");
IBaseControl SpiralActValue2 = GetBaseControl("SpiralActValue2");
IBaseControl SpiralActValue3 = GetBaseControl("SpiralActValue3");
IBaseControl SpiralActValue4 = GetBaseControl("SpiralActValue4");
IBaseControl MetageState1 = GetBaseControl("MetageState1");
IBaseControl MetageState2 = GetBaseControl("MetageState2");
IBaseControl MetageState3 = GetBaseControl("MetageState3");
IBaseControl MetageState4 = GetBaseControl("MetageState4");
IBaseControl WaterOutState1 = GetBaseControl("WaterOutState1");
IBaseControl WaterOutState2 = GetBaseControl("WaterOutState2");
IBaseControl WaterOutState3 = GetBaseControl("WaterOutState3");
IBaseControl WaterOutState4 = GetBaseControl("WaterOutState4");
IBaseControl SpiralState1 = GetBaseControl("SpiralState1");
IBaseControl SpiralState2 = GetBaseControl("SpiralState2");
IBaseControl SpiralState3 = GetBaseControl("SpiralState3");
IBaseControl SpiralState4 = GetBaseControl("SpiralState4");
if (GetAllDbMCControlsByOption(DbOptionTypes.InitData).Count == 0)
{
timer.Stop();
timer.Dispose();
}
Read = PlcConnect.Instance.Read("DB2119.22.0", 2);
@ -320,21 +390,22 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
// MetageState4.MCValue = "停止螺旋";
//}
}
private void InitTimer()
{
//设置定时间隔(毫秒为单位)
int interval = 900;
timer = new System.Timers.Timer(interval);
//设置执行一次false还是一直执行(true)
timer.AutoReset = true;
//设置是否执行System.Timers.Timer.Elapsed事件
timer.Enabled = true;
//绑定Elapsed事件
timer.Elapsed += new System.Timers.ElapsedEventHandler(ReadFromPlc);
}
//private void InitTimer()
//{
// //设置定时间隔(毫秒为单位)
// int interval = 900;
// timer = new System.Timers.Timer(interval);
// //设置执行一次false还是一直执行(true)
// timer.AutoReset = true;
// //设置是否执行System.Timers.Timer.Elapsed事件
// timer.Enabled = true;
// //绑定Elapsed事件
// timer.Elapsed += new System.Timers.ElapsedEventHandler(ReadFromPlc);
//}
private IBaseControl GetBaseControl(string name)
@ -343,5 +414,17 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
}
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();
}
}
}

@ -1,5 +1,7 @@
using DataBlockHelper;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Basic;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
using Mesnac.Core.Service;
@ -208,7 +210,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始称量");
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);
}
@ -224,6 +227,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.28.1", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称A称量已手动停止");
ManualLogControl("冷水称A称量已手动停止");
MessageBox.Show("称量已停止!");
}
@ -236,7 +240,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始称量");
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);
}
@ -252,6 +257,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.8.1", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称A称量已手动停止");
ManualLogControl("热水称A称量已手动停止");
MessageBox.Show("称量已停止!");
}
@ -264,7 +270,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始称量");
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);
}
@ -280,6 +287,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.38.1", true);
MesnacServiceManager.Instance.LoggingService.Info("冷水称B称量已手动停止");
ManualLogControl("冷水称B称量已手动停止");
MessageBox.Show("称量已停止!");
}
@ -292,7 +300,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
return;
}
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始称量");
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);
}
@ -308,6 +317,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.18.1", true);
MesnacServiceManager.Instance.LoggingService.Info("热水称B称量已手动停止");
ManualLogControl("热水称B称量已手动停止");
MessageBox.Show("称量已停止!");
}
@ -323,25 +333,33 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始排水");
}
@ -357,25 +375,32 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("热水称A开始排水");
}
@ -391,25 +416,33 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始排水");
}
@ -425,25 +458,33 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("热水称B开始排水");
}
@ -473,6 +514,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
}
MessageBox.Show("冷水称A已停止排水");
ManualLogControl("冷水称A停止排水");
MesnacServiceManager.Instance.LoggingService.Info("冷水称A停止排水");
}
@ -502,6 +544,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
}
MessageBox.Show("热水称A已停止排水");
ManualLogControl("热水称A停止排水");
MesnacServiceManager.Instance.LoggingService.Info("热水称A停止排水");
}
@ -531,6 +574,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
}
MessageBox.Show("冷水称B已停止排水");
ManualLogControl("冷水称B停止排水");
MesnacServiceManager.Instance.LoggingService.Info("冷水称B停止排水");
}
@ -560,6 +604,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
}
MessageBox.Show("热水称B已停止排水");
ManualLogControl("热水称B停止排水");
MesnacServiceManager.Instance.LoggingService.Info("热水称B停止排水");
}
@ -602,6 +647,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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));
@ -612,13 +659,14 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动");
}
@ -660,6 +708,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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));
@ -670,13 +720,14 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动");
}
@ -718,6 +769,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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));
@ -728,13 +781,14 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
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;
}
MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动");
}
@ -797,6 +851,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.60.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋1已手动停止");
ManualLogControl("螺旋1已手动停止");
MessageBox.Show("螺旋1已停止");
}
@ -804,6 +859,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.82.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋2已手动停止");
ManualLogControl("螺旋2已手动停止");
MessageBox.Show("螺旋2已停止");
}
@ -811,6 +867,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
PlcConnect.Instance.Write("DB2119.104.1", true);
MesnacServiceManager.Instance.LoggingService.Info("螺旋3已手动停止");
ManualLogControl("螺旋3已手动停止");
MessageBox.Show("螺旋3已停止");
}
@ -834,5 +891,17 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
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();
}
}
}

@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// Website: http://www.freesql.net
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using FreeSql.DataAnnotations;
namespace Mesnac.Action.ChemicalWeighing.ManualControl
{
[Table(Name = "Manual_Log")]
public partial class ManualLogEntity
{
[Column(IsPrimary = true, IsIdentity = true)]
public int id { get; set; }
[Column(DbType = "nvarchar(500)")]
public string logtext { get; set; } = string.Empty;
public DateTime? logtime { get; set; }
[Column(DbType = "nvarchar(50)")]
public string userid { get; set; } = string.Empty;
}
}

@ -494,6 +494,7 @@
</Compile>
<Compile Include="LoadingHelper.cs" />
<Compile Include="ManualControl\InitAction.cs" />
<Compile Include="ManualControl\ManualLogEntity.cs" />
<Compile Include="ManualControl\ManualControlAction.cs" />
<Compile Include="MaterialManage\BarcodeReport.cs">
<SubType>Component</SubType>

@ -21,6 +21,9 @@ namespace Mesnac.Action.ChemicalWeighing.Report.DeviceDetail2Report
List<DbMCControl> McControllist;
DeviceDetail2Entity DeviceDetailForm = new DeviceDetail2Entity();
private DbMCControl AlarmForm = null; //物料列表控件
Timer timer1;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
@ -254,7 +257,7 @@ namespace Mesnac.Action.ChemicalWeighing.Report.DeviceDetail2Report
DeviceDetailForm.GHSpeed = StringToLable("GHSpeed");
#endregion
Timer timer1 = new Timer();
timer1 = new Timer();
timer1.Interval = 2000;
timer1.Enabled = true;
timer1.Tick += new EventHandler(GetDataFromPLCToForm);//添加事件
@ -267,7 +270,12 @@ namespace Mesnac.Action.ChemicalWeighing.Report.DeviceDetail2Report
/// <param name="e"></param>
public void GetDataFromPLCToForm(object source, EventArgs e)
{
if (GetAllDbMCControlsByOption(DbOptionTypes.InitData).Count == 0)
{
timer1.Stop();
timer1.Dispose();
}
DataTable AlarmTable = DBHelp.GetTable(@"select t2.Alarm_ID, t2.Alarm_Other_Info,t2.Alarm_Block,t2.Alarm_Word,t2.Alarm_Bit,t1.Alarm_OccurTime from LR_Alarmlog t1
left join Pmt_Alarm t2 on t1.Alarm_ID=t2.Alarm_ID where t1.Alarm_Status=1");

@ -1,30 +1,44 @@
<Object type="Mesnac.Gui.Common.FrmRunTemplate, Mesnac.Gui.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="ManualWaterControl" children="Controls">
<Object type="Mesnac.Controls.Default.MCButton, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCButton9" children="Controls">
<Property name="ClickActionList">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAAEAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIEFEQTI3NUNERUFEODQwREY4NkZFMDBCNjIzOEU0M0Q3BgYAAAAP56qX5L2T5Yid5aeL5YyWBgcAAAAP56qX5L2T5Yid5aeL5YyWCw==</Binary>
</Property>
<Property name="MCKey">Refresh</Property>
<Property name="MCDataSourceID" />
<Property name="IsDbControl">False</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource" />
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="MCPurview">False</Property>
<Property name="Format" />
<Property name="TextName" />
<Property name="NewFillColor">Red</Property>
<Property name="OldFillColor">DarkGray</Property>
<Property name="FlatStyle">System</Property>
<Property name="Text">刷新读数</Property>
<Property name="Font">宋体, 19pt</Property>
<Property name="Location">696, 358</Property>
<Property name="Name">MCButton9</Property>
<Property name="Size">678, 73</Property>
<Property name="TabIndex">26</Property>
<Object type="System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="GroupBox9" children="Controls">
<Object type="Mesnac.Controls.Default.MCDataGridView, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCDataGridView3" children="Controls">
<Property name="DisplayAllColumn">False</Property>
<Property name="DgvColumn">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJoBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EYXRhR3JpZFZpZXdDb2x1bW5zLCBNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGxdXQMAAAAGX2l0ZW1zBV9zaXplCF92ZXJzaW9uBAAAKk1lc25hYy5Db250cm9scy5CYXNlLkRhdGFHcmlkVmlld0NvbHVtbnNbXQIAAAAICAkDAAAAAgAAAF4AAAAHAwAAAAABAAAACAAAAAQoTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGF0YUdyaWRWaWV3Q29sdW1ucwIAAAAJBAAAAAkFAAAADQYFBAAAAChNZXNuYWMuQ29udHJvbHMuQmFzZS5EYXRhR3JpZFZpZXdDb2x1bW5zAgAAAApfZmlsZWREYXRhDF9kaXNwbGF5TmFtZQEBAgAAAAYGAAAAB2xvZ3RleHQGBwAAAAzml6Xlv5flhoXlrrkBBQAAAAQAAAAGCAAAAAdsb2d0aW1lBgkAAAAM5pel5b+X5pel5pyfCw==</Binary>
</Property>
<Property name="ClickActionList">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAAAAAAABwMAAAAAAQAAAAAAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAL</Binary>
</Property>
<Property name="DoubleClickActionList">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAAAAAAABwMAAAAAAQAAAAAAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAL</Binary>
</Property>
<Property name="SelectionChangedActionList">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAAHAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAANBAs=</Binary>
</Property>
<Property name="MCKey">[DataSource1].[ManualLogGridView]</Property>
<Property name="MCDataSourceID" />
<Property name="IsDbControl">True</Property>
<Property name="InitDataSource" />
<Property name="ActionDataSource" />
<Property name="BindDataSource">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAE5TeXN0ZW0uRGF0YSwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAABVTeXN0ZW0uRGF0YS5EYXRhVGFibGUDAAAAGURhdGFUYWJsZS5SZW1vdGluZ1ZlcnNpb24JWG1sU2NoZW1hC1htbERpZmZHcmFtAwEBDlN5c3RlbS5WZXJzaW9uAgAAAAkDAAAABgQAAACFBDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9InV0Zi0xNiI/Pg0KPHhzOnNjaGVtYSB4bWxucz0iIiB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOm1zZGF0YT0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTp4bWwtbXNkYXRhIj4NCiAgPHhzOmVsZW1lbnQgbmFtZT0iTUNEYXRhR3JpZFZpZXciPg0KICAgIDx4czpjb21wbGV4VHlwZT4NCiAgICA8L3hzOmNvbXBsZXhUeXBlPg0KICA8L3hzOmVsZW1lbnQ+DQogIDx4czplbGVtZW50IG5hbWU9InRtcERhdGFTZXQiIG1zZGF0YTpJc0RhdGFTZXQ9InRydWUiIG1zZGF0YTpNYWluRGF0YVRhYmxlPSJNQ0RhdGFHcmlkVmlldyIgbXNkYXRhOlVzZUN1cnJlbnRMb2NhbGU9InRydWUiPg0KICAgIDx4czpjb21wbGV4VHlwZT4NCiAgICAgIDx4czpjaG9pY2UgbWluT2NjdXJzPSIwIiBtYXhPY2N1cnM9InVuYm91bmRlZCIgLz4NCiAgICA8L3hzOmNvbXBsZXhUeXBlPg0KICA8L3hzOmVsZW1lbnQ+DQo8L3hzOnNjaGVtYT4GBQAAAIABPGRpZmZncjpkaWZmZ3JhbSB4bWxuczptc2RhdGE9InVybjpzY2hlbWFzLW1pY3Jvc29mdC1jb206eG1sLW1zZGF0YSIgeG1sbnM6ZGlmZmdyPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOnhtbC1kaWZmZ3JhbS12MSIgLz4EAwAAAA5TeXN0ZW0uVmVyc2lvbgQAAAAGX01ham9yBl9NaW5vcgZfQnVpbGQJX1JldmlzaW9uAAAAAAgICAgCAAAAAAAAAP//////////Cw==</Binary>
</Property>
<Property name="DbOptionType">None</Property>
<Property name="MCVisible">True</Property>
<Property name="MCEnabled">True</Property>
<Property name="AutoGenerateColumns">False</Property>
<Property name="MultiSelect">False</Property>
<Property name="Location">3, 17</Property>
<Property name="Name">MCDataGridView3</Property>
<Property name="Size">357, 751</Property>
<Property name="TabIndex">2</Property>
</Object>
<Property name="TabStop">False</Property>
<Property name="Text">操作日志</Property>
<Property name="Location">696, 12</Property>
<Property name="Name">GroupBox9</Property>
<Property name="Size">366, 771</Property>
<Property name="TabIndex">27</Property>
</Object>
<Object type="System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="GroupBox6" children="Controls">
<Object type="Mesnac.Controls.Default.MCLabel, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="MCLabel84" children="Controls">
@ -455,7 +469,7 @@
</Object>
<Property name="TabStop">False</Property>
<Property name="Text">湿混机螺旋2</Property>
<Property name="Location">867, 12</Property>
<Property name="Location">183, 443</Property>
<Property name="Name">GroupBox6</Property>
<Property name="Size">165, 340</Property>
<Property name="TabIndex">25</Property>
@ -889,7 +903,7 @@
</Object>
<Property name="TabStop">False</Property>
<Property name="Text">湿混机螺旋3</Property>
<Property name="Location">1038, 12</Property>
<Property name="Location">354, 443</Property>
<Property name="Name">GroupBox7</Property>
<Property name="Size">165, 340</Property>
<Property name="TabIndex">25</Property>
@ -1323,7 +1337,7 @@
</Object>
<Property name="TabStop">False</Property>
<Property name="Text">湿混机螺旋4</Property>
<Property name="Location">1209, 12</Property>
<Property name="Location">525, 443</Property>
<Property name="Name">GroupBox8</Property>
<Property name="Size">165, 340</Property>
<Property name="TabIndex">25</Property>
@ -1757,7 +1771,7 @@
</Object>
<Property name="TabStop">False</Property>
<Property name="Text">湿混机螺旋1</Property>
<Property name="Location">696, 12</Property>
<Property name="Location">12, 443</Property>
<Property name="Name">GroupBox5</Property>
<Property name="Size">165, 340</Property>
<Property name="TabIndex">15</Property>
@ -3268,7 +3282,7 @@
<Property name="MCPurview">False</Property>
<Property name="AllowOriginalSizeShow">False</Property>
<Property name="BackColor">Control</Property>
<Property name="Size">1402, 487</Property>
<Property name="Size">1090, 832</Property>
<Property name="StartPosition">WindowsDefaultLocation</Property>
<Property name="Text">手动控制</Property>
<Property name="WindowState">Normal</Property>

Loading…
Cancel
Save