|
VR-Engage
2.3
|
DtOwnershipTransferConnector is the sole decision-making authority for all entity ownership acquire and divest operations in the VR-Engage frontend process. It lives as a base connector for the lifetime of the frontend session.
On acquire, the coordinator sends DtIfTakeOwnership directly to the current VRE Sim backend via the VRF message interface. DtIfTakeOwnershipResponse callbacks drive non-terminal status publications and terminal response publications back to the state machine.
On divest, the coordinator resolves the towing-specific LastVreSim target when present, otherwise falls back to LastVrfSim. If LastVrfSim is missing or unavailable, it uses the first available full-capabilities backend.
#include <ownershipTransferConnector.h>
Public Member Functions | |
| DtOwnershipTransferConnector ()=default | |
| virtual | ~DtOwnershipTransferConnector () override=default |
| virtual void | install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController, DtReflectedExtEntityList *reflectedExtEntityList) |
| virtual void | shutdown () override |
| virtual void | tick (double dt) override |
| virtual DtVreMessageResult | handleOwnershipTransferRequest (DtVreMessage *message) |
| virtual DtVreMessageResult | handleEntityRemoved (DtVreMessage *message) |
| virtual DtVreMessageResult | handlePlayerDisengaged (DtVreMessage *message) |
| virtual DtVreMessageResult | handlePlayerEngaged (DtVreMessage *message) |
| virtual DtExtEntityStateRepository * | reflectedEntityEESR (const DtEntityIdentifier &entityId) const |
Tick-Driven State Machine | |
| virtual void | startNextOperation () |
| virtual void | evaluateAndSend () |
| virtual void | evaluateAcquire (const DtSimulationAddress &vreSim) |
| virtual void | evaluateRelease (const DtSimulationAddress &vreSim) |
| virtual void | processBackendResponses (double dt) |
| virtual void | finalizeAndPublish () |
| virtual bool | detectBackendChange () |
| virtual void | detectExternalOwnershipChanges () |
Eligibility and Resolution | |
| virtual DtTransferEligibility | entityTransferElegibility (const DtEntityIdentifier &entityId, const DtSimulationAddress &targetVreSim, std::string &reason) const |
| virtual DtSimulationAddress | lastVrfSim (const DtUUID &entityUuid) const |
| virtual DtSimulationAddress | lastVreSim (const DtUUID &entityUuid) const |
Helpers | |
| virtual void | sendTransferOwnershipMessage (const DtSimulationAddress &target, const DtUUID &entityUuid) const |
| virtual void | sendStatusUpdate (VreOwnershipTransferStatusMessage::StatusCode statusCode) const |
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 () |
Protected Member Functions | |
| virtual void | clearSecondaryOwned () |
| virtual void | promoteSecondaryToPrimary () |
| virtual void | rollbackSecondaryOnAcquireFailure () |
| virtual void | clearAttrsForEntity (const DtUUID &uuid) |
| virtual void | setPrimaryOwned (const DtUUID &uuid, const DtEntityIdentifier &id) |
| virtual void | clearPrimaryOwned () |
| virtual bool | entityOnBackend (const DtEntityIdentifier &entityId, const DtSimulationAddress &vreSim) const |
| virtual bool | isRemoteVreOwnshipBackend (const DtSimulationAddress &backendAddress, const DtSimulationAddress &localVreSim) const |
| virtual bool | needsTowingOwnershipTransfer (const DtUUID &entityUuid) const |
| virtual bool | isOwnershipTransferDisabledForEntity (const DtEntityIdentifier &entityId) const |
| virtual DtSimulationAddress | statePropertySimAddress (const DtUUID &entityUuid, const std::string &propertyName) const |
| virtual std::vector< DtSimulationAddress > | releaseTargetsForEntity (const DtUUID &entityUuid, bool towingRelease) const |
| virtual bool | isBackendAvailable (const DtSimulationAddress &backendAddress) const |
| bool | ownershipTransferAvailable () const |
| virtual void | clearTowingOwnershipTransferMarker (const DtEntityIdentifier &entityId) const |
| virtual void | resetActiveDeadline () |
| virtual void | publishResponse (const OwnershipOperation &op, OwnershipTransferResponseMessage::ResponseStatus status, const std::string &msg=std::string()) const |
| virtual void | publishFailureIfExternal (const OwnershipOperation &op, const std::string &failureMsg) const |
| virtual void | completeActiveOperation (TerminalOutcome outcome, std::string failureMsg=std::string()) |
| virtual void | enqueueAutoDivestPair (const DtUUID ¤tPrimaryUuid, const DtEntityIdentifier ¤tPrimaryId) |
| virtual void | cancelPairedAcquire (unsigned int pairId, const std::string &failureMsg) |
| virtual bool | prepareSecondarySlot (const DtSimulationAddress &vreSim, std::string &outFailReason) |
| virtual void | tickIdleRelease (double dt) |
| virtual void | validateOwnshipEntity (double dt) |
| virtual void | blockingRelease (const DtUUID &uuid, const DtEntityIdentifier &entityId) |
VRF Response | |
| virtual void | onBackendEnabledChanged (bool enabled) |
| static void | takeOwnershipResponseCallback (DtSimMessage *msg, void *usr) |
Additional Inherited Members | |
Public Types inherited from makVre::DtConnector | |
| enum | DtConnectorType { DIS , HLA13 , HLA1516 , HLA1516E , HLA4 } |
Static Public Member Functions inherited from makVre::DtConnector | |
| static std::string | extension (DtConnectorType type) |
|
default |
Default constructor.
|
overridevirtualdefault |
Virtual destructor.
|
virtual |
Installs the coordinator with shared infrastructure.
| connection | Non-owning pointer to the protocol-specific VR-Link connection. |
| vrfRemoteController | Non-owning pointer to the shared VRF remote controller. |
| reflectedExtEntityList | Non-owning pointer to the reflected entity list used to look up entity sim engine addresses during eligibility checks |
Stores the non-owning infrastructure pointer, registers factory creators for DtIfTakeOwnership and DtIfTakeOwnershipResponse, registers the static takeOwnershipResponseCallback, and subscribes to OwnershipTransferRequestMessage via DtVreMessageManager. Binds the ownership-transfer manager from the global App attribute tree.
|
overridevirtual |
Shuts down the coordinator.
Cancels queued operations, removes the VRF response callback, unassigns App attribute handles, and clears non-owning infrastructure references.
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
overridevirtual |
Performs periodic processing for the ownership transfer coordinator.
Checks whether an in-flight acquire has exceeded its deadline and, if so, clears the pending transfer and publishes a terminal FAILURE response.
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
virtual |
Dispatches an incoming ownership transfer request by enqueuing it.
| message | Pointer to the ownership transfer request message |
|
virtual |
Dequeues the next operation from the FIFO queue and moves to Pending phase.
A no-op when the queue is empty (stays Idle).
|
virtual |
Evaluates EESR ground truth and sends TakeOwnership if needed.
Dispatches to evaluateAcquire or evaluateRelease based on operation type.
|
virtual |
Evaluates and dispatches the active Acquire operation.
| vreSim | The current VRE backend address (already validated non-null). |
|
virtual |
Evaluates and dispatches the active Release operation.
| vreSim | The current VRE backend address (already validated non-null). |
|
virtual |
Drains the response queue, applies response precedence, and advances state.
Processes all queued VRF responses in order, applying terminal detection per the response precedence table. After draining, checks timeout if no terminal was found.
| dt | Elapsed seconds since the previous tick. |
|
virtual |
Publishes results, updates ownership attrs, and returns to Idle phase.
For failed internal auto-divest releases, cancels the paired Acquire in the queue and publishes failure for the original request.
|
virtual |
Detects backend address change or disconnect; clears all state if found.
Checks the backend dirty flag set by the attribute callback. If the backend has changed or gone null, publishes failures for all in-flight work, clears queues and attrs, and returns true. The caller (tick) returns early.
|
virtual |
Detects when an entity has been transferred to our VRE backend by another station's divest, without an explicit acquire request.
Only runs during maintenance (phase==Idle && queue empty). If we don't currently own any entity but the local station is engaged on an entity whose simEngineAddress matches our VRE backend, claim ownership.
|
virtual |
Evaluates whether the entity can be transferred to the VRE sim backend.
| entityId | The entity identifier to check |
| targetVreSim | The simulation address of the VRE Sim backend |
| reason | Populated with a human-readable explanation when ineligible |
|
virtual |
Reads the reflected LastVrfSim owner for an entity.
| entityUuid | UUID of the entity |
|
virtual |
Reads the reflected LastVreSim owner for a towing-acquired entity.
| entityUuid | UUID of the entity |
|
static |
Static VRF message callback for DtIfTakeOwnershipResponse.
Extracts response data and pushes to myResponseQueue. Makes NO decisions.
| msg | Pointer to the simulation message |
| usr | Pointer to the connector instance |
|
virtual |
Processes a change to the backend Enabled attribute.
Sets myBackendDirtyFlag to true. All decision logic is deferred to detectBackendChange() in the next tick.
| enabled | The new value of the Enabled attribute |
|
virtual |
Sends DtIfTakeOwnership to the target backend.
| target | The simulation address to send to |
| entityUuid | The entity UUID to transfer |
|
virtual |
Publishes a VreOwnershipTransferStatusMessage to the frontend.
| statusCode | The status code to report |
|
virtual |
Handles notification that an entity was removed from the simulation.
If the removed entity matches the currently owned entity, clears all ownership tracking state and resets the attribute store to the initial values. This covers rewind and entity deletion scenarios.
| message | Pointer to the EntityRemovedMessage. |
|
virtual |
Handles OwnershipPlayerDisengagedMessage from chooseRoleState.
Arms the idle-release timer.
| message | Pointer to the OwnershipPlayerDisengagedMessage. |
|
virtual |
Handles OwnershipPlayerEngagedMessage from chooseRoleState.
Cancels an armed idle-release timer only when the message's entity matches the entity awaiting release.
| message | Pointer to the OwnershipPlayerEngagedMessage. |
|
virtual |
Looks up the extended entity state repository for a reflected entity.
Searches myReflectedEntityList for the first entry whose ESR entity identifier matches entityId and returns its extended ESR (EESR).
| entityId | The entity identifier to search for. |
|
protectedvirtual |
Clears secondary owned entity attributes to null.
|
protectedvirtual |
Promotes the secondary owned entity to primary.
Moves the secondary entity UUID and ID into the primary attributes, then clears the secondary.
|
protectedvirtual |
Rolls back secondary entity to primary after an acquire failure.
Called when a Vehicle acquire fails while the Human was moved to secondary (retain path). Restores Human as primary since it's still owned by our backend.
|
protectedvirtual |
Clears primary and/or secondary attrs that match the given entity UUID.
| uuid | The entity UUID to clear from owned attrs. |
|
protectedvirtual |
Sets primary owned entity attrs (UUID and ID together).
|
protectedvirtual |
Clears primary owned entity attrs (UUID and ID together).
|
protectedvirtual |
Returns true if entity is reflected and currently on the given backend.
|
protectedvirtual |
Returns true if an address belongs to a remote VRE ownship backend.
Uses the backend listener's limited-capability status first, then falls back to a recent remote VRE station status record.
| backendAddress | Simulation address to classify. |
| localVreSim | This station's VRE backend address, which is never remote. |
|
protectedvirtual |
Returns true if the reflected entity was acquired through towing.
|
protectedvirtual |
Returns true when the entity's DisableOwnershipTransfer state property is True.
| entityId | The entity to check |
|
protectedvirtual |
Reads a simulation-address-valued reflected state property.
|
protectedvirtual |
Resolves active candidate target backends for releasing an entity.
Prefers LastVreSim for towing releases, then LastVrfSim. When LastVrfSim is missing or unavailable, appends the first available backend that advertises all scenario capabilities.
|
protectedvirtual |
Returns true when the backend listener currently lists an address.
| backendAddress | Simulation address of the backend to find. |
|
protected |
Returns whether ownership transfer may run in the current session.
Returns false before the app-level manager is available and for unhosted or self-hosted sessions.
|
protectedvirtual |
Clears the reflected towing transfer marker after release succeeds.
|
protectedvirtual |
Resets the active operation's deadline using settings (or default).
|
protectedvirtual |
Publishes an OwnershipTransferResponseMessage for the given operation.
| op | The operation whose request id/entity is used to build the response. |
| status | The response status code to publish. |
| msg | Optional human-readable message. |
|
protectedvirtual |
Publishes a failure response for the operation only if it is externally visible (not an internal auto-divest and not idle-initiated).
|
protectedvirtual |
Transitions the active operation to Complete with the given outcome.
| outcome | Terminal outcome for the active operation. |
| failureMsg | Optional failure message (cleared if not provided). |
|
protectedvirtual |
Inserts an auto-divest pair at the front of the queue: a Release of the current primary followed by a re-queued copy of the active Acquire. Resets phase to Idle so the next tick processes the new pair.
|
protectedvirtual |
Cancels and removes the paired Acquire from the queue and publishes failure if it was externally visible.
|
protectedvirtual |
Checks whether the secondary slot can be used. If occupied by a stale entity, clears it. Returns false (with reason) if occupied by a live entity.
|
protectedvirtual |
Decrements the idle-release deadline and enqueues automatic release operations when it expires.
Internally gated: only counts down when phase==Idle && queue empty.
| dt | Elapsed seconds since the previous tick. |
|
protectedvirtual |
Validates that the currently-owned entity still exists on our backend, with a grace period before clearing stale ownership.
| dt | Elapsed seconds since the previous tick. |
|
protectedvirtual |
Releases an entity immediately during shutdown using sendImmediately=true, then clears local ownership attributes without waiting for backend response.
| uuid | The UUID of the entity to release. |
| entityId | The entity identifier to release. |
|
protected |
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 |
Non-owning pointer to the shared VRF remote controller.
|
protected |
Attribute handle for the app-level ownership-transfer manager.
Bound during install() to the non-owning manager pointer published by DtPlayerStationApp.
| Attribute Store Key | ownershipTransferManager |
|---|
|
protected |
Non-owning pointer to the reflected entity list.
|
protected |
FIFO operation queue. Handlers only push; tick() pops.
|
protected |
The currently executing operation and its phase.
|
protected |
VRF response queue. Callback pushes; tick() drains. Same thread — no mutex.
|
protected |
Monotonically increasing pair ID counter for linking auto-divest operations.
|
protected |
Set to true by onBackendEnabledChanged(); read and cleared by detectBackendChange().
|
protected |
Current VRE Sim backend simulation address.
| Attribute Store Key | vreBackendStatus.SimAddress |
|---|
|
protected |
Owned entity UUID. Written on acquire success, cleared on release/shutdown.
| Attribute Store Key | ownedEntityUuid |
|---|
|
protected |
Owned entity identifier. Written alongside UUID.
| Attribute Store Key | ownedEntityId |
|---|
|
protected |
Secondary (embarked) entity UUID.
| Attribute Store Key | secondaryOwnedEntityUuid |
|---|
|
protected |
Secondary (embarked) entity identifier.
| Attribute Store Key | secondaryOwnedEntityId |
|---|
|
protected |
Local station's currently engaged entity.
| Attribute Store Key | entityId |
|---|
|
protected |
Recent remote VRE station statuses used to identify ownship backends.
| Attribute Store Key | vreStatus.stations |
|---|
|
protected |
Seconds remaining before the idle-release timer fires. Zero means no timer is armed.
|
protected |
UUID of the entity the idle-release timer is armed for.
|
protected |
Entity identifier the idle-release timer is armed for.
|
protected |
Previous VRE backend address, tracked to detect disconnects.
|
protected |
Grace countdown for ownship entity validation (seconds).