|
VR-Engage
2.3
|
DtVreBackendConnector manages the full lifecycle of the VR-Engage simulation backend: configuration of the backend's simulation address, building and launching the backend process, loading scenarios, stopping the backend, and monitoring backend status changes.
In addition, it bridges chat events between the VRF event manager and the VR-Engage message bus, and handles wind state queries via the VRF remote environment controller.
#include <vreBackendConnector.h>
Public Member Functions | |
| DtVreBackendConnector () | |
| virtual | ~DtVreBackendConnector () override |
| virtual void | install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController) |
| virtual void | tick (double dt) override |
| virtual void | shutdown () override |
| bool | hasBackendAddress () const |
| DtSimulationAddress | backendAddress () const |
| void | setStartupTimeoutSeconds (int seconds) |
| virtual DtVreMessageResult | handleSetBackendConfig (DtVreMessage *message) |
| virtual DtVreMessageResult | handleStartBackend (DtVreMessage *message) |
| virtual DtVreMessageResult | handleStopBackend (DtVreMessage *message) |
| virtual DtVreMessageResult | handleRequestBackendStatus (DtVreMessage *message) |
| virtual DtVreMessageResult | handleLoadBackend (DtVreMessage *message) |
| virtual DtVreMessageResult | handleChatEvent (DtVreMessage *message) |
| virtual DtVreMessageResult | handleWindRequest (DtVreMessage *message) |
Public Member Functions inherited from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector | |
| DtSimEventConnector () | |
| virtual | ~DtSimEventConnector () override |
| virtual void | install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection) |
Public Member Functions inherited from makVre::DtConnector | |
| DtConnector () | |
| virtual | ~DtConnector () |
| virtual DtConnectorType | type () |
| virtual std::string | name () |
Static Public Member Functions | |
| static void | BackendDiscovered (const DtSimulationAddress &addr, void *usr) |
| static void | BackendRemoved (const DtSimulationAddress &addr, void *usr) |
| static void | ifLoadCompleteMessageCallback (DtSimMessage *msg, void *usr) |
| static bool | backendRemapper (DtBackendMap *map, const std::set< DtSimulationAddress > &expectedBackends, void *usr) |
Static Public Member Functions inherited from makVre::DtConnector | |
| static std::string | extension (DtConnectorType type) |
Protected Member Functions | |
| virtual void | processBackendDiscovered (const DtSimulationAddress &addr) |
| virtual void | processBackendRemoved (const DtSimulationAddress &addr) |
| virtual void | processLoadCompleteMessage (DtSimMessage *msg) |
| virtual void | processChatEvent (const makVrfEvents::DtEvent &evt) |
| virtual void | updateBackendStatus () |
| virtual void | sendBackendStatusMessage () |
| virtual bool | remapBackends (DtBackendMap *map, const std::set< DtSimulationAddress > &expectedBackends) |
| virtual void | sendTerrainScenario (DtScenario &scenario, const LoadBackendMessage *loadMsg, const std::set< std::string > &sessionSmsList, const DtFilename &terrain, const DtFilename &guiTerrain) |
| virtual void | sendSessionSmsUpdate () |
| virtual void * | launchVrfBackend (const DtSimulationAddress &address, int sessionId, int simType, const std::vector< std::string > &pluginBaseNames, bool showConsole, std::string &additionalArguments) |
| std::string | vrfSimEngineCommand (const DtSimulationAddress &address, int sessionId, int simType, const std::vector< std::string > &pluginBaseNames, std::string &additionalArguments) |
| virtual std::string | application () const |
| virtual std::string | connectionParameters (const DtSimulationAddress &address, std::string &additionalArguments) const |
| virtual std::string | protocol () const |
| void | clearBackendState () |
Additional Inherited Members | |
Public Types inherited from makVre::DtConnector | |
| enum | DtConnectorType { DIS , HLA13 , HLA1516 , HLA1516E , HLA4 } |
| makVre::DtVreBackendConnector::DtVreBackendConnector | ( | ) |
Default constructor. Initializes all state to default values.
|
overridevirtual |
Virtual destructor.
|
virtual |
Installs the backend connector with shared infrastructure.
| connection | Non-owning pointer to the protocol-specific VR-Link connection. |
| vrfRemoteController | Non-owning pointer to the shared VRF remote controller owned by DtConnectorAccessory. |
Also binds handles from the global App attribute tree and locks write-protected handles (myBackendIsHostAttr, myBackendStatusAttr) to prevent unintended writes from other connectors. These handles are read-only for this connector.
|
overridevirtual |
Performs periodic backend status evaluation.
Calls updateBackendStatus() each tick to detect backend status changes and broadcast updates to the frontend.
| dt | The elapsed time in seconds since the last tick |
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
overridevirtual |
Shuts down the connector.
Stops any running VRE backend process (sends DtIfExit), disconnects the chat boost signal, unregisters all VRE message handlers, and removes the DtLoadCompleteMessageType VRF callback.
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
virtual |
Backend lifecycle message handlers.
Handles backend configuration (site ID and application ID for starting address)
| message | Pointer to the SetBackendConfigMessage |
|
virtual |
Handles a request to launch the VRE backend process.
| message | Pointer to the StartBackendMessage |
If a backend is already running, queues a StopBackend + restart sequence. Otherwise calls launchVrfBackend() to spawn the sim process and updates the backend address. Publishes myBackendIsHostAttr to the global App attribute tree.
|
virtual |
Handles a request to stop the VRE backend process.
| message | Pointer to the StopBackendMessage (may be nullptr when called internally) |
Sends DtIfExit to the backend, clears backend state via clearBackendState(), and resets snapshot state.
|
virtual |
Handles a request for the current backend status.
| message | Pointer to the RequestBackendStatusMessage |
|
virtual |
Handles a request to load a scenario on the VRE backend.
| message | Pointer to the LoadBackendMessage |
Validates backend readiness, then loads either a session terrain (if a session is running), a full scenario file (if this backend can host), or a terrain-only scenario. Reads session state from DtSessionStatusConnector.
|
virtual |
Chat and environmental message handlers.
Handles chat send messages from the frontend → VRF backend
| message | Pointer to the ChatMessage |
|
virtual |
Handles wind state request messages.
| message | Pointer to the WindStateRequestMessage |
Queries the VRF remote environment controller for wind speed and direction at the requested geocentric location and queues a WindStateResponseMessage.
|
static |
Static callbacks for VRF backend events.
Static callback invoked when a backend simulation address is discovered
|
static |
Static callback invoked when a backend simulation address is removed.
|
static |
Static callback invoked when a VRE backend reports scenario load complete.
| msg | Pointer to the DtLoadComplete simulation message |
| usr | Pointer to the connector instance |
|
static |
Static callback for remapping backend addresses during scenario load.
| map | Backend address map to remap |
| expectedBackends | Set of expected backend addresses |
| usr | Pointer to the connector instance |
| bool makVre::DtVreBackendConnector::hasBackendAddress | ( | ) | const |
Returns true if this connector has a pending or active VRE backend address.
True from the moment handleStartBackend() sets the address, even before the backend process connects. Use for lifecycle guards (stop, shutdown, timeout).
| DtSimulationAddress makVre::DtVreBackendConnector::backendAddress | ( | ) | const |
Returns the current VRE backend simulation address.
Returns DtSimulationAddress::nullId() when no backend address is configured. The address is stored as the vreBackendStatus.SimAddress child attribute.
| void makVre::DtVreBackendConnector::setStartupTimeoutSeconds | ( | int | seconds | ) |
Sets the startup timeout used to detect backends that fail to connect.
If the backend process does not appear in the backend listener within this many seconds of being launched, the connector clears the backend state. Defaults to 30 seconds. A process-exit check (Windows only) takes priority: if the launched process is detected as exited before the timeout elapses, the state is cleared immediately.
| seconds | Timeout in seconds; must be positive |
|
protectedvirtual |
Processes a backend discovery notification.
| addr | Simulation address of the discovered backend |
|
protectedvirtual |
Processes a backend removal notification.
| addr | Simulation address of the removed backend |
|
protectedvirtual |
Processes a load-complete message from the VRE backend.
| msg | Pointer to the load-complete simulation message |
Calls loadedScenario() on the VRF remote controller, then takes a base snapshot.
|
protectedvirtual |
Processes a chat event received from the VRF event manager.
| evt | The VRF chat event; ignored if not a DtChatMessageEvent |
Connected via boost signal in install(). Converts the VRF chat event to a ChatMessage and queues it in the VRE message manager.
|
protectedvirtual |
Evaluates the current backend status and broadcasts changes to the frontend.
Inspects the backend referenced by backendAddress() via the backend listener. Sends a late-join Run command if the session is already playing but the backend just became loaded. Broadcasts BackendStatusMessage when any field changes.
|
protectedvirtual |
Sends the current cached backend status to the frontend.
|
protectedvirtual |
Remaps all backend addresses in a scenario to the current VRE backend address.
| map | Backend address map to remap in-place |
| expectedBackends | Set of expected backend addresses (unused; provided by VRF API) |
|
protectedvirtual |
Configures a scenario with terrain, SMS, and component attachment settings, then sends it to the backend.
| scenario | The scenario object to configure and send |
| loadMsg | The load backend message supplying exercise start time and component attachment table |
| sessionSmsList | The set of simulation model set filenames to add to the scenario |
| terrain | The terrain database filename |
| guiTerrain | The GUI terrain database filename; uses terrain if empty |
|
protectedvirtual |
|
protectedvirtual |
Launches a VR-Forces backend process with the specified parameters.
Builds a command line via vrfSimEngineCommand() and spawns the process via the platform process API.
| address | Site/application ID to use for the new backend |
| sessionId | VR-Engage session ID to pass to the backend |
| simType | Simulation mode: full VR-Forces, ownship-only, or limited |
| pluginBaseNames | List of plugin base names to load |
| showConsole | Whether to open a console window for the backend process |
| additionalArguments | Additional command-line arguments (may be modified) |
|
protected |
Builds the full command-line string for the sim engine process.
| address | Site/application ID to use |
| sessionId | VR-Engage session ID |
| simType | Simulation mode (full, ownship, limited) |
| pluginBaseNames | Plugin base names to include |
| additionalArguments | Additional arguments (may be modified to remove duplicates) |
|
protectedvirtual |
Returns the sim engine executable name (protocol- and build-variant-aware)
|
protectedvirtual |
Builds protocol-specific connection parameters for the sim engine command line.
| address | Site/application ID |
| additionalArguments | Additional arguments (duplicates are removed and warned) |
|
protectedvirtual |
Returns the protocol name string used in command-line arguments.
|
protected |
Clears all backend-owned state atomically.
Sets SimEngineAddress to nullId, Enabled to false, and resets snapshot state. Called from handleStopBackend, processBackendRemoved, startup timeout, and shutdown.
|
protected |
Handle to the launched backend process (Windows only; nullptr on other platforms)
Populated by launchVrfBackend() and cleared by clearBackendState(). Used to detect early process exit before the startup timeout fires.
|
protected |
Infrastructure pointers (NON-OWNING — owned by DtConnectorAccessory)
Shared VRF remote controller (NON-OWNING)
Provides access to the VRF message interface, backend listener, remote control APIs, and remote environment controller. Lifetime managed by DtConnectorAccessory, guaranteed to outlive this connector.
|
protected |
Connection for chat event forwarding callback.
|
protected |
Launch configuration.
Exercise connection initializer used to build protocol-specific connection parameters
Non-owning pointer sourced from the VR-Link driver during install(). Lifetime is guaranteed to outlive this connector.
|
protected |
VR-Engage session ID passed to the backend process on launch.
|
protected |
List of plugin base names to load in the backend process.
|
protected |
Whether to open a console window for the backend process.
|
protected |
Additional command-line arguments for the backend process.
|
protected |
Backend state.
Starting simulation address used when launching a new backend process
Incremented if already in use (from mySimulationAddresses).
|
protected |
True if a TakeBaseSnapshot save was issued after the scenario loaded.
|
protected |
Simulation time at which the base snapshot was taken.
|
protected |
Time point at which the backend process was launched.
Used to detect backends that fail to start: if the backend has not appeared in the backend listener within a timeout period after launch, the connector clears the stale address.
|
protected |
Startup timeout in seconds for detecting backends that fail to connect.
If the backend process has not appeared in the backend listener within this many seconds of being launched, the connector clears the stale backend address. Configurable via setStartupTimeoutSeconds(). Defaults to 30 seconds.
|
protected |
Set of all discovered backend simulation addresses.
Used to avoid starting a new backend at an address already in use.
|
protected |
True if the session is currently playing (not paused)
| Attribute Store Key | sessionPlayState |
|---|
|
protected |
Current set of simulation model set filenames for this session.
| Attribute Store Key | sessionSmsList |
|---|
|
protected |
Indicates whether this station is the backend host; true if started in full-forces (host) mode.
| Attribute Store Key | vreBackendIsHost |
|---|
|
protected |
Published backend status data.
| Attribute Store Key | vreBackendStatus |
|---|
|
protected |
Current cached session status data.
| Attribute Store Key | sessionStatus |
|---|