Changeset 10269
- Timestamp:
- 03/30/11 15:40:20 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/dclient5.cc
r10230 r10269 35 35 36 36 public: 37 void ConnectImp(const bs::error_code& error, 38 tcp::resolver::iterator endpoint_iterator) 39 { 40 Connection::ConnectImp(error, endpoint_iterator); 41 if (IsConnected()) 42 StartAsyncRead(); 37 void ConnectionEstablished() 38 { 39 StartAsyncRead(); 43 40 } 44 41 … … 78 75 } 79 76 80 void HandleReceivedData(const bs::error_code& error, size_t bytes_received )77 void HandleReceivedData(const bs::error_code& error, size_t bytes_received, int type) 81 78 { 82 79 // Do not schedule a new read if the connection failed. … … 185 182 kSM_Stopping, 186 183 kSM_Reconnect, 184 kSM_SetUrl, 187 185 }; 188 186 … … 211 209 c9(*this, *this), fTimers(out) 212 210 { 213 c1.SetEndpoint("localhost", 5000);211 // c1.SetEndpoint(); 214 212 c2.SetEndpoint("localhost", 4001); 215 213 c3.SetEndpoint("ftmboard1.ethz.ch", 5000); … … 231 229 c9.SetLogStream(this); 232 230 233 c1. AsyncConnect(); // This sets the connection to "open"234 c2. AsyncConnect(); // This sets the connection to "open"235 c3. AsyncConnect(); // This sets the connection to "open"236 //c4. AsyncConnect(); // This sets the connection to "open"237 //c5. AsyncConnect(); // This sets the connection to "open"238 //c6. AsyncConnect(); // This sets the connection to "open"239 //c7. AsyncConnect(); // This sets the connection to "open"240 //c8. AsyncConnect(); // This sets the connection to "open"241 //c9. AsyncConnect(); // This sets the connection to "open"231 c1.StartConnect(); // This sets the connection to "open" 232 c2.StartConnect(); // This sets the connection to "open" 233 c3.StartConnect(); // This sets the connection to "open" 234 //c4.StartConnect(); // This sets the connection to "open" 235 //c5.StartConnect(); // This sets the connection to "open" 236 //c6.StartConnect(); // This sets the connection to "open" 237 //c7.StartConnect(); // This sets the connection to "open" 238 //c8.StartConnect(); // This sets the connection to "open" 239 //c9.StartConnect(); // This sets the connection to "open" 242 240 243 241 AddStateName(kSM_Disconnected, "Disconnected"); … … 256 254 AddConfiguration("LED", kSM_Connected); 257 255 258 T::AddConfiguration("MYT", "I:1;C:5;I"); 259 T::AddConfiguration("TESTI", "I"); 260 T::AddConfiguration("TESTI:5", "I:5"); 261 T::AddConfiguration("TESTI:5;F:1;D:2", "I:5;F:1;D:2"); 262 T::AddConfiguration("TESTC", "C"); 263 T::AddConfiguration("TESTI:5;C", "I:5;C"); 256 T::AddConfiguration("TESTI", "I"); 257 T::AddConfiguration("TESTI2", "I:2"); 258 T::AddConfiguration("TESTIF", "I:2;F:2"); 259 T::AddConfiguration("TESTIC", "I:2;C"); 260 261 T::AddConfiguration("CMD", "C") 262 ->AssignFunction(boost::bind(&StateMachineFAD::Command, this, _1)); 264 263 265 264 AddTransition(kSM_Reconnect, "RECONNECT"); 266 265 266 AddTransition(kSM_SetUrl, "SETURL", "C"); 267 267 268 T::PrintListOfEvents(); 268 269 } 269 270 271 int Command(const EventImp &evt) 272 { 273 string cmd = evt.GetText(); 274 275 size_t p0 = cmd.find_first_of(' '); 276 if (p0==string::npos) 277 p0 = cmd.length(); 278 279 T::Out() << "\nCommand: '" << cmd.substr(0, p0) << "'" << cmd.substr(p0)<< "'" << endl; 280 /* 281 const Converter c(T::Out(), "B:5;I:2;F;W;O;C", "yes no false 0 1 31 42 11.12 \"test hallo\" "); 282 283 T::Out() << c.GetRc() << endl; 284 T::Out() << c.N() << endl; 285 T::Out() << c.Get<bool>(0) << endl; 286 T::Out() << c.Get<bool>(1) << endl; 287 T::Out() << c.Get<bool>(2) << endl; 288 T::Out() << c.Get<bool>(3) << endl; 289 T::Out() << c.Get<bool>(4) << endl; 290 T::Out() << c.Get<int>(5) << endl; 291 T::Out() << c.Get<int>(6) << endl; 292 T::Out() << c.Get<float>(7) << endl; 293 T::Out() << c.Get<int>(7) << endl; 294 T::Out() << c.Get<string>(8) << endl; 295 T::Out() << c.Get<string>(9) << endl; 296 T::Out() << c.Get<string>(10) << endl; 297 */ 298 return T::GetCurrentState(); 299 } 270 300 int Start(const EventImp &evt, int i) 271 301 { … … 336 366 switch (evt.GetTargetState()) 337 367 { 368 case kSM_SetUrl: 369 T::Out() << evt.GetText() << endl; 370 c1.SetEndpoint(evt.GetText()); 371 return T::GetCurrentState(); 338 372 case kSM_Reconnect: 339 373 // Close all connections
Note:
See TracChangeset
for help on using the changeset viewer.