Components initialization clean-up.
This commit is contained in:
@@ -20,7 +20,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public class UniCB : ComponentBase, IAdvancedControlBoard, SchematicDrawing.IDrawingItCmpntWithMeasuredVal
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(UniCB));
|
||||
public override string ToString() { return string.Format("CBoard({0})", cbCfg != null ? cbCfg.ToString(-1) : string.Empty); }
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
/// TBF component configuration and useful wrappers
|
||||
readonly UniCBCfg cbCfg;
|
||||
@@ -95,7 +95,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
///
|
||||
/// Digital outputs / Route / States of electromagnetic valves
|
||||
///
|
||||
readonly UInt128 routeMask; /// Set in the constructor, bits of outputs that can be controlled by Action.ChangeRoute are set.
|
||||
UInt128 routeMask; /// Set in the constructor, bits of outputs that can be controlled by Action.ChangeRoute are set.
|
||||
/// Regulation valve control outputs and diverters cannot be controlled by Action.ChangeRoute
|
||||
/// Depends on the control board configuration
|
||||
ulong valvesToInvert; /// From configurations of valve and pump components. Inversion is applied when creating
|
||||
@@ -157,10 +157,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// Constructor for user interfaces (change settings only).
|
||||
/// Initialize(), RunDeviceXY() and StopDevice() methods of the created object will not be called.
|
||||
/// </summary>
|
||||
public UniCB()
|
||||
{
|
||||
devices = new OutputPath(string.Empty, 0);
|
||||
}
|
||||
public UniCB() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor invoked when starting the test bench and creating components.
|
||||
@@ -169,23 +166,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
: base(cfg)
|
||||
{
|
||||
cbCfg = cfg as UniCBCfg;
|
||||
|
||||
devices = new OutputPath(string.Empty, 0);
|
||||
actionQueue = new Queue<Action>();
|
||||
actionQueue.Enqueue(Action.Stop(false)); /// Stop all
|
||||
outputsInitialized = false;
|
||||
|
||||
Data = new GeneralData();
|
||||
divTransitionData = null;
|
||||
scopeAnalyzerData = null;
|
||||
switchCounterData = null;
|
||||
|
||||
routeMask = 0xFF00FFFFFF;
|
||||
for (int i = 0; i < cbCfg.RegValvesCount; i++) routeMask &= ~((UInt128)3 << 2*i);
|
||||
if (cbCfg.RelaysFInstalled) routeMask |= 0xFF0000000000;
|
||||
if (cbCfg.RelaysGInstalled) routeMask |= 0xFF000000000000;
|
||||
if (cbCfg.RelaysHInstalled) routeMask |= 0xFF00000000000000;
|
||||
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
@@ -205,10 +186,36 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
devices = new OutputPath(string.Empty, 0);
|
||||
actionQueue = new Queue<Action>();
|
||||
actionQueue.Enqueue(Action.Stop(false)); /// Stop all
|
||||
outputsInitialized = false;
|
||||
|
||||
divTransitionData = null;
|
||||
scopeAnalyzerData = null;
|
||||
switchCounterData = null;
|
||||
|
||||
routeMask = 0xFF00FFFFFF;
|
||||
for (int i = 0; i < cbCfg.RegValvesCount; i++) routeMask &= ~((UInt128)3 << 2 * i);
|
||||
if (cbCfg.RelaysFInstalled) routeMask |= 0xFF0000000000;
|
||||
if (cbCfg.RelaysGInstalled) routeMask |= 0xFF000000000000;
|
||||
if (cbCfg.RelaysHInstalled) routeMask |= 0xFF00000000000000;
|
||||
|
||||
lastRcvdStMTime = StateMachine.Time; /// To indicate the serial connection state
|
||||
lastSentTime = DateTime.Now;
|
||||
lastReceivedTime = DateTime.Now;
|
||||
|
||||
/// Handler handling mouse clicks on the schematc drawinng - valve or pump state changes
|
||||
TBF.UiBridge.Bridge.RouteChangeHandler += delegate(object sndr, TBF.UiBridge.RouteChangeArgs args)
|
||||
{
|
||||
UInt128 oneBitMask = ((UInt128)1) << args.BitNr;
|
||||
lock (this)
|
||||
{
|
||||
bitsChangedByUI |= oneBitMask;
|
||||
displayedRoutePlusUI = displayedRoutePlusUI ^ oneBitMask;
|
||||
}
|
||||
};
|
||||
|
||||
if (cbCfg.DebugLevel == DebugMode.Normal)
|
||||
{
|
||||
buffer = new byte[BUFFER_SIZE];
|
||||
@@ -221,20 +228,13 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
serialPort.WriteTimeout = 4000;
|
||||
serialPort.ParityReplace = 0xFF;
|
||||
serialPort.Open();
|
||||
log.FatalFormat("{0} - Device successfully initialized", Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
serialPort = null;
|
||||
log.FatalFormat("{0} - Device simulated", Name);
|
||||
}
|
||||
|
||||
/// Handler handling mouse clicks on the schematc drawinng - valve or pump state changes
|
||||
TBF.UiBridge.Bridge.RouteChangeHandler += delegate(object sndr, TBF.UiBridge.RouteChangeArgs args)
|
||||
{
|
||||
UInt128 oneBitMask = ((UInt128)1) << args.BitNr;
|
||||
lock (this)
|
||||
{
|
||||
bitsChangedByUI |= oneBitMask;
|
||||
displayedRoutePlusUI = displayedRoutePlusUI ^ oneBitMask;
|
||||
}
|
||||
};
|
||||
|
||||
log.FatalFormat("{0} - Device successfully initialized", Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user