Logging objects

BACnet allows the use of three different objects for log data storage:

Trendlog: This object type represents the recorded log data of a single data source, e.g. the Present Value of an Analog Input object.

Here, recording can be done by polling (i.e., at a fixed recording interval in 1/100s), by Change of Value (COV), or by using a Boolean trigger.

Trendlog Multiple: This object type allows simultaneous recording of data from multiple sources. In principle, recording is only possible via polling or trigger, but not via COV. In practice, this object type is rarely used in BACnet projects.

Eventlog: This object type allows the storage of BACnet event messages (events and alarms). If a Notification Class object with the same instance number exists in the server for the instance number of an Eventlog object, the Notification Class object is automatically configured as the data source of the Eventlog object. Alarms reported via this notification class are therefore automatically stored in the log memory of the Eventlog object.

The following example shows the use of these three object types.

Variables

    fAnalogValue : REAL;
    fbTon : TON;
    fbAv : FB_BACnet_AV := (
                            sObjectName := 'Object to simulate changes and generate alarms',
                            fLowLimit := 1.0,
                            bLowLimitEnable := TRUE,
                            fHighLimit := 8.0,
                            bHighLimitEnable := TRUE,
                            bEnPgm := TRUE,
                            bEventDetectionEnable := TRUE,
                            nNotificationClass := 42,
                            aEventEnable := [TRUE,TRUE,TRUE],
                            eUnit := E_BA_Unit.eElectrical_Volts,
                            nTimeDelay := 0,
                            nTimeDelayNormal := 0,
                            fDeadband := 0.0
                            );

    fbNC42 : FB_BACnet_NC := (
                            nObjectInstance := 42,
                            nNotificationClass := 42,
                            sDescription := 'NC42',
                            aAckRequired := [ TRUE, TRUE, TRUE ],
                            aPriority := [ 1, 2, 3 ]
                            );

    fbELog_NC42 : FB_BACnet_ELogBuf := (
                            sObjectName := 'Event Log for NC42',
                            nObjectInstance := 42,
                            bLogEnable := TRUE
                            );

    fbTLog : FB_BACnet_TLog := (
                            sObjectName := 'Trend',
                            nNotificationClass := 42,
                            aEventEnable := [ TRUE, TRUE, FALSE ],
                            stStartTime := F_BA_ToSTDateTime(DT#2010-01-01-00:00),
                            bLogEnable := TRUE,
                            eLoggingType := E_BA_LoggingType.ePolled,
                            nLogInterval := 3 * 100, // log every 3 seconds, value in 1/100 seconds!
                            stObjectPropertyReference := F_BACnet_Reference(fbAv, PropPresentValue)
                            );
    fbTLogCov : FB_BACnet_TLog := (
                            sObjectName := 'Trend Cov',
                            bLogEnable := TRUE,
                            stObjectPropertyReference := F_BACnet_Reference(fbAv, PropPresentValue),
                            eLoggingType := E_BA_LoggingType.eCOV,
                            nCOVResubscriptionInterval := 600,
                            stClientCOV := (
                                eChoice := E_BACnet_ClientCOVChoice.eCovReal,
                                fIncrement := 5.0
                                )
                            );

    fbTLogBuf : FB_BACnet_TLogBuf := (
                            sObjectName := 'Trend with PLC buffer',
                            bLogEnable := TRUE,
                            eLoggingType := E_BA_LoggingType.eTriggered,
                            stObjectPropertyReference := F_BACnet_Reference(fbAv, PropPresentValue)
                        );

    fbTLogM : FB_BACnet_TLM := (
                            sObjectName := 'Trend Multiple',
                            bLogEnable := TRUE,
                            eLoggingType := E_BA_LoggingType.ePolled,
                            nLogInterval := 50, // log every 0.5 seconds, value in 1/100 seconds!
                            aObjectPropertyReferences := [
                                (iObject := fbAv, ePropertyId := PropPresentValue),
                                (iObject := fbAv, ePropertyId := PropStatusFlags),
                                (iObject := fbAv, ePropertyId := PropEventState) ]
                        );

Code

// generate value changes every second
fbTon( IN:= NOT fbTon.Q, PT:=T#1S );
IF fbTon.Q THEN
    fAnalogValue := fAnalogValue + 1.0;
    IF fAnalogValue > 10.0 THEN
    fAnalogValue := 0;
    END_IF
END_IF
fbAv.fValPgm := fAnalogValue;
fbAv();

// Notification Class
fbNC42();

// Event Log with buffer in PLC
fbELog_NC42();

// Trend Log every 3 seconds
fbTLog();

// COV based Trend Log
fbTLogCov();

// Trigger based Trend Log with buffer in PLC
fbTlogBuf();

// Trendlog Multiple
fbTLogM();