75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
///
|
|
/// Copyright (c) 2021 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.RegValveAnalog
|
|
{
|
|
public class ChangeRegValvePositionOp : IOperation
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(ChangeRegValvePositionOp));
|
|
public override string ToString()
|
|
{
|
|
return string.Format("ChangeRegValvePositionOp({0},{1}s)", regValve.Name, timePulseSec.ToString("F2"));
|
|
}
|
|
|
|
/// Set by the constructor
|
|
readonly UniCB uniCB;
|
|
readonly RegValve regValve;
|
|
readonly double timePulseSec;
|
|
|
|
/// <summary>
|
|
/// Set required water flow.
|
|
/// Events: FlowSet, FlowTimeOut
|
|
/// </summary>
|
|
/// <param name="uniCB">Control board device</param>
|
|
/// <param name="regValve">Regulation valve component</param>
|
|
/// <param name="posLoPct">Lower limit of the position to be achieved</param>
|
|
/// <param name="posHiPct">Upper limit of the position to be achieved</param>
|
|
/// <param name="timeout">Timeout in sec. for setting the flow</param>
|
|
/// <remarks>Only Elde.Valve flow are used, other flow on the lists are ignored</remarks>
|
|
public ChangeRegValvePositionOp(UniCB uniCB, RegValve regValve, double timePulseSec)
|
|
{
|
|
if (uniCB == null) throw new ArgumentNullException("ctrlBoard");
|
|
this.uniCB = uniCB;
|
|
|
|
this.regValve = regValve as RegValve;
|
|
if (this.regValve == null) throw new ArgumentNullException("regValve is null or not Elde");
|
|
|
|
this.timePulseSec = timePulseSec;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
|
|
/// <summary>Start this operation</summary>
|
|
public void Start()
|
|
{
|
|
double positionPct = regValve.Position;
|
|
log.WarnFormat("RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
|
|
|
|
uniCB.RegVlvIncrMove(false, regValve.Idx1, timePulseSec);
|
|
}
|
|
|
|
/// <summary>Run this operation</summary>
|
|
/// <returns>
|
|
/// Event.SetFlowDone
|
|
/// </returns>
|
|
public Event Run()
|
|
{
|
|
double positionPct = regValve.Position;
|
|
log.WarnFormat("RV#={0}, actPos={1}%", regValve.Idx1, positionPct.ToString("F1"));
|
|
|
|
return Event.PositionReached;
|
|
}
|
|
|
|
/// <summary>Stop this operation</summary>
|
|
public void Stop()
|
|
{
|
|
}
|
|
}
|
|
}
|