DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating TDMS Waveform File using DDC_ functions in C 6.0?

Solved!
Go to solution

I am trying to implement an export written in C 6.0. I can make TDMS files using the DDC_ commands without any problem. But I cant figure out how to make waveform TDMS files. I figured if I added the wf_ properties I should be able to set the waveform=Yes. But it appears to be more complicated than that.

 

Here is what I have working so far ... (excluding the error handling to make it easier to see)

DDC_CreateFile(sDestFileName, "TDMS", gszinfoline1, gszinfoline2, gszinfoline3, gszinfoline4, &hOutputFile);

DDC_AddChannelGroup(hOutputFile, szGROUP_NAME, szGROUP_DESC, &hgroup)

DDC_CreateChannelGroupPropertyTimestampComponents(hgroup,
                                                                      szCHANNEL_NAME,
                                                                      (unsigned int)year,
                                                                      (unsigned int)month,
                                                                      (unsigned int)days,
                                                                      (unsigned int)hours,
                                                                      (unsigned int)minutes,
                                                                      (unsigned int)wholeseconds,
                                                                      (double)fractionseconds);

DDC_AddChannel(hgroup, DDC_Double, szCHANNEL_NAME, szCHANNEL_DESC, szCHANNEL_UNITS, &lphchannel);

DDC_CreateChannelProperty (lphchannel,"wf_increment", DDC_Double, dInterval);
DDC_CreateChannelProperty (lphchannel,"wf_xname", DDC_String, "Time");
DDC_CreateChannelProperty (lphchannel,"wf_xunit_string", DDC_String, "s");
DDC_CreateChannelProperty (lphchannel,"wf_start_offset", DDC_Double, 0.0);

Any suggestions? (All the details on this in help are either aimed at LV or completely missing)

 

Thanks much,

Don

0 Kudos
Message 1 of 7
(5,932 Views)

Hi,

 

I have a few questions for you.  First, I want to confirm that you are using CVI 6.0?  Second, could you provide more information on what is going wrong with your TDMS file?  Are you receiving an error?  Or are you receiving something unexpected in your TDMS file?  Also, the code you posted above doesn’t seem to actually be appending any data to the channel that you created.  Is this just a section of the code?

 

 

Regards,

0 Kudos
Message 2 of 7
(5,896 Views)

Hi Lindsay,

Thank you so much for your reply.

I'm not using CVI, I am using Microsoft C/C++ 6.0.

Everything is fine if I make data TDMS files, but everything I have tried to make a waveform file has failed.

The posted code has error handling cut out and you are right, i was missing the following call at the end.

DDC_SetDataValues(lphchanneltime,  lpthischanneltimesarray,  (unsigned int)(scansinfile/decimationfactor));

 

This code all works to make a TDMS data file but I have to include a separate time channel to make it graphable (not shown).

I would rather specify the wf_increment and not include the Time channel with time values for each sample.

 

I would have thought all I need to do is set the waveform property on each channel to yes but nothing I do changes that from "No" to "Yes"

 

Kind Regards,

Don

0 Kudos
Message 3 of 7
(5,892 Views)
Solution
Accepted by topic author Don_White

Hi Don,

 

Thanks for the additional information.  After doing a bit more research, it looks like there are 3 properties required in order for the waveform property to be set to yes.  These are wf_start_offset, wf_increment, and wf_samples.  If you add in a call such as the following this should resolve the issue:

 

DDC_CreateChannelProperty (lphchannel,"wf_samples", DDC_Int32, 5);

 

Just replace 5 with the length of your array.

 

 

Regards,

Message 4 of 7
(5,873 Views)

Thats what was missing, thank you! 🙂

0 Kudos
Message 5 of 7
(5,869 Views)

On a related question what is the format of argument for setting wf_start_time?

I tried ...

        ddcError = DDC_CreateChannelProperty(lphchannel,"wf_start_time", DDC_Timestamp,"05/07/2014 12:22:23.000");
I tried type DDC_String also but no luck.

 

Thanks,

Don

0 Kudos
Message 6 of 7
(5,865 Views)

There is an additional method to create time properties.

 

int __stdcall DDC_CreateChannelPropertyTimestampComponents (DDCChannelHandle channel,
               const char *property,
               unsigned int year, 
               unsigned int month, 
               unsigned int day,
               unsigned int hour, 
               unsigned int minute, 
               unsigned int second, 
               double milliSecond);

 

0 Kudos
Message 7 of 7
(5,824 Views)