Exemple #1
0
void StdDataLoop::execPart2() {
    if (verbose)
        std::cout << __PRETTY_FUNCTION__ << std::endl;
    unsigned count = 0;
    uint32_t done = 0;
    //uint32_t rate = 0;
    //uint32_t curCnt = 0;
    unsigned iterations = 0;
    //uint32_t startAddr = 0;


    std::vector<RawData*> tmp_storage;
    RawData *newData = NULL;
    RawDataContainer *rdc = new RawDataContainer();
    while (done == 0) {
        //rate = g_rx->getDataRate();
        //curCnt = g_rx->getCurCount();
        done = g_tx->isTrigDone();
        do {
            newData =  g_rx->readData();
            iterations++;
            if (newData != NULL) {
                rdc->add(newData);
                count += newData->words;
            }
        } while (newData != NULL);
        delete newData;
    }
    // Gather rest of data after timeout (~0.1ms)
    std::this_thread::sleep_for(std::chrono::microseconds(500));
    do {
        //curCnt = g_rx->getCurCount();
        newData =  g_rx->readData();
        iterations++;
        if (newData != NULL) {
            rdc->add(newData);
            count += newData->words;
        }
    } while (newData != NULL);
    delete newData;
    
    rdc->stat = *g_stat;
    storage->pushData(rdc);
        
    if (verbose)
        std::cout << " --> Received " << count << " words! " << iterations << std::endl;
    m_done = true;
    counter++;
}
Exemple #2
0
void StdDataGatherer::execPart2() {
    if (verbose)
        std::cout << __PRETTY_FUNCTION__ << std::endl;
    unsigned count = 0;
    uint32_t done = 0;
    uint32_t rate = 0;

    signaled = 0;
    signal(SIGINT, [](int signum){signaled = 1;});

    std::cout << "### IMPORTANT ### Going into endless loop, interrupt with ^c (SIGINT)!" << std::endl;

    std::vector<RawData*> tmp_storage;
    RawData *newData = NULL;
    while (done == 0) {
        RawDataContainer *rdc = new RawDataContainer();
        rate = g_rx->getDataRate();
        if (verbose)
            std::cout << " --> Data Rate: " << rate/256.0/1024.0 << " MB/s" << std::endl;
        done = g_tx->isTrigDone();
        do {
            newData =  g_rx->readData();
            if (newData != NULL) {
                rdc->add(newData);
                count += newData->words;
            }
        } while (newData != NULL);
        delete newData;
        rdc->stat = *g_stat;
        storage->pushData(rdc);
        if (signaled == 1) {
            std::cout << "Caught interrupt, stopping data taking!" << std::endl;
            std::cout << "Abort will leave buffers full of data!" << std::endl;
            g_tx->toggleTrigAbort();
        }
        std::this_thread::sleep_for(std::chrono::microseconds(500));
    }
        
    m_done = true;
    counter++;
}