pdserv  3.3
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 
36 
37 #ifdef pdserv_EXPORTS
38 # define PDSERV_EXPORT __attribute__((__visibility__("default")))
39 #else
40 # define PDSERV_EXPORT
41 #endif
42 
43 
61 #define PDSERV_VERSION(major,minor,patchlevel) \
62  (((major) << 16) + ((minor) << 8) + (patchlevel))
63 #define PDSERV_VERSION_CODE \
64  PDSERV_VERSION(3,3,1)
65 #define PDSERV_VERSION_MAJOR 3
66 #define PDSERV_VERSION_MINOR 3
67 #define PDSERV_VERSION_PATCH 1
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
82 #define HAS_VERSION_CODE
83 PDSERV_EXPORT extern const char* const pdserv_version_str;
84 PDSERV_EXPORT extern const char* const pdserv_full_version;
85 
86 /* Data type definitions. */
161 /* Let the enumeration start at 1 so that an unset data type could be
162  * detected.*/
163 #define pd_double_T 1
164 #define pd_single_T 2
165 #define pd_uint8_T 3
166 #define pd_sint8_T 4
167 #define pd_uint16_T 5
168 #define pd_sint16_T 6
169 #define pd_uint32_T 7
170 #define pd_sint32_T 8
171 #define pd_uint64_T 9
172 #define pd_sint64_T 10
173 #define pd_boolean_T 11
174 #define pd_schar_T 12
175 #define pd_char_T 13
176 #define pd_uchar_T 14
177 #define pd_short_T 15
178 #define pd_ushort_T 16
179 #define pd_int_T 17
180 #define pd_uint_T 18
181 #define pd_long_T 19
182 #define pd_ulong_T 20
183 #define pd_longlong_T 21
184 #define pd_ulonglong_T 22
185 #define pd_ssize_T 23
186 #define pd_size_T 24
187 
188 #define pd_datatype_end 25
189 
190 struct timespec;
191 
194 /* Structure declarations.
195  */
196 struct pdserv;
197 struct pdtask;
198 struct pdvariable;
199 struct pdevent;
203 typedef int (*gettime_t)(struct timespec*);
204 
214 PDSERV_EXPORT struct pdserv* pdserv_create(
215  const char *name,
216  const char *version,
217  gettime_t gettime_cb
222  );
223 
235 PDSERV_EXPORT void pdserv_config_file(
236  struct pdserv* pdserv,
237  const char *file
238  );
239 
250 PDSERV_EXPORT void pdserv_set_parameter_writelock_cb(
251  struct pdserv* pdserv,
252  void (*fn)(int lock, void* priv_data),
253  void* priv_data
254  );
255 
265 PDSERV_EXPORT struct pdtask* pdserv_create_task(
266  struct pdserv* pdserv,
267  double tsample,
268  const char *name
269  );
270 
281 PDSERV_EXPORT void pdserv_set_signal_readlock_cb(
282  struct pdtask* pdtask,
283  void (*fn)(int lock, void* priv_data),
284  void* priv_data
285  );
286 
295 PDSERV_EXPORT int pdserv_create_compound(
296  const char *name,
297  size_t size
298  );
299 
302 PDSERV_EXPORT void pdserv_compound_add_field(
303  int compound,
304  const char *name,
305  int data_type,
309  size_t offset,
310  size_t ndim,
311  const size_t *dim
312  );
313 
340 PDSERV_EXPORT struct pdvariable *pdserv_signal(
341  struct pdtask* pdtask,
342  unsigned int decimation,
344  const char *path,
345  int datatype,
349  const void *addr,
350  size_t n,
353  const size_t *dim
355  );
356 
360 typedef int (*read_signal_t)(const struct pdvariable *signal, void *dst,
361  const void *src, size_t len, struct timespec* time, void *priv_data);
362 
363 PDSERV_EXPORT void pdserv_signal_set_read_cb(struct pdvariable* signal,
364  read_signal_t read_signal_cb, void* priv_data
365  ) __attribute__((deprecated("use pdserv_signal() instead")));
366 
367 PDSERV_EXPORT struct pdvariable *pdserv_signal_cb( struct pdtask* pdtask,
368  unsigned int decimation, const char *path, int datatype,
369  const void *addr, size_t n, const size_t *dim,
370  read_signal_t read_signal_cb, void* priv_data
371  ) __attribute__((deprecated("use pdserv_signal() instead")));;
402 #define RESET_EVENT 0
403 #define EMERG_EVENT 1
404 #define ALERT_EVENT 2
405 #define CRIT_EVENT 3
406 #define ERROR_EVENT 4
407 #define WARN_EVENT 5
408 #define NOTICE_EVENT 6
409 #define INFO_EVENT 7
410 #define DEBUG_EVENT 8
411 
419 PDSERV_EXPORT struct pdevent *pdserv_event(
420  struct pdserv* pdserv,
421  const char *path,
422  size_t n
423  );
424 
427 PDSERV_EXPORT void pdserv_event_set_text(
428  struct pdevent* event,
429  const char * const *text
434  );
435 
436 
442 PDSERV_EXPORT void pdserv_event_set(
443  const struct pdevent *event,
444  size_t element,
445  int priority,
455  const struct timespec *t
456  );
457 
463 PDSERV_EXPORT void pdserv_event_reset(
464  const struct pdevent *event,
465  size_t element,
466  const struct timespec *t
467  );
468 
482 PDSERV_EXPORT void pdserv_event_set_all(
483  const struct pdevent *event,
484  const unsigned int * level,
498  const struct timespec *t
499  );
500 
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 
549 PDSERV_EXPORT struct pdvariable *pdserv_parameter(
550  struct pdserv* pdserv,
551  const char *path,
552  unsigned int mode,
553  int datatype,
557  void *addr,
558  size_t n,
561  const size_t *dim,
563  write_parameter_t write_cb,
565  void *priv_data
567  );
568 
575 PDSERV_EXPORT void pdserv_set_alias(
576  struct pdvariable *variable,
577  const char *alias
578  );
579 
581 PDSERV_EXPORT void pdserv_set_unit(
582  struct pdvariable *variable,
583  const char *unit
584  );
585 
587 PDSERV_EXPORT void pdserv_set_comment(
588  struct pdvariable *variable,
589  const char *comment
590  );
591 
599 PDSERV_EXPORT const char *pdserv_get_variable_path(
600  const struct pdvariable *variable
601  );
602 
616 PDSERV_EXPORT int pdserv_prepare(
617  struct pdserv* pdserv
618  );
619 
625 PDSERV_EXPORT void pdserv_update_statistics(
626  struct pdtask* pdtask,
627  double exec_time,
628  double cycle_time,
629  unsigned int overrun
630  );
631 
637 PDSERV_EXPORT void pdserv_update(
638  struct pdtask* pdtask,
639  const struct timespec *t
641  );
642 
644 PDSERV_EXPORT void pdserv_exit(
645  struct pdserv*
646  );
647 
648 #ifdef __cplusplus
649 }
650 #endif /* __cplusplus */
651 
652 #endif /* PDSERV_H */
int(* gettime_t)(struct timespec *)
Definition: pdserv.h:203
PDSERV_EXPORT const char *const pdserv_version_str
String of pdserv version code "major.minor.patch".
PDSERV_EXPORT void pdserv_compound_add_field(int compound, const char *name, int data_type, size_t offset, size_t ndim, const size_t *dim)
PDSERV_EXPORT void pdserv_event_reset(const struct pdevent *event, size_t element, const struct timespec *t)
PDSERV_EXPORT void pdserv_set_comment(struct pdvariable *variable, const char *comment)
PDSERV_EXPORT void pdserv_event_set_all(const struct pdevent *event, const unsigned int *level, const struct timespec *t)
PDSERV_EXPORT struct pdtask * pdserv_create_task(struct pdserv *pdserv, double tsample, const char *name)
PDSERV_EXPORT void pdserv_config_file(struct pdserv *pdserv, const char *file)
PDSERV_EXPORT 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)
PDSERV_EXPORT void pdserv_update_statistics(struct pdtask *pdtask, double exec_time, double cycle_time, unsigned int overrun)
PDSERV_EXPORT const char *const pdserv_full_version
Full String of pdserv version, generated by git describe.
PDSERV_EXPORT 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)
PDSERV_EXPORT struct pdevent * pdserv_event(struct pdserv *pdserv, const char *path, size_t n)
PDSERV_EXPORT void pdserv_set_signal_readlock_cb(struct pdtask *pdtask, void(*fn)(int lock, void *priv_data), void *priv_data)
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
PDSERV_EXPORT int pdserv_create_compound(const char *name, size_t size)
PDSERV_EXPORT struct pdserv * pdserv_create(const char *name, const char *version, gettime_t gettime_cb)
PDSERV_EXPORT void pdserv_event_set_text(struct pdevent *event, const char *const *text)
PDSERV_EXPORT void pdserv_exit(struct pdserv *)
PDSERV_EXPORT int pdserv_prepare(struct pdserv *pdserv)
PDSERV_EXPORT void pdserv_set_unit(struct pdvariable *variable, const char *unit)
PDSERV_EXPORT void pdserv_update(struct pdtask *pdtask, const struct timespec *t)
PDSERV_EXPORT void pdserv_set_parameter_writelock_cb(struct pdserv *pdserv, void(*fn)(int lock, void *priv_data), void *priv_data)
PDSERV_EXPORT void pdserv_set_alias(struct pdvariable *variable, const char *alias)
PDSERV_EXPORT void pdserv_event_set(const struct pdevent *event, size_t element, int priority, const struct timespec *t)
PDSERV_EXPORT const char * pdserv_get_variable_path(const struct pdvariable *variable)