LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Stripchart control, strange high CPU usage

Solved!
Go to solution

Hi all...

I have tracked a strange problem with stripchart control.

I noticed in the past that "sometime" different programs I wrote had an abnormal CPU usage, not justified by any activity they were actually performing.

 

Finally I had the time to track down the problem and to build a minimal sample code.

The presented program has a panel with a stripchart control and two command buttons. 

The buttons simply clear the stripchart and add a single point to the empty stripchart.

 

int CVICALLBACK ControlCB (int panel, int control, int event,void *callbackData, int eventData1, int eventData2)
{
	switch (event) {
		case EVENT_COMMIT:
			switch(control) {
				case PANEL_BUG:
					ClearStripChart(panel,PANEL_GRAPH);
					PlotStripChartPoint (panel, PANEL_GRAPH, MAGIC_VALUE);
					break;
					
				case PANEL_NOBUG:
					ClearStripChart(panel,PANEL_GRAPH);
					PlotStripChartPoint (panel, PANEL_GRAPH, NOT_SO_MAGIC_VALUE);
					break;
			}
			break;
	}
	return 0;
}

 

I found that adding "special" values to the stripchart starts a background activity that consumes a significant amount of CPU time.

In this screenshot you can see what happens on my PC when I click the "Bug" command button.

The special value is here 42.22 but I bet there are other thousands with similar behaviour.

Being a single point, the stripchart does not show nothing but the change of the Y axis scale.

 

ScreenShot

 

Clicking the "No Bug" command button inserts the value 100.0 and no bad behaviour occurs.

Just to shuffle ideas, if you push "No Bug" and then "Bug", the bad behavior does not occurs, too.

 

It's surely an interaction between the Y axis autoscale, the initial values and may be the "scale name". I haven't the time to explore all the combinations and may be a minimal workaround.

In my applications I ended in doing the autoscaling "by hand".

 

I have tested the program on five different PCs, Core 2 Duo CPUs running XP, Vista and 7 (italian), compiled with CVI 2010 SP1

 

Attached there is the full project.

The distribution kit for the project (no sources) can be downloaded here: http://dl.dropbox.com/u/23913808/CPUeater.zip

 

 

Carlo A.
Megaris




0 Kudos
Message 1 of 3
(3,235 Views)
Solution
Accepted by topic author carlox

There was a bug in the graph/strip chart code which could cause endless cycling when attempting to resize a graph axis which had an axis label visible. It has been fixed for the next version of CVI so unfortunately you're going to have to wait a little bit.

 

There are two possible workarounds:

1) disable the axis label. If it isn't displayed, this looping can never occur.

2) Enable Fixed plot area and play around with the left and width of the plot area to move the whole thing over to the right a bit more. The problem was introduced when the graph/chart thinks the label is getting too close to the edge of the graph and attempts to reposition the label. Unfortunately the code was a little buggy and the label was getting positioned in the exact same spot, but we weren't checking to see if we'd already tried to reposition the label, and so it endlessly cycled.

 

Sorry about the inconvenience.

Kevin B.
0 Kudos
Message 2 of 3
(3,227 Views)

The workaround seems to be acceptable, while waiting for the patch...

Thanks

 

Carlo A.

Megaris s.r.l.

Carlo A.
Megaris




0 Kudos
Message 3 of 3
(3,204 Views)