- RegulValve ADC Open/Close values calibration implemented

- 'More' button added to ComponentCfgCtrl-s
- Dataflow from ComponentParametersDlg to components: CfgChangeHandler
- Dataflow from components to ComponentParametersDlg: CmdResponseHandler
- Detection of parameter changes and appropriate MesssageBox display:
  1.warning message when component configuration change requires program restart
  2.confirmation message box when any configuration changes would be lost
This commit is contained in:
Milan Hanajik
2015-01-03 14:45:58 +01:00
parent d9b1bc8b4a
commit 0160dc965d
49 changed files with 1461 additions and 452 deletions
@@ -2,14 +2,18 @@
using System.Globalization;
using System.Windows.Forms;
using System.IO.Ports;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.MettlerToledo
{
public partial class BalanceCfgCtrl : UserControl, IComponentCfgCtrl
{
BalanceCfg config;
static readonly ILog log = LogManager.GetLogger(typeof(BalanceCfgCtrl));
public bool ShowMore { get { return false; } }
BalanceCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
@@ -90,6 +94,10 @@ namespace TBF.BenchControl.MettlerToledo
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
@@ -121,49 +129,51 @@ namespace TBF.BenchControl.MettlerToledo
emptyTimeTextBox.Enabled = true;
}
public CfgVerifyFlags VerifyCfg(ref string message)
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgVerifyFlags flags = CfgVerifyFlags.None;
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy;
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
{
flags |= CfgVerifyFlags.Error;
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Serial Port Number' is not valid";
}
if (!int.TryParse(baudRateTextBox.Text, out dummy) || dummy < 150 || dummy > 115200)
{
flags |= CfgVerifyFlags.Error;
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Baud Rate' is not valid";
}
if (!int.TryParse(dataBitsTextBox.Text, out dummy) || dummy < 7 || dummy > 8)
{
flags |= CfgVerifyFlags.Error;
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Data Bits' is not valid";
}
float mass;
if (!Utils.TryParseUFloat(capacityTextBox.Text, out mass) || mass <= 0)
{
flags |= CfgVerifyFlags.Error;
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Capacity' is not valid";
}
if (!Utils.TryParseUFloat(emptyTextBox.Text, out mass) || mass <= 0)
{
flags |= CfgVerifyFlags.Error;
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Empty' is not valid";
}
if (!int.TryParse(emptyTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
{
flags |= CfgVerifyFlags.Error;
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Empty Time' should be between 1 and 999 sec";
}
return flags;
}
public void UpdateCfg()
public CfgUpdateFlags UpdateCfg()
{
if (config == null) return; /// Control was not loaded, settings were not changed
CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
@@ -175,6 +185,8 @@ namespace TBF.BenchControl.MettlerToledo
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text);
}
return flags;
}
}
}