using System; using System.Collections.Generic; using log4net; namespace TBF.BenchControl.Elde.FlowMeter { public class FlowMeter : Generic.IComponent, GenericDevices.IFlowMeter { /// /// Info: StartMassMeasurement() and "Balance response = .., Mass = ..." /// Warn: Start measurement when busy is true /// private static readonly ILog log = LogManager.GetLogger(typeof(FlowMeter)); public override string ToString() { return string.Format("FlowMeter({0},{1})", Name, Position); } public static void ResetStaticProperties() { } FlowMeterCfg flowMeterCfg; public Generic.IComponentCfg Cfg { get { return flowMeterCfg; } } public string Name { get { return flowMeterCfg.Name; } } public IList Corrections { get { return flowMeterCfg.Corrections; } } public readonly ControlBoardDev ControlBoard; public readonly int Position; /// 1..4 readonly float nominalFlow; public float NominalFlow { get { return nominalFlow; } } public FlowMeter(FlowMeterCfg cfg, IList components) { if (cfg == null) throw new ArgumentNullException("cfg"); this.flowMeterCfg = cfg; ControlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); if (ControlBoard == null) throw new Exception("Cannot find " + Name + " parent"); Position = cfg.Position; nominalFlow = cfg.NominalFlow; ControlBoard.EtCalib[Position] = NominalFlow; /// Prepare data for SendCalibData() control board component method log.Debug(this.ToString()); } /// /// Events: FlowDone, Error /// /// Reference to a variable for the flow in Bar /// ReadFlowOp instance reference casted to IOperaton public IOperation ReadFlowOp(ref FloatBox 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 FloatBox flow, Event flowDone) { return new ReadFlowOp(this, ref flow, flowDone); } } }