LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows float64 data storage format.

I am trying to write a simple data gathering program that writes data from a PCI6013 card to a file on the PC in LabWindows/CVI 7.0. I have written the float64 data to the file using arraytofile function. When I open the file in a text editor the data bears no resemblance to the values saved. I wish to retrieve the data to perform analysis at a later time. I cannot use the filetoarray function as the files will be very large and I can see no way of indexing through a file with this function. So to the question how do I recover the data from the file to analyse display it?
0 Kudos
Message 1 of 3
(3,459 Views)
ArrayToFile function can write to disk in two different ways, depending on the option in "File type" field: if you choose ASCII you can read the file created with a text editor, but this consumes more room on disk. If you choose Bynary you have a more compact file but you need to read back with an appropriate program.

This code reads back some doubles from a file created with ArrayToFile and prints them to the debug window. Note the SetFilePtr instructions, by wich you can move to an fro in the file: you can build a simple data viewer customized to your actual acquisition and to the contents of your data file.

Hope this helps
Roberto


#include
#include
#include
#include

static double m[16];

static char buf[128];
static int i;
static int fH;
static char file[MAX_PATHNAME_LEN];

// Choose the file and open it
FileSelectPopup ("", "*.*", "", "Choose file to open",
VAL_LOAD_BUTTON, 0, 0, 1, 0, file);
fH = OpenFile (file, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);

// Position anywhere in the file and read some doubles
SetFilePtr (fH, sizeof (double) * 16, 0);
ReadFile (fH, buf, sizeof (double) * 8);

// Cast to the array of doubles and print them
memcpy (&m, buf, sizeof (double) * 8);
for (i = 0; i < 8; i++) {
DebugPrintf ("%d: %.1f\n", i, m[i]);
}

// Close the file
CloseFile (fH);


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 2 of 3
(3,459 Views)
Thanks for the reply the SetFilePtr function is very useful. I am saving the data in binary format because as you said it is faster. This poses the problem of retrieving the data to display or convert to ascii at a later time to then analyse. I have a text editor that can open any file and view the contents so I can see the values in hex of the stored data. What I was after is how labwindows converts a double to a format to store in a binary file so that I can reverse the process. FiletoArray does it for you but as I said you cannot index through a file using this.
0 Kudos
Message 3 of 3
(3,459 Views)