(1) Tank & ManualLevelMsrmnt components added, (2) Sequences cope with IScaleOrTank, (3) FixedStartTankCollection & FlyingStartTankCollection added, etc., ver. 2.18.1040
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
using TBF.BenchControl.Configs.NameOnly;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Various.ManualLevelMsrmnt
|
||||
{
|
||||
public class ManualLevelMsrmnt : ComponentBase, ILevelMeter, IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ManualLevelMsrmnt));
|
||||
public override string ToString() { return string.Format("ManualLevelMsrmnt({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly TestMethodCfg myCfg;
|
||||
|
||||
DoubleBox levelBox;
|
||||
|
||||
public double WaterLevelMm;
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
|
||||
bool resultSaved; /// Set in Run() when results are saved
|
||||
|
||||
public enum CurrentOp
|
||||
{
|
||||
None,
|
||||
EnterLevel,
|
||||
}
|
||||
CurrentOp currentOp;
|
||||
|
||||
|
||||
public ManualLevelMsrmnt()
|
||||
{
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
|
||||
public ManualLevelMsrmnt(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
myCfg = cfg as TestMethodCfg;
|
||||
|
||||
currentOp = CurrentOp.None;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ReadLevelOp(ref DoubleBox levelBox)
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
this.levelBox = levelBox;
|
||||
currentOp = CurrentOp.EnterLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
delegate void EntryFormDlgt(ManualLevelMsrmnt myRef);
|
||||
///
|
||||
void OpenWaterLevelForm(ManualLevelMsrmnt myRef)
|
||||
{
|
||||
myRef.modelessDlg = new WaterLevelForm();
|
||||
modelessDlg.Show();
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
resultSaved = false;
|
||||
if (currentOp == CurrentOp.EnterLevel)
|
||||
{
|
||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenWaterLevelForm), this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
if ((modelessDlg is IHasCompleted) && !(modelessDlg as IHasCompleted).Completed)
|
||||
{
|
||||
return Event.Busy; /// = Form open
|
||||
}
|
||||
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
{
|
||||
if ((modelessDlg is WaterLevelForm) && (currentOp == CurrentOp.EnterLevel))
|
||||
{
|
||||
WaterLevelMm = (modelessDlg as WaterLevelForm).WaterLevelMm;
|
||||
if (levelBox != null) levelBox.Val = WaterLevelMm;
|
||||
resultSaved = true;
|
||||
modelessDlg = null;
|
||||
}
|
||||
}
|
||||
|
||||
return Event.LevelDone; /// = Form closed
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (modelessDlg is IHasCompleted)
|
||||
{
|
||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
||||
modelessDlg = null;
|
||||
}
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user