Changeset 16106


Ignore:
Timestamp:
05/24/13 13:56:21 (11 years ago)
Author:
tbretz
Message:
Removed a lot of debug code which was never used anyway; improved performance when starting a run by first waiting that all commands are sent and the just waiting a short time for them to be processed; some adaptions to the status printing
File:
1 edited

Legend:

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

    r15247 r16106  
    153153        }
    154154
    155         EventBuilderWrapper::This->debugStream(fSlot*7, fBuffer.data(), bytes_received);
    156 
    157155        if (type==kReadHeader)
    158156        {
     
    183181            UpdateEventHeader();
    184182
    185             EventBuilderWrapper::This->debugHead(fSlot*7, fEventHeader);
     183            EventBuilderWrapper::This->debugHead(fEventHeader);
    186184
    187185            fBuffer.resize(fEventHeader.fPackageLength-sizeof(FAD::EventHeader)/2);
     
    911909    }
    912910
    913     int SetDebugEb(const EventImp &evt)
    914     {
    915         if (!CheckEventSize(evt.GetSize(), "SetDebugEb", 1))
    916             return T::kSM_FatalError;
    917 
    918         SetDebugLog(evt.GetBool());
    919 
    920         return T::GetCurrentState();
    921     }
    922 
    923911    const BoardList::iterator GetSlot(uint16_t slot)
    924912    {
     
    10221010        for (int i=slot[0]; i<=slot[1]; i++)
    10231011            SetIgnore(i, block);
    1024 
    1025         return T::GetCurrentState();
    1026     }
    1027 
    1028     int SetDumpStream(const EventImp &evt)
    1029     {
    1030         if (!CheckEventSize(evt.GetSize(), "SetDumpStream", 1))
    1031             return T::kSM_FatalError;
    1032 
    1033         SetDebugStream(evt.Get<uint8_t>());
    1034 
    1035         return T::GetCurrentState();
    1036     }
    1037 
    1038     int SetDumpRecv(const EventImp &evt)
    1039     {
    1040         if (!CheckEventSize(evt.GetSize(), "SetDumpRecv", 1))
    1041             return T::kSM_FatalError;
    1042 
    1043         SetDebugRead(evt.Get<uint8_t>());
    10441012
    10451013        return T::GetCurrentState();
     
    10991067        }
    11001068
     1069        fConfigTimer = Time(Time::none);
     1070
    11011071        // Now the old run is stopped already. So all other servers can start a new run
    11021072        // (Note that we might need another step which only checks if the continous trigger
     
    11071077        // T::Info(" ==> TODO: Insert/update run configuration in database!");
    11081078
    1109         fConfigTimer = Time();
    1110 
    11111079        return FAD::State::kConfiguring1;
    11121080    }
     
    11901158            switch (fStatus2[idx])
    11911159            {
    1192             case 0:  str << "1-7:not connected)"; break;
    1193             case 8:  str << "1-7:connected)";     break;
    1194             default: str << "1-7:connecting [" << (int)(fStatus2[idx]-1) << "])"; break;
     1160            case 0:  str << "1:disconnected)"; break;
     1161            case 8:  str << "1:connected)";     break;
     1162            default: str << "1:connecting)";    break;
    11951163            }
    11961164
     
    12011169                str << " [data_ignored]";
    12021170
    1203             if (fStatusC[idx])
     1171            if (fad->IsConnected() && fStatus2[idx]==8 && fad->IsConfigured())
    12041172                str << " [configured]";
    12051173
     
    13941362    vector<uint8_t> fStatus1;
    13951363    vector<uint8_t> fStatus2;
    1396     vector<uint8_t> fStatusC;
    13971364    bool            fStatusT;
    13981365
     
    14581425            // ----- Event builder -----
    14591426
     1427            stat2[idx] = 0; // disconnected
    14601428            if (!runs)
    14611429                continue;
    14621430
    1463             stat2[idx] = GetNumConnected(idx);
    1464 
    1465             if (runs && IsConnecting(idx))
     1431            if (IsConnecting(idx))
    14661432            {
    14671433                nconnecting2++;
    1468                 stat2[idx]++;
     1434                stat2[idx] = 1; // connecting
    14691435            }
    14701436
    14711437            if (IsConnected(idx))
    14721438            {
    1473                 stat2[idx]++;
    14741439                nconnected2++;
     1440                stat2[idx] = 8; // connected
    14751441            }
    14761442        }
     
    15331499                // and really sees the software trigger
    15341500                // FIXME: Do we need this to be configurable?
    1535                 if (Time()-fConfigTimer<boost::posix_time::milliseconds(3000))
     1501                //if (Time()-fConfigTimer<boost::posix_time::milliseconds(3000))
     1502
     1503                // Wait until the configuration commands to all boards
     1504                // have been sent and achknowledged
     1505                for (BoardList::iterator it=fBoards.begin(); it!=fBoards.end(); it++)
     1506                    if (!it->second->IsTxQueueEmpty())
     1507                        return FAD::State::kConfiguring1;
     1508
     1509                if (!fConfigTimer)
     1510                    fConfigTimer = Time();
     1511
     1512                // Wait a short moment to ensure that all board have processed
     1513                // the received data
     1514                if (Time()-fConfigTimer<boost::posix_time::milliseconds(250))
    15361515                    return FAD::State::kConfiguring1;
    15371516
     
    15841563                // (means the the event builder has received its
    15851564                // first event)
    1586                 if (!IsRunStarted() && nconfigured==nconnected1)
     1565                if (IsRunWaiting() && nconfigured==nconnected1)
    15871566                    return FAD::State::kConfigured;
    15881567
    1589                 if (IsRunStarted())
    1590                     T::Message("Run successfully started... (gotNewRun called)");
     1568                if (!IsRunWaiting())
     1569                    T::Message("Run successfully started... first data received.");
    15911570                if (nconfigured!=nconnected1)
    15921571                    T::Message("Configuration of some boards changed.");
    15931572            }
    15941573
    1595             return GetNumFilesOpen()>0 && IsRunFileOpen() ? FAD::State::kWritingData : FAD::State::kConnected;
     1574            // FIXME: Rename WritingData to TakingData
     1575            return IsRunInProgress() ? FAD::State::kWritingData : FAD::State::kConnected;
    15961576        }
    15971577
     
    16491629    StateMachineFAD(ostream &out=cout) :
    16501630        T(out, "FAD_CONTROL"), EventBuilderWrapper(*static_cast<MessageImp*>(this)), ba::io_service::work(static_cast<ba::io_service&>(*this)),
    1651         fStatus1(40), fStatus2(40), fStatusC(40), fStatusT(false),
     1631        fStatus1(40), fStatus2(40), fStatusT(false),
    16521632        fDimStartRun("FAD_CONTROL/START_RUN", "X:1;X:1",
    16531633                                              "Run numbers"
     
    18211801             "|debug[bool]:disable or enable debug output for transmitted data (yes/no)");
    18221802
    1823         T::AddEvent("SET_DEBUG_EVENT_BUILDER_OUT", "B:1")
    1824             (bind(&StateMachineFAD::SetDebugEb, this, placeholders::_1))
    1825             ("Enable or disable the debug output from the event builder"
    1826              "|enable[bool]:Enable/Disable (yes/no)");
    1827 
    18281803        T::AddEvent("PRINT_EVENT", "S:1")
    18291804            (bind(&StateMachineFAD::PrintEvent, this, placeholders::_1))
    18301805            ("Print (last) event"
    18311806             "|board[short]:slot from which the event should be printed (-1 for all)");
    1832 
    1833         T::AddEvent("DUMP_STREAM", "B:1")
    1834             (bind(&StateMachineFAD::SetDumpStream, this, placeholders::_1))
    1835             ("For debugging purpose: the binary data stream read from the sockets 0-7 can be dumped to files."
    1836              "|switch[bool]:Enable (yes) or disable (no)");
    1837 
    1838         T::AddEvent("DUMP_RECV", "B:1")
    1839             (bind(&StateMachineFAD::SetDumpRecv, this, placeholders::_1))
    1840             ("For debugging purpose: the times when data has been receives are dumped to a file."
    1841              "|switch[bool]:Enable (yes) or disable (no)");
    18421807
    18431808        T::AddEvent("BLOCK_TRANSMISSION", "S:1;B:1")
Note: See TracChangeset for help on using the changeset viewer.