/// /// Copyright (c) 2017 Sensus Metering Systems /// using System; using System.Collections.Generic; using log4net; using TBF.Boxes; namespace TBF.BenchControl.Dummy.FlowMeter { public class FlowMeter : ComponentBase, GenericDevices.IFlowMeter { private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter)); public override string ToString() { return string.Format("FlowMeter({0})", Cfg.ToString(1)); } readonly FlowMeterCfg flowMeterCfg; public double NominalFlow { get { return flowMeterCfg.NominalFlow; } } public double LtrPerPulse { get { return flowMeterCfg.NominalFlow / 7200.0f; } } public double LtrPerPulseCorrected(double flow, int rangeIx) { return flow; } public int Idx1 { get { return 1; } } public FlowMeter() { } public FlowMeter(Generic.IComponentCfg cfg, IList components) : base(cfg) { flowMeterCfg = cfg as FlowMeterCfg; log.Debug(this.ToString()); } public double ReadFlow() { return 1.23; } public double ReadFrequency() { return 1.23 * 2000.0 / (double)NominalFlow; } /// /// Events: FlowDone, Error /// /// Reference to a variable for the flow in Bar /// ReadFlowOp instance reference casted to IOperaton public IOperation ReadFlowOp(ref DoubleBox flow) { return new ReadFlowOp(this, ref flow); } /// /// Events: flowDone, Error /// /// Reference to a variable for the flow in Bar /// Event returned when measurement done /// ReadFlowOp instance reference casted to IOperaton public IOperation ReadFlowOp(ref DoubleBox flow, Event flowDone) { return new ReadFlowOp(this, ref flow, flowDone); } } }