- Timestamp:
- 06/03/12 20:21:39 (12 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/RemoteControl.cc
r10493 r14050 23 23 { 24 24 fCurrentServer = s; 25 return false;25 return true; 26 26 } 27 27 lout << kRed << "Unkown server '" << s << "'" << endl; 28 return true;28 return false; 29 29 } 30 30 … … 32 32 { 33 33 fCurrentServer = ""; 34 return false;34 return true; 35 35 } 36 36 37 return !SendDimCommand(lout, fCurrentServer, str);37 return SendDimCommand(lout, fCurrentServer, str); 38 38 } 39 39 -
trunk/FACT++/src/RemoteControl.h
r13939 r14050 1 1 #ifndef FACT_RemoteControl 2 2 #define FACT_RemoteControl 3 4 #include "InterpreterV8.h" 3 5 4 6 // ************************************************************************** … … 59 61 60 62 template <class T> 61 class RemoteControl : public T, public RemoteControlImp 63 class RemoteControl : public T, public RemoteControlImp, public InterpreterV8 62 64 { 63 65 private: … … 135 137 T::UpdatePrompt(); 136 138 } 139 140 // =========================================================================== 141 142 virtual void JsLoad(const std::string &) { SetSection(-2); } 143 virtual void JsStart(const std::string &) { SetSection(-1); } 144 virtual void JsEnd(const std::string &) { SetSection(-3); } 145 virtual bool JsSend(const std::string &str) { return ProcessCommand(str); } 146 virtual void JsPrint(const std::string &msg) { fImp->Comment(msg); } 147 virtual void JsException(const std::string &str) { fImp->Error(str); } 148 149 void JsSleep(uint32_t ms) 150 { 151 const Time timeout = ms<=0 ? Time(Time::none) : Time()+boost::posix_time::millisec(ms); 152 153 T::GetStreamOut().Display(true); 154 T::GetStreamOut().SetBacklog(false); 155 T::GetStreamOut().SetNullOutput(false); 156 while (timeout>Time() && !T::IsScriptStopped()) 157 usleep(1); 158 T::GetStreamOut().SetNullOutput(true); 159 T::GetStreamOut().SetBacklog(true); 160 } 161 162 int JsWait(const string &server, int32_t state, uint32_t ms) 163 { 164 const ClientList::const_iterator l = fClientList.find(server); 165 if (l==fClientList.end()) 166 { 167 lout << kRed << "Server '" << server << "' not found." << endl; 168 T::StopScript(); 169 return -1; 170 } 171 172 const Time timeout = ms<=0 ? Time(Time::none) : Time()+boost::posix_time::millisec(ms); 173 174 T::GetStreamOut().Display(true); 175 T::GetStreamOut().SetBacklog(false); 176 T::GetStreamOut().SetNullOutput(false); 177 while (l->second->GetState()!=state && timeout>Time() && !T::IsScriptStopped()) 178 usleep(1); 179 T::GetStreamOut().SetNullOutput(true); 180 T::GetStreamOut().SetBacklog(true); 181 182 return l->second->GetState()==state; 183 } 184 185 186 // =========================================================================== 187 137 188 138 189 public: … … 196 247 } 197 248 249 if (str.substr(0, 4)==".js ") 250 { 251 JsRun(Tools::Trim(str.substr(3))); 252 return true; 253 } 254 198 255 if (str.substr(0, 3)==".s ") 199 256 { … … 210 267 } 211 268 212 const ClientList::const_iterator l = fClientList.find(server); 213 if (l==fClientList.end()) 214 { 215 lout << kRed << "Server '" << server << "' not found." << endl; 216 return true; 217 } 218 219 const Time timeout = ms<=0 ? Time(Time::none) : Time()+boost::posix_time::millisec(ms); 220 221 T::GetStreamOut().Display(true); 222 T::GetStreamOut().SetBacklog(false); 223 T::GetStreamOut().SetNullOutput(false); 224 while (l->second->GetState()!=state && timeout>Time() && !T::IsScriptStopped()) 225 usleep(1); 226 T::GetStreamOut().SetNullOutput(true); 227 T::GetStreamOut().SetBacklog(true); 228 229 if (l->second->GetState()==state) 269 const int rc = JsWait(server, state, ms); 270 271 if (rc<0 || rc==1) 230 272 return true; 231 273 … … 267 309 } 268 310 269 return ProcessCommand(str);311 return !ProcessCommand(str); 270 312 } 271 313
Note:
See TracChangeset
for help on using the changeset viewer.