2014-07-28 07:54:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.Elde.Diverter
|
|
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public class Diverter : ComponentBase, GenericDevices.IDiverter
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public override string ToString() { return string.Format("Diverter({0})", Cfg.ToString(1)); }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
readonly DiverterCfg diverterCfg;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
readonly ControlBoardDev controlBoard;
|
2014-12-29 23:17:45 +00:00
|
|
|
|
readonly ulong mask; /// derived from bitPosition in the constructor
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2014-12-31 12:46:33 +00:00
|
|
|
|
public bool State
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (controlBoard.Route & mask) != 0; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
public Diverter(DiverterCfg cfg, IList<Generic.IComponent> components)
|
2014-12-31 12:46:33 +00:00
|
|
|
|
: base(cfg)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2014-12-31 12:46:33 +00:00
|
|
|
|
diverterCfg = cfg;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
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");
|
2014-12-29 23:17:45 +00:00
|
|
|
|
this.mask = (((ulong)1) << cfg.BitPosition);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
log.Debug(this.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|