Statistics
| Branch: | Revision:

urtware / doc / activitydiagrams / topic / urtTopicInit.uml @ e87bd7c7

History | View | Annotate | Download (2.684 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
  ====
37
  -- **return** : urt_status_t --
38
  Returns ""URT_STATUS_OK"" on success.
39
  Returns ""URT_STATUS_ERROR"" if another topic with the same identifier already exists.
40
endnote
41

    
42
/'### PROCEDURE ##############################################################'/
43

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

    
93
/'### OUTRO ##################################################################'/
94

    
95
@enduml