1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | // Components _MQTT.IASyncPropertyProvider( IASyncPropertyProvider ); _MQTT.ITLSContextProvider( ITLSContextProvider ); _MQTT(); _RecvSTATEMesg := _MQTT.GetSTATEMessage( MessageTopic => _RecvSTATETopic ); onSTATEMessage( Topic := _RecvSTATETopic, Message := _RecvSTATEMesg ); END_IF IF _MQTT.NCMDMessageReceived() THEN Allows you to bidirectionally share sparkplug data from the edge of your network to a Primary Host Node *) {attribute 'reflection'} FUNCTION_BLOCK PUBLIC FB_Edge IMPLEMENTS IEdge VAR_INPUT KeepAlive : UINT := 60; // eg: 60 (Value is in seconds) // Persistent Session (FALSE = DEFAULT) // * You want the broker to queue the messages for the client and deliver them as soon as the client is back online. // * The client has limited resources. // * The client needs to reNumberOfMetricse all QoS 1 and 2 publish messages after a reconnect. // // Clean session (TRUE) // * You don t want the broker to store session information or retry transmission of QoS 1 and 2 messages. Username : WSTRING := ""; // specify a username if any (optional) UseTLS : BOOL; // Enables usage of the TLS encryption (optional) publishPeriod : UINT; // eg: 5000 (Value is in milliseconds) //Static initialization, as shown in the following code snippet; //VAR // commonName : STRING := 'MyRasPi'; IASyncPropertyProvider : MQTT.NBS.IAsyncProperty; // Runs the connect process in a own background task. Use this property if the connection setup takes longer than one task cycle (e.g. TLS connections) END_VAR VAR_OUTPUT Connected : BOOL; SessionState : SparkplugSessionStateType; {attribute 'no_copy'} itfEdge : IEdge := THIS^; NumberOfDevices : UDINT; VAR _LockTimesArray : ARRAY[1..8] OF TIME := [4(TIME#30S0MS), 2(TIME#1M0S0MS), TIME#2M0S0MS, TIME#4M0S0MS]; // could be made accessible public _LockTimeRemaining : TIME; // Duration of Out Time Period = FALSE remaining _cPrimaryHostID : WSTRING; // Corrected PrimaryHostID, contains no illegal chars _cNodeName : WSTRING; // Corrected NodeName, contains no illegal chars _MQTT : FB_EdgeMQTT; _MQTT_eError : MQTT.MQTT_ERROR; _Devices : List; // Handles all connected Devices _prevNumberOfDevices : UDINT; _ItfCurElement : IElement; _ItfCurDevice : ISparkplugDevice; _Initialise : BOOL; _Initialised : BOOL; _SubscribeNCMD : BOOL; _NodeBirthPublished : BOOL; _DisablePublisher : BOOL; _LastWillTopic : WSTRING(GC_Sparkplug.supported_string_lengths); _NDEATH : FB_RemoteMetric; // contains the current NDEATH BDSeq _NDEATHPayload : ARRAY[0..255] OF BYTE; // what is the maximum size of this payload? _LastWillRetain : BOOL := FALSE; _NBIRTH : FB_RemoteMetric := (_dataType := MetricDataType.UInt64); // contains the current raw NBIRTH seq _Blob : ARRAY[0..65535] OF BYTE; // buffer for encoded messages _BlobSize : UDINT; // current encoded message size _PublishNDATA : BOOL; _ChangeError : ERROR; _ChangeDetected : BOOL; // At least 1 Signal change has been detected; RBE needed next PublishInterval _CurrentChanges : UDINT; // Number of detected changes, each changes reflects 1 Signal _RecvSTATEMesg : STRING; _RecvSTATETopic : WSTRING(GC_Sparkplug.supported_string_lengths); _RecvNCMDMesg : REFERENCE TO FB_PayloadSimpleDecoder; _RecvNCMDTopic : WSTRING(GC_Sparkplug.supported_string_lengths); {attribute 'instance-path'} _POU : STRING; 15662 {8e575c5b-1d37-49c6-941b-5c0ec7874787} ChildObjectGuids AddAttributeSubsequent |