urtware / doc / activitydiagrams / publisher / urtPublisherPublish.uml @ e87bd7c7
History | View | Annotate | Download (3.021 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**\nurtPublisherPublish()\n  | 
  
| 27 | 
       | 
  
| 28 | 
      /'### PARAMETERS & RETURN ####################################################'/  | 
  
| 29 | 
       | 
  
| 30 | 
      note  | 
  
| 31 | 
      -- **publisher** : urt_publisher_t* --  | 
  
| 32 | 
      Pointer to the publisher to use.  | 
  
| 33 | 
      Must not be ""NULL"".  | 
  
| 34 | 
      -- **payload** : void* --  | 
  
| 35 | 
      Pointer to the data to be published.  | 
  
| 36 | 
      May be ""NULL"" for messages without payload.  | 
  
| 37 | 
      -- **n** : size_t --  | 
  
| 38 | 
      Size of the payload in bytes.  | 
  
| 39 | 
      -- **t** : urt_osTime_t --  | 
  
| 40 | 
      Timestamp to be set for the message.  | 
  
| 41 | 
      -- **timeout** : urt_delay_t --  | 
  
| 42 | 
      Timeout delay in case the message cannot be published.  | 
  
| 43 | 
      ====  | 
  
| 44 | 
      -- **return** : urt_status_t --  | 
  
| 45 | 
      Returns ""URT_STATUS_OK"" on success.  | 
  
| 46 | 
      Returns ""URT_STATUS_ERROR"" on timeout.  | 
  
| 47 | 
      endnote  | 
  
| 48 | 
       | 
  
| 49 | 
      /'### PROCEDURE ##############################################################'/  | 
  
| 50 | 
       | 
  
| 51 | 
      start  | 
  
| 52 | 
      :lock topic;  | 
  
| 53 | 
      :access topic's next message;  | 
  
| 54 | 
      while (HRT consumers left for the message?) is (yes)  | 
  
| 55 | 
      :wait for topic's condition variable (using topic's mutex) to be signaled or timeout;  | 
  
| 56 | 
      if (Timeout occurred?) then (yes)  | 
  
| 57 | 
      :unlock topic;  | 
  
| 58 | 
      stop  | 
  
| 59 | 
      note  | 
  
| 60 | 
      Returns ""URT_STATUS_ERROR"".  | 
  
| 61 | 
      endnote  | 
  
| 62 | 
      else (no)  | 
  
| 63 | 
      if (Message timestamp was modified?) then (yes)  | 
  
| 64 | 
      :access topic's next message;  | 
  
| 65 | 
      else (no)  | 
  
| 66 | 
      endif  | 
  
| 67 | 
      endif  | 
  
| 68 | 
      endwhile (no)  | 
  
| 69 | 
      fork  | 
  
| 70 | 
      fork  | 
  
| 71 | 
      :iterate topic pointer to this message;  | 
  
| 72 | 
      fork again  | 
  
| 73 | 
      :copy payload to message;  | 
  
| 74 | 
      fork again  | 
  
| 75 | 
      :set origin time of message;  | 
  
| 76 | 
      fork again  | 
  
| 77 | 
      :set number of HRT consumers (from topic);  | 
  
| 78 | 
      endfork  | 
  
| 79 | 
      fork again  | 
  
| 80 | 
      :set QoS rate timer (@topic) wrt. most critical HRT subscriber;  | 
  
| 81 | 
      fork again  | 
  
| 82 | 
      while (HRT subscribers left?) is (yes)  | 
  
| 83 | 
      if (QoS delay timer (@subscriber) is not armed?) then (yes)  | 
  
| 84 | 
      :set QoS delay timer (@subscriber) wrt. origin time of the message;  | 
  
| 85 | 
      note: No lock required since this timer is only accessed when the topic is locked.  | 
  
| 86 | 
      else (no)  | 
  
| 87 | 
      endif  | 
  
| 88 | 
      :iterate to next HRT subscriber;  | 
  
| 89 | 
      endwhile (no)  | 
  
| 90 | 
      endfork  | 
  
| 91 | 
      :fire event;  | 
  
| 92 | 
      note: Msut be within topic lock because of HRT counter.  | 
  
| 93 | 
      :unlock topic;  | 
  
| 94 | 
      stop  | 
  
| 95 | 
      note  | 
  
| 96 | 
      Returns ""URT_STATUS_OK"".  | 
  
| 97 | 
      endnote  | 
  
| 98 | 
       | 
  
| 99 | 
      /'### OUTRO ##################################################################'/  | 
  
| 100 | 
       | 
  
| 101 | 
      @enduml  |