FACT++  1.0
template<class T>
bool RemoteControl< T >::Process ( const std::string &  str)
inline

Definition at line 405 of file RemoteControl.h.

406  {
407  if (str.substr(0, 2)=="h " || str.substr(0, 5)=="help ")
408  {
409  const size_t p1 = str.find_first_of(' ');
410  const string svc = str.substr(p1+1);
411 
412  const size_t p3 = svc.find_first_of('/');
413  const string s = svc.substr(0, p3);
414  const string c = p3==string::npos?"":svc.substr(p3+1);
415 
416  lout << endl;
417  if (!fCurrentServer.empty())
418  {
419  if (PrintDescription(lout, true, fCurrentServer, svc)==0)
420  lout << " " << svc << ": <not found>" << endl;
421  }
422  else
423  {
424  if (PrintDescription(lout, true, s, c)==0)
425  lout << " <no matches found>" <<endl;
426  }
427 
428  return true;
429  }
430 
431  if (str.substr(0, 4)==".js ")
432  {
433  string opt(str.substr(4));
434 
435  map<string,string> data = Tools::Split(opt, true);
436  if (opt.size()==0)
437  {
438  if (data.size()==0)
439  lout << kRed << "JavaScript filename missing." << endl;
440  else
441  lout << kRed << "Equal sign missing in argument '" << data.begin()->first << "'" << endl;
442 
443  return true;
444  }
445 
446  T::fScript = opt;
447 
448  T::Lock();
449  JsRun(opt, data);
450  T::Unlock();
451 
452  return true;
453  }
454 
455  if (str==".java" && !StateMachineDimControl::fIsServer)
456  {
457  T::fScript = "java";
458 
459  T::Lock();
460  JsRun("");
461  T::Unlock();
462 
463  T::fScript = "";
464 
465  return true;
466  }
467 
468  if (str.substr(0, 3)==".s ")
469  {
470  istringstream in(str.substr(3));
471 
472  int state=-100, ms=0;
473  string server;
474 
475  in >> server >> state >> ms;
476  if (state==-100)
477  {
478  lout << kRed << "Couldn't parse state id in '" << str.substr(3) << "'" << endl;
479  return true;
480  }
481 
482  T::Lock();
483  const int rc = JsWait(server, state, ms);
484  T::Unlock();
485 
486  if (rc<0 || rc==1)
487  return true;
488 
489  int label = -1;
490  in >> label;
491  if (in.fail() && !in.eof())
492  {
493  lout << kRed << "Invalid label in '" << str.substr(3) << "'" << endl;
494  T::StopScript();
495  return true;
496  }
497  T::SetLabel(label);
498 
499  return true;
500  }
501 
502  if (str[0]=='>')
503  {
504  fImp->Comment(Tools::Trim(str.substr(1)));
505  return true;
506  }
507 
509  return true;
510 
511  if (T::Process(str))
512  return true;
513 
514  if (str=="services" || str=="svc")
515  {
516  PrintDescription(lout, false);
517  return true;
518  }
519 
520  if (str=="states" || str=="st")
521  {
522  PrintStates(lout);
523  return true;
524  }
525 
526  return !ProcessCommand(str);
527  }
int Comment(const std::string &str)
Definition: MessageImp.h:52
char str[80]
Definition: test_client.c:7
Set color Red.
Definition: WindowLog.h:17
StateMachineDimControl * fImp
Definition: RemoteControl.h:70
int JsWait(const string &server, int32_t state, uint32_t ms)
std::ostream & lout
Output stream for local synchrounous output.
Definition: RemoteControl.h:26
bool ProcessCommand(const std::string &str, bool change=true)
Definition: RemoteControl.cc:5
bool JsRun(const std::string &, const std::map< std::string, std::string > &=std::map< std::string, std::string >())
std::string fCurrentServer
Output stream for local synchrounous output.
Definition: RemoteControl.h:28
std::map< std::string, std::string > Split(std::string &, bool=false)
Definition: tools.cc:230
int PrintDescription(std::ostream &out, bool iscmd, const std::string &serv="", const std::string &service="") const
bool Process(std::ostream &out, const std::string &str)
float data[4 *1440]
std::string Trim(const std::string &str)
Definition: tools.cc:68
int PrintStates(std::ostream &out, const std::string &serv="") const