VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
vrfApp.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2018 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #pragma once
6 
7 #include <vlutil/vlString.h>
8 #include <vlutil/vlList.h>
9 #include <vlutil/vlUtil.h>
10 #include <vlutil/vlFilename.h>
11 #include <vlutil/vlTime.h>
12 #include <vlpi/simulationAddress.h>
13 
14 class DtCgf;
15 class DtCgfDispatcher;
16 class DtExerciseConn;
17 class DtFomMapper;
19 class DtVrfCreator;
20 class DtFilePrinter;
21 #ifdef WIN32
22 class DtWindowsConsolePrinter;
23 #endif
26 
27 #if !DtLEGION
28  #include <vl/rprFomMapper.h>
29  #include <vl/exerciseConn.h>
30 #endif
31 
32 // class DtVrfApp:
33 //
34 // Instances of DtVrfApp are the main class for the VR-Forces simulation
35 // back-end application.
36 
37 namespace makVrf
38 {
39 class DtVrfSimOptions;
40 }
41 
42 class DtVrfApp
43 {
44 public:
45  // constructor
46  DtVrfApp(int argc, char** argv);
47 
48  // destructor
49  virtual ~DtVrfApp();
50 
51  // Initialization. Must be called before any other member functions
52  // are called.
53  virtual bool init(DtVrfCreator* creator = 0);
54 
55  // Main execution loop. Calls our DtCgf's tick(). Calls DtSleep() for a
56  // given time interval (the main loop sleep interval). Polls the keyboard
57  // for input. If a 'q' key press is received, exits the application.
58  virtual void mainLoop();
59 
60  // Accessor for the DtCgf
61  virtual DtCgf* cgf();
62 
63 #if !DtLEGION
64  // Accessor for the DtExerciseConn
65  virtual DtExerciseConn* exerciseConn();
66 #endif
67 
68 #ifdef WIN32
69  virtual void setConsoleWindow(HWND consoleWindow);
70 #endif
71 
73  static void setUserRequestedShutdown(bool);
74  static bool userRequestedShutdown();
75 
77  static DtVrfApp* app();
78 
79 protected:
80  // Process mtl file. Also reads off mtl file (optionally) added to
81  // command line by -d command
82  virtual bool processMtlFile(int argc, char** argv);
83 
84  // Creates our cgf (called from init())
85  virtual DtCgf* createCgf(const DtSimulationAddress& addr);
86 
87  // Creates our simOptions (called from init())
89 
90  // This routine will read in the simulation options from the vrfSim.mtl
91  // file by default of the supplied filename
92  virtual bool readSimOptions(const DtFilename& mtlFile);
93 
94  // This routine will process the options read from the mtl file and set
95  // them in the appropriate places in the cgf. This method is called
96  // after the cgf has been initialized
97  virtual void processCgfOptions();
98 
99  // This routine will process app level options (parameter database, port,
100  // etc). This is called before processCgfOptions and before
101  // processCommandLine such that the command line options will take
102  // precedence over the .mtl options
103  virtual void processAppOptions();
104 
105  // Gets keyboard input and sends it to console command manager.
106  // Returns false if mainloop should exit.
107  // Called during mainloop.
108  virtual bool processKeyboardInput();
109 
110  // Prints out some general tracking information to console about this build (info level)
111  virtual void printGeneralInfoToConsole();
112 
113  // Ticks subcomponents. Returns false is mainloop should exit.
114  // Called during mainloop.
115  virtual bool tick();
116 
118  virtual void initializeCgfForScenarioOrTerrain();
119 
121  virtual void initializeCgfRunState();
122 
125  virtual void exec();
126 
128 #ifdef WIN32
129  bool frontEndStillActive(HANDLE processHandle);
130 #else
131  bool frontEndStillActive();
132 #endif
133 
134 #if !DtLEGION
135  virtual bool createExerciseConnection();
137 #endif
138 
139 #if DtHLA
140  virtual bool checkForRequiredFomClasses();
142 #endif
143 
144 protected:
148 
149 private:
150  // copy constructor - not implemented
151  DtVrfApp(const DtVrfApp& orig);
152 
153  // assignment operator - not implemented
154  DtVrfApp& operator=(const DtVrfApp& orig);
155 
156 protected:
157  // Our DIS/RPR (site id, application id) simulation address that
158  // uniquely identifies our application in an exercise.
159  DtSimulationAddress mySimAddress;
160 
161 #if !DtLEGION
162  // VR-Link exercise connection. Provides means by which all network
163  // interactions (PDUs/HLA objects and interactions) are sent/recieved.
164  DtExerciseConn* myExerciseConn;
165 #endif
166 
167  // Command line arguments are cached in our constructor so we can process
168  // them later in init().
169  int myArgc;
170  char** myArgv;
171 
172  // Driver for our CGF object that responds to network messages
174 
175  // Driver for CGF Object that handles execution of scenario batches.
177 
178  // Options that are read in from the vrfSim.mtl file
180 
182 
183 #ifdef WIN32
184  HWND myConsoleWindow;
185 
186  DtWindowsConsolePrinter* myWindowsConsolePrinter;
187 #endif
188 
189  // Writes diagnostics to the log file
190  DtFilePrinter* myFilePrinter;
191 
192  // Publishes all diagnostics to network in comment interactions.
194 
196 
198  static DtVrfApp* theApp;
199 
201 };
bool frontEndStillActive()
Check to see (if running in combined mode) that the front end is still active.
DtCgfDispatcher * myDispatcher
Definition: vrfApp.h:173
Batch mode allows you to run one or more scenarios multiple times, for a specified amount of time...
Definition: remoteBatchManager.h:30
static bool userRequestedShutdown()
virtual ~DtVrfApp()
int myArgc
Definition: vrfApp.h:169
This class handles messages from the front-end for loading and saving scenarios, and controlling the ...
Definition: cgfDispatcher.h:44
DtVrfApp & operator=(const DtVrfApp &orig)
DtSimulationAddress mySimAddress
Definition: vrfApp.h:159
DtCommunicationManager * myCommunicationManager
Definition: vrfApp.h:200
Definition: vrfApp.h:42
DtRemoteBatchManager * myBatchManager
Definition: vrfApp.h:176
Definition: vrfSimOptions.h:15
virtual DtCgf * cgf()
virtual void printGeneralInfoToConsole()
static void setUserRequestedShutdown(bool)
Whether or not the user has requested a shutdown of the application.
virtual bool createExerciseConnection()
Creates the exercise connection from the given sim options.
DtBackendConsoleNetworkPrinter * myBackendConsoleNetworkPrinter
Definition: vrfApp.h:193
Console printer which sends the console data to the network using the Comment PDU/Interaction.
Definition: backendConsoleNetworkPrinter.h:21
static DtVrfApp * theApp
Definition: vrfApp.h:198
static DtVrfApp * app()
The global application.
char ** myArgv
Definition: vrfApp.h:170
virtual void initializePluginsForCommandLineArguments(DtVrfCreator *creator)
Pre-load plugins that want to be loaded and call special method to add command line arguments to the ...
virtual bool init(DtVrfCreator *creator=0)
virtual DtExerciseConn * exerciseConn()
The DtCommunicationManager class is a convenience class that will create both the DtNetworkInterfaceM...
Definition: communicationManager.h:54
virtual bool processKeyboardInput()
DtCgf * myCgf
Definition: vrfApp.h:181
virtual void exec()
Enters into main loop and ticks the application and cgf, as well as check console or other input for ...
DtVrfApp(int argc, char **argv)
DtExerciseConn * myExerciseConn
Definition: vrfApp.h:164
makVrf::DtVrfSimOptions * mySimOptions
Definition: vrfApp.h:179
virtual bool tick()
virtual void initializeCgfRunState()
Given command line options, pause or run the Cgf.
DtFilePrinter * myFilePrinter
Definition: vrfApp.h:190
Instances of DtVrfCreator are responsible for creating all of the objects needed to create and manage...
Definition: vrfCreator.h:285
virtual void processCgfOptions()
virtual bool checkForRequiredFomClasses()
Verifies that the DtExerciseConn has loaded all required FOM modules.
virtual DtCgf * createCgf(const DtSimulationAddress &addr)
virtual makVrf::DtVrfSimOptions * createSimOptions()
The top level class of a VR-Forces Simulation Engine, representing a Computer Generated Forces instan...
Definition: cgf.h:157
virtual void initializeCgfForScenarioOrTerrain()
Give command line options, initialize the Cgf for either a batch scenario, scenario or a new terrain ...
virtual void processAppOptions()
virtual void mainLoop()
virtual bool processMtlFile(int argc, char **argv)
static bool theUserRequestedShutdown
Definition: vrfApp.h:197
virtual bool readSimOptions(const DtFilename &mtlFile)
bool myWarnedFailedGetExitCode
Definition: vrfApp.h:195

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)