Пример #1
0
void SimpleCounterWorker::getValues()
{
    /* Do values cut off */
    SimpleValues_t* old = values;

    values = new SimpleValues_t;

    emit valuesReady( old);
}
Пример #2
0
CounterValues* SimpleCounter::getValues()
{
    emit valuesRequest();

    /* Run dummy event loop to wait for asynchronous signal */
    QEventLoop loop;
    QObject::connect( this, SIGNAL( valuesReady()), &loop, SLOT( quit()));
    loop.exec();

    return (CounterValues*)values;
}
Пример #3
0
void
AnalysisDataAverageModule::dataFinished()
{
    for (int i = 0; i < rowCount(); ++i)
    {
        real ave = value(i, 0) / nsamples_[i];
        real std = sqrt(value(i, 1) / nsamples_[i] - ave * ave);
        setValue(i, 0, ave);
        setValue(i, 1, std);
    }
    valuesReady();
}
void
AnalysisDataAverageModule::dataFinished()
{
    allocateValues();
    for (int i = 0; i < columnCount(); ++i)
    {
        impl_->averagers_[i].finish();
        int j = 0;
        for (; j < impl_->averagers_[i].columnCount(); ++j)
        {
            value(j, i).setValue(impl_->averagers_[i].average(j),
                                 std::sqrt(impl_->averagers_[i].variance(j)));
        }
        for (; j < rowCount(); ++j)
        {
            value(j, i).setValue(0.0, 0.0, false);
        }
    }
    valuesReady();
}
Пример #5
0
void SimpleCounter::receiveValues( SimpleValues_t* val)
{
    /* Convert values to external format */
    values = new CounterValuesImpl;
    SimpleTable_t* table = values->getSimpleTable();

    SimpleValues_t::const_iterator i;
    for ( i = val->begin();
          i != val->end();
          ++i )
    {
        PlainRecord rec;
        rec.key = i.key();
        rec.val = i.value();

        table->push_back( rec);
    }

    /* Destroy internal values */
    delete val;

    emit valuesReady();
}
Пример #6
0
void
AnalysisDataLifetimeModule::dataFinished()
{
    // Need to process the elements present in the last frame explicitly.
    for (size_t i = 0; i < impl_->currentLifetimes_.size(); ++i)
    {
        for (size_t j = 0; j < impl_->currentLifetimes_[i].size(); ++j)
        {
            impl_->addLifetime(i, impl_->currentLifetimes_[i][j]);
        }
    }
    impl_->currentLifetimes_.clear();

    if (impl_->bCumulative_)
    {
        // Sum up subintervals of longer intervals into the histograms
        // if explicitly requested.
        std::vector<Impl::LifetimeHistogram>::iterator histogram;
        for (histogram  = impl_->lifetimeHistograms_.begin();
             histogram != impl_->lifetimeHistograms_.end();
             ++histogram)
        {
            Impl::LifetimeHistogram::iterator shorter, longer;
            for (shorter = histogram->begin(); shorter != histogram->end(); ++shorter)
            {
                int subIntervalCount = 2;
                for (longer = shorter + 1; longer != histogram->end();
                     ++longer, ++subIntervalCount)
                {
                    // Interval of length shorter contains (longer - shorter + 1)
                    // continuous intervals of length longer.
                    *shorter += subIntervalCount * (*longer);
                }
            }
        }
    }

    // X spacing is determined by averaging from the first and last frame
    // instead of first two frames to avoid rounding issues.
    const real spacing =
        (impl_->frameCount_ > 1)
        ? (impl_->lastx_ - impl_->firstx_) / (impl_->frameCount_ - 1)
        : 0.0;
    setXAxis(0.0, spacing);

    // Determine output dimensionality to cover all the histograms.
    setColumnCount(impl_->lifetimeHistograms_.size());
    std::vector<Impl::LifetimeHistogram>::const_iterator histogram;
    size_t maxLifetime = 1;
    for (histogram  = impl_->lifetimeHistograms_.begin();
         histogram != impl_->lifetimeHistograms_.end();
         ++histogram)
    {
        maxLifetime = std::max(maxLifetime, histogram->size());
    }
    setRowCount(maxLifetime);

    // Fill up the output data from the histograms.
    allocateValues();
    int column = 0;
    for (histogram  = impl_->lifetimeHistograms_.begin();
         histogram != impl_->lifetimeHistograms_.end();
         ++histogram, ++column)
    {
        int row = 0;
        Impl::LifetimeHistogram::const_iterator i;
        for (i = histogram->begin(); i != histogram->end(); ++i, ++row)
        {
            // Normalize by the number of frames, taking into account the
            // length of the interval (interval of length N cannot start in
            // N-1 last frames).  row is always smaller than frameCount_
            // because of the histograms have at most frameCount_ entries.
            const real normalized = *i / static_cast<real>(impl_->frameCount_ - row);
            value(row, column).setValue(normalized);
        }
        // Pad the rest of the histogram with zeros to match the longest
        // histogram.
        for (; row < rowCount(); ++row)
        {
            value(row, column).setValue(0.0);
        }
    }
    impl_->lifetimeHistograms_.clear();
    valuesReady();
}