///
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using log4net;
using TBF.Rig.ControlBoard.Uni;
using TBF.Rig.GenericDevices;
namespace TBF.Rig.Uni.RegValveLowRegulTimeSaturation
{
public class ChangeRegValvePositionOp : IOperation
{
private static readonly ILog log = LogManager.GetLogger(typeof(ChangeRegValvePositionOp));
public override string ToString()
{
return string.Format("ChangeRegValvePositionOp({0},{1}s)", regV.Name, timePulseSec.ToString("F2"));
}
/// Set by the constructor
readonly UniCB uniCB;
readonly RegValve regV;
readonly int regulValveNr;
readonly double timePulseSec;
///
/// Set required water flow.
/// Events: FlowSet, FlowTimeOut
///
/// Control board device
/// Regulation valve component
/// Lower limit of the position to be achieved
/// Upper limit of the position to be achieved
/// Timeout in sec. for setting the flow
/// Only Elde.Valve flow are used, other flow on the lists are ignored
public ChangeRegValvePositionOp(UniCB uniCB, RegValve regV, double timePulseSec)
{
this.uniCB = uniCB;
if (this.uniCB == null) throw new ArgumentNullException("ctrlBoard");
this.regV = regV as RegValve;
if (this.regV == null) throw new ArgumentNullException("regValve is null or not Uni");
regulValveNr = this.regV.Idx1;
this.timePulseSec = timePulseSec;
log.Debug(this.ToString());
}
/// Start this operation
public void Start()
{
uniCB.RegVlvIncrMove(false, regulValveNr, timePulseSec, this.regV.RegulationMinStep);
}
/// Run this operation
///
/// Event.SetFlowDone
///
public Event Run()
{
return Event.PositionReached;
}
/// Stop this operation
public void Stop()
{
}
}
}