08-14-2008 07:41 AM
Hello everybody,
I would like to ask for some advice regarding the following problem:
I am writing a program which saves measurement data into a TDMS file. Apart from the predefined properties I add some more properties which contain some data or information about the measurement. For example: a property called "volume" is added which contains the volume of water in the testbed's vessel and another property "no. of gauges" is added which holds the number of measurement devices. For these additional properties I use different data types. The property "volume" is of type TDMS_Double while the property "no. of gauges" is of type TDMS_UInt8 (others are of type TDMS_String).
I know how to retrieve the number of properties, their data type and the value. Regarding the latter I typically know what data type to expect and therefor can create a variable of the proper type into which the program stores the value. Relating to the above two examples the program would define a double variable for the volume and an integer variable to store the number of gauges. But in this way I need to write an individual subroutine for reading the properties for each application (the different applications require different sets of properties).
Instead of writing for each application an individual subroutine I would prefer to have a general subroutine which is able to retrieve all properties from file, channel groups and channels even if it is not known in advance of what data type they are. How can this be done? Is there a programming technique which can handle this sort of problem (e.g. using variables of type "void" together with casts)?
Thanks in advance,
Thomas
09-01-2008 03:01 AM
Hi Thomas,
have you tested the attached example (TDMS Reader).
Best regards
Rüdiger
09-01-2008 04:27 AM
Hello Rüdiger,
I have used this example as a starting point to learn how to use the TDMS format. But this example only retrieves some of the "standard properties" (TDMS_FILE_NAME, TDMS_FILE_DESCRIPTION, TDMS_CHANNELGROUP_NAME, TDMS_CHANNELGROUP_DESCRIPTION, TDMS_CHANNEL_NAME, TDMS_CHANNEL_DESCRIPTION). As they are all strings it is easy to allocate a corresponding piece of memory.
But how about additional properties apart from those standard ones? If it is not known in advance of what type additional properties are how can I allocate the necessary memory? For example: To some TDMS files I add a property of type double to every channel group which contains a flow rate. In other TDMS files I don't have this property (all TDMS files are created by my own programs). Ideally you would have a subroutine which identifies all properties and their type - this can be done using the corresponding functions - and stores them in the proper variables.
This is my problem: If the program finds a "non-standard" property of type double, how can it create/allocate the corresponding variable/memory assuming the program does not know about this property in advance? My question is probably less TDMS related but more general.
Thanks for your answer,
Thomas
09-01-2008 09:48 AM
Hi Thomas,
please read the "TDMS Read Custom Properties" section under following link.
Link:
http://zone.ni.com/devzone/cda/tut/p/id/5499
You can interpret the property value as string but finaly you have to know the data type of the property value in order to convert it in LabWindows/CVI to the appropriate data type.
Best regards
Rüdiger