High Performance OPC UA Server SDK  1.2.0.193

Retrieve current time in different formats and sleep. More...

Data Structures

struct  ua_timestamp
 Timestamp struct used by ua_time_timestamp. More...
 

Functions

int ua_time_datetime (uint64_t *dt)
 Returns the current time in ua_datetime format. More...
 
int ua_time_set_datetime (uint64_t dt)
 Sets the system time as ua_datetime (FILETIME). More...
 
int ua_time_build_datetime (uint64_t *dt)
 Returns the build time as UA datatime. More...
 
int ua_time_timestamp (struct ua_timestamp *ts)
 Returns the current time in ua_timestamp format. More...
 
int ua_time_set_time (const struct ua_timestamp *ts)
 Sets the system time as ua_timestamp format (unix time). More...
 
uint64_t ua_time_tickcount_min (void)
 Minimum value returned by ua_time_tickcount.
 
uint64_t ua_time_tickcount_max (void)
 Maximum value returned by ua_time_tickcount.
 
uint64_t ua_time_tickcount (void)
 Returns the number of milliseconds since some unspecified starting point.
 
void ua_time_usleep (unsigned int usec)
 Suspend execution of the calling thread (at least) usec microseconds. More...
 
void ua_time_unixtime_to_filetime (const struct ua_timestamp *ts, uint64_t *ft)
 Converts Unix time to Windows FILETIME. More...
 
void ua_time_filetime_to_unixtime (const uint64_t *ft, struct ua_timestamp *ts)
 Converts Unix time to Windows FILETIME. More...
 

Detailed Description

Retrieve current time in different formats and sleep.

Function Documentation

int ua_time_build_datetime ( uint64_t *  dt)

Returns the build time as UA datatime.

int ua_time_datetime ( uint64_t *  dt)

Returns the current time in ua_datetime format.

For more type safety use ua_datetime_now.

Parameters
dtPointer to uint64 to write time to.
Returns
Zero on success or errorcode on failure.
void ua_time_filetime_to_unixtime ( const uint64_t *  ft,
struct ua_timestamp ts 
)

Converts Unix time to Windows FILETIME.

Parameters
ftPointer to uint64_t with Windows FILETIME.
tsPointer to ua_timestamp with Unix time.
int ua_time_set_datetime ( uint64_t  dt)

Sets the system time as ua_datetime (FILETIME).

This is a convenience wrapper for ua_time_set_time which uses ua_datetime instead of unix time. This can be useful when the time source is an OPC UA variant value.

Parameters
dtCurrent time to write as ua_datetime.
Returns
Zero on success or errorcode on failure.
int ua_time_set_time ( const struct ua_timestamp ts)

Sets the system time as ua_timestamp format (unix time).

Note that you need the necessary admin permissions on most systems to use this function. This function is mainly useful for small embedded systems which have no built-in time synchronization like NTP. On full-featured operating systems like Linux/Unix and Windows the operating systems takes care about time synchronization and you should not interfere with that.

Parameters
tsPointer to ua_timestamp with current time.
Returns
Zero on success or a negative error code with the operation fails.
int ua_time_timestamp ( struct ua_timestamp ts)

Returns the current time in ua_timestamp format.

Parameters
dtPointer to ua_timestamp to write time to.
Returns
Zero on success or a negative error code with the operation fails.
void ua_time_unixtime_to_filetime ( const struct ua_timestamp ts,
uint64_t *  ft 
)

Converts Unix time to Windows FILETIME.

Parameters
tsPointer to ua_timestamp with Unix time.
ftPointer to uint64_t with Windows FILETIME.
void ua_time_usleep ( unsigned int  usec)

Suspend execution of the calling thread (at least) usec microseconds.