UniCB : (1) Supports output bits 0..7 (2) Uses QuidoRS outputs for route bits 64..79
This commit is contained in:
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.1.1874.0")]
|
||||
[assembly: AssemblyFileVersion("3.1.1874.0")]
|
||||
[assembly: AssemblyVersion("3.1.1876.0")]
|
||||
[assembly: AssemblyFileVersion("3.1.1876.0")]
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
public ActionID ActionId { get; set; }
|
||||
public bool IsFromUI { get; set; } /// false = action is comming from the state machine, true = action is comming from the UI
|
||||
public ulong Route { get; set; } /// ChangeRoute argument
|
||||
public UInt128 Route { get; set; } /// ChangeRoute argument
|
||||
public int FlowMId { get; set; } /// MeasureFlow, SetFlow and StartTest argument
|
||||
public int RegVId { get; set; } /// SetFlow and StartTest argument
|
||||
public int DivId { get; set; } /// StartTest and SwitchDiverter argument
|
||||
@@ -98,7 +98,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
}
|
||||
|
||||
///----------------------------------------------------------------------------------------------
|
||||
public static Action ChangeRoute(bool isFromUI, ulong route)
|
||||
public static Action ChangeRoute(bool isFromUI, UInt128 route)
|
||||
{
|
||||
return new Action
|
||||
{
|
||||
@@ -572,7 +572,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
log.InfoFormat("Combined action: {0} Rt={1} Et={2} RV={3} Div#={4} Cmd={5} Sync={6} wDiv={7} S/S={8} Prolng={9} ToTank={10} Puls={11} MPls={12} RVMode={13} P1={14} P2={15} pid={16}",
|
||||
((int)combinedAction.ActionId).ToString("X3"),
|
||||
combinedAction.Route.ToString("X12"),
|
||||
combinedAction.Route.ToString("X32"),
|
||||
combinedAction.FlowMId,
|
||||
combinedAction.RegVId,
|
||||
combinedAction.DivId,
|
||||
@@ -601,7 +601,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
switch (ActionId)
|
||||
{
|
||||
case ActionID.ChangeRoute:
|
||||
args = string.Format("Rt={0}", Route.ToString("X12"));
|
||||
args = string.Format("Rt={0}", Route.ToString("X32"));
|
||||
break;
|
||||
case ActionID.MeasureFlow:
|
||||
args = string.Format("Et={0}", FlowMId);
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
return " [. .. .. ..Cmd P1 P2 (pulses) (mass.p) xx (cfg) Xg (------- route -------) (DA2) RV Rpar1 Rpar2 St (DA1) PID x ST Div Sum ]";
|
||||
}
|
||||
|
||||
public static byte[] GetMessage(Action action, short config, ulong bitsToInvert)
|
||||
public static byte[] GetMessage(Action action, short config, UInt128 bitsToInvert)
|
||||
{
|
||||
FetchArguments(action);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
message[15] = (byte)((config >> 8) & 0xff);
|
||||
|
||||
/// Route
|
||||
ulong routeOut = arguments.Route ^ bitsToInvert;
|
||||
UInt128 routeOut = arguments.Route ^ bitsToInvert;
|
||||
message[16] = ((action.ActionId & ActionID.ChangeRoute) != 0) ? (byte)1 : (byte)0; /// Route change flag
|
||||
message[17] = (byte)(routeOut & 0xFF); /// RV0 .. RV3
|
||||
message[18] = (byte)((routeOut >> 8) & 0xFF); /// RV4 .. RV7
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2021-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -20,7 +20,10 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(UniCBCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); }
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
|
||||
{
|
||||
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
|
||||
}
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
@@ -32,6 +35,8 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public bool RelaysFInstalled;
|
||||
public bool RelaysGInstalled;
|
||||
public bool RelaysHInstalled;
|
||||
public bool RelaysIInstalled;
|
||||
public string QuidoRS;
|
||||
public bool ShowState;
|
||||
|
||||
/// Schematic drawing info
|
||||
@@ -91,6 +96,8 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
RelaysFInstalled = true;
|
||||
RelaysGInstalled = true;
|
||||
RelaysHInstalled = true;
|
||||
RelaysIInstalled = true;
|
||||
QuidoRS = string.Empty;
|
||||
ShowState = false;
|
||||
}
|
||||
|
||||
@@ -100,9 +107,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
"Diverters count (1..5)",
|
||||
"Drain valves count (0..8)",
|
||||
"Regulation valves count (4..8)",
|
||||
"Relays F are installed",
|
||||
"Relays G are installed",
|
||||
"Relays H are installed",
|
||||
"Relays F are installed (bits 40..47)",
|
||||
"Relays G are installed (bits 48..55)",
|
||||
"Relays H are installed (bits 56..63)",
|
||||
"Relays I are installed (bits 0..7)",
|
||||
"Quido RS component (bits 64..79)",
|
||||
"Show state",
|
||||
};
|
||||
public string ParamName(int i) { return paramNames[i]; }
|
||||
@@ -122,7 +131,10 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 9:
|
||||
return new string[] { Strings.yes, Strings.no };
|
||||
case 8:
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -139,7 +151,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 4: return RelaysFInstalled ? Strings.yes : Strings.no;
|
||||
case 5: return RelaysGInstalled ? Strings.yes : Strings.no;
|
||||
case 6: return RelaysHInstalled ? Strings.yes : Strings.no;
|
||||
case 7: return ShowState ? Strings.yes : Strings.no;
|
||||
case 7: return RelaysIInstalled ? Strings.yes : Strings.no;
|
||||
case 8: return QuidoRS != null ? QuidoRS : string.Empty;
|
||||
case 9: return ShowState ? Strings.yes : Strings.no;
|
||||
default:
|
||||
return string.Format("{0}: COM{1} DIVs={2} VBs={3} RVs={4} RelaysF={5} RelaysG={6} RelaysH={7}",
|
||||
Name, ComPortNr, DivertersCount, DrainValvesCount, RegValvesCount,
|
||||
@@ -158,7 +172,9 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 4: RelaysFInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 5: RelaysGInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 6: RelaysHInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 7: ShowState = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 7: RelaysIInstalled = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
case 8: QuidoRS = str; return CfgUpdateFlags.RestartRqrd;
|
||||
case 9: ShowState = (str == Strings.yes); return CfgUpdateFlags.RestartRqrd;
|
||||
default: return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
@@ -186,8 +202,11 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 9:
|
||||
if (ParamValues(i).Contains(str)) return true;
|
||||
break;
|
||||
case 8:
|
||||
return true;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
@@ -206,6 +225,8 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
prms.RelaysFInstalled = RelaysFInstalled;
|
||||
prms.RelaysGInstalled = RelaysGInstalled;
|
||||
prms.RelaysHInstalled = RelaysHInstalled;
|
||||
prms.RelaysIInstalled = RelaysIInstalled;
|
||||
prms.QuidoRS = QuidoRS;
|
||||
prms.ShowState = ShowState;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user