2 Attachment(s)
How implement real time history plot with data samples having varying timestamps?
Can anyone recommend an approach to plotting data with non-fixed elapsed time intervals?
Basically the X time values of each data sample are non-fixed, non-integral seconds, and will vary.
However, I want the X-axis time labels to remain in units of integral seconds (or perhaps minutes).
I am working on a real-time history plot based on the Qwt cpuplot example. While cpuplot works well it is implemented using a fixed 1.0 second time intervals. My time stamped data contains elapsed time stamp values in milliseconds rather than integral seconds and time bewteen samples can vary perhaps up to 1000 ms. How can I plot a data sample with a timestamp of 1.5 seconds and line up properly with an X-axis label displaying integral seconds?
Example of my time stamped data series:
- 0 ms, 0.1 volts
- 1350 ms, 0.22 volts
- 2820 ms, 0.31 volts
- 4120 ms, 0.47 volts
- etc.
I attached a screenshot that may hep give you an idea of what I am seeking to accomplish.
Thanks in advance for any tips or direction,
-Ed
Re: How implement real time history plot with data samples having varying timestamps?
Solved. ( Sorry, bad arithmetic calculating elapsed time - it should have been working all along )
The cpuplot source was used pretty much as is, simply replacing the timer event handler with my own code that I called when I received the updated time-stamped data sample:
Code:
// Update X-axis time series labels for the amount of time that has passed since last update
double elapsedTimeIntervalSeconds = (structDataSample.timeStampMs - m_structDataSampleLast.timeStampMs) / 1000.0;
m_structDataSampleLast = structDataSample;
qDebug() << "Dbg: elapsedTimeIntervalSeconds = " << elapsedTimeIntervalSeconds << endl;
for ( int j = 0; j < HISTORY_BUFFER_LENGTH; j++ )
{
timeDataSeries[j] = timeDataSeries[j] + elapsedTimeIntervalSeconds;
}
Re: How implement real time history plot with data samples having varying timestamps?
I'm also doing the same kind of application. I'm new to QWT and QT. Can u please upload the full code?