urtware / doc / activitydiagrams / publisher / urtPublisherPublish.uml @ c22d21ad
History | View | Annotate | Download (3.161 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**\nurtPublisherPublish()\n |
||
| 27 | |||
| 28 | !include ../../functions.iuml |
||
| 29 | |||
| 30 | /'### PARAMETERS & START #####################################################'/ |
||
| 31 | |||
| 32 | start |
||
| 33 | note |
||
| 34 | -- ""**publisher** : urt_publisher_t*"" -- |
||
| 35 | Pointer to the publisher to use. |
||
| 36 | Must not be ""NULL"". |
||
| 37 | -- ""**payload** : void*"" -- |
||
| 38 | Pointer to the data to be published. |
||
| 39 | May be ""NULL"" for messages without payload. |
||
| 40 | -- ""**n** : size_t"" -- |
||
| 41 | Size of the payload in bytes. |
||
| 42 | -- ""**t** : urt_osTime_t"" -- |
||
| 43 | Timestamp to be set for the message. |
||
| 44 | -- ""**timeout** : urt_delay_t"" -- |
||
| 45 | Timeout delay in case the message cannot be published. |
||
| 46 | end note |
||
| 47 | |||
| 48 | /'### PROCEDURE ##############################################################'/ |
||
| 49 | |||
| 50 | :lock topic; |
||
| 51 | c22d21ad | Thomas Schöpping | :access next message; |
| 52 | while (HRT consumers left for the message\nor the message timestamp was modified\nand a timeout occurred?) is (yes) |
||
| 53 | if (Message timestamp was modified?) the (yes) |
||
| 54 | :iterate to next message; |
||
| 55 | else (no) |
||
| 56 | :wait for topic's condition variable (using topic's mutex) to be signaled or timeout; |
||
| 57 | endif |
||
| 58 | 7491c395 | Thomas Schöpping | endwhile (no) |
| 59 | if (Timeout occurred?) then (yes) |
||
| 60 | :unlock topic; |
||
| 61 | :return ""URT_STATUS_ERROR""; |
||
| 62 | else (no) |
||
| 63 | fork |
||
| 64 | fork |
||
| 65 | :iterate topic pointer to this message; |
||
| 66 | fork again |
||
| 67 | :copy payload to message; |
||
| 68 | fork again |
||
| 69 | :set origin time of message; |
||
| 70 | fork again |
||
| 71 | :set number of HRT consumers (from topic); |
||
| 72 | endfork |
||
| 73 | fork again |
||
| 74 | :set QoS rate timer (@topic) wrt. most critical HRT subscriber; |
||
| 75 | fork again |
||
| 76 | while (HRT subscribers left?) is (yes) |
||
| 77 | if (QoS delay timer (@subscriber) is not armed?) then (yes) |
||
| 78 | :set QoS delay timer (@subscriber) wrt. origin time of the message; |
||
| 79 | note: No lock required since this timer is only accessed when the topic is locked. |
||
| 80 | else (no) |
||
| 81 | endif |
||
| 82 | :iterate to next HRT subscriber; |
||
| 83 | endwhile (no) |
||
| 84 | endfork |
||
| 85 | :fire event; |
||
| 86 | note: Msut be within topic lock because of HRT counter. |
||
| 87 | :unlock topic; |
||
| 88 | :return ""URT_STATUS_OK""; |
||
| 89 | endif |
||
| 90 | |||
| 91 | /'### STOP & RETURN ##########################################################'/ |
||
| 92 | |||
| 93 | stop |
||
| 94 | note |
||
| 95 | -- **return** ""urt_status_t"" -- |
||
| 96 | Returns ""URT_STATUS_ERROR"" on timeout. |
||
| 97 | end note |
||
| 98 | |||
| 99 | /'### OUTRO ##################################################################'/ |
||
| 100 | |||
| 101 | @enduml |