urtware / inc / urt_primitives.h @ 2c811df1
History | View | Annotate | Download (6.793 KB)
1 | 46471486 | 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 | #ifndef URT_PRIMITIVES_H
|
||
23 | #define URT_PRIMITIVES_H
|
||
24 | |||
25 | #include <urtware.h> |
||
26 | |||
27 | #include <stdint.h> |
||
28 | |||
29 | /*============================================================================*/
|
||
30 | /* CONSTANTS */
|
||
31 | /*============================================================================*/
|
||
32 | |||
33 | /**
|
||
34 | * @brief Special constant value for immediate (nonexistent) delays.
|
||
35 | */
|
||
36 | #define URT_DELAY_IMMEDIATE (urt_delay_t)0 |
||
37 | |||
38 | /**
|
||
39 | * @brief Special constant value for infinite delays.
|
||
40 | */
|
||
41 | #define URT_DELAY_INFINITE (urt_delay_t)~0 |
||
42 | |||
43 | /*============================================================================*/
|
||
44 | /* SETTINGS */
|
||
45 | /*============================================================================*/
|
||
46 | |||
47 | /*============================================================================*/
|
||
48 | /* CHECKS */
|
||
49 | /*============================================================================*/
|
||
50 | |||
51 | /*============================================================================*/
|
||
52 | /* DATA STRUCTURES AND TYPES */
|
||
53 | /*============================================================================*/
|
||
54 | |||
55 | /**
|
||
56 | * @brief Type for temporal delays (in microseconds).
|
||
57 | */
|
||
58 | #if (URT_CFG_DELAY_WIDTH == 32) |
||
59 | typedef uint32_t urt_delay_t;
|
||
60 | #elif (URT_CFG_DELAY_WIDTH == 64) |
||
61 | typedef uint64_t urt_delay_t;
|
||
62 | #else
|
||
63 | # error "URT_CFG_DELAY_WIDTH must be set to 32 or 64." |
||
64 | #endif
|
||
65 | |||
66 | /**
|
||
67 | * @brief Type to use for the node stage value.
|
||
68 | * @details Use wide types only if you need to synchronize the system very often.
|
||
69 | */
|
||
70 | #if (URT_CFG_NODESTAGE_WIDTH == 8) |
||
71 | typedef uint8_t urt_nodestage_t;
|
||
72 | #elif (URT_CFG_NODESTAGE_WIDTH == 16) |
||
73 | typedef uint16_t urt_nodestage_t;
|
||
74 | #elif (URT_CFG_NODESTAGE_WIDTH == 32) |
||
75 | typedef uint32_t urt_nodestage_t;
|
||
76 | #elif (URT_CFG_NODESTAGE_WIDTH == 64) |
||
77 | typedef uint64_t urt_nodestage_t;
|
||
78 | #else
|
||
79 | # error "URT_CFG_NODESTAGE_WIDTH must be set to 8, 16, 32 or 64." |
||
80 | #endif
|
||
81 | |||
82 | /**
|
||
83 | * @brief General status type used throughout µRtWare and its interfaces.
|
||
84 | */
|
||
85 | typedef enum { |
||
86 | URT_STATUS_OK = 0, /**< Status indicating success. */ |
||
87 | URT_STATUS_DEADLINEVIOLATION, /**< Status indicating a violated deadline. */
|
||
88 | URT_STATUS_JITTERVIOLATION, /**< Status indicating a violated jitter requirement. */
|
||
89 | URT_STATUS_RATEVIOLATION, /**< Status indicating a violated rate requirement. */
|
||
90 | URT_STATUS_SYNC_PENDING, /**< Status indicating a synchronization barrier. */
|
||
91 | URT_STATUS_SYNC_ERROR, /**< Status indicating a failed synchronization. */
|
||
92 | URT_STATUS_NODE_INVALEVTMASK, /**< Status indicating an invalid event mask. */
|
||
93 | #if (URT_CFG_PUBSUB_ENABLED == true) || defined(__DOXYGEN__) |
||
94 | URT_STATUS_TOPIC_DUPLICATE, /**< Status indicating multiple use of the same topic ID. */
|
||
95 | URT_STATUS_PUBLISH_TIMEOUT, /**< Status indicating a timeout when publishinh a message. */
|
||
96 | URT_STATUS_SUBSCRIBE_TOPICSET, /**< Status indicating that the subscriber is already associated to a topic. */
|
||
97 | URT_STATUS_FETCH_NOTOPIC, /**< Status indicating that the subscriber is not associated to any topic. */
|
||
98 | URT_STATUS_FETCH_NOMESSAGE, /**< Status indicating that no message could be fetched. */
|
||
99 | URT_STATUS_UNSUBSCRIBE_NOTOPIC, /**< Status indicating that the subscriber is not associated to an topic. */
|
||
100 | #endif /* URT_CFG_PUBSUB_ENABLED == true */ |
||
101 | #if (URT_CFG_RPC_ENABLED == true) || defined(__DOXYGEN__) |
||
102 | URT_STATUS_SERVICE_DUPLICATE, /**< Status indicating multiple use of the same service ID. */
|
||
103 | URT_STATUS_REQUEST_BADOWNER, /**< Status indicating that a request is currently owned by another component. */
|
||
104 | URT_STATUS_REQUEST_LOCKED, /**< Status indicating a currently locked request. */
|
||
105 | #endif /* URT_CFG_RPC_ENABLED == true */ |
||
106 | } urt_status_t; |
||
107 | |||
108 | #if (URT_CFG_PUBSUB_ENABLED == true) || defined(__DOXYGEN__) |
||
109 | # if (URT_CFG_PUBSUB_TOPICID_WIDTH == 8) |
||
110 | typedef uint8_t urt_topicid_t;
|
||
111 | # elif (URT_CFG_PUBSUB_TOPICID_WIDTH == 16) |
||
112 | typedef uint16_t urt_topicid_t;
|
||
113 | # elif (URT_CFG_PUBSUB_TOPICID_WIDTH == 32) |
||
114 | typedef uint32_t urt_topicid_t;
|
||
115 | # elif (URT_CFG_PUBSUB_TOPICID_WIDTH == 64) |
||
116 | typedef uint64_t urt_topicid_t;
|
||
117 | # else
|
||
118 | # error "URT_CFG_PUBSUB_TOPICID_WIDTH must be set to 8, 16, 32 or 64." |
||
119 | # endif
|
||
120 | #endif /* URT_CFG_PUBSUB_ENABLED == true */ |
||
121 | |||
122 | #if (URT_CFG_RPC_ENABLED == true) || defined(__DOXYGEN__) |
||
123 | # if (URT_CFG_RPC_SERVICEID_WIDTH == 8) |
||
124 | typedef uint8_t urt_serviced_t;
|
||
125 | # elif (URT_CFG_RPC_SERVICEID_WIDTH == 16) |
||
126 | typedef uint16_t urt_serviced_t;
|
||
127 | # elif (URT_CFG_RPC_SERVICEID_WIDTH == 32) |
||
128 | typedef uint32_t urt_serviced_t;
|
||
129 | # elif (URT_CFG_RPC_SERVICEID_WIDTH == 64) |
||
130 | typedef uint64_t urt_serviced_t;
|
||
131 | # else
|
||
132 | # error "URT_CFG_RPC_SERVICEID_WIDTH must be set to 8, 16, 32 or 64." |
||
133 | # endif
|
||
134 | #endif /* URT_CFG_RPC_ENABLED == true */ |
||
135 | |||
136 | /**
|
||
137 | * @brief Usefulness calculation function type.
|
||
138 | *
|
||
139 | * @param[in] dt Delay to calculate the usefulness for.
|
||
140 | * @param[in] param Pointer to optional parameters (may be NULL).
|
||
141 | *
|
||
142 | * return The usefulness (of some data) after the specified delay as value in range [0, 1].
|
||
143 | */
|
||
144 | typedef float (*urt_usefulness_f)(urt_delay_t dt, void* params); |
||
145 | |||
146 | /*============================================================================*/
|
||
147 | /* MACROS */
|
||
148 | /*============================================================================*/
|
||
149 | |||
150 | /*============================================================================*/
|
||
151 | /* EXTERN DECLARATIONS */
|
||
152 | /*============================================================================*/
|
||
153 | |||
154 | /*============================================================================*/
|
||
155 | /* INLINE FUNCTIONS */
|
||
156 | /*============================================================================*/
|
||
157 | |||
158 | #endif /* URT_PRIMITIVES_H */ |