urtware / doc / activitydiagrams / subscriber / urtSubscriberFetchLatestMessage.uml @ c22d21ad
History | View | Annotate | Download (3.38 KB)
1 |
/' |
---|---|
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**\nurtSubscriberFetchLatestMessage()\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 |
:access next message; |
52 |
else (no) |
53 |
if (Has a message been read before?) then (yes) |
54 |
:access last read message; |
55 |
if (Message timestamp equals local copy?) then (yes) |
56 |
else (no) |
57 |
partition "find oldest valid message" { |
58 |
:access next message; |
59 |
while (Timestamp of next is younger than of current?) is (yes) |
60 |
:iterate by one message; |
61 |
endwhile (no) |
62 |
} |
63 |
endif |
64 |
else (no) |
65 |
:access message after topic's latest message; |
66 |
endif |
67 |
endif |
68 |
partition "iterate to latest" { |
69 |
while (Timestamp of next message is younger than of current?) is (yes) |
70 |
if (Is HRT subscriber?) then (yes) |
71 |
fork |
72 |
:decrement HRT counter of current message; |
73 |
fork again |
74 |
:update QoS delay timer (@subscriber); |
75 |
endfork |
76 |
else (no) |
77 |
endif |
78 |
:iterate by one message; |
79 |
endwhile (no) |
80 |
} |
81 |
fork |
82 |
:set last fetched message pointer to locked message; |
83 |
fork again |
84 |
fork |
85 |
:copy timestamp of message; |
86 |
fork again |
87 |
if (Optional output argument "latency" given?) then (yes) |
88 |
:set latency value (now - message origin time); |
89 |
else (no) |
90 |
endif |
91 |
endfork |
92 |
fork again |
93 |
:copy message payload; |
94 |
fork again |
95 |
if (Is HRT subscriber?) then (yes) |
96 |
fork |
97 |
:decrement HRT counter of current message; |
98 |
if (At least one HRT counter became 0?) then (yes) |
99 |
:signal topic's condition variable; |
100 |
else (no) |
101 |
endif |
102 |
fork again |
103 |
:update QoS delay timer (@subscriber); |
104 |
endfork |
105 |
else (no) |
106 |
endif |
107 |
endfork |
108 |
:unlock topic; |
109 |
|
110 |
/'### STOP & RETURN ##########################################################'/ |
111 |
|
112 |
stop |
113 |
note |
114 |
-- **return** ""urt_status_t"" -- |
115 |
Returns ""URT_STATUS_OK"". |
116 |
end note |
117 |
|
118 |
/'### OUTRO ##################################################################'/ |
119 |
|
120 |
@enduml |