01-22-2019 07:49 AM
A common method for measurement settings we use involves the use of clusters, which may contain different controls (numeric, boolean, string, etc.) that are set by the user at run-time to specify measurement conditions.
It is helpful to be able to dump these to the header of a measurement text .csv file so that during data analysis, there is no ambiguity about the important measurement parameters.
This can be done by unbundling the cluster (which one has to usually anyways) and then manually wiring the controls with string constants at coding time to a text file VI. This is a messy solution, is not robust with a change in cluster content during code edits that happen at some times, and takes up block diagram real estate.
I want to be able to programmatically (by defining a sub VI) extract key-value pairs (name of control, value of control) at run-time and then dump the text to a header string (which would perhaps be the output port of this sub VI). I have played around with Property Nodes to do this, but cannot figure out how to get both keys and their values in a loop (will need to find out number of elements).
01-22-2019 07:58 AM
Hi m-s,
using the cluster reference
All "Gets" are done using property nodes…
01-22-2019 09:08 AM
Depending on the amount of data types you need it can be some work, but it's a one time job.
/Y
01-22-2019 08:16 PM - edited 01-22-2019 08:18 PM
You can set this in a functional global.
Use the VI Flatten to string and save this to a text file. you can encode it basically to prevent modification by doing a XOR on the string.
Then redo the save XOR on the string at the application initialization and Unflatten from string with you cluster prototype to get your data back.
The magic of this method is that if you ever change the type def that defines your parameter, everything id done automatically.
Of course if it needs to be human readable, why not using the JSON tools?
Or do as specified above... it's a one time hard work.
Benoit