NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

DATE Data Type

I'm using TS_OutputMessageGetTimeStamp to get the time stamp of output messages. The time stamp is in DATE data type. How can I convert DATE to a string or something like "struct tm" in C?
 
Thanks
Eric
0 Kudos
Message 1 of 9
(4,137 Views)
Hi Eric,
 
Assign the DATE type initially to a number.  Then use a Statement step to convert the number to a string data type using the Str() function.  Your statement would appear similiar to:

Locals.myString = Str( Locals.myNumber )

 

Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 2 of 9
(4,118 Views)

I tried Jessica's suggestion - assigning DATE to a number and use Str() to convert to a string. I got a string with the format of double, eg 12345.678. In my application, I can't do the convert in TS sequence. It needs to be in the C code. Could you give me any suggestion?

Thanks

Eric

 

0 Kudos
Message 3 of 9
(4,059 Views)
Hi Eric,

I am sorry to hear that didn't work.  Can you provide a little more information about what you are trying to achieve?  What variable type are you assigning the DATE return type to?  Can you provide a sample of what the DATE type is returning?

If you can successfully assign the DATE type to an integer, you may be able to use the itoa() function in your C code.
Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 4 of 9
(4,031 Views)

Jessica,

I have a custom user interface using TS engine. When I get TS_UIMsg_OutputMessages message from TS, I need to log all OutputMessage from OutputMessages to a text file. I got date variable from TS_OutputMessageGetTimeStamp, but I'm not sure how to convert to a date string.

Here is what I've done :

case TS_UIMsg_OutputMessages:
{
 ...

 Date date;
 TS_EngineGetOutputMessages(gEngine, 0, &hSrcMessages);
 TS_EngineNewOutputMessages(gEngine, 0, &hDestMessages);
 TS_OutputMessagesTransferMessagesToCollection(hSrcMessages, 0, hDestMessages);

 TS_OutputMessagesGetCount(hDestMessages, 0, &count);
 if ( count <= 0 )
 {

 CA_DiscardObjHandle(hDestMessages);
  CA_DiscardObjHandle(hDestMessages);
  break;
 }

 for(i=0; i<count; i++)
 {
  TS_OutputMessagesGetItem(hDestMessages, 0, CA_VariantLong(i), &hMessage);
  TS_OutputMessageGetTimeStamp(hMessage, 0, &date);
  
  // log message here with timestamp
  
 }

 ...
  
}

 

0 Kudos
Message 5 of 9
(4,014 Views)

Jessica,

I have a custom user interface using TS engine. When I get TS_UIMsg_OutputMessages message from TS, I need to log all OutputMessage from OutputMessages to a text file. I got date variable from TS_OutputMessageGetTimeStamp, but I'm not sure how to convert to a date string.

Here is what I've done :

case TS_UIMsg_OutputMessages:
{
 ...

 Date date;
 TS_EngineGetOutputMessages(gEngine, 0, &hSrcMessages);
 TS_EngineNewOutputMessages(gEngine, 0, &hDestMessages);
 TS_OutputMessagesTransferMessagesToCollection(hSrcMessages, 0, hDestMessages);

 TS_OutputMessagesGetCount(hDestMessages, 0, &count);
 if ( count <= 0 )
 {

  CA_DiscardObjHandle(hDestMessages);
  CA_DiscardObjHandle(hDestMessages);
  break;
 }

 for(i=0; i<count; i++)
 {
  TS_OutputMessagesGetItem(hDestMessages, 0, CA_VariantLong(i), &hMessage);
  TS_OutputMessageGetTimeStamp(hMessage, 0, &date);
  
  // log message here with timestamp
  
 }

 ...
  
}

 

0 Kudos
Message 6 of 9
(4,014 Views)

could you convert it to a variant and then do something with it... i.e. CA_VariantDate function converts the Date to a variant and then maybe use some of the variant functions to get it as a string???

I don't have CVI or I'd play around with it.  Sorry! 

OR what about the asctime function? I'm assuming the Date datatype is just a struct like that.

Anyhow, that's my 2 cents. 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 7 of 9
(4,005 Views)

From MSDN: some C Windows SDK functions that could help you are:

VariantTimeToSystemTime

GetDateFormat or GetDateFormatEx 

0 Kudos
Message 8 of 9
(3,982 Views)

James,

Thanks. It works.

Eric

0 Kudos
Message 9 of 9
(3,968 Views)