70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde.FlowMeter
|
|
{
|
|
public class ReadFlowOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ReadFlowOp));
|
|
public override string ToString() { return string.Format("ReadFlowOp(.,{0},{1},.)", eventDone, flowMeterNr); }
|
|
|
|
/// Set by the constructor
|
|
readonly ControlBoardDev controlBoard;
|
|
readonly int flowMeterNr;
|
|
readonly Event eventDone;
|
|
DoubleBox flow;
|
|
|
|
/// <summary>
|
|
/// Events: FlowInDone, FlowOutDone or Error
|
|
/// </summary>
|
|
/// <param name="flowMeter">Flow meter reference</param>
|
|
/// <param name="flow">Reference to the measured flow variable, value is in bar</param>
|
|
/// <param name="eventDone">Event to be returned by Run() when completed OK</param>
|
|
public ReadFlowOp(FlowMeter flowMeter, ref DoubleBox flow, Event eventDone)
|
|
{
|
|
if (flowMeter == null) throw new ArgumentNullException("flowMeter");
|
|
this.controlBoard = flowMeter.ControlBoard;
|
|
this.flowMeterNr = flowMeter.Idx1;
|
|
this.eventDone = eventDone;
|
|
this.flow = flow;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
public ReadFlowOp(FlowMeter flowMeter, ref DoubleBox flow)
|
|
: this(flowMeter, ref flow, Event.FlowMeasurementDone)
|
|
{
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.FlowInDone or Event.FlowOutDone
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
if (flowMeterNr == (int)(controlBoard.StatusP & StatusP.RefFlowMeterMask))
|
|
{
|
|
flow.Val = controlBoard.ReferenceFlow;
|
|
return eventDone;
|
|
}
|
|
else
|
|
{
|
|
return Event.Error;
|
|
}
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|