- 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
@@ -1,5 +1,6 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
using TBF.Resources; using TBF.Resources;
@@ -7,8 +8,11 @@ namespace TBF.BenchControl.BenchId
{ {
public partial class ComponentCfgCtrl : UserControl, IComponentCfgCtrl public partial class ComponentCfgCtrl : UserControl, IComponentCfgCtrl
{ {
ComponentCfg config; static readonly ILog log = LogManager.GetLogger(typeof(ComponentCfgCtrl));
public bool ShowMore { get { return false; } }
ComponentCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +35,10 @@ namespace TBF.BenchControl.BenchId
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -45,19 +53,24 @@ namespace TBF.BenchControl.BenchId
numberTextBox.Enabled = true; numberTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
try { config.TestBenchNr = int.Parse(numberTextBox.Text); } try { config.TestBenchNr = int.Parse(numberTextBox.Text); }
catch { config.TestBenchNr = 1; } catch { config.TestBenchNr = 1; }
return flags;
} }
} }
} }
@@ -1,14 +1,19 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO.Ports; using System.IO.Ports;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Cameras.CameraRoi namespace TBF.BenchControl.Cameras.CameraRoi
{ {
public partial class CameraRoiCfgCtrl : UserControl, IComponentCfgCtrl public partial class CameraRoiCfgCtrl : UserControl, IComponentCfgCtrl
{ {
static readonly ILog log = LogManager.GetLogger(typeof(CameraRoiCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
CameraRoiCfg config; CameraRoiCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -45,6 +50,10 @@ namespace TBF.BenchControl.Cameras.CameraRoi
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -62,33 +71,37 @@ namespace TBF.BenchControl.Cameras.CameraRoi
roiTextBox.Enabled = true; roiTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
int dummy; int dummy;
if (!int.TryParse(roiTextBox.Text, out dummy) || dummy < 1 || dummy > 4) if (!int.TryParse(roiTextBox.Text, out dummy) || dummy < 1 || dummy > 4)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Region of Interest' is not valid"; message += Environment.NewLine + "'Region of Interest' is not valid";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.RoiNr = int.Parse(roiTextBox.Text); config.RoiNr = int.Parse(roiTextBox.Text);
return flags;
} }
} }
} }
@@ -1,14 +1,18 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO.Ports; using System.IO.Ports;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Cameras.IdcCamera namespace TBF.BenchControl.Cameras.IdcCamera
{ {
public partial class IdcCameraCfgCtrl : UserControl, IComponentCfgCtrl public partial class IdcCameraCfgCtrl : UserControl, IComponentCfgCtrl
{ {
IdcCameraCfg config; static readonly ILog log = LogManager.GetLogger(typeof(IdcCameraCfgCtrl));
public bool ShowMore { get { return false; } }
IdcCameraCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -32,6 +36,10 @@ namespace TBF.BenchControl.Cameras.IdcCamera
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -51,38 +59,42 @@ namespace TBF.BenchControl.Cameras.IdcCamera
brightnessTextBox.Enabled = true; brightnessTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999) 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"; message += Environment.NewLine + "'Serial Port Number' is not valid";
} }
if (!int.TryParse(baudRateComboBox.Text, out dummy) || ((dummy != 57600) && (dummy != 115200))) if (!int.TryParse(baudRateComboBox.Text, out dummy) || ((dummy != 57600) && (dummy != 115200)))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Baud Rate' should be 57600 or 115200 Bd"; message += Environment.NewLine + "'Baud Rate' should be 57600 or 115200 Bd";
} }
if (!int.TryParse(brightnessTextBox.Text, out dummy) || dummy < 0 || dummy > 100) if (!int.TryParse(brightnessTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Brightness' should be between 0 and 100 %"; message += Environment.NewLine + "'Brightness' should be between 0 and 100 %";
} }
return flags; 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.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text); config.ComPortNr = int.Parse(comPortNrTextBox.Text);
config.BaudRate = int.Parse(baudRateComboBox.Text); config.BaudRate = int.Parse(baudRateComboBox.Text);
config.BrightnessCam = ((float)int.Parse(brightnessTextBox.Text) / 100.0f); config.BrightnessCam = ((float)int.Parse(brightnessTextBox.Text) / 100.0f);
return flags;
} }
} }
} }
@@ -0,0 +1,16 @@
using System;
namespace TBF.BenchControl
{
public class CfgChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public Generic.IComponentCfg Cfg;
public CfgChangeArgs(CfgChangeCmd command, Generic.IComponentCfg cfg)
{
Command = command;
Cfg = cfg;
}
}
}
@@ -0,0 +1,16 @@
using System;
namespace TBF.BenchControl
{
public class CmdResponseArgs : EventArgs
{
public CfgChangeCmd Command;
public int Response;
public CmdResponseArgs(CfgChangeCmd command, int response)
{
Command = command;
Response = response;
}
}
}
@@ -26,11 +26,13 @@ namespace TBF.BenchControl
this.cfg = cfg; this.cfg = cfg;
} }
/// <summary> /// <summary> Empty implementation, might be overriden in derived classes </summary>
/// Empty implementation, might be overriden in derived classes public static void ResetStaticProperties() { }
/// </summary>
public static void ResetStaticProperties() /// <summary> Empty implementation, might be overriden in derived classes </summary>
{ public virtual void StartChangeHandler() { }
}
/// <summary> Empty implementation, might be overriden in derived classes </summary>
public virtual void StopChangeHandler() { }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.DataEntry.Munich
{ {
static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl));
EntryFormCfg config; public bool ShowMore { get { return false; } }
EntryFormCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.DataEntry.Munich
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -49,19 +54,24 @@ namespace TBF.BenchControl.DataEntry.Munich
protocolTitle3TextBox.Enabled = true; protocolTitle3TextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
config.ProtocolTitle1 = protocolTitle1TextBox.Text; config.ProtocolTitle1 = protocolTitle1TextBox.Text;
config.ProtocolTitle2 = protocolTitle2TextBox.Text; config.ProtocolTitle2 = protocolTitle2TextBox.Text;
config.ProtocolTitle3 = protocolTitle3TextBox.Text; config.ProtocolTitle3 = protocolTitle3TextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.DataEntry.Munich3
{ {
static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl));
EntryFormCfg config; public bool ShowMore { get { return false; } }
EntryFormCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.DataEntry.Munich3
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -49,19 +54,24 @@ namespace TBF.BenchControl.DataEntry.Munich3
protocolTitle3TextBox.Enabled = true; protocolTitle3TextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
config.ProtocolTitle1 = protocolTitle1TextBox.Text; config.ProtocolTitle1 = protocolTitle1TextBox.Text;
config.ProtocolTitle2 = protocolTitle2TextBox.Text; config.ProtocolTitle2 = protocolTitle2TextBox.Text;
config.ProtocolTitle3 = protocolTitle3TextBox.Text; config.ProtocolTitle3 = protocolTitle3TextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.DataEntry.WMStates
{ {
static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(EntryFormCfgCtrl));
EntryFormCfg config; public bool ShowMore { get { return false; } }
EntryFormCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.DataEntry.WMStates
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.DataEntry.WMStates
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -1,11 +1,16 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde namespace TBF.BenchControl.Elde
{ {
public partial class ControlBoardCfgCtrl : UserControl, IComponentCfgCtrl public partial class ControlBoardCfgCtrl : UserControl, IComponentCfgCtrl
{ {
static readonly ILog log = LogManager.GetLogger(typeof(ControlBoardCfgCtrl));
public bool ShowMore { get { return false; } }
ControlBoardCfg config; ControlBoardCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -27,6 +32,10 @@ namespace TBF.BenchControl.Elde
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -47,15 +56,15 @@ namespace TBF.BenchControl.Elde
/// Called when user wants to close/save the configuration. /// Called when user wants to close/save the configuration.
/// </summary> /// </summary>
/// <returns>See VerifyFlags</returns> /// <returns>See VerifyFlags</returns>
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy <= 0 || dummy > 999) if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy <= 0 || dummy > 999)
{ {
message += "Control board serial port number is invalid"; message += "Control board serial port number is invalid";
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
} }
return flags; return flags;
@@ -64,12 +73,16 @@ namespace TBF.BenchControl.Elde
/// <summary> /// <summary>
/// Save settings to the configuration class. /// Save settings to the configuration class.
/// </summary> /// </summary>
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
this.Name = nameTextBox.Text; this.Name = nameTextBox.Text;
this.config.ComPortNr = int.Parse(comPortNrTextBox.Text); this.config.ComPortNr = int.Parse(comPortNrTextBox.Text);
return flags;
} }
} }
} }
@@ -1,12 +1,18 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Elde.Diverter namespace TBF.BenchControl.Elde.Diverter
{ {
public partial class DiverterCfgCtrl : UserControl, IComponentCfgCtrl public partial class DiverterCfgCtrl : UserControl, IComponentCfgCtrl
{ {
static readonly ILog log = LogManager.GetLogger(typeof(DiverterCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
DiverterCfg config; DiverterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -42,6 +48,10 @@ namespace TBF.BenchControl.Elde.Diverter
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -59,31 +69,35 @@ namespace TBF.BenchControl.Elde.Diverter
bitPositionTextBox.Enabled = true; bitPositionTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64) if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.BitPosition = int.Parse(bitPositionTextBox.Text); config.BitPosition = int.Parse(bitPositionTextBox.Text);
return flags;
} }
} }
} }
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
static readonly ILog log = LogManager.GetLogger(typeof(RegisterReaderCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(RegisterReaderCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
RegisterReaderCfg config; RegisterReaderCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -60,24 +67,28 @@ namespace TBF.BenchControl.Elde.FixedStartRegisterReader
parentNameComboBox.Enabled = true; parentNameComboBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
return flags;
} }
} }
} }
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Elde.FlowMeter
static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
FlowMeterCfg config; FlowMeterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -46,6 +49,10 @@ namespace TBF.BenchControl.Elde.FlowMeter
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -65,38 +72,42 @@ namespace TBF.BenchControl.Elde.FlowMeter
nominalFlowTextBox.Enabled = true; nominalFlowTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 7) if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 7)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Idx1' should be between 1 and 7"; message += Environment.NewLine + "'Idx1' should be between 1 and 7";
} }
float fdummy; float fdummy;
if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.2 || fdummy > 1600) if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.2 || fdummy > 1600)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Nominal flow' should be between 0.2 and 1600"; message += Environment.NewLine + "'Nominal flow' should be between 0.2 and 1600";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx1 = int.Parse(positionTextBox.Text); config.Idx1 = int.Parse(positionTextBox.Text);
Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow); Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow);
}
return flags;
}
} }
} }
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(FlowMeterCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
FlowMeterCfg config; FlowMeterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -51,6 +54,10 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -72,43 +79,47 @@ namespace TBF.BenchControl.Elde.FlowMeterTwins
nominalFlowTextBox.Enabled = true; nominalFlowTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!flowMeter1ComboBox.Items.Contains(flowMeter1ComboBox.Text)) if (!flowMeter1ComboBox.Items.Contains(flowMeter1ComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Flow Meter 1'"; message += Environment.NewLine + "Invalid 'Flow Meter 1'";
} }
if (!flowMeter2ComboBox.Items.Contains(flowMeter2ComboBox.Text)) if (!flowMeter2ComboBox.Items.Contains(flowMeter2ComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Flow Meter 2'"; message += Environment.NewLine + "Invalid 'Flow Meter 2'";
} }
float fdummy; float fdummy;
if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.2 || fdummy > 1600) if (!Utils.TryParseUFloat(nominalFlowTextBox.Text, out fdummy) || fdummy < 0.2 || fdummy > 1600)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Nominal flow' should be between 0.2 and 1600"; message += Environment.NewLine + "'Nominal flow' should be between 0.2 and 1600";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.FlowMeter1 = flowMeter1ComboBox.Text.Equals("---") ? string.Empty : flowMeter1ComboBox.Text; config.FlowMeter1 = flowMeter1ComboBox.Text.Equals("---") ? string.Empty : flowMeter1ComboBox.Text;
config.FlowMeter2 = flowMeter2ComboBox.Text.Equals("---") ? string.Empty : flowMeter2ComboBox.Text; config.FlowMeter2 = flowMeter2ComboBox.Text.Equals("---") ? string.Empty : flowMeter2ComboBox.Text;
Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow); Utils.TryParseUFloat(nominalFlowTextBox.Text, out config.NominalFlow);
}
return flags;
}
} }
} }
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.PressureMeter
static readonly ILog log = LogManager.GetLogger(typeof(PressureMeterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(PressureMeterCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
PressureMeterCfg config; PressureMeterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.PressureMeter
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -64,37 +71,41 @@ namespace TBF.BenchControl.Elde.PressureMeter
rs485AddressTextBox.Enabled = true; rs485AddressTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7) if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be between 0 and 7"; message += Environment.NewLine + "'Position' should be between 0 and 7";
} }
if (!int.TryParse(rs485AddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255) if (!int.TryParse(rs485AddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'RS485 Address' should be between 0 and 255"; message += Environment.NewLine + "'RS485 Address' should be between 0 and 255";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Idx0 = int.Parse(positionTextBox.Text); config.Idx0 = int.Parse(positionTextBox.Text);
config.RS485Address = (byte)int.Parse(rs485AddressTextBox.Text); config.RS485Address = (byte)int.Parse(rs485AddressTextBox.Text);
return flags;
} }
} }
} }
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.Pump
static readonly ILog log = LogManager.GetLogger(typeof(PumpCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(PumpCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
PumpCfg config; PumpCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.Pump
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -64,34 +71,38 @@ namespace TBF.BenchControl.Elde.Pump
delayTextBox.Enabled = true; delayTextBox.Enabled = true;
} }
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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.BitPosition = int.Parse(bitPositionTextBox.Text); config.BitPosition = int.Parse(bitPositionTextBox.Text);
config.Delay = int.Parse(delayTextBox.Text); config.Delay = int.Parse(delayTextBox.Text);
}
public CfgVerifyFlags VerifyCfg(ref string message) return flags;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64) if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
} }
if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300) if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)"; message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
} }
return flags; return flags;
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.PumpWithFM
static readonly ILog log = LogManager.GetLogger(typeof(PumpCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(PumpCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
PumpCfg config; PumpCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.PumpWithFM
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -66,40 +73,44 @@ namespace TBF.BenchControl.Elde.PumpWithFM
delayTextBox.Enabled = true; delayTextBox.Enabled = true;
} }
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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.BitPosition = int.Parse(bitPositionTextBox.Text); config.BitPosition = int.Parse(bitPositionTextBox.Text);
config.FMIndex = int.Parse(fmIndexTextBox.Text); config.FMIndex = int.Parse(fmIndexTextBox.Text);
config.Delay = int.Parse(delayTextBox.Text); config.Delay = int.Parse(delayTextBox.Text);
}
public CfgVerifyFlags VerifyCfg(ref string message) return flags;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64) if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
} }
if (!int.TryParse(fmIndexTextBox.Text, out dummy) || dummy < 0) if (!int.TryParse(fmIndexTextBox.Text, out dummy) || dummy < 0)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'FM Index' should be between 0 and FMPumpsCount - 1"; message += Environment.NewLine + "'FM Index' should be between 0 and FMPumpsCount - 1";
} }
if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300) if (!int.TryParse(delayTextBox.Text, out dummy) || dummy < 0 || dummy >= 300)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)"; message += Environment.NewLine + "'Delay' should be between 0 and 300s (5min)";
} }
return flags; return flags;
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.RegisterReader
static readonly ILog log = LogManager.GetLogger(typeof(RegisterReaderCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(RegisterReaderCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
RegisterReaderCfg config; RegisterReaderCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -45,6 +48,10 @@ namespace TBF.BenchControl.Elde.RegisterReader
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -62,31 +69,35 @@ namespace TBF.BenchControl.Elde.RegisterReader
positionTextBox.Enabled = true; positionTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(positionTextBox.Text, out dummy) || (dummy < 1)) if (!int.TryParse(positionTextBox.Text, out dummy) || (dummy < 1))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be >= 1"; message += Environment.NewLine + "'Position' should be >= 1";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
config.Position = int.Parse(positionTextBox.Text); config.Position = int.Parse(positionTextBox.Text);
return flags;
} }
} }
} }
@@ -29,6 +29,56 @@ namespace TBF.BenchControl.Elde.RegulValve
get { return controlBoard.RValvePosition(Idx1); } get { return controlBoard.RValvePosition(Idx1); }
} }
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)
{
if (CfgChangeHandler == null) return;
try { CfgChangeHandler(sender, args); }
catch (Exception e) { log.Error("CfgChangeHandler(...) failed", e); }
}
public static event EventHandler<CfgChangeArgs> CfgChangeHandler;
public override void StartChangeHandler()
{
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
{
RegulValveCfg tmpcfg = args.Cfg as RegulValveCfg;
if (tmpcfg != null && tmpcfg.Name.Equals(Name))
{
if (args.Command == CfgChangeCmd.CfgChange)
{
RegulValveCfg.PidCoef = tmpcfg.PidCoef;
RegulValveCfg.StableTimeMs = tmpcfg.StableTimeMs;
RegulValveCfg.FlowStableSec = tmpcfg.FlowStableSec;
}
else if (args.Command == CfgChangeCmd.RVOpenStep)
{
controlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new float[2] { 0.05f, 0.05f }, StableTime);
// TODO: avoid conflicts
// TOTEST
}
else if (args.Command == CfgChangeCmd.RVCloseStep)
{
controlBoard.ValveMove(Idx1, RegulValveMode.PulseWidth, new float[2] { -0.05f, -0.05f }, StableTime);
// TODO: avoid conflicts
// TOTEST
}
else if (args.Command == CfgChangeCmd.GetRVAdc1 || args.Command == CfgChangeCmd.GetRVAdc2)
{
int adc = (int)controlBoard.AnalogInputRaw(Idx1, 0);
// TOTEST
RegulValveCfgCtrl.OnCmdResponse(this, new CmdResponseArgs(args.Command, adc));
}
}
};
}
#endregion Configuration Change Handling
public RegulValve(RegulValveCfg cfg, IList<Generic.IComponent> components) public RegulValve(RegulValveCfg cfg, IList<Generic.IComponent> components)
: base(cfg) : base(cfg)
{ {
@@ -0,0 +1,16 @@
using System;
namespace TBF.BenchControl.Elde.RegulValve
{
public class RegulValveCfgChangeArgs : EventArgs
{
public CfgChangeCmd Command;
public Generic.IComponentCfg Cfg;
public RegulValveCfgChangeArgs(CfgChangeCmd command, Generic.IComponentCfg cfg)
{
Command = command;
Cfg = cfg;
}
}
}
@@ -28,210 +28,403 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.positionTextBox = new System.Windows.Forms.TextBox(); this.positionTextBox = new System.Windows.Forms.TextBox();
this.positionLabel = new System.Windows.Forms.Label(); this.positionLabel = new System.Windows.Forms.Label();
this.parentNameLabel = new System.Windows.Forms.Label(); this.parentNameLabel = new System.Windows.Forms.Label();
this.nameTextBox = new System.Windows.Forms.TextBox(); this.nameTextBox = new System.Windows.Forms.TextBox();
this.nameLabel = new System.Windows.Forms.Label(); this.nameLabel = new System.Windows.Forms.Label();
this.classNameLabel = new System.Windows.Forms.Label(); this.classNameLabel = new System.Windows.Forms.Label();
this.dacClosedLabel = new System.Windows.Forms.Label(); this.dacClosedLabel = new System.Windows.Forms.Label();
this.dacClosedTextBox = new System.Windows.Forms.TextBox(); this.dacClosedTextBox = new System.Windows.Forms.TextBox();
this.dacOpenTextBox = new System.Windows.Forms.TextBox(); this.dacOpenTextBox = new System.Windows.Forms.TextBox();
this.dacOpenLabel = new System.Windows.Forms.Label(); this.dacOpenLabel = new System.Windows.Forms.Label();
this.parentNameComboBox = new System.Windows.Forms.ComboBox(); this.parentNameComboBox = new System.Windows.Forms.ComboBox();
this.pidCoefLabel = new System.Windows.Forms.Label(); this.pidCoefLabel = new System.Windows.Forms.Label();
this.pidCoefTextBox = new System.Windows.Forms.TextBox(); this.pidCoefTextBox = new System.Windows.Forms.TextBox();
this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox(); this.storedPosReuseCheckBox = new System.Windows.Forms.CheckBox();
this.stableTimeTextBox = new System.Windows.Forms.TextBox(); this.stableTimeTextBox = new System.Windows.Forms.TextBox();
this.stableTimeLabel = new System.Windows.Forms.Label(); this.stableTimeLabel = new System.Windows.Forms.Label();
this.flowStableSecTextBox = new System.Windows.Forms.TextBox(); this.flowStableSecTextBox = new System.Windows.Forms.TextBox();
this.flowStableSecLabel = new System.Windows.Forms.Label(); this.flowStableSecLabel = new System.Windows.Forms.Label();
this.SuspendLayout(); this.groupBox1 = new System.Windows.Forms.GroupBox();
// this.setButton1 = new System.Windows.Forms.Button();
// positionTextBox this.label1 = new System.Windows.Forms.Label();
// this.ADC = new System.Windows.Forms.Label();
this.positionTextBox.Enabled = false; this.getButton1 = new System.Windows.Forms.Button();
this.positionTextBox.Location = new System.Drawing.Point(138, 78); this.pctTextBox1 = new System.Windows.Forms.TextBox();
this.positionTextBox.Name = "positionTextBox"; this.adcTextBox1 = new System.Windows.Forms.TextBox();
this.positionTextBox.Size = new System.Drawing.Size(46, 20); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.positionTextBox.TabIndex = 6; this.setButton2 = new System.Windows.Forms.Button();
// this.label2 = new System.Windows.Forms.Label();
// positionLabel this.label3 = new System.Windows.Forms.Label();
// this.getButton2 = new System.Windows.Forms.Button();
this.positionLabel.AutoSize = true; this.pctTextBox2 = new System.Windows.Forms.TextBox();
this.positionLabel.Location = new System.Drawing.Point(28, 81); this.adcTextBox2 = new System.Windows.Forms.TextBox();
this.positionLabel.Name = "positionLabel"; this.groupBox3 = new System.Windows.Forms.GroupBox();
this.positionLabel.Size = new System.Drawing.Size(18, 13); this.closeButton = new System.Windows.Forms.Button();
this.positionLabel.TabIndex = 5; this.openButton = new System.Windows.Forms.Button();
this.positionLabel.Text = "ID"; this.groupBox1.SuspendLayout();
// this.groupBox2.SuspendLayout();
// parentNameLabel this.groupBox3.SuspendLayout();
// this.SuspendLayout();
this.parentNameLabel.AutoSize = true; //
this.parentNameLabel.Location = new System.Drawing.Point(28, 57); // positionTextBox
this.parentNameLabel.Name = "parentNameLabel"; //
this.parentNameLabel.Size = new System.Drawing.Size(69, 13); this.positionTextBox.Enabled = false;
this.parentNameLabel.TabIndex = 3; this.positionTextBox.Location = new System.Drawing.Point(138, 78);
this.parentNameLabel.Text = "Parent Name"; this.positionTextBox.Name = "positionTextBox";
// this.positionTextBox.Size = new System.Drawing.Size(46, 20);
// nameTextBox this.positionTextBox.TabIndex = 6;
// //
this.nameTextBox.Enabled = false; // positionLabel
this.nameTextBox.Location = new System.Drawing.Point(138, 30); //
this.nameTextBox.Name = "nameTextBox"; this.positionLabel.AutoSize = true;
this.nameTextBox.Size = new System.Drawing.Size(130, 20); this.positionLabel.Location = new System.Drawing.Point(28, 81);
this.nameTextBox.TabIndex = 2; this.positionLabel.Name = "positionLabel";
// this.positionLabel.Size = new System.Drawing.Size(18, 13);
// nameLabel this.positionLabel.TabIndex = 5;
// this.positionLabel.Text = "ID";
this.nameLabel.AutoSize = true; //
this.nameLabel.Location = new System.Drawing.Point(28, 33); // parentNameLabel
this.nameLabel.Name = "nameLabel"; //
this.nameLabel.Size = new System.Drawing.Size(35, 13); this.parentNameLabel.AutoSize = true;
this.nameLabel.TabIndex = 1; this.parentNameLabel.Location = new System.Drawing.Point(28, 57);
this.nameLabel.Text = "Name"; this.parentNameLabel.Name = "parentNameLabel";
// this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
// classNameLabel this.parentNameLabel.TabIndex = 3;
// this.parentNameLabel.Text = "Parent Name";
this.classNameLabel.AutoSize = true; //
this.classNameLabel.Location = new System.Drawing.Point(135, 9); // nameTextBox
this.classNameLabel.Name = "classNameLabel"; //
this.classNameLabel.Size = new System.Drawing.Size(89, 13); this.nameTextBox.Enabled = false;
this.classNameLabel.TabIndex = 0; this.nameTextBox.Location = new System.Drawing.Point(138, 30);
this.classNameLabel.Text = "ComponentName"; this.nameTextBox.Name = "nameTextBox";
// this.nameTextBox.Size = new System.Drawing.Size(130, 20);
// dacClosedLabel this.nameTextBox.TabIndex = 2;
// //
this.dacClosedLabel.AutoSize = true; // nameLabel
this.dacClosedLabel.Location = new System.Drawing.Point(28, 104); //
this.dacClosedLabel.Name = "dacClosedLabel"; this.nameLabel.AutoSize = true;
this.dacClosedLabel.Size = new System.Drawing.Size(93, 13); this.nameLabel.Location = new System.Drawing.Point(28, 33);
this.dacClosedLabel.TabIndex = 7; this.nameLabel.Name = "nameLabel";
this.dacClosedLabel.Text = "DAC when Closed"; this.nameLabel.Size = new System.Drawing.Size(35, 13);
// this.nameLabel.TabIndex = 1;
// dacClosedTextBox this.nameLabel.Text = "Name";
// //
this.dacClosedTextBox.Enabled = false; // classNameLabel
this.dacClosedTextBox.Location = new System.Drawing.Point(138, 101); //
this.dacClosedTextBox.Name = "dacClosedTextBox"; this.classNameLabel.AutoSize = true;
this.dacClosedTextBox.Size = new System.Drawing.Size(46, 20); this.classNameLabel.Location = new System.Drawing.Point(135, 9);
this.dacClosedTextBox.TabIndex = 8; this.classNameLabel.Name = "classNameLabel";
// this.classNameLabel.Size = new System.Drawing.Size(89, 13);
// dacOpenTextBox this.classNameLabel.TabIndex = 0;
// this.classNameLabel.Text = "ComponentName";
this.dacOpenTextBox.Enabled = false; //
this.dacOpenTextBox.Location = new System.Drawing.Point(138, 124); // dacClosedLabel
this.dacOpenTextBox.Name = "dacOpenTextBox"; //
this.dacOpenTextBox.Size = new System.Drawing.Size(46, 20); this.dacClosedLabel.AutoSize = true;
this.dacOpenTextBox.TabIndex = 10; this.dacClosedLabel.Location = new System.Drawing.Point(28, 104);
// this.dacClosedLabel.Name = "dacClosedLabel";
// dacOpenLabel this.dacClosedLabel.Size = new System.Drawing.Size(93, 13);
// this.dacClosedLabel.TabIndex = 7;
this.dacOpenLabel.AutoSize = true; this.dacClosedLabel.Text = "DAC when Closed";
this.dacOpenLabel.Location = new System.Drawing.Point(28, 127); //
this.dacOpenLabel.Name = "dacOpenLabel"; // dacClosedTextBox
this.dacOpenLabel.Size = new System.Drawing.Size(87, 13); //
this.dacOpenLabel.TabIndex = 9; this.dacClosedTextBox.Enabled = false;
this.dacOpenLabel.Text = "DAC when Open"; this.dacClosedTextBox.Location = new System.Drawing.Point(138, 101);
// this.dacClosedTextBox.Name = "dacClosedTextBox";
// parentNameComboBox this.dacClosedTextBox.Size = new System.Drawing.Size(46, 20);
// this.dacClosedTextBox.TabIndex = 8;
this.parentNameComboBox.Enabled = false; //
this.parentNameComboBox.FormattingEnabled = true; // dacOpenTextBox
this.parentNameComboBox.Location = new System.Drawing.Point(138, 54); //
this.parentNameComboBox.Name = "parentNameComboBox"; this.dacOpenTextBox.Enabled = false;
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21); this.dacOpenTextBox.Location = new System.Drawing.Point(138, 124);
this.parentNameComboBox.TabIndex = 4; this.dacOpenTextBox.Name = "dacOpenTextBox";
// this.dacOpenTextBox.Size = new System.Drawing.Size(46, 20);
// pidCoefLabel this.dacOpenTextBox.TabIndex = 10;
// //
this.pidCoefLabel.AutoSize = true; // dacOpenLabel
this.pidCoefLabel.Location = new System.Drawing.Point(28, 150); //
this.pidCoefLabel.Name = "pidCoefLabel"; this.dacOpenLabel.AutoSize = true;
this.pidCoefLabel.Size = new System.Drawing.Size(78, 13); this.dacOpenLabel.Location = new System.Drawing.Point(28, 127);
this.pidCoefLabel.TabIndex = 11; this.dacOpenLabel.Name = "dacOpenLabel";
this.pidCoefLabel.Text = "PID Coefficient"; this.dacOpenLabel.Size = new System.Drawing.Size(87, 13);
// this.dacOpenLabel.TabIndex = 9;
// pidCoefTextBox this.dacOpenLabel.Text = "DAC when Open";
// //
this.pidCoefTextBox.Enabled = false; // parentNameComboBox
this.pidCoefTextBox.Location = new System.Drawing.Point(138, 147); //
this.pidCoefTextBox.Name = "pidCoefTextBox"; this.parentNameComboBox.Enabled = false;
this.pidCoefTextBox.Size = new System.Drawing.Size(46, 20); this.parentNameComboBox.FormattingEnabled = true;
this.pidCoefTextBox.TabIndex = 12; this.parentNameComboBox.Location = new System.Drawing.Point(138, 54);
// this.parentNameComboBox.Name = "parentNameComboBox";
// storedPosReuseCheckBox this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
// this.parentNameComboBox.TabIndex = 4;
this.storedPosReuseCheckBox.AutoSize = true; //
this.storedPosReuseCheckBox.Enabled = false; // pidCoefLabel
this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 196); //
this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox"; this.pidCoefLabel.AutoSize = true;
this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17); this.pidCoefLabel.Location = new System.Drawing.Point(28, 150);
this.storedPosReuseCheckBox.TabIndex = 13; this.pidCoefLabel.Name = "pidCoefLabel";
this.storedPosReuseCheckBox.Text = "Enable stored position re-use"; this.pidCoefLabel.Size = new System.Drawing.Size(78, 13);
this.storedPosReuseCheckBox.UseVisualStyleBackColor = true; this.pidCoefLabel.TabIndex = 11;
// this.pidCoefLabel.Text = "PID Coefficient";
// stableTimeTextBox //
// // pidCoefTextBox
this.stableTimeTextBox.Enabled = false; //
this.stableTimeTextBox.Location = new System.Drawing.Point(138, 170); this.pidCoefTextBox.Enabled = false;
this.stableTimeTextBox.Name = "stableTimeTextBox"; this.pidCoefTextBox.Location = new System.Drawing.Point(138, 147);
this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20); this.pidCoefTextBox.Name = "pidCoefTextBox";
this.stableTimeTextBox.TabIndex = 15; this.pidCoefTextBox.Size = new System.Drawing.Size(46, 20);
// this.pidCoefTextBox.TabIndex = 12;
// stableTimeLabel //
// // storedPosReuseCheckBox
this.stableTimeLabel.AutoSize = true; //
this.stableTimeLabel.Location = new System.Drawing.Point(28, 173); this.storedPosReuseCheckBox.AutoSize = true;
this.stableTimeLabel.Name = "stableTimeLabel"; this.storedPosReuseCheckBox.Enabled = false;
this.stableTimeLabel.Size = new System.Drawing.Size(81, 13); this.storedPosReuseCheckBox.Location = new System.Drawing.Point(31, 196);
this.stableTimeLabel.TabIndex = 14; this.storedPosReuseCheckBox.Name = "storedPosReuseCheckBox";
this.stableTimeLabel.Text = "Stable time [ms]"; this.storedPosReuseCheckBox.Size = new System.Drawing.Size(162, 17);
// this.storedPosReuseCheckBox.TabIndex = 13;
// flowStableSecTextBox this.storedPosReuseCheckBox.Text = "Enable stored position re-use";
// this.storedPosReuseCheckBox.UseVisualStyleBackColor = true;
this.flowStableSecTextBox.Enabled = false; //
this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 219); // stableTimeTextBox
this.flowStableSecTextBox.Name = "flowStableSecTextBox"; //
this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20); this.stableTimeTextBox.Enabled = false;
this.flowStableSecTextBox.TabIndex = 17; this.stableTimeTextBox.Location = new System.Drawing.Point(138, 170);
// this.stableTimeTextBox.Name = "stableTimeTextBox";
// flowStableSecLabel this.stableTimeTextBox.Size = new System.Drawing.Size(46, 20);
// this.stableTimeTextBox.TabIndex = 15;
this.flowStableSecLabel.AutoSize = true; //
this.flowStableSecLabel.Location = new System.Drawing.Point(28, 222); // stableTimeLabel
this.flowStableSecLabel.Name = "flowStableSecLabel"; //
this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13); this.stableTimeLabel.AutoSize = true;
this.flowStableSecLabel.TabIndex = 16; this.stableTimeLabel.Location = new System.Drawing.Point(28, 173);
this.flowStableSecLabel.Text = "Flow stable [s]"; this.stableTimeLabel.Name = "stableTimeLabel";
// this.stableTimeLabel.Size = new System.Drawing.Size(81, 13);
// RegulValveCfgCtrl this.stableTimeLabel.TabIndex = 14;
// this.stableTimeLabel.Text = "Stable time [ms]";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; // flowStableSecTextBox
this.Controls.Add(this.flowStableSecTextBox); //
this.Controls.Add(this.flowStableSecLabel); this.flowStableSecTextBox.Enabled = false;
this.Controls.Add(this.stableTimeTextBox); this.flowStableSecTextBox.Location = new System.Drawing.Point(138, 219);
this.Controls.Add(this.stableTimeLabel); this.flowStableSecTextBox.Name = "flowStableSecTextBox";
this.Controls.Add(this.storedPosReuseCheckBox); this.flowStableSecTextBox.Size = new System.Drawing.Size(46, 20);
this.Controls.Add(this.pidCoefTextBox); this.flowStableSecTextBox.TabIndex = 17;
this.Controls.Add(this.pidCoefLabel); //
this.Controls.Add(this.parentNameComboBox); // flowStableSecLabel
this.Controls.Add(this.dacOpenTextBox); //
this.Controls.Add(this.dacOpenLabel); this.flowStableSecLabel.AutoSize = true;
this.Controls.Add(this.dacClosedTextBox); this.flowStableSecLabel.Location = new System.Drawing.Point(28, 222);
this.Controls.Add(this.dacClosedLabel); this.flowStableSecLabel.Name = "flowStableSecLabel";
this.Controls.Add(this.positionTextBox); this.flowStableSecLabel.Size = new System.Drawing.Size(74, 13);
this.Controls.Add(this.positionLabel); this.flowStableSecLabel.TabIndex = 16;
this.Controls.Add(this.parentNameLabel); this.flowStableSecLabel.Text = "Flow stable [s]";
this.Controls.Add(this.nameTextBox); //
this.Controls.Add(this.nameLabel); // groupBox1
this.Controls.Add(this.classNameLabel); //
this.Name = "RegulValveCfgCtrl"; this.groupBox1.Controls.Add(this.setButton1);
this.Size = new System.Drawing.Size(300, 250); this.groupBox1.Controls.Add(this.label1);
this.Load += new System.EventHandler(this.RegulationValveCfgCtrl_Load); this.groupBox1.Controls.Add(this.ADC);
this.ResumeLayout(false); this.groupBox1.Controls.Add(this.getButton1);
this.PerformLayout(); this.groupBox1.Controls.Add(this.pctTextBox1);
this.groupBox1.Controls.Add(this.adcTextBox1);
this.groupBox1.Location = new System.Drawing.Point(17, 273);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(280, 68);
this.groupBox1.TabIndex = 18;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Measured value 1";
//
// setButton1
//
this.setButton1.Location = new System.Drawing.Point(229, 21);
this.setButton1.Name = "setButton1";
this.setButton1.Size = new System.Drawing.Size(38, 33);
this.setButton1.TabIndex = 5;
this.setButton1.Text = "Set";
this.setButton1.UseVisualStyleBackColor = true;
this.setButton1.Click += new System.EventHandler(this.setButton1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(209, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(15, 13);
this.label1.TabIndex = 4;
this.label1.Text = "%";
//
// ADC
//
this.ADC.AutoSize = true;
this.ADC.Location = new System.Drawing.Point(11, 32);
this.ADC.Name = "ADC";
this.ADC.Size = new System.Drawing.Size(32, 13);
this.ADC.TabIndex = 3;
this.ADC.Text = "ADC:";
//
// getButton1
//
this.getButton1.Location = new System.Drawing.Point(101, 22);
this.getButton1.Name = "getButton1";
this.getButton1.Size = new System.Drawing.Size(38, 33);
this.getButton1.TabIndex = 2;
this.getButton1.Text = "Get";
this.getButton1.UseVisualStyleBackColor = true;
this.getButton1.Click += new System.EventHandler(this.getButton1_Click);
//
// pctTextBox1
//
this.pctTextBox1.Location = new System.Drawing.Point(160, 28);
this.pctTextBox1.Name = "pctTextBox1";
this.pctTextBox1.Size = new System.Drawing.Size(46, 20);
this.pctTextBox1.TabIndex = 1;
//
// adcTextBox1
//
this.adcTextBox1.Location = new System.Drawing.Point(47, 28);
this.adcTextBox1.Name = "adcTextBox1";
this.adcTextBox1.Size = new System.Drawing.Size(44, 20);
this.adcTextBox1.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.setButton2);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.getButton2);
this.groupBox2.Controls.Add(this.pctTextBox2);
this.groupBox2.Controls.Add(this.adcTextBox2);
this.groupBox2.Location = new System.Drawing.Point(17, 350);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(280, 68);
this.groupBox2.TabIndex = 19;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Measured value 2";
//
// setButton2
//
this.setButton2.Location = new System.Drawing.Point(229, 21);
this.setButton2.Name = "setButton2";
this.setButton2.Size = new System.Drawing.Size(38, 33);
this.setButton2.TabIndex = 5;
this.setButton2.Text = "Set";
this.setButton2.UseVisualStyleBackColor = true;
this.setButton2.Click += new System.EventHandler(this.setButton2_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(209, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(15, 13);
this.label2.TabIndex = 4;
this.label2.Text = "%";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(11, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(32, 13);
this.label3.TabIndex = 3;
this.label3.Text = "ADC:";
//
// getButton2
//
this.getButton2.Location = new System.Drawing.Point(101, 22);
this.getButton2.Name = "getButton2";
this.getButton2.Size = new System.Drawing.Size(38, 33);
this.getButton2.TabIndex = 2;
this.getButton2.Text = "Get";
this.getButton2.UseVisualStyleBackColor = true;
this.getButton2.Click += new System.EventHandler(this.getButton2_Click);
//
// pctTextBox2
//
this.pctTextBox2.Location = new System.Drawing.Point(160, 28);
this.pctTextBox2.Name = "pctTextBox2";
this.pctTextBox2.Size = new System.Drawing.Size(46, 20);
this.pctTextBox2.TabIndex = 1;
//
// adcTextBox2
//
this.adcTextBox2.Location = new System.Drawing.Point(47, 28);
this.adcTextBox2.Name = "adcTextBox2";
this.adcTextBox2.Size = new System.Drawing.Size(44, 20);
this.adcTextBox2.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.closeButton);
this.groupBox3.Controls.Add(this.openButton);
this.groupBox3.Location = new System.Drawing.Point(17, 427);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(280, 60);
this.groupBox3.TabIndex = 20;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Regulation valve";
//
// closeButton
//
this.closeButton.Location = new System.Drawing.Point(14, 19);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(107, 28);
this.closeButton.TabIndex = 1;
this.closeButton.Text = "Close";
this.closeButton.UseVisualStyleBackColor = true;
this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
//
// openButton
//
this.openButton.Location = new System.Drawing.Point(160, 19);
this.openButton.Name = "openButton";
this.openButton.Size = new System.Drawing.Size(107, 28);
this.openButton.TabIndex = 0;
this.openButton.Text = "Open";
this.openButton.UseVisualStyleBackColor = true;
this.openButton.Click += new System.EventHandler(this.openButton_Click);
//
// RegulValveCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.flowStableSecTextBox);
this.Controls.Add(this.flowStableSecLabel);
this.Controls.Add(this.stableTimeTextBox);
this.Controls.Add(this.stableTimeLabel);
this.Controls.Add(this.storedPosReuseCheckBox);
this.Controls.Add(this.pidCoefTextBox);
this.Controls.Add(this.pidCoefLabel);
this.Controls.Add(this.parentNameComboBox);
this.Controls.Add(this.dacOpenTextBox);
this.Controls.Add(this.dacOpenLabel);
this.Controls.Add(this.dacClosedTextBox);
this.Controls.Add(this.dacClosedLabel);
this.Controls.Add(this.positionTextBox);
this.Controls.Add(this.positionLabel);
this.Controls.Add(this.parentNameLabel);
this.Controls.Add(this.nameTextBox);
this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel);
this.Name = "RegulValveCfgCtrl";
this.Size = new System.Drawing.Size(300, 500);
this.Load += new System.EventHandler(this.RegulationValveCfgCtrl_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
} }
@@ -255,5 +448,22 @@
private System.Windows.Forms.Label stableTimeLabel; private System.Windows.Forms.Label stableTimeLabel;
private System.Windows.Forms.TextBox flowStableSecTextBox; private System.Windows.Forms.TextBox flowStableSecTextBox;
private System.Windows.Forms.Label flowStableSecLabel; private System.Windows.Forms.Label flowStableSecLabel;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button setButton1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label ADC;
private System.Windows.Forms.Button getButton1;
private System.Windows.Forms.TextBox pctTextBox1;
private System.Windows.Forms.TextBox adcTextBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button setButton2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button getButton2;
private System.Windows.Forms.TextBox pctTextBox2;
private System.Windows.Forms.TextBox adcTextBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.Button openButton;
} }
} }
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.RegulValve
static readonly ILog log = LogManager.GetLogger(typeof(RegulValveCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(RegulValveCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return true; } }
RegulValveCfg config; RegulValveCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -42,7 +45,21 @@ namespace TBF.BenchControl.Elde.RegulValve
} }
} }
if (config != null)
{
adc1 = config.DacValueClosed;
pct1 = 0;
adc2 = config.DacValueOpen;
pct2 = 100;
}
Redraw(); Redraw();
StartResponseHandler();
}
public void Closing()
{
StopResponseHandler();
} }
void Redraw() void Redraw()
@@ -59,7 +76,12 @@ namespace TBF.BenchControl.Elde.RegulValve
stableTimeTextBox.Text = config.StableTimeMs.ToString(); stableTimeTextBox.Text = config.StableTimeMs.ToString();
storedPosReuseCheckBox.Checked = config.StoredPositionReuse; storedPosReuseCheckBox.Checked = config.StoredPositionReuse;
flowStableSecTextBox.Text = config.FlowStableSec.ToString(); flowStableSecTextBox.Text = config.FlowStableSec.ToString();
}
adcTextBox1.Text = adc1.ToString();
adcTextBox2.Text = adc2.ToString();
pctTextBox1.Text = pct1.ToString();
pctTextBox2.Text = pct2.ToString();
}
public void Unlock() public void Unlock()
{ {
@@ -74,63 +96,219 @@ namespace TBF.BenchControl.Elde.RegulValve
flowStableSecTextBox.Enabled = true; flowStableSecTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 5) if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 1 || dummy > 5)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be between 1 and 5"; message += Environment.NewLine + "'Position' should be between 1 and 5";
} }
if (!int.TryParse(dacClosedTextBox.Text, out dummy) || dummy < 0 || dummy > 1023) if (!int.TryParse(dacClosedTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'DAC when Closed' should be between 0 and 1023"; message += Environment.NewLine + "'DAC when Closed' should be between 0 and 1023";
} }
if (!int.TryParse(dacOpenTextBox.Text, out dummy) || dummy < 0 || dummy > 1023) if (!int.TryParse(dacOpenTextBox.Text, out dummy) || dummy < 0 || dummy > 1023)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'DAC when Open' should be between 0 and 1023"; message += Environment.NewLine + "'DAC when Open' should be between 0 and 1023";
} }
if (!int.TryParse(pidCoefTextBox.Text, out dummy) || dummy < 0 || dummy > 100) if (!int.TryParse(pidCoefTextBox.Text, out dummy) || dummy < 0 || dummy > 100)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'PID Coefficient' should be between 0 and 100"; message += Environment.NewLine + "'PID Coefficient' should be between 0 and 100";
} }
if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0) if (!int.TryParse(stableTimeTextBox.Text, out dummy) || dummy < 200 || dummy > 1500 || (dummy % 50) != 0)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Stable time' should be between 200 and 1500 ms in 50 ms steps"; message += Environment.NewLine + "'Stable time' should be between 200 and 1500 ms in 50 ms steps";
} }
if (!int.TryParse(flowStableSecTextBox.Text, out dummy) || dummy < 0 || dummy > 60) if (!int.TryParse(flowStableSecTextBox.Text, out dummy) || dummy < 0 || dummy > 60)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Flow stable' should be between 0 and 60 sec"; message += Environment.NewLine + "'Flow stable' should be between 0 and 60 sec";
} }
return flags; return flags;
} }
public void UpdateCfg() public CfgUpdateFlags UpdateCfg()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed CfgUpdateFlags flags = CfgUpdateFlags.None;
config.Name = nameTextBox.Text; if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; ///
config.Idx1 = int.Parse(positionTextBox.Text); if (!config.Name.Equals(nameTextBox.Text))
config.DacValueClosed = int.Parse(dacClosedTextBox.Text); {
config.DacValueOpen = int.Parse(dacOpenTextBox.Text); config.Name = nameTextBox.Text;
config.PidCoef = int.Parse(pidCoefTextBox.Text); flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
config.StableTimeMs = int.Parse(stableTimeTextBox.Text); }
config.StoredPositionReuse = storedPosReuseCheckBox.Checked;
config.FlowStableSec = int.Parse(flowStableSecTextBox.Text); string parentname = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
if (!config.ParentName.Equals(parentname))
{
config.ParentName = parentname;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
int tmp = int.Parse(positionTextBox.Text);
if (config.Idx1 != tmp)
{
config.Idx1 = tmp;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
tmp = int.Parse(dacClosedTextBox.Text);
if (config.DacValueClosed != tmp)
{
config.DacValueClosed = tmp;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
tmp = int.Parse(dacOpenTextBox.Text);
if (config.DacValueOpen != tmp)
{
config.DacValueOpen = tmp;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
tmp = int.Parse(pidCoefTextBox.Text);
if (config.PidCoef != tmp)
{
config.PidCoef = tmp;
flags |= CfgUpdateFlags.AnyChange;
}
tmp = int.Parse(stableTimeTextBox.Text);
if (config.StableTimeMs != tmp)
{
config.StableTimeMs = tmp;
flags |= CfgUpdateFlags.AnyChange;
}
bool btmp = storedPosReuseCheckBox.Checked;
if (config.StoredPositionReuse != btmp)
{
config.StoredPositionReuse = btmp;
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
}
tmp = int.Parse(flowStableSecTextBox.Text);
if (config.FlowStableSec != tmp)
{
config.FlowStableSec = tmp;
flags |= CfgUpdateFlags.AnyChange;
}
if ((flags & CfgUpdateFlags.AnyChange) != 0)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
}
return flags;
} }
int adc1;
int pct1;
int adc2;
int pct2;
private void openButton_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.RVOpenStep, config));
}
private void closeButton_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.RVCloseStep, config));
}
//
private void getButton1_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetRVAdc1, config));
}
private void getButton2_Click(object sender, EventArgs e)
{
RegulValve.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.GetRVAdc2, config));
}
private void setButton1_Click(object sender, EventArgs e)
{
setButton2_Click(sender, e); /// Both Save buttons have the same effect
}
private void setButton2_Click(object sender, EventArgs e)
{
int tmpPct1;
int tmpPct2;
if ((int.TryParse(pctTextBox1.Text, out tmpPct1) && (tmpPct1 >= 0) && (tmpPct1 <= 100)) &&
(int.TryParse(pctTextBox2.Text, out tmpPct2) && (tmpPct2 >= 0) && (tmpPct2 <= 100)))
{
pct1 = tmpPct1;
pct2 = tmpPct2;
UpdateValveOpenClose();
}
}
void UpdateValveOpenClose()
{
if ((adc1 == adc2) || (pct1 == pct2)) return;
double factor = (float)(adc2 - adc1) / (float)(pct2 - pct1);
int dacClosed = (int)((float)(0 - pct1) * factor + (float)adc1 + 0.5f);
int dacOpen = (int)((float)(100 - pct1) * factor + (float)adc1 + 0.5f);
if ((dacClosed >= 0) && (dacOpen >= 0))
{
dacClosedTextBox.Text = dacClosed.ToString();
dacOpenTextBox.Text = dacOpen.ToString();
}
}
#region Configuration Change Handling
public static void OnCmdResponse(object sender, CmdResponseArgs args)
{
if (CmdResponseHandler == null) return;
try { CmdResponseHandler(sender, args); }
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
}
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
public void StartResponseHandler()
{
CmdResponseHandler += delegate(object sender, CmdResponseArgs args)
{
if (args.Command == CfgChangeCmd.GetRVAdc1)
{
adc1 = args.Response;
adcTextBox1.Text = adc1.ToString();
}
else if (args.Command == CfgChangeCmd.GetRVAdc2)
{
adc2 = args.Response;
adcTextBox2.Text = adc2.ToString();
}
};
}
public void StopResponseHandler()
{
CmdResponseHandler = null;
}
#endregion Configuration Change Handling
} }
} }
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Elde.TempMeter
static readonly ILog log = LogManager.GetLogger(typeof(TempMeterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TempMeterCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
TempMeterCfg config; TempMeterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -46,6 +49,10 @@ namespace TBF.BenchControl.Elde.TempMeter
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -73,59 +80,61 @@ namespace TBF.BenchControl.Elde.TempMeter
a5TextBox.Enabled = true; a5TextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7) if (!int.TryParse(positionTextBox.Text, out dummy) || dummy < 0 || dummy > 7)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Position' should be between 0 and 7"; message += Environment.NewLine + "'Position' should be between 0 and 7";
} }
float fdummy; float fdummy;
if (!Utils.TryParseEFloat(a1TextBox.Text, out fdummy)) if (!Utils.TryParseEFloat(a1TextBox.Text, out fdummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A1' is not valid"; message += Environment.NewLine + "'A1' is not valid";
} }
if (!Utils.TryParseEFloat(a2TextBox.Text, out fdummy)) if (!Utils.TryParseEFloat(a2TextBox.Text, out fdummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A2' is not valid"; message += Environment.NewLine + "'A2' is not valid";
} }
if (!Utils.TryParseEFloat(a3TextBox.Text, out fdummy)) if (!Utils.TryParseEFloat(a3TextBox.Text, out fdummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A3' is not valid"; message += Environment.NewLine + "'A3' is not valid";
} }
if (!Utils.TryParseEFloat(a4TextBox.Text, out fdummy)) if (!Utils.TryParseEFloat(a4TextBox.Text, out fdummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A4' is not valid"; message += Environment.NewLine + "'A4' is not valid";
} }
if (!Utils.TryParseEFloat(a5TextBox.Text, out fdummy)) if (!Utils.TryParseEFloat(a5TextBox.Text, out fdummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'A5' is not valid"; message += Environment.NewLine + "'A5' is not valid";
} }
return flags; 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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
@@ -135,6 +144,8 @@ namespace TBF.BenchControl.Elde.TempMeter
Utils.TryParseEFloat(a3TextBox.Text, out config.A3) && Utils.TryParseEFloat(a3TextBox.Text, out config.A3) &&
Utils.TryParseEFloat(a4TextBox.Text, out config.A4) && Utils.TryParseEFloat(a4TextBox.Text, out config.A4) &&
Utils.TryParseEFloat(a5TextBox.Text, out config.A5); Utils.TryParseEFloat(a5TextBox.Text, out config.A5);
return flags;
} }
} }
} }
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Elde.Valve
static readonly ILog log = LogManager.GetLogger(typeof(ValveCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(ValveCfgCtrl));
ComponentParametersDlg parent; ComponentParametersDlg parent;
public bool ShowMore { get { return false; } }
ValveCfg config; ValveCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
@@ -57,6 +60,10 @@ namespace TBF.BenchControl.Elde.Valve
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -88,9 +95,11 @@ namespace TBF.BenchControl.Elde.Valve
lagClosingTextBox.Enabled = true; lagClosingTextBox.Enabled = true;
} }
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.Name = nameTextBox.Text;
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text; config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
@@ -108,46 +117,48 @@ namespace TBF.BenchControl.Elde.Valve
config.InvertCouple = invertCoupleCheckBox.Checked; config.InvertCouple = invertCoupleCheckBox.Checked;
config.LagOpening = int.Parse(lagOpeningTextBox.Text); config.LagOpening = int.Parse(lagOpeningTextBox.Text);
config.LagClosing = int.Parse(lagClosingTextBox.Text); config.LagClosing = int.Parse(lagClosingTextBox.Text);
return flags;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text)) if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Parent Name'"; message += Environment.NewLine + "Invalid 'Parent Name'";
} }
if (!categoryComboBox.Items.Contains(categoryComboBox.Text)) if (!categoryComboBox.Items.Contains(categoryComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Category'"; message += Environment.NewLine + "Invalid 'Category'";
} }
if (!coupledToComboBox.Items.Contains(coupledToComboBox.Text)) if (!coupledToComboBox.Items.Contains(coupledToComboBox.Text))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid 'Coupled To'"; message += Environment.NewLine + "Invalid 'Coupled To'";
} }
if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64) if (!int.TryParse(bitPositionTextBox.Text, out dummy) || dummy < 0 || dummy >= 64)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Bit Position' should be between 0 and 63"; message += Environment.NewLine + "'Bit Position' should be between 0 and 63";
} }
if (!int.TryParse(openCloseTimeTextBox.Text, out dummy) || dummy < 0 || dummy > 300) if (!int.TryParse(openCloseTimeTextBox.Text, out dummy) || dummy < 0 || dummy > 300)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Open/close time' should be between 0 and 300 s"; message += Environment.NewLine + "'Open/close time' should be between 0 and 300 s";
} }
if (!int.TryParse(lagOpeningTextBox.Text, out dummy)) if (!int.TryParse(lagOpeningTextBox.Text, out dummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Delay when opening' error"; message += Environment.NewLine + "'Delay when opening' error";
} }
if (!int.TryParse(lagClosingTextBox.Text, out dummy)) if (!int.TryParse(lagClosingTextBox.Text, out dummy))
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Delay when closing' error"; message += Environment.NewLine + "'Delay when closing' error";
} }
return flags; return flags;
+15 -1
View File
@@ -14,11 +14,25 @@
/// <summary> /// <summary>
/// Flags returned by each device configuration control Verify(...) function. /// Flags returned by each device configuration control Verify(...) function.
/// </summary> /// </summary>
public enum CfgVerifyFlags public enum CfgUpdateFlags
{ {
None = 0, None = 0,
Error = 0x1, /// Some settings in the user control are invalid and cannot be set Error = 0x1, /// Some settings in the user control are invalid and cannot be set
Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation Warning = 0x02, /// Some settings in the user control are suspicious, can be set after user confirmation
RestartRqrd = 0x04, /// TBF program restart is required to apply all changed parameters
AnyChange = 0x08, /// At least one parameter have changed
}
public enum CfgChangeCmd
{
None,
CfgChange, /// COnfiguation change
ValveOpen, /// Open a valve
ValveClose, /// Close a valve
RVOpenStep, /// Open a regulation valve
RVCloseStep, /// Close a regulation valve
GetRVAdc1, /// Get regulation valve ADC feedback value #1
GetRVAdc2, /// Get regulation valve ADC feedback value #2
} }
public enum ValveCategory public enum ValveCategory
@@ -14,5 +14,9 @@ namespace TBF.BenchControl.Generic
Entities.LogLevel LogLevel { get; } Entities.LogLevel LogLevel { get; }
IComponentCfg Cfg { get; } IComponentCfg Cfg { get; }
void StartChangeHandler();
void StopChangeHandler();
} }
} }
@@ -9,20 +9,31 @@ namespace TBF.BenchControl.Generic
IComponentCfg Config { get; set; } IComponentCfg Config { get; set; }
/// <summary> /// <summary>
/// Verify current user controls for validity. /// When true, More/Less button will be shown and processed
/// Called when user wants to close/save the configuration.
/// </summary> /// </summary>
/// <returns>See VerifyFlags</returns> bool ShowMore { get; }
CfgVerifyFlags VerifyCfg(ref string message);
/// <summary> /// <summary>
/// Save settings to the configuration class. /// Unlock controls.
/// </summary> /// </summary>
void Unlock(); void Unlock();
/// <summary> /// <summary>
/// Save settings to the configuration class. /// Verify current user controls for validity.
/// Called when user wants to close/save the configuration.
/// </summary> /// </summary>
void UpdateCfg(); /// <returns>See VerifyFlags</returns>
CfgUpdateFlags VerifyCfg(ref string message);
/// <summary>
/// Save form parameters to the configuration class.
/// </summary>
CfgUpdateFlags UpdateCfg();
/// <summary>
/// Called when the dialog with component configuration control is closing.
/// In this function CmdResponse handelrs (if any) should be closed, etc.
/// </summary>
void Closing();
} }
} }
@@ -1,14 +1,18 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO.Ports; using System.IO.Ports;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.Greco namespace TBF.BenchControl.Greco
{ {
public partial class AmbientCfgCtrl : UserControl, IComponentCfgCtrl public partial class AmbientCfgCtrl : UserControl, IComponentCfgCtrl
{ {
AmbientCfg config; static readonly ILog log = LogManager.GetLogger(typeof(AmbientCfgCtrl));
public bool ShowMore { get { return false; } }
AmbientCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -89,6 +93,10 @@ namespace TBF.BenchControl.Greco
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -114,9 +122,11 @@ namespace TBF.BenchControl.Greco
handshakeComboBox.Enabled = true; handshakeComboBox.Enabled = true;
} }
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.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text); config.ComPortNr = int.Parse(comPortNrTextBox.Text);
@@ -125,28 +135,30 @@ namespace TBF.BenchControl.Greco
config.DataBits = int.Parse(dataBitsTextBox.Text); config.DataBits = int.Parse(dataBitsTextBox.Text);
config.StopBits = GetStopBits(stopBitsComboBox.SelectedItem.ToString()); config.StopBits = GetStopBits(stopBitsComboBox.SelectedItem.ToString());
config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString()); config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString());
return flags;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
int dummy; int dummy;
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999) 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"; message += Environment.NewLine + "'Serial Port Number' is not valid";
} }
if (!int.TryParse(baudRateTextBox.Text, out dummy) || dummy < 150 || dummy > 115200) 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"; message += Environment.NewLine + "'Baud Rate' is not valid";
} }
if (!int.TryParse(dataBitsTextBox.Text, out dummy) || dummy < 7 || dummy > 8) 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"; message += Environment.NewLine + "'Data Bits' is not valid";
} }
@@ -2,14 +2,18 @@
using System.Globalization; using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO.Ports; using System.IO.Ports;
using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
namespace TBF.BenchControl.MettlerToledo namespace TBF.BenchControl.MettlerToledo
{ {
public partial class BalanceCfgCtrl : UserControl, IComponentCfgCtrl 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 public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -90,6 +94,10 @@ namespace TBF.BenchControl.MettlerToledo
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -121,49 +129,51 @@ namespace TBF.BenchControl.MettlerToledo
emptyTimeTextBox.Enabled = true; 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; int dummy;
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999) 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"; message += Environment.NewLine + "'Serial Port Number' is not valid";
} }
if (!int.TryParse(baudRateTextBox.Text, out dummy) || dummy < 150 || dummy > 115200) 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"; message += Environment.NewLine + "'Baud Rate' is not valid";
} }
if (!int.TryParse(dataBitsTextBox.Text, out dummy) || dummy < 7 || dummy > 8) 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"; message += Environment.NewLine + "'Data Bits' is not valid";
} }
float mass; float mass;
if (!Utils.TryParseUFloat(capacityTextBox.Text, out mass) || mass <= 0) if (!Utils.TryParseUFloat(capacityTextBox.Text, out mass) || mass <= 0)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Capacity' is not valid"; message += Environment.NewLine + "'Tank Capacity' is not valid";
} }
if (!Utils.TryParseUFloat(emptyTextBox.Text, out mass) || mass <= 0) if (!Utils.TryParseUFloat(emptyTextBox.Text, out mass) || mass <= 0)
{ {
flags |= CfgVerifyFlags.Error; flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "'Tank Empty' is not valid"; message += Environment.NewLine + "'Tank Empty' is not valid";
} }
if (!int.TryParse(emptyTimeTextBox.Text, out dummy) || dummy < 1 || dummy > 999) 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"; message += Environment.NewLine + "'Tank Empty Time' should be between 1 and 999 sec";
} }
return flags; 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.Name = nameTextBox.Text;
config.ComPortNr = int.Parse(comPortNrTextBox.Text); config.ComPortNr = int.Parse(comPortNrTextBox.Text);
@@ -175,6 +185,8 @@ namespace TBF.BenchControl.MettlerToledo
config.Capacity = Utils.ParseUFloat(capacityTextBox.Text); config.Capacity = Utils.ParseUFloat(capacityTextBox.Text);
config.Empty = Utils.ParseUFloat(emptyTextBox.Text); config.Empty = Utils.ParseUFloat(emptyTextBox.Text);
config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text); config.EmptyTimeSec = int.Parse(emptyTimeTextBox.Text);
}
return flags;
}
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
{ {
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
PrinterCfg config; public bool ShowMore { get { return false; } }
PrinterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.ResultsPrinters.Basic
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.ResultsPrinters.Munich
{ {
static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(PrinterCfgCtrl));
PrinterCfg config; public bool ShowMore { get { return false; } }
PrinterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.ResultsPrinters.Munich
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.ResultsPrinters.Munich
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.ResultsWriters.Basic
{ {
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
WriterCfg config; public bool ShowMore { get { return false; } }
WriterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.ResultsWriters.Basic
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.ResultsWriters.Basic
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -226,6 +226,8 @@ namespace TBF.BenchControl
Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve); Elde.Valve.Valve eldeValve = (cmpnt as Elde.Valve.Valve);
if ((eldeValve != null) && eldeValve.Inverted) valvesToInvert |= eldeValve.Mask; if ((eldeValve != null) && eldeValve.Inverted) valvesToInvert |= eldeValve.Mask;
cmpnt.StartChangeHandler(); /// Start handling parameter change events
} }
/// Create an array with tank capacities /// Create an array with tank capacities
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
{ {
static readonly ILog log = LogManager.GetLogger(typeof(RoiDetectionCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(RoiDetectionCfgCtrl));
RoiDetectionCfg config; public bool ShowMore { get { return false; } }
RoiDetectionCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.CameraRoiDetection
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
{ {
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
TestMethodCfg config; public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.CombinedMeters
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
{ {
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
TestMethodCfg config; public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.CombinedWithDetection
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
{ {
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
TestMethodCfg config; public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.FixedStartMassCollection
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
{ {
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
TestMethodCfg config; public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStart
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
{ {
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
TestMethodCfg config; public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.FlyingStartCollectionMethod
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -9,8 +9,9 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
{ {
static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(TestMethodCfgCtrl));
TestMethodCfg config; public bool ShowMore { get { return false; } }
TestMethodCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -31,6 +32,10 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -43,16 +48,21 @@ namespace TBF.BenchControl.TestMethods.ReferenceFlowmeterCalibration
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
@@ -10,8 +10,9 @@ namespace TBF.BenchControl.WaterMeter
{ {
static readonly ILog log = LogManager.GetLogger(typeof(WaterMeterCfgCtrl)); static readonly ILog log = LogManager.GetLogger(typeof(WaterMeterCfgCtrl));
WaterMeterCfg config; public bool ShowMore { get { return false; } }
WaterMeterCfg config;
public IComponentCfg Config public IComponentCfg Config
{ {
get { return config as IComponentCfg; } get { return config as IComponentCfg; }
@@ -33,6 +34,10 @@ namespace TBF.BenchControl.WaterMeter
Redraw(); Redraw();
} }
public void Closing()
{
}
void Redraw() void Redraw()
{ {
if (config == null) return; /// Control was not loaded, settings were not changed if (config == null) return; /// Control was not loaded, settings were not changed
@@ -45,16 +50,21 @@ namespace TBF.BenchControl.WaterMeter
nameTextBox.Enabled = true; nameTextBox.Enabled = true;
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
CfgVerifyFlags flags = CfgVerifyFlags.None; CfgUpdateFlags flags = CfgUpdateFlags.AnyChange;
return flags; 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.Name = nameTextBox.Text;
return flags;
} }
} }
} }
+42 -5
View File
@@ -21,6 +21,8 @@ namespace TBF
} }
} }
public CfgUpdateFlags Flags;
/// <summary> /// <summary>
/// List of components (=component configuration instances) /// List of components (=component configuration instances)
/// </summary> /// </summary>
@@ -30,12 +32,15 @@ namespace TBF
{ {
InitializeComponent(); InitializeComponent();
Flags = CfgUpdateFlags.None;
/// SharedDlgButtons configuration /// SharedDlgButtons configuration
sharedButtons.RequiredGroupMembership = Grp.GID.Metrologists; sharedButtons.RequiredGroupMembership = Grp.GID.Metrologists;
sharedButtons.OptionalButtons = SharedButtons.Buttons.None; sharedButtons.OptionalButtons = SharedButtons.Buttons.None;
sharedButtons.Unlocked += Unlock; sharedButtons.Unlocked += Unlock;
sharedButtons.OKClicked += okButton_Click; sharedButtons.OKClicked += okButton_Click;
sharedButtons.CancelClicked += cancelButton_Click; sharedButtons.CancelClicked += cancelButton_Click;
sharedButtons.MoreClicked += moreButton_Click;
} }
private void ComponentCfgForm_Load(object sender, EventArgs e) private void ComponentCfgForm_Load(object sender, EventArgs e)
@@ -46,6 +51,11 @@ namespace TBF
{ {
splitContainer.Panel1.Controls.Add((UserControl)ComponentCfgCtrl); splitContainer.Panel1.Controls.Add((UserControl)ComponentCfgCtrl);
} }
if ((ComponentCfgCtrl != null) && ComponentCfgCtrl.ShowMore)
{
sharedButtons.OptionalButtons = SharedButtons.Buttons.More;
}
} }
private void Unlock(object sender, EventArgs e) private void Unlock(object sender, EventArgs e)
@@ -53,25 +63,36 @@ namespace TBF
ComponentCfgCtrl.Unlock(); ComponentCfgCtrl.Unlock();
} }
public CfgVerifyFlags VerifyCfg(ref string message) public CfgUpdateFlags VerifyCfg(ref string message)
{ {
if (ComponentCfgCtrl == null) return CfgVerifyFlags.None; /// Nothing to verify -> OK if (ComponentCfgCtrl == null) return CfgUpdateFlags.None; /// Nothing to verify -> OK
return ComponentCfgCtrl.VerifyCfg(ref message); return ComponentCfgCtrl.VerifyCfg(ref message);
} }
private void okButton_Click(object sender, EventArgs e) private void okButton_Click(object sender, EventArgs e)
{ {
string message = string.Empty; string message = string.Empty;
CfgVerifyFlags flags = VerifyCfg(ref message); CfgUpdateFlags flags = VerifyCfg(ref message);
if ((flags & CfgVerifyFlags.Error) == CfgVerifyFlags.Error) if ((flags & CfgUpdateFlags.Error) == CfgUpdateFlags.Error)
{ {
MessageBox.Show(Strings.Please_change_the_following_settings + message, MessageBox.Show(Strings.Please_change_the_following_settings + message,
Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); Strings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (ComponentCfgCtrl != null) ComponentCfgCtrl.UpdateCfg(); if (ComponentCfgCtrl != null)
{
flags = ComponentCfgCtrl.UpdateCfg();
if ((flags & CfgUpdateFlags.RestartRqrd) == CfgUpdateFlags.RestartRqrd)
{
MessageBox.Show(Strings.Program_restart_is_required_to_apply_some_settings,
Strings.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
ComponentCfgCtrl.Closing();
}
Flags = flags;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
return; return;
@@ -79,9 +100,25 @@ namespace TBF
private void cancelButton_Click(object sender, EventArgs e) private void cancelButton_Click(object sender, EventArgs e)
{ {
if (ComponentCfgCtrl != null) ComponentCfgCtrl.Closing();
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
return; return;
} }
private void moreButton_Click(object sender, EventArgs e)
{
ComponentCfgCtrl.Unlock();
if (sharedButtons.MoreActive)
{
Height = Height + 250;
}
else
{
Height = Height - 250;
}
return;
}
} }
} }
+30 -12
View File
@@ -26,6 +26,8 @@ namespace TBF
SelectComponentClassDlg selectComponentTypeDlg; /// Constructed once, the selection is kept between dialog usages SelectComponentClassDlg selectComponentTypeDlg; /// Constructed once, the selection is kept between dialog usages
CfgUpdateFlags flags; /// Or-ed from particular Flags from ComponentParametersDlg
/// <summary> /// <summary>
/// ListViewEx columns /// ListViewEx columns
/// </summary> /// </summary>
@@ -52,6 +54,8 @@ namespace TBF
InitializeComponent(); InitializeComponent();
flags = CfgUpdateFlags.None;
selectComponentTypeDlg = new SelectComponentClassDlg(); selectComponentTypeDlg = new SelectComponentClassDlg();
/// SharedDlgButtons configuration /// SharedDlgButtons configuration
@@ -183,20 +187,23 @@ namespace TBF
/// OK /// OK
private void okButton_Click(object sender, EventArgs e) private void okButton_Click(object sender, EventArgs e)
{ {
foreach (var cmpnt in toBeDeletedEntities) if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
{ {
FluentCommon.DeleteFromDb(session, cmpnt); foreach (var cmpnt in toBeDeletedEntities)
} {
foreach (var cmpnt in cmpntEntities) FluentCommon.DeleteFromDb(session, cmpnt);
{ }
FluentCommon.SaveToDb(session, cmpnt); foreach (var cmpnt in cmpntEntities)
} {
FluentCommon.SaveToDb(session, cmpnt);
}
Program.LocalSettings.ComponentsDlgLeft = Location.X; Program.LocalSettings.ComponentsDlgLeft = Location.X;
Program.LocalSettings.ComponentsDlgTop = Location.Y; Program.LocalSettings.ComponentsDlgTop = Location.Y;
Program.LocalSettings.ComponentsDlgWidth = Size.Width; Program.LocalSettings.ComponentsDlgWidth = Size.Width;
Program.LocalSettings.ComponentsDlgHeight = Size.Height; Program.LocalSettings.ComponentsDlgHeight = Size.Height;
Program.LocalSettings.Save(); Program.LocalSettings.Save();
}
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
@@ -212,6 +219,15 @@ namespace TBF
Program.LocalSettings.ComponentsDlgHeight = Size.Height; Program.LocalSettings.ComponentsDlgHeight = Size.Height;
Program.LocalSettings.Save(); Program.LocalSettings.Save();
if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
{
DialogResult dr = MessageBox.Show(Strings.Changes_will_be_lost_Do_you_want_to_proceed,
Strings.Warning,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (dr != DialogResult.Yes) return;
}
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
return; return;
@@ -277,6 +293,8 @@ namespace TBF
DialogResult dr = cfgForm.ShowDialog(); DialogResult dr = cfgForm.ShowDialog();
if (dr != DialogResult.OK) return; if (dr != DialogResult.OK) return;
flags |= cfgForm.Flags;
sharedButtons.UnlockButtons(); /// Unlock this dialog buttons as changes were enabled sharedButtons.UnlockButtons(); /// Unlock this dialog buttons as changes were enabled
unlocked = true; /// in the ComponentParametersDlg. unlocked = true; /// in the ComponentParametersDlg.
+36
View File
@@ -231,6 +231,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Changes will be lost. Do you want to proceed?.
/// </summary>
internal static string Changes_will_be_lost_Do_you_want_to_proceed {
get {
return ResourceManager.GetString("Changes_will_be_lost_Do_you_want_to_proceed", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Clear results. /// Looks up a localized string similar to Clear results.
/// </summary> /// </summary>
@@ -780,6 +789,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Less.
/// </summary>
internal static string LessBtnText {
get {
return ResourceManager.GetString("LessBtnText", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Loading the procedure. /// Looks up a localized string similar to Loading the procedure.
/// </summary> /// </summary>
@@ -933,6 +951,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to More.
/// </summary>
internal static string MoreBtnText {
get {
return ResourceManager.GetString("MoreBtnText", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Name. /// Looks up a localized string similar to Name.
/// </summary> /// </summary>
@@ -1284,6 +1311,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Program restart is required to apply some settings.
/// </summary>
internal static string Program_restart_is_required_to_apply_some_settings {
get {
return ResourceManager.GetString("Program_restart_is_required_to_apply_some_settings", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Progress. /// Looks up a localized string similar to Progress.
/// </summary> /// </summary>
@@ -774,4 +774,10 @@
<data name="Time2MassMsrmt_chdr" xml:space="preserve"> <data name="Time2MassMsrmt_chdr" xml:space="preserve">
<value>Stab.Zeit [s]</value> <value>Stab.Zeit [s]</value>
</data> </data>
<data name="LessBtnText" xml:space="preserve">
<value>weniger</value>
</data>
<data name="MoreBtnText" xml:space="preserve">
<value>mehr</value>
</data>
</root> </root>
+12
View File
@@ -862,4 +862,16 @@
<data name="Time2MassMsrmt_chdr" xml:space="preserve"> <data name="Time2MassMsrmt_chdr" xml:space="preserve">
<value>Stab.time [s]</value> <value>Stab.time [s]</value>
</data> </data>
<data name="LessBtnText" xml:space="preserve">
<value>Less</value>
</data>
<data name="MoreBtnText" xml:space="preserve">
<value>More</value>
</data>
<data name="Program_restart_is_required_to_apply_some_settings" xml:space="preserve">
<value>Program restart is required to apply some settings</value>
</data>
<data name="Changes_will_be_lost_Do_you_want_to_proceed" xml:space="preserve">
<value>Changes will be lost. Do you want to proceed?</value>
</data>
</root> </root>
+2
View File
@@ -159,6 +159,8 @@
<Compile Include="BenchControl\Cameras\IdcCamera\Command\SetBrightness.cs" /> <Compile Include="BenchControl\Cameras\IdcCamera\Command\SetBrightness.cs" />
<Compile Include="BenchControl\Cameras\IdcCamera\Command\StartNew.cs" /> <Compile Include="BenchControl\Cameras\IdcCamera\Command\StartNew.cs" />
<Compile Include="BenchControl\Cameras\IdcCamera\Command\Stream.cs" /> <Compile Include="BenchControl\Cameras\IdcCamera\Command\Stream.cs" />
<Compile Include="BenchControl\CfgChangeArgs.cs" />
<Compile Include="BenchControl\CmdResponseArgs.cs" />
<Compile Include="BenchControl\ComponentBase.cs" /> <Compile Include="BenchControl\ComponentBase.cs" />
<Compile Include="BenchControl\Constants.cs" /> <Compile Include="BenchControl\Constants.cs" />
<Compile Include="BenchControl\DataEntry\Munich3\CycleBeginningForm.cs"> <Compile Include="BenchControl\DataEntry\Munich3\CycleBeginningForm.cs">
+14
View File
@@ -40,6 +40,7 @@
this.newTabButton = new System.Windows.Forms.Button(); this.newTabButton = new System.Windows.Forms.Button();
this.renameTabButton = new System.Windows.Forms.Button(); this.renameTabButton = new System.Windows.Forms.Button();
this.removeTabButton = new System.Windows.Forms.Button(); this.removeTabButton = new System.Windows.Forms.Button();
this.moreButton = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// removeButton // removeButton
@@ -174,10 +175,22 @@
this.removeTabButton.UseVisualStyleBackColor = true; this.removeTabButton.UseVisualStyleBackColor = true;
this.removeTabButton.Click += new System.EventHandler(this.removeTabButton_Click); this.removeTabButton.Click += new System.EventHandler(this.removeTabButton_Click);
// //
// moreButton
//
this.moreButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.moreButton.Location = new System.Drawing.Point(10, 523);
this.moreButton.Name = "moreButton";
this.moreButton.Size = new System.Drawing.Size(80, 40);
this.moreButton.TabIndex = 12;
this.moreButton.Text = "More";
this.moreButton.UseVisualStyleBackColor = true;
this.moreButton.Click += new System.EventHandler(this.moreButton_Click);
//
// SharedButtons // SharedButtons
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.moreButton);
this.Controls.Add(this.removeTabButton); this.Controls.Add(this.removeTabButton);
this.Controls.Add(this.renameTabButton); this.Controls.Add(this.renameTabButton);
this.Controls.Add(this.newTabButton); this.Controls.Add(this.newTabButton);
@@ -211,5 +224,6 @@
private System.Windows.Forms.Button newTabButton; private System.Windows.Forms.Button newTabButton;
private System.Windows.Forms.Button renameTabButton; private System.Windows.Forms.Button renameTabButton;
private System.Windows.Forms.Button removeTabButton; private System.Windows.Forms.Button removeTabButton;
private System.Windows.Forms.Button moreButton;
} }
} }
+38 -1
View File
@@ -24,7 +24,8 @@ namespace TBF.UiControls
NewTab = 256, /// optional NewTab = 256, /// optional
RenameTab = 512, /// optional RenameTab = 512, /// optional
RemoveTab = 1024, /// optional RemoveTab = 1024, /// optional
} More = 2048, /// optional
}
/// <summary> /// <summary>
/// Optional buttons are Add, Remove, Up, Down, Edit and Copy. /// Optional buttons are Add, Remove, Up, Down, Edit and Copy.
@@ -39,6 +40,8 @@ namespace TBF.UiControls
} }
LockState lockState; LockState lockState;
public bool MoreActive;
/// <summary> /// <summary>
/// Used by controls to indicate which item is selected /// Used by controls to indicate which item is selected
/// and to appropriately update Remove, Up and Down Buttons. /// and to appropriately update Remove, Up and Down Buttons.
@@ -63,6 +66,7 @@ namespace TBF.UiControls
{ {
originalUser = Entities.User.CurrentUser; originalUser = Entities.User.CurrentUser;
lockState = LockState.Locked; lockState = LockState.Locked;
MoreActive = false;
OptionalButtons = Buttons.None; OptionalButtons = Buttons.None;
RequiredGroupMembership = Grp.GID.None; RequiredGroupMembership = Grp.GID.None;
InitializeComponent(); InitializeComponent();
@@ -87,6 +91,7 @@ namespace TBF.UiControls
newTabButton.Text = Strings.NewTabBtnText; newTabButton.Text = Strings.NewTabBtnText;
renameTabButton.Text = Strings.RenameTabBtnText; renameTabButton.Text = Strings.RenameTabBtnText;
removeTabButton.Text = Strings.RemoveTabBtnText; removeTabButton.Text = Strings.RemoveTabBtnText;
moreButton.Text = Strings.MoreBtnText;
cancelButton.Hide(); cancelButton.Hide();
addButton.Hide(); addButton.Hide();
@@ -98,6 +103,7 @@ namespace TBF.UiControls
newTabButton.Hide(); newTabButton.Hide();
renameTabButton.Hide(); renameTabButton.Hide();
removeTabButton.Hide(); removeTabButton.Hide();
moreButton.Hide();
/// Reposition 'Edit' and 'Copy" buttons in case both 'Up' and 'Down' are hidden /// Reposition 'Edit' and 'Copy" buttons in case both 'Up' and 'Down' are hidden
if (((OptionalButtons & Buttons.Up) == 0) && if (((OptionalButtons & Buttons.Up) == 0) &&
@@ -116,6 +122,18 @@ namespace TBF.UiControls
renameTabButton.Top = copyButton.Top + 15; renameTabButton.Top = copyButton.Top + 15;
} }
if ((OptionalButtons & Buttons.Add) == 0 &&
(OptionalButtons & Buttons.Remove) == 0 &&
(OptionalButtons & Buttons.Up) == 0 &&
(OptionalButtons & Buttons.Down) == 0 &&
(OptionalButtons & Buttons.Edit) == 0 &&
(OptionalButtons & Buttons.Copy) == 0 &&
(OptionalButtons & Buttons.NewTab) == 0 &&
(OptionalButtons & Buttons.RenameTab) == 0 &&
(OptionalButtons & Buttons.RemoveTab) == 0)
{
moreButton.Top = addButton.Top + 70;
}
#if DEBUG #if DEBUG
//unlockBtn_Click(sender, e); //unlockBtn_Click(sender, e);
#endif #endif
@@ -138,6 +156,7 @@ namespace TBF.UiControls
if ((OptionalButtons & Buttons.NewTab) != 0) newTabButton.Show(); if ((OptionalButtons & Buttons.NewTab) != 0) newTabButton.Show();
if ((OptionalButtons & Buttons.RenameTab) != 0) renameTabButton.Show(); if ((OptionalButtons & Buttons.RenameTab) != 0) renameTabButton.Show();
if ((OptionalButtons & Buttons.RemoveTab) != 0) removeTabButton.Show(); if ((OptionalButtons & Buttons.RemoveTab) != 0) removeTabButton.Show();
if ((OptionalButtons & Buttons.More) != 0) moreButton.Show();
lockState = LockState.Unlocked; lockState = LockState.Unlocked;
} }
@@ -171,6 +190,7 @@ namespace TBF.UiControls
if ((buttons & Buttons.NewTab) != 0) newTabButton.Enabled = value; if ((buttons & Buttons.NewTab) != 0) newTabButton.Enabled = value;
if ((buttons & Buttons.RenameTab) != 0) renameTabButton.Enabled = value; if ((buttons & Buttons.RenameTab) != 0) renameTabButton.Enabled = value;
if ((buttons & Buttons.RemoveTab) != 0) removeTabButton.Enabled = value; if ((buttons & Buttons.RemoveTab) != 0) removeTabButton.Enabled = value;
if ((buttons & Buttons.More) != 0) moreButton.Enabled = value;
} }
void RestoreUser() void RestoreUser()
@@ -194,6 +214,7 @@ namespace TBF.UiControls
public event EventHandler NewTabClicked; public event EventHandler NewTabClicked;
public event EventHandler RenameTabClicked; public event EventHandler RenameTabClicked;
public event EventHandler RemoveTabClicked; public event EventHandler RemoveTabClicked;
public event EventHandler MoreClicked;
/// <summary> /// <summary>
/// 'Unlock' button handler /// 'Unlock' button handler
@@ -234,6 +255,22 @@ namespace TBF.UiControls
} }
} }
private void moreButton_Click(object sender, EventArgs e)
{
if (MoreActive)
{
MoreActive = false;
moreButton.Text = Strings.MoreBtnText;
}
else
{
MoreActive = true;
moreButton.Text = Strings.LessBtnText;
}
if (MoreClicked != null) MoreClicked(sender, e);
}
/// ///
/// All remaining handlers: /// All remaining handlers:
/// ///