VR-Engage  2.3
Loading...
Searching...
No Matches
Manager Panel Architecture

The VR-Engage Manager Panel (vreManager) is the reference implementation of External Role Management. It is a VR-Forces GUI extension that lets an operator monitor connected VR-Engage stations and assign entities and roles to them interactively. This page documents its internal architecture and the extension points a developer needs in order to understand, maintain, or reuse it.

For the on-the-wire message protocol, see External Role Management. For the operator-facing workflow, see the panel's user guide at design/VREngageManagerPanel/README-UserGuide.md.

Overview

vreManager builds a single Qt shared library that registers a dockable page (DtVreManagerWidget, a makVrv::DtPage) into the VR-Forces GUI. The panel never controls stations directly; it participates on the simulation network exactly like any external application, exchanging three interface messages:

Direction Message Role
In (heartbeat) DtIfVreStatus Station announces identity and current entity/role/spectator state
Out DtIfAssignRolePlayer Assign or change a station's entity + role (and spectator flag)
Out DtIfUnassignRolePlayer Return a station to role selection (Plan View)

Because the contract is message-only, the same code that backs this panel can be lifted into a standalone Instructor Operating Station — see External Role Management for that pattern.

Layered design

The module is deliberately split into UI-free and UI layers so the network and state logic can be reasoned about independently of Qt widgets.

flowchart TB
    subgraph UI["Presentation (Qt)"]
        Widget["DtVreManagerWidget<br/>(DtPage)"]
        TreeModel["DtVreEntityRoleTreeModel<br/>+ delegates"]
        ListModel["DtVreStationListModel<br/>+ sort proxy + delegate"]
    end
    subgraph Core["UI-free core"]
        Tracker["DtVreAssignmentTracker<br/>(QObject, no widgets)"]
        Persist["DtVreAssignmentPersistence<br/>(pure JSON)"]
        ModelDb["DtVreModelSetDb<br/>(role metadata)"]
    end
    subgraph Net["Network (no Qt)"]
        Listener["DtVreStatusListener<br/>(VreAppStatusMap, timeouts)"]
    end

    Listener -- "added/changed/removed callbacks" --> Widget
    Listener -- "added/changed/removed callbacks" --> Tracker
    Widget --> TreeModel
    Widget --> ListModel
    TreeModel -- "reads" --> Tracker
    ListModel -- "reads" --> Tracker
    Tracker -- "signals" --> TreeModel
    Tracker -- "signals" --> ListModel
    Tracker <--> Persist
    Tracker -- "roles for entity" --> ModelDb
    Widget -- "DtIfAssign/UnassignRolePlayer" --> Net

Network ingestion — DtVreStatusListener

Header include/vrfExtensions/vreManager/vreListener.h (library vreManager).

A Qt-free class that subscribes to DtVreStatusMessageType on the DtDe, decodes DtIfVreStatus, and maintains a VreAppStatusMap (std::map<std::string, VreAppStatus>) keyed by the stable station ID string. It:

  • diffs each heartbeat against the stored state and fires added / changed / removed callbacks accordingly;
  • removes a station immediately on its finalStatusMessage();
  • times out silent stations from signal_postTick (doTimeouts() / setTimeoutInterval()).

Notifications use three raw function-pointer callback lists registered via addVreAppAddedCallback / addVreAppChangedCallback / addVreAppRemovedCallback (and their remove* counterparts). Consumers must unregister in their destructor; registration is the mechanism both DtVreManagerWidget and DtVreAssignmentTracker use to observe the network.

Assignment state — DtVreAssignmentTracker

Header vreAssignmentTracker.h (library vreManager). A QObject with no widget dependencies. It is the authoritative model behind the current UI and implements the edit / preview / submit interaction model by overlaying two layers of state:

  • Confirmed — read through the listener's VreAppStatusMap; never mutated by the tracker.
  • Pending — local uncommitted edits: myPendingAssignments, myPendingUnassignments, mySpectatorPreferences, and placeholder stations (myPlaceholderStations) for offline/loaded assignments.

Queries return the effective assignment (pending over confirmed over placeholder). Key responsibilities:

  • conflict detection — two or more non-spectator stations on the same (entity, role);
  • computing the displacement set and the message payload a submit must send (getStationsToUnassign, getPendingAssignments, getPendingUnassignments);
  • reconciling pending edits against confirmed state as heartbeats arrive (the listener callbacks onStationAdded / onStationChanged / onStationRemoved);
  • emitting assignmentStateChanged, stationAdded, stationRemoved, and stationAssignmentChanged to drive UI refreshes.

Persistence — DtVreAssignmentPersistence

Header vreAssignmentPersistence.h (library vreManager). A static, UI-free unit that serializes the tracker's effective layout to a versioned JSON document and validates it on load:

The current serializer/reader in libsrc/vrfExtensions/vreManager/vreAssignmentPersistence.cxx uses these fields:

Field Contract
version Root format version, currently 1
assignments Root array of assignment objects
stationName Required nonempty string; stable station identity
entityUuid Required nonempty string containing the full DtUUID::uuidString() representation
roleName Required nonempty entity-role name
objectName Optional display name
spectatorMode Boolean; defaults to false with a warning when absent

isPlaceholder is not a serialized field. Placeholder state is reconstructed by the tracker.

Saving uses QSaveFile for an atomic write; loading reports per-field errors (missing/empty required fields, wrong version, malformed container) distinctly from warnings (e.g. a missing spectatorMode). Placeholders are preserved so a layout can be prepared before stations connect.

Entity/role metadata — DtVreModelSetDb

Header vreModelSetDb.h (library vreManager). A DtDe-scoped singleton wrapping DtVreModelSet. It answers, from loaded .entity definition files, whether an entity type is VR-Engage-controllable (isVreEntityType) and which roles an entity exposes (lookupEngageStationData). It is the source of the role lists shown in the tree and the engageability check that limits the entity tree to controllable entities.

Presentation

The widget presents a two-panel QSplitter: an entity/role tree on one side and a station list on the other. The tree is backed by DtVreEntityRoleTreeModel; the station list by DtVreStationListModel (wrapped in DtVreStationSortProxyModel for sorting). Rendering uses DtStationItemDelegate and DtEntityRoleTreeDelegate.

The tree model groups entities by SISO force and nested aggregates, lists each entity's engageable roles as leaves, and overlays live assignment state read from the tracker. Edits in the UI flow out through click-to-arm and drag-and-drop (station → role), which call DtVreAssignmentTracker::setPendingAssignment; there is no setData() on the tree model.

An earlier table-based UI, selected by a VRE_USE_NEW_MANAGER_UI compile-time flag, has been removed; the two-panel layout above is now the only UI. The legacy table model, view, item delegates, entity-selection dialog, and vreManagerWidget.ui were deleted (see the design review's "Legacy-UI removal" note).

Registration and lifecycle

The panel is registered by the vreVrfGuiPlugin GUI plugin, not by vreManager itself (in the plugin's assembleQtElements method):

The source libsrc/vrfExtensions/vreVrfGuiPlugin/vreVrfGuiPlugin.cxx resolves the startup assignment filename, then registers the page creator:

// Source: vreVrfGuiPlugin.cxx, assembleQtElements() excerpt
DtQtPageAssembler::instance(de).registerPageCreator(
new DtVreManagerWidgetCreator(de, startupAssignmentFile));
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.

The function obtains the current DtVrfGuiApplication, checks whether the page collection already exists, and then adds the collection/page/menu paths. Keep those guards and application context when adapting it. The file includes the Manager widget, Qt page assembler, and VR-Forces GUI application headers.

DtVreManagerWidgetCreator (a DtPageCreator) constructs the widget on demand; DtVreManagerWidget's constructor is private and grants the creator friend access. The widget identifies itself through pageClassName() ("DtVreManagerWidget"), title() ("VR-Engage Manager"), and icon(). The same plugin also installs a VR-Engage entry into the VR-Forces About box via DtVreVrfAboutItem (vreVrfHelpActions).

At construction the widget creates the listener, tracker, and models and registers its listener callbacks; activate() / deactivate() manage the page's visibility-driven wiring; the destructor unregisters callbacks and tears down the manually-owned objects.

End-to-end data flow

---
config:
  sequence:
    width: 220
    actorMargin: 45
---
sequenceDiagram
    participant Net as Network
    participant L as DtVreStatusListener
    participant W as DtVreManagerWidget
    participant T as DtVreAssignmentTracker
    participant M as Tree / List models
    Net->>L: DtIfVreStatus (heartbeat)
    L->>T: onStationAdded / Changed / Removed
    L->>W: handleVreAppAdded / Changed / Removed
    T->>M: assignmentStateChanged / stationAdded / removed
    Note over W,T: Operator drags a station onto a role
    W->>T: setPendingAssignment(stationId, uuid, role)
    T->>M: assignmentStateChanged (preview)
    Note over W: Operator clicks Submit
    W->>T: read getPendingAssignments / getStationsToUnassign
    W->>Net: DtIfAssignRolePlayer / DtIfUnassignRolePlayer
    W->>T: clearAllPendingAssignments()
    Net->>L: updated DtIfVreStatus → confirms, clears pending

Reference: public headers

The panel is implemented in the vreManager library (vreManager.dll), a VR-Forces GUI extension; registration is provided by the vreVrfGuiPlugin plugin. The public headers below declare the classes described on this page. Implementation sources are internal to those libraries and are not distributed.

Component Header Library
Panel widget (DtPage) include/vrfExtensions/vreManager/vreManagerWidget.h vreManager
Status listener include/vrfExtensions/vreManager/vreListener.h vreManager
Assignment tracker include/vrfExtensions/vreManager/vreAssignmentTracker.h vreManager
Assignment persistence include/vrfExtensions/vreManager/vreAssignmentPersistence.h vreManager
Model-set DB include/vrfExtensions/vreManager/vreModelSetDb.h vreManager
Entity/role tree model include/vrfExtensions/vreManager/vreEntityRoleTreeModel.h vreManager
Station list model include/vrfExtensions/vreManager/vreStationListModel.h vreManager
Station sort proxy include/vrfExtensions/vreManager/vreStationSortProxyModel.h vreManager
Tree / station delegates include/vrfExtensions/vreManager/entityRoleTreeDelegate.h, stationItemDelegate.h vreManager
Plugin registration include/vrfExtensions/vreVrfGuiPlugin/vreVrfGuiPlugin.h vreVrfGuiPlugin

Extending the panel

  • Reuse the listener to observe station status in your own VR-Forces GUI code: instantiate DtVreStatusListener(de) and register callbacks; it has no Qt dependency. Always unregister in your destructor.
  • Reuse the tracker to drive a different UI: it is UI-free apart from Qt signals, and exposes the full conflict/displacement/placeholder logic plus persistence import/export.
  • Add a new role attribute to the tree: extend the VreTreeDataRole enum and the data() switch in DtVreEntityRoleTreeModel, then read it from the column-1 delegate.
  • Change controllability rules: adjust DtVreModelSetDb::isVreEntityType / lookupEngageStationData (driven by .entity definitions and engageControllable()).

See also