FB_BACnet_NSinkReadEvent
Application
The function block can be used to read any entry from the BACnet Notification Sink. The Example shows a possible configuration.
The input to be read is selected at input nIndex. The numbering matches the order in the buffer of the Notification Sink. In a ring buffer the numbering of incoming events starts at 0, in the event of a buffer overflow.
Within the block, the message text is decoded based on the string coding. The following encodings are supported: UTF-8, UCS2, UCS4 and ISO8859-1. The string sMessage within the output structure stEvent is Windows-1252-coded (see also FB_BACnet_StringExtDecode). If an error occurs during decoding, this is indicated at the nErrorId output.
The block instance is created by the PLC program and called cyclically. The input/output stAdsConn must be linked to the output stBACnetAds of the corresponding NotificationSink function block (FB_BACnet_NotificationSink).
VAR_INPUT
nIndex : UDINT;
bAutoGet : BOOL:=TRUE;
bGet : BOOL;
nIndex: Index of the event entry to be read (0 to n).
bAutoGet: TRUE = the event entry is read automatically when the ADS connection or the input nIndex have changed. An ADS connection change occurs when the connection is restored after an interruption, or if the AMS NetID or port has changed. Automatic reading does not occur cyclically, and not if the event entry itself changes!
bGet: FALSE → TRUE = event entry is read once, irrespective of input bAutoGet.
VAR_OUPUT
bDone : BOOL;
bNoEntry : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrorId : UINT;
stEvent : ST_BACnet_NSinkEvent;
bDone: Read of the data completed successfully. bDone remains set until to bGet and bAutoGet are reset or re-reading begins. If bGet and bAutoGet are reset before bDone is active, bDone is set for one cycle. bDone is only set if the event entry to be read is not empty.
bNoEntry: Reading completed, but without data - event entry under nIndex is empty. bNoEntry remains set until a new read operation starts. The output is used to detect the end of the event list.
bBusy: The block is busy.
bError: Error during processing.
nErrorId: Error code, see BACnet_Globals for an overview.
stEvent: Output structure with data of an event entry. See example for a comparison of the PLC data and the online event entry in the TwinCAT System Manager.
VAR_IN_OUT
stAdsConn : ST_BACnet_AdsConnection;
stAdsConn: Linking to the output stBACnetAds of the corresponding NotificationSink function block.
Example 1: Comparison of PLC and System Manager
Example 2: Function block call
The AMS port depends on the TwinCAT System Manager configuration of the corresponding BACnet device (see FB_BACnet_NotificationSink). |