LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to view the curve of the past on Strip Chart ?

I use a Strip Chart to display real-time curve. But our costomer want to view the curve of the past and I don't know how to do it.

I want to use a scroll bar to view the the curve of the past.

But I need help.

I would appreciate it very much if anyone could help me.

Thank you very much.

Best regards.

 

xiepei 

 

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 23
(4,789 Views)

From CVI help:

 

Viewing Strip Chart Data

Enable ATTR_STRIP_CHART_PAUSED to pause the strip chart. When the strip chart is paused, LabWindows/CVI adds a scroll bar to the strip chart control, which allows the user to view previously plotted data. Use the ATTR_HISTORY_BUFFER_SIZE attribute to specify how many points are available to view when you pause plotting.

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 2 of 23
(4,788 Views)

Hi !

Thank you very much for your reply.

I'm so sorry that I could find http://zone.ni.com/reference/en-XX/help/370051M-01/cvi/uiref/cviattrstripchartpaused/     http://zone.ni.com/reference/en-XX/help/370051M-01/cvi/uiref/cviattrhistorybuffersize/ in my CVI.

My CVI version is 8.0.

Could you give me an example ?

Thank you very much!

Best regards.

 

xiepei

 

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 23
(4,787 Views)

I don't know if these attributes are available on CVI 8.0, but if they're available you can look at the stripchart example into the CVI samples folder

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 4 of 23
(4,779 Views)

Hi !

Which version is your CVI ? I really need this. But I could find similar examples. Could you give me an example ? Even if it is a function application statement.

It you don't want to make your example public,could you send it to me with emal ? My emal is   xiepeilin0826@126.com .

I really appreciate your help .

Thank you very much,

Best regards.

xiepei

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 23
(4,777 Views)

I've been using CVI 2010, but the stripchart.prj demo example is in the CVI samples folder since CVI 6.0 at least.

If ATTR_STRIP_CHART_PAUSED is available, you should find the following callback

 

/*---------------------------------------------------------------------------*/
/* 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:
            GetCtrlVal(panel, control, &val);
            SetCtrlAttribute(panel, PANEL_CHART, ATTR_STRIP_CHART_PAUSED, val);
            break;
    }
    return 0;
}

if not, you should read the help of your CVI release to see if there is some other workaround

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 6 of 23
(4,769 Views)

Hi !

Thank you very much for your guidance!

Unfortunately.there is no

ATTR_STRIP_CHART_PAUSED

 in my CVI.When I put this in my programm,it occurs error.ATTR_STRIP_CHART_PAUSED.jpg

I used to read all datas and plot them on graph.But it's always crashing.When the .txt file is more than 400kb,the whole programm could crash.

This is my code beloe:

static char	buf[1024];
static struct tm	ti;
double *wj = NULL, *mv = NULL, *ma = NULL, *et= NULL ; 
double *c1 = NULL, *c2 = NULL, *c3 = NULL,*c4 = NULL, *c5 = NULL;  
int CVICALLBACK FhCallbck (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	int	cnt = 0, aSize = 30000,fH = 0;
	int	r = 0;
	switch (event)
	{
		case EVENT_COMMIT:
			 // Initial array dimensioning
	         c1 = malloc (aSize * sizeof (double));
	         c2 = malloc (aSize * sizeof (double));
	         c3 = malloc (aSize * sizeof (double));
			 c4 = malloc (aSize * sizeof (double));
	         c5 = malloc (aSize * sizeof (double));
	         et = malloc (aSize * sizeof (double));
			 fH = OpenFile ("yb.txt", VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
	while (1) {

	     r = ReadLine (fH, buf, 511);
        if (r == -2) break;
		
		if (!strlen (buf)) goto loop;	// Do not scan empty lines

		// Parse line read and fill the array
		Scan (buf, "%d[x]%d[x]%d[x]%d[x]%d[x]%d[x]%s[dt#]%f[x]%s[dt#]%f[x]%s[dt#]%f[x]%s[dt#]%f[x]%s[dt#]%f",
                  &ti.tm_mon, &ti.tm_mday, &ti.tm_year, &ti.tm_hour, &ti.tm_min, &ti.tm_sec, &c1[cnt], &c2[cnt], &c3[cnt], &c4[cnt], &c5[cnt]);
		// Adjust fields for tm struct correct format
		ti.tm_mon--; ti.tm_year -= 1900;
		// Calculate timestamp
		et[cnt] = mktime (&ti);
		// Check array size and increase if needed
		if (++cnt > aSize) {
			aSize += 500;   // Increase array size
			// Further memory allocation
			c1 = realloc (wj, aSize * sizeof (double));
			c2 = realloc (mv, aSize * sizeof (double));
			c3 = realloc (ma, aSize * sizeof (double));
			c4 = realloc (mv, aSize * sizeof (double));
			c5 = realloc (ma, aSize * sizeof (double));
			et = realloc (ma, aSize * sizeof (double));
		}
		loop:	;
	}
	CloseFile (fH); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_CO2, et, c1, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_O2, et, c2, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_CO, et, c3, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_H2S, et, c4, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_CH4, et, c5, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
		// Free dynamic memory
	if (c1) free (c1);
	if (c2) free (c2);
	if (c3) free (c3);
	if (c4) free (c4);
	if (c5) free (c5);
	if (et) free (et);	

	        break;
	}
	return 0;
}

 This is the .uir panel:Data Playback.jpg

Besides,our customers want to use scroll bar to see the datas of the past.I need to solve these two problems. I used to download CVI8.5,CVI9.0,CVI2010 and set it up,but high version CVI would cover low version.At last,I had to reinstall system. I think I should download CVI2010 and find a crak.

 

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 23
(4,760 Views)

Hi,

I have found some documentation on previous versione and I seem to have found that that attribute was introduced in CVI8.5.

 

Regarding your code, 400kB of data are not a problem with CVI, which can handle tons of data (I have succesfully managed arrays of dozens of MB in some application of mine!); a possible cause of crash in the code may occur when you are increasing array size, since you are using array pointers you have never allocated; look at these lines and the highlighted parts:

 

if (++cnt > aSize) {
	aSize += 500;   // Increase array size
	// Further memory allocation
	c1 = realloc (wj, aSize * sizeof (double));
	c2 = realloc (mv, aSize * sizeof (double));
	c3 = realloc (ma, aSize * sizeof (double));
	c4 = realloc (mv, aSize * sizeof (double));
	c5 = realloc (ma, aSize * sizeof (double));
	et = realloc (ma, aSize * sizeof (double));
}

Similar lines should raise meaningful errors to help you debugging code.

 

 



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 8 of 23
(4,757 Views)

Hi xiepei, please don't speak about cracks: you won't find any help on this here!

Cracking a software won't solve your coding problems. You should fully debug your code, instead, and try to take the maximum out of your product. As an example, using a graph instead of a strip chart (like in the code you have posted) permits you to exploit zooming capabilities of graph control, which can hopefully address your customer's desires.

 

You can find plenty of useful sample projects on this site that cen help you in developing a good and powerful application; take a look to this one as an example, it was developed with CVI6: Creating a scrolling graph.

 

 



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 9 of 23
(4,753 Views)

Hi !

Thank you very much for your reply.

I have modfied the codes as the following:

int CVICALLBACK FhCallbck (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	int	cnt = 0, aSize = 30000,fH = 0;
	int	r = 0;
	switch (event)
	{
		case EVENT_COMMIT:
			 // Initial array dimensioning
	         c1 = malloc (aSize * sizeof (double));
	         c2 = malloc (aSize * sizeof (double));
	         c3 = malloc (aSize * sizeof (double));
			 c4 = malloc (aSize * sizeof (double));
	         c5 = malloc (aSize * sizeof (double));
	         et = malloc (aSize * sizeof (double));
			 fH = OpenFile ("yb.txt", VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
	while (1) {

	     r = ReadLine (fH, buf, 511);
        if (r == -2) break;
		
		if (!strlen (buf)) goto loop;	// Do not scan empty lines

		// Parse line read and fill the array
		Scan (buf, "%d[x]%d[x]%d[x]%d[x]%d[x]%d[x]%s[dt#]%f[x]%s[dt#]%f[x]%s[dt#]%f[x]%s[dt#]%f[x]%s[dt#]%f",
                  &ti.tm_mon, &ti.tm_mday, &ti.tm_year, &ti.tm_hour, &ti.tm_min, &ti.tm_sec, &c1[cnt], &c2[cnt], &c3[cnt], &c4[cnt], &c5[cnt]);
		// Adjust fields for tm struct correct format
		ti.tm_mon--; ti.tm_year -= 1900;
		// Calculate timestamp
		et[cnt] = mktime (&ti);
		// Check array size and increase if needed
		if (++cnt > aSize) {
			aSize += 500;   // Increase array size
			// Further memory allocation
			c1 = realloc (c1, aSize * sizeof (double));
			c2 = realloc (c2, aSize * sizeof (double));
			c3 = realloc (c3, aSize * sizeof (double));
			c4 = realloc (c4, aSize * sizeof (double));
			c5 = realloc (c5, aSize * sizeof (double));
			et = realloc (c5, aSize * sizeof (double));
		}
		loop:	;
	}
	CloseFile (fH); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_CO2, et, c1, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_O2, et, c2, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_CO, et, c3, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_H2S, et, c4, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED); 
	PlotXY (ybppanelHandle, PANEL_YBP_GRAPH_CH4, et, c5, cnt, VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
		// Free dynamic memory
	if (c1) free (c1);
	if (c2) free (c2);
	if (c3) free (c3);
	if (c4) free (c4);
	if (c5) free (c5);
	if (et) free (et);	

	        break;
	}
	return 0;
}

 But it can still lead to crash.It needs take out  five kinds of data here, and later I have to take seven kinds of data  out and plot them on graph.

I don't know how to aviod these similar mistakes.

Would you have any good idea ?

Thank you very much !

Best regards.

 

xiepei 

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 10 of 23
(4,740 Views)