Changeset 11195


Ignore:
Timestamp:
06/27/11 14:45:57 (13 years ago)
Author:
tbretz
Message:
Updated with some more status bit support.
File:
1 edited

Legend:

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

    r11179 r11195  
    2828class tcp_connection : public ba::ip::tcp::socket, public boost::enable_shared_from_this<tcp_connection>
    2929{
    30 private:
     30public:
    3131    const int fBoardId;
    3232
     
    8585    void SendData()
    8686    {
    87         if (!fTriggerEnabled)
    88             return;
    89 
    9087        fHeader.fPackageLength = sizeof(EventHeader)/2+1;
    9188        fHeader.fEventCounter++;
     
    147144
    148145        // The deadline has passed.
    149         SendData();
     146        if (fTriggerEnabled)
     147            SendData();
    150148
    151149        AsyncWait(fTriggerSendData, 1, &tcp_connection::TriggerSendData);
     
    186184                cout << "-> Trigger line" << endl;
    187185                fTriggerEnabled = fBufCommand[0]==kCmdTriggerLine;
     186                fHeader.Enable(FAD::EventHeader::kTriggerLine, fTriggerEnabled);
    188187                break;
    189188
     
    205204                break;
    206205
     206            case kCmdBusy:
     207            case kCmdBusy+0x100:
     208                cout << "-> Busy" << endl;
     209                fHeader.Enable(FAD::EventHeader::kBusy, fBufCommand[0]==kCmdBusy);
     210                break;
     211
    207212            case kCmdSocket:
    208213            case kCmdSocket+0x100:
    209214                cout << "-> Socket" << endl;
    210215                fCommandSocket = fBufCommand[0]==kCmdSocket;
     216                fHeader.Enable(FAD::EventHeader::kSock17, fCommandSocket);
    211217                break;
    212218
    213219            case kCmdContTrigger:
    214220            case kCmdContTrigger+0x100:
    215                 if (fBufCommand[0]==kCmdContTrigger+0x100)
     221                if (fBufCommand[0]==kCmdContTrigger)
    216222                    AsyncWait(fTriggerSendData, 1, &tcp_connection::TriggerSendData);
    217223                else
    218224                    fTriggerSendData.cancel();
     225                fHeader.Enable(FAD::EventHeader::kContTrigger, fBufCommand[0]==kCmdContTrigger);
    219226                cout << "-> ContTrig" << endl;
    220227                break;
    221228
    222229            case kCmdResetTriggerId:
    223                 cout << "-> Reset" << endl;
     230                cout << "-> ResetId" << endl;
    224231                fHeader.fEventCounter = 0;
    225232                break;
    226233
    227234            case kCmdSingleTrigger:
    228                 cout << "-> Trigger" << endl;
     235                cout << "-> Trigger " << fBoardId << endl;
    229236                SendData();
    230237                break;
     
    361368    void handle_accept(boost::shared_ptr<ba::ip::tcp::socket> socket, int port, const boost::system::error_code&/* error*/)
    362369    {
    363         cout << "Added one socket " << socket->remote_endpoint().address().to_v4().to_string();
     370        cout << this << " Added one socket[" << fBoardId << "] " << socket->remote_endpoint().address().to_v4().to_string();
    364371        cout << ":"<< port << endl;
    365372        fSockets.push_back(socket);
     
    406413        boost::shared_ptr<ba::ip::tcp::socket> connection =
    407414            boost::shared_ptr<ba::ip::tcp::socket>(new ba::ip::tcp::socket(acc.io_service()));
     415
    408416        acc.async_accept(*connection,
    409417                          boost::bind(&tcp_connection::handle_accept,
     
    415423    void start_accept()
    416424    {
    417         cout << "Start accept " << acc0.local_endpoint().port() << "..." << flush;
     425        cout << "Start accept[" << fBoardId << "] " << acc0.local_endpoint().port() << "..." << flush;
    418426        tcp_connection::shared_ptr new_connection = tcp_connection::create(/*acceptor_.*/acc0.io_service(), fBoardId);
     427
     428        cout << new_connection.get() << " ";
    419429
    420430        // This will accept a connection without blocking
     
    441451
    442452        // not installing a new handler will stop run()
    443         cout << "Handle accept..." << flush;
     453        cout << new_connection.get() << " Handle accept[" << fBoardId << "]["<<new_connection->fBoardId<<"]..." << flush;
    444454        if (!error)
    445455        {
Note: See TracChangeset for help on using the changeset viewer.