VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
textIf.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 text interface for controlling VR-Forces over the network.
12 //This interface currently supports the following actions:
13 //
14 //1. load <filename>
15 // load a scenario file
16 
17 //2. save <filename>
18 // save the current scenario
19 
20 //3. new <db filename>
21 // create a new scenario
22 
23 //4. close
24 // close the current scenario
25 
26 //5. rewind
27 // rewind the current scenario to its start state
28 
29 //6. run
30 // sends a message interface request to run the current scenario
31 
32 //6a. simrun
33 // sends a sim mgmt start PDU to run the current scenario
34 
35 //7. simpause
36 // sends a sim mgmt stop PDU to pause the current scenario
37 
38 //7a. pause
39 // sends a sim mgmt pause request to pause the current scenario
40 
41 //8. list
42 // list all the backends that are currently running
43 
44 //9. create [ waypoint | route | tank | aggregate]
45 // create a VR-Forces waypoint, route, tank, or tank aggregate
46 
47 //10. delete [ <object_name> | <object_id> ]
48 // delete a VR-Forces object by name or by object ID
49 
50 //11. set [ plan | label | location | fuel | target | restore ]
51 // set a VR-Forces object attribute
52 
53 //12. task [ patrolRoute | moveToPoint | follow | wait ]
54 // task a VR-Forces entity
55 
56 //13. aggregate "name1" "name2" "name3"
57 // aggregate 3 VR-Forces entities together
58 
59 //14. timemultiplier
60 // sets the time multiplier on the exercise clock
61 
62 //15. quit
63 // quit the application
64 
66 {
67 public:
68 
69  //constructor
71 
72  //destructor
73  virtual ~DtTextInterface();
74 
75  //Process entered text
76  void readStdin();
77 
78  //Set/Get time to quit
79  virtual void setTimeToQuit(bool yesNo);
80  virtual bool timeToQuit() const;
81 
82  //Get remote vrf controller pointer
84 
85 public:
86 
87  //Functions for parsing command strings and calling
88  //the corresponding methods on DtVrfRemoteController.
89 
90  virtual void createWaypoint(char* str);
91  virtual void createRoute(char* str);
92  virtual void createTank(char* str);
93  virtual void printEnv(char* str);
94  virtual void createAggregate(char* str);
95  virtual void createAerodrome(char* str);
96  virtual void setPlan(char* str);
97  virtual void setLabel(char* str);
98  virtual void setSystemEnabled(char* str);
99  virtual void setLocation(char* str);
100  virtual void setFuel(char* str);
101  virtual void setTarget(char* str);
102  virtual void setRestore(char* str);
103  virtual void patrolRoute(char* str);
104  virtual void moveToPoint(char* str);
105  virtual void follow(char* str);
106  virtual void wait(char* str);
107  virtual void bigRoute(int iPoints);
108  virtual void listSnapshots();
110 
111 public:
112 
113  //-------------------------------------------------------
114  //Text callback functions
115  //-------------------------------------------------------
116 
117  //Called in response to "list"
118  static void listCmd(char* s, DtTextInterface* a);
119 
120  //Called in response to "load"
121  static void loadCmd(char* s, DtTextInterface* a);
122  //Called by DtVrfRemoteController::loadScenario when back-ends are missing
123  static bool missingBackends(DtBackendMap* map, const std::set<DtSimulationAddress>& currentBackends, void* usr);
124 
125  //Called in response to "new"
126  static void newCmd(char* s, DtTextInterface* a);
127 
128  //Called in response to "save"
129  static void saveCmd(char* s, DtTextInterface* a);
130 
131  //Called in response to "create"
132  static void createCmd(char* s, DtTextInterface* a);
133 
134  //Called in response to "print"
135  static void printCmd(char* s, DtTextInterface* a);
136 
137  //Called in response to "set"
138  static void setCmd(char* s, DtTextInterface* a);
139 
140  //Called in response to "setspeed"
141  static void setSpeedCmd(char* s, DtTextInterface* a);
142 
143  //Called in response to "setsensor"
144  static void setSensorCmd(char* s, DtTextInterface* a);
145 
146  //Called in response to "task"
147  static void taskCmd(char* s, DtTextInterface* a);
148 
149  //Called in response to "aggregate"
150  static void aggregateCmd(char* s, DtTextInterface* a);
151 
152  //Called in response to "delete"
153  static void deleteCmd(char* s, DtTextInterface* a);
154 
155  //Called in response to "close"
156  static void closeCmd(char* s, DtTextInterface* a);
157 
158  //Called in response to "monitor"
159  static void monitorResourcesCmd(char* s, DtTextInterface* a);
160 
161  //Called in response to "unmonitor"
162  static void removeMonitorResourcesCmd(char* s, DtTextInterface* a);
163 
164  //Called in response to "rewind"
165  static void rewindCmd(char* s, DtTextInterface* a);
166 
167  //Called in response to "run"
168  static void runCmd(char* s, DtTextInterface* a);
169 
170  //Called in response to "pause"
171  static void pauseCmd(char* s, DtTextInterface* a);
172 
173  //Called in response to "simrun"
174  static void simrunCmd(char* s, DtTextInterface* a);
175 
176  //Called in response to "simpause"
177  static void simpauseCmd(char* s, DtTextInterface* a);
178 
179  //Called in response to "timemultipler"
180  static void timemultiplierCmd(char* s, DtTextInterface* a);
181 
182  //Called in response to "time"
183  static void timeCmd(char* s, DtTextInterface* a);
184 
185  //Called in response to "quit" or "q"
186  static void quitCmd(char* s, DtTextInterface* a);
187 
188  //Called in response to "help" or "?" or "h"
189  static void helpCmd(char* s, DtTextInterface* a);
190 
191  //Called in response to "help" or "?" or "h"
192  static void bigRouteCmd(char* s, DtTextInterface* a);
193 
194  //Called in response to "listsnapshots"
195  static void listSnapshotsCmd(char* s, DtTextInterface* a);
196 
197  //Called in response to "takesnapshot"
198  static void takeSnapshotCmd(char* s, DtTextInterface* a);
199 
200  //Called in response to "turnonsnapshots"
201  static void turnOnSnapshotsCmd(char* s, DtTextInterface* a);
202 
203  //Called in response to "turnoffsnapshots"
204  static void turnOffSnapshotsCmd(char* s, DtTextInterface* a);
205 
206  //Called in response to "rollback"
207  static void rollbackToSnapshotCmd(char* s, DtTextInterface* a);
208 
209  //Called in response to "simulationStatus"
210  static void simulationStatusCmd(char* s, DtTextInterface* a);
211 
212  //-------------------------------------------------------
213  //DtVrfRemoteController callback functions
214  //-------------------------------------------------------
215 
216  //Backend arrival/departure callbacks
217  static void backendAddedCb(const DtSimulationAddress& addr, void* usr);
218  static void backendRemovedCb(const DtSimulationAddress& addr, void* usr);
219 
220  //Simulation status changed callback
221  static void simulationStatusChanged(DtSimulationStatus, void* usr);
222 
223  //Backend loaded/saved callbacks
224  static void backendLoadedCb(const DtSimulationAddress& addr, void* usr);
225  static void backendSavedCb(const DtSimulationAddress& addr,
226  DtSaveResult result, void* usr);
227 
228  //Scenario loaded/saved callbacks
229  static void ScenarioLoadedCb(void* usr);
230  static void ScenarioSavedCb(void* usr);
231 
232  //VR-Forces object created callback
233  static void vrfObjectCreatedCb(
234  const DtString& name, const DtEntityIdentifier& id, const DtUUID& uuid, void* usr);
235 
236  //Plan callbacks
237  static void printStatement(const DtSimStatement* stmt, int indent = 1);
238  static void printBlock(const DtSimBlock* stmt, int indent = 1);
239  static void planCb(const DtUUID& name,
240  const std::vector<DtSimStatement*>& statements, bool append, void* usr);
241  static void planStmtCb(const DtUUID& id, DtPlanStatus status, void* usr);
242  static void planCompleteCb(const DtUUID& id, void* usr);
243 
244  //Callback used to process monitor resource responses
245  static void resourcesProcessedCb(DtSimMessage* msg, void* usr);
246 
247  //Callback for list of current snapshots
248  static void scenarioSnapshotResponseCb(DtSimMessage* msg, void* usr);
249 
250  //Callback used to receive object console messages from the remote control
251  //API.
252  static void objectConsoleMessageCb(const DtEntityIdentifier& id,
253  int notifyLevel, const DtString& message, void* usr);
254 
256 
257  // Accessors for entityList
260 
261 protected:
262 
263  //Present command line interface.
264  void prompt();
265 
266  //Parse user input, call corresponding function
267  void processCmd(char *buff);
268 
269 protected:
270 
273  DtSelectParam sparam;
274  static unsigned int theNextAggregateId;
275  static unsigned int theNextSubordinateId;
278 
279 private:
281 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
static void pauseCmd(char *s, DtTextInterface *a)
virtual void setRestore(char *str)
static void backendSavedCb(const DtSimulationAddress &addr, DtSaveResult result, void *usr)
static void listCmd(char *s, DtTextInterface *a)
DtTextInterface(makVrf::DtVrlinkVrfRemoteController *controller)
static void backendRemovedCb(const DtSimulationAddress &addr, void *usr)
DtSimulationStatus
Definition: backend.h:26
static void ScenarioSavedCb(void *usr)
static void rollbackToSnapshotCmd(char *s, DtTextInterface *a)
static void simpauseCmd(char *s, DtTextInterface *a)
static void scenarioSnapshotResponseCb(DtSimMessage *msg, void *usr)
virtual void setTarget(char *str)
static void removeMonitorResourcesCmd(char *s, DtTextInterface *a)
Definition: textIf.h:65
virtual void setFuel(char *str)
static void planCompleteCb(const DtUUID &id, void *usr)
virtual void wait(char *str)
static void turnOffSnapshotsCmd(char *s, DtTextInterface *a)
virtual void createWaypoint(char *str)
static bool missingBackends(DtBackendMap *map, const std::set< DtSimulationAddress > &currentBackends, void *usr)
void processCmd(char *buff)
virtual void createAerodrome(char *str)
virtual void createAggregate(char *str)
virtual void setLabel(char *str)
static void planStmtCb(const DtUUID &id, DtPlanStatus status, void *usr)
int kbInterest
Definition: textIf.h:280
static void setSensorCmd(char *s, DtTextInterface *a)
void setRemoveListCallback(bool b)
Definition: textIf.h:255
virtual void follow(char *str)
static void loadCmd(char *s, DtTextInterface *a)
static void printBlock(const DtSimBlock *stmt, int indent=1)
static void timemultiplierCmd(char *s, DtTextInterface *a)
static void rewindCmd(char *s, DtTextInterface *a)
class DtBackendMap:
Definition: backendMap.h:21
virtual void listSnapshots()
bool myTimeToQuit
Definition: textIf.h:271
static void simrunCmd(char *s, DtTextInterface *a)
static void planCb(const DtUUID &name, const std::vector< DtSimStatement * > &statements, bool append, void *usr)
static void printStatement(const DtSimStatement *stmt, int indent=1)
static void resourcesProcessedCb(DtSimMessage *msg, void *usr)
static void bigRouteCmd(char *s, DtTextInterface *a)
class DtSimBlock:
Definition: simBlock.h:27
virtual void printSimulationStatus(DtSimulationStatus)
static void deleteCmd(char *s, DtTextInterface *a)
DtSaveResult
Definition: ifSaveComplete.h:18
DtSelectParam sparam
Definition: textIf.h:273
virtual void setLocation(char *str)
static void closeCmd(char *s, DtTextInterface *a)
static void quitCmd(char *s, DtTextInterface *a)
File: simMsg.h.
Definition: simMessage.h:35
virtual void patrolRoute(char *str)
static void backendLoadedCb(const DtSimulationAddress &addr, void *usr)
static void createCmd(char *s, DtTextInterface *a)
virtual void createTank(char *str)
static void takeSnapshotCmd(char *s, DtTextInterface *a)
static void backendAddedCb(const DtSimulationAddress &addr, void *usr)
virtual void bigRoute(int iPoints)
static void saveCmd(char *s, DtTextInterface *a)
static unsigned int theNextSubordinateId
Definition: textIf.h:275
makVrf::DtVrlinkVrfRemoteController * myController
Definition: textIf.h:272
static void turnOnSnapshotsCmd(char *s, DtTextInterface *a)
DtReflectedEntityList * myEntityList
Definition: textIf.h:277
static void objectConsoleMessageCb(const DtEntityIdentifier &id, int notifyLevel, const DtString &message, void *usr)
Small container class that holds the status of a running DtPlan.
Definition: plan.h:45
static void newCmd(char *s, DtTextInterface *a)
static void runCmd(char *s, DtTextInterface *a)
static void aggregateCmd(char *s, DtTextInterface *a)
virtual void setSystemEnabled(char *str)
class DtSimStatement:
Definition: simStatement.h:38
virtual void moveToPoint(char *str)
virtual ~DtTextInterface()
virtual void setPlan(char *str)
static void listSnapshotsCmd(char *s, DtTextInterface *a)
static void vrfObjectCreatedCb(const DtString &name, const DtEntityIdentifier &id, const DtUUID &uuid, void *usr)
static void setSpeedCmd(char *s, DtTextInterface *a)
static unsigned int theNextAggregateId
Definition: textIf.h:274
static void printCmd(char *s, DtTextInterface *a)
static void monitorResourcesCmd(char *s, DtTextInterface *a)
virtual makVrf::DtVrlinkVrfRemoteController * controller() const
virtual bool timeToQuit() const
static void ScenarioLoadedCb(void *usr)
virtual void createRoute(char *str)
static void setCmd(char *s, DtTextInterface *a)
static void taskCmd(char *s, DtTextInterface *a)
virtual void printEnv(char *str)
DtReflectedEntityList * entityList() const
bool myRemoveListCallback
Definition: textIf.h:276
static void helpCmd(char *s, DtTextInterface *a)
static void simulationStatusCmd(char *s, DtTextInterface *a)
static void simulationStatusChanged(DtSimulationStatus, void *usr)
virtual void setTimeToQuit(bool yesNo)
static void timeCmd(char *s, DtTextInterface *a)
void setEntityList(DtReflectedEntityList *rel)

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)