pdserv  3.1
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 
53 #define PDSERV_VERSION(major,minor,patchlevel) \
54  (((major) << 16) + ((minor) << 8) + (patchlevel))
55 #define PDSERV_VERSION_CODE \
56  PDSERV_VERSION(3,1,1)
57 #define PDSERV_VERSION_MAJOR 3
58 #define PDSERV_VERSION_MINOR 1
59 #define PDSERV_VERSION_PATCH 1
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
71 #define HAS_VERSION_CODE
72 extern const char* pdserv_version_str;
73 
74 /* Data type definitions. */
149 /* Let the enumeration start at 1 so that an unset data type could be
150  * detected.*/
151 #define pd_double_T 1
152 #define pd_single_T 2
153 #define pd_uint8_T 3
154 #define pd_sint8_T 4
155 #define pd_uint16_T 5
156 #define pd_sint16_T 6
157 #define pd_uint32_T 7
158 #define pd_sint32_T 8
159 #define pd_uint64_T 9
160 #define pd_sint64_T 10
161 #define pd_boolean_T 11
162 #define pd_schar_T 12
163 #define pd_char_T 13
164 #define pd_uchar_T 14
165 #define pd_short_T 15
166 #define pd_ushort_T 16
167 #define pd_int_T 17
168 #define pd_uint_T 18
169 #define pd_long_T 19
170 #define pd_ulong_T 20
171 #define pd_longlong_T 21
172 #define pd_ulonglong_T 22
173 #define pd_ssize_T 23
174 #define pd_size_T 24
175 
176 #define pd_datatype_end 25
177 
178 struct timespec;
179 
182 /* Structure declarations.
183  */
184 struct pdserv;
185 struct pdtask;
186 struct pdvariable;
187 struct pdevent;
191 typedef int (*gettime_t)(struct timespec*);
192 
202 struct pdserv* pdserv_create(
203  const char *name,
204  const char *version,
205  gettime_t gettime_cb
210  );
211 
223 void pdserv_config_file(
224  struct pdserv* pdserv,
225  const char *file
226  );
227 
239  struct pdserv* pdserv,
240  void (*fn)(int lock, void* priv_data),
241  void* priv_data
242  );
243 
253 struct pdtask* pdserv_create_task(
254  struct pdserv* pdserv,
255  double tsample,
256  const char *name
257  );
258 
270  struct pdtask* pdtask,
271  void (*fn)(int lock, void* priv_data),
272  void* priv_data
273  );
274 
284  const char *name,
285  size_t size
286  );
287 
291  int compound,
292  const char *name,
293  int data_type,
297  size_t offset,
298  size_t ndim,
299  const size_t *dim
300  );
301 
328 struct pdvariable *pdserv_signal(
329  struct pdtask* pdtask,
330  unsigned int decimation,
332  const char *path,
333  int datatype,
337  const void *addr,
338  size_t n,
341  const size_t *dim
343  );
344 
348 typedef int (*read_signal_t)(const struct pdvariable *signal, void *dst,
349  const void *src, size_t len, struct timespec* time, void *priv_data);
350 
351 void pdserv_signal_set_read_cb(struct pdvariable* signal,
352  read_signal_t read_signal_cb, void* priv_data
353  ) __attribute__((deprecated("use pdserv_signal() instead")));
354 
355 struct pdvariable *pdserv_signal_cb( struct pdtask* pdtask,
356  unsigned int decimation, const char *path, int datatype,
357  const void *addr, size_t n, const size_t *dim,
358  read_signal_t read_signal_cb, void* priv_data
359  ) __attribute__((deprecated("use pdserv_signal() instead")));;
390 #define RESET_EVENT 0
391 #define EMERG_EVENT 1
392 #define ALERT_EVENT 2
393 #define CRIT_EVENT 3
394 #define ERROR_EVENT 4
395 #define WARN_EVENT 5
396 #define NOTICE_EVENT 6
397 #define INFO_EVENT 7
398 #define DEBUG_EVENT 8
399 
407 struct pdevent *pdserv_event(
408  struct pdserv* pdserv,
409  const char *path,
410  size_t n
411  );
412 
416  struct pdevent* event,
417  const char * const *text
422  );
423 
424 
430 void pdserv_event_set(
431  const struct pdevent *event,
432  size_t element,
433  int priority,
443  const struct timespec *t
444  );
445 
451 void pdserv_event_reset(
452  const struct pdevent *event,
453  size_t element,
454  const struct timespec *t
455  );
456 
471  const struct pdevent *event,
472  const unsigned int * level,
486  const struct timespec *t
487  );
488 
514 typedef int (*write_parameter_t)(
515  const struct pdvariable *param,
516  void *dst,
517  const void *src,
518  size_t len,
519  struct timespec* time,
520  void *priv_data
521  );
522 
537 struct pdvariable *pdserv_parameter(
538  struct pdserv* pdserv,
539  const char *path,
540  unsigned int mode,
541  int datatype,
545  void *addr,
546  size_t n,
549  const size_t *dim,
551  write_parameter_t write_cb,
553  void *priv_data
555  );
556 
563 void pdserv_set_alias(
564  struct pdvariable *variable,
565  const char *alias
566  );
567 
569 void pdserv_set_unit(
570  struct pdvariable *variable,
571  const char *unit
572  );
573 
575 void pdserv_set_comment(
576  struct pdvariable *variable,
577  const char *comment
578  );
579 
591 int pdserv_prepare(
592  struct pdserv* pdserv
593  );
594 
601  struct pdtask* pdtask,
602  double exec_time,
603  double cycle_time,
604  unsigned int overrun
605  );
606 
612 void pdserv_update(
613  struct pdtask* pdtask,
614  const struct timespec *t
616  );
617 
619 void pdserv_exit(
620  struct pdserv*
621  );
622 
623 #ifdef __cplusplus
624 }
625 #endif /* __cplusplus */
626 
627 #endif /* PDSERV_H */
int(* gettime_t)(struct timespec *)
Definition: pdserv.h:191
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)
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)
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:514
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)