FB_ALYC_MqttStream
This function block represents an Analytics MQTT stream. The connection to a stream can be established using the ObjectId as an input variable. The requirement is an existing stream, e.g. created in the System Manager under the Data Logger node in the project tree. The stream can be controlled using the Start/Stop methods and reconfigured using Reconfigure. A structure of the type ST_ALYC_MqttStreamConfig containing the new configuration parameters is transferred to the method for this purpose. 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 Reconfig 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. Errors can be recorded via the bError output and the corresponding ipResultMessage.
Definition:
FUNCTION_BLOCK FB_ALYC_MqttStream
VAR_INPUT
{attribute 'tcinitsymbol'}
nObjectID : OTCID := 0;
END_VAR
VAR_OUTPUT
bInitialized : BOOL := FALSE;
bError : BOOL := FALSE;
ipResultMessage : I_TcMessage := fbResult;
eReconfigState : E_ALYC_ReconfigState := E_ALYC_ReconfigState.DONE;
END_VAR
Inputs
Name | Type | Description |
---|---|---|
nObjectID | OTCID | TcCom-Object ID of the referenced stream. This can be initialized under the 'Init symbols' tab of the corresponding PLC instance node in the System Manager project tree. |
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. |
Methods
Name | Return type | Description |
---|---|---|
Reconfigure | BOOL | Reconfigure the stream. Parameter: ST_ALYC_MqttStreamConfig. TRUE if successful. |
Start | BOOL | Start the stream. TRUE if successful. |
Stop | BOOL | Stop the stream. TRUE if successful. |
Properties
Name |
Type |
Direction |
Description |
---|---|---|---|
bConnected | BOOL | get | TRUE if MQTT connection exists. |
bStarted | BOOL | get | TRUE if stream started. |
nDataSize | UDINT | get | Sample data size |
nSamplesIssued | ULINT | get | Number of samples that have been written. |
nSamplesLost | ULINT | get | Number of discarded samples. |
tCycleTime | LTIME | get | Cycle time in ns |
nCompDataSaving | DINT | get | Percentage of data volume saved compared to the uncompressed alternative. If negative, there is additional work instead of data savings. |