void LoadMonitor::update() { // call with the mutex int now = upTime(); if (now == mLastUpdate) // current return; if ((now < mLastUpdate) || (now > (mLastUpdate + 8))) { // way out of date mCounts = 0; mLatencyEvents = 0; mLatencyMSAvg = 0; mLatencyMSPeak = 0; mLastUpdate = now; return; } do { // do exponential decay ++mLastUpdate; mCounts -= ((mCounts + 3) / 4); mLatencyEvents -= ((mLatencyEvents + 3) / 4); mLatencyMSAvg -= (mLatencyMSAvg / 4); mLatencyMSPeak -= (mLatencyMSPeak / 4); } while (mLastUpdate < now); }
// Init X axis. void DataPlot::initAxisX() { //QwtText xTitle("System Uptime [h:m:s]"); //xTitle.setFont(QFont("Ubuntu", 10)); //setAxisTitle(QwtPlot::xBottom, xTitle); setAxisScaleDraw(QwtPlot::xBottom,new TimeScaleDraw(upTime())); setAxisScale(QwtPlot::xBottom, 0, PLOT_SIZE ); setAxisLabelRotation(QwtPlot::xBottom, -50.0); setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom); QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom); const int fmh = QFontMetrics(scaleWidget->font()).height(); scaleWidget->setMinBorderDist(0, fmh / 2); }