07-29-2014 08:11 PM - edited 07-29-2014 08:19 PM
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
Solved! Go to Solution.
07-30-2014 04:01 PM
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,
07-30-2014 04:22 PM
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
07-31-2014 12:49 PM - edited 07-31-2014 12:50 PM
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,
07-31-2014 01:33 PM
Thats what was missing, thank you! 🙂
07-31-2014 01:47 PM
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
08-02-2014 01:54 PM
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);