BuiltIn.Valve initialization changed.

This commit is contained in:
Milan Hanajik
2021-04-08 10:05:02 +02:00
parent 56294bbffc
commit 988bcd6387
+4 -6
View File
@@ -47,17 +47,15 @@ namespace TBF.Rig.BuiltIn.Valve
valveCfg = cfg as ValveCfg;
controlBoard = TbfComponents.FindComponent(cfg.ParentName, components) as TBF.Rig.ControlBoard.IControlBoard;
if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
if (controlBoard == null) throw new Exception(string.Format("Cannot find the parent of {0}", Name));
if (valveCfg.CoupledToName != null)
if (!string.IsNullOrEmpty(valveCfg.CoupledToName))
{
coupledTo = (IValve)TbfComponents.FindComponent(valveCfg.CoupledToName, components);
if (coupledTo == null) throw new Exception(string.Format("Cannot find the coupled valve {0}", valveCfg.CoupledToName));
}
if (valveCfg.BitNr < 0 || valveCfg.BitNr >= 128)
{
throw new ArgumentOutOfRangeException("position");
}
if (valveCfg.BitNr < 0 || valveCfg.BitNr > 127) throw new ArgumentOutOfRangeException("Invalid bit number");
Mask = (((UInt128)1) << valveCfg.BitNr);
log.Warn(this.ToString());