urtware / doc / activitydiagrams / subscriber / hrtsubscriber / urtHrtSubscriberFetchNextMessage.uml @ 1fb06240
History | View | Annotate | Download (5.739 KB)
| 1 | dd31cb03 | Thomas Schöpping | /' |
|---|---|---|---|
| 2 | µRtWare is a lightweight publish/subscribe middleware for real-time |
||
| 3 | applications. It was developed as part of the software habitat for the |
||
| 4 | Autonomous Mini Robot [1] (AMiRo) but can be used for other purposes as well. |
||
| 5 | |||
| 6 | Copyright (C) 2018..2020 Thomas Schöpping et al. |
||
| 7 | |||
| 8 | This program is free software: you can redistribute it and/or modify |
||
| 9 | it under the terms of the GNU General Public License as published by |
||
| 10 | the Free Software Foundation, either version 3 of the License, or |
||
| 11 | (at your option) any later version. |
||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful, |
||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 16 | GNU General Public License for more details. |
||
| 17 | |||
| 18 | You should have received a copy of the GNU General Public License |
||
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 20 | '/ |
||
| 21 | |||
| 22 | /'### INTRO ##################################################################'/ |
||
| 23 | |||
| 24 | @startuml |
||
| 25 | |||
| 26 | title **µRtWare**\nurtHrtSubscriberFetchNextMessage()\n |
||
| 27 | |||
| 28 | !include ../functions.iuml |
||
| 29 | |||
| 30 | /'### PARAMETERS & RETURN ####################################################'/ |
||
| 31 | |||
| 32 | note |
||
| 33 | -- **subscriber** : urt_hrtsubscriber_t* -- |
||
| 34 | The HRT subscriber that shall fetch the message. |
||
| 35 | Must not be ""NULL"". |
||
| 36 | -- **payload** : void* -- |
||
| 37 | Pointer where to copy the payload to. |
||
| 38 | May be ""NULL"" for messages without payload. |
||
| 39 | -- **bytes** : size_t -- |
||
| 40 | Payload size in bytes. |
||
| 41 | -- **latency** : urt_delay_t* -- |
||
| 42 | The latency can be returned by reference. |
||
| 43 | May be ""NULL"". |
||
| 44 | ==== |
||
| 45 | -- **return** : urt_status_t -- |
||
| 46 | Returns ""URT_STATUS_OK"" on success. |
||
| 47 | Returns ""URT_STATUS_FETCH_NOTOPIC"" if the subscriber is not associated to a topic. |
||
| 48 | Retruns ""URT_STATUS_FETCH_NOMESSAGE"" if there is no new message to fetch. |
||
| 49 | Returns ""URT_STATUS_JITTERVIOLATION"" if the message's latency violated the maximum expected jitter. |
||
| 50 | endnote |
||
| 51 | |||
| 52 | /'### PROCEDURE ##############################################################'/ |
||
| 53 | |||
| 54 | start |
||
| 55 | if (Associated to a topic?) then (yes) |
||
| 56 | :lock topic; |
||
| 57 | if (Next message is younger?) then (yes) |
||
| 58 | :proceed to next message; |
||
| 59 | else (no) |
||
| 60 | :unlock topic; |
||
| 61 | stop |
||
| 62 | note |
||
| 63 | Returns ""URT_STATUS_FETCH_NOMESSAGE"". |
||
| 64 | endnote |
||
| 65 | endif |
||
| 66 | fork |
||
| 67 | :calculate message latency; |
||
| 68 | fork |
||
| 69 | #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\naccumulate ""sumLatencies"" value; |
||
| 70 | fork again |
||
| 71 | if (Optional ""latency"" output argument given?) then (yes) |
||
| 72 | :set ""latency"" value; |
||
| 73 | else (no) |
||
| 74 | endif |
||
| 75 | endfork |
||
| 76 | fork again |
||
| 77 | :decrement message's HRT counter; |
||
| 78 | if (HRT counter became 0?) then (yes) |
||
| 79 | else (no) |
||
| 80 | :signal topic's condition variable; |
||
| 81 | endif |
||
| 82 | fork again |
||
| 83 | partition "//URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE {
|
||
| 84 | fork |
||
| 85 | #EEEEEE:decrement counter of consumers left (@message); |
||
| 86 | fork again |
||
| 87 | #EEEEEE:increment counter of received messages; |
||
| 88 | endfork |
||
| 89 | } |
||
| 90 | endfork |
||
| 91 | partition "//URT_CFG_PUBSUB_QOS_JITTERCHECKS == true || URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE {
|
||
| 92 | if (Latency is within allowed jitter range?) then (yes) |
||
| 93 | if (Latency is lower than ""minLatency""?) then (yes) |
||
| 94 | #EEEEEE:update ""minLatency"" value; |
||
| 95 | elseif (Latency is greater than ""maxLatency""?) then (yes) |
||
| 96 | #EEEEEE:update ""maxLatency"" value; |
||
| 97 | else (no) |
||
| 98 | endif |
||
| 99 | else (no) |
||
| 100 | partition "//URT_CFG_PUBSUB_QOS_JITTERCHECKS == true//" #EEEEEE {
|
||
| 101 | #EEEEEE:unlock topic; |
||
| 102 | #EEEEEE:call ""urtCoreStopNodes(URT_STATUS_JITTERVIOLATION)""; |
||
| 103 | stop |
||
| 104 | note |
||
| 105 | Returns ""URT_STATUS_JITTERVIOLATION"". |
||
| 106 | endnote |
||
| 107 | } |
||
| 108 | endif |
||
| 109 | } |
||
| 110 | fork |
||
| 111 | $fetch_message() |
||
| 112 | fork again |
||
| 113 | partition "//URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true//" #EEEEEE {
|
||
| 114 | if (Timestamp of next message is younger?) then (yes) |
||
| 115 | #EEEEEE:update QoS deadline timer wrt. next message; |
||
| 116 | else (no) |
||
| 117 | #EEEEEE:reset QoS deadline timer; |
||
| 118 | endif |
||
| 119 | } |
||
| 120 | endfork |
||
| 121 | |||
| 122 | /' |
||
| 123 | fork |
||
| 124 | $fetch_message() |
||
| 125 | fork again |
||
| 126 | :calculate message latency; |
||
| 127 | fork |
||
| 128 | #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\naccumulate ""sumLatencies"" value; |
||
| 129 | fork again |
||
| 130 | if (Optional ""latency"" output argument given?) then (yes) |
||
| 131 | :set ""latency"" value; |
||
| 132 | else (no) |
||
| 133 | endif |
||
| 134 | endfork |
||
| 135 | partition "//URT_CFG_PUBSUB_QOS_JITTERCHECKS == true || URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE {
|
||
| 136 | if (Latency is within allowed jitter range?) then (yes) |
||
| 137 | if (Latency is lower than ""minLatency""?) then (yes) |
||
| 138 | #EEEEEE:update ""minLatency"" value; |
||
| 139 | elseif (Latency is greater than ""maxLatency""?) then (yes) |
||
| 140 | #EEEEEE:update ""maxLatency"" value; |
||
| 141 | else (no) |
||
| 142 | endif |
||
| 143 | else (no) |
||
| 144 | :unlock topic; |
||
| 145 | :call ""urtCoreStopNodes(URT_STATUS_JITTERVIOLATION)""; |
||
| 146 | stop |
||
| 147 | note |
||
| 148 | Returns ""URT_STATUS_JITTERVIOLATION"". |
||
| 149 | endnote |
||
| 150 | endif |
||
| 151 | } |
||
| 152 | fork again |
||
| 153 | :decrement message's HRT counter; |
||
| 154 | if (HRT counter became 0?) then (yes) |
||
| 155 | else (no) |
||
| 156 | :signal topic's condition variable; |
||
| 157 | endif |
||
| 158 | fork again |
||
| 159 | partition "//URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true//" #EEEEEE {
|
||
| 160 | if (Timestamp of next message is younger?) then (yes) |
||
| 161 | #EEEEEE:update QoS deadline timer wrt. next message; |
||
| 162 | else (no) |
||
| 163 | #EEEEEE:reset QoS deadline timer; |
||
| 164 | endif |
||
| 165 | } |
||
| 166 | fork again |
||
| 167 | partition "//URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE {
|
||
| 168 | fork |
||
| 169 | #EEEEEE:decrement counter of consumers left (@message); |
||
| 170 | fork again |
||
| 171 | #EEEEEE:increment counter of received messages; |
||
| 172 | endfork |
||
| 173 | } |
||
| 174 | endfork |
||
| 175 | '/ |
||
| 176 | |||
| 177 | :unlock topic; |
||
| 178 | stop |
||
| 179 | note |
||
| 180 | Returns ""URT_STATUS_OK"". |
||
| 181 | endnote |
||
| 182 | else (no) |
||
| 183 | stop |
||
| 184 | note |
||
| 185 | Returns ""URT_STATUS_FETCH_NOTOPIC"". |
||
| 186 | endnote |
||
| 187 | endif |
||
| 188 | |||
| 189 | /'### OUTRO ##################################################################'/ |
||
| 190 | |||
| 191 | @enduml |