VR-Engage  2.3
Loading...
Searching...
No Matches
glsVreMessageUtil.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file glsVreMessageUtil.h
7//! \brief Utility functions for sending VR-Engage messages from GL Studio components
8//!
9//! This file provides helper functions for sending common VR-Engage messages
10//! from GL Studio instrument panel code. It simplifies message creation and
11//! queuing for joystick inputs, SAR requests, radar controls, and other
12//! cockpit-related functionality.
13
14#pragma once
15
16// VR-Engage includes
42#include <vreUtil/logger.h>
43
44// VR-Link includes
45#include <vlpi/entityIdentifier.h>
46
47#include <string>
48
49namespace makVre
50{
51 //! Send a joystick message to the ownship entity.
52 static inline void sendJoystickMessage(const DtEntityIdentifier& entity,
53 const std::string& functionGroup, const std::string& function,
54 double value, bool repeat = false)
55 {
57
58 msg->setEntityId(entity);
59 msg->setFunctionGroup(functionGroup);
60 msg->setFunction(function);
61 msg->setValue(value);
62 msg->setRepeat(repeat);
63
65 }
66
67 //! Sends a SAR request using current SAR manager settings.
72
73 //! Start a raise security gate task on the specified gate entity.
74 static inline void raiseGate(const DtEntityIdentifier& entity)
75 {
77
78 msg->setEntityId(entity);
79 msg->setScriptName("Raise_Security_Gate");
80
82 }
83
84 //! Start a lower security gate task on the specified gate entity.
85 static inline void lowerGate(const DtEntityIdentifier& entity)
86 {
88
89 msg->setEntityId(entity);
90 msg->setScriptName("Lower_Security_Gate");
91
93 }
94
95 //! Set state for a light on an entity.
96 static inline void setLightState(const DtEntityIdentifier& entity, int light, bool state)
97 {
99
100 msg->setEntityId(entity);
101 std::vector<int> lights;
102 lights.push_back(light);
103 msg->setLights(lights);
104 msg->setState(state);
105
107 }
108
109 //! Requests a SimulationStateMessage for the specified entity.
110 static inline void requestSimState(const DtEntityIdentifier& entity)
111 {
113
114 msg->setEntityId(entity);
115
117 }
118
119 //! Creates a gimbal view window. Once created, a RenderTextureInitializedMessage is sent when this operation is complete.
120 static inline void createGimbalView(const DtEntityIdentifier& entity, int width, int height, const std::string& sensorMode)
121 {
123
126 msg->setOwnshipEntityId(entity);
127 msg->setWindowPosition(DtVector(10000, 10000, 0));
128 msg->setWindowSize(DtVector(width, height, 0.0));
129 msg->setIsFullScreen(false);
130 msg->setSensorMode(sensorMode);
131 msg->setScreen(0);
132
134 }
135
136 //! Destroy a gimbal view window.
147
148 static inline void modifyGimbalView(const DtEntityIdentifier& entity, const std::string& sensorMode)
149 {
151
154 msg->setOwnshipEntityId(entity);
155 msg->setSensorMode(sensorMode);
156
158 }
159
160 static inline void cycleGimbalView(const DtEntityIdentifier& entity)
161 {
163
164 msg->setHostId(entity);
165
167 }
168
169 //! Creates a plan view window. Once created, a RenderTextureInitializedMessage is sent when this operation is complete.
170 static inline void createPlanView(const DtEntityIdentifier& entity, int width, int height)
171 {
173
176 msg->setOwnshipEntityId(entity);
177 msg->setWindowPosition(DtVector(10000, 10000, 0));
178 msg->setWindowSize(DtVector(width, height, 0.0));
179 msg->setIsFullScreen(false);
180 msg->setScreen(0);
181
183 }
184
185 //! Destroy a plan view window.
196
197 //! \brief Takes joystick control of an entity for specific function groups.
198 //! \param entity The entity to control.
199 //! \param functionGroups The function groups to acquire.
200 static inline void takeControlOf(const DtEntityIdentifier& entity,
201 const std::vector<std::string>& functionGroups)
202 {
204
205 msg->setEntityId(entity);
206 msg->setFunctionGroups(functionGroups);
207
209 }
210
211 //! \brief Releases all joystick control for an entity.
212 //! \param entity The entity to release.
213 static inline void releaseControlOf(const DtEntityIdentifier& entity)
214 {
216
217 msg->setEntityId(entity);
218
220 }
221
222 //! \brief Sets VR-Engage role control for an entity.
223 //! \param entity The entity whose roles are being changed.
224 //! \param stationId The controlling VR-Engage station.
225 //! \param roles The role types to add or remove.
226 //! \param controlled True to add the roles; false to remove them.
227 //! \param ignoreErrors True to release roles that are not currently tracked.
228 static inline void setVreControlled(const DtEntityIdentifier& entity,
229 const std::string& stationId,
230 const std::vector<std::string>& roles,
231 bool controlled,
232 bool ignoreErrors = false)
233 {
235 msg->setEntityId(entity);
236 msg->setStationId(stationId);
237 msg->setRoleTypes(roles);
238 msg->setControlled(controlled);
239 msg->setIgnoreErrors(ignoreErrors);
240
242 }
243
244 //! \brief Takes joystick and VR-Engage role control of an entity.
245 //! \param entity The entity to control.
246 //! \param functionGroups The function groups to acquire.
247 //! \param roles The role types to add.
248 static inline void takeControlOf(const DtEntityIdentifier& entity,
249 const std::vector<std::string>& functionGroups,
250 const std::vector<std::string>& roles)
251 {
252 takeControlOf(entity, functionGroups);
253 setVreControlled(entity, std::string(), roles, true);
254 }
255
256 //! Sends a message confirming the cockpit has been initialized.
257 static inline void sendCockpitInitialized(const std::string& cockpitName)
258 {
260
261 msg->setName(cockpitName);
262
264 }
265
266 static inline void setOverlaySections(const std::vector<std::string>& sections)
267 {
269
270 msg->setOverlaySections(sections);
271
273 }
274
279
280 static inline void startMapZoomIn(const DtEntityIdentifier& entity)
281 {
283
284 msg->setHostId(entity);
285
287 }
288
289 static inline void startMapZoomOut(const DtEntityIdentifier& entity)
290 {
292
293 msg->setHostId(entity);
294
296 }
297
298 static inline void stopMapZoomIn(const DtEntityIdentifier& entity)
299 {
301
302 msg->setHostId(entity);
303
305 }
306
307 static inline void stopMapZoomOut(const DtEntityIdentifier& entity)
308 {
310
311 msg->setHostId(entity);
312
314 }
315
316 //! Requests any configuration specific to this panel (see the "instrumentPanels" block in pilot.lua for
317 //! the configuration).
318 static inline void requestGlsConfig(const DtEntityIdentifier& entity, const std::string& panelId)
319 {
321
322 msg->setHostId(entity);
323 msg->setPanelId(panelId);
324
326 }
327
328 static inline void sendSetRwrEnabledMessage(const DtEntityIdentifier& entity, bool enabled)
329 {
331
332 msg->setHostId(entity);
333 msg->setEnabled(enabled);
334
336 }
337
338 static inline void setRwrSoundsEnabled(bool enabled)
339 {
341
342 msg->setSoundsEnabled(enabled);
343
345 }
346
347 static inline void playRwrSound(const std::string& sound)
348 {
350
351 msg->setPlayRwrSound(sound);
352
354 }
355
356 static inline void setRadarModeAndSubmode(const DtEntityIdentifier& hostId,
357 const std::string& mode, const std::string& submode, int sttTarget = -1)
358 {
360
361 msg->setHostId(hostId);
362 msg->setMode(mode);
363 msg->setSubMode(submode);
364 msg->setSttTarget(sttTarget);
365
367 }
368
369 static inline void subscribeToBoss(const std::string& messageType)
370 {
372
373 msg->setMessageName(messageType);
374
376 }
377
378 static inline void unsubscribeFromBoss(const std::string& messageType)
379 {
381
382 msg->setMessageName(messageType);
383
385 }
386}
Sent after cockpit initialization, so the user can perform any post-initialization steps.
Definition cockpitInitialized.h:33
static CockpitInitializedMessage * create()
Create a copy of the given message.
virtual void setName(const std::string &val)
virtual void queueMessage(DtVreMessage *msg, double delay=0.0)=0
Queues a message for later dispatch.
static DtVreMessageManager & instance()
Gets the singleton instance of the message manager.
static GenerateSarRequestMessage * create()
Create a copy of the given message.
Sent to cycle a gimbaled sensor to the next sensor mode.
Definition gimbalCycleSensorMode.h:33
virtual void setHostId(const DtEntityIdentifier &val)
static GimbalCycleSensorModeMessage * create()
Create a copy of the given message.
Sent from a GLStudio cockpit to request any role-level configuration.
Definition glsConfigRequest.h:34
static GlsConfigRequestMessage * create()
Create a copy of the given message.
virtual void setHostId(const DtEntityIdentifier &val)
virtual void setPanelId(const std::string &val)
Send from any VR-Engage thread to cause the DtVrfRemoteControlConnector to generate a VR-Forces joyst...
Definition joystick.h:34
virtual void setRepeat(bool val)
virtual void setFunction(const std::string &val)
virtual void setValue(double val)
virtual void setFunctionGroup(const std::string &val)
static JoystickMessage * create()
Create a copy of the given message.
virtual void setEntityId(const DtEntityIdentifier &val)
Sent to start the minimap zooming in.
Definition minimapStartZoomIn.h:33
virtual void setHostId(const DtEntityIdentifier &val)
static MinimapStartZoomInMessage * create()
Create a copy of the given message.
Sent to start the minimap zooming out.
Definition minimapStartZoomOut.h:33
static MinimapStartZoomOutMessage * create()
Create a copy of the given message.
virtual void setHostId(const DtEntityIdentifier &val)
Sent to stop the minimap zooming in.
Definition minimapStopZoomIn.h:33
virtual void setHostId(const DtEntityIdentifier &val)
static MinimapStopZoomInMessage * create()
Create a copy of the given message.
Sent to stop the minimap zooming out.
Definition minimapStopZoomOut.h:33
virtual void setHostId(const DtEntityIdentifier &val)
static MinimapStopZoomOutMessage * create()
Create a copy of the given message.
Send to request a SimulationStateMessage for the specified entity.
Definition RequestSimulationState.h:34
static RequestSimulationStateMessage * create()
Create a copy of the given message.
virtual void setEntityId(const DtEntityIdentifier &val)
static RestoreGimbalOverlaySectionsMessage * create()
Create a copy of the given message.
Sent to send a Radar Warning Receiver sound.
Definition rwrPlaySound.h:33
static RwrPlaySoundMessage * create()
Create a copy of the given message.
virtual void setPlayRwrSound(const std::string &val)
Sent to enable or disable the Radar Warning Receiver sim component.
Definition RwrSetEnabled.h:33
virtual void setHostId(const DtEntityIdentifier &val)
virtual void setEnabled(bool val)
static RwrSetEnabledMessage * create()
Create a copy of the given message.
Sent to enable or disable the GUI's Radar Warning Receiver sounds.
Definition RwrSetSoundsEnabled.h:32
static RwrSetSoundsEnabledMessage * create()
Create a copy of the given message.
virtual void setSoundsEnabled(bool val)
Sent to change which parts of the gimbaled sensor overlay are displayed.
Definition setGimbalOverlaySections.h:33
static SetGimbalOverlaySectionsMessage * create()
Create a copy of the given message.
virtual void setOverlaySections(const std::vector< std::string > &val)
Sets the mode and submode of the specified radar.
Definition SetRadarModeAndSubmode.h:34
virtual void setHostId(const DtEntityIdentifier &val)
virtual void setMode(const std::string &val)
virtual void setSubMode(const std::string &val)
static SetRadarModeAndSubmodeMessage * create()
Create a copy of the given message.
virtual void setSttTarget(int val)
Send from a minion to request the boss role forwards the specified message type.
Definition subscribeToBoss.h:33
virtual void setMessageName(const std::string &val)
static SubscribeToBossMessage * create()
Create a copy of the given message.
Send from a minion to request the boss role stops forwarding the specified message type.
Definition unsubscribeFromBoss.h:33
static UnsubscribeFromBossMessage * create()
Create a copy of the given message.
virtual void setMessageName(const std::string &val)
Send to release joystick control for given function groups on a specified entity.
Definition vrfReleaseControlOf.h:34
virtual void setEntityId(const DtEntityIdentifier &val)
static VrfReleaseControlOfMessage * create()
Create a copy of the given message.
Message for executing a script on an entity with arbitrary attributes.
Definition vrfTaskEntityScript.h:41
virtual void setEntityId(const DtEntityIdentifier &val)
Sets the entity identifier for this message.
virtual void setScriptName(const std::string &script)
Sets the script name for this message.
static VrfScriptedEntityTaskMessage * create()
Creates a new instance of this message type.
Send to the DtVrfRemoteControlConnector to generate a VRF set light state request.
Definition vrfSetLightState.h:34
virtual void setState(bool val)
static VrfSetLightStateMessage * create()
Create a copy of the given message.
virtual void setLights(const std::vector< int > &val)
virtual void setEntityId(const DtEntityIdentifier &val)
Set VR-Engage role control state for an entity.
Definition vrfSetVreControlled.h:35
static VrfSetVreControlledMessage * create()
Create a copy of the given message.
virtual void setRoleTypes(const std::vector< std::string > &val)
virtual void setStationId(const std::string &val)
virtual void setEntityId(const DtEntityIdentifier &val)
virtual void setIgnoreErrors(bool val)
virtual void setControlled(bool val)
Send to take control of an entity for specified function groups.
Definition vrfTakeControlOf.h:34
virtual void setFunctionGroups(const std::vector< std::string > &val)
static VrfTakeControlOfMessage * create()
Create a copy of the given message.
virtual void setEntityId(const DtEntityIdentifier &val)
Used to create, modify or destroy a window or channel.
Definition windowOperation.h:36
virtual void setOwnshipEntityId(const DtEntityIdentifier &val)
virtual void setIsFullScreen(bool val)
static WindowOperationMessage * create()
Create a copy of the given message.
@ WindowType_Gimbal
Definition windowOperation.h:48
@ WindowType_PVD
Definition windowOperation.h:49
virtual void setWindowSize(const DtVector &val)
virtual void setOperation(OperationType val)
virtual void setSensorMode(const std::string &val)
virtual void setScreen(int val)
virtual void setWindowType(WindowType val)
@ OperationType_Modify
Definition windowOperation.h:42
@ OperationType_Create
Definition windowOperation.h:41
@ OperationType_Destroy
Definition windowOperation.h:43
virtual void setWindowPosition(const DtVector &val)
Provides logging functionality with various severity levels and channels.
!
Definition glsVreMessageUtil.h:50
static void startMapZoomOut(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:289
static void subscribeToBoss(const std::string &messageType)
Definition glsVreMessageUtil.h:369
static void requestGlsConfig(const DtEntityIdentifier &entity, const std::string &panelId)
Requests any configuration specific to this panel (see the "instrumentPanels" block in pilot....
Definition glsVreMessageUtil.h:318
static void lowerGate(const DtEntityIdentifier &entity)
Start a lower security gate task on the specified gate entity.
Definition glsVreMessageUtil.h:85
static void startMapZoomIn(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:280
static void playRwrSound(const std::string &sound)
Definition glsVreMessageUtil.h:347
static void stopMapZoomOut(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:307
static void setRadarModeAndSubmode(const DtEntityIdentifier &hostId, const std::string &mode, const std::string &submode, int sttTarget=-1)
Definition glsVreMessageUtil.h:356
static void createPlanView(const DtEntityIdentifier &entity, int width, int height)
Creates a plan view window. Once created, a RenderTextureInitializedMessage is sent when this operati...
Definition glsVreMessageUtil.h:170
static void modifyGimbalView(const DtEntityIdentifier &entity, const std::string &sensorMode)
Definition glsVreMessageUtil.h:148
static void destroyPlanView(const DtEntityIdentifier &entity)
Destroy a plan view window.
Definition glsVreMessageUtil.h:186
static void stopMapZoomIn(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:298
static void raiseGate(const DtEntityIdentifier &entity)
Start a raise security gate task on the specified gate entity.
Definition glsVreMessageUtil.h:74
static void setOverlaySections(const std::vector< std::string > &sections)
Definition glsVreMessageUtil.h:266
static void sendSarRequest()
Sends a SAR request using current SAR manager settings.
Definition glsVreMessageUtil.h:68
static void sendCockpitInitialized(const std::string &cockpitName)
Sends a message confirming the cockpit has been initialized.
Definition glsVreMessageUtil.h:257
static void sendSetRwrEnabledMessage(const DtEntityIdentifier &entity, bool enabled)
Definition glsVreMessageUtil.h:328
static void releaseControlOf(const DtEntityIdentifier &entity)
Releases all joystick control for an entity.
Definition glsVreMessageUtil.h:213
static void sendJoystickMessage(const DtEntityIdentifier &entity, const std::string &functionGroup, const std::string &function, double value, bool repeat=false)
Send a joystick message to the ownship entity.
Definition glsVreMessageUtil.h:52
static void setVreControlled(const DtEntityIdentifier &entity, const std::string &stationId, const std::vector< std::string > &roles, bool controlled, bool ignoreErrors=false)
Sets VR-Engage role control for an entity.
Definition glsVreMessageUtil.h:228
static void cycleGimbalView(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:160
static void createGimbalView(const DtEntityIdentifier &entity, int width, int height, const std::string &sensorMode)
Creates a gimbal view window. Once created, a RenderTextureInitializedMessage is sent when this opera...
Definition glsVreMessageUtil.h:120
static void destroyGimbalView(const DtEntityIdentifier &entity)
Destroy a gimbal view window.
Definition glsVreMessageUtil.h:137
static void unsubscribeFromBoss(const std::string &messageType)
Definition glsVreMessageUtil.h:378
static void restoreOverlaySections()
Definition glsVreMessageUtil.h:275
static void setLightState(const DtEntityIdentifier &entity, int light, bool state)
Set state for a light on an entity.
Definition glsVreMessageUtil.h:96
static void requestSimState(const DtEntityIdentifier &entity)
Requests a SimulationStateMessage for the specified entity.
Definition glsVreMessageUtil.h:110
static void setRwrSoundsEnabled(bool enabled)
Definition glsVreMessageUtil.h:338
static void takeControlOf(const DtEntityIdentifier &entity, const std::vector< std::string > &functionGroups)
Takes joystick control of an entity for specific function groups.
Definition glsVreMessageUtil.h:200
Defines the central message manager for the VREngage messaging system.
Defines message classes for entity script task operations.