LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PlotXY refresh

I am using LabWindows CVi 6.0. I'm a part time programmer. I have developed a small application to acquire data and plot using PlotXY() function. I have to acquire data from 6 pressure transducer equipments and then plot 2 parameters for each equipment. I'm not able to refresh (clear or delete) the previous traces of plot, when I select new parameters to plot. I use a timer to update plotXY function. I have ListBox to select equipment. I tried many options for Plot in GUI, DeleteGraph() function still not successful.

 

Peice of code which I used during my app development attached below. Am I missing something here?..

 

 

// Function to select Equipment/Parameters

 

int plotIdWt=0, plotIdLR=0;
 

 

int CVICALLBACK PlotDataFunctionCB (int panel, int control, int event,  void *callbackData, int eventData1, int eventData2)
{
 unsigned long int Tcount=0;
 switch (event)
  {
  case EVENT_COMMIT:
   GetCtrlVal (panel, PLOTPANEL_EQUIPMENT, &plot_ctrlVal);
   
   SetCtrlAttribute (panel, PLOTPANEL_TIMER01, ATTR_ENABLED, 0); // Disable Timer
   SetCtrlAttribute (panel, PLOTPANEL_PLOT, ATTR_DATA_MODE, VAL_DISCARD);
   DeleteGraphPlot (panel, PLOTPANEL_PLOT, plotIdLR, VAL_DELAYED_DRAW);
   DeleteGraphPlot (panel, PLOTPANEL_PLOT, plotIdWt, VAL_DELAYED_DRAW);
   //RefreshGraph (panel, PLOTPANEL_PLOT);
   plotIdWt = plotIdLR = 0;
   SetCtrlAttribute (panel, PLOTPANEL_TIMER01, ATTR_ENABLED, 1); // enable Timer
   //MessagePopup("Message", "plotting Data complete");
   break;
  }
 return 0;
}

  

int CVICALLBACK CallPlotTimeFunction (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
   switch (event)
  {
  case EVENT_TIMER_TICK:

   SetCtrlAttribute (panel, PLOTPANEL_PLOT, ATTR_DATA_MODE, VAL_RETAIN);
   plotIdWt = PlotXY (panel, PLOTPANEL_PLOT, timeA, PTR_WtArray[plot_ctrlVal-1], timeCount,VAL_DOUBLE, VAL_DOUBLE, VAL_CONNECTED_POINTS,VAL_ASTERISK,    VAL_SOLID, 1, VAL_DK_GREEN);
   //SetPlotAttribute (panel, PLOTPANEL_PLOT, plotIdLR, ATTR_PLOT_YAXIS,  VAL_RIGHT_YAXIS); 

   plotIdLR = PlotXY (panel, PLOTPANEL_PLOT, timeA,PTR_LRArray[plot_ctrlVal-1], timeCount, VAL_DOUBLE,VAL_DOUBLE, VAL_CONNECTED_POINTS, VAL_ASTERISK,VAL_SOLID, 1, VAL_DK_BLUE);
      SetPlotAttribute (panel, PLOTPANEL_PLOT, plotIdWt, ATTR_PLOT_YAXIS,  VAL_LEFT_YAXIS); 
   SetCtrlAttribute (panel, PLOTPANEL_PLOT, ATTR_DATA_MODE, VAL_DISCARD);
   
   break;
  }
 return 0;
}

 

Thanks & Regards,

 Joy Gomes.

0 Kudos
Message 1 of 3
(3,460 Views)
I noted that in your timer callback you are drawing new plots reusing the same plot handles, so all previous plotted plots are no more individually accessible. Nevertheless, I suppose that when changing equipment shown you want that all plots are deleted from the graph, not only the last one drawn whise plots have been saved. I suggest you to pass -1 as the plot handle to DeleteGraphPlot and to use VAL_IMMEDIATE_DRAW, so that all plots are immediately deleted from the graph: the next time the timer callback executes the first diagramp for the new equipment will be shown.


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 3
(3,444 Views)

Thanks for valuable suggestion. I shall try.

Regards,

 Joy Gomes.

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