|
VR-Engage
2.3
|
DtOwnshipCreationConnector is responsible for the lifecycle of the single locally controlled "new ownship" entity. When the frontend requests a new ownship of a specific type, this connector submits a createEntity call to the VR-Forces backend and tracks the result via a static callback. When the desired entity type changes (or is cleared), it deletes the existing entity and optionally creates a new one.
The connector registers entity-added and entity-removed callbacks on the DtReflectedExtEntityList to detect when the created entity appears in or disappears from the reflected entity list. These callbacks are filtered to the owned entity only.
Backend readiness (started + loaded) and the active backend address are read from the app attribute store via DtAttributeHandleType<> handles published by DtVreBackendConnector. This avoids any direct connector-to-connector pointer dependency.
#include <ownshipCreationConnector.h>
Public Member Functions | |
| DtOwnshipCreationConnector () | |
| virtual | ~DtOwnshipCreationConnector () override |
| virtual void | install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController, DtReflectedExtEntityList *reflectedExtEntityList) |
| virtual void | tick (double dt) override |
| virtual void | shutdown () override |
| virtual DtVreMessageResult | handleCreateNewOwnship (DtVreMessage *message) |
| virtual DtVreMessageResult | handleDestroyNewOwnship (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 | localEntityCreatedCallback (const DtString &name, const DtEntityIdentifier &id, const DtUUID &uuid, void *usr) |
| static void | ownedEntityAddedCallback (DtReflectedExtEntity *obj, void *usr) |
| static void | ownedEntityRemovedCallback (DtReflectedExtEntity *obj, void *usr) |
Static Public Member Functions inherited from makVre::DtConnector | |
| static std::string | extension (DtConnectorType type) |
Protected Member Functions | |
| virtual void | verifyNewOwnship () |
| virtual void | sendCreateNewOwnship () |
| virtual void | sendDeleteNewOwnship () |
| virtual void | handleLocalEntityCreated (const DtString &name, const DtEntityIdentifier &entityId, const DtUUID &uuid) |
| virtual void | handleOwnedEntityAdded (const DtReflectedExtEntity *entity) |
| virtual void | handleOwnedEntityRemoved (const DtReflectedExtEntity *entity) |
Protected Attributes | |
| makVrf::DtVrlinkVrfRemoteController * | myVrfRemoteController = nullptr |
| DtReflectedExtEntityList * | myReflectedExtEntityList = nullptr |
| DtAttributeHandleType< DtSimulationAddress > | myVreBackendAttr |
| DtAttributeHandleType< BackendStatusMessage::BackendStatusData > | myBackendStatusAttr |
| CreateNewOwnshipMessage * | myDesiredCreateEntityMessage |
| DtReflectedExtEntityInfo | myCreatedEntityInfo |
| bool | myWaitingForOwnshipDelete = false |
| bool | myWaitingForOwnshipCreate = false |
| bool | myCreatedOwnshipNeedsReposition = false |
Protected Attributes inherited from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector | |
| makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection * | myConnection |
Protected Attributes inherited from makVre::DtConnector | |
| std::string | myName |
| DtConnectorType | myType |
| DtAttributeCallbackManager | myAttributeCallbacks |
| DtVreMessageHandlerGroup | myMessageHandlers |
Additional Inherited Members | |
Public Types inherited from makVre::DtConnector | |
| enum | DtConnectorType { DIS , HLA13 , HLA1516 , HLA1516E , HLA4 } |
| makVre::DtOwnshipCreationConnector::DtOwnshipCreationConnector | ( | ) |
Default constructor. Initializes all state to default/null values.
|
overridevirtual |
Virtual destructor. Frees myDesiredCreateEntityMessage.
|
virtual |
Installs the ownship connector with shared infrastructure.
Stores the infrastructure pointers, registers VRE message handlers for CreateNew/DestroyNewOwnship, and registers entity-added/removed callbacks on the reflected ext entity list. Backend readiness and the active backend address are read from the global App attribute tree via DtAttributeHandleType<> handles bound to vreBackendStatus and vreBackendStatus.SimAddress.
| connection | Non-owning pointer to the protocol-specific VR-Link connection. |
| vrfRemoteController | Non-owning pointer to the VRF remote controller; used to call createEntity(), deleteObject(), and sendSetDataMsg() |
| reflectedExtEntityList | Non-owning pointer to the reflected extended entity list; used to register entity-added/removed callbacks |
|
overridevirtual |
Performs periodic processing (currently a no-op)
| dt | The elapsed time in seconds since the last tick |
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
overridevirtual |
Shuts down the connector.
Removes VRE message handlers and entity-added/removed callbacks, and frees the desired-create message.
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
virtual |
Ownship message handlers.
Handles a request to create a new ownship entity of the specified type
| message | Pointer to a CreateNewOwnshipMessage |
Copies the desired entity specification to myDesiredCreateEntityMessage, then calls verifyNewOwnship() to initiate creation if the backend is ready.
|
virtual |
Handles a request to destroy the current new ownship entity.
| message | Pointer to a DestroyNewOwnshipMessage |
Sets the desired entity type to nullType, then calls verifyNewOwnship() to initiate deletion of the current entity if one exists.
|
static |
Static VR-Link callbacks.
Invoked by VRF when a locally requested entity has been created
| name | Display name assigned by VRF to the new entity |
| id | DIS entity identifier of the new entity |
| uuid | UUID assigned to the new entity |
| usr | Pointer to the owning DtOwnshipCreationConnector instance |
References makVre::DtConnector::name().
|
static |
Invoked by VR-Link when any entity is added to the reflected list.
| obj | Pointer to the added entity; filtered to owned entity only |
| usr | Pointer to the owning DtOwnshipCreationConnector instance |
|
static |
Invoked by VR-Link when any entity is removed from the reflected list.
| obj | Pointer to the removed entity; filtered to owned entity only |
| usr | Pointer to the owning DtOwnshipCreationConnector instance |
|
protectedvirtual |
Verifies whether the current entity matches the desired state and acts accordingly.
If the backend is not started/loaded, returns immediately. Otherwise compares myDesiredCreateEntityMessage entity type against myCreatedEntityInfo.myEntityType and issues a create or delete command as needed.
|
protectedvirtual |
Sends a createEntity request to the VRF backend.
Asserts that no create or delete is already in progress and that the backend exists. Calls myVrfRemoteController->createEntity() with the parameters from myDesiredCreateEntityMessage. Sets myWaitingForOwnshipCreate = true.
|
protectedvirtual |
Sends a deleteObject request to the VRF backend for the current ownship.
Asserts that no create or delete is already in progress and that an owned UUID exists. Calls myVrfRemoteController->deleteObject(). Sets myWaitingForOwnshipDelete = true.
|
protectedvirtual |
Called when VRF confirms the locally requested entity was created.
Sends NewOwnshipCreatedMessage to the frontend, applies a hold-fire ROE, records myCreatedEntityInfo, and calls verifyNewOwnship() to check the result. If the entity type is not yet known (not yet reflected), type resolution is deferred to handleOwnedEntityAdded().
| name | Display name of the created entity |
| entityId | DIS entity identifier |
| uuid | UUID of the created entity |
References makVre::DtConnector::name().
|
protectedvirtual |
Called when the owned entity appears in the reflected entity list.
If the entity type was unknown at creation time (deferred from handleLocalEntityCreated), fills in the type and clears myWaitingForOwnshipCreate, then calls verifyNewOwnship().
| entity | Pointer to the reflected extended entity that was added |
|
protectedvirtual |
Called when the owned entity is removed from the reflected entity list.
Handles expected removal (waiting for delete or backend reloading) by clearing myCreatedEntityInfo and calling verifyNewOwnship(). Also handles unexpected removal due to backend shutdown/unload.
| entity | Pointer to the reflected extended entity that was removed |
|
protected |
Infrastructure pointers (NON-OWNING — owned by DtConnectorAccessory)
Shared VRF remote controller (NON-OWNING)
Used to call createEntity(), deleteObject(), and sendSetDataMsg().
|
protected |
Reflected extended entity list (NON-OWNING)
Used to register entity-added/removed callbacks.
|
protected |
App attribute store handles for reading backend state.
Written by DtVreBackendConnector; read here without any direct connector pointer.
VRE backend simulation address
Published by DtVreBackendConnector as a DtAttributeHandleType<DtSimulationAddress>. Nullid when no backend is running.
| Attribute Store Key | vreBackendStatus.SimAddress |
|---|
|
protected |
Published backend status data.
| Attribute Store Key | vreBackendStatus |
|---|
|
protected |
Ownship state.
The entity creation parameters that the frontend has requested
Owned by this connector; initialized to an empty CreateNewOwnshipMessage in the constructor. A nullType entity type signals "no ownship desired".
|
protected |
Information about the entity that has been created (or is being tracked)
myEntityId is nullId() when no entity is created. myEntityType is nullType() if the entity exists but type is not yet known.
|
protected |
True while waiting for VRF to confirm deletion of an ownship entity.
|
protected |
True while waiting for VRF to confirm creation of an ownship entity.
|
protected |
True if the newly created ownship needs to be repositioned after creation.