Changeset 10864 for trunk/FACT++


Ignore:
Timestamp:
05/27/11 14:18:07 (13 years ago)
Author:
tbretz
Message:
Don't catch exceptions in main; propagare continous number as board id.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fad.cc

    r10862 r10864  
    2929{
    3030private:
     31    const int fBoardId;
    3132
    3233    double   fStartTime;
     
    5455
    5556    // 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         fTriggerSendData(ioservice)
     57    tcp_connection(ba::io_service& ioservice, int boardid) : ba::ip::tcp::socket(ioservice),
     58        fBoardId(boardid), fTriggerSendData(ioservice)
    5859    {
    5960    }
     
    199200            case kCmdRun:
    200201            case kCmdRun+0x100:
     202                fStartTime = Time(Time::utc).UnixTime();
    201203                cout << "-> Run" << endl;
    202204                break;
     
    278280    typedef boost::shared_ptr<tcp_connection> shared_ptr;
    279281
    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));
    283285    }
    284286
     
    292294        fHeader.fStartDelimiter = FAD::kDelimiterStart;
    293295        fHeader.fVersion = 0x104;
     296        fHeader.fBoardId = (fBoardId%10) | ((fBoardId/10)<<8);
    294297        fHeader.fStatus = 0xf<<12 |
    295298            FAD::EventHeader::kDenable    |
     
    345348    tcp::acceptor acc7;
    346349
    347     int fPort;
     350    int fBoardId;
    348351
    349352public:
    350     tcp_server(ba::io_service& ioservice, int port) :
     353    tcp_server(ba::io_service& ioservice, int port, int board) :
    351354        acc0(ioservice, tcp::endpoint(tcp::v4(), port)),
    352355        acc1(ioservice, tcp::endpoint(tcp::v4(), port+1)),
     
    357360        acc6(ioservice, tcp::endpoint(tcp::v4(), port+6)),
    358361        acc7(ioservice, tcp::endpoint(tcp::v4(), port+7)),
    359         fPort(port)
     362        fBoardId(board)
    360363    {
    361364        // We could start listening for more than one connection
     
    382385    {
    383386        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);
    385388
    386389        // This will accept a connection without blocking
     
    423426int main(int argc, const char **argv)
    424427{
    425     try
     428    //try
    426429    {
    427430        ba::io_service io_service;
     
    434437        for (int i=0; i<n; i++)
    435438        {
    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));
    437440            servers.push_back(server);
    438441
     
    450453        //cout << "end." << endl;
    451454    }
    452     catch (std::exception& e)
     455    /*catch (std::exception& e)
    453456    {
    454457        std::cerr << e.what() << std::endl;
    455     }
     458    }*/
    456459
    457460    return 0;
Note: See TracChangeset for help on using the changeset viewer.