/// /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using TBF.BenchControl.GenericDevices; namespace TBF.BenchControl.Elde.RegulValve { public class ChangeRegulValvePositionOp : IOperation { private static readonly ILog log = LogManager.GetLogger(typeof(ChangeRegulValvePositionOp)); public override string ToString() { return string.Format("ChangeRegulValvePositionOp({0},{1}s)", regulValve.Name, timePulseSec.ToString("F2")); } /// Set by the constructor readonly ControlBoardDev controlBoard; readonly RegulValve regulValve; readonly int regulValveNr; readonly float 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 ChangeRegulValvePositionOp(ControlBoardDev controlBoard, RegulValve _regulValve, float timePulseSec) { if (controlBoard == null) throw new ArgumentNullException("ctrlBoard"); this.controlBoard = controlBoard; regulValve = _regulValve as RegulValve; if (regulValve == null) throw new ArgumentNullException("regValve is null or not Elde"); regulValveNr = this.regulValve.Idx1; this.timePulseSec = timePulseSec; log.Debug(this.ToString()); } /// Start this operation public void Start() { float positionPct = controlBoard.RValvePosition(regulValveNr); log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1")); controlBoard.ValveMove(regulValveNr, RegulValveMode.PulseWidth, new float[2] { timePulseSec, timePulseSec }, regulValve.StableTime); } /// Run this operation /// /// Event.SetFlowDone /// public Event Run() { float positionPct = controlBoard.RValvePosition(regulValveNr); log.WarnFormat("RV#={0}, actPos={1}%", regulValveNr, positionPct.ToString("F1")); return Event.PositionReached; } /// Stop this operation public void Stop() { } } }