Changeset 10864
- Timestamp:
- 05/27/11 14:18:07 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fad.cc
r10862 r10864 29 29 { 30 30 private: 31 const int fBoardId; 31 32 32 33 double fStartTime; … … 54 55 55 56 // The constructor is prvate to force the obtained pointer to be shared 56 tcp_connection(ba::io_service& ioservice ) : ba::ip::tcp::socket(ioservice),57 f TriggerSendData(ioservice)57 tcp_connection(ba::io_service& ioservice, int boardid) : ba::ip::tcp::socket(ioservice), 58 fBoardId(boardid), fTriggerSendData(ioservice) 58 59 { 59 60 } … … 199 200 case kCmdRun: 200 201 case kCmdRun+0x100: 202 fStartTime = Time(Time::utc).UnixTime(); 201 203 cout << "-> Run" << endl; 202 204 break; … … 278 280 typedef boost::shared_ptr<tcp_connection> shared_ptr; 279 281 280 static shared_ptr create(ba::io_service& io_service )281 { 282 return shared_ptr(new tcp_connection(io_service ));282 static shared_ptr create(ba::io_service& io_service, int boardid) 283 { 284 return shared_ptr(new tcp_connection(io_service, boardid)); 283 285 } 284 286 … … 292 294 fHeader.fStartDelimiter = FAD::kDelimiterStart; 293 295 fHeader.fVersion = 0x104; 296 fHeader.fBoardId = (fBoardId%10) | ((fBoardId/10)<<8); 294 297 fHeader.fStatus = 0xf<<12 | 295 298 FAD::EventHeader::kDenable | … … 345 348 tcp::acceptor acc7; 346 349 347 int f Port;350 int fBoardId; 348 351 349 352 public: 350 tcp_server(ba::io_service& ioservice, int port ) :353 tcp_server(ba::io_service& ioservice, int port, int board) : 351 354 acc0(ioservice, tcp::endpoint(tcp::v4(), port)), 352 355 acc1(ioservice, tcp::endpoint(tcp::v4(), port+1)), … … 357 360 acc6(ioservice, tcp::endpoint(tcp::v4(), port+6)), 358 361 acc7(ioservice, tcp::endpoint(tcp::v4(), port+7)), 359 f Port(port)362 fBoardId(board) 360 363 { 361 364 // We could start listening for more than one connection … … 382 385 { 383 386 cout << "Start accept " << acc0.local_endpoint().port() << "..." << flush; 384 tcp_connection::shared_ptr new_connection = tcp_connection::create(/*acceptor_.*/acc0.io_service() );387 tcp_connection::shared_ptr new_connection = tcp_connection::create(/*acceptor_.*/acc0.io_service(), fBoardId); 385 388 386 389 // This will accept a connection without blocking … … 423 426 int main(int argc, const char **argv) 424 427 { 425 try428 //try 426 429 { 427 430 ba::io_service io_service; … … 434 437 for (int i=0; i<n; i++) 435 438 { 436 shared_ptr<tcp_server> server(new tcp_server(io_service, port ));439 shared_ptr<tcp_server> server(new tcp_server(io_service, port, i)); 437 440 servers.push_back(server); 438 441 … … 450 453 //cout << "end." << endl; 451 454 } 452 catch (std::exception& e)455 /*catch (std::exception& e) 453 456 { 454 457 std::cerr << e.what() << std::endl; 455 } 458 }*/ 456 459 457 460 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.