UniCB : (1) Supports output bits 0..7 (2) Uses QuidoRS outputs for route bits 64..79
This commit is contained in:
@@ -84,6 +84,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
public UInt64 State { get { return Data.State; } } /// Control board state
|
||||
|
||||
/// Quido RS
|
||||
TBF.Rig.Modbus.QuidoRS.QuidoRS quidoRS;
|
||||
|
||||
/// Current flow meter ID
|
||||
public int FlowmeterId { get { return Convert.ToInt32(Data.State & (ulong)StatusP.FlowmtrNrMask); } }
|
||||
|
||||
@@ -105,7 +108,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// Regulation valve control outputs and diverters cannot be controlled by Action.ChangeRoute
|
||||
/// Depends on the control board configuration
|
||||
UInt128 invInputsMask; /// Typically 0xff000000 0000ffff ffffffff ffffffff, inputs are mapped to route bits 80..119
|
||||
ulong valvesToInvert; /// From configurations of valve and pump components. Inversion is applied when creating
|
||||
UInt128 valvesToInvert; /// From configurations of valve and pump components. Inversion is applied when creating
|
||||
/// a message to be sent by serial port
|
||||
UInt128 displayedRoutePlusUI; /// A route displayed on the screen plus the modifications from UI (inversions are not applied)
|
||||
UInt128 bitsChangedByUI; /// Ones in this word indicate which valves/pumpes were changed in UI by mouse clicks
|
||||
@@ -183,7 +186,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// <param name="valvesToInvert"></param>
|
||||
public void SpecifyInvertedValves(UInt128 valvesToInvert)
|
||||
{
|
||||
this.valvesToInvert = (ulong)valvesToInvert;
|
||||
this.valvesToInvert = valvesToInvert;
|
||||
}
|
||||
|
||||
#region IDevice interface
|
||||
@@ -193,6 +196,8 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
quidoRS = TbfComponents.FindComponent(cbCfg.QuidoRS) as TBF.Rig.Modbus.QuidoRS.QuidoRS;
|
||||
|
||||
devices = new OutputPath(string.Empty, 0);
|
||||
actionQueue = new Queue<Action>();
|
||||
actionQueue.Enqueue(Action.Stop(false)); /// Stop all
|
||||
@@ -202,12 +207,14 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
scopeAnalyzerData = null;
|
||||
switchCounterData = null;
|
||||
|
||||
routeMask = 0x0FF1EFFFF00;
|
||||
routeMask = 0x000000ff1effff00;
|
||||
if (cbCfg.RelaysFInstalled) routeMask |= 0x0000ff0000000000;
|
||||
if (cbCfg.RelaysGInstalled) routeMask |= 0x00ff000000000000;
|
||||
if (cbCfg.RelaysHInstalled) routeMask |= 0xff00000000000000;
|
||||
if (cbCfg.RelaysIInstalled) routeMask |= 0x00000000000000ff;
|
||||
for (int i = 4; i < cbCfg.RegValvesCount; i++) routeMask &= ~(((UInt128)3) << (2 * i));
|
||||
for (int i = 1; i < cbCfg.DivertersCount; i++) routeMask &= ~(((UInt128)1) << (24 + i));
|
||||
if (cbCfg.RelaysFInstalled) routeMask |= 0xFF0000000000;
|
||||
if (cbCfg.RelaysGInstalled) routeMask |= 0xFF000000000000;
|
||||
if (cbCfg.RelaysHInstalled) routeMask |= 0xFF00000000000000;
|
||||
if (quidoRS != null) routeMask |= (((UInt128)0xffff) << 64);
|
||||
|
||||
invInputsMask = (UInt128)0xffffffffffffffffL;
|
||||
invInputsMask |= (((UInt128)0xffff) << 64);
|
||||
@@ -242,6 +249,12 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
serialPort.WriteTimeout = 4000;
|
||||
serialPort.ParityReplace = 0xFF;
|
||||
serialPort.Open();
|
||||
|
||||
if (!string.IsNullOrEmpty(cbCfg.QuidoRS) && quidoRS == null)
|
||||
{
|
||||
throw new Exception(string.Format("Cannot find Quido RS component named {0}", cbCfg.QuidoRS));
|
||||
}
|
||||
|
||||
log.FatalFormat("{0} initialized, routeMask = {1}", Name, Utils.ToBin88(routeMask));
|
||||
}
|
||||
else if (cbCfg.DebugLevel == DebugMode.Replay)
|
||||
@@ -427,7 +440,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
///
|
||||
lock (this)
|
||||
{
|
||||
if (generalDataReceived) route = (UInt128)(Data.Vystupy ^ valvesToInvert);
|
||||
if (generalDataReceived) route = ((route & (((UInt128)0xffffffffffffffff) << 64)) | Data.Vystupy) ^ valvesToInvert;
|
||||
///
|
||||
if (!IsUIBlocked && bitsChangedByUI != 0)
|
||||
{
|
||||
@@ -509,6 +522,8 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
}
|
||||
}
|
||||
|
||||
if (quidoRS != null) quidoRS.SetOutputs((route >> 64) & 0xFFFF);
|
||||
|
||||
if (!outputsInitialized || (outputLatch & routeMask) != (route & routeMask)) /// || (StateMachine.Time - lastStateMachineTime) >= 15)
|
||||
{
|
||||
var actionsToModify = actionQueue.Where(x => (x.ActionId == ActionID.ChangeRoute));
|
||||
@@ -522,7 +537,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
}
|
||||
|
||||
oneModified = true;
|
||||
a.Route = (ulong)route;
|
||||
a.Route = route;
|
||||
log.InfoFormat("ChangeRoute(route={0:X}) ... an action in the queue modified", route);
|
||||
}
|
||||
|
||||
@@ -537,7 +552,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
|
||||
var combinedAction = Action.FetchNonConflictingActions(actionQueue); /// Default action is RequestDataOnly
|
||||
byte[] outData = OutputMessage.GetMessage(combinedAction, config, valvesToInvert);
|
||||
byte[] outData = OutputMessage.GetMessage(combinedAction, config, (ulong)valvesToInvert);
|
||||
if (outData != null && outData.Length > 0)
|
||||
{
|
||||
if ((combinedAction.ActionId & ActionID.ChangeRoute) != 0)
|
||||
@@ -546,7 +561,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
outputLatch = combinedAction.Route;
|
||||
if (cbCfg.DebugLevel != DebugMode.Normal)
|
||||
{
|
||||
Data.Vystupy = combinedAction.Route ^ valvesToInvert;
|
||||
Data.Vystupy = (ulong)(combinedAction.Route ^ valvesToInvert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user