LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Why it occurs error when I add a scroll bar to a stripchart?

Solved!
Go to solution

I want to add a horizontal scroll bar to a strip chart. I creat a check box on the strip chart panel.If it is marked I set

 SetCtrlAttribute (psmpanelHandle, PSM_PANEL_ACHART, ATTR_STRIP_CHART_PAUSED, 1);

 and I use

GetCtrlVal(psmpanelHandle,PSM_PANEL_CHECKBOX, &val);

 to judge if the check box is marked. And,the complete code is :

//Pause the stripchart traces    
int CVICALLBACK PauseChart (int panel, int control, int event,
                void *callbackData, int eventData1, int eventData2)
{
        int val; 
        switch (event)
        {
                case EVENT_COMMIT:
                     SetCtrlAttribute (psmpanelHandle, PSM_PANEL_ACHART, ATTR_HISTORY_BUFFER_SIZE, 86400);
             GetCtrlVal(psmpanelHandle,PSM_PANEL_CHECKBOX, &val);
             if (val==TRUE)
                 SetCtrlAttribute (psmpanelHandle, PSM_PANEL_ACHART, ATTR_STRIP_CHART_PAUSED, 1);
            else
                SetCtrlAttribute (psmpanelHandle, PSM_PANEL_ACHART, ATTR_STRIP_CHART_PAUSED, 0); 
                        break;
        }
        return 0;
}

 However,I could not move the scroll bar to view the historical datas when I pause the the real-time curve of the display on the strip chart.

iew.jpg

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 1 of 9
(3,921 Views)

I'm not sure about it, but I would set the history buffer way before you pause the graph: if you set it in that precise moment you haven't any historic data collected to show! I'd set this attribute immediately after loading the panel the chart is on.

 

Additionally, since a checkbox can only assume values 0 and 1, your code can be simplified a little as follows:

GetCtrlVal(panel, control, &val);
SetCtrlAttribute (panel, PSM_PANEL_ACHART, ATTR_STRIP_CHART_PAUSED, val);

 this way you could also avoid the need for a global variable holding the panel handle, if this is the only function in which you are using it.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 9
(3,919 Views)

Hi ! Thank you very much for your reply.I modified the code according to your advice. 

//Pause the stripchart traces    
int CVICALLBACK PauseChart (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	int val; 
	switch (event)
	{
		case EVENT_COMMIT:
		     SetCtrlAttribute (psmpanelHandle, PSM_PANEL_WJCHART, ATTR_HISTORY_BUFFER_SIZE, 86400);
             GetCtrlVal(psmpanelHandle,PSM_PANEL_CHECKBOX, &val);
//	     if (val==TRUE)
	         SetCtrlAttribute (psmpanelHandle, PSM_PANEL_WJCHART, ATTR_STRIP_CHART_PAUSED, val);
		     
//	    else
//	        SetCtrlAttribute (psmpanelHandle, PSM_PANEL_ACHART, ATTR_STRIP_CHART_PAUSED, 0); 
			break;
	}
	return 0;
}

 

 However,it could not reach to ideal effect,The original real-time curve is  the following picture: .

view.jpg

when I press the "pausechart"button,it's the following picture:

view2.jpg

When press the "pausechart"button again and do not marked the checkbox "view",it's the following picture:

view3.jpg 

 

Expect your good advice.

Best regards.

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 3 of 9
(3,912 Views)
It appears as if you have missed the forst part of my post Smiley Wink

Roberto Bozzolo ha scritto:

I'm not sure about it, but I would set the history buffer way before you pause the graph: if you set it in that precise moment you haven't any historic data collected to show! I'd set this attribute immediately after loading the panel the chart is on.


It is possible the setting history buffer lenght clears the chart, which I suppose it can be expected since the command must manipulate someway internal chart buffers.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 9
(3,905 Views)

Hi !

Thank you very much for your direction.

It works very well when it has only one panel. However,I have several panels and I use menu bars.

It could not work when I put

SetCtrlAttribute (panelHandle2, PANEL_2_STRIPCHART, ATTR_HISTORY_BUFFER_SIZE, 86400); 

 

 in the panel Callback where the chart is on.It wll appears nothing when the other chart is drawing.So I put It in the main code,however,it occurs error,too. 

break.jpgpause.jpg

But,If I delete the satement and do not use it in the procedure,I could view the historical datas when the number of datas is more than the points per screen.

If the number of datas is less than the points per screen,I could not view the historical datas.

As we would save datas continuously several days,  we expect to view as many datas as possible,so I'm afraid it would only view some historial datas if I do not set the history buffer.

Because my procedure is very large,I wrote a small example in the attachment.Could you give me some guidance ?

Thank you very much.

Best regards.

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 5 of 9
(3,887 Views)
Solution
Accepted by 佩林

You are very likely to get that error! As you surely know, you cannot operate on a panel or its control before it is loaded in memory, so you have to set the chart attribute in Pause1Callback or Pause2Callback using the appropriate panel handle.

As per the chart history functionality, having the scroll bar is useless until you fill up one chart screen: once it starts moving and accumulating data on the left side you can move along with the scroll bar to review its history.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 9
(3,882 Views)

Hi !

Thank you very much !

It didn't occurs error.

Wish you happy every day !

Best regards.

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 7 of 9
(3,879 Views)

I just wanted to chime in that Robert was right. Everytime you set ATTR_HISTORY_BUFFER_SIZE the previous buffer is thrown away. You have to set this attribute before you start plotting if you want all of your plotted data to be visible when the chart is paused.

Kevin B.
Message 8 of 9
(3,869 Views)

Hi !

Thank you very much for your reminding.

Actually,I want to view all the plotted datas.So,I want to set ATTR_HISTORY_BUFFER_SIZE the previous buffer and will set it as big as enough.

Thank you very much !

Wish you happy every day.

Best regards.

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 9 of 9
(3,863 Views)