2014-07-28 07:54:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Elde
|
|
|
|
|
|
{
|
|
|
|
|
|
public class StartMeasurementOp : IOperation
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(StartMeasurementOp));
|
|
|
|
|
|
public override string ToString() { return string.Format("StartMeasurementOp(ref={0},pulses={1})", flowMeter.Position, refPulses); }
|
|
|
|
|
|
|
|
|
|
|
|
/// Set by the constructor
|
|
|
|
|
|
readonly ControlBoardDev controlBoard;
|
|
|
|
|
|
readonly Elde.FlowMeter.FlowMeter flowMeter;
|
|
|
|
|
|
readonly int refPulses; /// Number of reference pulses for a complete test
|
|
|
|
|
|
readonly TestMethods testMethod;
|
2014-07-30 22:50:42 +00:00
|
|
|
|
readonly float filterConstant;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
bool started = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Starts the measurement.
|
|
|
|
|
|
/// Events: MeasurementStarted
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="controlBoardDev">Control board component reference</param>
|
|
|
|
|
|
/// <param name="flowMeter">Flow meter component reference</param>
|
|
|
|
|
|
/// <param name="readers">Register readers references</param>
|
|
|
|
|
|
/// <param name="volume">Water volume for the test in liters</param>
|
2014-07-30 22:50:42 +00:00
|
|
|
|
public StartMeasurementOp(ControlBoardDev controlBoardDev, GenericDevices.IFlowMeter flowMeter,
|
|
|
|
|
|
int refPulses, TestMethods method, float filterConstant)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (controlBoardDev == null) throw new ArgumentNullException("controlBoardDev");
|
|
|
|
|
|
this.controlBoard = controlBoardDev;
|
|
|
|
|
|
|
|
|
|
|
|
this.flowMeter = flowMeter as Elde.FlowMeter.FlowMeter;
|
|
|
|
|
|
if (this.flowMeter == null) throw new ArgumentException("flowMeter is null or is not Elde");
|
|
|
|
|
|
|
|
|
|
|
|
this.refPulses = refPulses;
|
|
|
|
|
|
this.testMethod = method;
|
2014-07-30 22:50:42 +00:00
|
|
|
|
this.filterConstant = filterConstant;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
log.Debug(this.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Start this operation</summary>
|
|
|
|
|
|
public void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
controlBoard.SendCommand(Command.Start, flowMeter.Position, controlBoard.RRoute, refPulses, testMethod,
|
2014-07-30 22:50:42 +00:00
|
|
|
|
filterConstant, 20, 0, StopDevs.None);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Run this operation</summary>
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
/// Event.FlowInDone or Event.FlowOutDone
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
public Event Run()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (started) return Event.MeasurementStarted;
|
|
|
|
|
|
if (0 != (controlBoard.StatusP & StatusP.TestInProgress))
|
|
|
|
|
|
{
|
|
|
|
|
|
started = true;
|
|
|
|
|
|
return Event.MeasurementStarted;
|
|
|
|
|
|
}
|
|
|
|
|
|
return Event.None;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|