Sending/acknowledging EventLogger signals from the PLC

The example demonstrates the use of the ADSLOGEVENT function block.

The complete sources for the example application can be unpacked here: AdsLogEventExample.zip

Step by step sequence

Configuration of an event:

Parameterisation of EventConfigData structure

Transfer of parameters:

Generate an address of a structure, an array or a single variable with ADR operator at EventDataAddress. Determine the length of the structure, array or single variable using the SIZEOF operator and apply it to the EventDataLength input. If, for example, a structure with an INT and an LREAL variable is to be transferred with the event, then a structure must be created with these two components and instanced. The address and the length of this instance must be transferred.

Setting an event:

Rising edge at the Event input

Resetting an event:

Falling edge at the Event input

To acknowledge an events:

Rising edge at the Quit input

Complete deletion of the instance:

The contents of the instance are completely deleted with a rising edge at the FbCleanup input. An existing event from the EventLogger is not directly deleted by this.

After an event has been sent to the EventLogger, the status of the event changes visibly at the Eventstate output.

Calling the ADSLOGEVENT function block

PROGRAM MAIN
VAR
    FB_Event1   : ADSLOGEVENT;
    CfgEvent    : TcEvent;
    Eventdata   : ParaStruct;
    EventState  : UDINT;
    bEvent      : BOOL;
    bQuit       : BOOL;         
END_VAR
VAR CONSTANT
    TCEventDataFormatString : STRING:='%f%d';
    TcEventTimeOut     : TIME:=T#1s;
END_VAR

Sending/acknowledging EventLogger signals from the PLC 1:

Declaration Part

PROGRAM MAIN
VAR
    CfgEvent                : TcEvent;
    fbEvent                 : ADSLOGEVENT;
    bSetEvent               : BOOL;(* Rising edge sets event *)

    eventData               : ST_EventData;
    TcEventDataFormatString : STRING    := '%f%d';
END_VAR

Implementation

CfgEvent.Class := TCEVENTCLASS_ALARM;
CfgEvent.Prio := 2;
CfgEvent.Id := 1;
CfgEvent.SourceId := 100;
CfgEvent.bQuitRequired := TRUE;
CfgEvent.DataFormatStrAddress := ADR(TcEventDataFormatString);
CfgEvent.Flags := TCEVENTFLAG_LOG OR TCEVENTFLAG_SRCID OR TCEVENTFLAG_AUTOFMTALL;
CfgEvent.StreamType := TCEVENTSTREAM_SIMPLE;
CfgEvent.ProgId :='TcEventFormatter.TcXMLFormatter' ;

eventData.rVal     := 2.65;
eventData.iVal    := 3;

fbEvent( NETID:= '',
        PORT:= 110,
        Event:= bSetEvent,
        EventConfigData:= CfgEvent,
        EventDataAddress := ADR(eventData) ,
        EventDataLength := SIZEOF(eventData),
        TMOUT:= t#3s);