From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do determine data type?

 I am trying to write my own binary file saver and I need to list the data type in the custom header. How do you do this in labview?

0 Kudos
Message 1 of 8
(4,118 Views)
Well, that depends. If you have a custom header do you not already have defined how you're going to specify the datatype? For instance, how do you specify that you're going to read an integer or a floating point, or an array of integers as an array of floating-points? What about an array of waveforms? Are these files supposed to be read by LabVIEW only, or do other program/applications need to be able to read these files?
0 Kudos
Message 2 of 8
(4,107 Views)
I am trying to save data into a binary file generated and taken from within labview so a header does not already exist. I will take this data into a another program for further processing. The external analysis software reads an integer from the header which indicates the data type (i.e. header reads a 1 for 8-bit unsigned int, 2 for 16-bit short, 3 for 32-bit int and so on. I would like to create a case structure within labview which determines data type and then writes the correct number to the binary file header which corresponds to the data type. Currently, I have many different versions of the same file where the only difference is the header integer value and the type of data being saved. Whenever I make a change to one, then I have to go through and make changes to all of the other versions too. I am hoping to not have to do this anymore. It is quite cumbersome.
0 Kudos
Message 3 of 8
(4,102 Views)
I don't quite understand your dilemma. If you are writing the file from your LabVIEW application shouldn't you already know the datatype you are writing? If this is the case you simply write the appropriate header to the data file. Unless you are saying that in LabVIEW your data is always the same type and you are converting when you write the data to file. Again though you have to have some type of control to indicate how you want to save the data and you should then write the appropriate header to the data file. It sounds like you know what the valid values for the file headers.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 8
(4,097 Views)
The data acquistion spits out data in several different formats so a priori, I do not know the data type. It can be either a 32-unsigned int, 16-bit unsigned int, 8-bit unsigned int or the signed version of each one of these. To make the program general purpose however, I would like to incorporate floating point data points as well.
0 Kudos
Message 5 of 8
(4,095 Views)

kameronrausch wrote:
The data acquistion spits out data in several different formats so a priori, I do not know the data type. It can be either a 32-unsigned int, 16-bit unsigned int, 8-bit unsigned int or the signed version of each one of these. To make the program general purpose however, I would like to incorporate floating point data points as well.

At some point you have to know what the data type is before start collecting data. If all you have is a stream of bits there is no way to determine what the data type is. What controls how the data acquistion is getting its data? If it is test specific you could use an external configuration file to store this and use that to determine how the data should be interpreted. If you have arrays of specificdata types you could use a polymorphic VI for your data writes. Based on teh wire type of the input the appropriate VI would be called. How is your data being passed from your data acquistion to the VI that will write it to a file?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 8
(4,088 Views)

I can think of two ways to return the "type" of data programaticaly.

 

1) Flatten to string-  Will output a string of the data type that you could use in a case statement to generate your "1=U8, 2=U16....Enum.

 

2) the "To XML" fucntion Will also output the data type as a portion of the output string and allows you to select the XML schema.  You could parse the XML for the data tye.

 

It seems you almost might want to programatically determine the instance of a polymorphic VI (Like "Daqmx Read Single Chan Single Sample (U8).vi" that is used in a upper level vi..  You COULD use the "Call Chain" function to output the exact instance of the poly-morphic f you wrote the VI or, do this with some invoke nodes .

Message Edited by Jeff Bohrer on 03-08-2010 04:43 PM

"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(4,086 Views)
If in one case you're getting an array of U8s and in another case you're getting an array of floats you could also use the OpenG  "Get TDEnum From Data" VI, or the "GetTypeInfo" VI from the <LabVIEW>\vi.lib\Utility\VariantDataType. This will give you an enum of the datatype and you can then simple select what to write out to the header based on the enum value.
Message Edited by smercurio_fc on 03-08-2010 05:02 PM
Message 8 of 8
(4,077 Views)