diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs index a5fc8e9..745aa4d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs @@ -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 McControllist; + OperateResult 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.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.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(Log).ExecuteIdentity(); + } + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs index 548de5e..74965b9 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs @@ -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(Log).ExecuteIdentity(); + } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualLogEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualLogEntity.cs new file mode 100644 index 0000000..f5191e7 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualLogEntity.cs @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// Website: http://www.freesql.net +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ +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; + + } + +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 961ec28..2743d1c 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -494,6 +494,7 @@ + Component diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DeviceDetail2Report/DeviceDetail2ReportAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DeviceDetail2Report/DeviceDetail2ReportAction.cs index 141f328..c077ea0 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DeviceDetail2Report/DeviceDetail2ReportAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/DeviceDetail2Report/DeviceDetail2ReportAction.cs @@ -21,6 +21,9 @@ namespace Mesnac.Action.ChemicalWeighing.Report.DeviceDetail2Report List 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 /// 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"); diff --git a/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml b/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml index 748f925..9647c67 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/ManualWaterControl.xml @@ -1,30 +1,44 @@ - - - AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAAEAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIEFEQTI3NUNERUFEODQwREY4NkZFMDBCNjIzOEU0M0Q3BgYAAAAP56qX5L2T5Yid5aeL5YyWBgcAAAAP56qX5L2T5Yid5aeL5YyWCw== - - Refresh - - False - - - - None - True - True - False - - - Red - DarkGray - System - 刷新读数 - 宋体, 19pt - 696, 358 - MCButton9 - 678, 73 - 26 + + + False + + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJoBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EYXRhR3JpZFZpZXdDb2x1bW5zLCBNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGxdXQMAAAAGX2l0ZW1zBV9zaXplCF92ZXJzaW9uBAAAKk1lc25hYy5Db250cm9scy5CYXNlLkRhdGFHcmlkVmlld0NvbHVtbnNbXQIAAAAICAkDAAAAAgAAAF4AAAAHAwAAAAABAAAACAAAAAQoTWVzbmFjLk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DAAAABgQAAACFBDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9InV0Zi0xNiI/Pg0KPHhzOnNjaGVtYSB4bWxucz0iIiB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zOm1zZGF0YT0idXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTp4bWwtbXNkYXRhIj4NCiAgPHhzOmVsZW1lbnQgbmFtZT0iTUNEYXRhR3JpZFZpZXciPg0KICAgIDx4czpjb21wbGV4VHlwZT4NCiAgICA8L3hzOmNvbXBsZXhUeXBlPg0KICA8L3hzOmVsZW1lbnQ+DQogIDx4czplbGVtZW50IG5hbWU9InRtcERhdGFTZXQiIG1zZGF0YTpJc0RhdGFTZXQ9InRydWUiIG1zZGF0YTpNYWluRGF0YVRhYmxlPSJNQ0RhdGFHcmlkVmlldyIgbXNkYXRhOlVzZUN1cnJlbnRMb2NhbGU9InRydWUiPg0KICAgIDx4czpjb21wbGV4VHlwZT4NCiAgICAgIDx4czpjaG9pY2UgbWluT2NjdXJzPSIwIiBtYXhPY2N1cnM9InVuYm91bmRlZCIgLz4NCiAgICA8L3hzOmNvbXBsZXhUeXBlPg0KICA8L3hzOmVsZW1lbnQ+DQo8L3hzOnNjaGVtYT4GBQAAAIABPGRpZmZncjpkaWZmZ3JhbSB4bWxuczptc2RhdGE9InVybjpzY2hlbWFzLW1pY3Jvc29mdC1jb206eG1sLW1zZGF0YSIgeG1sbnM6ZGlmZmdyPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOnhtbC1kaWZmZ3JhbS12MSIgLz4EAwAAAA5TeXN0ZW0uVmVyc2lvbgQAAAAGX01ham9yBl9NaW5vcgZfQnVpbGQJX1JldmlzaW9uAAAAAAgICAgCAAAAAAAAAP//////////Cw== + + None + True + True + False + False + 3, 17 + MCDataGridView3 + 357, 751 + 2 + + False + 操作日志 + 696, 12 + GroupBox9 + 366, 771 + 27 @@ -455,7 +469,7 @@ False 湿混机螺旋2 - 867, 12 + 183, 443 GroupBox6 165, 340 25 @@ -889,7 +903,7 @@ False 湿混机螺旋3 - 1038, 12 + 354, 443 GroupBox7 165, 340 25 @@ -1323,7 +1337,7 @@ False 湿混机螺旋4 - 1209, 12 + 525, 443 GroupBox8 165, 340 25 @@ -1757,7 +1771,7 @@ False 湿混机螺旋1 - 696, 12 + 12, 443 GroupBox5 165, 340 15 @@ -3268,7 +3282,7 @@ False False Control - 1402, 487 + 1090, 832 WindowsDefaultLocation 手动控制 Normal