using System; using System.Collections.Generic; using log4net; namespace TBF.BenchControl.Elde.Diverter { public class Diverter : Generic.IComponent, GenericDevices.IDiverter { /// /// Info: StartMassMeasurement() and "Balance response = .., Mass = ..." /// Warn: Start measurement when busy is true /// private static readonly ILog log = LogManager.GetLogger(typeof(Diverter)); public override string ToString() { return string.Format("Diverter({0},{1})", Name, diverterCfg.BitPosition); } public static void ResetStaticProperties() { } private readonly DiverterCfg diverterCfg; public Generic.IComponentCfg Cfg { get { return diverterCfg; } } public string Name { get { return diverterCfg.Name; } } readonly ControlBoardDev controlBoard; public readonly ulong Mask; /// derived from bitPosition in the constructor public Diverter(DiverterCfg cfg, IList components) { if (cfg == null) throw new ArgumentNullException("cfg"); this.diverterCfg = cfg; controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components); if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent"); if (cfg.BitPosition < 0 || cfg.BitPosition >= 64) throw new ArgumentOutOfRangeException("position"); this.Mask = (((ulong)1) << cfg.BitPosition); log.Debug(this.ToString()); } public bool State { get { return (controlBoard.Route & Mask) != 0; } } } }