PDA

View Full Version : Cpu Plot walkthrough

maxpayne
13th October 2008, 05:52
hi!!

i am a qwt newbie and have been assigned a task to draw a plot very similar to the cpu plot example. Unfortunately i am unable to understand this example.I know the logic of parsing the /proc/stat and converting the statistics into percentages.

What i did not get is the qwt part. How the scale was set,the background,the time scale,the run time information etc etc.:confused:Can anyone give me a simple walk through to get me started...or at least explain the sequence of execution...i would be really great full.

thanks !!

-max

maxpayne
13th October 2008, 11:16
any body?...or atleast help me understand this:

void CpuPlot::timerEvent(QTimerEvent *)
{
for ( int i = dataCount; i > 0; i-- ) //wht is the initial value of dataCount?
{
for ( int c = 0; c < NCpuData; c++ )
{
if ( i < HISTORY )
data[c].data[i] = data[c].data[i-1];
}
}

cpuStat.statistic(data[User].data[0], data[System].data[0]);

data[Total].data[0] = data[User].data[0] +
data[System].data[0];
data[Idle].data[0] = 100.0 - data[Total].data[0];

if ( dataCount < HISTORY ) //60
dataCount++;

for ( int j = 0; j < HISTORY; j++ )
timeData[j]++;

//***set scale**********//
setAxisScale(QwtPlot::xBottom,
timeData[HISTORY - 1], timeData[0]);

for ( int c = 0; c < NCpuData; c++ )
{
data[c].curve->setRawData(
timeData, data[c].data, dataCount);
}

replot();
}

what is happening here?.

thanks