09-12-2012 12:32 PM
I have following code. It ran without error but no *.TDMS file was created. Would anyone could point me to error? I am new to DIAdem functions.
//==============================================================================
//
// Title: Command-line Application
// Purpose: A short description of the command-line tool.
//
// Created on: 9/12/2012 at 10:28:28 AM by xpertsolutions.
// Copyright: xpert inc.. All Rights Reserved.
//
//==============================================================================
//==============================================================================
// Include files
#include <utility.h>
#include <cvitdms.h>
#include <ansi_c.h>
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
#define tdmsChk(f) if (tdmsError = (f), tdmsError < 0) goto Error; else
//==============================================================================
// Constants
#define TDMS_FILENAME "TestTdms.tdms"
#define TDMS_FILE_PATH "D:\\temp\\CreateTdmsFile\\TestTdms2.tdms"
#define TDMS_FILE_DESC "Test 200 Hz TDMS data format"
#define TDMS_FILE_TIT "Test 200 Hz TDMS data format"
#define TDMS_FILE_AUT "No Joen"
#define TDMS_ORION_200_HZ_CHANS 44
#define NUM_MAX_POINTS 44
//==============================================================================
// Types
//==============================================================================
// Static global variables
static const char * GROUP_NAME = "200 Hz data";
static const char * GROUP_DESC = "Test 200 Hz data collect by simulation test";
//==============================================================================
// Static functions
//==============================================================================
// Global variables
double startTime, elapsedTime;
TDMSFileHandle hTdmsTestFileHandle;
TDMSChannelGroupHandle hTdmsTestGroupHandle;
TDMSChannelHandle * phChannels;
//==============================================================================
// Global functions
/// HIFN The main entry-point function.
/// HIPAR argc/The number of command-line arguments.
/// HIPAR argc/This number includes the name of the command-line tool.
/// HIPAR argv/An array of command-line arguments.
/// HIPAR argv/Element 0 contains the name of the command-line tool.
/// HIRET Returns 0 if successful.
int main (int argc, char *argv[])
{
int tdmsError = 0;
int i = 0;
unsigned int usChan;
char szChanName[20];
char szChanDesc[20];
char *values[] = {"one", "two", "three", "four", "five"};
startTime = Timer();
//tdmsChk (TDMS_CreateFile(TDMS_FILE_PATH, TDMS_Streaming, TDMS_FILENAME,
// TDMS_FILE_DESC, TDMS_FILE_TIT, TDMS_FILE_AUT, &hTdmsTestFileHandle));
tdmsError = TDMS_CreateFile(TDMS_FILE_PATH, TDMS_Streaming, TDMS_FILENAME,
TDMS_FILE_DESC, TDMS_FILE_TIT, TDMS_FILE_AUT, &hTdmsTestFileHandle);
tdmsError = TDMS_AddChannelGroup (hTdmsTestFileHandle, GROUP_NAME, GROUP_DESC, &hTdmsTestGroupHandle);
phChannels = malloc (sizeof(TDMSChannelHandle) * TDMS_ORION_200_HZ_CHANS);
for (usChan = 0; usChan < TDMS_ORION_200_HZ_CHANS; usChan++)
{
sprintf (szChanName, "point_%d", usChan);
sprintf (szChanDesc, "Data for channel %d", usChan);
tdmsError = TDMS_AddChannel (hTdmsTestGroupHandle, TDMS_Double, szChanName, szChanDesc, 0, &phChannels[usChan]);
//tdmsError = TDMS_AppendDataValues (phChannels[usChan], decvalue, 5, 1);
}
free (phChannels);
tdmsError = TDMS_CloseFile (hTdmsTestFileHandle);
return 0;
}
Solved! Go to Solution.
09-13-2012 10:05 AM
Hi NiCoder,
I see that you created a duplicate post. I just want to go ahead and link it in this thread
Cheers,