BuiltIn components clean-up.

This commit is contained in:
Milan Hanajik
2021-04-02 20:27:02 +02:00
parent ce0b8af4a0
commit bb3a6ff4f3
5 changed files with 32 additions and 42 deletions
+12 -17
View File
@@ -33,10 +33,11 @@ namespace TBF.Rig.BuiltIn.Valve
public int LagOpening { get { return valveCfg.LagOpening; } }
public int LagClosing { get { return valveCfg.LagClosing; } }
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
public int BitPosition { get { return valveCfg.BitNr; } }
public bool State { get { return (controlBoard.Route & Mask) != 0; } }
public Valve() { }
@@ -48,26 +49,20 @@ namespace TBF.Rig.BuiltIn.Valve
controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.Rig.ControlBoard.IControlBoard;
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (valveCfg.BitNr < 0 || valveCfg.BitNr >= 128)
{
throw new ArgumentOutOfRangeException("position");
}
this.Mask = (((UInt128)1) << valveCfg.BitNr);
if (valveCfg.CoupledToName != null)
{
coupledTo = (IValve)TbfComponents.FindComponent(valveCfg.CoupledToName, components);
}
if (valveCfg.CoupledToName != null)
{
coupledTo = (IValve)TbfComponents.FindComponent(valveCfg.CoupledToName, components);
}
if (valveCfg.BitNr < 0 || valveCfg.BitNr >= 128)
{
throw new ArgumentOutOfRangeException("position");
}
Mask = (((UInt128)1) << valveCfg.BitNr);
log.Warn(this.ToString());
}
public bool State
{
get { return (controlBoard.Route & Mask) != 0; }
}
#region Configuration Change Handling
public static void OnCfgChange(object sender, CfgChangeArgs args)