Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving graph data as binary file

I need to save 3 graphs. Each graph data consists of:

1) 1D array of clusters of 2 elements – XY graph curves info (acquired previously).

2) Clusters of 2 elements - XY graph curve info (acquired in real time)

3) 1D array of strings - names of XY graph curves (acquired previously).

4) string – name of XY graph curve (acquired in real time).

 

I thought that easiest way to save data would be as binary file…

I took the NI example and modified it to fit my requirements: to save and retrieve 1D array of clusters with 4 elements (please see description above). Also modified sub VIs are attached.

 

The questions:

1) What is easiest way to save and retrieve the data? binary file? Or something else? Can you give me an example. Text file seems to me too complicated. I used already text file format, but only for saving one curve.

2) If binary file is most appropriate: what is wrong with my Sub VIs – I can save the file but when I was retrieving it I got the message file is corrupted.

 

Download All
0 Kudos
Message 1 of 3
(3,464 Views)
VVV,

Binary files should be an easy way to read and write your file.  I had a look at your program, and the problem is that the data types differ between what you are reading and writing.  You are writing an array of clusters of your information, but you are just reading a cluster of your information.  The data types between your reads and writes must be the same.

To fix your program, you're going to need to make those types match.  Based on the description of your program, I can not figure out which data type is correct.  If you are only writing one cluster of data in your write, you should get rid of the outer array in your write program, and just write a cluster.  If you do indeed want to write an array of clusters, you need to change the data type in your read program by putting the cluster contant inside of an array.

Keep in mind that the output of the read is going to be an array of the data type that you provide it.  If the data type you provide it is an array, the output is going to be an array of clusters of arrays, since LabVIEW doesn't allow arrays of arrays.  This can get pretty confusing, I know, but it depends on how your program and your file are set up.  You may need to index the array and/or unbundle the output to get the information you desire.

One other thing you're going to want to change in your read program is the count input for your read operation.  The way you have it set up now, it determines the count based on dividing the file size by 8.  Since the data you are writing is of an undetermined size (due to variable sized arrays) and is not a fixed 8 bytes, this approach will not work.  Your best bet is to wire in a constant of 1 to read a single cluster of data, or to use a constant of -1 to read all of the data written to the file.

I have modified your example and attached a set of two different read and write files.  One version (with "cluster" in the file names) assumes that for each write made to the file you want to write a single cluster of data.  The other version (with "array of clusters" in the file anmes) assumes that for each write made to the file you want to write an array of clusters of data.

I hope this helps clear things up (instead of making them more confusing!), but if you need further clarification I would be happy to help you.

Regards,
0 Kudos
Message 2 of 3
(3,443 Views)

Hi Devin:

 

Thanks a lot for reply especially thanks for examples: The example "array of clusters" works for me very well.

 

Thanks again,

Vassiliy

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