urtware / inc / urt_subscriber.h @ 1fb06240
History | View | Annotate | Download (6.167 KB)
1 | 1fb06240 | skenneweg | /*
|
---|---|---|---|
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 | #ifndef URTWARE_SUBSCRIBER_H
|
||
23 | #define URTWARE_SUBSCRIBER_H
|
||
24 | |||
25 | #include <urt_types.h> |
||
26 | |||
27 | /******************************************************************************/
|
||
28 | /* CONSTANTS */
|
||
29 | /******************************************************************************/
|
||
30 | |||
31 | /******************************************************************************/
|
||
32 | /* SETTINGS */
|
||
33 | /******************************************************************************/
|
||
34 | |||
35 | /******************************************************************************/
|
||
36 | /* CHECKS */
|
||
37 | /******************************************************************************/
|
||
38 | |||
39 | /******************************************************************************/
|
||
40 | /* DATA STRUCTURES AND TYPES */
|
||
41 | /******************************************************************************/
|
||
42 | |||
43 | /**
|
||
44 | * @brief Base subscriber
|
||
45 | * @details The base subscriber is included in each specialized subscriber
|
||
46 | */
|
||
47 | typedef struct urt_basesubscriber |
||
48 | { |
||
49 | urt_topic_t* topic; |
||
50 | urt_osEventListener_t evtListener; |
||
51 | urt_message_t* lastMessage; |
||
52 | urt_osTime_t lastMessageTime; |
||
53 | #if (URT_CFG_PUBSUB_PROFILING)
|
||
54 | uint64_t sumLatencies; |
||
55 | uint64_t numMessagesReceived; |
||
56 | #endif /* URT_CFG_PUBSUB_PROFILING */ |
||
57 | }urt_basesubscriber_t; |
||
58 | |||
59 | /**
|
||
60 | * @brief nrt subscriber
|
||
61 | */
|
||
62 | typedef struct urt_nrtsubscriber |
||
63 | { |
||
64 | urt_basesubscriber_t base; |
||
65 | #if (URT_CFG_PUBSUB_PROFILING)
|
||
66 | urt_delay_t minLatency; |
||
67 | urt_delay_t maxLatency; |
||
68 | #endif /* URT_CFG_PUBSUB_PROFILING */ |
||
69 | }urt_nrtsubscriber_t; |
||
70 | |||
71 | /**
|
||
72 | * @brief nrt subscriber
|
||
73 | */
|
||
74 | typedef struct urt_srtsubscriber |
||
75 | { |
||
76 | urt_basesubscriber_t base; |
||
77 | urt_srtusefulnessfunc_t* usefulnesscb; |
||
78 | #if (URT_CFG_PUBSUB_PROFILING)
|
||
79 | urt_delay_t minLatency; |
||
80 | urt_delay_t maxLatency; |
||
81 | #endif /* URT_CFG_PUBSUB_PROFILING */ |
||
82 | }urt_srtsubscriber_t; |
||
83 | |||
84 | /**
|
||
85 | * @brief nrt subscriber
|
||
86 | */
|
||
87 | typedef struct urt_frtsubscriber |
||
88 | { |
||
89 | urt_basesubscriber_t base; |
||
90 | #if (URT_CFG_PUBSUB_QOS_DEADLINECHECKS)
|
||
91 | urt_delay_t deadlineOffset; |
||
92 | #endif /* URT_CFG_PUBSUB_QOS_DEADLINECHECKS */ |
||
93 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS)
|
||
94 | urt_delay_t maxJitter; |
||
95 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS */ |
||
96 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING)
|
||
97 | urt_delay_t minLatency; |
||
98 | urt_delay_t maxLatency; |
||
99 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING */ |
||
100 | }urt_frtsubscriber_t; |
||
101 | |||
102 | /**
|
||
103 | * @brief nrt subscriber
|
||
104 | */
|
||
105 | typedef struct urt_hrtsubscriber |
||
106 | { |
||
107 | urt_basesubscriber_t base; |
||
108 | urt_hrtsubscriber_t* next; |
||
109 | #if (URT_CFG_PUBSUB_QOS_DEADLINECHECKS)
|
||
110 | urt_delay_t deadlineOffset; |
||
111 | urt_osTimer_t qosDeadlineTimer; |
||
112 | #endif /* URT_CFG_PUBSUB_QOS_DEADLINECHECKS */ |
||
113 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS)
|
||
114 | urt_delay_t maxJitter; |
||
115 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS */ |
||
116 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING)
|
||
117 | urt_delay_t minLatency; |
||
118 | urt_delay_t maxLatency; |
||
119 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING */ |
||
120 | #if (URT_CFG_PUBSUB_QOS_RATECHECKS)
|
||
121 | urt_delay_t expectedRate; |
||
122 | #endif /* URT_CFG_PUBSUB_QOS_RATECHECKS */ |
||
123 | }urt_hrtsubscriber_t; |
||
124 | |||
125 | /******************************************************************************/
|
||
126 | /* MACROS */
|
||
127 | /******************************************************************************/
|
||
128 | |||
129 | /******************************************************************************/
|
||
130 | /* EXTERN DECLARATIONS */
|
||
131 | /******************************************************************************/
|
||
132 | |||
133 | #if defined(__cplusplus)
|
||
134 | extern "C" { |
||
135 | #endif /* defined(__cplusplus) */ |
||
136 | |||
137 | void urtNrtSubscriberInit();
|
||
138 | urt_status_t urtNrtSubscriberSubscribe(); |
||
139 | urt_status_t urtNrtSubscriberFetchNextMessage(); |
||
140 | urt_status_t urtNrtSubscriberFetchLatestMessage(); |
||
141 | urt_status_t urtNrtSubscriberUnsubscribe(); |
||
142 | |||
143 | void urtSrtSubscriberInit();
|
||
144 | urt_status_t urtSrtSubscriberSubscribe(); |
||
145 | urt_status_t urtSrtSubscriberFetchNextMessage(); |
||
146 | urt_status_t urtSrtSubscriberFetchLatestMessage(); |
||
147 | urt_status_t urtSrtSubscriberCalculateUsefulness(); |
||
148 | urt_status_t urtSrtSubscriberUnsubscribe(); |
||
149 | |||
150 | void urtFrtSubscriberInit();
|
||
151 | urt_status_t urtFrtSubscriberSubscribe(); |
||
152 | urt_status_t urtFrtSubscriberFetchNextMessage(); |
||
153 | urt_status_t urtFrtSubscriberFetchLatestMessage(); |
||
154 | bool urtFrtSubscriberCalculateValidity();
|
||
155 | urt_status_t urtFrtSubscriberUnsubscribe(); |
||
156 | |||
157 | void urtHrtSubscriberInit();
|
||
158 | urt_status_t urtHrtSubscriberSubscribe(); |
||
159 | urt_status_t urtHrtSubscriberFetchNextMessage(); |
||
160 | urt_status_t urtHrtSubscriberFetchLatestMessage(); |
||
161 | urt_status_t urtHrtSubscriberUnsubscribe(); |
||
162 | |||
163 | float urt_srtusefulnessfunc_t();
|
||
164 | #if defined(__cplusplus)
|
||
165 | } |
||
166 | #endif /* defined(__cplusplus) */ |
||
167 | |||
168 | /******************************************************************************/
|
||
169 | /* INLINE FUNCTIONS */
|
||
170 | /******************************************************************************/
|
||
171 | |||
172 | #endif /* URTWARE_SUBSCRIBER_H */ |