#include <G4UIGainServer.hh>
Inheritance diagram for G4UIGainServer:
Public Member Functions | |
G4UIsession * | SessionStart () |
void | PauseSessionStart (G4String msg) |
G4int | ReceiveG4cout (G4String coutString) |
G4int | ReceiveG4cerr (G4String cerrString) |
G4UIGainServer () | |
~G4UIGainServer () | |
void | SessionTerminate () |
void | Prompt (G4String) |
G4String | GetCommand () |
Private Member Functions | |
void | GetNewTreeStructure (G4UIcommandTree *, int recursiveLevel) |
void | GetNewTreeValues (G4UIcommandTree *, int recursiveLevel) |
void | ExecuteCommand (G4String aCommand) |
G4bool | GetHelpChoice (G4int &aInt) |
void | ExitHelp () |
bool | SetUPServer () |
void | WaitingConnection () |
void | CloseConnection () |
void | ChangeDirectory (G4String) |
void | ListDirectory (G4String) |
void | TerminalHelp (G4String) |
G4String | ModifyPrefix (G4String) |
G4UIcommandTree * | FindDirPath (G4String) |
void | ShowCurrent (G4String) |
G4String | GetFullPath (G4String) |
void | SendCommandProperties (G4UIcommandTree *) |
void | SendParameterProperties (G4UIcommandTree *) |
void | SendAParamProperty (G4UIcommand *) |
void | SendATclParamProperty (G4UIcommand *) |
void | CodeGenJavaTree (G4UIcommandTree *, int recursiveLevel) |
void | CodeGenJavaParams (G4UIcommandTree *, int recursiveLevel) |
void | CodeGenTclTree (G4UIcommandTree *, int recursiveLevel) |
void | CodeGenTclParams (G4UIcommandTree *, int recursiveLevel) |
void | SendDisableList (G4UIcommandTree *, int recursiveLevel) |
void | NotifyStateChange (void) |
void | NotifyCommandUpdate (void) |
void | NotifyParameterUpdate (G4UIcommand *) |
int | CommandUpdated (void) |
void | UpdateState (void) |
void | UpdateParamVal (void) |
Private Attributes | |
G4String | prefix |
G4String | promptCharacter |
G4UImanager * | UI |
UImode | uiMode |
G4String | JVersion |
G4String | TVersion |
G4bool | iExit |
G4bool | iCont |
int | socketD [3] |
int | port |
sockaddr_in | saddr |
sockaddr_in | caddr |
int | len |
int | ret |
char | buf [1024] |
std::vector< G4String > | previousTreeCommands |
std::vector< G4String > | newTreeCommands |
std::vector< G4String > | previousTreeParams |
std::vector< G4String > | newTreeParams |
std::vector< G4UIcommand * > | previousTreePCP |
std::vector< G4UIcommand * > | newTreePCP |
|
Definition at line 44 of file G4UIGainServer.cc. References GetNewTreeStructure(), GetNewTreeValues(), iCont, iExit, JVersion, newTreeCommands, newTreeParams, newTreePCP, port, prefix, previousTreeCommands, previousTreeParams, previousTreePCP, promptCharacter, SetUPServer(), terminal_mode, TVersion, UI, and uiMode.
00046 { 00047 TVersion ="T1.0a"; JVersion="J1.0a"; 00048 prefix = "/"; 00049 00050 port = DEFAULT_PORT; 00051 while(SetUPServer() == false){ 00052 G4cout<<"can't get the port no. "<<port<<" Now, try to get the next port "<<port+1<<G4endl; 00053 port++; 00054 } 00055 00056 00057 UI= G4UImanager::GetUIpointer(); 00058 UI-> SetSession(this); 00059 UI-> SetCoutDestination(this); 00060 00061 G4StateManager* statM = G4StateManager::GetStateManager(); 00062 promptCharacter = statM->GetStateString(statM->GetCurrentState()); 00063 uiMode = terminal_mode; 00064 00065 iExit= FALSE; 00066 iCont= FALSE; 00067 00068 G4UIcommandTree* tree = UI->GetTree(); 00069 GetNewTreeStructure(tree,0); 00070 GetNewTreeValues(tree,0); 00071 previousTreeCommands = newTreeCommands; 00072 previousTreeParams = newTreeParams; 00073 previousTreePCP = newTreePCP; 00074 00075 } |
Here is the call graph for this function:
|
Definition at line 78 of file G4UIGainServer.cc. References UI.
|
|
Referenced by GetCommand(), and WaitingConnection(). |
|
|
|
Referenced by WaitingConnection(). |
|
Referenced by WaitingConnection(). |
|
|
|
|
|
Referenced by ExecuteCommand(), and WaitingConnection(). |
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Reimplemented from G4VBasicShell. Definition at line 132 of file G4UIGainServer.cc. References CommandUpdated(), GetNewTreeStructure(), GetNewTreeValues(), newTreeCommands, newTreeParams, newTreePCP, NotifyCommandUpdate(), previousTreeCommands, previousTreeParams, previousTreePCP, terminal_mode, UI, uiMode, UpdateParamVal(), and UpdateState(). Referenced by PauseSessionStart(), and SessionStart().
00134 { 00135 if(aCommand.length()<2) return; 00136 00137 G4UIcommandTree* tree = UI->GetTree(); 00138 if(aCommand.length()<2) return; 00139 G4int returnVal = UI->ApplyCommand(aCommand); 00140 G4int paramIndex = returnVal % 100; 00141 // 0 - 98 : paramIndex-th parameter is invalid 00142 // 99 : convination of parameters is invalid 00143 G4int commandStatus = returnVal - paramIndex; 00144 00145 UpdateState(); 00146 00147 if(uiMode != terminal_mode){ 00148 switch(commandStatus) { 00149 case fCommandSucceeded: 00150 GetNewTreeStructure(tree,0); 00151 GetNewTreeValues(tree,0); 00152 if(CommandUpdated()){ 00153 NotifyCommandUpdate(); 00154 } else{ 00155 UpdateParamVal(); 00156 } 00157 previousTreeCommands = newTreeCommands; 00158 previousTreeParams = newTreeParams; 00159 previousTreePCP = newTreePCP; 00160 break; 00161 case fCommandNotFound: 00162 G4cerr << "@@ErrResult \" <" << UI->SolveAlias(aCommand) << "> not found.\"" << G4endl; 00163 break; 00164 case fIllegalApplicationState: 00165 G4cerr << "@@ErrResult \"illegal application state -- command refused.\"" << G4endl; 00166 break; 00167 case fParameterOutOfRange: 00168 G4cout << "@@ErrResult \"Parameter Out of Range.\"" << G4endl; 00169 break; 00170 case fParameterUnreadable: 00171 G4cout << "@@ErrResult \"Parameter is wrong type and/or is not omittable.\""<<G4endl; 00172 break; 00173 case fParameterOutOfCandidates: 00174 G4cerr << "@@ErrResult \"Parameter is out of candidate.\"" << G4endl; 00175 break; 00176 case fAliasNotFound: 00177 default: 00178 G4cerr << "command refused (" << commandStatus << ")" << G4endl; 00179 } 00180 } 00181 } |
Here is the call graph for this function:
|
Implements G4VBasicShell. Definition at line 362 of file G4UIGainServer.cc.
00364 {
00365 char temp[100];
00366 G4cin.getline(temp, 100);
00367 }
|
|
Referenced by WaitingConnection(). |
|
Definition at line 184 of file G4UIGainServer.cc. References buf, ChangeDirectory(), GetFullPath(), iCont, iExit, java_mode, JVersion, ListDirectory(), NotifyStateChange(), prefix, promptCharacter, SendCommandProperties(), ShowCurrent(), socketD, tcl_mode, terminal_mode, TerminalHelp(), TVersion, UI, and uiMode. Referenced by PauseSessionStart(), and SessionStart().
00186 { 00187 G4String newCommand; 00188 G4String nullString; 00189 00190 while( 1 ) 00191 { 00192 G4UIcommandTree* tree = UI->GetTree(); 00193 if ( uiMode != terminal_mode ){ 00194 G4cout << "@@PROMPT \"" << promptCharacter << "\"" << G4endl; 00195 } 00196 if ( uiMode != java_mode ){ 00197 G4cout << promptCharacter << "> " << G4endl; 00198 }else{ 00199 G4cout << "@@Ready" << G4endl; 00200 } 00201 00202 00205 read(socketD[1],buf,1024); 00206 newCommand=buf; 00207 //DEBUG cout<<"->"<<newCommand<<"<-"<<newCommand.length()<<G4endl; 00208 //newCommand.readLine( G4cin, FALSE ); 00211 00212 00213 00214 if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;} 00215 00216 newCommand = newCommand.strip(G4String::leading); 00217 if( newCommand.length() < 1) { break; } 00218 00219 while( newCommand(newCommand.length()-1) == '_' ) 00220 { 00221 G4String newLine; 00222 newCommand.remove(newCommand.length()-1); 00223 newLine.readLine( G4cin ); 00224 if (!G4cin.good()) { G4cin.clear(); newCommand = nullString; iExit=false;break;} 00225 newCommand.append(newLine); 00226 } 00227 00228 G4String nC = newCommand.strip(G4String::leading); 00229 if( nC.length() < 1) { break; } 00230 00231 // -------------------- nC.toUpper(); 00232 if( nC == "@@GainmodeJAVA" ) { 00233 uiMode = java_mode; 00234 G4cout << G4endl << "@@Version " << JVersion << G4endl; 00235 SendCommandProperties(tree); 00236 NotifyStateChange(); 00237 } 00238 else if( nC == "@@GainmodeTcl" ) { 00239 uiMode = tcl_mode; 00240 G4cout << G4endl << "@@Version " << TVersion << G4endl; 00241 SendCommandProperties(tree); 00242 NotifyStateChange(); 00243 } 00244 else if( nC(0) == '#' ) 00245 { G4cout << nC << G4endl; } 00246 00247 else if( nC == "ls" || nC(0,3) == "ls " ) 00248 { ListDirectory( nC ); } 00249 else if( nC == "pwd" ) 00250 { G4cout << "Current Working Directory : " << prefix << G4endl; } 00251 else if( nC(0,2) == "cd" || nC(0,3) == "cd " ) 00252 { ChangeDirectory( nC ); } 00253 else if( nC == "help" || nC(0,5) == "help ") 00254 { TerminalHelp( nC ); } 00255 else if( nC(0) == '?' ) 00256 { ShowCurrent( nC ); } 00257 else if( nC(0,4) == "hist" || nC == "history") 00258 { 00259 G4int nh = UI->GetNumberOfHistory(); 00260 for(int i=0;i<nh;i++) 00261 { G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl; } 00262 } 00263 else if( nC(0) == '!' ) 00264 { 00265 G4String ss = nC(1,nC.length()-1); 00266 G4int vl; 00267 const char* tt = ss; 00268 std::istringstream is((char*)tt); 00269 is >> vl; 00270 G4int nh = UI->GetNumberOfHistory(); 00271 if(vl>=0 && vl<nh) 00272 { 00273 newCommand = UI->GetPreviousCommand(vl); 00274 G4cout << newCommand << G4endl; 00275 break; 00276 } 00277 else 00278 { G4cerr << "history " << vl << " is not found." << G4endl; } 00279 } 00280 else if( nC(0,4) == "exit" ) 00281 { 00282 if( iCont ) 00283 { 00284 if ( uiMode == terminal_mode){ 00285 G4cerr << "You are now processing RUN." << G4endl; 00286 G4cerr << "Please abrot it using \"/run/abort\" command first" << G4endl; 00287 G4cerr << " and use \"continue\" command until the application" << G4endl; 00288 G4cerr << " becomes to Idle." << G4endl; 00289 }else{ 00290 G4cout << "@@ErrResult \"You are now processing RUN.\"" << G4endl; 00291 } 00292 } 00293 else 00294 { 00295 close(socketD[1]); 00296 close(socketD[2]); 00297 iExit = false; 00298 newCommand = nullString; 00299 break; 00300 } 00301 } 00302 else if( nC == "cont" || nC == "continue" ) 00303 { 00304 iCont = false; 00305 newCommand = nullString; 00306 break; 00307 } 00308 else 00309 { break; } 00310 } 00311 return GetFullPath(newCommand); 00312 } |
Here is the call graph for this function:
|
Referenced by GetCommand(), and WaitingConnection(). |
|
Implements G4VBasicShell. Definition at line 349 of file G4UIGainServer.cc.
00351 { 00352 G4cin >> aInt; 00353 if(!G4cin.good()){ 00354 G4cin.clear(); 00355 G4cin.ignore(30,'\n'); 00356 return FALSE; 00357 } 00358 return TRUE; 00359 } |
|
Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Reimplemented from G4VBasicShell. Referenced by GetCommand(), and WaitingConnection(). |
|
Referenced by WaitingConnection(). |
|
Referenced by ExecuteCommand(), and WaitingConnection(). |
|
Referenced by WaitingConnection(). |
|
Referenced by GetCommand(), and WaitingConnection(). |
|
Implements G4VBasicShell. Definition at line 114 of file G4UIGainServer.cc. References buf, ExecuteCommand(), GetCommand(), iCont, promptCharacter, and socketD.
00116 { 00117 promptCharacter = msg; 00118 G4cout<<"@@PROMPT \""<<promptCharacter<<"\""<<G4endl; 00119 00120 iCont= TRUE; 00121 00122 G4String newCommand= GetCommand(); 00123 while(iCont){ 00124 ExecuteCommand(newCommand); 00125 newCommand= GetCommand(); 00126 strcpy(buf,"nowIdle"); 00127 write(socketD[1],buf,strlen(buf)); 00128 } 00129 } |
Here is the call graph for this function:
|
|
|
Definition at line 334 of file G4UIGainServer.cc. References socketD.
00336 { 00337 if(socketD[2]>0){ 00338 write(socketD[2],cerrString,cerrString.length()); 00339 } 00340 return 0; 00341 00342 00343 00344 //std::cerr << cerrString << std::flush; 00345 //return 0; 00346 } |
|
Definition at line 315 of file G4UIGainServer.cc. References socketD.
00317 { 00318 if(socketD[1]>0){ 00319 write(socketD[1],coutString,coutString.length()); 00320 } 00321 return 0; 00322 00323 00324 00325 00326 00327 00328 00329 //std::cout << coutString << std::flush; 00330 //return 0; 00331 } |
|
Referenced by WaitingConnection(). |
|
|
|
Referenced by GetCommand(), and WaitingConnection(). |
|
Referenced by WaitingConnection(). |
|
Referenced by WaitingConnection(). |
|
Implements G4VBasicShell. Definition at line 95 of file G4UIGainServer.cc. References ExecuteCommand(), GetCommand(), iExit, promptCharacter, and WaitingConnection().
00097 { 00098 G4String newCommand; 00099 00100 G4StateManager* statM = G4StateManager::GetStateManager(); 00101 promptCharacter = statM->GetStateString(statM->GetCurrentState()); 00102 00103 iExit= TRUE; 00104 00105 WaitingConnection(); 00106 while(iExit){ 00107 newCommand= GetCommand(); 00108 ExecuteCommand(newCommand); 00109 } 00110 return NULL; 00111 } |
Here is the call graph for this function:
|
Referenced by WaitingConnection(). |
|
Definition at line 370 of file G4UIGainServer.cc. References port, saddr, and socketD. Referenced by G4UIGainServer().
00370 { 00372 00373 socketD[0] = socket(AF_INET,SOCK_STREAM,0); 00374 00375 if(socketD[0]<0){ 00376 perror("server:socket"); 00377 return (false); 00378 //exit(1); 00379 } 00380 00381 memset( (char *)&saddr,'\0',sizeof(saddr)) ; 00382 00383 saddr.sin_family = AF_INET; 00384 saddr.sin_addr.s_addr = INADDR_ANY; 00385 saddr.sin_port = htons(port); 00386 unlink(SOCK_NAME); 00387 00388 if(bind(socketD[0] , (struct sockaddr *)&saddr , sizeof(saddr))<0){ 00389 perror("bind"); 00390 return (false); 00391 //exit(1); 00392 } 00393 else{ G4cout<<"G4GainServer waiting at "<<port<<G4endl; } 00394 00395 if(listen(socketD[0],1)<0){ 00396 perror("listen"); 00397 return (false); 00398 //exit(1); 00399 } 00400 00401 return (true); 00402 } |
|
Reimplemented from G4VBasicShell. Referenced by GetCommand(), and WaitingConnection(). |
|
Reimplemented from G4VBasicShell. Referenced by GetCommand(), and WaitingConnection(). |
|
Referenced by ExecuteCommand(), and WaitingConnection(). |
|
Referenced by ExecuteCommand(), and WaitingConnection(). |
|
Here is the call graph for this function:
|
Definition at line 88 of file G4UIGainServer.hh. Referenced by GetCommand(), and PauseSessionStart(). |
|
Definition at line 85 of file G4UIGainServer.hh. Referenced by WaitingConnection(). |
|
Definition at line 79 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), GetCommand(), and PauseSessionStart(). |
|
Definition at line 78 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), GetCommand(), and SessionStart(). |
|
Definition at line 71 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), and GetCommand(). |
|
Definition at line 86 of file G4UIGainServer.hh. Referenced by WaitingConnection(). |
|
Definition at line 95 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Definition at line 97 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Definition at line 99 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Definition at line 83 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), and SetUPServer(). |
|
Definition at line 67 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), GetCommand(), and WaitingConnection(). |
|
Definition at line 94 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Definition at line 96 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), and WaitingConnection(). |
|
Definition at line 98 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), and G4UIGainServer(). |
|
Definition at line 68 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), GetCommand(), PauseSessionStart(), and SessionStart(). |
|
Definition at line 87 of file G4UIGainServer.hh. |
|
Definition at line 84 of file G4UIGainServer.hh. Referenced by SetUPServer(). |
|
Definition at line 82 of file G4UIGainServer.hh. Referenced by GetCommand(), PauseSessionStart(), ReceiveG4cerr(), ReceiveG4cout(), SetUPServer(), and WaitingConnection(). |
|
Definition at line 72 of file G4UIGainServer.hh. Referenced by G4UIGainServer(), and GetCommand(). |
|
Definition at line 69 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), GetCommand(), WaitingConnection(), and ~G4UIGainServer(). |
|
Definition at line 70 of file G4UIGainServer.hh. Referenced by ExecuteCommand(), G4UIGainServer(), GetCommand(), and WaitingConnection(). |