参数优化方案

dep
我叫锄头 10 months ago
parent 8bdef78ded
commit 9a6b601201

@ -41,11 +41,11 @@ namespace Mesnac.Action.ChemicalWeighing.LjElectrical
return;
}
LoadingHelper.ShowLoadingScreen();
var watchDog = LjHelp.WatchDog;
if (watchDog == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
@ -61,7 +61,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjElectrical
//select Id, Name, Speed from ElectricalSetting
string sql = $"update ElectricalSetting set Speed={view.Speed} where id={view.Id}";
DBHelp.ExecuteNonQuery(sql);
LoadingHelper.CloseForm();
this.DialogResult = DialogResult.OK;

@ -37,6 +37,10 @@ namespace Mesnac.Action.ChemicalWeighing.LjElectrical
DataTable table =
DBHelp.GetTable(@"select Id, Name, Speed from ElectricalSetting");
var view = ElectricalPlc.UpFromPlc();
if (this._materialGridControl != null && this._materialGridControl.BaseControl != null)
{
this._materialGridControl.BaseControl.BindDataSource = null;

@ -30,17 +30,17 @@ namespace Mesnac.Action.ChemicalWeighing.LjMetage
if (MessageBox.Show("确定下发称量频参数到PLC?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information) == DialogResult.OK)
{
LoadingHelper.ShowLoadingScreen();
var watchDog = LjHelp.WatchDog;
if (watchDog == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
DoWord();
LoadingHelper.CloseForm();
};
}

@ -55,7 +55,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
}
LoadingHelper.ShowLoadingScreen();
@ -97,7 +97,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
var watchDog = LjHelp.WatchDog;
if (watchDog == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
@ -489,7 +489,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning
LoadingHelper.CloseForm();
MessageBox.Show("数据下发成功");
if (OnDown != null)

@ -19,7 +19,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
public FrmPressureUpdate(int id) : this()
{
LoadingHelper.ShowLoadingScreen();
_id = id;
@ -41,7 +41,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
var i = LjHelp.WatchDog;
if (i == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
@ -67,7 +67,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
MessageBox.Show("获取PLC 异常请联系管理员");
}
LoadingHelper.CloseForm();
}
private void btnCancel_Click(object sender, EventArgs e)

@ -28,11 +28,11 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
private void DoWord()
{
LoadingHelper.ShowLoadingScreen();
var i = LjHelp.WatchDog;
if (i == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
ICSharpCode.Core.LoggingService<UpAction>.Warn("PLC通讯失败");
return;
@ -46,7 +46,6 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
DBHelp.ExecuteNonQuery(sql);
}
LoadingHelper.CloseForm();
if (OnHandler != null)
{

@ -28,17 +28,17 @@ namespace Mesnac.Action.ChemicalWeighing.LjProportional
if (MessageBox.Show("确定下发比例阀参数到PLC?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) ==
DialogResult.OK)
{
LoadingHelper.ShowLoadingScreen();
var watchDog = LjHelp.WatchDog;
if (watchDog == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
DoWord();
LoadingHelper.CloseForm();
if (OnHandler != null)
{

@ -46,7 +46,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjProportional
var watchDoy = LjHelp.WatchDog;
if (watchDoy == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
@ -59,14 +59,14 @@ namespace Mesnac.Action.ChemicalWeighing.LjProportional
var i = LjHelp.WatchDog;
if (i == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
LoadingHelper.ShowLoadingScreen();
ProportionalPlc.DownToPlc(new []{view});
ProportionalDB.Update(view);
LoadingHelper.CloseForm();
this.DialogResult = DialogResult.OK;
}
}

@ -24,17 +24,17 @@ namespace Mesnac.Action.ChemicalWeighing
/// <summary>
/// 显示loading框
/// </summary>
public static void ShowLoadingScreen()
{
// Make sure it is only launched once.
if (loading != null)
return;
Thread thread = new Thread(new ThreadStart(LoadingHelper.ShowForm));
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
//public static void ShowLoadingScreen()
//{
// // Make sure it is only launched once.
// if (loading != null)
// return;
// Thread thread = new Thread(new ThreadStart(LoadingHelper.ShowForm));
// thread.IsBackground = true;
// thread.SetApartmentState(ApartmentState.STA);
// thread.Start();
}
//}
/// <summary>
/// 显示窗口
@ -54,22 +54,22 @@ namespace Mesnac.Action.ChemicalWeighing
/// <summary>
/// 关闭窗口
/// </summary>
public static void CloseForm()
{
Thread.Sleep(50); //可能到这里线程还未起来,所以进行延时,可以确保线程起来,彻底关闭窗口
if (loading != null)
{
lock (syncLock)
{
Thread.Sleep(50);
if (loading != null)
{
Thread.Sleep(50); //通过三次延时,确保可以彻底关闭窗口
loading.Invoke(new CloseDelegate(LoadingHelper.CloseFormInternal));
}
}
}
}
//public static void CloseForm()
//{
// Thread.Sleep(50); //可能到这里线程还未起来,所以进行延时,可以确保线程起来,彻底关闭窗口
// if (loading != null)
// {
// lock (syncLock)
// {
// Thread.Sleep(50);
// if (loading != null)
// {
// Thread.Sleep(50); //通过三次延时,确保可以彻底关闭窗口
// loading.Invoke(new CloseDelegate(LoadingHelper.CloseFormInternal));
// }
// }
// }
//}
/// <summary>
/// 关闭窗口,委托中使用

@ -2,7 +2,12 @@
using System.Data;
using System.Linq;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjElectrical;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
using Mesnac.Action.ChemicalWeighing.LjMetage;
using Mesnac.Action.ChemicalWeighing.LjPressure;
using Mesnac.Action.ChemicalWeighing.LjProportional;
using Mesnac.Action.ChemicalWeighing.LjWeight;
namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
{
@ -31,7 +36,7 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
UpActionProportional.Run(runtime);
UpActionWeight.Run(runtime);
LoadingHelper.CloseForm();
}
private void InitEvent()
@ -140,8 +145,21 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "pressureSetting")
.FirstOrDefault(); //获取物料数据控件
//table.Rows.Clear();
var pressureSettingViews = PressurePLC.UpdateFromPlc();
foreach (var v in pressureSettingViews)
{
string sql =
$"update PressureSetting set LowLimit={v.LowLimit},HighLimit={v.HighLimit} where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
DataTable table =
DBHelp.GetTable(@"select Id,Name,ActualValue,LowLimit,HighLimit,Alarm,
DBHelp.GetTable(@"select Id,Name,ActualValue,LowLimit,HighLimit,Alarm,
case Alarm when 1 then '' else '' end as AlarmValue from pressureSetting;");
@ -160,6 +178,16 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ProportionalSetting")
.FirstOrDefault(); //获取物料数据控件
var views = ProportionalPlc.UpFromPlc();
foreach (var v in views)
{
string sql =
$"update ProportionalSetting set SV={v.SV},PV={v.PV} where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
DataTable table =
DBHelp.GetTable(@"select Id, Name, PV, SV from ProportionalSetting");
@ -179,6 +207,15 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "WeightSetting")
.FirstOrDefault(); //获取物料数据控件
var views = WeightSettingPlc.UpFromPlc();
foreach (var v in views)
{
string sql =
$"update WeightSetting set LowWeight={v.LowWeight},HighWeight={v.HighWeight} where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
DataTable table =
DBHelp.GetTable(@"select Id,Name,ActWeight,HighLevel,HighWeight,LowLevel,LowWeight from WeightSetting");
@ -196,6 +233,16 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ElectricalSetting")
.FirstOrDefault(); //获取物料数据控件
var view = ElectricalPlc.UpFromPlc();
foreach (var v in view)
{
string sql =
$"update ElectricalSetting set Speed={v.Speed} where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
DataTable table =
DBHelp.GetTable(@"select Id, Name, Speed from ElectricalSetting");
@ -213,6 +260,15 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "MetageSetting")
.FirstOrDefault(); //获取物料数据控件
var view = MetagePlc.UpFromPlc();
foreach (var v in view)
{
string sql =
$"update MetageSetting set HighSpeed={v.HighSpeed},LowSpeed={v.LowSpeed},WeightSlow={v.WeightSlow},Precut={v.Precut},JogTime={v.JogTime} where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
DataTable table =
DBHelp.GetTable(@"select Id, Name, HighSpeed, LowSpeed, WeightSlow, Precut, JogTime from MetageSetting");

Loading…
Cancel
Save