FB_ALYC_MqttStreamHelper
This function block represents an Analytics Stream Helper in MQTT mode. The connection to an existing Stream Helper can be established via the ObjectId as an input variable. This must be configured in MQTT mode. The stream can be controlled using the Start/Stop methods and reconfigured using Reconfigure. For this purpose, a structure of the type ST_ALYC_MqttStreamHelperConfig is transferred to the method, which contains the new configuration parameters. During reconfiguration, starting from the OP state, the TcCom states SAFEOP, PREOP, SAFEOP, OP are run through in this order. Since all states below SAFEOP no longer run in real-time mode, but the remaining TwinCAT runtime does, the reconfiguration must take place asynchronously to the task cycle, whereby the Reconfigure method should be called cyclically as long as the OP state is not reached again. The properties bConnected, bStarted etc. provide information about the current state of the Stream Helper. Errors can be recorded via the bError output and the corresponding ipResultMessage.
Definition:
FUNCTION_BLOCK FB_ALYC_MqttStreamHelper
VAR_INPUT
{attribute 'tcinitsymbol'}
nObjectID : OTCID := 0;
nNumInputBuffer : UDINT := 20;
END_VAR
VAR_OUTPUT
ipResultMessage : I_TcMessage := fbResult;
bError : BOOL := FALSE;
bNewResult : BOOL := FALSE;
bInitialized : BOOL := FALSE;
nNumElements : UDINT;
eReconfigState : E_ALYC_ReconfigState := E_ALYC_ReconfigState.DONE;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
nObjectID | OTCID | TcCom-Object ID of the referenced StreamHelper. This can be initialized under the 'Init symbols' tab of the corresponding PLC instance node in the System Manager project tree. |
nNumInputBuffer | UDINT | Maximum number of buffered symbol values (samples) in the symbol queues. |
Outputs
Name | Type | Description |
---|---|---|
bInitialized | BOOL | TRUE if the function block is initialized and can be used. Initialization takes place automatically after TwinCAT is set to run mode. |
bError | BOOL | TRUE if an error has occurred. |
ipResultMessage | I_TcMessage | Message EventLogger |
eReconfigState | E_ALYC_ReconfigState | The state of the state machine during reconfiguration. |
bNewResult | BOOL | TRUE if new values have been read into the symbol queues. |
nNumElements | UDINT | Number of new values in the symbol queues |
Methods
Name | Return type | Description |
---|---|---|
Reconfigure | BOOL | Reconfigure the Stream Helper with a ST_ALYC_MqttStreamHelperConfig as parameter. Returns TRUE if successful. |
Call | BOOL | Main method that should always be called cyclically. TRUE if successful. |
AddIotSymbol | BOOL | Add a symbol of type I_ALYC_IotSymbol to the internal symbol list whose values are to be received. TRUE if successful. |
ReleaseIotSymbol | BOOL | Remove a symbol of type I_ALYC_IotSymbol from the internal symbol list. TRUE if successful. |
ReleaseAllIotSymbols | BOOL | TRUE if successful. |
ContainsIotSymbol | BOOL | TRUE if symbol of type I_ALYC_IotSymbol is in the internal symbol list. |
Properties
Name |
Type |
Direction |
Description |
---|---|---|---|
bConnected | BOOL | get | TRUE if an MQTT connection exists. |
bReconnect | BOOL | get/set | If TRUE, interrupt the MQTT connection, if FALSE, renew the MQTT connection. |
sStream | STRING(255) | get/set | MQTT receive topic in the format <MainTopic>/<StreamTopic> |
nNumIotSymbolsRegistered | UDINT | get/set | Number of Iot symbols added. |