tbf/TestBenchFramework/BenchControl/Elde/StartMeasurementOp.cs
Milan Hanajik 74a6800f9e Changes done on Fuzhou300 system:
- ControlComDev.SetFMFreq() modifications (array size)
- StatusP and Route logging
- StatusP bit assignments: bit3 -> bit5
- MettlerToledo logging
2014-09-05 22:14:12 +02:00

79 lines
2.9 KiB
C#

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;
readonly float filterConstant;
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>
public StartMeasurementOp(ControlBoardDev controlBoardDev, GenericDevices.IFlowMeter flowMeter,
int refPulses, TestMethods method, float filterConstant)
{
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;
this.filterConstant = filterConstant;
log.Debug(this.ToString());
}
/// <summary>Start this operation</summary>
public void Start()
{
controlBoard.SendCommand(Command.Start, flowMeter.Position, controlBoard.RRoute, refPulses, testMethod,
filterConstant, 20, 0, StopDevs.None);
}
/// <summary>Run this operation</summary>
/// <returns>
/// Event.FlowInDone or Event.FlowOutDone
/// </returns>
public Event Run()
{
if (started) return Event.MeasurementStarted;
StatusP statusP = controlBoard.StatusP;
log.DebugFormat("statusP = {0} {1} {2} {3}",
(((ulong)statusP >> 48) & 0xFFFF).ToString("X4"),
(((ulong)statusP >> 32) & 0xFFFF).ToString("X4"),
(((ulong)statusP >> 16) & 0xFFFF).ToString("X4"),
((ulong)statusP & 0xFFFF).ToString("X4"));
if (0 != (statusP & StatusP.TestInProgress))
{
log.Info("Test started");
started = true;
return Event.MeasurementStarted;
}
return Event.None;
}
/// <summary>Stop this operation</summary>
public void Stop()
{
}
}
}