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 
46  // constructor
47  DtVrfApp(int argc, char** argv);
48 
49  // destructor
50  virtual ~DtVrfApp();
51 
52  // Initialization. Must be called before any other member functions
53  // are called.
54  virtual bool init(DtVrfCreator* creator = 0);
55 
56  // Main execution loop. Calls our DtCgf's tick(). Calls DtSleep() for a
57  // given time interval (the main loop sleep interval). Polls the keyboard
58  // for input. If a 'q' key press is received, exits the application.
59  virtual void mainLoop();
60 
61  // Accessor for the DtCgf
62  virtual DtCgf* cgf();
63 
64 #if !DtLEGION
65  // Accessor for the DtExerciseConn
66  virtual DtExerciseConn* exerciseConn();
67 #endif
68 
69 #ifdef WIN32
70  virtual void setConsoleWindow(HWND consoleWindow);
71 #endif
72 
74  static void setUserRequestedShutdown(bool);
75  static bool userRequestedShutdown();
76 
78  static DtVrfApp* app();
79 
80 protected:
81 
82  // Process mtl file. Also reads off mtl file (optionally) added to
83  // command line by -d command
84  virtual bool processMtlFile(int argc, char** argv);
85 
86  // Creates our cgf (called from init())
87  virtual DtCgf* createCgf(const DtSimulationAddress& addr);
88 
89  // Creates our simOptions (called from init())
91 
92  // This routine will read in the simulation options from the vrfSim.mtl
93  // file by default of the supplied filename
94  virtual bool readSimOptions(const DtFilename& mtlFile);
95 
96  // This routine will process the options read from the mtl file and set
97  // them in the appropriate places in the cgf. This method is called
98  // after the cgf has been initialized
99  virtual void processCgfOptions();
100 
101  // This routine will process app level options (parameter database, port,
102  // etc). This is called before processCgfOptions and before
103  // processCommandLine such that the command line options will take
104  // precedence over the .mtl options
105  virtual void processAppOptions();
106 
107  // Gets keyboard input and sends it to console command manager.
108  // Returns false if mainloop should exit.
109  // Called during mainloop.
110  virtual bool processKeyboardInput();
111 
112  // Prints out some general tracking information to console about this build (info level)
113  virtual void printGeneralInfoToConsole();
114 
115  // Ticks subcomponents. Returns false is mainloop should exit.
116  // Called during mainloop.
117  virtual bool tick();
118 
120  virtual void initializeCgfForScenarioOrTerrain();
121 
123  virtual void initializeCgfRunState();
124 
126  virtual void exec();
127 
129 #ifdef WIN32
130  bool frontEndStillActive(HANDLE processHandle);
131 #else
132  bool frontEndStillActive();
133 #endif
134 
135 #if !DtLEGION
136  virtual bool createExerciseConnection();
138 #endif
139 
140 protected:
143 
144 private:
145  // copy constructor - not implemented
146  DtVrfApp(const DtVrfApp& orig);
147 
148  // assignment operator - not implemented
149  DtVrfApp& operator=(const DtVrfApp& orig);
150 
151 protected:
152 
153  // Our DIS/RPR (site id, application id) simulation address that
154  // uniquely identifies our application in an exercise.
155  DtSimulationAddress mySimAddress;
156 
157 #if !DtLEGION
158  // VR-Link exercise connection. Provides means by which all network
159  // interactions (PDUs/HLA objects and interactions) are sent/recieved.
160  DtExerciseConn* myExerciseConn;
161 #endif
162 
163  // Command line arguments are cached in our constructor so we can process
164  // them later in init().
165  int myArgc;
166  char** myArgv;
167 
168  // Driver for our CGF object that responds to network messages
170 
171  // Driver for CGF Object that handles execution of scenario batches.
173 
174  // Options that are read in from the vrfSim.mtl file
176 
178 
179 #ifdef WIN32
180  HWND myConsoleWindow;
181 #endif
182 
183  // Writes diagnostics to the log file
184  DtFilePrinter* myFilePrinter;
185 
186  // Publishes all diagnostics to network in comment interactions.
188 
190 
192  static DtVrfApp* theApp;
193 
195 };
bool frontEndStillActive()
Check to see (if running in combined mode) that the front end is still active.
DtCgfDispatcher * myDispatcher
Definition: vrfApp.h:169
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:165
This class handles messages from the front-end for loading and saving scenarios, and controlling the ...
Definition: cgfDispatcher.h:42
DtVrfApp & operator=(const DtVrfApp &orig)
DtSimulationAddress mySimAddress
Definition: vrfApp.h:155
DtCommunicationManager * myCommunicationManager
Definition: vrfApp.h:194
Definition: vrfApp.h:42
DtRemoteBatchManager * myBatchManager
Definition: vrfApp.h:172
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:187
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:192
static DtVrfApp * app()
The global application.
char ** myArgv
Definition: vrfApp.h:166
virtual void initializePluginsForCommandLineArguments(DtVrfCreator *creator)
Preload plugins that want to be loaded and call special method to add command line arguments to the c...
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:51
virtual bool processKeyboardInput()
DtCgf * myCgf
Definition: vrfApp.h:177
virtual void exec()
Enters into main loop and ticks the applicaiton and cgf, as well as check console or other input for ...
DtVrfApp(int argc, char **argv)
DtExerciseConn * myExerciseConn
Definition: vrfApp.h:160
makVrf::DtVrfSimOptions * mySimOptions
Definition: vrfApp.h:175
virtual bool tick()
virtual void initializeCgfRunState()
Given command line options, pause or run the Cgf.
DtFilePrinter * myFilePrinter
Definition: vrfApp.h:184
Instances of DtVrfCreator are responsible for creating all of the objects needed to create and manage...
Definition: vrfCreator.h:284
virtual void processCgfOptions()
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:147
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:191
virtual bool readSimOptions(const DtFilename &mtlFile)
bool myWarnedFailedGetExitCode
Definition: vrfApp.h:189

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)