VR-Engage  2.2
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
41#include <vreUtil/logger.h>
42
43// VR-Link includes
44#include <vlpi/entityIdentifier.h>
45
46#include <string>
47
48namespace makVre
49{
50 //! Send a joystick message to the ownship entity.
51 static inline void sendJoystickMessage(const DtEntityIdentifier& entity,
52 const std::string& functionGroup, const std::string& function,
53 double value, bool repeat = false)
54 {
56
57 msg->setEntityId(entity);
58 msg->setFunctionGroup(functionGroup);
59 msg->setFunction(function);
60 msg->setValue(value);
61 msg->setRepeat(repeat);
62
64 }
65
66 //! Sends a SAR request using current SAR manager settings.
71
72 //! Start a raise security gate task on the specified gate entity.
73 static inline void raiseGate(const DtEntityIdentifier& entity)
74 {
76
77 msg->setEntityId(entity);
78 msg->setScriptName("Raise_Security_Gate");
79
81 }
82
83 //! Start a lower security gate task on the specified gate entity.
84 static inline void lowerGate(const DtEntityIdentifier& entity)
85 {
87
88 msg->setEntityId(entity);
89 msg->setScriptName("Lower_Security_Gate");
90
92 }
93
94 //! Set state for a light on an entity.
95 static inline void setLightState(const DtEntityIdentifier& entity, int light, bool state)
96 {
98
99 msg->setEntityId(entity);
100 std::vector<int> lights;
101 lights.push_back(light);
102 msg->setLights(lights);
103 msg->setState(state);
104
106 }
107
108 //! Requests a SimulationStateMessage for the specified entity.
109 static inline void requestSimState(const DtEntityIdentifier& entity)
110 {
112
113 msg->setEntityId(entity);
114
116 }
117
118 //! Creates a gimbal view window. Once created, a RenderTextureInitializedMessage is sent when this operation is complete.
119 static inline void createGimbalView(const DtEntityIdentifier& entity, int width, int height, const std::string& sensorMode)
120 {
122
125 msg->setOwnshipEntityId(entity);
126 msg->setWindowPosition(DtVector(10000, 10000, 0));
127 msg->setWindowSize(DtVector(width, height, 0.0));
128 msg->setIsFullScreen(false);
129 msg->setSensorMode(sensorMode);
130 msg->setScreen(0);
131
133 }
134
135 //! Destroy a gimbal view window.
146
147 static inline void modifyGimbalView(const DtEntityIdentifier& entity, const std::string& sensorMode)
148 {
150
153 msg->setOwnshipEntityId(entity);
154 msg->setSensorMode(sensorMode);
155
157 }
158
159 static inline void cycleGimbalView(const DtEntityIdentifier& entity)
160 {
162
163 msg->setHostId(entity);
164
166 }
167
168 //! Creates a plan view window. Once created, a RenderTextureInitializedMessage is sent when this operation is complete.
169 static inline void createPlanView(const DtEntityIdentifier& entity, int width, int height)
170 {
172
175 msg->setOwnshipEntityId(entity);
176 msg->setWindowPosition(DtVector(10000, 10000, 0));
177 msg->setWindowSize(DtVector(width, height, 0.0));
178 msg->setIsFullScreen(false);
179 msg->setScreen(0);
180
182 }
183
184 //! Destroy a plan view window.
195
196 //! Take joystick control of an entity, for specific function groups and roles.
197 static inline void takeControlOf(const DtEntityIdentifier& entity,
198 const std::vector<std::string>& functionGroups,
199 const std::vector<std::string>& roles)
200 {
202
203 msg->setEntityId(entity);
204 msg->setFunctionGroups(functionGroups);
205 msg->setRoles(roles);
206
208 }
209
210 //! Release all joystick control for an entity.
211 static inline void releaseControlOf(const DtEntityIdentifier& entity)
212 {
214
215 msg->setEntityId(entity);
216
218 }
219
220 //! Sends a message confirming the cockpit has been initialized.
221 static inline void sendCockpitInitialized(const std::string& cockpitName)
222 {
224
225 msg->setName(cockpitName);
226
228 }
229
230 static inline void setOverlaySections(const std::vector<std::string>& sections)
231 {
233
234 msg->setOverlaySections(sections);
235
237 }
238
243
244 static inline void startMapZoomIn(const DtEntityIdentifier& entity)
245 {
247
248 msg->setHostId(entity);
249
251 }
252
253 static inline void startMapZoomOut(const DtEntityIdentifier& entity)
254 {
256
257 msg->setHostId(entity);
258
260 }
261
262 static inline void stopMapZoomIn(const DtEntityIdentifier& entity)
263 {
265
266 msg->setHostId(entity);
267
269 }
270
271 static inline void stopMapZoomOut(const DtEntityIdentifier& entity)
272 {
274
275 msg->setHostId(entity);
276
278 }
279
280 //! Requests any configuration specific to this panel (see the "instrumentPanels" block in pilot.lua for
281 //! the configuration).
282 static inline void requestGlsConfig(const DtEntityIdentifier& entity, const std::string& panelId)
283 {
285
286 msg->setHostId(entity);
287 msg->setPanelId(panelId);
288
290 }
291
292 static inline void sendSetRwrEnabledMessage(const DtEntityIdentifier& entity, bool enabled)
293 {
295
296 msg->setHostId(entity);
297 msg->setEnabled(enabled);
298
300 }
301
302 static inline void setRwrSoundsEnabled(bool enabled)
303 {
305
306 msg->setSoundsEnabled(enabled);
307
309 }
310
311 static inline void playRwrSound(const std::string& sound)
312 {
314
315 msg->setPlayRwrSound(sound);
316
318 }
319
320 static inline void setRadarModeAndSubmode(const DtEntityIdentifier& hostId,
321 const std::string& mode, const std::string& submode, int sttTarget = -1)
322 {
324
325 msg->setHostId(hostId);
326 msg->setMode(mode);
327 msg->setSubMode(submode);
328 msg->setSttTarget(sttTarget);
329
331 }
332
333 static inline void subscribeToBoss(const std::string& messageType)
334 {
336
337 msg->setMessageName(messageType);
338
340 }
341
342 static inline void unsubscribeFromBoss(const std::string& messageType)
343 {
345
346 msg->setMessageName(messageType);
347
349 }
350}
Definition cockpitInitialized.h:29
static CockpitInitializedMessage * create()
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()
Definition gimbalCycleSensorMode.h:29
virtual void setHostId(const DtEntityIdentifier &val)
static GimbalCycleSensorModeMessage * create()
Definition glsConfigRequest.h:30
static GlsConfigRequestMessage * create()
virtual void setHostId(const DtEntityIdentifier &val)
virtual void setPanelId(const std::string &val)
Definition joystick.h:30
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()
virtual void setEntityId(const DtEntityIdentifier &val)
Definition minimapStartZoomIn.h:29
virtual void setHostId(const DtEntityIdentifier &val)
static MinimapStartZoomInMessage * create()
Definition minimapStartZoomOut.h:29
static MinimapStartZoomOutMessage * create()
virtual void setHostId(const DtEntityIdentifier &val)
Definition minimapStopZoomIn.h:29
virtual void setHostId(const DtEntityIdentifier &val)
static MinimapStopZoomInMessage * create()
Definition minimapStopZoomOut.h:29
virtual void setHostId(const DtEntityIdentifier &val)
static MinimapStopZoomOutMessage * create()
Definition RequestSimulationState.h:30
static RequestSimulationStateMessage * create()
virtual void setEntityId(const DtEntityIdentifier &val)
static RestoreGimbalOverlaySectionsMessage * create()
Definition rwrPlaySound.h:29
static RwrPlaySoundMessage * create()
virtual void setPlayRwrSound(const std::string &val)
Definition RwrSetEnabled.h:29
virtual void setHostId(const DtEntityIdentifier &val)
virtual void setEnabled(bool val)
static RwrSetEnabledMessage * create()
Definition RwrSetSoundsEnabled.h:28
static RwrSetSoundsEnabledMessage * create()
virtual void setSoundsEnabled(bool val)
Definition setGimbalOverlaySections.h:29
static SetGimbalOverlaySectionsMessage * create()
virtual void setOverlaySections(const std::vector< std::string > &val)
Definition SetRadarModeAndSubmode.h:31
virtual void setHostId(const DtEntityIdentifier &val)
virtual void setMode(const std::string &val)
virtual void setSubMode(const std::string &val)
static SetRadarModeAndSubmodeMessage * create()
virtual void setSttTarget(int val)
Definition subscribeToBoss.h:29
virtual void setMessageName(const std::string &val)
static SubscribeToBossMessage * create()
Definition unsubscribeFromBoss.h:29
static UnsubscribeFromBossMessage * create()
virtual void setMessageName(const std::string &val)
Definition vrfReleaseControlOf.h:30
virtual void setEntityId(const DtEntityIdentifier &val)
static VrfReleaseControlOfMessage * create()
Message for executing a script on an entity with arbitrary attributes.
Definition vrfTaskEntityScript.h:39
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.
Definition vrfSetLightState.h:30
virtual void setState(bool val)
static VrfSetLightStateMessage * create()
virtual void setLights(const std::vector< int > &val)
virtual void setEntityId(const DtEntityIdentifier &val)
Definition vrfTakeControlOf.h:31
virtual void setFunctionGroups(const std::vector< std::string > &val)
virtual void setRoles(const std::vector< std::string > &val)
static VrfTakeControlOfMessage * create()
virtual void setEntityId(const DtEntityIdentifier &val)
Definition windowOperation.h:32
virtual void setOwnshipEntityId(const DtEntityIdentifier &val)
virtual void setIsFullScreen(bool val)
static WindowOperationMessage * create()
@ WindowType_Gimbal
Definition windowOperation.h:35
@ WindowType_PVD
Definition windowOperation.h:35
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:34
@ OperationType_Create
Definition windowOperation.h:34
@ OperationType_Destroy
Definition windowOperation.h:34
virtual void setWindowPosition(const DtVector &val)
Provides logging functionality with various severity levels and channels.
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
static void startMapZoomOut(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:253
static void subscribeToBoss(const std::string &messageType)
Definition glsVreMessageUtil.h:333
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:282
static void lowerGate(const DtEntityIdentifier &entity)
Start a lower security gate task on the specified gate entity.
Definition glsVreMessageUtil.h:84
static void startMapZoomIn(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:244
static void playRwrSound(const std::string &sound)
Definition glsVreMessageUtil.h:311
static void stopMapZoomOut(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:271
static void setRadarModeAndSubmode(const DtEntityIdentifier &hostId, const std::string &mode, const std::string &submode, int sttTarget=-1)
Definition glsVreMessageUtil.h:320
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:169
static void modifyGimbalView(const DtEntityIdentifier &entity, const std::string &sensorMode)
Definition glsVreMessageUtil.h:147
static void destroyPlanView(const DtEntityIdentifier &entity)
Destroy a plan view window.
Definition glsVreMessageUtil.h:185
static void takeControlOf(const DtEntityIdentifier &entity, const std::vector< std::string > &functionGroups, const std::vector< std::string > &roles)
Take joystick control of an entity, for specific function groups and roles.
Definition glsVreMessageUtil.h:197
static void stopMapZoomIn(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:262
static void raiseGate(const DtEntityIdentifier &entity)
Start a raise security gate task on the specified gate entity.
Definition glsVreMessageUtil.h:73
static void setOverlaySections(const std::vector< std::string > &sections)
Definition glsVreMessageUtil.h:230
static void sendSarRequest()
Sends a SAR request using current SAR manager settings.
Definition glsVreMessageUtil.h:67
static void sendCockpitInitialized(const std::string &cockpitName)
Sends a message confirming the cockpit has been initialized.
Definition glsVreMessageUtil.h:221
static void sendSetRwrEnabledMessage(const DtEntityIdentifier &entity, bool enabled)
Definition glsVreMessageUtil.h:292
static void releaseControlOf(const DtEntityIdentifier &entity)
Release all joystick control for an entity.
Definition glsVreMessageUtil.h:211
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:51
static void cycleGimbalView(const DtEntityIdentifier &entity)
Definition glsVreMessageUtil.h:159
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:119
static void destroyGimbalView(const DtEntityIdentifier &entity)
Destroy a gimbal view window.
Definition glsVreMessageUtil.h:136
static void unsubscribeFromBoss(const std::string &messageType)
Definition glsVreMessageUtil.h:342
static void restoreOverlaySections()
Definition glsVreMessageUtil.h:239
static void setLightState(const DtEntityIdentifier &entity, int light, bool state)
Set state for a light on an entity.
Definition glsVreMessageUtil.h:95
static void requestSimState(const DtEntityIdentifier &entity)
Requests a SimulationStateMessage for the specified entity.
Definition glsVreMessageUtil.h:109
static void setRwrSoundsEnabled(bool enabled)
Definition glsVreMessageUtil.h:302
Defines the central message manager for the VREngage messaging system.
Defines message classes for entity script task operations.