/' µ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**\nurtPublisherPublish()\n /'### PARAMETERS & RETURN ####################################################'/ note -- **publisher** : urt_publisher_t* -- Pointer to the publisher to use. Must not be ""NULL"". -- **payload** : void* -- Pointer to the data to be published. May be ""NULL"" for messages without payload. -- **bytes** : size_t -- Size of the payload in bytes. -- **t** : urt_osTime_t -- Timestamp to be set for the message. -- **timeout** : urt_delay_t -- Timeout delay in case the message cannot be published. ==== -- **return** : urt_status_t -- Returns ""URT_STATUS_OK"" on success. Returns ""URT_STATUS_PUBLISH_TIMEOUT"" on timeout. endnote /'### PROCEDURE ##############################################################'/ start :lock topic; fork :access topic's next message; fork again #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\nincrement counter of publish attempts; endfork while (HRT consumers left for the message?) is (yes) :wait for topic's condition variable (using topic's mutex) to be signaled or timeout; if (Timeout occurred?) then (yes) #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\nincrement counter of publish fails; :unlock topic; stop note Returns ""URT_STATUS_PUBLISH_TIMEOUT"". endnote else (no) if (Message timestamp was modified?) then (yes) repeat :proceed to next message; repeat while (Timestamp is younger than of previous message?) is (yes) ->no; else (no) endif endif endwhile (no) partition "//URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE { if (Consumers left for this message?) then (yes) #EEEEEE:increment counter of discarded messages (@topic); else (no) endif } fork partition "setup message" { fork :iterate topic's pointer to this message; fork again :copy payload to message; fork again :set origin time of message; fork again :set number of HRT consumers (from topic); fork again #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//.. set numer of consumers (from topic); endfork } fork again #EEEEEE:..//URT_CFG_PUBSUB_QOS_RATECHECKS == true//..\nset QoS rate timer (@topic) wrt. most critical HRT subscriber; fork again partition "//URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true//" #EEEEEE { #EEEEEE:access first HRT subscriber of topic; while (HRT subscriber is not ""NULL""?) is (yes) if (QoS deadline timer (@subscriber) is not armed?) then (yes) #EEEEEE:set QoS deadline timer (@subscriber) wrt. origin time of the message; note No lock required. This timer is only accessed while topic is locked. endnote else (no) endif #EEEEEE:proceed to next HRT subscriber; endwhile (no) } fork again #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\nincrement counter of published messages (@topic); endfork :fire event; note: Msut be within topic lock because of HRT counter. :unlock topic; stop note Returns ""URT_STATUS_OK"". endnote /'### OUTRO ##################################################################'/ @enduml