BuiltIn components clean-up.
This commit is contained in:
@@ -19,8 +19,8 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
||||
readonly GenericDevices.IPump pump1;
|
||||
readonly GenericDevices.IPump pump2;
|
||||
|
||||
readonly GenericDevices.IPumpFM pumpFm1;
|
||||
readonly GenericDevices.IPumpFM pumpFm2;
|
||||
GenericDevices.IPumpFM pumpFm1;
|
||||
GenericDevices.IPumpFM pumpFm2;
|
||||
|
||||
public bool State { get { return pump1.State || pump2.State; } }
|
||||
|
||||
@@ -38,8 +38,8 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
||||
public int LagClosing { get { return 0; } }
|
||||
|
||||
|
||||
readonly UInt128 mask1;
|
||||
readonly UInt128 mask2;
|
||||
UInt128 mask1;
|
||||
UInt128 mask2;
|
||||
public UInt128 Mask { get { return mask1 | mask2; } } /// derived from masks of two pumps
|
||||
|
||||
|
||||
@@ -56,11 +56,16 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
||||
pump2 = TbfComponents.FindComponent(pumpCfg.Pump2, components) as GenericDevices.IPump;
|
||||
if (pump2 == null) throw new Exception("Cannot find component Pump 2");
|
||||
|
||||
pumpFm1 = pump1 as GenericDevices.IPumpFM;
|
||||
pumpFm2 = pump2 as GenericDevices.IPumpFM;
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
pumpFm1 = pump1 as GenericDevices.IPumpFM;
|
||||
pumpFm2 = pump2 as GenericDevices.IPumpFM;
|
||||
|
||||
if (pump1 is BuiltIn.Pump.Pump) { mask1 = (pump1 as BuiltIn.Pump.Pump).Mask; }
|
||||
else if (pump1 is Danfoss.VLT2800.Pump) { mask1 = (pump1 as Danfoss.VLT2800.Pump).Mask; }
|
||||
else if (pump1 is Danfoss.VLT2800.Pump) { mask1 = (pump1 as Danfoss.VLT2800.Pump).Mask; }
|
||||
else if (pump1 is Modbus.PumpFM.DanfossVLT.Pump) { mask1 = (pump1 as Modbus.PumpFM.DanfossVLT.Pump).Mask; }
|
||||
else { mask1 = 0; }
|
||||
|
||||
@@ -68,9 +73,7 @@ namespace TBF.Rig.BuiltIn.PumpTandem
|
||||
else if (pump2 is Danfoss.VLT2800.Pump) { mask2 = (pump2 as Danfoss.VLT2800.Pump).Mask; }
|
||||
else if (pump2 is Modbus.PumpFM.DanfossVLT.Pump) { mask2 = (pump2 as Modbus.PumpFM.DanfossVLT.Pump).Mask; }
|
||||
else { mask2 = 0; }
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void TurnOn(double powerArg)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -15,10 +15,8 @@ namespace TBF.Rig.BuiltIn.ValveEx
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
readonly ValveCfg valveCfg;
|
||||
|
||||
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
|
||||
///
|
||||
public readonly IValve[] InputValves;
|
||||
public readonly IValve[] InputValves;
|
||||
public readonly UInt128 Mask; /// derived from bitPosition in the constructor
|
||||
|
||||
|
||||
public Valve() { }
|
||||
@@ -27,15 +25,6 @@ namespace TBF.Rig.BuiltIn.ValveEx
|
||||
: base(cfg)
|
||||
{
|
||||
valveCfg = cfg as ValveCfg;
|
||||
|
||||
//controlBoard = (ControlBoardDev)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
//if (controlBoard == null) throw new Exception("Cannot find " + Name + " parent");
|
||||
|
||||
if (valveCfg.BitPosition < 0 || valveCfg.BitPosition >= 128)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("position");
|
||||
}
|
||||
this.Mask = (((UInt128)1) << valveCfg.BitPosition);
|
||||
|
||||
InputValves = new IValve[valveCfg.InputValvesCount];
|
||||
InputValves[0] = TbfComponents.FindComponent(valveCfg.Input1, components) as IValve;
|
||||
@@ -53,9 +42,12 @@ namespace TBF.Rig.BuiltIn.ValveEx
|
||||
InputValves[4] = TbfComponents.FindComponent(valveCfg.Input5, components) as IValve;
|
||||
}
|
||||
|
||||
Mask = (((UInt128)1) << valveCfg.BitPosition);
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
|
||||
public void UpdateRoute(ref UInt128 route)
|
||||
{
|
||||
bool output;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace TBF.Rig.BuiltIn.ValveEx
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int BitPosition; /// Bit-position
|
||||
public int BitPosition; /// Bit-position 0 .. 127
|
||||
///
|
||||
public ValveExOperation LogicalOp; /// Logical operation between input valves
|
||||
public bool InvertOutput; /// Invert the output of logical operation
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// <summary>
|
||||
/// Initialize control board device hardware
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
public override void Initialize()
|
||||
{
|
||||
devices = new OutputPath(string.Empty, 0);
|
||||
actionQueue = new Queue<Action>();
|
||||
|
||||
Reference in New Issue
Block a user