Program Organization Units (POUs)
The program SR_MqttHandling implements the program code to control the MQTT client.
The program code has been split into single logical functions. The single program parts are processed in subroutines, referred to as actions.
The actions called from the program are listed in the following table:
Name of the subroutine (action) |
Description |
---|---|
ACT_InputMapping |
In this logic, the input variables, mainly coming from the visualization, are verified and assigned to local variables for further processing. |
ACT_StateMachineMqttClient |
This logic implements the state machine for the operation of the instance of the function block FB_MqttClient. The general states are: oInitialization of the function block oEstablishing the connection to the server oMonitoring the status of the connection oDisconnecting oError handling |
ACT_StateMachinePublish |
This logic implements the state machine for the operation of the instance of the function block FB_MqttPublish. The general states are: oInitialization of the function block oPublishing of a message oMonitoring the execution of the function block |
ACT_CreateDataString |
This logic implements the creation of the message to be published. |
ACT_StateMachinePublish |
This logic implements the state machine for the operation of the instance of the function block FB_MqttSubscribe. The general states are: oInitialization of the function block oSubscribe to a topic oMonitoring for incoming messages oCopying new messages to the corresponding process variable oMonitoring the status of the function block |
ACT_OutputMapping |
In this logic, the local variables are converted into the required format and then assigned to the associated output variables. The output variables are linked to the visualization. |
The program SR_VisControl implements additional program code to control the displayed information on the visualization in the Logic Builder within the EcoStruxure Machine Expert software.
The program SR_SimulatedMachineData implements the simulation of process values which will be converted into the JSON formatted string and then published via MQTT.