64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
///
|
|
/// Copyright (c) 2020 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using log4net;
|
|
using TBF.Boxes;
|
|
|
|
namespace TBF.BenchControl.Elde
|
|
{
|
|
public class ReadDiverterStateOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ReadFlowOp));
|
|
public override string ToString() { return string.Format("ReadDiverterStateOp(div={0}, delay={1})", div.Name, delay); }
|
|
|
|
/// Set by the constructor
|
|
readonly GenericDevices.IDiverter div;
|
|
readonly ControlBoardDev ctrlBrd;
|
|
readonly int delay;
|
|
|
|
int startTime;
|
|
|
|
/// <summary>
|
|
/// Events: FlowInDone, FlowOutDone or Error
|
|
/// </summary>
|
|
/// <param name="flowMeter">Flow meter reference</param>
|
|
/// <param name="flowBox">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 ReadDiverterStateOp(ControlBoardDev ctrlBrd, GenericDevices.IDiverter div, int delay)
|
|
{
|
|
if (ctrlBrd == null || div == null) throw new ArgumentNullException();
|
|
|
|
this.ctrlBrd = ctrlBrd;
|
|
this.div = div;
|
|
this.delay = delay;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
public ReadDiverterStateOp(ControlBoardDev ctrlBrd, GenericDevices.IDiverter div)
|
|
: this(ctrlBrd, div, 0)
|
|
{
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
startTime = StateMachine.Time;
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns> Event.ToTank or Event.ToSink </returns>
|
|
public Event Run()
|
|
{
|
|
if (StateMachine.Time - startTime <= delay)
|
|
{
|
|
return Event.None;
|
|
}
|
|
return div.State ? Event.ToTank : Event.ToSink;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop() { }
|
|
}
|
|
}
|