11-08-2017 08:10 AM
Flush written TDMS data from examples
I wonder whether tdms operations can change the tdms file reference. When writing to tdms in a while loop, do I need shift registers to have the file reference stored for the next iteration or can I just use a tunnel? See the above example (shipped with the LabVIEW examples.
This becomes relevant when using a state machine where in one state I open a tdms file, write in another state and close the reference in yet another state (when exiting the vi).
I need to store the tdms file reference anyway, so it's not an issue to "overwrite" it whenever I write to the tdms file. In fact, that's what I've always done in the past.
However, I recently updated my state machine and removed all tdms references coming out of the tdms write vi. Is this ok or not?
Write to tdms (and flush) in state machine. TDMS reference out is not wired. Is this ok?
Solved! Go to Solution.
11-08-2017 08:24 AM
@donkdonk wrote:
I wonder whether tdms operations can change the tdms file reference. When writing to tdms in a while loop, do I need shift registers to have the file reference stored for the next iteration or can I just use a tunnel? See the above example (shipped with the LabVIEW examples.
No, the file-refnum will not change. In your special case with a for loop that is executed at least once it would not make a differnce if you did not use a shift register. But it is still very good practice to use a shift register. Here is an example where is does make a difference:
With an for-loop with autoindexing, wires with a shift-register retain their value, even if the for-loop is executed zero times. Wires use their value.
Write to tdms (and flush) in state machine. TDMS reference out is not wired. Is this ok?
I'd say: yes, that's ok.
Regards, Jens
11-08-2017 08:36 AM
In your State Machine setup, you should be fine. In the FOR loop, I recommend always having the reference in a shift register due to a condition where the loop runs 0 times. Yes, the happens a lot, especially with autoindexing tunnels and an empty array suddenly comes around. In that case, a tunnel will output the default value and your reference is gone. But a shift register uses the same memory location on both sides of the loop, so what you initialize the shift register as is what will come out.
11-09-2017 07:21 AM
Thanks a lot for the prompt replies!
Now I can conclude that tdms operations do not change the tdms file reference and therefore my state machine setup is ok.
(BTW, I have been using my SM for a while and I did not run into problems, justed wanted to know for sure).
Very good for pointing out what might happen when using for loops!
Of course, easiest thing to do is just use shift registers. Everywhere. Probably no noticable drawback by doing just that.