VR-Forces 4.7 Class Documentation
 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 <vl/hostStructs.h>
11 #include <vlutil/vlFilename.h>
12 #include <vl/rprFomMapper.h>
13 #include <vlutil/vlTime.h>
14 #include <vl/exerciseConn.h>
15 
16 #include <vrfutil/itt.h>
17 
18 class DtCgf;
19 class DtCgfDispatcher;
20 class DtExerciseConn;
21 class DtFomMapper;
22 class DtBatchManager;
23 class DtVrfCreator;
24 class DtVrfSimOptions;
25 #ifdef WIN32
26 class DtFilePrinter;
27 class DtWindowsConsolePrinter;
28 #endif
30 
31 // class DtVrfApp:
32 //
33 // Instances of DtVrfApp are the main class for the VR-Forces simulation
34 // back-end application.
35 
36 class DtVrfApp
37 {
38 public:
39 
40  // constructor
41  DtVrfApp(int argc, char** argv);
42 
43  // destructor
44  virtual ~DtVrfApp();
45 
46  // Initialization. Must be called before any other member functions
47  // are called.
48  virtual bool init(DtVrfCreator* creator = 0);
49 
50  // Main execution loop. Calls our DtCgf's tick(). Calls DtSleep() for a
51  // given time interval (the main loop sleep interval). Polls the keyboard
52  // for input. If a 'q' key press is received, exits the application.
53  virtual void mainLoop();
54 
55  // Accessor for the DtCgf
56  virtual DtCgf* cgf();
57 
58  // Accessor for the DtExerciseConn
59  virtual DtExerciseConn* exerciseConn();
60 
61 #ifdef WIN32
62  virtual void setConsoleWindow(HWND consoleWindow);
63 #endif
64 
66  static void setUserRequestedShutdown(bool);
67  static bool userRequestedShutdown();
68 
70  static DtVrfApp* app();
71 
72 protected:
73 
74  // Process mtl file. Also reads off mtl file (optionally) added to
75  // command line by -d command
76  virtual bool processMtlFile(int argc, char** argv);
77 
78  // Creates our cgf (called from init())
79  virtual DtCgf* createCgf(const DtSimulationAddress& addr, DtU32 sessionId);
80 
81  // Creates our simOptions (called from init())
83 
84  // This routine will read in the simulation options from the vrfSim.mtl
85  // file by default of the supplied filename
86  virtual bool readSimOptions(const DtFilename& mtlFile);
87 
88  // This routine will process the options read from the mtl file and set
89  // them in the appropriate places in the cgf. This method is called
90  // after the cgf has been initialized
91  virtual void processCgfOptions();
92 
93  // This routine will process app level options (parameter database, port,
94  // etc). This is called before processCgfOptions and before
95  // processCommandLine such that the command line options will take
96  // precedence over the .mtl options
97  virtual void processAppOptions();
98 
99  // Calls down to myCgf to schedule to load up all plugins from command line and vrfSim.mtl
100  virtual void addPluginsToLoad();
101 
102  // Print out collected frame rate stats to file
103  virtual void logFrameRateStats();
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 
124  virtual void exec();
125 
127 #ifdef WIN32
128  bool frontEndStillActive(HANDLE processHandle);
129 #else
130  bool frontEndStillActive();
131 #endif
132 
134  virtual bool createExerciseConnection();
135 
136 private:
137  // copy constructor - not implemented
138  DtVrfApp(const DtVrfApp& orig);
139 
140  // assignment operator - not implemented
141  DtVrfApp& operator=(const DtVrfApp& orig);
142 
143 protected:
144 
145  // Our DIS/RPR (site id, application id) simulation address that
146  // uniquely identifies our application in an exercise.
147  DtSimulationAddress mySimAddress;
148 
149  // VR-Link exercise connection. Provides means by which all network
150  // interactions (PDUs/HLA objects and interactions) are sent/recieved.
151  DtExerciseConn* myExerciseConn;
152 
153  // Command line arguments are cached in our constructor so we can process
154  // them later in init().
155  int myArgc;
156  char** myArgv;
157 
158  // Driver for our CGF object that responds to network messages
160 
161  // Driver for CGF Object that handles execution of scenario batches.
163 
164  // Options that are read in from the vrfSim.mtl file
166 
168 
169 #ifdef WIN32
170  HWND myConsoleWindow;
171 
172  // Writes diagnostics to vrfSim.log
173  DtFilePrinter* myFilePrinter;
174 #endif
175 
176  // Publishes all diagnostics to network in comment interactions.
178 
180 
182 
184  static DtVrfApp* theApp;
185 };

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)