pdserv  3.0
Process data server
pdserv.h
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * $Id$
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 #include <time.h>
36 
54 #define PDSERV_VERSION(major,minor,patchlevel) \
55  (((major) << 16) + ((minor) << 8) + (patchlevel))
56 #define PDSERV_VERSION_CODE \
57  PDSERV_VERSION(3,0,0)
58 #define PDSERV_VERSION_MAJOR 3
59 #define PDSERV_VERSION_MINOR 0
60 #define PDSERV_VERSION_PATCH 0
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
72 #define HAS_VERSION_CODE
73 extern const char* pdserv_version_str;
74 
75 /* Data type definitions. */
150 /* Let the enumeration start at 1 so that an unset data type could be
151  * detected.*/
152 #define pd_double_T 1
153 #define pd_single_T 2
154 #define pd_uint8_T 3
155 #define pd_sint8_T 4
156 #define pd_uint16_T 5
157 #define pd_sint16_T 6
158 #define pd_uint32_T 7
159 #define pd_sint32_T 8
160 #define pd_uint64_T 9
161 #define pd_sint64_T 10
162 #define pd_boolean_T 11
163 #define pd_schar_T 12
164 #define pd_char_T 13
165 #define pd_uchar_T 14
166 #define pd_short_T 15
167 #define pd_ushort_T 16
168 #define pd_int_T 17
169 #define pd_uint_T 18
170 #define pd_long_T 19
171 #define pd_ulong_T 20
172 #define pd_longlong_T 21
173 #define pd_ulonglong_T 22
174 #define pd_ssize_T 23
175 #define pd_size_T 24
176 
177 #define pd_datatype_end 25
178 
180 /* Structure declarations.
181  */
182 struct pdserv;
183 struct pdtask;
184 struct pdvariable;
185 struct pdevent;
188 typedef int (*gettime_t)(struct timespec*);
189 
199 struct pdserv* pdserv_create(
200  const char *name,
201  const char *version,
202  gettime_t gettime_cb
207  );
208 
220 void pdserv_config_file(
221  struct pdserv* pdserv,
222  const char *file
223  );
224 
234 struct pdtask* pdserv_create_task(
235  struct pdserv* pdserv,
236  double tsample,
237  const char *name
238  );
239 
249  const char *name,
250  size_t size
251  );
252 
256  int compound,
257  const char *name,
258  int data_type,
262  size_t offset,
263  size_t ndim,
264  const size_t *dim
265  );
266 
293 struct pdvariable *pdserv_signal(
294  struct pdtask* pdtask,
295  unsigned int decimation,
297  const char *path,
298  int datatype,
302  const void *addr,
303  size_t n,
306  const size_t *dim
308  );
309 
335 typedef int (*read_signal_t)(
336  const struct pdvariable *signal,
337  void *dst,
338  const void *src,
339  size_t len,
340  struct timespec* time,
341  void *priv_data
342  );
343 
349  struct pdvariable* signal,
350  read_signal_t read_signal_cb,
351  void* priv_data
353  );
354 
361 struct pdvariable *pdserv_signal_cb(
362  struct pdtask* pdtask,
363  unsigned int decimation,
365  const char *path,
366  int datatype,
367  const void *addr,
368  size_t n,
369  const size_t *dim,
370  read_signal_t read_signal_cb,
371  void* priv_data
373  );
374 
403 #define RESET_EVENT 0
404 #define EMERG_EVENT 1
405 #define ALERT_EVENT 2
406 #define CRIT_EVENT 3
407 #define ERROR_EVENT 4
408 #define WARN_EVENT 5
409 #define NOTICE_EVENT 6
410 #define INFO_EVENT 7
411 #define DEBUG_EVENT 8
412 
420 struct pdevent *pdserv_event(
421  struct pdserv* pdserv,
422  const char *path,
423  size_t n
424  );
425 
429  struct pdevent* event,
430  const char * const *text
435  );
436 
437 
443 void pdserv_event_set(
444  const struct pdevent *event,
445  size_t element,
446  int priority,
456  const struct timespec *t
457  );
458 
464 void pdserv_event_reset(
465  const struct pdevent *event,
466  size_t element,
467  const struct timespec *t
468  );
469 
484  const struct pdevent *event,
485  const unsigned int * level,
499  const struct timespec *t
500  );
501 
526 typedef int (*write_parameter_t)(
527  const struct pdvariable *param,
528  void *dst,
529  const void *src,
530  size_t len,
531  struct timespec* time,
532  void *priv_data
533  );
534 
552 struct pdvariable *pdserv_parameter(
553  struct pdserv* pdserv,
554  const char *path,
555  unsigned int mode,
556  int datatype,
560  void *addr,
561  size_t n,
564  const size_t *dim,
566  write_parameter_t write_cb,
568  void *priv_data
570  );
571 
578 void pdserv_set_alias(
579  struct pdvariable *variable,
580  const char *alias
581  );
582 
584 void pdserv_set_unit(
585  struct pdvariable *variable,
586  const char *unit
587  );
588 
590 void pdserv_set_comment(
591  struct pdvariable *variable,
592  const char *comment
593  );
594 
606 int pdserv_prepare(
607  struct pdserv* pdserv
608  );
609 
616  struct pdtask* pdtask,
617  double exec_time,
618  double cycle_time,
619  unsigned int overrun
620  );
621 
627 void pdserv_update(
628  struct pdtask* pdtask,
629  const struct timespec *t
631  );
632 
634 void pdserv_exit(
635  struct pdserv*
636  );
637 
638 #ifdef __cplusplus
639 }
640 #endif /* __cplusplus */
641 
642 #endif /* PDSERV_H */
int(* gettime_t)(struct timespec *)
Definition: pdserv.h:188
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 * 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)
struct pdvariable * pdserv_signal_cb(struct pdtask *pdtask, unsigned int decimation, const char *path, int datatype, const void *addr, size_t n, const size_t *dim, read_signal_t read_signal_cb, void *priv_data)
void pdserv_set_unit(struct pdvariable *variable, const char *unit)
void pdserv_signal_set_read_cb(struct pdvariable *signal, read_signal_t read_signal_cb, void *priv_data)
void pdserv_set_alias(struct pdvariable *variable, const char *alias)
void pdserv_set_comment(struct pdvariable *variable, const char *comment)
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)
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:526
void pdserv_event_set_text(struct pdevent *event, const char *const *text)
void pdserv_config_file(struct pdserv *pdserv, const char *file)
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)
int(* read_signal_t)(const struct pdvariable *signal, void *dst, const void *src, size_t len, struct timespec *time, void *priv_data)
Definition: pdserv.h:335
struct pdserv * pdserv_create(const char *name, const char *version, gettime_t gettime_cb)