Processing of the log memory in the PLC

BACnet defines the CHOICE data type for various properties. This represents a selection of different possible property values.

To be able to process these data types in the PLC, the PLC data type UNION is used together with an enumeration. The enumeration contains the information which element of the union must be accessed.

Log memory of the Trendlog object

The following example shows the processing of the log memory of a Trendlog object.

An object of the type FB_BACnet_TLogBuf is used for this purpose. This provides a log memory whose contents can be read out by the PLC. The variable aLogBuffer is available as an array of the type T_BACnet_TLogBuffer. The individual elements of the log buffer are of type ST_BA_TrendEntry with the following elements:

dtTime: Contains the date and time of the log entry in BACnet format (ST_BA_Date and ST_BA_Time).

eType: Contains the information about the type of the log entry:

    eBinary: The log entry contains a value of type BinaryPV. In the element uValue the value of the variable bVal is to be processed.

    eAnalog: The log entry contains a value of type REAL. In the element uValue the value of the variable fVal is to be processed.

    eMultistate: The log entry contains a value of type UDINT. In the element uValue the value of the variable udiVal is to be processed.

    eEvent: The log entry contains an event. Four bits are available in the stEvent structure:

        bStart: Recording has been started.

        bStop: Recording has been stopped.

        bBufferPurged: The log memory has been cleared.

        bInterrupted: Recording was interrupted (e.g. due to a network interruption)

In addition, the four status flags are available in the stState structure element:

    bInAlarm: The object is in an active alarm state.

    bFault: The object is in a faulty state, e.g. encoder malfunction.

    bOverridden: The object has been overridden by an internal mechanism, e.g. by the PLC.

    bOutOfService: The object was put out of operation. Values are simulated.

Log memory of the Eventlog object

The following example shows the processing of the log memory of an Eventlog object.

An object of the type FB_BACnet_ELogBuf is used for this purpose. This provides a log memory whose contents can be read out by the PLC. The variable aLogBuffer is available as an array of the type T_BACnet_ELogBuffer. The individual elements of the log buffer are of type ST_BACnet_EventLogEntry with the following elements:

dtTime: Contains the date and time of the log entry in BACnet format (ST_BA_Date and ST_BA_Time).

eType: Contains the information about the type of the log entry:

    eStatus: The log entry contains the information of the StatusFlags. Four bits are available in the stStatus structure:

        bInAlarm: The object is in an active alarm state.

        bFault: The object is in a faulty state, e.g. encoder malfunction.

        bOverridden: The object has been overridden by an internal mechanism, e.g. by the PLC.

        bOutOfService: The object was put out of operation. Values are simulated.

    eTimesync: A time synchronization message has been received. The fTimeSync element contains the delta to the previous time.

    eNotification: The log entry contains an event message. In the structure stNotification the parameters of the event message are available, e.g. the process ID, the triggering device and object, the alarm priority, etc.