/' µRtWare is a lightweight publish/subscribe middleware for real-time applications. It was developed as part of the software habitat for the Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well. Copyright (C) 2018..2020 Thomas Schöpping et al. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . '/ /'### INTRO ##################################################################'/ @startuml title **µRtWare**\nurtNrtSubscriberFetchNextMessage()\n !include ../functions.iuml /'### PARAMETERS & RETURN ####################################################'/ note -- **subscriber** : urt_nrtsubscriber_t* -- The NRT subscriber that shall fetch the message. Must not be ""NULL"". -- **payload** : void* -- Pointer where to copy the payload to. May be ""NULL"" for messages without payload. -- **bytes** : size_t -- Payload size in bytes. -- **latency** : urt_delay_t* -- The latency can be returned by reference. May be ""NULL"". ==== -- **return** : urt_status_t -- Returns ""URT_STATUS_OK"" on success. Returns ""URT_STATUS_FETCH_NOTOPIC"" if the subscriber is not associated to a topic. Retruns ""URT_STATUS_FETCH_NOMESSAGE"" if there is no new message to fetch. endnote /'### PROCEDURE ##############################################################'/ start if (Associated to a topic?) then (yes) :lock topic; if (Timestamp of last read message equals local copy?) then (yes) if (Next message is younger?) then (yes) :proceed to next message; else (no) :unlock topic; stop note Returns ""URT_STATUS_FETCH_NOMESSAGE"". endnote endif else (no) partition "find oldest message" { repeat :proceed to next message; repeat while (Timestamp of next message is younger?) is (yes) } endif fork $fetch_message() fork again :calculate message latency; note Can be optimized in case all flags are disabled. endnote fork #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\naccumulate ""sumLatencies"" value; fork again partition "//URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE { if (Latency is lower than ""minLatency""?) then (yes) #EEEEEE:update ""minLatency"" value; elseif (Latency is greater than ""maxLatency""?) then (yes) #EEEEEE:update ""maxLatency"" value; else (no) endif } fork again if (Optional ""latency"" output argument given?) then (yes) :set ""latency"" value; else (no) endif endfork fork again partition "//URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE { fork #EEEEEE:decrement counter of consumers left (@message); fork again #EEEEEE:increment counter of received messages; endfork } endfork :unlock topic; stop note Returns ""URT_STATUS_OK"". endnote else (no) stop note Returns ""URT_STATUS_FETCH_NOTOPIC"". endnote endif /'### OUTRO ##################################################################'/ @enduml