|
VR-Engage
2.3
|
DtReflectedEntityConnector registers callbacks with DtReflectedExtEntityList and DtReflectedControlObjectList to receive notifications when entities and control objects are added or removed from the simulation. It translates these VR-Link events into VR-Engage messages (EntityDiscoveredMessage, EntityRemovedMessage, VrfDiscoverEventMessage, VrfRemoveEventMessage) and queues them for frontend consumption.
It also handles RequestEntitiesByTypeMessage, querying both the entity list and the control object list for matches and responding with RequestEntitiesByTypeResponseMessage.
A single-entry cache (myCachedReflectedEntityInfo) accelerates repeated lookups of UUID and entity type for the most recently accessed entity. The deprecated lookupUUID() and findEntityIdFromUUID() methods wrap DtUUID::objectIdentificationResolver() for backward compatibility; prefer calling the resolver directly in new code.
This connector is fully independent — it does not depend on any other connector and does not publish shared state to the app attribute store.
#include <reflectedEntityConnector.h>
Public Member Functions | |
| DtReflectedEntityConnector () | |
| virtual | ~DtReflectedEntityConnector () override |
| virtual void | install (makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController, DtReflectedExtEntityList *reflectedExtEntityList, DtReflectedControlObjectList *reflectedControlObjectList) |
| virtual void | tick (double dt) override |
| virtual void | shutdown () override |
| virtual DtVreMessageResult | handleRequestEntitiesByType (DtVreMessage *msg) |
| virtual DtReflectedExtEntityInfo * | lookupReflectedEntityInfo (const DtEntityIdentifier &entityId) |
| virtual DtUUID | lookupUUID (const DtEntityIdentifier &entityId) |
| virtual DtEntityIdentifier | findEntityIdFromUUID (const DtUUID &uuid) |
| virtual DtUUID | findUUID (DtReflectedExtEntity *reflectedEntity) |
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 | entityAddedCallback (DtReflectedExtEntity *obj, void *usr) |
| static void | entityRemovedCallback (DtReflectedExtEntity *obj, void *usr) |
| static void | controlObjectAddedCallback (DtReflectedControlObject *obj, void *usr) |
| static void | controlObjectRemovedCallback (DtReflectedControlObject *obj, void *usr) |
| static bool | envProcessDiscoveryConditionCallback (DtReflectedObject *envProcess, void *userData) |
Static Public Member Functions inherited from makVre::DtConnector | |
| static std::string | extension (DtConnectorType type) |
Protected Member Functions | |
| virtual void | handleActionMenuControlObjectDiscovered (DtReflectedControlObject *obj) |
| virtual void | handleActionMenuControlObjectRemoved (DtReflectedControlObject *obj) |
| virtual bool | processEnvProcessDiscoveryCriteria (DtReflectedEnvironmentProcess *envProcess) |
| virtual void | debugFillAllEntities () |
Protected Attributes | |
| makVrf::DtVrlinkVrfRemoteController * | myVrfRemoteController |
| DtReflectedExtEntityList * | myReflectedExtEntityList |
| DtReflectedControlObjectList * | myReflectedControlObjectList |
| DtReflectedExtEntityInfo * | myCachedReflectedEntityInfo |
| DtAttributeHandle | myLocalStatusAttr |
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 |
| using | SetAttrFunc = std::function<void(const DtReflectedExtEntity&, DtAttributeHandle&)> |
| using | ReadAppearanceFunc = std::function<void(const DtAppearance&, DtAttributeHandle&)> |
| DtAttributeHandleType< std::set< std::string > > | myEntityStateStore |
| std::map< std::string, SetAttrFunc > | mySetAttrMap |
| std::map< std::string, ReadAppearanceFunc > | myReadAppearanceMap |
| virtual void | updateReflectedEntityAttributes () |
| virtual void | updateAttributesForEntity (DtReflectedExtEntity *ree, DtAttributeHandle &entityAttr) |
| virtual void | installSetAttrFunctions () |
| using | ConvertExtDataFunc = std::function<void(const DtString&, DtAttributeHandle&)> |
| std::map< DtString, ConvertExtDataFunc > | myExtDataConversionMap |
| using | ReadStatePropFunc = std::function<void(const DtPropertyInterface&, DtAttributeHandle&)> |
| std::map< DtString, ReadStatePropFunc > | myRwToAttrMap |
| using | SetPartParamAttrFunc = std::function<void(const DtArticulatedPart&, DtAttributeHandle&)> |
| std::map< std::string, SetPartParamAttrFunc > | mySetPartParamAttrMap |
| using | ReadResourceParamFunc = std::function<void(const DtSimResource&, DtAttributeHandle&)> |
| std::map< std::string, ReadResourceParamFunc > | myReadResourceParamMap |
| boost::signals2::connection | myResourceResponseConnection |
| std::unordered_set< std::string > | myResourceMonitoringSet |
| virtual void | fillResourceAttribute (const DtSimResource &resource, DtAttributeHandle resourceAttr) const |
| virtual void | processResourceResponse (const makVrfEvents::DtEvent &evt) |
| using | ReadSensorParamFunc = std::function<void(const DtIfSensorData&, DtAttributeHandle&)> |
| std::map< std::string, ReadSensorParamFunc > | myReadSensorParamMap |
| std::map< std::string, std::unordered_set< std::string > > | mySensorMonitoringMap |
| virtual void | processSensorUpdate (const DtIfSensorData &sensorData) |
| static void | sensorUpdateCallback (DtSimMessage *msg, void *usr) |
Additional Inherited Members | |
Public Types inherited from makVre::DtConnector | |
| enum | DtConnectorType { DIS , HLA13 , HLA1516 , HLA1516E , HLA4 } |
|
protected |
Function pointer for setting a Reflected Entity Attribute from reflected ESR data.
|
protected |
Appearance readers.
|
protected |
Extended Data convenience conversions.
Function pointer for setting a type-converted Reflected Entity Attribute from an Extended Data string
|
protected |
State Property readers.
Function pointer for setting a Reflected Entity Attribute from a State Property Interface
|
protected |
Articulated part readers.
|
protected |
Resource readers.
|
protected |
Sensor readers.
| makVre::DtReflectedEntityConnector::DtReflectedEntityConnector | ( | ) |
Default constructor. Initializes all pointers to nullptr.
|
overridevirtual |
Virtual destructor. Frees myCachedReflectedEntityInfo.
|
virtual |
Installs the entity tracking connector with shared infrastructure.
Stores the infrastructure pointers, registers entity-added/removed callbacks on the reflected extended entity list, control-object-added/removed callbacks on the reflected control object list, and sets the environment process discovery condition. Also registers a handler for RequestEntitiesByTypeMessage.
| connection | Non-owning pointer to the protocol-specific VR-Link connection. |
| vrfRemoteController | Non-owning pointer to the VRF remote controller; retained for potential controller-level queries |
| reflectedExtEntityList | Non-owning pointer to the reflected extended entity list; used to register entity-added/removed callbacks and answer type queries |
| reflectedControlObjectList | Non-owning pointer to the reflected control object list; used to register control-object-added/removed callbacks, set the discovery condition, and answer type queries |
|
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 the RequestEntitiesByType message handler, removes entity-added/removed callbacks from the reflected entity list, and removes control-object-added/removed callbacks from the reflected control object list.
Reimplemented from makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector.
|
virtual |
Message handlers.
Handles a request to find entities matching a specific type pattern
| msg | Pointer to a RequestEntitiesByTypeMessage |
Iterates over the reflected entity list and the reflected control object list, collecting entities whose type matches the requested pattern. Queues a RequestEntitiesByTypeResponseMessage with all matches.
|
static |
Static VR-Link entity callbacks.
Invoked by VR-Link when an entity is added to the reflected list
| obj | Pointer to the added entity |
| usr | Pointer to the owning DtReflectedEntityConnector instance |
Constructs and queues an EntityDiscoveredMessage carrying the entity's id, type, force, marking text, and VRF object label.
|
static |
Invoked by VR-Link when an entity is removed from the reflected list.
| obj | Pointer to the removed entity |
| usr | Pointer to the owning DtReflectedEntityConnector instance |
Queues an EntityRemovedMessage and clears myCachedReflectedEntityInfo if it held data for the removed entity.
|
static |
Static VR-Link control object callbacks.
Invoked by VR-Link when a control object is added to the reflected list
| obj | Pointer to the added control object |
| usr | Pointer to the owning DtReflectedEntityConnector instance |
For scenario event objects (DtScenarioEventsType): extracts the scenario event caption and UUID and queues a VrfDiscoverEventMessage. For action menu objects (entity types 16.0.0.1, bullseye, 17.0.0.2): delegates to handleActionMenuControlObjectDiscovered().
|
static |
Invoked by VR-Link when a control object is removed from the reflected list.
| obj | Pointer to the removed control object |
| usr | Pointer to the owning DtReflectedEntityConnector instance |
For scenario event objects: queues a VrfRemoveEventMessage. For action menu objects: delegates to handleActionMenuControlObjectRemoved().
|
static |
Discovery condition callback for environment processes.
| envProcess | Pointer to the reflected object being evaluated as an environment process |
| userData | Pointer to the owning DtReflectedEntityConnector instance |
Delegates to processEnvProcessDiscoveryCriteria() on the connector instance.
|
virtual |
Entity caching and UUID lookup.
Looks up and caches reflected entity info for the given entity ID
| entityId | The entity identifier to look up |
Checks myCachedReflectedEntityInfo first. On a cache miss, looks the entity up in myReflectedExtEntityList, updates the cache, and returns the new entry.
|
virtual |
Returns the UUID for an entity using the single-entry cache.
| entityId | The entity identifier to resolve |
|
virtual |
Resolves a UUID to an entity identifier via the object identification resolver.
| uuid | The UUID to resolve |
|
virtual |
Extracts the UUID from a reflected entity via the object identification resolver.
| reflectedEntity | The reflected entity to get the UUID for |
|
protectedvirtual |
Constructs and queues an EntityDiscoveredMessage for an action menu control object.
| obj | Pointer to the action menu control object |
|
protectedvirtual |
Constructs and queues an EntityRemovedMessage for an action menu control object.
| obj | Pointer to the action menu control object |
|
protectedvirtual |
Evaluates whether an environment process meets the discovery criteria.
| envProcess | Pointer to the environment process to evaluate |
|
protectedvirtual |
Function pointer for setting a Reflected Entity Attribute from reflected ESR data.
|
protectedvirtual |
Function pointer for setting a Reflected Entity Attribute from reflected ESR data.
|
protectedvirtual |
Register SetAttrFunc functions in mySetAttrMap for reading Entity Attributes from reflected ESR data.
|
protectedvirtual |
Resource readers.
|
protectedvirtual |
Resource readers.
|
staticprotected |
Static callback wrapper for sensor update.
Calls user->handleSensorUpdate() with the sensor data extracted from the message.
| msg | The DtSimMessage containing the sensor update information. |
| usr | Pointer to the DtReflectedEntityConnector instance to call the member handler. |
|
protectedvirtual |
Member handler for sensor data from update callback.
| sensorData | The sensor data extracted from the message. |
|
protectedvirtual |
|
protected |
Non-owning pointer to the VRF remote controller.
|
protected |
Non-owning pointer to the reflected extended entity list.
|
protected |
Non-owning pointer to the reflected control object list.
|
protected |
Single-entry cache for the most recently accessed entity's reflected info.
|
protected |
|
protected |
Reflected Entity Attribute system.
Provides a mechanism for accessing (nearly) all reflected entity information using DtAttributes. This includes most ESR data members, as well as Resources and Sensor data.
Entity data is stored in DtAttribute::Root()["Entities"][entityId][propertyName]
Attribute store for reflected entity state
|
protected |
Map of individual Reflected Entity Attribute names with corresponding set functions to read ESR data.
Most getter methods in ESR are mirrored by an Attribute of the same name. e.g. DtReflectedEntity::damageState is found as DtAttribute::Root()["Entities"][entityId]["damageState"]
|
protected |
Function pointer for setting a Reflected Entity Attribute from reflected ESR data.
|
protected |
Map of State Property names with corresponding functions to read the property and set an Attribute.
|
protected |
Map of State Property names with corresponding functions to read the property and set an Attribute.
|
protected |
Articulated part readers.
|
protected |
Resource readers.
|
protected |
Connection for resource response events from the VR-Forces backend.
Connected during initialization and disconnected during shutdown.
|
protected |
Resource readers.
|
protected |
Sensor readers.
|
protected |
Sensor readers.