Passing Time to PI as a Floating-Point Value

When using the PITIMESTAMP structure to put new data values into PI, an alternate mechanism for passing time values to PI is supported.

Some foreign devices generate timestamps in the form of an integer or floating point number of seconds after a given starting point. This time can be passed directly to PI by setting all fields of the PITIMESTAMP structure to zero, except seconds.

The seconds field in this case will be assumed to contain the floating-point number of seconds, Universal Coordinated Time (UTC) as implemented on the computer running the PI-API application. UTC is the time returned by the C language run-time library time function.

This means that the following programming examples are functionally equivalent:

Example 1:

PITIMESTAMP tm;

pitm_setcurtime(&tm, 0);

err = pisn_putsnapshotx(pt, &drval, 0, 0, 0, &istat, 0, &tm);

Example 2:

PITIMESTAMP tm;

time_t now;

memset((void *) &tm, 0, sizeof(PITIMESTAMP));

time(&now);

tm.second = (double) now;

err = pisn_putsnapshotx(pt, &drval, 0, 0, 0, &istat, 0, &tm);

Example 3:

PITIMESTAMP tm;

if ( pitm_settime(&tm, 0, 0, 0, 0, 0, (double)time(NULL)) == 0)

err = pisn_putsnapshotx(pt, &drval, 0, 0, 0, &istat, 0, &tm);

Process data retrieved by your application from the PI System snapshot or archive are always returned with the fields of the PITIMESTAMP structure fully populated with local time values.

Enabling Operational Intelligence