56 UI-> SetSession(
this);
57 UI-> SetCoutDestination(
this);
81 UI-> SetSession(NULL);
82 UI-> SetCoutDestination(NULL);
124 strcpy(
buf,
"nowIdle");
134 if(aCommand.length()<2)
return;
137 if(aCommand.length()<2)
return;
139 G4int paramIndex = returnVal % 100;
142 G4int commandStatus = returnVal - paramIndex;
147 switch(commandStatus) {
164 G4cerr <<
"@@ErrResult \"illegal application state -- command refused.\"" <<
G4endl;
167 G4cout <<
"@@ErrResult \"Parameter Out of Range.\"" <<
G4endl;
170 G4cout <<
"@@ErrResult \"Parameter is wrong type and/or is not omittable.\""<<
G4endl;
173 G4cerr <<
"@@ErrResult \"Parameter is out of candidate.\"" <<
G4endl;
177 G4cerr <<
"command refused (" << commandStatus <<
")" <<
G4endl;
214 if (!
G4cin.good()) {
G4cin.clear(); newCommand = nullString;
iExit=
false;
break;}
217 if( newCommand.length() < 1) {
break; }
219 while( newCommand(newCommand.length()-1) ==
'_' )
222 newCommand.
remove(newCommand.length()-1);
224 if (!
G4cin.good()) {
G4cin.clear(); newCommand = nullString;
iExit=
false;
break;}
225 newCommand.
append(newLine);
229 if( nC.length() < 1) {
break; }
232 if( nC ==
"@@GainmodeJAVA" ) {
238 else if( nC ==
"@@GainmodeTcl" ) {
244 else if( nC(0) ==
'#' )
247 else if( nC ==
"ls" || nC(0,3) ==
"ls " )
249 else if( nC ==
"pwd" )
251 else if( nC(0,2) ==
"cd" || nC(0,3) ==
"cd " )
253 else if( nC ==
"help" || nC(0,5) ==
"help ")
255 else if( nC(0) ==
'?' )
257 else if( nC(0,4) ==
"hist" || nC ==
"history")
260 for(
int i=0;i<nh;i++)
263 else if( nC(0) ==
'!' )
268 std::istringstream is((
char*)tt);
278 {
G4cerr <<
"history " << vl <<
" is not found." <<
G4endl; }
280 else if( nC(0,4) ==
"exit" )
286 G4cerr <<
"Please abort it using \"/run/abort\" command first" <<
G4endl;
287 G4cerr <<
" and use \"continue\" command until the application" <<
G4endl;
290 G4cout <<
"@@ErrResult \"You are now processing RUN.\"" <<
G4endl;
298 newCommand = nullString;
302 else if( nC ==
"cont" || nC ==
"continue" )
305 newCommand = nullString;
319 ssize_t rc = write(
socketD[1],coutString,coutString.length());
333 ssize_t rc = write(
socketD[2],cerrString,cerrString.length());
349 G4cin.ignore(30,
'\n');
360 G4cin.getline(temp, 100);
370 perror(
"server:socket");
377 saddr.sin_family = AF_INET;
378 saddr.sin_addr.s_addr = INADDR_ANY;
403 for(
int i=1;i<=2;i++){
404 #if defined __APPLE__ && (__GNUC__<4)
414 "Invalid Socket. Cannot establish connection");
425 if( newCommand(0) ==
'/' )
426 { tmpString = newCommand; }
427 else if( newCommand(0,3) ==
"../" )
430 unsigned i_direc = 0;
431 while( i_direc < newCommand.length() )
433 if( newCommand(i_direc,3) ==
"../" )
442 tmpString.
append( newCommand( i_direc, newCommand.length()-i_direc ) );
448 tmpString.
append( newCommand );
465 if( ! (curV.
isNull()||curV(0)==
'\0' ) ) {
467 G4cout <<
"Current value(s) of the parameter(s) : " << curV <<
G4endl;
474 G4cout <<
"@@ErrResult \"Current value is not available.\"" <<
G4endl;
482 if( newCommand.length() <= 3 )
486 G4String aNewPrefix = newCommand(3,newCommand.length()-3);
488 if( newPrefix(0) ==
'/' )
490 else if( newPrefix(0) !=
'.' )
509 if( newCommand.length() <= 3 )
513 G4String newPrefix = newCommand(3,newCommand.length()-3);
515 if( newPrefix(0) ==
'/' )
516 { targetDir = newPrefix; }
517 else if( newPrefix(0) !=
'.' )
520 targetDir += newPrefix;
525 if( targetDir( targetDir.length() - 1 ) !=
'/' )
526 { targetDir +=
"/"; }
528 if( commandTree == NULL )
529 {
G4cout <<
"Directory <" << targetDir <<
"> is not found." <<
G4endl; }
540 if(i!=std::string::npos){
541 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
543 if(newValue(0)!=
'/'){
547 if(theCommand !=NULL){
552 G4cout<<
"Command<" << newValue <<
"is not found."<<
G4endl;
560 unsigned prefixIndex = 1;
561 while(prefixIndex<
prefix.length()-1){
562 int ii =
prefix.index(
"/",prefixIndex);
571 G4cout<<
G4endl <<
"Type the number (0:end, -n:n level back) :"<<std::flush;
575 G4cin.ignore(30,
'\n');
580 if(iFloor <0) iFloor =0;
583 else if(j==0){
break;}
587 if(j<=n_tree+floor[iFloor]->GetCommandEntry()){
592 floor[iFloor+1] = floor[iFloor]->
GetTree(j);
601 G4cin.getline(temp,100);
610 if(newCommand(0,2) ==
".."){
612 G4String tmpString = newPrefix(0,newPrefix.length()-1);
613 newPrefix = newPrefix(0,tmpString.
last(
'/')+1);
617 newPrefix += newCommand;
620 if(newCommand ==
".." || newCommand ==
"../"){
623 newCommand=newCommand(3,newCommand.length()-3);
633 while( idx < newCommand.length()-1 )
635 int i = newCommand.
index(
"/",idx);
637 if( comTree == NULL )
676 int treeEntry, commandEntry;
681 for(
int i=0; i<commandEntry; i++){
685 if(treeEntry == 0)
return;
687 for(
int j=0; j<treeEntry; j++){
695 int treeEntry,commandEntry,i;
701 for(i=0;i<commandEntry; i++){
704 if(treeEntry ==0)
return;
706 for(i=0;i<treeEntry; i++){
718 int guidanceEntry, parameterEntry;
727 for (
int j=0; j<guidanceEntry; j++){
731 for(
int i=0; i< (
int)title.length(); i++){
734 if ( c[0] ==
'\n' || c[0] ==
'\r') {
744 for(
int par=0; par<parameterEntry; par++) {
760 int treeEntry, commandEntry;
765 for(
int com=0; com<commandEntry; com++) {
771 if( treeEntry == 0 )
return;
773 for(
int i=0; i<treeEntry; i++) {
791 if( newState != previousState )
794 previousState = newState;
807 G4cout <<
"@@State \"" << stateString <<
"\"" <<
G4endl;
836 for( i=0; i<pEntry; i++) {
837 for( j=0; j<nEntry; j++) {
845 for( i=0; i<nEntry; i++) {
846 for( j=0; j<pEntry; j++) {
871 for(
int com=0; com<commandEntry; com++){
877 if(treeEntry == 0)
return;
879 for(
int i=0; i< treeEntry; i++){
898 if (pEntry != nEntry)
return;
899 for( i=0; i<nEntry; i++) {
903 <<
" command is updated." <<
G4endl;
923 for(
int com=0; com<commandEntry; com++) {
927 param = commandPath +
" ";
928 for(
int par=0; par< parameterEntry; par++) {
940 if( treeEntry == 0 )
return;
941 for(
int i=0; i< treeEntry; i++) {