FB_BACnet_ReadProp

Function block for access to BACnet properties via ADS. All BACnet properties of server and client objects can be read or written via ADS. If a client is accessed via ADS, the ADS accesses are converted to "Read_Property" or "Read_Range" BACnet requests and sent to the remote server.

FB_BACnet_ReadProp 1:

Use

The function block instance is created by the PLC program and called cyclically. The input BACnetDevicePort is assigned with the ADS port from the System Manager configuration (see Figure 1). Ports for servers and clients may vary, depending on the configuration.

FB_BACnet_ReadProp 2:
Figure 1: ADS port in the System Manager

The NetId (AMS NetId) of the BACnet device can also be read in the System Manager (see Figure 2).

FB_BACnet_ReadProp 3:

The NetID does not match the local NetID and always has to be specified - empty strings cannot be used!). Another possibility is to query the NetID from the device function block or adapter function block in the PLC (see Figure 3).

FB_BACnet_ReadProp 4:
Figure 2: AMS NetID of the BACnet device

For information on the operating principle of the adapter function block see FB_BACnet_Adapter.

FB_BACnet_ReadProp 5:
Figure 3: AMS NetID of the BACnet device

VAR_INPUT

BACnetDevicePort : UINT := 16#FFFF;
bExecute         : BOOL;
sNetId           : T_AmsNetId;
ObjectType       : E_BACnetObjectType;
PropertyID       : E_BACnetPropertyIdentifier;
DataType         : E_BACnetDataTypes;
ObjectInstance   : DINT;
ptrValue         : POINTER TO BYTE;
nLenValue        : UDINT; (* byte size of value (SIZEOF) *)

BACnetDevicePort: ADS port under which the required object was created (see also under use).

bExecute: Rising edge at the input starts the read process. Falling edge deletes the output bDone.

sNetId: AMS NetID of the BACnet device (adapter) under which the server or client was configured.

ObjectType: Enumeration of the object type (AnalogValue, BinaryInput...).

PropertyID: Enumeration of the property ID (Present_Value, Status_Flags...).

ObjectInstance: Object number of the BACnet object (the lower 22 bits of the Object_Identifier).

ptrValue: Pointer to the variable in which the read data are to be stored (can be determined with ADR()).

nLenValue: Byte length of the variable in which the read data are to be stored (can be determined with SIZEOF()).

VAR_OUTPUT

bDone        : BOOL;
bBusy        : BOOL;
bError       : BOOL;
nErrID       : UDINT;
nProcessedLen: UDINT; (* the received data length (can be different to given length) *)

bDone: Read of the data completed successfully. bDone remains set until bExecute is reset. If bExecute is reset before bDone is active, bDone is set for one cycle.

bBusy: The block is busy.

bError: Error during processing.

nErrID: ADS error code.

nProcessedLen: Byte length of the read data. The length may differ from the target length nLenValue (smaller/equal).

Example

FB_BACnet_ReadProp 6:
Fig. 4: Application example