Statistics
| Branch: | Revision:

urtware / doc / activitydiagrams / topic / urtTopicInit.uml @ 982056f7

History | View | Annotate | Download (2.866 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**\nurtTopicInit()\n
27

    
28
/'### PARAMETERS & RETURN ####################################################'/
29

    
30
note
31
  -- **topic** : urt_topic_t* --
32
  The topic to initialize.
33
  Must not be ""NULL"".
34
  -- **id** : urt_topicid_t --
35
  Unique, numeric identifier of the topic.
36
  -- **mandatoryMessage** : urt_message_t* --
37
  Starting message of the topic.
38
  Must not be ""NULL"".
39
  ====
40
  -- **return** : urt_status_t --
41
  Returns ""URT_STATUS_OK"" on success.
42
  Returns ""URT_STATUS_TOPIC_DUPLICATE"" if another topic with the same identifier already exists.
43
endnote
44

    
45
/'### PROCEDURE ##############################################################'/
46

    
47
start
48
:initialize members;
49
note
50
  * **next** ← ""NULL""
51
  * **id** ← id
52
  * urtMutexInit(**lock**)
53
  * urtEventSourceInit(**evtSource**)
54
  * **numHrtSubscriber** ← 0
55
  * urtCondvarInit(**hrtReleased**)
56
  * **mandatoryMessage** ← mandatoryMessage
57
  * **latestMessage** ← &mandatoryMessage
58
  .. URT_CFG_PUBSUB_QOS_RATECHECKS == true ..
59
  * **hrtSubscribers** ← ""NULL""
60
  * urtTimerInit(**qosRateTimer**)
61
  .. URT_CFG_PUBSUB_PROFILING == true ..
62
  * **numMessagesPublished** ← 0
63
  * **numMessagesDiscarded** ← 0
64
  * **numSubscribers** ← 0
65
endnote
66
:close circular message buffer;
67
note
68
  latestMessage""->""next ← latestMessage
69
endnote
70
:lock core;
71
:access first topic;
72
while (Topic is not ""NULL""\nand topic ID is lower?) is (yes)
73
  :proceed to next topic;
74
endwhile (no)
75
if (Current topic is ""NULL""?) then (yes)
76
  :append self to core's list of topic;
77
  :unlock core;
78
  stop
79
  note
80
    Returns ""URT_STATUS_OK"".
81
  endnote
82
elseif (Current topic ID is greater?) then (yes)
83
  :insert self in front of current topic;
84
  :unlock core;
85
  stop
86
  note
87
    Returns ""URT_STATUS_OK"".
88
  endnote
89
else (no)
90
  :unlock core;
91
  stop
92
  note
93
    Returns ""URT_STATUS_TOPIC_DUPLICATE"".
94
  endnote
95
endif
96

    
97
/'### OUTRO ##################################################################'/
98

    
99
@enduml