FACT++  1.0
template<class T>
int RemoteControl< T >::JsWait ( const string &  server,
int32_t  state,
uint32_t  ms 
)
inlineprotected

Definition at line 212 of file RemoteControl.h.

213  {
214  if (!fImp)
215  {
216  lout << kRed << "RemoteControl class not fully initialized." << endl;
217  T::StopScript();
218  return -1;
219  }
220 
221  if (!HasServer(server))
222  {
223  lout << kRed << "Server '" << server << "' not found." << endl;
224  T::StopScript();
225  return -1;
226  }
227 
228  T::Lock();
229 
230  const Time timeout = ms<=0 ? Time(Time::none) : Time()+boost::posix_time::millisec(ms);
231 
232  int rc = 0;
233  do
234  {
235  State st = fImp->GetServerState(server);
236  if (st.index==-256)
237  {
238  lout << kRed << "Server '" << server << "' disconnected." << endl;
239  T::StopScript();
240  return -1;
241  }
242  if (st.index==state)
243  {
244  rc = 1;
245  break;
246  }
247 
248  usleep(1);
249  }
250  while (timeout>Time() && !T::IsScriptStopped());
251 
252  T::Unlock();
253 
254  return rc;
255  }
bool HasServer(const std::string &server)
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
Set color Red.
Definition: WindowLog.h:17
StateMachineDimControl * fImp
Definition: RemoteControl.h:70
int index
Definition: State.h:11
std::ostream & lout
Output stream for local synchrounous output.
Definition: RemoteControl.h:26
State GetServerState(const std::string &server)
Do not initialize the time.
Definition: Time.h:51