![]() |
VR-Forces Developer's Guide
|
DtVrfManager - Generic VRF tick engine and command gateway.
Responsibilities:
The DtVrfManager has NO knowledge of specific processor types. Processors are registered by the WebSocket layer on client connect and removed on client disconnect.
Thread Safety:
Public Member Functions | |
| void | initialize (DtRemoteControlInitializer &initializer, const std::string &configFilePath) |
| void | shutdown () |
| bool | isInitialized () const |
| void | addProcessor (std::shared_ptr< DtProcessor > processor) |
| void | removeProcessor (std::shared_ptr< DtProcessor > processor) |
| DtDatasource::DtDataSourceStatus | getStatus () |
| size_t | trackedObjectCount () const |
| DtWebServerObjectList & | trackedObjects () |
| tbb::spin_rw_mutex & | vrfApiMutex () |
| const DtWebServerSubordinateResolver & | subordinateResolver () const |
| std::vector< DtWebServerObjectPtr > | allTrackedObjects () const |
| std::vector < DtDatasource::DtContactReportSnapshot > | contactReportsForRoles (const std::vector< std::string > &roleNames) const |
| int | entityForceId (const std::string &objectName) const |
| std::string | tacticalGraphicOverlay (const std::string &objectName) const |
| size_t | capableTaskQueueSize () const |
| Json::Value | getScenarioStatus () const |
| uint64_t | scenarioStatusGeneration () const |
| void | pauseScenario () |
| void | resumeScenario () |
| bool | deleteObject (const std::string &objectName) |
| bool | editObject (const std::string &objectName, const Json::Value &body, std::string &errorMessage, bool &isValidationError) |
| std::string | createTacticalGraphic (const Json::Value &body, std::string &errorMessage, bool &isValidationError) |
| Json::Value | getCommandSummaries (const std::vector< std::string > &filter={}) |
| Json::Value | getCommandSpec (const std::string &commandType, const std::string &objectName="") |
| Json::Value | getRwCommandSpecsConfig () |
| bool | updateRwCommandSpecEntry (const std::string &commandType, const Json::Value &entry) |
| bool | issueCommand (const std::string &objectName, const std::string &commandType, const Json::Value ¶meters, std::string *errorMessage=nullptr) |
| bool | skipTask (const std::string &objectName, std::string *errorMessage=nullptr) |
| void | addScenarioChangedListener (std::function< void(const std::string &)> listener) |
Static Public Member Functions | |
| static DtVrfManager & | getInstance () |
Protected Member Functions | |
| DtVrfManager () | |
| ~DtVrfManager () | |
| DtVrfManager (const DtVrfManager &)=delete | |
| DtVrfManager & | operator= (const DtVrfManager &)=delete |
| void | initializeVRFAPI (DtRemoteControlInitializer &initializer) |
| void | shutdownVRFAPI () |
| DtDatasource::DtDataSourceStatus | queryStatusFromVRF () |
| void | onStatusChanged () |
| Json::Value | queryScenarioStatusFromVRF () |
| void | onStateDataAdded (makVrf::DtStateData *stateData) |
| void | onStateDataAboutToBeRemoved (const makVrf::DtStateData *stateData) |
| void | onCurrentTaskChanged (const DtUUID &uuid) |
| void | syncRoleSpotReportPerspectives () |
| void | tryBindParameterDb () |
| void | vrfUpdateLoop () |
Static Protected Member Functions | |
| static void | statusChangedCallback (DtSimulationStatus status, void *userData) |
|
protected |
|
protected |
|
protecteddelete |
|
static |
Singleton accessor.
| void DtVrfManager::initialize | ( | DtRemoteControlInitializer & | initializer, |
| const std::string & | configFilePath | ||
| ) |
| void DtVrfManager::shutdown | ( | ) |
|
inline |
References myInitialized.
| void DtVrfManager::addProcessor | ( | std::shared_ptr< DtProcessor > | processor | ) |
Add a processor to the tick loop. The processor's initialize() is called immediately so it is ready before the next tick. Safe to call from any thread.
| void DtVrfManager::removeProcessor | ( | std::shared_ptr< DtProcessor > | processor | ) |
Remove a processor from the tick loop. The processor's shutdown() is called before it is removed. Safe to call from any thread.
| DtDatasource::DtDataSourceStatus DtVrfManager::getStatus | ( | ) |
|
inline |
References myTrackedObjects, and DtWebServerObjectList::size().
|
inline |
References myTrackedObjects.
|
inline |
References myVrfApiMutex.
|
inline |
References mySubordinateResolver.
| std::vector<DtWebServerObjectPtr> DtVrfManager::allTrackedObjects | ( | ) | const |
Returns a thread-safe snapshot of all currently tracked simulation objects. Acquires a shared read lock on the VRF API mutex.
| std::vector<DtDatasource::DtContactReportSnapshot> DtVrfManager::contactReportsForRoles | ( | const std::vector< std::string > & | roleNames | ) | const |
Returns contact report snapshots visible to the given roles. For each role, queries the corresponding DtSpotReportByForceAndUuidPerspective (if one exists) and collects all flushed contact report handlers. Deduplicates across roles by spot-report UUID. Acquires myVrfApiMutex shared; safe to call from WebSocket timer threads.
| int DtVrfManager::entityForceId | ( | const std::string & | objectName | ) | const |
Returns the DIS force ID for the entity with the given objectName (UUID string). Returns -1 if the object is not found or the name is not a valid UUID.
| std::string DtVrfManager::tacticalGraphicOverlay | ( | const std::string & | objectName | ) | const |
Returns the overlay name for the tactical graphic with the given UUID. Returns an empty string if the object is not found.
|
inline |
Returns the number of entities waiting for a CapableTaskAndSet response. Safe to call from any thread.
References myCapableTaskRequester, and DtCapableTaskRequester::queueSize().
| Json::Value DtVrfManager::getScenarioStatus | ( | ) | const |
Returns a JSON snapshot of the current scenario status, ready for wire transmission. Safe to call from any thread.
| uint64_t DtVrfManager::scenarioStatusGeneration | ( | ) | const |
Monotonically increasing counter incremented whenever scenario status changes (excluding simulation time). WebSocket listeners compare this against their own cached value to detect changes without deep comparison.
| void DtVrfManager::pauseScenario | ( | ) |
| void DtVrfManager::resumeScenario | ( | ) |
| bool DtVrfManager::deleteObject | ( | const std::string & | objectName | ) |
| bool DtVrfManager::editObject | ( | const std::string & | objectName, |
| const Json::Value & | body, | ||
| std::string & | errorMessage, | ||
| bool & | isValidationError | ||
| ) |
Applies one or more attribute/geometry edits to an existing tactical graphic by building a single DtIfModifyVrfObject from the supplied JSON body.
| objectName | UUID string of the object to edit. |
| body | JSON object containing any subset of: Coordinates ([[lat,lon,alt],...]), ForceIdentifier (int>=0), Marking (string), OverlayName (string), Active (bool), Label (string). |
| errorMessage | Populated on failure with a human-readable reason. |
| isValidationError | Set true for client input errors (maps to 400), false for server-side failures (maps to 404). |
| std::string DtVrfManager::createTacticalGraphic | ( | const Json::Value & | body, |
| std::string & | errorMessage, | ||
| bool & | isValidationError | ||
| ) |
Create a new tactical graphic (overlay object) from the JSON request body. Validates all required fields, generates a UUID, and sends a fire-and-forget create message to the sim. On failure, errorMessage is populated with a human-readable reason and isValidationError indicates whether the failure was a client input error (HTTP 400) or an unexpected server error (HTTP 500).
| Json::Value DtVrfManager::getCommandSummaries | ( | const std::vector< std::string > & | filter = {} | ) |
Returns a JSON array of lightweight command summaries for building menus/toolbars. If filter is non-empty, only the listed commandTypes are returned.
| Json::Value DtVrfManager::getCommandSpec | ( | const std::string & | commandType, |
| const std::string & | objectName = "" |
||
| ) |
Returns the full parameter spec for a single command type. objectName is optional; when supplied, entity-specific choice lists are populated. Returns a null Json::Value if commandType is unknown.
| Json::Value DtVrfManager::getRwCommandSpecsConfig | ( | ) |
Returns a JSON array of all registered RW command types merged with any existing configuration from commandSpecs.json. Intended for the configure web UI — includes hidden status and all stored fields.
| bool DtVrfManager::updateRwCommandSpecEntry | ( | const std::string & | commandType, |
| const Json::Value & | entry | ||
| ) |
Upserts the commandSpecs.json entry for commandType in memory and on disk. The supplied entry JSON entirely replaces any existing entry.
| bool DtVrfManager::issueCommand | ( | const std::string & | objectName, |
| const std::string & | commandType, | ||
| const Json::Value & | parameters, | ||
| std::string * | errorMessage = nullptr |
||
| ) |
Dispatches a command to the named entity.
| errorMessage | If non-null and the call fails, populated with a human-readable reason (bad UUID, unknown command type, wrong parameter type, etc.). |
| bool DtVrfManager::skipTask | ( | const std::string & | objectName, |
| std::string * | errorMessage = nullptr |
||
| ) |
Sends a skip-task request to the named entity.
| objectName | UUID string identifying the simulation object. |
| errorMessage | If non-null and the call fails, populated with a human-readable reason. |
| void DtVrfManager::addScenarioChangedListener | ( | std::function< void(const std::string &)> | listener | ) |
Registers a callback that is invoked on the VRF update thread whenever the scenario name changes (a new scenario is loaded or the current one is unloaded). The argument is the raw scenario path string as reported by VRF; it is empty when no scenario is loaded. Must be called from main() before the VRF update loop starts.
|
protecteddelete |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
Query current scenario status from VRF; called on the VRF tick thread.
|
protected |
|
protected |
|
protected |
Invoked on the VRF update thread whenever an entity's current task changes. Copies the latest EntityTaskInformation from DtRemoteControlCurrentTaskManager into the corresponding DtWebServerObject.
|
protected |
Checks whether the active role definition has changed and, if so, rebuilds the per-role DtSpotReportByForceAndUuidPerspective instances on the spot-report manager. Also triggered by a scenario change (myCachedRoleDefinitionGeneration is reset to UINT64_MAX in vrfUpdateLoop on every scenario name transition). Called exclusively from the VRF update thread — no additional locking needed.
|
protected |
Fully loads available sms parameters, so they are available for querying information afterwards Called once during initialization, after the VRF API is initialized and the first scenario status is received (which indicates that the sim is ready).
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Last observed DateAndTimeOfDay; used to detect manual time jumps.
|
protected |
|
protected |
|
protected |
|
mutableprotected |
Referenced by vrfApiMutex().
|
protected |
|
protected |
|
protected |
Referenced by isInitialized().
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
Referenced by trackedObjectCount(), and trackedObjects().
|
protected |
|
protected |
|
protected |
Connection handle for DtRemoteControlCurrentTaskManager::signal_currentTaskChanged. Disconnected explicitly in shutdownVRFAPI() to avoid dangling callbacks into a partially-torn-down DtVrfManager.
|
protected |
Manages one DtSpotReportByForceAndUuidPerspective per role that is configured to receive contact reports. Accessed only from the VRF update thread.
|
protected |
Referenced by subordinateResolver().
|
protected |
Generation counter cached from DtRoleDefinitionStore::definitionGeneration(). Initialised to UINT64_MAX so that syncRoleSpotReportPerspectives() always performs a rebuild on the first tick.
|
protected |
Referenced by capableTaskQueueSize().
|
protected |
|
protected |