Overview of TwinCAT 3 function blocks

Name

Function

FB_CrestronConnections

This function block represents the TCP/IP server and manages the TCP connections.

FB_CrestronCommunication

This function block manages the communication to the individual Crestron controllers.

FB_CrestronReadBoolArray

This function block allows several signals to be read from a Crestron controller and written to a bool array of the PLC.

FB_CrestronReadByteArray

This function block allows several signals to be read from a Crestron controller and written to a byte array of the PLC.

FB_CrestronReadUIntArray

This function block allows several signals to be read from a Crestron controller and written to a UInt array of the PLC.

FB_CrestronWriteBoolArray

This function block allows a bool array of the PLC to be written to a Crestron controller.

FB_CrestronWriteByteArray

This function block allows a byte array of the PLC to be written to a Crestron controller.

FB_CrestronWriteUIntArray

This function block allows a UInt array of the PLC to be written to a Crestron controller.

FB_CrestronPushBoolArray

This function block allows a bool array of the PLC to be written to a Crestron controller. The push commands do not receive any confirmation from the Crestron controller.

FB_CrestronPushByteArray

This function block allows a byte array of the PLC to be written to a Crestron controller. The push commands do not receive any confirmation from the Crestron controller.

FB_CrestronPushUIntArray

This function block allows several signals to be read from a Crestron controller and written to a UInt array of the PLC. The push commands do not receive any confirmation from the Crestron controller.

In addition to the above-named FBs, some interfaces and a base class are used. However, as these are not used directly, a more precise description has been omitted. The relationship between the respective interfaces and function blocks should be briefly illustrated, however.

Each FB that represents a write or read command inherits from the FB_CrestronCommand. This FB contains some general inputs and outputs (e.g. bStart, bBusy, bError and nErrorId), some internal variables and a method to generate the Invoke-Id. In addition, the FB contains an interface pointer of the type I_CrestronCommunication. The methods for transmitting and receiving data packets are provided via this interface pointer. When declaring the individual FBs for the write or read commands, an instance of FB_CrestronCommunication is transferred. This FB implements the interface I_CrestronCommunication with the methods SendCommand() and TryGetResponse().

In addition to I_CrestronCommunication, FB_CrestronCommunication also implements the interface I_CrestronSocketObserver. The method Update() is called via this interface whenever FB_CrestronConnections receives a new TCP socket. Here, too, the instance of FB_CrestronConnections is transferred when declaring FB_CrestronCommunication.

Overview of TwinCAT 3 function blocks 1:

This advantage of this approach is that no global or IN_OUT variables are required for the communication of the individual instances with one another. All function blocks are decoupled from one another by interfaces.