DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary Meta Data

I've got Binary Meta Data in my file format that I need to read in, I need to write a DataPlugin to read this. I also have my Meta Data and my Rawdata in separate files, I need to know how to do this. Thanks.
0 Kudos
Message 1 of 4
(3,685 Views)
Hi Garett,

You do have the DataPlugin API, right? Just in case, I'm including it below, though it's available for download at www.ni.com/dataplugins. In order to get information from a second file, you will need to create a new file object which accesses the other file (you'll have to know how to get the header file path from the data file path, or vice versa):

HdrFilePath = File.Info.Drive & File.Info.Directory
HdrFilePath = HdrFilePath & File.Info.FileName & ".HDR"
Set HdrFile = OpenFile(HdrFilePath)

Then with the following 3 items:

HdrFile.Formatter.ByteOrder
HdrFile.Position
HdrFile.GetNextBinaryValue(eDataType)

You can read off all the binary header information you need from that second header file.

Ask if you have further questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,668 Views)
Thanks for that beginning steps...

My Meta Data is exactly 80 bytes wide per channel block, I need to read in all the data. Each block is a mix of strings, signed and unsigned integers, and reals. It seems that I can't use the getnextbinaryvalue() command with strings. Also, I need to convert the binary to useful info, i.e. I need readable strings and numbers.
0 Kudos
Message 3 of 4
(3,671 Views)
Hi Garett,

You're going to need to make a single "File.Get...()" function call for each property stored in that 80 bytes. While it is possible to read those 80 bytes into a variable and parse the values from the variable, it's actually much simpler and no slower to request one property value after another directly from the file. Note that the File.Position moves automatically when you call a "File.Get...()" function.

When you call the method "File.GetNextBinaryValue(eDataType)" to read out numeric information stored in binary format, it returns the stored numeric value in a variant variable of the correct subtype (I32 or DBL). You can then happily MsgBox that value, as in:

MsgBox File.GetNextBinaryValue(eR64)

will output the numeric value stored in the file at File.Position as a binary 64 bit real (double).

If you want to read the raw ASCII characters directly from the file, for instance in the case of string properties, you just have to know how many bytes the string property is and use the
"File.GetCharacters(Bytes)" method. Again, this returns the string value in a variant variable of string subtype. You can also happily MsgBox this value also, as in:

MsgBox File.GetCharacters(10)

will output the 10 character string value stored in the file at File.Position.

Note that the DataPlugin API has 4 examples of how to create DataPlugins, with specific directions and helpful screenshots-- I recommend you look through these examples when getting started with DataPlugins.

Ask as you have further questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,635 Views)