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 "create aggregate"
58  virtual DtCommandStatus createAggregate(const std::vector<std::string>& args);
59 
60  // Called in response to "create aerodrome"
61  virtual DtCommandStatus createAerodrome(const std::vector<std::string>& args);
62 
63  // Called in response to "set plan"
64  virtual DtCommandStatus setPlan(const std::vector<std::string>& args);
65 
66  // Called in response to "set label"
67  virtual DtCommandStatus setLabel(const std::vector<std::string>& args);
68 
69  // Called in response to "set systemEnabled"
70  virtual DtCommandStatus setSystemEnabled(const std::vector<std::string>& args);
71 
72  // Called in response to "set location"
73  virtual DtCommandStatus setLocation(const std::vector<std::string>& args);
74 
75  // Called in response to "set fuel"
76  virtual DtCommandStatus setFuel(const std::vector<std::string>& args);
77 
78  // Called in response to "set target"
79  virtual DtCommandStatus setTarget(const std::vector<std::string>& args);
80 
81  // Called in response to "set restore"
82  virtual DtCommandStatus setRestore(const std::vector<std::string>& args);
83 
84  // Called in response to "task patrolRoute"
85  virtual DtCommandStatus patrolRoute(const std::vector<std::string>& args);
86 
87  // Called in response to "task moveToPoint"
88  virtual DtCommandStatus moveToPoint(const std::vector<std::string>& args);
89 
90  // Called in response to "task follow"
91  virtual DtCommandStatus follow(const std::vector<std::string>& args);
92 
93  // Called in response to "task wait"
94  virtual DtCommandStatus wait(const std::vector<std::string>& args);
95 
96  // Called as helper function for bigRoutCommand
97  virtual void bigRoute(int iPoints);
98 
99  // Called as helper for listSnapshotsCommand
100  virtual void listSnapshots();
101 
102  // Called as helper for printCommand
104 
105 public:
106 
107  //-------------------------------------------------------
108  // Text callback functions
109  //-------------------------------------------------------
110 
111  // Called in response to "list"
112  static DtCommandStatus listCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
113 
114  // Called in response to "load"
115  static DtCommandStatus loadCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
116 
117  // Called in response to "new"
118  static DtCommandStatus newCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
119 
120  // Called in response to "save"
121  static DtCommandStatus saveCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
122 
123  // Called in response to "create"
124  static DtCommandStatus createCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
125 
126  // Called in response to "print"
127  static DtCommandStatus printCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
128 
129  // Called in response to "set"
130  static DtCommandStatus setCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
131 
132  // Called in response to "task"
133  static DtCommandStatus taskCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
134 
135  // Called in response to "aggregate"
136  static DtCommandStatus aggregateCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
137 
138  // Called in response to "delete"
139  static DtCommandStatus deleteCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
140 
141  // Called in response to "close"
142  static DtCommandStatus closeCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
143 
144  // Called in response to "monitor"
145  static DtCommandStatus monitorResourcesCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
146 
147  // Called in response to "unmonitor"
148  static DtCommandStatus removeMonitorResourcesCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
149 
150  // Called in response to "rewind"
151  static DtCommandStatus rewindCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
152 
153  // Called in response to "run"
154  static DtCommandStatus runCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
155 
156  // Called in response to "pause"
157  static DtCommandStatus pauseCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
158 
159  // Called in response to "simrun"
160  static DtCommandStatus simrunCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
161 
162  // Called in response to "simpause"
163  static DtCommandStatus simpauseCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
164 
165  // Called in response to "timemultipler"
166  static DtCommandStatus timemultiplierCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
167 
168  // Called in response to "time"
169  static DtCommandStatus timeCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
170 
171  // Called in response to "quit" or "q"
172  static DtCommandStatus quitCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
173 
174  // Called in response to "help" or "?" or "h"
175  static DtCommandStatus helpCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
176 
177  // Helper function called when we want help with a specific command
178  static DtCommandStatus helpCommand(const std::string command, DtCommandLineRemoteController* a);
179 
180  // Called in response to "help" or "?" or "h"
181  static DtCommandStatus bigRouteCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
182 
183  // Called in response to "listsnapshots"
184  static DtCommandStatus listSnapshotsCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
185 
186  // Called in response to "takesnapshot"
187  static DtCommandStatus takeSnapshotCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
188 
189  // Called in response to "turnonsnapshots"
190  static DtCommandStatus turnOnSnapshotsCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
191 
192  // Called in response to "turnoffsnapshots"
193  static DtCommandStatus turnOffSnapshotsCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
194 
195  // Called in response to "rollback"
196  static DtCommandStatus rollbackToSnapshotCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
197 
198  // Called in response to "simulationStatus"
199  static DtCommandStatus simulationStatusCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
200 
201 #if DtHLA
202  // Called in response to "etrfireat"
203  static DtCommandStatus etrfireatCommand(const std::vector<std::string>& args, DtCommandLineRemoteController* a);
204 #endif
205 
206  //-------------------------------------------------------
207  // DtVrfRemoteController callback functions
208  //-------------------------------------------------------
209 
210  // Called by DtVrfRemoteController::loadScenario when sim engines are missing
211  static bool missingBackends(DtBackendMap* map, const std::set<DtSimulationAddress>& currentBackends, void* usr);
212 
213  // Sim engine arrival/departure callbacks
214  static void backendAddedCb(const DtSimulationAddress& addr, void* usr);
215  static void backendRemovedCb(const DtSimulationAddress& addr, void* usr);
216 
217  // Simulation status changed callback
218  static void simulationStatusChanged(DtSimulationStatus, void* usr);
219 
220  // Sim engine loaded/saved callbacks
221  static void backendLoadedCb(const DtSimulationAddress& addr, void* usr);
222  static void backendSavedCb(const DtSimulationAddress& addr,
223  DtSaveResult result, void* usr);
224 
225  // Scenario loaded/saved callbacks
226  static void ScenarioLoadedCb(void* usr);
227  static void ScenarioSavedCb(void* usr);
228 
229  // VR-Forces object created callback
230  static void vrfObjectCreatedCb(
231  const DtString& name, const DtEntityIdentifier& id, const DtUUID& uuid, void* usr);
232 
233  // Plan callbacks
234  static void printStatement(const DtSimStatement* stmt, int indent = 1);
235  static void printBlock(const DtSimBlock* stmt, int indent = 1);
236  static void planCb(const DtUUID& name,
237  const std::vector<DtSimStatement*>& statements, bool append, void* usr);
238  static void planStmtCb(const DtUUID& id, DtPlanStatus status, void* usr);
239  static void planCompleteCb(const DtUUID& id, void* usr);
240 
241  // Callback used to process monitor resource responses
243 
244  // Callback for list of current snapshots
245  static void scenarioSnapshotResponseCb(DtSimMessage* msg, void* usr);
246 
248 
249 
250 protected:
251 
252  // Present command line interface.
253  void prompt();
254 
255  // Parse user input, call corresponding function
256  void processCommand(const std::string buff);
257 
258  // Parse a point received as a string "p1,p2,p3", put those points into a DtVector that is passed
259  // the function as returnVector.
260  // Return true if this was successful, false otherwise.
261  const bool parsePoint(const std::string& pointString, DtVector& returnVector);
262 
263  // Parse the command
264  //
265  // Tokenize the string on ' ' and '"', return a vector of arguments
266  const std::vector<std::string> parseCommand(const std::string& rawCommand);
267 
268 protected:
269 
272  //DtSelectParam sparam;
273  static unsigned int theNextAggregateId;
274  static unsigned int theNextSubordinateId;
276  //DtReflectedEntityList* myEntityList;
277 
278 private:
280 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtSimulationStatus
Definition: backend.h:26
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 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:270
static unsigned int theNextAggregateId
Definition: commandLineRemoteController.h:273
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 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)
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:275
void processCommand(const std::string buff)
static DtCommandStatus turnOnSnapshotsCommand(const std::vector< std::string > &args, DtCommandLineRemoteController *a)
void setRemoveListCallback(bool b)
Definition: commandLineRemoteController.h:247
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:274
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:279
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:271
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)
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 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)