11-17-2011 07:05 PM
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.
Solved! Go to Solution.
11-17-2011 11:59 PM
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.
11-18-2011 02:57 AM - edited 11-18-2011 03:01 AM
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: .
when I press the "pausechart"button,it's the following picture:
When press the "pausechart"button again and do not marked the checkbox "view",it's the following picture:
Expect your good advice.
Best regards.
11-18-2011 08:16 AM
It appears as if you have missed the forst part of my post
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.
11-20-2011 08:58 PM - edited 11-20-2011 08:59 PM
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.
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.
11-21-2011 12:08 AM
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.
11-21-2011 12:21 AM
Hi !
Thank you very much !
It didn't occurs error.
Wish you happy every day !
Best regards.
11-21-2011 02:49 PM
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.
11-21-2011 06:29 PM
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.