Statistics
| Branch: | Revision:

urtware / doc / classdiagrams / pubsub.uml @ 056e40d2

History | View | Annotate | Download (11.7 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**\nPublish-Subscribe System
27

    
28
!include ../functions.iuml
29

    
30
/'### ENTITIES ###############################################################'/
31

    
32
!startsub ENTITIES
33

    
34
/' Message type. '/
35
$structure("urt_message_t") {
36
    'Pointer to the next message in a list.
37
  + {field} next : urt_message_t*
38
    'Pointer to some arbitrary (reusable) payload object.
39
  + {field} payload : void*
40
    'Origin time of the message.
41
  + {field} originTime : urt_osTime_t
42
    'Mutex lock for exclusive access.
43
  + {field} lock : urt_osMutex_t
44
    'Counter of HRT subscribers that did not consume the message yet.
45
  + {field} numHrtConsumersLeft : unsigned int
46
  .. URT_CFG_PUBSUB_PROFILING == true ..
47
    'Counter of overall subscribers that did not consume the message yet.
48
  + {field} numConsumersLeft : unsigned int
49
  __
50
    'Initializes a urt_message_t object.
51
  + {method} urtMessageInit (message : urt_message_t*, payload : void*) : urt_status_t
52
}
53

    
54
$group("subscriber") {
55
  $group("real-time constraint data") {
56
    /' The top level RT constraints structure. '/
57
    $structure("urt_rtdata_t") {
58
        'The actual RT constraint class.
59
      + {field} class : urt_rtconstraintclass_t
60
        'Parameters of the RT constraints.
61
      + {field} params : urt_rtconstraintsparams_t
62
    }
63

    
64
    /' Descriptor to distinguish the four RT classes. '/
65
    $enumeration("urt_rtclass_t") {
66
        'Hard real-time.
67
      URT_RTCLASS_HARD = 0
68
        'Firm real-time.
69
      URT_RTCLASS_FIRM = 1
70
        'Soft real-time.
71
      URT_RTCLASS_SOFT = 2
72
        'No real-time at all.
73
      URT_RTCLASS_NONE = 3
74
    }
75

    
76
    /' Union structure, holding RT constraints parameters. '/
77
    $union("urt_rtclassdata_t") {
78
        'Parameters for hard real-time.
79
      + {field} hrt : urt_hrtparams_t
80
        'Parameters for firm real-time.
81
      + {field} frt : urt_frtparams_t
82
        'Parameters for soft real-time.
83
      + {field} srt : urt_srtparans_t
84
        'Parameters for non-real-time.
85
      + {field} nrt : urt_nrtparams_t
86
    }
87

    
88
    /' Parameters for hard real-time. '/
89
    $structure("urt_hrtdata_t") {
90
        'Pointer to the next HRT subscriber in a list.
91
      + {field} next : urt_subscriber_t*
92
      .. URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true ..
93
        'QoS Timer to detect missed deadlines.
94
      + {field} qosDeadlineTimer : urt_osTimer_t
95
        'Maximum temporal offset between creation and consumption of messages.
96
      + {field} deadlineOffset : urt_delay_t
97
      .. URT_CFG_PUBSUB_QOS_RATECHECKS == true ..
98
        'Expected rate at which data is published.
99
      + {field} expectedRate : urt_delay_t
100
      .. URT_CFG_PUBSUB_PROFILING == true || URT_CFG_PUBSUB_QOS_JITTERCHECKS == true ..
101
        'Maximum expected jitter.
102
      + {field} maxJitter : urt_delay_t
103
        'Minimum latency ever detected (to calculate jitter).
104
      + {field} minLatency : urt_delay_t
105
        'Maximum latency ever detected (to calculate jitter).
106
      + {field} maxLatency : urt_delay_t
107
    }
108

    
109
    /' Parameters for firm real-time. '/
110
    $structure("urt_frtdata_t") {
111
      .. URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true ..
112
        'Maximum temporal offset between creation and consumption of messages.
113
      + {field} deadlineOffset : urt_delay_t
114
      .. URT_CFG_PUBSUB_QOS_RATECHECKS == true ..
115
        'Expected rate at which data is published.
116
      + {field} expectedRate : urt_delay_t
117
      .. URT_CFG_PUBSUB_PROFILING == true || URT_CFG_PUBSUB_QOS_JITTERCHECKS == true ..
118
        'Maximum expected jitter.
119
      + {field} maxJitter : urt_delay_t
120
        'Minimum latency ever detected (to calculate jitter).
121
      + {field} minLatency : urt_delay_t
122
        'Maximum latency ever detected (to calculate jitter).
123
      + {field} maxLatency : urt_delay_t
124
    }
125

    
126
    $group("SRT data") {
127
      /' Function type to be called when calculating the usefulness of a message. '/
128
      $function("urt_srtusefulnessfunc_t") {
129
          'Takes a delay and optionally parameters as arguments and returns a float in [0, 1].
130
        urt_srtusefulnessfunc_t (dt : urt_delay_t, params : void*) : float
131
      }
132

    
133
      /' Parameters for soft real-time. '/
134
      $structure("urt_srtdata_t") {
135
          'Callback to calculate usefulness of a message
136
        + {field} usefullnesscb : urt_srtusefulnessfunc_t*
137
          'Optional parameters for the callback function.
138
        + {field} cbparams : void*
139
      }
140
    } /'SRT data'/
141

    
142
    /' Parameters for non-real-time. '/
143
    $structure("urt_nrtdata_t") {
144
      'There are nor parameters in this case.
145
    }
146
  } /'real-time constraint data'/
147

    
148
  /' Subscriber type. '/
149
  $structure("urt_subscriber_t") {
150
      'Pointer to the topic, this subscriber subscribed to.
151
    + {field} topic : urt_topic_t*
152
      'Event listener to notify the node about new messages.
153
    + {field} evtListener : urt_osEventListener_t
154
      'Real-time class descriptor.
155
    + {field} rtdata : urt_rtdata_t
156
      'Pointer to the message consumed most recently.
157
    + {field} lastMessage : urt_message_t*
158
      'Copy of the origin time of the message consumed most recently.
159
    + {field} lastMessageTime : urt_osTime_t
160
    .. URT_CFG_PUBSUB_PROFILING == true ..
161
      'Sum of all latencies.
162
    + {field} sumLatencies : uint64_t
163
      'Number of messages received.
164
    + {field} numMessagesReceived : uint64_t
165
    .. URT_CFG_PUBSUB_PROFILING == true ..
166
      'Minimum latency ever detected (to calculate jitter).
167
    + {field} minLatency : urt_delay_t
168
      'Maximum latency ever detected (to calculate jitter).
169
    + {field} maxLatency : urt_delay_t
170
    __
171
      'Initializes a urt_subscriber_t object.
172
    + {method} urtSubscriberInit (subscriber : urt_subscriber_t*) : urt_status_t
173
      'Tries to subscribe to a topic as HRT subscriber, sets all according parameters and optionally contributes a list of messages to the topic.
174
    + {method} urtSubscriberSubscribeHrt (subscriber : urt_subscriber_t*, topic : urt_topic_t*, messages : urt_message_t*, deadline : urt_delay_t, rate : urt_delay_t, jitter : urt_delay_t) : urt_status_t
175
      'Tries to subscribe to a topic as FRT subscriber, sets all according parameters and optionally contributes a list of messages to the topic.
176
    + {method} urtSubscriberSubscribeFrt (subscriber : urt_subscriber_t*, topic : urt_topic_t*, messages : urt_message_t*, deadline : urt_delay_t, rate : urt_delay_t, jitter : urt_delay_t) : urt_status_t
177
      'Tries to subscribe to a topic as SRT subscriber, sets all according parameters and optionally contributes a list of messages to the topic.
178
    + {method} urtSubscriberSubscribeSrt (subscriber : urt_subscriber_t*, topic : urt_topic_t*, messages : urt_message_t*, usefulnesscb : urt_srtusefulnessfunc_t*, cbparams : void*) : urt_status_t
179
      'Tries to subscribe to a topic as NRT subscriber and optionally contributes a list of messages to the topic.
180
    + {method} urtSubscriberSubscribeNrt (subscriber : urt_subscriber_t*, topic : urt_topic_t*, messages : urt_message_t*) : urt_status_t
181
      'Unsubscribes from a topic.
182
    + {method} urtSubscriberUnsubscribe (subscriber : urt_subscriber_t*) : urt_status_t
183
      'Fetches the next message in the buffer, optionally copies the payload and optionally returns the latency.
184
    + {method} urtSubscriberFetchNextMessage (subscriber : urt_subscriber_t*, payload : void*, bytes : size_t, latency : urt_delay_t*) : urt_status_t
185
      'Fetches the latest message, optionally copies the payload and optionally returns the latency.
186
    + {method} urtSubscriberFetchLatestMessage (subscriber : urt_subscriber_t*, payload : void*, bytes : size_t, latency : urt_delay_t*) : urt_status_t
187
      'Calculates the usefulness of a message after the specified delay depending on the SRT or FRT (or HRT) parameters.
188
    + {method} urtSubscriberCalculateUsefulness (subscriber : urt_subscriber_t*, latency : urt_delay_t) : float
189
  }
190
} /'subscriber'/
191

    
192
/' Publisher type. '/
193
$structure("urt_publisher_t") {
194
    'Pointer to the topic for publishing.
195
  + {field} topic : urt_topic_t*
196
  .. URT_CFG_PROFILING == true ..
197
    'Counter of attempts to publish a message.
198
  + {field} publishAttempts : uint64_t
199
    'Counter of failed attempts to publish a message.
200
  + {field} publishFails : uint64_t
201
  __
202
    'Initializes a urt_publisher_t object and contributes an optional list of messages.
203
  + {method} urtPublisherInit (publisher : urt_publisher_t*, topic : urt_topic_t*, messages : urt_message_t*) : urt_status_t
204
    'Publishes a message via the associated topic.
205
  + {method} urtPublisherPublish (publisher : urt_publisher_t*, payload : void*, n : size_t, t : urt_osTime_t, timeout : urt_delay_t) : urt_status_t
206
}
207

    
208
/' Topic type. '/
209
$structure("urt_topic_t") {
210
    'Pointer to the next topic in a list.
211
  + {field} next : urt_topic_t*
212
    'Identifier of the topic.
213
  + {field} id : urt_topicid_t
214
    'Mutex lock for exclusive access.
215
  + {field} lock : urt_osMutex_t
216
    'Event source to inform all subscribers when a new message is published.
217
  + {field} evtSource : urt_osEventSource_t
218
    'Number of HRT subscribers.
219
  + {field} numHrtSubscribers : unsigned int
220
    'List of HRT subscribers, orderd by their expected rate (most critical first).
221
  + {field} hrtSubscribers : urt_subscriber_t*
222
    'Condition variable to inform waiting publishers when a blocked message becomes available.
223
  + {field} hrtReleased : urt_osCondvar_t
224
    'Mandatory message, each Topic holds.
225
  + {field} mandatoryMessage : urt_message_t
226
    'Pointer to the latest message.
227
  + {field} latestMessage : urt_message_t*
228
  .. URT_CFG_PUBSUB_QOS_RATECHECKS == true ..
229
    'Timer to check for missed rates.
230
  + {field} qosRateTimer : urt_osTimer_t
231
  .. URT_CFG_PUBSUB_PROFILING == true ..
232
    'Variable to count how many (non-hrt) subscribers did not fetch a message before it was reused.
233
  + {field} numDiscardedMessages : uint64_t
234
    'Number of overall subscribers.
235
  + {field} numSubscribers : unsigned int
236
  __
237
    'Initializes an urt_topic_t object.
238
  + {method} urtTopicInit (topic : urt_topic_t*, id : urt_topicid_t) : urt_status_t
239
}
240

    
241
!endsub
242

    
243
/'### DEPENDENCIES & LAYOUT ##################################################'/
244

    
245
!startsub DEPENDENCIES
246

    
247
urt_srtdata_t "1" o-- "0..1" urt_srtusefulnessfunc_t
248

    
249
urt_rtclassdata_t "1" *-- "0..1" urt_hrtdata_t
250
urt_rtclassdata_t "1" *-- "0..1" urt_frtdata_t
251
urt_rtclassdata_t "1" *-- "0..1" urt_srtdata_t
252
urt_rtclassdata_t "1" *-- "0..1" urt_nrtdata_t
253

    
254
urt_rtdata_t "1" *-- "1" urt_rtclass_t
255
urt_rtdata_t "1" *-- "1" urt_rtclassdata_t
256

    
257
urt_hrtdata_t "1" o-up- "0..1" urt_subscriber_t
258

    
259
urt_message_t "1" o-- "0..1" urt_message_t
260

    
261
urt_subscriber_t "1" *-- "1" urt_rtdata_t
262
urt_subscriber_t "1" o- "0..1" urt_topic_t
263
urt_subscriber_t "1" o-- "0..1" urt_message_t
264

    
265
urt_publisher_t "1" o- "1" urt_topic_t
266
urt_publisher_t ..> urt_message_t
267

    
268
urt_topic_t "1" o-- "0..1" urt_topic_t
269
urt_topic_t "1" o- "0..1" urt_subscriber_t
270
urt_topic_t "1" o-- "1..1" urt_message_t
271
urt_topic_t "1" *-- "1" urt_message_t
272

    
273
!endsub
274

    
275
/'### OUTRO ##################################################################'/
276

    
277
@enduml
278