Statistics
| Branch: | Revision:

urtware / doc / activitydiagrams / publisher / urtPublisherPublish.uml @ 65dc89cb

History | View | Annotate | Download (4.143 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 ee83a495 Thomas Schöpping
/'### PARAMETERS & RETURN ####################################################'/
29 7491c395 Thomas Schöpping
30
note
31 ee83a495 Thomas Schöpping
  -- **publisher** : urt_publisher_t* --
32 7491c395 Thomas Schöpping
  Pointer to the publisher to use.
33
  Must not be ""NULL"".
34 ee83a495 Thomas Schöpping
  -- **payload** : void* --
35 7491c395 Thomas Schöpping
  Pointer to the data to be published.
36
  May be ""NULL"" for messages without payload.
37 dd31cb03 Thomas Schöpping
  -- **bytes** : size_t --
38 7491c395 Thomas Schöpping
  Size of the payload in bytes.
39 ee83a495 Thomas Schöpping
  -- **t** : urt_osTime_t --
40 7491c395 Thomas Schöpping
  Timestamp to be set for the message.
41 ee83a495 Thomas Schöpping
  -- **timeout** : urt_delay_t --
42 7491c395 Thomas Schöpping
  Timeout delay in case the message cannot be published.
43 0de5bed8 Thomas Schöpping
  This parameter is only available if ""URT_PUBSUB_PUBLISHER_PUBLISH_TIMEOUT"" is ""true"".
44 ee83a495 Thomas Schöpping
  ====
45
  -- **return** : urt_status_t --
46
  Returns ""URT_STATUS_OK"" on success.
47 dd31cb03 Thomas Schöpping
  Returns ""URT_STATUS_PUBLISH_TIMEOUT"" on timeout.
48 ee83a495 Thomas Schöpping
endnote
49 7491c395 Thomas Schöpping
50
/'### PROCEDURE ##############################################################'/
51
52 ee83a495 Thomas Schöpping
start
53 7491c395 Thomas Schöpping
:lock topic;
54 dd31cb03 Thomas Schöpping
fork
55
  :access topic's next message;
56
fork again
57
  #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\nincrement counter of publish attempts;
58
endfork
59 ee83a495 Thomas Schöpping
while (HRT consumers left for the message?) is (yes)
60
  :wait for topic's condition variable (using topic's mutex) to be signaled or timeout;
61
  if (Timeout occurred?) then (yes)
62 dd31cb03 Thomas Schöpping
    #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\nincrement counter of publish fails;
63 ee83a495 Thomas Schöpping
    :unlock topic;
64
    stop
65
    note
66 dd31cb03 Thomas Schöpping
      Returns ""URT_STATUS_PUBLISH_TIMEOUT"".
67 ee83a495 Thomas Schöpping
    endnote
68 c22d21ad Thomas Schöpping
  else (no)
69 ee83a495 Thomas Schöpping
    if (Message timestamp was modified?) then (yes)
70 dd31cb03 Thomas Schöpping
      repeat
71
        :proceed to next message;
72
      repeat while (Timestamp is younger than of previous message?) is (yes)
73
      ->no;
74 ee83a495 Thomas Schöpping
    else (no)
75
    endif
76 c22d21ad Thomas Schöpping
  endif
77 7491c395 Thomas Schöpping
endwhile (no)
78 dd31cb03 Thomas Schöpping
partition "//URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE {
79
  if (Consumers left for this message?) then (yes)
80
    #EEEEEE:increment counter of discarded messages (@topic);
81
  else (no)
82
  endif
83
}
84 ee83a495 Thomas Schöpping
fork
85 dd31cb03 Thomas Schöpping
  partition "setup message" {
86
    fork
87
      :iterate topic's pointer to this message;
88
    fork again
89
      :copy payload to message;
90
    fork again
91
      :set origin time of message;
92
    fork again
93
      :set number of HRT consumers (from topic);
94
    fork again
95
      #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..
96
       set numer of consumers (from topic);
97
    endfork
98
  }
99 ee83a495 Thomas Schöpping
fork again
100 dd31cb03 Thomas Schöpping
  #EEEEEE:..//URT_CFG_PUBSUB_QOS_RATECHECKS == true//..\nset QoS rate timer (@topic) wrt. most critical HRT subscriber;
101 ee83a495 Thomas Schöpping
fork again
102 dd31cb03 Thomas Schöpping
  partition "//URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true//" #EEEEEE {
103
    #EEEEEE:access first HRT subscriber of topic;
104
    while (HRT subscriber is not ""NULL""?) is (yes)
105
      if (QoS deadline timer (@subscriber) is not armed?) then (yes)
106
        #EEEEEE:set QoS deadline timer (@subscriber) wrt. origin time of the message;
107
        note
108
          No lock required.
109
          This timer is only accessed while topic is locked.
110
        endnote
111
      else (no)
112
      endif
113
      #EEEEEE:proceed to next HRT subscriber;
114
    endwhile (no)
115
  }
116
fork again
117
  #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\nincrement counter of published messages (@topic);
118 ee83a495 Thomas Schöpping
endfork
119
:fire event;
120
note: Msut be within topic lock because of HRT counter.
121
:unlock topic;
122 7491c395 Thomas Schöpping
stop
123
note
124 ee83a495 Thomas Schöpping
 Returns ""URT_STATUS_OK"".
125
endnote
126 7491c395 Thomas Schöpping
127
/'### OUTRO ##################################################################'/
128
129
@enduml