EPICS Base  7.0.7.0
 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 typedef struct evSubscrip {
45  ELLNODE node;
46  struct dbChannel * chan;
47  EVENTFUNC * user_sub;
48  void * user_arg;
49  struct event_que * ev_que;
50  db_field_log ** pLastLog;
51  unsigned long npend;
52  unsigned long nreplace;
53  unsigned char select;
54  char useValque;
55  char callBackInProgress;
56  char enabled;
57 } evSubscrip;
58 
59 typedef struct chFilter chFilter;
60 
69 typedef struct dbChannel {
70  const char *name;
74  short final_type;
78 } dbChannel;
79 
93 typedef db_field_log* (chPostEventFunc)(void *pvt, dbChannel *chan, db_field_log *pLog);
94 
100 typedef enum {
101  parse_stop, parse_continue
102 } parse_result;
103 
108 typedef struct chFilterIf {
115  void (* priv_free)(void *puser);
116 
135 
142  void (* parse_abort)(chFilter *filter);
143 
153 
162 
170  parse_result (* parse_boolean)(chFilter *filter, int boolVal);
171 
179  parse_result (* parse_integer)(chFilter *filter, long integerVal);
180 
188  parse_result (* parse_double)(chFilter *filter, double doubleVal);
189 
198  parse_result (* parse_string)(chFilter *filter, const char *stringVal,
199  size_t stringLen);
200 
209 
218  parse_result (* parse_map_key)(chFilter *filter, const char *key,
219  size_t stringLen);
220 
228 
237 
245 
254  long (* channel_open)(chFilter *filter);
255 
265  void (* channel_register_pre) (chFilter *filter,
266  chPostEventFunc **cb_out, void **arg_out, db_field_log *probe);
267 
276  void (* channel_register_post)(chFilter *filter,
277  chPostEventFunc **cb_out, void **arg_out, db_field_log *probe);
278 
286  void (* channel_report)(chFilter *filter,
287  int level, const unsigned short indent);
288 
294  void (* channel_close)(chFilter *filter);
295 } chFilterIf;
296 
301 typedef struct chFilterPlugin {
303  const char *name;
304  const chFilterIf *fif;
305  void *puser;
307 
312 struct chFilter {
319  void *pre_arg;
321  void *post_arg;
322  void *puser;
323 };
324 
325 struct dbCommon;
326 struct dbFldDes;
327 
329 DBCORE_API void dbChannelInit(void);
330 
332 DBCORE_API void dbChannelExit(void);
333 
344 DBCORE_API long dbChannelTest(const char *name);
345 
351 DBCORE_API dbChannel * dbChannelCreate(const char *name);
352 
358 DBCORE_API long dbChannelOpen(dbChannel *chan);
359 
365 DBCORE_API extern unsigned short dbDBRnewToDBRold[];
366 
374 #define dbChannelName(pChan) ((pChan)->name)
375 
381 #define dbChannelRecord(pChan) ((pChan)->addr.precord)
382 
388 #define dbChannelFldDes(pChan) ((pChan)->addr.pfldDes)
389 
395 #define dbChannelElements(pChan) ((pChan)->addr.no_elements)
396 
402 #define dbChannelFieldType(pChan) ((pChan)->addr.field_type)
403 
409 #define dbChannelExportType(pChan) ((pChan)->addr.dbr_field_type)
410 
416 #define dbChannelExportCAType(pChan) (dbDBRnewToDBRold[dbChannelExportType(pChan)])
417 
423 #define dbChannelFieldSize(pChan) ((pChan)->addr.field_size)
424 
430 #define dbChannelFinalElements(pChan) ((pChan)->final_no_elements)
431 
437 #define dbChannelFinalFieldType(pChan) ((pChan)->final_type)
438 
444 #define dbChannelFinalCAType(pChan) (dbDBRnewToDBRold[(pChan)->final_type])
445 
450 #define dbChannelFinalFieldSize(pChan) ((pChan)->final_field_size)
451 
457 #define dbChannelSpecial(pChan) ((pChan)->addr.special)
458 
467 #define dbChannelField(pChan) ((pChan)->addr.pfield)
468 
469 
484 DBCORE_API long dbChannelGet(dbChannel *chan, short type,
485  void *pbuffer, long *options, long *nRequest, void *pfl);
486 
500 DBCORE_API long dbChannelGetField(dbChannel *chan, short type,
501  void *pbuffer, long *options, long *nRequest, void *pfl);
502 
514 DBCORE_API long dbChannelPut(dbChannel *chan, short type,
515  const void *pbuffer, long nRequest);
516 
527 DBCORE_API long dbChannelPutField(dbChannel *chan, short type,
528  const void *pbuffer, long nRequest);
529 
537 DBCORE_API void dbChannelShow(dbChannel *chan, int level,
538  const unsigned short indent);
539 
547 DBCORE_API void dbChannelFilterShow(dbChannel *chan, int level,
548  const unsigned short indent);
549 
555 DBCORE_API void dbChannelDelete(dbChannel *chan);
556 
557 
560 DBCORE_API void dbRegisterFilter(const char *key,
561  const chFilterIf *fif, void *puser);
562 DBCORE_API db_field_log* dbChannelRunPreChain(dbChannel *chan,
563  db_field_log *pLogIn);
564 DBCORE_API db_field_log* dbChannelRunPostChain(dbChannel *chan,
565  db_field_log *pLogIn);
566 DBCORE_API const chFilterPlugin * dbFindFilter(const char *key, size_t len);
567 DBCORE_API void dbChannelGetArrayInfo(dbChannel *chan,
568  void **pfield, long *no_elements, long *offset);
569 
570 #ifdef __cplusplus
571 }
572 #endif
573 
574 #endif /* INC_dbChannel_H */
DBCORE_API unsigned short dbDBRnewToDBRold[]
Request (DBR) type conversion array.
short final_field_size
Definition: dbChannel.h:73
short final_type
Definition: dbChannel.h:74
Channel Filter Interface.
Definition: dbChannel.h:108
parse_result(* parse_map_key)(chFilter *filter, const char *key, size_t stringLen)
Parser saw a JSON map key.
Definition: dbChannel.h:218
parse_result(* parse_double)(chFilter *filter, double doubleVal)
Parser saw double value.
Definition: dbChannel.h:188
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:69
void(* channel_register_pre)(chFilter *filter, chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)
Get pre-chain filter function.
Definition: dbChannel.h:265
void(* parse_abort)(chFilter *filter)
Parsing of filter instance is being cancelled.
Definition: dbChannel.h:142
unsigned long nreplace
Definition: dbChannel.h:52
parse_result(* parse_end)(chFilter *filter)
Parsing of filter instance has completed successfully.
Definition: dbChannel.h:152
dbChannel * chan
The dbChannel we belong to.
Definition: dbChannel.h:316
List node type.
Definition: ellLib.h:46
The core data types used by epics.
chPostEventFunc * post_func
post-chain filter function
Definition: dbChannel.h:320
void * puser
For use by the plugin.
Definition: dbChannel.h:322
ELLLIST filters
Definition: dbChannel.h:75
parse_result(* parse_end_array)(chFilter *filter)
Parser saw end of a JSON array value.
Definition: dbChannel.h:244
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:208
const char * name
Filter name.
Definition: dbChannel.h:303
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:115
Filter instance data.
Definition: dbChannel.h:312
Definition: dbAddr.h:17
ELLLIST pre_chain
Definition: dbChannel.h:76
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:286
DBCORE_API long dbChannelPut(dbChannel *chan, short type, const void *pbuffer, long nRequest)
dbPut() through a dbChannel.
long final_no_elements
Definition: dbChannel.h:72
A doubly-linked list library.
ELLLIST post_chain
Definition: dbChannel.h:77
void * post_arg
post-chain context pointer
Definition: dbChannel.h:321
void(* channel_register_post)(chFilter *filter, chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)
Get post-chain filter function.
Definition: dbChannel.h:276
void * puser
For use by the plugin.
Definition: dbChannel.h:305
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:134
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:318
void * pre_arg
pre-chain context pointer
Definition: dbChannel.h:319
DBCORE_API void dbChannelDelete(dbChannel *chan)
Delete a channel.
ELLNODE pre_node
List node (dbChannel->pre_chain)
Definition: dbChannel.h:314
parse_result(* parse_end_map)(chFilter *filter)
Parser saw end of a JSON map value.
Definition: dbChannel.h:227
const char * name
Definition: dbChannel.h:70
parse_result(* parse_integer)(chFilter *filter, long integerVal)
Parser saw integer value.
Definition: dbChannel.h:179
parse_result(* parse_null)(chFilter *filter)
Parser saw null value.
Definition: dbChannel.h:161
parse_result
Result returned by chFilterIf parse routines.
Definition: dbChannel.h:100
const chFilterPlugin * plug
The plugin that created us.
Definition: dbChannel.h:317
ELLNODE post_node
List node (dbChannel->post_chain)
Definition: dbChannel.h:315
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:313
long(* channel_open)(chFilter *filter)
Open filter on channel.
Definition: dbChannel.h:254
ELLNODE node
List node (dbBase->filterList)
Definition: dbChannel.h:302
Filter plugin data.
Definition: dbChannel.h:301
DBCORE_API void dbChannelExit(void)
Cleanup the dbChannel subsystem.
dbAddr addr
Definition: dbChannel.h:71
unsigned long npend
Definition: dbChannel.h:51
db_field_log *( chPostEventFunc)(void *pvt, dbChannel *chan, db_field_log *pLog)
Event filter function type.
Definition: dbChannel.h:93
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:304
Miscellaneous macro definitions.
parse_result(* parse_boolean)(chFilter *filter, int boolVal)
Parser saw boolean value.
Definition: dbChannel.h:170
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:236
void(* channel_close)(chFilter *filter)
Close filter.
Definition: dbChannel.h:294
parse_result(* parse_string)(chFilter *filter, const char *stringVal, size_t stringLen)
Parser saw string value.
Definition: dbChannel.h:198