urtware / inc / urt_subscriber.h @ 33aa05c5
History | View | Annotate | Download (7.017 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 | 7d9678db | skenneweg | #include <urtware.h> |
| 26 | 982056f7 | Svenja | #include <urt_basesubscriber.h> |
| 27 | 1fb06240 | skenneweg | |
| 28 | /******************************************************************************/
|
||
| 29 | /* CONSTANTS */
|
||
| 30 | /******************************************************************************/
|
||
| 31 | |||
| 32 | /******************************************************************************/
|
||
| 33 | /* SETTINGS */
|
||
| 34 | /******************************************************************************/
|
||
| 35 | |||
| 36 | /******************************************************************************/
|
||
| 37 | /* CHECKS */
|
||
| 38 | /******************************************************************************/
|
||
| 39 | |||
| 40 | /******************************************************************************/
|
||
| 41 | /* DATA STRUCTURES AND TYPES */
|
||
| 42 | /******************************************************************************/
|
||
| 43 | |||
| 44 | /**
|
||
| 45 | * @brief nrt subscriber
|
||
| 46 | */
|
||
| 47 | typedef struct urt_nrtsubscriber |
||
| 48 | {
|
||
| 49 | cd21e832 | skenneweg | urt_basesubscriber_t base; |
| 50 | #if (URT_CFG_PUBSUB_PROFILING)
|
||
| 51 | urt_delay_t minLatency; |
||
| 52 | urt_delay_t maxLatency; |
||
| 53 | #endif /* URT_CFG_PUBSUB_PROFILING */ |
||
| 54 | 1fb06240 | skenneweg | }urt_nrtsubscriber_t; |
| 55 | |||
| 56 | /**
|
||
| 57 | 5c6cb22f | skenneweg | * @brief srt subscriber
|
| 58 | 1fb06240 | skenneweg | */
|
| 59 | typedef struct urt_srtsubscriber |
||
| 60 | {
|
||
| 61 | cd21e832 | skenneweg | urt_basesubscriber_t base; |
| 62 | 5c6cb22f | skenneweg | void* cbparams;
|
| 63 | urt_usefulness_f* usefulnesscb; |
||
| 64 | cd21e832 | skenneweg | #if (URT_CFG_PUBSUB_PROFILING)
|
| 65 | urt_delay_t minLatency; |
||
| 66 | urt_delay_t maxLatency; |
||
| 67 | #endif /* URT_CFG_PUBSUB_PROFILING */ |
||
| 68 | 1fb06240 | skenneweg | }urt_srtsubscriber_t; |
| 69 | |||
| 70 | /**
|
||
| 71 | 5c6cb22f | skenneweg | * @brief frt subscriber
|
| 72 | 1fb06240 | skenneweg | */
|
| 73 | typedef struct urt_frtsubscriber |
||
| 74 | {
|
||
| 75 | cd21e832 | skenneweg | urt_basesubscriber_t base; |
| 76 | #if (URT_CFG_PUBSUB_QOS_DEADLINECHECKS)
|
||
| 77 | urt_delay_t deadlineOffset; |
||
| 78 | #endif /* URT_CFG_PUBSUB_QOS_DEADLINECHECKS */ |
||
| 79 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS)
|
||
| 80 | urt_delay_t maxJitter; |
||
| 81 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS */ |
||
| 82 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING)
|
||
| 83 | urt_delay_t minLatency; |
||
| 84 | urt_delay_t maxLatency; |
||
| 85 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING */ |
||
| 86 | 1fb06240 | skenneweg | }urt_frtsubscriber_t; |
| 87 | |||
| 88 | /**
|
||
| 89 | * @brief nrt subscriber
|
||
| 90 | */
|
||
| 91 | typedef struct urt_hrtsubscriber |
||
| 92 | {
|
||
| 93 | cd21e832 | skenneweg | urt_basesubscriber_t base; |
| 94 | 5c6cb22f | skenneweg | struct urt_hrtsubscriber* next;
|
| 95 | cd21e832 | skenneweg | #if (URT_CFG_PUBSUB_QOS_DEADLINECHECKS)
|
| 96 | urt_delay_t deadlineOffset; |
||
| 97 | urt_osTimer_t qosDeadlineTimer; |
||
| 98 | #endif /* URT_CFG_PUBSUB_QOS_DEADLINECHECKS */ |
||
| 99 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS)
|
||
| 100 | urt_delay_t maxJitter; |
||
| 101 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS */ |
||
| 102 | #if (URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING)
|
||
| 103 | urt_delay_t minLatency; |
||
| 104 | urt_delay_t maxLatency; |
||
| 105 | #endif /* URT_CFG_PUBSUB_QOS_JITTERCHECKS || URT_CFG_PUBSUB_PROFILING */ |
||
| 106 | #if (URT_CFG_PUBSUB_QOS_RATECHECKS)
|
||
| 107 | urt_delay_t expectedRate; |
||
| 108 | #endif /* URT_CFG_PUBSUB_QOS_RATECHECKS */ |
||
| 109 | 1fb06240 | skenneweg | }urt_hrtsubscriber_t; |
| 110 | |||
| 111 | /******************************************************************************/
|
||
| 112 | /* MACROS */
|
||
| 113 | /******************************************************************************/
|
||
| 114 | |||
| 115 | /******************************************************************************/
|
||
| 116 | /* EXTERN DECLARATIONS */
|
||
| 117 | /******************************************************************************/
|
||
| 118 | |||
| 119 | #if defined(__cplusplus)
|
||
| 120 | extern "C" { |
||
| 121 | #endif /* defined(__cplusplus) */ |
||
| 122 | |||
| 123 | cd21e832 | skenneweg | void urtNrtSubscriberInit(urt_nrtsubscriber_t* subscriber);
|
| 124 | urt_status_t urtNrtSubscriberSubscribe(urt_nrtsubscriber_t* subscriber, urt_topic_t* topic, urt_message_t* messages); |
||
| 125 | urt_status_t urtNrtSubscriberFetchNextMessage(urt_nrtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
||
| 126 | urt_status_t urtNrtSubscriberFetchLatestMessage(urt_nrtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
||
| 127 | urt_status_t urtNrtSubscriberUnsubscribe(urt_nrtsubscriber_t* subscriber); |
||
| 128 | |||
| 129 | void urtSrtSubscriberInit(urt_srtsubscriber_t* subscriber);
|
||
| 130 | a5e142de | skenneweg | urt_status_t urtSrtSubscriberSubscribe(urt_srtsubscriber_t* subscriber, urt_topic_t* topic, urt_message_t* messages, urt_usefulness_f* usefulnesscb, void* cbparams);
|
| 131 | cd21e832 | skenneweg | urt_status_t urtSrtSubscriberFetchNextMessage(urt_srtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
| 132 | urt_status_t urtSrtSubscriberFetchLatestMessage(urt_srtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
||
| 133 | 5198dfae | skenneweg | float urtSrtSubscriberCalculateUsefulness(urt_srtsubscriber_t* subscriber, urt_delay_t latency);
|
| 134 | cd21e832 | skenneweg | urt_status_t urtSrtSubscriberUnsubscribe(urt_srtsubscriber_t* subscriber); |
| 135 | |||
| 136 | void urtFrtSubscriberInit(urt_frtsubscriber_t* subscriber);
|
||
| 137 | urt_status_t urtFrtSubscriberSubscribe(urt_frtsubscriber_t* subscriber, urt_topic_t* topic, urt_message_t* messages, urt_delay_t deadline, urt_delay_t jitter); |
||
| 138 | urt_status_t urtFrtSubscriberFetchNextMessage(urt_frtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
||
| 139 | urt_status_t urtFrtSubscriberFetchLatestMessage(urt_frtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
||
| 140 | bool urtFrtSubscriberCalculateValidity(urt_frtsubscriber_t* subscriber, urt_delay_t latency);
|
||
| 141 | urt_status_t urtFrtSubscriberUnsubscribe(urt_frtsubscriber_t* subscriber); |
||
| 142 | |||
| 143 | void urtHrtSubscriberInit(urt_hrtsubscriber_t* subscriber);
|
||
| 144 | 5b7188aa | skenneweg | urt_status_t urtHrtSubscriberSubscribe(urt_hrtsubscriber_t* subscriber, urt_topic_t* topic, urt_message_t* messages, urt_delay_t deadline, urt_delay_t rate, urt_delay_t jitter); |
| 145 | cd21e832 | skenneweg | urt_status_t urtHrtSubscriberFetchNextMessage(urt_hrtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
| 146 | urt_status_t urtHrtSubscriberFetchLatestMessage(urt_hrtsubscriber_t* subscriber, void* payload, size_t bytes, urt_delay_t* latency);
|
||
| 147 | urt_status_t urtHrtSubscriberUnsubscribe(urt_hrtsubscriber_t* subscriber); |
||
| 148 | 1fb06240 | skenneweg | #if defined(__cplusplus)
|
| 149 | } |
||
| 150 | #endif /* defined(__cplusplus) */ |
||
| 151 | |||
| 152 | /******************************************************************************/
|
||
| 153 | /* INLINE FUNCTIONS */
|
||
| 154 | /******************************************************************************/
|
||
| 155 | |||
| 156 | #endif /* URTWARE_SUBSCRIBER_H */ |