01-31-2014 06:02 AM
Hello!
I have a project when I save to TDMS file. I would like to add a button, which would open a new file and continue to write into it.
My idea is:
Event structure to handle the "new file" button. When I press the button, a new state would come to a state machine, in which I close the previous file and open the new one, and then go back to the "save" state.
It works until the new file is created, and I get back to the saving state, and one record is saved into the file. After it seems, that I lose the reference and the program writes to the memory. So when I stop the program only 1 record what I can see in the new file, the old (first) file is ok.
Any idea why can this happen?
Thank you in advance!
02-03-2014 02:50 AM
Hi,
Use any structure that can losslessly store your measurement data, specifically I recommend queues, typically used in a producer-consumer architecture. You already have a state machine, so you can use the state machine loop as the consumer loop to write data from a queue to the TDMS. Add the data source as a separate, parallel loop that acquires your measurement data, and puts it in the queue. This way, even if your state machine is busy doing other things such as opening or closing TDMS files, your data does not get lost.
Note that what I mean above is NOT necessarily the Queued State Machine Architecture. In QSM the she state machine transitions are stored in a queue, however in my recommendation above, the queue is independent of the state machine.
If you have further questions, it would be great if we could take a look at your code, maybe there is some simpler issue with the way your are using the TDMS VI-s.
02-09-2014 12:36 PM
I just can't get it work 😕 I attached the VI-s. I read the channel/group names from the csv files attached, so you have to set the paths for them.