650492cf68555d312581313d344eb2196aa26323
[staging/basesystem.git] / service / native / common_library / client / include / native_service / cl_monitor.h
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /**
17  * @file
18  * @brief \~english This file contains the enum,struct and api of cl_monitor.
19  */
20 #ifndef _cl_monitor_h_  // NOLINT(build/header_guard)
21 #define _cl_monitor_h_  // NOLINT(build/header_guard)
22
23 #include <stdint.h>
24
25 /////////////////////////////////////////////////////////////////////////////////////
26 /// \ingroup Monitor
27 /// \~english @par Brief
28 ///        Monitor init enum
29 /////////////////////////////////////////////////////////////////////////////////////
30 typedef enum {
31   CL_MONITOR_INIT_SYSTEM = 0,
32   CL_MONITOR_INIT_USER
33 } CL_MonitorInit_t;
34
35 /////////////////////////////////////////////////////////////////////////////////////
36 /// \ingroup Monitor
37 /// \~english @par Brief
38 ///        the struct of Monitor Entry
39 /////////////////////////////////////////////////////////////////////////////////////
40 typedef struct {
41   uint16_t pid;
42   uint8_t type;
43   uint8_t state;
44
45 //  uint32_t timeout;
46   time_t timeout;
47   uint32_t id;
48   uint32_t user_data;
49 } CL_MonitorEntry_t;
50
51 /////////////////////////////////////////////////////////////////////////////////////
52 /// \ingroup Monitor
53 /// \~english @par Brief
54 ///        Monitor type enum
55 /////////////////////////////////////////////////////////////////////////////////////
56 typedef enum {
57   CL_MONITOR_TYPE_GENERIC = 0,
58   CL_MONITOR_TYPE_RPC
59 } CL_MonitorType_t;
60
61 /////////////////////////////////////////////////////////////////////////////////////
62 /// \ingroup Monitor
63 /// \~english @par Brief
64 ///        Monitor state enum
65 /////////////////////////////////////////////////////////////////////////////////////
66 typedef enum {
67   CL_MONITOR_STATE_SLEEP = 0,
68   CL_MONITOR_STATE_RUN
69 } CL_MonitorState_t;
70
71
72 /////////////////////////////////////////////////////////////////////////////////////
73 /// \ingroup Monitor
74 /// \~english @par Brief
75 ///        the struct of Monitor Search
76 /////////////////////////////////////////////////////////////////////////////////////
77 typedef struct {
78   CL_MonitorEntry_t *entry_list;
79   int entry_num;
80 } CL_MonitorSearch_t;
81
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85 /**
86  * @file cl_monitor.h
87  */
88
89 /** @addtogroup BaseSystem
90  *  @{
91  */
92 /** @addtogroup native_service
93  *  @ingroup BaseSystem
94  *  @{
95  */
96 /** @addtogroup common_library
97  *  @ingroup native_service
98  *  @{
99  */
100
101 /////////////////////////////////////////////////////////////////////////////////////
102 /// \ingroup Monitor
103 /// \~english @par Brief
104 ///     Monitor initialize
105 /// \~english @param [in] init_type
106 ///     CL_MonitorInit_t - the type of initialzation
107 /// \~english @retval 0  Success
108 /// \~english @retval -1 Error
109 /// \~english @par Prerequisite
110 ///     None
111 /// \~english @par Change of internal state
112 ///     None
113 /// \~english @par Conditions of processing failure
114 ///     None
115 /// \~english @par Classification
116 ///     Public
117 /// \~english @par Type
118 ///     Sync
119 /// \~english @par Detail
120 ///     None
121 /// \~english @see None
122 ////////////////////////////////////////////////////////////////////////////////////
123 int CL_MonitorInit(CL_MonitorInit_t init_type);  // NOLINT(readability/nolint)
124
125
126 /////////////////////////////////////////////////////////////////////////////////////
127 /// \ingroup Monitor
128 /// \~english @par Brief
129 ///     Set Monitor Entry
130 /// \~english @param [in] type
131 ///     CL_MonitorType_t - the type of monitor
132 /// \~english @param [in] state
133 ///     CL_MonitorState_t - the state of monitor
134 /// \~english @param [in] timeout
135 ///     uint32_t - the vlaue of timeout
136 /// \~english @param [in] user_data
137 ///     uint32_t - the user data
138 /// \~english @retval 0  Success
139 /// \~english @retval -1 Error
140 /// \~english @par Prerequisite
141 ///     None
142 /// \~english @par Change of internal state
143 ///     None
144 /// \~english @par Conditions of processing failure
145 ///     None
146 /// \~english @par Classification
147 ///     Public
148 /// \~english @par Type
149 ///     Sync
150 /// \~english @par Detail
151 ///     None
152 /// \~english @see None
153 ////////////////////////////////////////////////////////////////////////////////////
154 int CL_MonitorSetEntry(CL_MonitorType_t type, uint32_t id,  // NOLINT(readability/nolint)
155                        CL_MonitorState_t state, uint32_t timeout,
156                        uint32_t user_data);
157
158
159 /////////////////////////////////////////////////////////////////////////////////////
160 /// \ingroup Monitor
161 /// \~english @par Brief
162 ///     Get Monitor Entry
163 /// \~english @param [in] type
164 ///     CL_MonitorType_t - the type of monitor
165 /// \~english @param [in] id
166 ///     uint32_t - the monitor id
167 /// \~english @param [out] entry
168 ///     CL_MonitorEntry_t* - the pointer to monitor entry
169 /// \~english @retval 0  Success
170 /// \~english @retval -1 Error
171 /// \~english @par Prerequisite
172 ///     None
173 /// \~english @par Change of internal state
174 ///     None
175 /// \~english @par Conditions of processing failure
176 ///     None
177 /// \~english @par Classification
178 ///     Public
179 /// \~english @par Type
180 ///     Sync
181 /// \~english @par Detail
182 ///     None
183 /// \~english @see None
184 ////////////////////////////////////////////////////////////////////////////////////
185 int CL_MonitorGetEntry(CL_MonitorType_t type, uint32_t id, CL_MonitorEntry_t *entry);  // NOLINT(readability/nolint)
186
187
188 /////////////////////////////////////////////////////////////////////////////////////
189 /// \ingroup Monitor
190 /// \~english @par Brief
191 ///     Monitor searth intialize
192 /// \~english @param [in] serch
193 ///     CL_MonitorSearch_t* - the pointor to monitory search
194 /// \~english @retval 0  Success
195 /// \~english @retval -1 Error
196 /// \~english @par Prerequisite
197 ///     None
198 /// \~english @par Change of internal state
199 ///     None
200 /// \~english @par Conditions of processing failure
201 ///     None
202 /// \~english @par Classification
203 ///     Public
204 /// \~english @par Type
205 ///     Sync
206 /// \~english @par Detail
207 ///     None
208 /// \~english @see None
209 ////////////////////////////////////////////////////////////////////////////////////
210 int CL_MonitorSearchInit(CL_MonitorSearch_t *serch);  // NOLINT(readability/nolint)
211
212
213 /////////////////////////////////////////////////////////////////////////////////////
214 /// \ingroup Monitor
215 /// \~english @par Brief
216 ///     Monitor searth destroy
217 /// \~english @param [in] serch
218 ///     CL_MonitorSearch_t* - the pointor to monitory search
219 /// \~english @retval 0  Success
220 /// \~english @retval -1 Error
221 /// \~english @par Prerequisite
222 ///     None
223 /// \~english @par Change of internal state
224 ///     None
225 /// \~english @par Conditions of processing failure
226 ///     None
227 /// \~english @par Classification
228 ///     Public
229 /// \~english @par Type
230 ///     Sync
231 /// \~english @par Detail
232 ///     None
233 /// \~english @see None
234 ////////////////////////////////////////////////////////////////////////////////////
235 int CL_MonitorSearchDestroy(CL_MonitorSearch_t *serch);  // NOLINT(readability/nolint)
236
237
238 /////////////////////////////////////////////////////////////////////////////////////
239 /// \ingroup Monitor
240 /// \~english @par Brief
241 ///     Monitor searth timeout
242 /// \~english @param [in] serch
243 ///     CL_MonitorSearch_t* - the pointor to monitory search
244 /// \~english @retval 0  Success
245 /// \~english @retval -1 Error
246 /// \~english @par Prerequisite
247 ///     None
248 /// \~english @par Change of internal state
249 ///     None
250 /// \~english @par Conditions of processing failure
251 ///     None
252 /// \~english @par Classification
253 ///     Public
254 /// \~english @par Type
255 ///     Sync
256 /// \~english @par Detail
257 ///     None
258 /// \~english @see None
259 ////////////////////////////////////////////////////////////////////////////////////
260 int CL_MonitorSearchTimeout(CL_MonitorSearch_t *search);  // NOLINT(readability/nolint)
261
262 /** @}*/  // end of common_library
263 /** @}*/  // end of NativeService
264 /** @}*/  // end of BaseSystem
265 #ifdef __cplusplus
266 }
267 #endif
268
269 #endif /* ifndef _cl_monitor_h_ */  // NOLINT(build/header_guard)