Statistics
| Branch: | Revision:

urtware / doc / activitydiagrams / subscriber / hrtsubscriber / urtHrtSubscriberFetchLatestMessage.uml @ dd31cb03

History | View | Annotate | Download (4.25 KB)

1 dd31cb03 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**\nurtHrtSubscriberFetchLatestMessage()\n
27
28
!include ../functions.iuml
29
30
/'### PARAMETERS & RETURN ####################################################'/
31
32
note
33
  -- **subscriber** : urt_hrtsubscriber_t* --
34
  The HRT subscriber that shall fetch the message.
35
  Must not be ""NULL"".
36
  -- **payload** : void* --
37
  Pointer where to copy the payload to.
38
  May be ""NULL"" for messages without payload.
39
  -- **bytes** : size_t --
40
  Payload size in bytes.
41
  -- **latency** : urt_delay_t* --
42
  The latency can be returned by reference.
43
  May be ""NULL"".
44
  ====
45
  -- **return** : urt_status_t --
46
  Returns ""URT_STATUS_OK"" on success.
47
  Returns ""URT_STATUS_FETCH_NOTOPIC"" if the subscriber is not associated to a topic.
48
  Retruns ""URT_STATUS_FETCH_NOMESSAGE"" if there is no new message to fetch.
49
  Returns ""URT_STATUS_JITTERVIOLATION"" if the message's latency violated the maximum expected jitter.
50
endnote
51
52
/'### PROCEDURE ##############################################################'/
53
54
start
55
if (Associated to a topic?) then (yes)
56
  :lock topic;
57
  partition "find latest message" {
58
    :access ""lastMessage"";
59
    while (Timestamp of next message is younger?) is (yes)
60
      fork
61
        :proceed to next message;
62
        fork
63
          :decrement message's counter of HRT consumers;
64
        fork again
65
          #EEEEEE:..//URT_CFG_PUBSUB_PROFILING == true//..\ndecrement message's counter of consumers;
66
        fork again
67
          #EEEEEE:..//URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true//..\nreset QoS deadline timer;
68
        endfork
69
      fork again
70
        #EEEEEE:..//URT_CFG:PUBSUB_PROFILING == true//..\nincrement counter of received messages;
71
      endfork
72
      if (HRT counter of a message became 0?) then (yes)
73
        :signal topic's condition variable;
74
      else (no)
75
      endif
76
    endwhile (no)
77
  }
78
  if (Timestamp equals local copy?) then (yes)
79
    :unlock topic;
80
    stop
81
    note
82
      Returns ""URT_STATUS_FETCH_NOMESSAGE"".
83
    endnote
84
  else (no)
85
    :calculate message latency;
86
    fork
87
      #EEEEEE:..//URT:CFG_PUBSUB_PROFILING == true//..\naccumulate ""sumLatencies"" value;
88
    fork again
89
      if (Optional ""latency"" output argument given?) then (yes)
90
        :set ""latency"" value;
91
      else (no)
92
      endif
93
    endfork
94
  endif
95
  partition "//URT_CFG_PUBSUB_QOS_JITTERCHECKS == true || URT_CFG_PUBSUB_PROFILING == true//" #EEEEEE {
96
    if (Latency is within allowed jitter range?) then (yes)
97
      if (Latency is lower than ""minlatency""?) then (yes)
98
        #EEEEEE:update ""minLatency"" value;
99
      elseif (Latency is greater than ""maxLatency"" value?) then (yes)
100
        #EEEEEE:update ""maxLatency"" value;
101
      else (no)
102
      endif
103
    else (no)
104
      partition "//URT_CFG_PUBSUB_QOS_JITTERCHECKS == true//" #EEEEEE {
105
        #EEEEEE:unlock topic;
106
        #EEEEEE:call ""urtCoreStopNodes(URT_STATUS_JITTERVIOLATION)"";
107
        stop
108
        note
109
          Returns ""URT_STATUS_JITTERVIOLATION"".
110
        endnote
111
      }
112
    endif
113
  }
114
  fork
115
    $fetch_message()
116
  fork again
117
    #EEEEEE:..//URT_CFG_PUBSUB_QOS_DEADLINECHECKS == true//..\nreset QoS deadline timer;
118
  endfork
119
  :unlock topic;
120
  stop
121
  note
122
    Returns ""URT_STATUS_OK"".
123
  endnote
124
else (no)
125
  stop
126
  note
127
    Returns ""URT_STATUS_ERROR"".
128
  endnote
129
endif
130
131
/'### OUTRO ##################################################################'/
132
133
@enduml