using System; using System.Collections.Generic; using log4net; namespace TBF.BenchControl.Elde.Diverter { public class Diverter : ComponentBase, GenericDevices.IDiverter { private static readonly ILog log = LogManager.GetLogger(typeof(Diverter)); public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); } readonly DiverterCfg diverterCfg; readonly ControlBoardDev controlBoard; readonly ulong mask; /// derived from bitPosition in the constructor public bool State { get { return (controlBoard.Route & mask) != 0; } } public Diverter(DiverterCfg cfg, IList components) : base(cfg) { 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()); } } }