VR-Engage  2.3
Loading...
Searching...
No Matches
connectorAccessory.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6#pragma once
7
8//! \file connectorAccessory.h
9//! \brief Contains the DtConnectorAccessory class that manages VREngage connectivity
10//!
11//! This accessory establishes the connection between VREngage components and VR-Link,
12//! handling installation, connection events, coordinate systems, and event messaging.
15
16#ifndef DT_PROTOCOL_NAMESPACE
17 #error Namespace Protocol Macro DT_PROTOCOL_NAMESPACE not defined.
18#endif
19
20#include <vrvCore/DtBaseAccessory.h>
21
22#include <list>
23#include <memory>
24
25namespace makVrv
26{
27class DtVrlinkDriver;
28class DtVrlinkBaseConnection;
29class DtCoordinateSystem;
30
32{
33class DtVrlinkConnection;
34}
35} // namespace makVrv
36
37namespace makVrf
38{
39class DtVrlinkNetworkInterface;
40class DtVrlinkVrfRemoteController;
41} // namespace makVrf
42
43//! \brief Forward declaration of the reflected entity list class
44class DtReflectedEntityList;
45
46//! \brief Forward declaration of the VRF message interface class
47class DtVrfMessageInterface;
48
49//! \brief Forward declaration of the reflected control object list class
50class DtReflectedControlObjectList;
51
52//! \brief Forward declaration of the reflected extended entity list class
53class DtReflectedExtEntityList;
54
55namespace makVre
56{
57//! \brief Forward declaration of the player station application
58class DtPlayerStationApp;
59
60//! \brief Forward declaration of the network forwarder
61class DtExerciseConnNetworkForwarder;
62
63//! \brief Forward declaration of the message factory
64class DtVreMessageFactory;
65
66//! \brief Forward declaration of the communication manager
67class DtVreCommunicationManager;
68
70{
71//! \brief Forward declaration of the simulation event connector
73
74//! \brief Accessory that manages connections between VREngage and VR-Link
75//!
76//! DtConnectorAccessory establishes and manages the connection between VREngage
77//! components and the VR-Link simulation environment. It handles installation of
78//! various connector types, manages connection events, coordinates system changes,
79//! and processes simulation messages.
80//!
81//! This class is protocol-specific, with behavior defined by the DT_PROTOCOL_NAMESPACE macro
82//! which determines whether DIS, HLA 1.3, HLA 1516, or HLA 1516e is being used.
83class VRL_DLL DtConnectorAccessory : public makVrv::DtBaseAccessory
84{
85public:
86 //! \brief Constructor for the connector accessory.
87 //! \param de Reference to the distributed environment to use.
88 //!
89 //! Initializes all member pointers to nullptr, determines the network
90 //! protocol type (DIS, HLA13, HLA1516, HLA1516e, HLA4) from compile-time
91 //! macros, and stores the result in myType.
92 DtConnectorAccessory(makVrv::DtDe& de);
93
94 //! \brief Virtual destructor.
95 //!
96 //! Disconnects the connection-created, connected, and about-to-be-disconnected
97 //! signals if the driver and its connection are still valid.
98 virtual ~DtConnectorAccessory() override;
99
100 //! \brief Determines if this accessory is compatible with a given driver
101 //! \param driver Pointer to the driver to check compatibility with
102 //! \return True if compatible, false otherwise
103 //!
104 //! Checks if the driver is of the correct protocol-specific type for this accessory
105 virtual bool isCompatible(makVrv::DtDriver* driver) override;
106
107 //! \brief Installs this accessory into a compatible driver.
108 //! \param driver Pointer to the driver to install this accessory into.
109 //!
110 //! Casts the driver to a DtVrlinkDriver, locates the DtPlayerStationApp via
111 //! the DtPlayerStationDriver, registers all protocol-suffixed connector
112 //! creators in the connector factory, and connects to the driver's
113 //! signal_connectionCreated signal.
114 virtual void install(makVrv::DtDriver* driver) override;
115
116 //! \brief Uninstalls this accessory from a driver.
117 //! \param baseConn Pointer to the driver to uninstall from.
118 //!
119 //! Disconnects the connection-created signal and clears the driver pointer.
120 virtual void uninstall(makVrv::DtDriver* baseConn) override;
121
122 //! \brief Callback for when a simulation connection is created
123 //! \param connection Pointer to the newly created connection
124 //!
125 //! Registers reflected-list creators and connects the lifecycle signals.
126 //! Hooks signal_exerciseConnectionCreated to register the network dispatch
127 //! thread before reflected lists are created and register their SMS handlers.
128 virtual void slot_onSimCreated(makVrv::DtVrlinkBaseConnection* connection);
129
130 //! \brief Callback for when a simulation connection is established
131 //! \param connection Pointer to the connected connection
132 //!
133 //! Runs on the network thread after dispatch registration. Obtains the reflected
134 //! lists, initializes simulation infrastructure, installs connectors, and sends
135 //! the network-connected notification.
136 virtual void slot_onSimConnected(makVrv::DtVrlinkBaseConnection* connection);
137
138 //! \brief Callback for when a simulation is about to disconnect
139 //! \param connection Pointer to the connection about to disconnect
140 //!
141 //! Removes connectors and clears simulation resources. Queues the network-disconnected
142 //! notification before shutting down the network dispatch thread.
143 virtual void slot_onSimAboutToBeDisconnected(makVrv::DtVrlinkBaseConnection* connection);
144
145 //! \brief Callback for periodic thread ticks.
146 //!
147 //! Computes the simulation time delta, ticks the VRE message manager,
148 //! flushes the network forwarder, processes pending attribute callbacks,
149 //! and ticks all base and entity-specific connectors.
150 virtual void slot_onThreadTick();
151
152 //! \brief Sets the coordinate system for the simulation
153 //! \param vrvCS Reference to the coordinate system to use
154 //!
155 //! Creates and configures the appropriate coordinate converter based on the
156 //! provided coordinate system
157 virtual void setCoordinateSystem(const makVrv::DtCoordinateSystem& vrvCS);
158
159protected:
160 //! \brief Handles messages to install connectors
161 //! \param msg Pointer to the message containing installation parameters
162 //! \return Message result indicating how the message was handled
163 //!
164 //! Processes requests to install specific connectors for an entity
166
167 //! \brief Handles messages to remove connectors
168 //! \param msg Pointer to the message containing removal parameters
169 //! \return Message result indicating how the message was handled
170 //!
171 //! Processes requests to remove specific connectors for an entity
173
174 //! \brief Installs the base set of connectors for the simulation
175 //!
176 //! Creates and installs the standard set of connectors that all simulations need
177 virtual void installBaseConnectors();
178
179 //! \brief Uninstalls all base connectors
180 //!
181 //! Cleans up and removes all base connectors
183
184 //! \brief Clears all entity-specific connectors
185 //!
186 //! Removes all connectors associated with specific entities
187 virtual void clearEntityConnectors();
188
189 //! \brief Creates and initializes the VRF communication infrastructure
190 //!
191 //! Constructs and wires together the three core VRF objects required before
192 //! any connectors can be installed:
193 //! - DtVreCommunicationManager: owns the network message pipeline and
194 //! parameter database; registered against the active VR-Link connection.
195 //! - DtVrlinkNetworkInterface: drives the underlying exercise connection;
196 //! configured so VR-Vantage, not VR-Forces, controls drain/sim-time.
197 //! - DtVrlinkVrfRemoteController: provides the remote-control channel to
198 //! the VR-Forces backend; initialized with the reflected entity list and
199 //! the session ID retrieved from the app attribute store.
200 //!
201 //! \pre myVrlConnection must be valid (called from slot_onSimConnected).
202 //! \pre myReflectedEntityList must be populated before this call.
203 //! \note On HLA builds, disables parallel publishing to avoid a known
204 //! deadlock during rapid subrole changes (VRE-4119).
206
207 //! \brief Creates and configures the network forwarder
208 //!
209 //! Constructs DtExerciseConnNetworkForwarder, which bridges VREngage
210 //! message-manager events to the VR-Link exercise connection so that
211 //! messages can be sent to the VR-Forces backend.
212 //!
213 //! Also registers DtVreMessageManager handlers for InstallConnectorsMessage
214 //! and RemoveConnectorsMessage, and subscribes all event-forwarding patterns
215 //! required by the current feature set (inputs, entity queries, designator,
216 //! radio, missile, debug, etc.).
217 //!
218 //! \pre myCommunicationManager must be valid (call setupVrfInfrastructure first).
219 //! \pre myApp must be valid.
220 //! \note The forwardEvents registrations that do not begin with "net." are
221 //! legacy patterns pending a rename; see the TODO comments in the body.
223
224 //! \brief Creates and installs a base connector via the connector factory.
225 //!
226 //! Looks up the connector in the factory using
227 //! `connectorTypeName + "-" + networkProtocolPostfix()`, casts it to
228 //! TConnector, calls install() with (myVrlConnection, args...),
229 //! and adds it to myBaseConnectors.
230 //!
231 //! \tparam TConnector Concrete connector type (must derive from DtSimEventConnector).
232 //! \tparam TArgs Additional argument types forwarded to TConnector::install().
233 //! \param connectorTypeName Base name of the connector type (without protocol suffix).
234 //! \param args Additional arguments forwarded to the connector's install() method.
235 //! \return Non-owning pointer to the created connector, or nullptr if the
236 //! factory lookup or dynamic_cast failed. The connector is owned by
237 //! myBaseConnectors.
238 template <typename TConnector, typename... TArgs>
239 TConnector* createAndInstallConnector(const std::string& connectorTypeName, TArgs&&... args);
240
241protected:
242 //! \brief Reference to the distributed environment
243 makVrv::DtDe& myDe;
244
245 //! \brief Pointer to the player station application
247
248 //! \brief Type of connector being used
250
251 //! \brief List of base simulation event connectors
252 //!
253 //! These connectors handle core simulation functionality and are not entity-specific
254 std::list<std::unique_ptr<makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector>> myBaseConnectors;
255
256 //! \brief Map of entity-specific connectors grouped by entity ID and connector name
257 //!
258 //! First key is entity ID, second key is connector name, value is the connector instance
259 std::map<std::string, std::map<std::string, std::unique_ptr<makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector>>>
261
262 //! \brief Pointer to the VR-Link driver
263 makVrv::DtVrlinkDriver* myDriver;
264
265 //! \brief Pointer to the protocol-specific VR-Link connection
266 makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* myVrlConnection;
267
268 //! \brief Pointer to the network forwarder for transferring messages
269 std::unique_ptr<DtExerciseConnNetworkForwarder> myNetworkForwarder;
270
271 //! \brief Pointer to the communication manager that handles messages
273
274 //! \brief Pointer to the VR-Link network interface
275 makVrf::DtVrlinkNetworkInterface* myVrlinkNetworkInterface;
276
277 //! \brief Core VRF Infrastructure (created in installBaseConnectors, destroyed in uninstallBaseConnectors)
278 //! @{
279
280 //! \brief VRF remote controller (OWNED - unique_ptr)
281 std::unique_ptr<makVrf::DtVrlinkVrfRemoteController> myVrfRemoteController;
282
283 //! \brief Reflected entity list (NON-OWNING - owned by myVrfRemoteController)
284 DtReflectedEntityList* myReflectedEntityList;
285
286 //! \brief Reflected control object list (NON-OWNING - owned by myVrfRemoteController)
287 DtReflectedControlObjectList* myReflectedControlObjectList;
288
289 //! \brief Reflected extended entity list (NON-OWNING - owned by myVrfRemoteController)
290 DtReflectedExtEntityList* myReflectedExtEntityList;
291
292 //! @}
293
294 //! \brief Boost signal connections
295 //! @{
296
297 //! \brief Connection for signal_connectionCreated on the VR-Link driver (bound in install)
298 boost::signals2::connection myConnectionCreatedConn;
299
300 //! \brief Connection for signal_connected on the VR-Link connection (bound in slot_onSimCreated)
301 boost::signals2::connection mySimConnectedConn;
302
303 //! \brief Connection for signal_toBeDisconnected on the VR-Link connection (bound in slot_onSimCreated)
304 boost::signals2::connection mySimAboutToBeDisconnectedConn;
305
306 //! \brief Connection for signal_preConnectionTick on the VR-Link connection (bound in slot_onSimConnected)
307 boost::signals2::connection myPreConnectionTickConn;
308
309 //! \brief Connection for signal_coordinateSystemChanged on the VR-Link connection (bound in slot_onSimConnected)
310 boost::signals2::connection myCoordinateSystemChangedConn;
311
312 //! @}
313};
314} // namespace DT_PROTOCOL_NAMESPACE
315} // namespace makVre
DtReflectedExtEntityList * myReflectedExtEntityList
Reflected extended entity list (NON-OWNING - owned by myVrfRemoteController)
Definition connectorAccessory.h:290
boost::signals2::connection myConnectionCreatedConn
Boost signal connections.
Definition connectorAccessory.h:298
virtual void slot_onThreadTick()
Callback for periodic thread ticks.
DtVreCommunicationManager * myCommunicationManager
Pointer to the communication manager that handles messages.
Definition connectorAccessory.h:272
virtual void clearEntityConnectors()
Clears all entity-specific connectors.
DtReflectedControlObjectList * myReflectedControlObjectList
Reflected control object list (NON-OWNING - owned by myVrfRemoteController)
Definition connectorAccessory.h:287
virtual void slot_onSimConnected(makVrv::DtVrlinkBaseConnection *connection)
Callback for when a simulation connection is established.
makVrf::DtVrlinkNetworkInterface * myVrlinkNetworkInterface
Pointer to the VR-Link network interface.
Definition connectorAccessory.h:275
virtual makVre::DtVreMessageResult handleRemoveConnectors(makVre::DtVreMessage *msg)
Handles messages to remove connectors.
virtual makVre::DtVreMessageResult handleInstallConnectors(makVre::DtVreMessage *msg)
Handles messages to install connectors.
virtual void setCoordinateSystem(const makVrv::DtCoordinateSystem &vrvCS)
Sets the coordinate system for the simulation.
std::unique_ptr< DtExerciseConnNetworkForwarder > myNetworkForwarder
Pointer to the network forwarder for transferring messages.
Definition connectorAccessory.h:269
virtual void slot_onSimCreated(makVrv::DtVrlinkBaseConnection *connection)
Callback for when a simulation connection is created.
virtual void installBaseConnectors()
Installs the base set of connectors for the simulation.
boost::signals2::connection mySimAboutToBeDisconnectedConn
Connection for signal_toBeDisconnected on the VR-Link connection (bound in slot_onSimCreated)
Definition connectorAccessory.h:304
makVrv::DtVrlinkDriver * myDriver
Pointer to the VR-Link driver.
Definition connectorAccessory.h:263
DtReflectedEntityList * myReflectedEntityList
Reflected entity list (NON-OWNING - owned by myVrfRemoteController)
Definition connectorAccessory.h:284
std::map< std::string, std::map< std::string, std::unique_ptr< makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector > > > myEntityConnectors
Map of entity-specific connectors grouped by entity ID and connector name.
Definition connectorAccessory.h:260
virtual bool isCompatible(makVrv::DtDriver *driver) override
Determines if this accessory is compatible with a given driver.
boost::signals2::connection myCoordinateSystemChangedConn
Connection for signal_coordinateSystemChanged on the VR-Link connection (bound in slot_onSimConnected...
Definition connectorAccessory.h:310
makVre::DtPlayerStationApp * myApp
Pointer to the player station application.
Definition connectorAccessory.h:246
virtual void configureNetworkForwarder()
Creates and configures the network forwarder.
virtual void install(makVrv::DtDriver *driver) override
Installs this accessory into a compatible driver.
makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection * myVrlConnection
Pointer to the protocol-specific VR-Link connection.
Definition connectorAccessory.h:266
TConnector * createAndInstallConnector(const std::string &connectorTypeName, TArgs &&... args)
Creates and installs a base connector via the connector factory.
makVrv::DtDe & myDe
Reference to the distributed environment.
Definition connectorAccessory.h:243
makVre::DtConnector::DtConnectorType myType
Type of connector being used.
Definition connectorAccessory.h:249
std::unique_ptr< makVrf::DtVrlinkVrfRemoteController > myVrfRemoteController
Core VRF Infrastructure (created in installBaseConnectors, destroyed in uninstallBaseConnectors)
Definition connectorAccessory.h:281
boost::signals2::connection mySimConnectedConn
Connection for signal_connected on the VR-Link connection (bound in slot_onSimCreated)
Definition connectorAccessory.h:301
virtual void slot_onSimAboutToBeDisconnected(makVrv::DtVrlinkBaseConnection *connection)
Callback for when a simulation is about to disconnect.
virtual void uninstallBaseConnectors()
Uninstalls all base connectors.
virtual void uninstall(makVrv::DtDriver *baseConn) override
Uninstalls this accessory from a driver.
std::list< std::unique_ptr< makVre::DT_PROTOCOL_NAMESPACE::DtSimEventConnector > > myBaseConnectors
List of base simulation event connectors.
Definition connectorAccessory.h:254
virtual ~DtConnectorAccessory() override
Virtual destructor.
virtual void setupVrfInfrastructure()
Creates and initializes the VRF communication infrastructure.
DtConnectorAccessory(makVrv::DtDe &de)
Constructor for the connector accessory.
boost::signals2::connection myPreConnectionTickConn
Connection for signal_preConnectionTick on the VR-Link connection (bound in slot_onSimConnected)
Definition connectorAccessory.h:307
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:53
DtConnectorType
Enumeration of supported connector types.
Definition connector.h:40
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:155
This class manages communication between player stations and VR-Link connections.
Definition vreCommunicationManager.h:38
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
Definition connectorAccessory.h:70
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition connectorAccessory.h:38
Definition connectorAccessory.h:32
Definition appLauncherComponent.h:28
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.
Defines the base DtSimEventConnector class for VREngage simulation events.