VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
commandLineRemoteController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
8 #include <vlutil/vlUtil.h>
10 
11 // This class provides a command line interface for controlling VR-Forces over
12 // the network with the remote controller class.
13 
14 // Enumeration used as a return value for commands in the DtCommandLineRemoteController, anything less than 1 is a failure of some sort
16 
17 
19 {
20 public:
21 
22  // constructor
24 
25  // destructor
27 
28  // Process entered text
29  void readStdin();
30 
31  // Set/Get time to quit
32  virtual void setTimeToQuit(bool yesNo);
33  virtual bool timeToQuit() const;
34 
35  // Get remote vrf controller pointer
37 
38  // Returns true if the given string vector has greater than or equal to the number of arguments required for current step
39  static const bool hasEnoughArguments(const int minNumberOfArguments, const std::vector<std::string>& args);
40 
41 public:
42 
43  // Functions for calling the corresponding methods on DtVrfRemoteController.
44 
45  // Called in response to "create waypoint"
46  virtual DtCommandStatus createWaypoint(const std::vector<std::string>& args);
47 
48  // Called in response to "create route"
49  virtual DtCommandStatus createRoute(const std::vector<std::string>& args);
50 
51  // Called in response to "create tank"
52  virtual DtCommandStatus createTank(const std::vector<std::string>& args);
53 
54  // Called in response to "print weather"
55  virtual DtCommandStatus printEnv(const std::vector<std::string>& args);
56 
57  // Called in response to "terrainheight"
58  virtual DtCommandStatus terrainHeight(const std::vector<std::string>& args);
59 
60  // Called in response to "create aggregate"
61  virtual DtCommandStatus createAggregate(const std::vector<std::string>& args);
62 
63  // Called in response to "create aerodrome"
64  virtual DtCommandStatus createAerodrome(const std::vector<std::string>& args);
65 
66  // Called in response to "set plan"
67  virtual DtCommandStatus setPlan(const std::vector<std::string>& args);
68 
69  // Called in response to "set label"
70  virtual DtCommandStatus setLabel(const std::vector<std::string>& args);
71 
72  // Called in response to "set systemEnabled"
73  virtual DtCommandStatus setSystemEnabled(const std::vector<std::string>& args);
74 
75  // Called in response to "set location"
76  virtual DtCommandStatus setLocation(const std::vector<std::string>& args);
77 
78  // Called in response to "set fuel"
79  virtual DtCommandStatus setFuel(const std::vector<std::string>& args);
80 
81  // Called in response to "set target"
82  virtual DtCommandStatus setTarget(const std::vector<std::string>& args);
83 
84  // Called in response to "set restore"
85  virtual DtCommandStatus setRestore(const std::vector<std::string>& args);
86 
87  // Called in response to "task patrolRoute"
88  virtual DtCommandStatus patrolRoute(const std::vector<std::string>& args);
89 
90  // Called in response to "task moveToPoint"
91  virtual DtCommandStatus moveToPoint(const std::vector<std::string>& args);
92 
93  // Called in response to "task follow"
94  virtual DtCommandStatus follow(const std::vector<std::string>& args);
95 
96  // Called in response to "task wait"
97  virtual DtCommandStatus wait(const std::vector<std::string>& args);
98 
99  // Called as helper function for bigRoutCommand
100  virtual void bigRoute(int iPoints);
101 
102  // Called as helper for listSnapshotsCommand
103  virtual void listSnapshots();
104 
105  // Called as helper for printCommand
107 
108 public:
109 
110  //-------------------------------------------------------
111  // Text callback functions
112  //-------------------------------------------------------
113 
114  // Called in response to "list"
115  static DtCommandStatus listCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
116 
117  // Called in response to "load"
118  static DtCommandStatus loadCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
119 
120  // Called in response to "new"
121  static DtCommandStatus newCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
122 
123  // Called in response to "save"
124  static DtCommandStatus saveCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
125 
126  // Called in response to "create"
127  static DtCommandStatus createCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
128 
129  // Called in response to "print"
130  static DtCommandStatus printCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
131 
132  // Called in response to "set"
133  static DtCommandStatus setCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
134 
135  // Called in response to "task"
136  static DtCommandStatus taskCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
137 
138  // Called in response to "aggregate"
139  static DtCommandStatus aggregateCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
140 
141  // Called in response to "delete"
142  static DtCommandStatus deleteCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
143 
144  // Called in response to "close"
145  static DtCommandStatus closeCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
146 
147  // Called in response to "monitor"
148  static DtCommandStatus monitorResourcesCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
149 
150  // Called in response to "unmonitor"
151  static DtCommandStatus removeMonitorResourcesCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
152 
153  // Called in response to "rewind"
154  static DtCommandStatus rewindCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
155 
156  // Called in response to "run"
157  static DtCommandStatus runCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
158 
159  // Called in response to "rununtil"
160  static DtCommandStatus runUntilCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
161 
162  // Called in response to "pause"
163  static DtCommandStatus pauseCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
164 
165  // Called in response to "simrun"
166  static DtCommandStatus simrunCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
167 
168  // Called in response to "simpause"
169  static DtCommandStatus simpauseCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
170 
171  // Called in response to "timemultipler"
172  static DtCommandStatus timemultiplierCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
173 
174  // Called in response to "time"
175  static DtCommandStatus timeCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
176 
177  // Called in response to "quit" or "q"
178  static DtCommandStatus quitCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
179 
180  // Called in response to "help" or "?" or "h"
181  static DtCommandStatus helpCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
182 
183  // Helper function called when we want help with a specific command
184  static DtCommandStatus helpCommand(const std::string command, DtCommandLineRemoteController* a);
185 
186  // Called in response to "help" or "?" or "h"
187  static DtCommandStatus bigRouteCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
188 
189  // Called in response to "listsnapshots"
190  static DtCommandStatus listSnapshotsCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
191 
192  // Called in response to "takesnapshot"
193  static DtCommandStatus takeSnapshotCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
194 
195  // Called in response to "turnonsnapshots"
196  static DtCommandStatus turnOnSnapshotsCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
197 
198  // Called in response to "turnoffsnapshots"
199  static DtCommandStatus turnOffSnapshotsCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
200 
201  // Called in response to "rollback"
202  static DtCommandStatus rollbackToSnapshotCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
203 
204  // Called in response to "simulationStatus"
205  static DtCommandStatus simulationStatusCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
206 
207  // Called in response to "terrainheight"
208  static DtCommandStatus terrainHeightCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
209 
210 #if DtHLA
211  // Called in response to "etrfireat"
212  static DtCommandStatus etrfireatCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
213 #endif
214 
215  //-------------------------------------------------------
216  // DtVrfRemoteController callback functions
217  //-------------------------------------------------------
218 
219  // Called by DtVrfRemoteController::loadScenario when sim engines are missing
220  static bool missingBackends(DtBackendMap* map, const std::set<DtSimulationAddress>& currentBackends, void* usr);
221 
222  // Sim engine arrival/departure callbacks
223  static void backendAddedCb(const DtSimulationAddress& addr, void* usr);
224  static void backendRemovedCb(const DtSimulationAddress& addr, void* usr);
225 
226  // Simulation status changed callback
227  static void simulationStatusChanged(DtSimulationStatus, void* usr);
228 
229  // Sim engine loaded/saved callbacks
230  static void backendLoadedCb(const DtSimulationAddress& addr, void* usr);
231  static void backendSavedCb(const DtSimulationAddress& addr,
232  DtSaveResult result, void* usr);
233 
234  // Scenario loaded/saved callbacks
235  static void ScenarioLoadedCb(void* usr);
236  static void ScenarioSavedCb(void* usr);
237 
238  // VR-Forces object created callback
239  static void vrfObjectCreatedCb(
240  const DtString& name, const DtEntityIdentifier& id, const DtUUID& uuid, void* usr);
241 
242  // Plan callbacks
243  static void printStatement(const DtSimStatement* stmt, int indent = 1);
244  static void printBlock(const DtSimBlock* stmt, int indent = 1);
245  static void planCb(const DtUUID& name,
246  const std::vector<DtSimStatement*>& statements, bool append, void* usr);
247  static void planStmtCb(const DtUUID& id, DtPlanStatus status, void* usr);
248  static void planCompleteCb(const DtUUID& id, void* usr);
249 
250  // Callback used to process monitor resource responses
252 
253  // Callback for list of current snapshots
254  static void scenarioSnapshotResponseCb(DtSimMessage* msg, void* usr);
255 
256  // Callback for terrain intersection response
257  static void terrainIntersectionCb(bool intersectionResult, const DtVector& intersectionPoint, void* usr);
258 
260 
261 
262 protected:
263 
264  // Present command line interface.
265  void prompt();
266 
267  // Parse user input, call corresponding function
268  void processCommand(const std::string buff);
269 
270  // Parse a point received as a string "p1,p2,p3", put those points into a DtVector that is passed
271  // the function as returnVector.
272  // Return true if this was successful, false otherwise.
273  const bool parsePoint(const std::string& pointString, DtVector& returnVector);
274 
275  // Parse the command
276  //
277  // Tokenize the string on ' ' and '"', return a vector of arguments
278  const std::vector<std::string> parseCommand(const std::string& rawCommand);
279 
280 protected:
281 
284  //DtSelectParam sparam;
285  static unsigned int theNextAggregateId;
286  static unsigned int theNextSubordinateId;
288  //DtReflectedEntityList* myEntityList;
289 
290 private:
292 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtSimulationStatus
Definition: backend.h:27
static DtCommandStatus listCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static void ProcessResourceResponse(const makVrfEvents::DtEvent &)
virtual DtCommandStatus createAggregate(const std::vector< std::string > &args)
virtual DtCommandStatus createRoute(const std::vector< std::string > &args)
static void terrainIntersectionCb(bool intersectionResult, const DtVector &intersectionPoint, void *usr)
static DtCommandStatus takeSnapshotCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus aggregateCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
DtCommandLineRemoteController(makVrf::DtVrlinkVrfRemoteController *controller)
static void ScenarioSavedCb(void *usr)
static DtCommandStatus timemultiplierCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus helpCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus createTank(const std::vector< std::string > &args)
bool myTimeToQuit
Definition: commandLineRemoteController.h:282
static unsigned int theNextAggregateId
Definition: commandLineRemoteController.h:285
virtual DtCommandStatus printEnv(const std::vector< std::string > &args)
static DtCommandStatus listSnapshotsCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual void bigRoute(int iPoints)
static DtCommandStatus runUntilCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus bigRouteCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus newCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus follow(const std::vector< std::string > &args)
static DtCommandStatus simrunCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static void backendRemovedCb(const DtSimulationAddress &addr, void *usr)
virtual DtCommandStatus terrainHeight(const std::vector< std::string > &args)
static DtCommandStatus pauseCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
const std::vector< std::string > parseCommand(const std::string &rawCommand)
static DtCommandStatus simulationStatusCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus patrolRoute(const std::vector< std::string > &args)
class DtBackendMap:
Definition: backendMap.h:21
virtual DtCommandStatus setTarget(const std::vector< std::string > &args)
bool myRemoveListCallback
Definition: commandLineRemoteController.h:287
void processCommand(const std::string buff)
static DtCommandStatus turnOnSnapshotsCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
void setRemoveListCallback(bool b)
Definition: commandLineRemoteController.h:259
virtual DtCommandStatus setSystemEnabled(const std::vector< std::string > &args)
static DtCommandStatus quitCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static void backendSavedCb(const DtSimulationAddress &addr, DtSaveResult result, void *usr)
static DtCommandStatus taskCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus createCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
class DtSimBlock:
Definition: simBlock.h:27
static DtCommandStatus etrfireatCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
DtSaveResult
Definition: ifSaveComplete.h:18
static void printBlock(const DtSimBlock *stmt, int indent=1)
static void printStatement(const DtSimStatement *stmt, int indent=1)
Definition: event.h:13
static DtCommandStatus printCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus rewindCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual void setTimeToQuit(bool yesNo)
static void backendLoadedCb(const DtSimulationAddress &addr, void *usr)
virtual makVrf::DtVrlinkVrfRemoteController * controller() const
Definition: commandLineRemoteController.h:15
File: simMsg.h.
Definition: simMessage.h:35
static unsigned int theNextSubordinateId
Definition: commandLineRemoteController.h:286
static const bool hasEnoughArguments(const int minNumberOfArguments, const std::vector< std::string > &args)
static DtCommandStatus removeMonitorResourcesCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static void backendAddedCb(const DtSimulationAddress &addr, void *usr)
int kbInterest
Definition: commandLineRemoteController.h:291
static DtCommandStatus monitorResourcesCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus deleteCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus closeCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus moveToPoint(const std::vector< std::string > &args)
makVrf::DtVrlinkVrfRemoteController * myController
Definition: commandLineRemoteController.h:283
virtual void printSimulationStatus(DtSimulationStatus)
static DtCommandStatus loadCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus setLabel(const std::vector< std::string > &args)
static void vrfObjectCreatedCb(const DtString &name, const DtEntityIdentifier &id, const DtUUID &uuid, void *usr)
Small container class that holds the status of a running DtPlan.
Definition: plan.h:45
static DtCommandStatus rollbackToSnapshotCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus timeCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static void planCb(const DtUUID &name, const std::vector< DtSimStatement * > &statements, bool append, void *usr)
virtual DtCommandStatus wait(const std::vector< std::string > &args)
static DtCommandStatus setCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus runCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
class DtSimStatement:
Definition: simStatement.h:38
virtual bool timeToQuit() const
static DtCommandStatus simpauseCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus setPlan(const std::vector< std::string > &args)
Definition: commandLineRemoteController.h:15
virtual DtCommandStatus setFuel(const std::vector< std::string > &args)
virtual DtCommandStatus setLocation(const std::vector< std::string > &args)
virtual DtCommandStatus createAerodrome(const std::vector< std::string > &args)
static void planStmtCb(const DtUUID &id, DtPlanStatus status, void *usr)
static DtCommandStatus turnOffSnapshotsCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
static DtCommandStatus terrainHeightCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
const bool parsePoint(const std::string &pointString, DtVector &returnVector)
Definition: commandLineRemoteController.h:18
static void simulationStatusChanged(DtSimulationStatus, void *usr)
static void planCompleteCb(const DtUUID &id, void *usr)
static bool missingBackends(DtBackendMap *map, const std::set< DtSimulationAddress > &currentBackends, void *usr)
virtual DtCommandStatus setRestore(const std::vector< std::string > &args)
Definition: commandLineRemoteController.h:15
DtCommandStatus
Definition: commandLineRemoteController.h:15
static void scenarioSnapshotResponseCb(DtSimMessage *msg, void *usr)
static void ScenarioLoadedCb(void *usr)
Definition: commandLineRemoteController.h:15
static DtCommandStatus saveCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
virtual DtCommandStatus createWaypoint(const std::vector< std::string > &args)

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)