384 views
in GUI Development by

Hi dear Paul

Please refer to solar demo example.My question is that we consider a slider to adjust scale of horizontal axis,like "time/dive" on osiloscope and data source can be anything .

in here many random number in -100 to +100.so by slider we can adjust plotter to show data for example each 500ms or 1s and when time value( scale of horizontal axis ) go higher,plotter showes data more expanded.

Thanks if answer me soon.

1 Answer

0 votes
by

For this application case you need to treat the visualization and the storage of the data samples separately. First of all there should be a data source providing samples with their corresponding timestamps. On the other hand the visualization part of the application manages its own time base. This time base can change, affecting the data samples to appear more or less closely.

This approach expects the visible curves to be redrawn every time when the time base is changed. The problem here, the example SolarDemo is not optimized for such application case. It simply stores the visible portion of the curve in an internal image memory. When new data samples arrive, the image within the memory is moved and the new samples are drawn. As you probably deduce, the application is optimized for showing endless live data streams. Once drawn, the data and the time base can't be changed. 

Thus for your application case I would forget the SolarDemo and implement an own ChartView component optimized for the visualization of data samples with flexible time base. I prepared an example demonstrating it. See the link below.

http://ask.embedded-wizard.de/?qa=blob&qa_blobid=14109088174575481347

In principle the entire curve drawing is handled in the simple component ChartView. It manages internally in the property FirstTime the time at the left edge of the Chart. Changing this property scrolls the curve. In the property VisibleTime is stores the time span covered by the Chart view. Changing this property stretches the curve accordingly.

One important aspect: the ChartView doesn't store the data samples. Instead, it has a property OnGetSample. The owner of the ChartView has to assign to this property its own slot method. The ChartView, every time it needs a data sample, sends a signal to the associated slot method. In response, the slot method has to provide the data of the desired sample: its time and its value.

How this work is demonstrated in the Application component itself. There you can see two arrays dummySampleTime and dummySampleValue initialized at the begin with some random data. The slot method onGetSample is connected to the ChartView. This method simply reads data from the arrays and transfers it to the ChartView. Also important is the property NoOfSamples of the ChartView. It determines how many samples are available. When you adapt the example to your needs, you should save the number of available samples in this property. In this example, the number of samples corresponds to the number of entries within the arrays.

Finally the Application contains two sliders. The first one is connected to the FirstTime property of the ChartView. When you move the slider, the content in ChartView is scrolled. The second slider is connected to the property VisibleTime. Here moving the slider will stretch the visible curve.

Hope it helps you further. Feel free to modify the example to your needs. Also take a look at the inline comments within methods.

by
Thanks my dear freind paul

But may you change youre example with" Mosaic 2.0"?

I cant see anything when I open project!!

all of the Manfred examples was with Mosaic 2.0 too.

Thanks if you answer
by
The link is modified to refer to the correct (Mosaic 2.0) project version now.

Embedded Wizard Website | Privacy Policy | Imprint

...