04-09-2010 05:40 AM
Hi Everyone,
I am new in CVI development.. My current work is on TDMS inside CVI 8.5 , I been through CVI help on TDMS and one white paper on NI website..
My current requirement is that user is running application and see the data on graph of user interface.. if user accepts the data and press control buttoon accept the data will get saved in TDMS file.. otherwise user will redo the data acqusition process to see another iteration result to accept or deny..
I am able to write data first time but as i accept another set of data it throws an error
| -6604 | TDMS_FileCouldNotBeOpened | The file could not be opened. |
Inside TDMS_CreateFile function, i understand it may be as file is already created in first iteration..
Is there any way to update the same channel data by appending every iteration with time stamping ?
Thanks for your time and support
Regards
HS
Solved! Go to Solution.
04-09-2010 06:04 AM
Hi HS,
because you didn't tell us which function you are using we can only guess... are you aware of the function TDMS_AppendDataValues which appends data values?
04-09-2010 06:48 AM
Hi,
my syntax for control button "Accept" press is as below
-------------------------------------------------------------------------
int CVICALLBACK DataSave (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
TDMSChannelHandle mainChannel;
TDMSChannelGroupHandle mainChanGroup;
TDMSFileHandle tdmsFileHandle;
switch (event)
{
case EVENT_COMMIT:
TDMS_CreateFile ("d:\\CVI\\signal.tdms", TDMS_Streaming, "signal", "", "", "",&tdmsFileHandle );
TDMS_AddChannelGroup (tdmsFileHandle, "Main Group", "Dev1",&mainChanGroup);
TDMS_AddChannel (mainChanGroup, TDMS_Double, "Main Channel", "ai0", "", &mainChannel);
TDMS_AppendDataValues (mainChannel, sine, 100, 1);
TDMS_CloseFile(tdmsFileHandle);
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
--------------------------------------------------------------------------------------------------
This works fine as i press Accept first time, this create signal.tdms and save data in mainChannel... But as i press it to save second time it throws error code "-6604" in TDMS_CreateFile syntax...
I want to append the data in mainchannel with time stamp over and over with acceped iteration results.. number of iteration is not predefined sothat ian initialize any array for mainchannel...
Anyway around to get it solved ?
Thanks HS
04-09-2010 06:56 AM
to begin with your first line:
the function TDMS_CreateFile is obsolete. You should use the TDMS_CreateFileEx function instead.
04-09-2010 07:08 AM
04-09-2010 07:42 AM
sorry (I am using CVI2009).
My guess is that you should not close the file every time but only once and instead call TDMS_SaveFile () to write data to disk, and only if you are done call TDMS_CloseFile.
Hence, you should rearrange your code: somewhere in the beginning of the program, call TDMS_CreateFile , TDMS_AddChannelGroup , and TDMS_AddChannel , and in your button callback only keep the append / save function. Before closing your application, call TDMS_CloseFile
04-09-2010 08:08 AM
Thanks alot ! it solves my current work partially, as you know problem will come if i stop the program and restart it the again, this TDMS_CreateFile will throw same error "-6604" .. as file will be already created and closed in first run of program..
Is there any way to handle such error like as i start program it should check the TDMS file in specified location, if file exist then only data should append on click button other wise it should create file and then append on click..
Kind regards and thanks to you Mr/Ms Wolfgang for your continuous support
04-09-2010 12:51 PM