FB_IotMqtt5MessageQueue
This function block provides a message queue for MQTT messages that are received with the function block FB_IotMqtt5Client. For this purpose, an instance is already provided at the output of FB_IotMqtt5Client
. The function block operates based on the first in, first out principle (FIFO). It is possible that multiple MQTT messages are received within one PLC cycle and made available at the message queue.
During the program sequence, the property nQueuedMessages
can be used to check whether and how many messages have been collected in the message queue. The Dequeue()
method is used for removing messages from the FIFO queue. The oldest message is output first.
Size of the MQTT message queue The maximum number of possible messages in the queue can be set via the parameter The MQTT message queue allocates new memory space for new messages according to the topic and payload size. By default the maximum size of a message is limited to 100 kB, the size of the MQTT message queue is limited to 1000 kB. For special cases these values can also be adjusted in the parameter list. |
Properties
Name | Type | Access | Description |
---|---|---|---|
bOverwriteOldestEntry | BOOL | Get, Set | Here you can parameterize whether, when the queue is full, a newly received message should overwrite the oldest message. If yes (TRUE), the oldest message is lost. If no (FALSE), the reception of the new message will wait until the queue offers space. A full queue is an unlikely case if the user ensures a speedy readout of the queue using the |
nLostMessages | UDINT | Get | Returns the number of MQTT messages which had to be discarded completely. Discarded MQTT messages can be caused by a full queue or by the total size of a newly received message being too large. |
nMaxSizeOfMessage | UDINT | Get | Maximum size in bytes of all received MQTT messages, which should be received by the FB_IotMqtt5Client and stored in the FB_IotMqtt5MessageQueue. If the maximum size specified with the library parameter |
nQueuedMessages | UDINT | Get | Outputs the number of MQTT messages currently collected in the queue. The maximum possible number is set with the library parameter |
Methods
Name | Description |
---|---|
Removes an MQTT message from the queue. | |
Deletes all messages from the queue. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4026.0 | IPC or CX (x86, x64, ARM) | Tc3_IotBase (>= v3.4.2.0) |