pdserv  3.2
Process data server
pdserv.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * $Id: pdserv.h,v fa0afd9f0a9e 2015/12/21 10:02:02 lerichi $
4  * vim:ft=c:tw=78
5  *
6  * Copyright 2010 - 2016 Richard Hacker (lerichi at gmx dot net)
7  *
8  * This file is part of the pdserv library.
9  *
10  * The pdserv library is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published
12  * by the Free Software Foundation, either version 3 of the License, or (at
13  * your option) any later version.
14  *
15  * The pdserv library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the pdserv library. If not, see <http://www.gnu.org/licenses/>.
22  *
23  *****************************************************************************/
24 
29 #ifndef PDSERV_H
30 #define PDSERV_H
31 
34 #include <stddef.h>
35 
53 #define PDSERV_VERSION(major,minor,patchlevel) \
54  (((major) << 16) + ((minor) << 8) + (patchlevel))
55 #define PDSERV_VERSION_CODE \
56  PDSERV_VERSION(3,2,3)
57 #define PDSERV_VERSION_MAJOR 3
58 #define PDSERV_VERSION_MINOR 2
59 #define PDSERV_VERSION_PATCH 3
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
74 #define HAS_VERSION_CODE
75 extern const char* const pdserv_version_str;
76 extern const char* const pdserv_full_version;
77 
78 /* Data type definitions. */
153 /* Let the enumeration start at 1 so that an unset data type could be
154  * detected.*/
155 #define pd_double_T 1
156 #define pd_single_T 2
157 #define pd_uint8_T 3
158 #define pd_sint8_T 4
159 #define pd_uint16_T 5
160 #define pd_sint16_T 6
161 #define pd_uint32_T 7
162 #define pd_sint32_T 8
163 #define pd_uint64_T 9
164 #define pd_sint64_T 10
165 #define pd_boolean_T 11
166 #define pd_schar_T 12
167 #define pd_char_T 13
168 #define pd_uchar_T 14
169 #define pd_short_T 15
170 #define pd_ushort_T 16
171 #define pd_int_T 17
172 #define pd_uint_T 18
173 #define pd_long_T 19
174 #define pd_ulong_T 20
175 #define pd_longlong_T 21
176 #define pd_ulonglong_T 22
177 #define pd_ssize_T 23
178 #define pd_size_T 24
179 
180 #define pd_datatype_end 25
181 
182 struct timespec;
183 
186 /* Structure declarations.
187  */
188 struct pdserv;
189 struct pdtask;
190 struct pdvariable;
191 struct pdevent;
195 typedef int (*gettime_t)(struct timespec*);
196 
206 struct pdserv* pdserv_create(
207  const char *name,
208  const char *version,
209  gettime_t gettime_cb
214  );
215 
227 void pdserv_config_file(
228  struct pdserv* pdserv,
229  const char *file
230  );
231 
243  struct pdserv* pdserv,
244  void (*fn)(int lock, void* priv_data),
245  void* priv_data
246  );
247 
257 struct pdtask* pdserv_create_task(
258  struct pdserv* pdserv,
259  double tsample,
260  const char *name
261  );
262 
274  struct pdtask* pdtask,
275  void (*fn)(int lock, void* priv_data),
276  void* priv_data
277  );
278 
288  const char *name,
289  size_t size
290  );
291 
295  int compound,
296  const char *name,
297  int data_type,
301  size_t offset,
302  size_t ndim,
303  const size_t *dim
304  );
305 
332 struct pdvariable *pdserv_signal(
333  struct pdtask* pdtask,
334  unsigned int decimation,
336  const char *path,
337  int datatype,
341  const void *addr,
342  size_t n,
345  const size_t *dim
347  );
348 
352 typedef int (*read_signal_t)(const struct pdvariable *signal, void *dst,
353  const void *src, size_t len, struct timespec* time, void *priv_data);
354 
355 void pdserv_signal_set_read_cb(struct pdvariable* signal,
356  read_signal_t read_signal_cb, void* priv_data
357  ) __attribute__((deprecated("use pdserv_signal() instead")));
358 
359 struct pdvariable *pdserv_signal_cb( struct pdtask* pdtask,
360  unsigned int decimation, const char *path, int datatype,
361  const void *addr, size_t n, const size_t *dim,
362  read_signal_t read_signal_cb, void* priv_data
363  ) __attribute__((deprecated("use pdserv_signal() instead")));;
394 #define RESET_EVENT 0
395 #define EMERG_EVENT 1
396 #define ALERT_EVENT 2
397 #define CRIT_EVENT 3
398 #define ERROR_EVENT 4
399 #define WARN_EVENT 5
400 #define NOTICE_EVENT 6
401 #define INFO_EVENT 7
402 #define DEBUG_EVENT 8
403 
411 struct pdevent *pdserv_event(
412  struct pdserv* pdserv,
413  const char *path,
414  size_t n
415  );
416 
420  struct pdevent* event,
421  const char * const *text
426  );
427 
428 
434 void pdserv_event_set(
435  const struct pdevent *event,
436  size_t element,
437  int priority,
447  const struct timespec *t
448  );
449 
455 void pdserv_event_reset(
456  const struct pdevent *event,
457  size_t element,
458  const struct timespec *t
459  );
460 
475  const struct pdevent *event,
476  const unsigned int * level,
490  const struct timespec *t
491  );
492 
518 typedef int (*write_parameter_t)(
519  const struct pdvariable *param,
520  void *dst,
521  const void *src,
522  size_t len,
523  struct timespec* time,
524  void *priv_data
525  );
526 
541 struct pdvariable *pdserv_parameter(
542  struct pdserv* pdserv,
543  const char *path,
544  unsigned int mode,
545  int datatype,
549  void *addr,
550  size_t n,
553  const size_t *dim,
555  write_parameter_t write_cb,
557  void *priv_data
559  );
560 
567 void pdserv_set_alias(
568  struct pdvariable *variable,
569  const char *alias
570  );
571 
573 void pdserv_set_unit(
574  struct pdvariable *variable,
575  const char *unit
576  );
577 
579 void pdserv_set_comment(
580  struct pdvariable *variable,
581  const char *comment
582  );
583 
595 int pdserv_prepare(
596  struct pdserv* pdserv
597  );
598 
605  struct pdtask* pdtask,
606  double exec_time,
607  double cycle_time,
608  unsigned int overrun
609  );
610 
616 void pdserv_update(
617  struct pdtask* pdtask,
618  const struct timespec *t
620  );
621 
623 void pdserv_exit(
624  struct pdserv*
625  );
626 
627 #ifdef __cplusplus
628 }
629 #endif /* __cplusplus */
630 
631 #endif /* PDSERV_H */
int(* gettime_t)(struct timespec *)
Definition: pdserv.h:195
void pdserv_update_statistics(struct pdtask *pdtask, double exec_time, double cycle_time, unsigned int overrun)
struct pdvariable * pdserv_parameter(struct pdserv *pdserv, const char *path, unsigned int mode, int datatype, void *addr, size_t n, const size_t *dim, write_parameter_t write_cb, void *priv_data)
struct pdtask * pdserv_create_task(struct pdserv *pdserv, double tsample, const char *name)
const char *const pdserv_version_str
String of pdserv version code "major.minor.patch".
void pdserv_event_reset(const struct pdevent *event, size_t element, const struct timespec *t)
void pdserv_exit(struct pdserv *)
int pdserv_prepare(struct pdserv *pdserv)
void pdserv_update(struct pdtask *pdtask, const struct timespec *t)
void pdserv_compound_add_field(int compound, const char *name, int data_type, size_t offset, size_t ndim, const size_t *dim)
void pdserv_set_unit(struct pdvariable *variable, const char *unit)
void pdserv_set_alias(struct pdvariable *variable, const char *alias)
void pdserv_set_comment(struct pdvariable *variable, const char *comment)
const char *const pdserv_full_version
Full String of pdserv version, generated by git describe.
struct pdvariable * pdserv_signal(struct pdtask *pdtask, unsigned int decimation, const char *path, int datatype, const void *addr, size_t n, const size_t *dim)
void pdserv_event_set_all(const struct pdevent *event, const unsigned int *level, const struct timespec *t)
void pdserv_set_signal_readlock_cb(struct pdtask *pdtask, void(*fn)(int lock, void *priv_data), void *priv_data)
int pdserv_create_compound(const char *name, size_t size)
int(* write_parameter_t)(const struct pdvariable *param, void *dst, const void *src, size_t len, struct timespec *time, void *priv_data)
Definition: pdserv.h:518
void pdserv_event_set_text(struct pdevent *event, const char *const *text)
void pdserv_config_file(struct pdserv *pdserv, const char *file)
void pdserv_set_parameter_writelock_cb(struct pdserv *pdserv, void(*fn)(int lock, void *priv_data), void *priv_data)
struct pdevent * pdserv_event(struct pdserv *pdserv, const char *path, size_t n)
void pdserv_event_set(const struct pdevent *event, size_t element, int priority, const struct timespec *t)
struct pdserv * pdserv_create(const char *name, const char *version, gettime_t gettime_cb)