DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the TDMS C DLL API

Solved!
Go to solution
I'm looking into exporting data in the TDMS data file format in my application.
 
I found that a C DLL API existed, and I tried to include this into my code. See all my comments in end.
 
When compiled, I called the following code:
 
int ddcError = 0;
DDCFileHandle file_id = NULL;
ddcError = DDC_CreateFile(pszFileName,"TDM","TDM Export File","TDM Export File","","",&file_id);
 
Which resulted in the following error:
 
'xxx.exe': Loaded 'D:\xxx\exe\nilibddc.dll', Exports loaded.
'xxx.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.5592_none_d09196c24426e2d4\msvcp80.dll', Exports loaded.
'xxx.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.5592_none_d09196c24426e2d4\msvcr80.dll', Exports loaded.
'xxx.exe': Loaded 'D:\xxx\exe\usiEx.dll', Exports loaded.
'xxx.exe': Loaded 'D:\xxx\exe\xerces-c_2_8_usi.dll', Exports loaded.
'xxx.exe': Loaded 'D:\xxx\exe\stlport.5.0.dll', Exports loaded.
'xxx.exe': Loaded 'D:\xxx\exe\dacasr.dll', Exports loaded.
'xxx.exe': Loaded 'D:\xxx\exe\uds.dll', Exports loaded.
The thread 'TpCallbackMayRunLong' (0xe64) has exited with code 0 (0x0).
The thread 'TpCallbackMayRunLong' (0x162c) has exited with code 0 (0x0).
The thread 'TpCallbackMayRunLong' (0x1614) has exited with code 0 (0x0).
The thread 'TpCallbackMayRunLong' (0x14e8) has exited with code 0 (0x0).
First-chance exception at 0x770ee124 (kernel32.dll) in xxx.exe: Microsoft C++ exception: DataCache::ToIntMsgDa at memory location 0x09a9f6fc..
First-chance exception at 0x770ee124 (kernel32.dll) in xxx.exe: Microsoft C++ exception: ni::usi::Exception at memory location 0x09a9f7a0..
First-chance exception at 0x770ee124 (kernel32.dll) in xxx.exe: Microsoft C++ exception: DDCError at memory location 0x09a9fb18..
 
I have to say that I'm using C++ on Windows Vista, and is calling the API from a worker thread.
 
Comments:
 
* There are way to many dependent DLLs. Keep it simple for the user and supply a "nilibddc.h", "nilibddc.lib" and "nilibddc.dll".
* Error messages in the component refers to DIAdem, which is should of cause not.
* Use of MFC should be hidden and made static. It uses v8, and most are using v9 or v10.
* If this should be a serious data format, multi-dimensional arrays should be supported.
* Add a method for getting the version of the library.
* Unicode filenames, use wchar instead of char?
 
This doesn't look like a finished product. I really hope someone can help me.
 
-cpede
0 Kudos
Message 1 of 18
(9,880 Views)

If you want to export to tdms

 

pszFileName = "C:\out.tdms"

 

use "TDMS" as file type.

If you want to export TDM

 

pszFileName = "C:\out.tdm"

 

use "TDM".

 

If you are looking for a simple way to export to tdm

http://zone.ni.com/devzone/cda/tut/p/id/2824

may be a solution for you. It has the capability to

write a tdm header to an existing binary file given in

a specified format (one header/one dll but TDM export only).

 

P.S.: What error code did you get?

  Did a logfile appear?

  What do you mean by DIAdem error?

 


0 Kudos
Message 2 of 18
(9,875 Views)

Hi thanks for the reply.

 

First what is the difference between TDMS and TDM ??

 

I can see that the files I found is probable related to TDMS, and the ones you suggested is TDM.

 

The TDM looks much simpler "niTdmHW1_0.dll" etc. But why is it called TDM Header Writer, can it only write headers?

 

-cpede

0 Kudos
Message 3 of 18
(9,870 Views)

The two formats TDM/TDMS represent two flavors of the NI file format.

  • Their content is: root->group->channel
  • Each level can have properties(meta data: name/value pairs)
  • The channels can have attached bulk data (measured signals)

Formats:

  • TDM: xml header containing the structural and meta data refering one or many binary files containing the bulk data. Normally its one binary file with the extension tdx. So the format is an tupel (xml header(meta data)/binary file(bulk data))
  • TDMS: Binary format containing meta and bulk data. The format is set up to allow easy append which allows streaming usage. To speed up read an additional index file might be generated.

Libaries:

  • TDM header writer: Write only! TDM only! Used to create the xml header. The bulk data refered by the tdm header can be written by the 3rd party application on its own. This allows tdm to be put on top of existing file formats/writers.
  • ddc lib: Read/Write! TDM/TDMS! The lib can be used to read/write TDMS or TDM directly in your application.

P.S.: The name DIAdem in the help file is the name of the API in LabWindows/CVI. Because TDM was first introduced in NI DIAdem. The API was exported to allow 3rd party to read/write TDM/TDMS files.

0 Kudos
Message 4 of 18
(9,857 Views)

I'm not sure I fully understand the difference. TDM is a file format where you add an xml header to an already existing binary file, and TDMS is a binary file format for string data.

 

But when I change the File Format parameter in DDC_CreateFile from "TDC"to "TDMS" my program doesn't crash, but the function fails with error -6204, and the callstack shows:

 

First-chance exception at 0x770ee124 (kernel32.dll) in xxx.exe: Microsoft C++ exception: DataCache::ToIntMsgDa at memory location 0x08a5f6fc..

First-chance exception at 0x770ee124 (kernel32.dll) in xxx.exe: Microsoft C++ exception: ni::usi::Exception at memory location 0x08a5f7a0..

First-chance exception at 0x770ee124 (kernel32.dll) in xxx.exe: Microsoft C++ exception: DDCError at memory location 0x08a5fb18..

 

The DDC methods looks as they supports what I want. Besides that if fails my biggest problem is all the dependent DLL's needed.

 

-cpede

0 Kudos
Message 5 of 18
(9,851 Views)
Solution
Accepted by cpede

TDM: 2 file format. XML header(*.tdm) + Binary file(*.tdx)

TDMS: 1 file format (*.tdms) + optional index file that is recreated if deleted.

 

Did you also copy the DataModles folder or only the dlls?

Are you capable to run the included examples?

 

Greetings

Andreas

0 Kudos
Message 6 of 18
(9,842 Views)

Ok, I got it to work.

 

I like the API it is simple and intuitive.

 

BUT

 

No Unicode support ?

No multi-dimensional support ?

 

And, there is no way that I install 10 DLL plus a DataModel folder into my application for supporting TDMS export.

 

I know that NI doesn't care much about installing a lot of unnecessary stuff on the users PC, just look at the

DAQmx driver installation over 1 GB for installing a simple AD driver ??? This is the no one complaint from our

customers !!!

 

So, no way I'm installing all these files. I will stick to HDF5, one DLL, lib and header file.

 

Thanks for all the help, and I really hope NI begins to take this serious.

 

-cpede

0 Kudos
Message 7 of 18
(9,835 Views)

Ok, just for information, when I use the TDMS format it seems that I can strip the installation down to the following files:

 

nilibddc.dll

tdms_ebd.dll

usiPluginTDM_dll

uspTdms.dll

DataModels -> USI -> TDM -> 1_0 -> USI_TDM_1_0.xml

 

If selecting TDM and maybe calling other methods, who knows ?

 

By the way, I can get the error message: "Error occurred when loading the DIAdem library DLL (nilibddc.dll)", and that is

what I mean by mentioning DIAdem, even it is a standalone driver.

 

-cpede

0 Kudos
Message 8 of 18
(9,832 Views)

You can't strip anything from the package. There is no way that you do not need the files you do not mention.

The package includes an installer module that helps to install the component on target systems.

 

Its like I said.the DDC means DIAdem Connectivity. That is the name of the API because of historical reasons.

0 Kudos
Message 9 of 18
(9,827 Views)

Hello,

 

I could use your expertise, too.

 

I keep on getting this error: "Error occurred when loading the DIAdem library DLL (nilibddc.dll)"

 

I am using VS2010C++ express version.

 

Thank you

B

0 Kudos
Message 10 of 18
(7,894 Views)