EPICS Base  7.0.8.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dbChannel.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2010 Brookhaven National Laboratory.
5 * Copyright (c) 2010 Helmholtz-Zentrum Berlin
6 * fuer Materialien und Energie GmbH.
7 * SPDX-License-Identifier: EPICS
8 * EPICS BASE is distributed subject to a Software License Agreement found
9 * in file LICENSE that is included with this distribution.
10 \*************************************************************************/
11 
12 #ifndef INC_dbChannel_H
13 #define INC_dbChannel_H
14 
28 #include "dbDefs.h"
29 #include "dbAddr.h"
30 #include "ellLib.h"
31 #include "epicsTypes.h"
32 #include "errMdef.h"
33 #include "db_field_log.h"
34 #include "dbEvent.h"
35 #include "dbCoreAPI.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
44 struct evSubscrip;
45 
46 typedef struct evSubscrip evSubscrip;
47 
48 #ifdef EPICS_PRIVATE_API
49 struct evSubscrip {
50  ELLNODE node;
51  struct dbChannel * chan;
52  /* user_sub==NULL used to indicate db_cancel_event() */
53  EVENTFUNC * user_sub;
54  void * user_arg;
55  /* associated queue, may be shared with other evSubscrip */
56  struct event_que * ev_que;
57  /* NULL if !npend. if npend!=0, pointer to last event added to event_que::valque */
58  db_field_log ** pLastLog;
59  /* n times this event is on the queue */
60  unsigned long npend;
61  /* n times replacing event on the queue */
62  unsigned long nreplace;
63  /* DBE mask */
64  unsigned char select;
65  /* if set, subscription will yield dbfl_type_val */
66  char useValque;
67  /* event_task is handling this subscription */
68  char callBackInProgress;
69  /* this node added to dbCommon::mlis */
70  char enabled;
71 };
72 #endif
73 
74 typedef struct chFilter chFilter;
75 
84 typedef struct dbChannel {
85  const char *name;
89  short final_type;
93 } dbChannel;
94 
108 typedef db_field_log* (chPostEventFunc)(void *pvt, dbChannel *chan, db_field_log *pLog);
109 
115 typedef enum {
116  parse_stop, parse_continue
117 } parse_result;
118 
123 typedef struct chFilterIf {
130  void (* priv_free)(void *puser);
131 
150 
157  void (* parse_abort)(chFilter *filter);
158 
168 
177 
185  parse_result (* parse_boolean)(chFilter *filter, int boolVal);
186 
194  parse_result (* parse_integer)(chFilter *filter, long integerVal);
195 
203  parse_result (* parse_double)(chFilter *filter, double doubleVal);
204 
213  parse_result (* parse_string)(chFilter *filter, const char *stringVal,
214  size_t stringLen);
215 
224 
233  parse_result (* parse_map_key)(chFilter *filter, const char *key,
234  size_t stringLen);
235 
243 
252 
260 
269  long (* channel_open)(chFilter *filter);
270 
280  void (* channel_register_pre) (chFilter *filter,
281  chPostEventFunc **cb_out, void **arg_out, db_field_log *probe);
282 
291  void (* channel_register_post)(chFilter *filter,
292  chPostEventFunc **cb_out, void **arg_out, db_field_log *probe);
293 
301  void (* channel_report)(chFilter *filter,
302  int level, const unsigned short indent);
303 
309  void (* channel_close)(chFilter *filter);
310 } chFilterIf;
311 
316 typedef struct chFilterPlugin {
318  const char *name;
319  const chFilterIf *fif;
320  void *puser;
322 
327 struct chFilter {
334  void *pre_arg;
336  void *post_arg;
337  void *puser;
338 };
339 
340 struct dbCommon;
341 struct dbFldDes;
342 
344 DBCORE_API void dbChannelInit(void);
345 
347 DBCORE_API void dbChannelExit(void);
348 
359 DBCORE_API long dbChannelTest(const char *name);
360 
366 DBCORE_API dbChannel * dbChannelCreate(const char *name);
367 
373 DBCORE_API long dbChannelOpen(dbChannel *chan);
374 
380 DBCORE_API extern unsigned short dbDBRnewToDBRold[];
381 
389 #define dbChannelName(pChan) ((pChan)->name)
390 
396 #define dbChannelRecord(pChan) ((pChan)->addr.precord)
397 
403 #define dbChannelFldDes(pChan) ((pChan)->addr.pfldDes)
404 
410 #define dbChannelElements(pChan) ((pChan)->addr.no_elements)
411 
417 #define dbChannelFieldType(pChan) ((pChan)->addr.field_type)
418 
424 #define dbChannelExportType(pChan) ((pChan)->addr.dbr_field_type)
425 
431 #define dbChannelExportCAType(pChan) (dbDBRnewToDBRold[dbChannelExportType(pChan)])
432 
438 #define dbChannelFieldSize(pChan) ((pChan)->addr.field_size)
439 
445 #define dbChannelFinalElements(pChan) ((pChan)->final_no_elements)
446 
452 #define dbChannelFinalFieldType(pChan) ((pChan)->final_type)
453 
459 #define dbChannelFinalCAType(pChan) (dbDBRnewToDBRold[(pChan)->final_type])
460 
465 #define dbChannelFinalFieldSize(pChan) ((pChan)->final_field_size)
466 
472 #define dbChannelSpecial(pChan) ((pChan)->addr.special)
473 
482 #define dbChannelField(pChan) ((pChan)->addr.pfield)
483 
484 
499 DBCORE_API long dbChannelGet(dbChannel *chan, short type,
500  void *pbuffer, long *options, long *nRequest, void *pfl);
501 
515 DBCORE_API long dbChannelGetField(dbChannel *chan, short type,
516  void *pbuffer, long *options, long *nRequest, void *pfl);
517 
529 DBCORE_API long dbChannelPut(dbChannel *chan, short type,
530  const void *pbuffer, long nRequest);
531 
542 DBCORE_API long dbChannelPutField(dbChannel *chan, short type,
543  const void *pbuffer, long nRequest);
544 
552 DBCORE_API void dbChannelShow(dbChannel *chan, int level,
553  const unsigned short indent);
554 
562 DBCORE_API void dbChannelFilterShow(dbChannel *chan, int level,
563  const unsigned short indent);
564 
570 DBCORE_API void dbChannelDelete(dbChannel *chan);
571 
572 
575 DBCORE_API void dbRegisterFilter(const char *key,
576  const chFilterIf *fif, void *puser);
577 DBCORE_API db_field_log* dbChannelRunPreChain(dbChannel *chan,
578  db_field_log *pLogIn);
579 DBCORE_API db_field_log* dbChannelRunPostChain(dbChannel *chan,
580  db_field_log *pLogIn);
581 DBCORE_API const chFilterPlugin * dbFindFilter(const char *key, size_t len);
582 DBCORE_API void dbChannelGetArrayInfo(dbChannel *chan,
583  void **pfield, long *no_elements, long *offset);
584 
585 #ifdef __cplusplus
586 }
587 #endif
588 
589 #endif /* INC_dbChannel_H */
DBCORE_API unsigned short dbDBRnewToDBRold[]
Request (DBR) type conversion array.
short final_field_size
Definition: dbChannel.h:88
short final_type
Definition: dbChannel.h:89
Channel Filter Interface.
Definition: dbChannel.h:123
parse_result(* parse_map_key)(chFilter *filter, const char *key, size_t stringLen)
Parser saw a JSON map key.
Definition: dbChannel.h:233
parse_result(* parse_double)(chFilter *filter, double doubleVal)
Parser saw double value.
Definition: dbChannel.h:203
DBCORE_API long dbChannelGet(dbChannel *chan, short type, void *pbuffer, long *options, long *nRequest, void *pfl)
dbGet() through a dbChannel.
A Database Channel object.
Definition: dbChannel.h:84
void(* channel_register_pre)(chFilter *filter, chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)
Get pre-chain filter function.
Definition: dbChannel.h:280
void(* parse_abort)(chFilter *filter)
Parsing of filter instance is being cancelled.
Definition: dbChannel.h:157
parse_result(* parse_end)(chFilter *filter)
Parsing of filter instance has completed successfully.
Definition: dbChannel.h:167
dbChannel * chan
The dbChannel we belong to.
Definition: dbChannel.h:331
List node type.
Definition: ellLib.h:46
The core data types used by epics.
chPostEventFunc * post_func
post-chain filter function
Definition: dbChannel.h:335
void * puser
For use by the plugin.
Definition: dbChannel.h:337
ELLLIST filters
Definition: dbChannel.h:90
parse_result(* parse_end_array)(chFilter *filter)
Parser saw end of a JSON array value.
Definition: dbChannel.h:259
DBCORE_API long dbChannelTest(const char *name)
Test the given PV name for existance.
parse_result(* parse_start_map)(chFilter *filter)
Parser saw start of a JSON map value.
Definition: dbChannel.h:223
const char * name
Filter name.
Definition: dbChannel.h:318
Declaration of dbCommon.
Definition: dbCommon.h:18
DBCORE_API long dbChannelOpen(dbChannel *chan)
Open a dbChannel for doing I/O.
void(* priv_free)(void *puser)
Release private filter data.
Definition: dbChannel.h:130
Filter instance data.
Definition: dbChannel.h:327
Definition: dbAddr.h:17
ELLLIST pre_chain
Definition: dbChannel.h:91
DBCORE_API long dbChannelGetField(dbChannel *chan, short type, void *pbuffer, long *options, long *nRequest, void *pfl)
dbGetField() through a dbChannel.
void(* channel_report)(chFilter *filter, int level, const unsigned short indent)
Print information about filter to stdout.
Definition: dbChannel.h:301
DBCORE_API long dbChannelPut(dbChannel *chan, short type, const void *pbuffer, long nRequest)
dbPut() through a dbChannel.
long final_no_elements
Definition: dbChannel.h:87
A doubly-linked list library.
ELLLIST post_chain
Definition: dbChannel.h:92
void * post_arg
post-chain context pointer
Definition: dbChannel.h:336
void(* channel_register_post)(chFilter *filter, chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)
Get post-chain filter function.
Definition: dbChannel.h:291
void * puser
For use by the plugin.
Definition: dbChannel.h:320
DBCORE_API long dbChannelPutField(dbChannel *chan, short type, const void *pbuffer, long nRequest)
dbPutField() through a dbChannel.
parse_result(* parse_start)(chFilter *filter)
Create new filter instance.
Definition: dbChannel.h:149
List header type.
Definition: ellLib.h:57
DBCORE_API void dbChannelInit(void)
Initialize the dbChannel subsystem.
chPostEventFunc * pre_func
pre-chain filter function
Definition: dbChannel.h:333
void * pre_arg
pre-chain context pointer
Definition: dbChannel.h:334
DBCORE_API void dbChannelDelete(dbChannel *chan)
Delete a channel.
ELLNODE pre_node
List node (dbChannel->pre_chain)
Definition: dbChannel.h:329
parse_result(* parse_end_map)(chFilter *filter)
Parser saw end of a JSON map value.
Definition: dbChannel.h:242
const char * name
Definition: dbChannel.h:85
parse_result(* parse_integer)(chFilter *filter, long integerVal)
Parser saw integer value.
Definition: dbChannel.h:194
parse_result(* parse_null)(chFilter *filter)
Parser saw null value.
Definition: dbChannel.h:176
parse_result
Result returned by chFilterIf parse routines.
Definition: dbChannel.h:115
const chFilterPlugin * plug
The plugin that created us.
Definition: dbChannel.h:332
ELLNODE post_node
List node (dbChannel->post_chain)
Definition: dbChannel.h:330
DBCORE_API void dbChannelShow(dbChannel *chan, int level, const unsigned short indent)
Print report on a channel.
ELLNODE list_node
List node (dbChannel->filters)
Definition: dbChannel.h:328
long(* channel_open)(chFilter *filter)
Open filter on channel.
Definition: dbChannel.h:269
ELLNODE node
List node (dbBase->filterList)
Definition: dbChannel.h:317
Filter plugin data.
Definition: dbChannel.h:316
DBCORE_API void dbChannelExit(void)
Cleanup the dbChannel subsystem.
dbAddr addr
Definition: dbChannel.h:86
db_field_log *( chPostEventFunc)(void *pvt, dbChannel *chan, db_field_log *pLog)
Event filter function type.
Definition: dbChannel.h:108
DBCORE_API void dbChannelFilterShow(dbChannel *chan, int level, const unsigned short indent)
Print report on a channel's filters.
const chFilterIf * fif
Filter interface routines.
Definition: dbChannel.h:319
Miscellaneous macro definitions.
parse_result(* parse_boolean)(chFilter *filter, int boolVal)
Parser saw boolean value.
Definition: dbChannel.h:185
DBCORE_API dbChannel * dbChannelCreate(const char *name)
Create a dbChannel object for the given PV name.
parse_result(* parse_start_array)(chFilter *filter)
Parser saw start of a JSON array value.
Definition: dbChannel.h:251
void(* channel_close)(chFilter *filter)
Close filter.
Definition: dbChannel.h:309
parse_result(* parse_string)(chFilter *filter, const char *stringVal, size_t stringLen)
Parser saw string value.
Definition: dbChannel.h:213