Real Time Data Structures

The PICS real time database system uses two closely related yet distinct data structures for real time data. The internal data structure is used by the RTDB programs themselves for internal storage of the database. The real time agent allows external program to READ the internal data via a shared memory section named "RTDB Memory Image". The structure below (declared in the header file "REALTIME.h") is an example of how records in the shared memory section should be accessed. Shared memory records should be indexed by point ID number.

typedef struct RTDB_tag
{
  WORD wDate; // Date (days since 1/1/1980)
  DWORD   dwTime; // Time (ms of day)
  PS ps; // Point Status
  union EUVal_u // EU Value
  {
    float rfValue;   // EU Value for AI, AC, and AO points
    DWORD dwValue; // EU Value for non-digital points
  };      
  union RawVal_u
  {
    float rfRaw; //
    DWORD dwRaw; //
  };
  PSX psx; // Extended point status
  DWORD dwReserved;   // reserved for internal use
  WORD wReserved;
}; RTDB, *LPRTDB;

The public forms of realtime data records (one example is shown below) look very similar to the internal structure, except for the addition of a point ID (PID) and the elimination of some internal variables. These records are declared in the header file "PICS.h"

typedef struct ANALOG_tag
{
 WORD wPid; // Point ID number (1..0x7FFFF)
 WORD wDate; // Date (days since 1/1/1980)
 DWORD    dwTime; // Time (ms of day)
 PS ps; // Point Status
 float rfValue;   // EU Value
 float rfRaw; // Raw Value
 PSX psx; // Point Status, Extended
}ANALOG, FAR *LPANALOG;

All of the records for the different data types are joined together into a single union named ANYPOINT. This allows a single variable to be used for any real time record encountered. All records begin with common information (PID, date, time, status) so that any of the access types may be used to look at the record's point type field (located in the status) to determine how to handle the remainder of the record. This is the format that is used when transmitting real time data, both in UDP broadcast messages, in TCP data streams, and in ICP pipes (an EVI proprietary communication method).

This structure is used to transport PICS real time data throughout the system, by UDP (to/from RTDBA), TCP (RTServer/RTClient), and IPC (any client/provider and RTDBA) . Additionally, this structure is used by the PDR both when recording data, and when binary data retrievals are performed. When being transmitted between machines, this data uses Intel (aka "little endian") byte-ordering.

Internally, PICS keeps time using UTC and the wDate/dwTime values reflect that. PICS applications generally translate local time to UTC before working with it, and also change UTC times to local before presentation.

The point status are described in detail on their one page. Click here for a complete breakdown of the point status bits. Some of the bits, especially the point type, affect the meaning of other fields (and some of the other point status bits) in the real time data records. For example, the EU value is a float for the AI, AO and AC point types, but it is a DWORD for all other types. The raw value is a float when the appropriate flag is set in the PSX, otherwise it is a DWORD. This mechanism help us to store the maximum amount of useful information in the smallest space possible. Unfortunately, it also makes sharing the raw data with other system somewhat difficult as few systems are capable of easily interpreting data streams this complex.

The point status for some types (notably analog and digital types) include alarm state and value quality information. Some basic information about alarm levels and quality codes may be found here.