DI-Guy SDK Documentation  13.6
diguyExerciseInterface.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2022 MAK Technologies, Inc.
4  ** All rights reserved.
5  *********************************************************************/
6 
7 /*********************************************************************
8  **
9  *t diguyExerciseInterface
10  **
11  *b Link against: libdiguy
12  */
13 
14 #ifndef __diguyExerciseInterface_H
15 #define __diguyExerciseInterface_H
16 
17 #ifdef SWIG
19 #else
20 #define CPLUSPLUS_ONLY
21 #endif
22 
23 #include <diguyExerciseInterface.h>
24 
25 #ifdef CPLUSPLUS_ONLY
26 
27 class bdiExerciseInterface;
28 class diguyCharacter;
29 
30 #include <stdio.h> // for NULL
31 #include <diguy_constants.h>
32 
33 #endif /* CPLUSPLUS_ONLY */
34 
35 
36 #include <declspec_diguy.h>
37 
44 class BDI_DECLSPEC_diguy diguyExerciseInterface
45 {
46 
47 public:
48 
49 /*****************************************************************************/
58  /*l
59  *b Description:
60  **
61  ** This function sends an xc_set_tin_tod PDU. This PDU
62  ** tells a remote DI-Guy application the simulated time of day
63  ** at which its scenario is supposed to begin. Doing this
64  ** provides a conceptual link between scenario time, which
65  ** nominally starts at zero, and wall-clock time. This makes
66  ** it possible for a scenario to be run under different
67  ** simulated lighting conditions.
68  **
69  ** The remote DI-Guy application essentially does a
70  ** diguyScenario::set_tin_time_of_day() call.
71  **
72  *b Arguments:
73  **
74  *a site - destination host id (65535 for all sites)
75  *a host - destination host id (65535 for all hosts)
76  *a ttod - tin time of day (seconds after midnight)
77  */
78  void send_xc_set_tin_tod(unsigned short site,
79  unsigned short host,
80  float ttod);
81 
82  /*l
83  *b Description:
84  **
85  ** This function sends an xc_load_scenario PDU. This PDU
86  ** tells a remote DI-Guy application to load a particular
87  ** scenario file.
88  **
89  ** The remote DI-Guy application essentially does a
90  ** diguyScenario::load() call.
91  **
92  *b Arguments:
93  **
94  *a site - destination host id (65535 for all sites)
95  *a host - destination host id (65535 for all hosts)
96  *a filename - scenario to load
97  *a refname - scenario reference name
98  */
99  void send_xc_load_scenario(unsigned short site,
100  unsigned short host,
101  const char* filename,
102  const char* refname);
103 
104  /*l
105  *b Description:
106  **
107  ** This function sends an xc_save_scenario PDU. This PDU
108  ** tells a remote DI-Guy application to save a particular
109  ** scenario file.
110  **
111  ** The remote DI-Guy application essentially does a
112  ** diguyScenario::save_as() call.
113  **
114  *b Arguments:
115  **
116  *a site - destination host id (65535 for all sites)
117  *a host - destination host id (65535 for all hosts)
118  *a filename - scenario to load
119  *a use_user_name - user name to uniquely identify the file
120  */
121  void send_xc_save_scenario(unsigned short site,
122  unsigned short host,
123  const char* filename,
124  const int use_user_name);
125 
126  /*l
127  *b Description:
128  **
129  ** This function sends an xc_reset_scenario PDU. This PDU
130  ** tells a remote DI-Guy application to reset the current
131  ** scenario file.
132  **
133  ** The remote DI-Guy application essentially does a
134  ** diguyScenario::reset() call.
135  **
136  *b Arguments:
137  **
138  *a site - destination host id (65535 for all sites)
139  *a host - destination host id (65535 for all hosts)
140  */
141  void send_xc_reset_scenario(unsigned short site,
142  unsigned short host);
143 
144  /*l
145  *b Description:
146  **
147  ** This function sends an xc_merge_scenario PDU. This PDU
148  ** tells a remote DI-Guy application to merge a particular
149  ** scenario file.
150  **
151  ** The remote DI-Guy application essentially does a
152  ** diguyScenario::merge() call.
153  **
154  *b Arguments:
155  **
156  *a site - destination host id (65535 for all sites)
157  *a host - destination host id (65535 for all hosts)
158  *a ttod - tin time of day for the merged scenario
159  *a (seconds after midnight)
160  *a refx, refy, refz - transformation reference point in merged
161  *a scenario (point around which translation
162  *a and rotation will occur)
163  *a tx, ty, tz - translation of reference point in merged
164  *a scenario
165  *a rz, rx, ry - rotation of reference point in merged scenario
166  *a filename - filename of scenario to merge
167  *a collision_suffix - suffix to be used in event of name
168  *a conflicts
169  */
170  void send_xc_merge_scenario(unsigned short site,
171  unsigned short host,
172  float ttod,
173  float refx, float refy, float refz,
174  float tx, float ty, float tz,
175  float rz, float rx, float ry,
176  const char* filename,
177  const char* suffix);
178 
179  /*l
180  *b Description:
181  **
182  ** This function sends an xc_trigger_script PDU. This PDU
183  ** tells a remote DI-Guy application to trigger the named
184  ** script.
185  **
186  ** The remote DI-Guy application essentially does a
187  ** diguyScenario::trigger_script() call.
188  **
189  *b Arguments:
190  **
191  *a site - destination host id (65535 for all sites)
192  *a host - destination host id (65535 for all hosts)
193  *a script_name - name of the script to be triggered
194  */
195  void send_xc_trigger_script(unsigned short site,
196  unsigned short host,
197  const char* script_name);
198 
199  /*l
200  *b Description:
201  **
202  ** This function sends an xc_control PDU. This PDU tells a
203  ** remote DI-Guy application to PLAY, STOP, RESET, etc.
204  **
205  *b Arguments:
206  **
207  *a site - destination host id (65535 for all sites)
208  *a host - destination host id (65535 for all hosts)
209  *a command - command string. Valid values are "RESET",
210  *a "RUN", "STOP", "FF", "REWIND"
211  */
212  void send_xc_control(unsigned short site,
213  unsigned short host,
214  const char* command);
215 
216  /*l
217  *b Description:
218  **
219  ** This function sends an xc_time_now PDU. This PDU tells all
220  ** remote DI-Guy applications what the simulated time of day is
221  ** right now. There is no way to target this message at
222  ** particular DI-Guy hosts. It is received and processed by all
223  ** DI-Guy applications in the DIS exercise.
224  **
225  *b Arguments:
226  **
227  *a tod - time of day: number of seconds since midnight,
228  *a where 0.0 <= tod < 86400.0
229  *a smooth_period - how many real seconds should be taken to get
230  *a into sync
231  **
232  ** Scenarios can proceed from one day to the next, up to a length of
233  ** 24 hours. When midnight comes, tod should be specified AS ZERO,
234  ** and should increase from there. Values less than zero or greater
235  ** than or equal to 86400.0 will NOT be sent over the network. In
236  ** the case nothing will be sent.
237  */
238  void send_xc_time_now(float tod, float smooth_period);
239 
240  /*l
241  *b Description:
242  **
243  ** This function sends an xc_eval_script PDU. This PDU tells a
244  ** remote DI-Guy application to evaluate a literal piece of
245  ** script text.
246  **
247  *b Arguments:
248  **
249  *a site - destination host id (65535 for all sites)
250  *a host - destination host id (65535 for all hosts)
251  *a text - text of the script to be executed
252  */
253  void send_xc_eval_script(unsigned short site,
254  unsigned short host,
255  const char* text);
256 
257  /*l
258  *b Description:
259  **
260  ** This function sends an xc_enter_slave PDU. This PDU tells a remote
261  ** DI-Guy application to start slaving it's camera to incoming
262  ** camera/time packets.
263  **
264  *b Arguments:
265  **
266  *a site - destination host id (65535 for all sites)
267  *a host - destination host id (65535 for all hosts)
268  */
269  void send_xc_enter_slave_mode(unsigned short site, unsigned short host);
270 
271  /*l
272  *b Description:
273  **
274  ** This function sends an xc_exit_slave PDU. This PDU tells a remote
275  ** DI-Guy application to stop slaving it's camera to incoming
276  ** camera/time packets.
277  **
278  *b Arguments:
279  **
280  *a site - destination host id (65535 for all sites)
281  *a host - destination host id (65535 for all hosts)
282  */
283  void send_xc_exit_slave_mode(unsigned short site, unsigned short host);
284 
285 
290  /*l
291  *b Description:
292  **
293  ** This function sends a custom AI message PDU. This PDU is mapped
294  ** into a diguyCharacter::agent_accept_message() function call on
295  ** the receiving side.
296  **
297  *b Arguments:
298  **
299  *a character - pointer to the remote diguyCharacter
300  *a sender - pointer to local diguyCharacter
301  *a message_type - type of message is being sent
302  *a message - message string
303  *a message_params - optional parameter string
304  **
305  ** Use diguyExerciseInterface::get_net_id() to get the name of the
306  ** character that the remote machine will see the sender as.
307  */
308  int send_message_to_character(diguyCharacter* character,
309  diguyCharacter* sender,
310  const char* message_type,
311  const char* message,
312  const char* message_params = NULL);
313 
314  /*l
315  *b Description:
316  **
317  ** This function sends a custom AI message PDU. This PDU is mapped
318  ** into a diguyCharacterGroup::send_message_to_all_members() on all
319  ** clients.
320  **
321  *b Arguments:
322  **
323  *a group_name - name of the diguyCharacterGroup to target
324  *a sender - pointer to local diguyCharacter
325  *a message_type - what type of message is being sent
326  *a message - the message string
327  *a message_params - optional parameter string
328  **
329  ** Use diguyExerciseInterface::get_net_id() to get the name of the
330  ** character that the remote machine will see the sender as.
331  */
332  int send_message_to_group(const char* group_name,
333  diguyCharacter* sender,
334  const char* message_type,
335  const char* message,
336  const char* message_params = NULL);
337 
338  /*l
339  *b Description:
340  **
341  ** This function sends a custom AI message PDU. This PDU is mapped
342  ** into a diguyCharacter::agent_broadcast_message() on all clients.
343  **
344  *b Arguments:
345  **
346  *a sender - pointer to the diguyCharacter that is broadcasting
347  *a the message
348  *a radius - how far to broadcast the message
349  *a message_type - what type of message is being sent
350  *a message - the message string
351  *a message_params - optional parameter string
352  */
353  int broadcast_message(diguyCharacter* sender,
354  float radius,
355  const char* message_type,
356  const char* message,
357  const char* message_params = NULL);
358 
359  /*l
360  *b Description:
361  **
362  ** This function sends a custom AI message PDU. This PDU is mapped
363  ** into a diguyCharacter::agent_broadcast_message_to_group() on all
364  ** clients.
365  **
366  *b Arguments:
367  **
368  *a sender - pointer to the diguyCharacter that is broadcasting
369  *a the message
370  *a group_name - the group that receive the message
371  *a radius - how far to broadcast the message
372  *a message_type - what type of message is being sent
373  *a message - the message string
374  *a message_params - optional parameter string
375  */
376  int broadcast_message_to_group(diguyCharacter* sender,
377  const char* group_name,
378  float radius,
379  const char* message_type,
380  const char* message,
381  const char* message_params = NULL);
382 
383  /*l
384  *b Returns:
385  **
386  ** "sitenum_hostnum_idnum" as a string
387  **
388  ** Useful for knowing the name that this entity will have on remote
389  ** machines. This string should be copied.
390  */
391  const char* get_net_id(diguyCharacter* character);
392 
393  /*l
394  *b Returns:
395  **
396  ** HLA federate type string, or "NA" if using DIS
397  **
398  */
399  const char* get_federate_type();
400 
402 
403 /****************************************************************************/
404 /****************************************************************************/
409 /****************************************************************************/
410 
415  int convert_mgrs_to_local(const char* MGRS_str, float* x, float* y, float* z);
417  const char* convert_local_to_mgrs(float x, float y, float z);
418 
419  // returns straightforward latitude and longitude coordinates
420  float convert_local_to_lat(float x, float y, float z);
421  double convert_local_to_lat_double(double x, double y, double z );
422  float convert_local_to_long(float x, float y, float z);
423  double convert_local_to_long_double(double x, double y, double z );
424 
425  // returns latitude and longitude in degrees, minutes, seconds
426  const char* convert_local_to_lat_long_string(float x, float y, float z);
427 
428  int convert_lat_long_to_local(float lat, float lon, float* x, float* y, float* z);
429  int convert_lat_long_to_local_double(double lat, double lon, float* x, float* y, float* z);
430 
431 
436 #ifdef CPLUSPLUS_ONLY
437 
438  bdiExerciseInterface* get_scripted_object() {return m_bdiExerciseInterface;}
439 
440 private:
441 
442  friend class bdiExerciseInterface;
443 
444  /*l
445  ** A private constructor.
446  */
447  diguyExerciseInterface(bdiExerciseInterface* ei);
448 
449  /*l
450  ** A pointer to internal data.
451  */
452  bdiExerciseInterface* m_bdiExerciseInterface;
453 
454 #endif /* CPLUSPLUS_ONLY */
455 
456 };
457 
458 
459 #endif /* __diguyExerciseInterface_H */
460 
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:82
Represents a scriptable api wrapping the DIS/HLA network connection.
Definition: diguyExerciseInterface.h:42