04-04-2012 04:58 PM
I am trying to figure out a good way to determine how to line up data in a TDMS file with corresponding timestamps when the user in my application adds channels.
Here's the scenario,
Lets say I've been recording 10 channels (called Ch0,Ch1...Ch9) in a group called 'Data'. My data appears as follows in the TDMS file:
(10 Ch's, 3 Samples)
Timestamp | Ch0 | Ch1 | Ch2 | Ch3 | Ch4 | Ch5 | Ch6 | Ch7 | Ch8 | Ch9 |
12:00:01 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
12:00:02 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
12:00:03 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
Let's say now the user decides to add an additional channel to the group. The TDMS write function will add the channel, but the new data does not line up with the corresponding timestamp, instead it start writing to the first row as follows:
(11 Ch's, 6 samples, 3 new channel samples)
Timestamp | Ch0 | Ch1 | Ch2 | Ch3 | Ch4 | Ch5 | Ch6 | Ch7 | Ch8 | Ch9 | Ch10 |
12:00:01 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 |
12:00:02 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 |
12:00:03 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 |
12:00:04 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | |
12:00:05 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
|
12:00:06 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
|
I would want it to appear as follows:
Timestamp | Ch0 | Ch1 | Ch2 | Ch3 | Ch4 | Ch5 | Ch6 | Ch7 | Ch8 | Ch9 | Ch10 |
12:00:01 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | |
12:00:02 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | |
12:00:03 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | |
12:00:04 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 |
12:00:05 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
1100 |
12:00:06 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
1100 |
Other than just starting a brand new TDMS file, can anyone think of a way to line the data up with its corresponding timestamp in this scenario? Or if there is a way to determine what the corresponding timestamp is when I read in the TDMS file.
Any help is appreciated
Thanks,
-CAC
04-05-2012 06:55 AM
Any suggestions...?
04-05-2012 08:03 AM
Can you post your block diagram ? I´m still new in Labview, I´m having trouble with the header, how to edit the header in the tdms file ?
dt (ms) | channel 0 | channel 1 | channel 2 |
0 | 1 | 2 | 3 |
0,1 | 4 | 5 | 6 |
0,2 | 7 | 8 | 9 |
0,3 | 10 | 11 | 12 |
04-06-2012 03:46 AM - edited 04-06-2012 03:47 AM
From your description that the channel values have their corresponding timestamp, I assume that you are writing the waveform data rather than those basic data type(integer, double, etc.) which do not have any timestamp related information.
The reason that the new data in Ch10 does not line up with the same timestamp data in other channels is because:
In your case, the new data in Ch10 channel should have the timestamp starting from 12:00:04 AM to 12:00:06 AM, these data are definitely stored from the first position of Ch10, and .tdms file format cannot do anything to line up the data between channels.
Timestamp | Ch0 | Ch1 | Ch2 | Ch3 | Ch4 | Ch5 | Ch6 | Ch7 | Ch8 | Ch9 | Ch10 |
12:00:01 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 (12:00:04 AM) |
12:00:02 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 (12:00:05 AM) |
12:00:03 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | 1100 (12:00:06 AM) |
12:00:04 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 | |
12:00:05 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
|
12:00:06 AM | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 1000 |
For your second question, there is a approach to determine the corresponding timestamp of each channel data read out from .tdms file. The waveform data type is stored in .tdms file in the form of three components:
So it's very easy to calculate the Timestamp of value[index] = t0 + (dt * index) (0 <= index < num of samples in value[])
Here is a VI in the attachment that demonstrates how to get the timestamp of each value in the channel.
Regards,
Tianbin