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

Definition at line 84 of file LocalControl.h.

85  {
86  if (str.substr(0, 2)=="h " || str.substr(0, 5)=="help ")
87  {
88  lout << endl;
89  fStateMachine->PrintListOfEvents(lout, str.substr(str.find_first_of(' ')+1));
90  lout << endl;
91 
92  return true;
93  }
94  if (str=="states" || str=="st")
95  {
97  return true;
98  }
99  if (str=="allowed" || str=="ac")
100  {
101  lout << endl << kBold << "List of commands allowed in current state:" << endl;
103  lout << endl;
104  return true;
105  }
106 
107  if (str.substr(0, 3)==".s ")
108  {
109  istringstream in(str.substr(3));
110 
111  int state=-100, ms=0;
112  in >> state >> ms;
113 
114  if (state==-100)
115  {
116  lout << kRed << "Couldn't parse state id in '" << str.substr(3) << "'" << endl;
117  return true;
118  }
119 
120  const Time timeout = ms<=0 ? Time(Time::none) : Time()+boost::posix_time::millisec(ms);
121 
122  while (fStateMachine->GetCurrentState()!=state && timeout>Time() && !T::IsScriptStopped())
123  usleep(1);
124 
125  if (fStateMachine->GetCurrentState()==state)
126  return true;
127 
128  int label = -1;
129  in >> label;
130  if (in.fail() && !in.eof())
131  {
132  lout << kRed << "Invalid label in '" << str.substr(3) << "'" << endl;
133  T::StopScript();
134  return true;
135  }
136  T::SetLabel(label);
137 
138  return true;
139  }
140 
141  if (str[0]=='>')
142  {
143  fStateMachine->Comment(Tools::Trim(str.substr(1)));
144  return true;
145  }
146 
147  if (T::Process(str))
148  return true;
149 
150  return !fStateMachine->PostEvent(lout, str);
151  }
int Comment(const std::string &str)
Definition: MessageImp.h:52
void PrintListOfStates(std::ostream &out) const
std::ostream & lout
Definition: LocalControl.h:46
int GetCurrentState() const
return the current state of the machine
bool PostEvent(std::ostream &lout, const std::string &str)
Post an event to the event queue.
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
Set color Red.
Definition: WindowLog.h:17
StateMachineImp * fStateMachine
Definition: LocalControl.h:44
bool Process(std::ostream &out, const std::string &str)
void PrintListOfEvents(std::ostream &out, const std::string &evt="")
void PrintListOfAllowedEvents(std::ostream &out)
std::string Trim(const std::string &str)
Definition: tools.cc:68
Do not initialize the time.
Definition: Time.h:51
Set attribute Bold.
Definition: WindowLog.h:36