07-14-2015 06:38 AM
Hello,
I have 1D array of cluster and I want to write the data to a tdms file.Cluster contains numeric constants and enums.Can you suggest a method to do that?
07-14-2015 07:13 AM
as far as i know, you cannot write clusters directly to TDMS.
but what you can do is to have a for-loop in which you unpack your cluster and write each member to a different channel.
example: https://decibel.ni.com/content/docs/DOC-13118
hope that helps
07-14-2015 07:15 AM
I haven't tried it but here is some code for writing anything to a TDMS.
https://lavag.org/topic/5216-tdms-for-big-config-clusters-is-there-a-better-way/
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-14-2015 07:17 AM
What type of cluster are you trying to write? Also what is the requirement to save the data in TDMS file format?
07-14-2015 07:19 AM
If all the data in the cluster is numeric, then unbundle and build an array from the values. You can write the array to the tdms file.
07-14-2015 07:23 AM
Another thought - I know you specifically asked for tdms, but If your data is one-off type data rather than continuous data-logging type data, you can write to an xml file instead. Labview will flatten and unflatten any data type to an xml string. You could even write the xml strings to a tdms file if you want!
07-14-2015 07:34 AM
@Stuart.Parkinson wrote:
Another thought - I know you specifically asked for tdms, but If your data is one-off type data rather than continuous data-logging type data, you can write to an xml file instead. Labview will flatten and unflatten any data type to an xml string. You could even write the xml strings to a tdms file if you want!
Oh I like this solution, you can use XML, JSON, or NI's flatten to string then write that as a sample in each channel. Wonder if you can do a MGI to INI or from INI as well. Then at least the data can still be human readable in each channel. Not that XML isn't human readable but it can be more difficult to view as text than an INI.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
07-14-2015 07:49 AM
@Stuart.Parkinson wrote:
Another thought - I know you specifically asked for tdms, but If your data is one-off type data rather than continuous data-logging type data, you can write to an xml file instead. Labview will flatten and unflatten any data type to an xml string. You could even write the xml strings to a tdms file if you want!
The OP did specify a 1D array. So it sounds like it is a streaming type data.
For this, I would recommend the FOR loop (autoindexing on the array), unbundle the cluster and autoindex the data out. Then write each array to the TDMS file.
07-15-2015 06:21 AM
Can you guys suggest me how the save the array of clusters into tdms.Please find sample attached vi
07-15-2015 06:59 AM - edited 07-15-2015 07:01 AM
just an example .. read up on the documentation
http://www.ni.com/tutorial/9334/en/
http://www.ni.com/white-paper/3727/en/
EDIT: couldnt add the .vi 😞 .. but drag and dropping the snippet should still work