![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2002 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: textIf.h,v $ $Revision: 1.13 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00009 #ifndef DtTextInterface_H_ 00010 #define DtTextInterface_H_ 00011 00012 #include <vlutil/vlUtil.h> 00013 #include "vrfcontrol/vrfController.h" 00014 00015 //This class provides a text interface for controlling VR-Forces over the network. 00016 //This interface currently supports the following actions: 00017 // 00018 //1. load <filename> 00019 // load a scenario file 00020 00021 //2. save <filename> 00022 // save the current scenario 00023 00024 //3. new <db filename> 00025 // create a new scenario 00026 00027 //4. close 00028 // close the current scenario 00029 00030 //5. rewind 00031 // rewind the current scenario to its start state 00032 00033 //6. run 00034 // sends a message interface request to run the current scenario 00035 00036 //6a. simrun 00037 // sends a sim mgmt start PDU to run the current scenario 00038 00039 //7. simpause 00040 // sends a sim mgmt stop PDU to pause the current scenario 00041 00042 //7a. pause 00043 // sends a sim mgmt pause request to pause the current scenario 00044 00045 //8. list 00046 // list all the backends that are currently running 00047 00048 //9. create [ waypoint | route | tank | aggregate] 00049 // create a VR-Forces waypoint, route, tank, or tank aggregate 00050 00051 //10. delete [ <object_name> | <object_id> ] 00052 // delete a VR-Forces object by name or by object ID 00053 00054 //11. set [ plan | label | location | fuel | target | restore ] 00055 // set a VR-Forces object attribute 00056 00057 //12. task [ patrolRoute | moveToPoint | follow | wait ] 00058 // task a VR-Forces entity 00059 00060 //13. aggregate "name1" "name2" "name3" 00061 // aggregate 3 VR-Forces entities together 00062 00063 //14. quit 00064 // quit the application 00065 00066 00067 class DtTextInterface 00068 { 00069 public: 00070 00071 //constructor 00072 DtTextInterface(DtVrfRemoteController* controller); 00073 00074 //destructor 00075 virtual ~DtTextInterface(); 00076 00077 //Process entered text 00078 void readStdin(); 00079 00080 //Set/Get time to quit 00081 virtual void setTimeToQuit(bool yesNo); 00082 virtual bool timeToQuit() const; 00083 00084 //Get remote vrf controller pointer 00085 virtual DtVrfRemoteController* controller() const; 00086 00087 public: 00088 00089 //Functions for parsing command strings and calling 00090 //the corresponding methods on DtVrfRemoteController. 00091 00092 virtual void createWaypoint(char* str); 00093 virtual void createRoute(char* str); 00094 virtual void createTank(char* str); 00095 virtual void createAggregate(char* str); 00096 virtual void setPlan(char* str); 00097 virtual void setLabel(char* str); 00098 virtual void setLocation(char* str); 00099 virtual void setFuel(char* str); 00100 virtual void setTarget(char* str); 00101 virtual void setRestore(char* str); 00102 virtual void patrolRoute(char* str); 00103 virtual void moveToPoint(char* str); 00104 virtual void follow(char* str); 00105 virtual void wait(char* str); 00106 virtual void bigRoute(int iPoints); 00107 00108 public: 00109 00110 //------------------------------------------------------- 00111 //Text callback functions 00112 //------------------------------------------------------- 00113 00114 //Called in response to "list" 00115 static void listCmd(char* s, DtTextInterface* a); 00116 00117 //Called in response to "load" 00118 static void loadCmd(char* s, DtTextInterface* a); 00119 //Called by DtVrfRemoteController::loadScenario when back-ends are missing 00120 static bool missingBackends(DtBackendMap* map, void* usr); 00121 00122 //Called in response to "new" 00123 static void newCmd(char* s, DtTextInterface* a); 00124 00125 //Called in response to "save" 00126 static void saveCmd(char* s, DtTextInterface* a); 00127 00128 //Called in response to "create" 00129 static void createCmd(char* s, DtTextInterface* a); 00130 00131 //Called in response to "set" 00132 static void setCmd(char* s, DtTextInterface* a); 00133 00134 //Called in response to "task" 00135 static void taskCmd(char* s, DtTextInterface* a); 00136 00137 //Called in response to "aggregate" 00138 static void aggregateCmd(char* s, DtTextInterface* a); 00139 00140 //Called in response to "delete" 00141 static void deleteCmd(char* s, DtTextInterface* a); 00142 00143 //Called in response to "close" 00144 static void closeCmd(char* s, DtTextInterface* a); 00145 00146 //Called in response to "monitor" 00147 static void monitorResourcesCmd(char* s, DtTextInterface* a); 00148 00149 //Called in response to "unmonitor" 00150 static void removeMonitorResourcesCmd(char* s, DtTextInterface* a); 00151 00152 //Called in response to "rewind" 00153 static void rewindCmd(char* s, DtTextInterface* a); 00154 00155 //Called in response to "run" 00156 static void runCmd(char* s, DtTextInterface* a); 00157 00158 //Called in response to "pause" 00159 static void pauseCmd(char* s, DtTextInterface* a); 00160 00161 //Called in response to "simrun" 00162 static void simrunCmd(char* s, DtTextInterface* a); 00163 00164 //Called in response to "simpause" 00165 static void simpauseCmd(char* s, DtTextInterface* a); 00166 00167 //Called in response to "quit" or "q" 00168 static void quitCmd(char* s, DtTextInterface* a); 00169 00170 //Called in response to "help" or "?" or "h" 00171 static void helpCmd(char* s, DtTextInterface* a); 00172 00173 //Called in response to "help" or "?" or "h" 00174 static void bigRouteCmd(char* s, DtTextInterface* a); 00175 00176 00177 //------------------------------------------------------- 00178 //DtVrfRemoteController callback functions 00179 //------------------------------------------------------- 00180 00181 //Backend arrival/departure callbacks 00182 static void backendAddedCb(const DtSimulationAddress& addr, void* usr); 00183 static void backendRemovedCb(const DtSimulationAddress& addr, void* usr); 00184 00185 //Backend loaded/saved callbacks 00186 static void backendLoadedCb(const DtSimulationAddress& addr, void* usr); 00187 static void backendSavedCb(const DtSimulationAddress& addr, 00188 DtSaveResult result, void* usr); 00189 00190 //Scenario loaded/saved callbacks 00191 static void ScenarioLoadedCb(void* usr); 00192 static void ScenarioSavedCb(void* usr); 00193 00194 //VR-Forces object created callback 00195 static void vrfObjectCreatedCb( 00196 const DtString& name, const DtEntityIdentifier& id, void* usr); 00197 00198 //Plan callbacks 00199 static void planCb(const DtString& name, 00200 const DtList& stmts, bool append, void* usr); 00201 static void planStmtCb(const DtString& id, DtPlanStatus status, void* usr); 00202 static void planCompleteCb(const DtString& id, void* usr); 00203 00204 //Callback used to process monitor resource responses 00205 static void resourcesProcessedCb(DtSimMessage* msg, void* usr); 00206 00207 //Callback used to receive object console messages from the remote control 00208 //API. 00209 static void objectConsoleMessageCb(const DtEntityIdentifier& id, 00210 int notifyLevel, const DtString& message, void* usr); 00211 00212 protected: 00213 00214 //Present commmand line interface. 00215 void prompt(); 00216 00217 //Parse user input, call corresponding function 00218 void processCmd(char *buff); 00219 00220 protected: 00221 00222 bool myTimeToQuit; 00223 DtVrfRemoteController* myController; 00224 DtSelectParam sparam; 00225 static unsigned int theNextAggregateId; 00226 static unsigned int theNextSubordinateId; 00227 00228 private: 00229 int kbInterest; 00230 }; 00231 00232 00233 #endif 00234