urtware / doc / activitydiagrams / subscriber / urtSubscriberFetchNextMessage.uml @ 7491c395
History | View | Annotate | Download (3.237 KB)
| 1 | 7491c395 | 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**\nurtSubscriberFetchNextMessage()\n |
||
| 27 | |||
| 28 | !include ../../functions.iuml |
||
| 29 | |||
| 30 | /'### PARAMETERS & START #####################################################'/ |
||
| 31 | |||
| 32 | start |
||
| 33 | note |
||
| 34 | -- ""**subscriber** : urt_subscriber_t*"" -- |
||
| 35 | The subscriber that shall fetch the message. |
||
| 36 | Must not be ""NULL"". |
||
| 37 | -- ""**payload** : void*"" -- |
||
| 38 | Pointer where to copy the payload to. |
||
| 39 | May be ""NULL"" for messages without payload. |
||
| 40 | -- ""**bytes** : size_t"" -- |
||
| 41 | Payload size in bytes. |
||
| 42 | -- ""**latency** : urt_delay_t*"" -- |
||
| 43 | The latency can be returned by reference. |
||
| 44 | May be ""NULL"". |
||
| 45 | end note |
||
| 46 | |||
| 47 | /'### PROCEDURE ##############################################################'/ |
||
| 48 | |||
| 49 | :lock topic; |
||
| 50 | if (Is HRT subscriber?) then (yes) |
||
| 51 | :lock next message; |
||
| 52 | else (no) |
||
| 53 | if (Has a message been read before?) then (yes) |
||
| 54 | :lock last read message; |
||
| 55 | if (Message timestamp equals local copy?) then (yes) |
||
| 56 | else (no) |
||
| 57 | partition "find oldest valid message" {
|
||
| 58 | :lock next message; |
||
| 59 | note: Locked two messages ahead. |
||
| 60 | while (Timestamp of next message is younger than of current?) is (yes) |
||
| 61 | fork |
||
| 62 | :unlock current message; |
||
| 63 | fork again |
||
| 64 | :lock one message further ahead; |
||
| 65 | endfork |
||
| 66 | endwhile (no) |
||
| 67 | :unlock next message; |
||
| 68 | note: One message still locked. |
||
| 69 | } |
||
| 70 | endif |
||
| 71 | else (no) |
||
| 72 | :lock message after topic's latest message; |
||
| 73 | endif |
||
| 74 | endif |
||
| 75 | fork |
||
| 76 | :set last fetched message pointer to locked message; |
||
| 77 | fork again |
||
| 78 | fork |
||
| 79 | :copy timestamp of message; |
||
| 80 | fork again |
||
| 81 | if (Optional output argument "latency" given?) then (yes) |
||
| 82 | :set latency value (now - message origin time); |
||
| 83 | else (no) |
||
| 84 | endif |
||
| 85 | endfork |
||
| 86 | fork again |
||
| 87 | :copy message payload; |
||
| 88 | fork again |
||
| 89 | if (Is HRT subscriber?) then (yes) |
||
| 90 | fork |
||
| 91 | :decrement HRT counter of current message; |
||
| 92 | if (HRT counter became 0?) then (yes) |
||
| 93 | :signal topic's condition variable; |
||
| 94 | else (no) |
||
| 95 | endif |
||
| 96 | fork again |
||
| 97 | :update QoS delay timer (@subscriber); |
||
| 98 | endfork |
||
| 99 | else (no) |
||
| 100 | endif |
||
| 101 | endfork |
||
| 102 | :unlock message; |
||
| 103 | :unlock topic; |
||
| 104 | |||
| 105 | /'### STOP & RETURN ##########################################################'/ |
||
| 106 | |||
| 107 | stop |
||
| 108 | note |
||
| 109 | -- **return** ""urt_status_t"" -- |
||
| 110 | Returns ""URT_STATUS_OK"". |
||
| 111 | end note |
||
| 112 | |||
| 113 | /'### OUTRO ##################################################################'/ |
||
| 114 | |||
| 115 | @enduml |