This is Unofficial EPICS BASE Doxygen Site
access.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 
10 /*
11  *
12  * L O S A L A M O S
13  * Los Alamos National Laboratory
14  * Los Alamos, New Mexico 87545
15  *
16  * Copyright, 1986, The Regents of the University of California.
17  *
18  * Author: Jeffrey O. Hill
19  *
20  */
21 
22 #include <new>
23 #include <float.h>
24 
25 #include "dbDefs.h"
26 #include "epicsExit.h"
27 
28 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
29 
30 
31 /*
32  * allocate error message string array
33  * here so I can use sizeof
34  */
35 #define CA_ERROR_GLBLSOURCE
36 
37 /*
38  * allocate header version strings here
39  */
40 #define CAC_VERSION_GLOBAL
41 
42 #include "iocinf.h"
43 #include "oldAccess.h"
44 #include "cac.h"
45 
47 
48 const char * ca_message_text []
49 =
50 {
51 "Normal successful completion",
52 "Maximum simultaneous IOC connections exceeded",
53 "Unknown internet host",
54 "Unknown internet service",
55 "Unable to allocate a new socket",
56 
57 "Unable to connect to internet host or service",
58 "Unable to allocate additional dynamic memory",
59 "Unknown IO channel",
60 "Record field specified inappropriate for channel specified",
61 "The requested data transfer is greater than available memory or EPICS_CA_MAX_ARRAY_BYTES",
62 
63 "User specified timeout on IO operation expired",
64 "Sorry, that feature is planned but not supported at this time",
65 "The supplied string is unusually large",
66 "The request was ignored because the specified channel is disconnected",
67 "The data type specifed is invalid",
68 
69 "Remote Channel not found",
70 "Unable to locate all user specified channels",
71 "Channel Access Internal Failure",
72 "The requested local DB operation failed",
73 "Channel read request failed",
74 
75 "Channel write request failed",
76 "Channel subscription request failed",
77 "Invalid element count requested",
78 "Invalid string",
79 "Virtual circuit disconnect",
80 
81 "Identical process variable names on multiple servers",
82 "Request inappropriate within subscription (monitor) update callback",
83 "Database value get for that channel failed during channel search",
84 "Unable to initialize without the vxWorks VX_FP_TASK task option set",
85 "Event queue overflow has prevented first pass event after event add",
86 
87 "Bad event subscription (monitor) identifier",
88 "Remote channel has new network address",
89 "New or resumed network connection",
90 "Specified task isnt a member of a CA context",
91 "Attempt to use defunct CA feature failed",
92 
93 "The supplied string is empty",
94 "Unable to spawn the CA repeater thread- auto reconnect will fail",
95 "No channel id match for search reply- search reply ignored",
96 "Reseting dead connection- will try to reconnect",
97 "Server (IOC) has fallen behind or is not responding- still waiting",
98 
99 "No internet interface with broadcast available",
100 "Invalid event selection mask",
101 "IO operations have completed",
102 "IO operations are in progress",
103 "Invalid synchronous group identifier",
104 
105 "Put callback timed out",
106 "Read access denied",
107 "Write access denied",
108 "Requested feature is no longer supported",
109 "Empty PV search address list",
110 
111 "No reasonable data conversion between client and server types",
112 "Invalid channel identifier",
113 "Invalid function pointer",
114 "Thread is already attached to a client context",
115 "Not supported by attached service",
116 
117 "User destroyed channel",
118 "Invalid channel priority",
119 "Preemptive callback not enabled - additional threads may not join context",
120 "Client's protocol revision does not support transfers exceeding 16k bytes",
121 "Virtual circuit connection sequence aborted",
122 
123 "Virtual circuit unresponsive"
124 };
125 
126 static epicsThreadOnceId caClientContextIdOnce = EPICS_THREAD_ONCE_INIT;
127 
128 // runs once only for each process
129 extern "C" void ca_init_client_context ( void * )
130 {
131  caClientContextId = epicsThreadPrivateCreate ();
132 }
133 
134 /*
135  * fetchClientContext ();
136  */
138 {
139  epicsThreadOnce ( &caClientContextIdOnce, ca_init_client_context, 0 );
140  if ( caClientContextId == 0 ) {
141  return ECA_ALLOCMEM;
142  }
143 
144  int status;
145  *ppcac = ( ca_client_context * ) epicsThreadPrivateGet ( caClientContextId );
146  if ( *ppcac ) {
147  status = ECA_NORMAL;
148  }
149  else {
150  status = ca_task_initialize ();
151  if ( status == ECA_NORMAL ) {
152  *ppcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
153  if ( ! *ppcac ) {
154  status = ECA_INTERNAL;
155  }
156  }
157  }
158 
159  return status;
160 }
161 
162 /*
163  * ca_task_initialize ()
164  */
165 // extern "C"
166 int epicsStdCall ca_task_initialize ( void )
167 {
169 }
170 
171 // extern "C"
172 int epicsStdCall ca_context_create (
173  ca_preemptive_callback_select premptiveCallbackSelect )
174 {
175  ca_client_context *pcac;
176 
177  try {
178  epicsThreadOnce ( & caClientContextIdOnce, ca_init_client_context, 0);
179  if ( caClientContextId == 0 ) {
180  return ECA_ALLOCMEM;
181  }
182 
183  pcac = ( ca_client_context * ) epicsThreadPrivateGet ( caClientContextId );
184  if ( pcac ) {
185  if ( premptiveCallbackSelect == ca_enable_preemptive_callback &&
186  ! pcac->preemptiveCallbakIsEnabled() ) {
187  return ECA_NOTTHREADED;
188  }
189  return ECA_NORMAL;
190  }
191 
192  pcac = new ca_client_context (
193  premptiveCallbackSelect == ca_enable_preemptive_callback );
194  if ( ! pcac ) {
195  return ECA_ALLOCMEM;
196  }
197 
198  epicsThreadPrivateSet ( caClientContextId, (void *) pcac );
199  }
200  catch ( ... ) {
201  return ECA_ALLOCMEM;
202  }
203  return ECA_NORMAL;
204 }
205 
206 //
207 // ca_modify_host_name ()
208 //
209 // defunct
210 //
211 // extern "C"
212 int epicsStdCall ca_modify_host_name ( const char * )
213 {
214  return ECA_NORMAL;
215 }
216 
217 //
218 // ca_modify_user_name()
219 //
220 // defunct
221 //
222 // extern "C"
223 int epicsStdCall ca_modify_user_name ( const char * )
224 {
225  return ECA_NORMAL;
226 }
227 
228 //
229 // ca_context_destroy ()
230 //
231 // extern "C"
232 void epicsStdCall ca_context_destroy ()
233 {
234  ca_client_context *pcac;
235 
236  if ( caClientContextId != NULL ) {
237  pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
238  if ( pcac ) {
239  delete pcac;
240  epicsThreadPrivateSet ( caClientContextId, 0 );
241  }
242  }
243 }
244 
245 /*
246  * ca_task_exit()
247  *
248  * releases all resources alloc to a channel access client
249  */
250 // extern "C"
251 int epicsStdCall ca_task_exit ()
252 {
254  return ECA_NORMAL;
255 }
256 
257 /*
258  *
259  * CA_BUILD_AND_CONNECT
260  *
261  * backwards compatible entry point to ca_search_and_connect()
262  */
263 // extern "C"
264 int epicsStdCall ca_build_and_connect ( const char *name_str, chtype get_type,
265  arrayElementCount get_count, chid * chan, void *pvalue,
266  caCh *conn_func, void *puser )
267 {
268  if ( get_type != TYPENOTCONN && pvalue != 0 && get_count != 0 ) {
269  return ECA_ANACHRONISM;
270  }
271 
272  return ca_search_and_connect ( name_str, chan, conn_func, puser );
273 }
274 
275 /*
276  * ca_search_and_connect()
277  */
278 // extern "C"
279 int epicsStdCall ca_search_and_connect (
280  const char * name_str, chid * chanptr,
281  caCh * conn_func, void * puser )
282 {
283  return ca_create_channel ( name_str, conn_func,
284  puser, CA_PRIORITY_DEFAULT, chanptr );
285 }
286 
287 // extern "C"
288 int epicsStdCall ca_create_channel (
289  const char * name_str, caCh * conn_func, void * puser,
290  capri priority, chid * chanptr )
291 {
292  ca_client_context * pcac;
293  int caStatus = fetchClientContext ( & pcac );
294  if ( caStatus != ECA_NORMAL ) {
295  return caStatus;
296  }
297 
298  {
299  CAFDHANDLER * pFunc = 0;
300  void * pArg = 0;
301  {
303  guard ( pcac->mutex );
304  if ( pcac->fdRegFuncNeedsToBeCalled ) {
305  pFunc = pcac->fdRegFunc;
306  pArg = pcac->fdRegArg;
307  pcac->fdRegFuncNeedsToBeCalled = false;
308  }
309  }
310  if ( pFunc ) {
311  ( *pFunc ) ( pArg, pcac->sock, true );
312  }
313  }
314 
315  try {
316  epicsGuard < epicsMutex > guard ( pcac->mutex );
317  oldChannelNotify * pChanNotify =
318  new ( pcac->oldChannelNotifyFreeList )
319  oldChannelNotify ( guard, *pcac, name_str,
320  conn_func, puser, priority );
321  // make sure that their chan pointer is set prior to
322  // calling connection call backs
323  *chanptr = pChanNotify;
324  pChanNotify->initiateConnect ( guard );
325  // no need to worry about a connect preempting here because
326  // the connect sequence will not start untill initiateConnect()
327  // is called
328  }
329  catch ( cacChannel::badString & ) {
330  return ECA_BADSTR;
331  }
332  catch ( std::bad_alloc & ) {
333  return ECA_ALLOCMEM;
334  }
335  catch ( cacChannel::badPriority & ) {
336  return ECA_BADPRIORITY;
337  }
339  return ECA_UNAVAILINSERV;
340  }
341  catch ( std :: exception & except ) {
342  pcac->printFormated (
343  "ca_create_channel: "
344  "unexpected exception was \"%s\"",
345  except.what () );
346  return ECA_INTERNAL;
347  }
348  catch ( ... ) {
349  return ECA_INTERNAL;
350  }
351 
352  return ECA_NORMAL;
353 }
354 
355 /*
356  * ca_clear_channel ()
357  *
358  * a known defect here is that there will be a
359  * crash if they destroy the channel after destroying
360  * its context
361  */
362 // extern "C"
363 int epicsStdCall ca_clear_channel ( chid pChan )
364 {
365  ca_client_context & cac = pChan->getClientCtx ();
366  {
367  epicsGuard < epicsMutex > guard ( cac.mutex );
368  try {
369  pChan->eliminateExcessiveSendBacklog ( guard );
370  }
371  catch ( cacChannel::notConnected & ) {
372  // intentionally ignored
373  }
374  }
375  if ( cac.pCallbackGuard.get() &&
376  cac.createdByThread == epicsThreadGetIdSelf () ) {
377  epicsGuard < epicsMutex > guard ( cac.mutex );
378  pChan->destructor ( *cac.pCallbackGuard.get(), guard );
379  cac.oldChannelNotifyFreeList.release ( pChan );
380  }
381  else {
382  //
383  // we will definately stall out here if all of the
384  // following are true
385  //
386  // o user creates non-preemtive mode client library context
387  // o user doesnt periodically call a ca function
388  // o user calls this function from an auxiillary thread
389  //
390  CallbackGuard cbGuard ( cac.cbMutex );
391  epicsGuard < epicsMutex > guard ( cac.mutex );
392  pChan->destructor ( *cac.pCallbackGuard.get(), guard );
393  cac.oldChannelNotifyFreeList.release ( pChan );
394  }
395  return ECA_NORMAL;
396 }
397 
398 /*
399  * Specify an event subroutine to be run for asynch exceptions
400  */
401 // extern "C"
402 int epicsStdCall ca_add_exception_event ( caExceptionHandler *pfunc, void *arg )
403 {
404  ca_client_context *pcac;
405  int caStatus = fetchClientContext ( &pcac );
406  if ( caStatus != ECA_NORMAL ) {
407  return caStatus;
408  }
409 
410  pcac->changeExceptionEvent ( pfunc, arg );
411 
412  return ECA_NORMAL;
413 }
414 
415 /*
416  * ca_add_masked_array_event
417  */
418 int epicsStdCall ca_add_masked_array_event (
419  chtype type, arrayElementCount count, chid pChan,
420  caEventCallBackFunc *pCallBack, void *pCallBackArg,
422  evid *monixptr, long mask )
423 {
424  return ca_create_subscription ( type, count, pChan, mask,
425  pCallBack, pCallBackArg, monixptr );
426 }
427 
428 /*
429  * ca_clear_event ()
430  */
431 int epicsStdCall ca_clear_event ( evid pMon )
432 {
433  return ca_clear_subscription ( pMon );
434 }
435 
436 // extern "C"
437 chid epicsStdCall ca_evid_to_chid ( evid pMon )
438 {
439  return & pMon->channel ();
440 }
441 
442 // extern "C"
443 int epicsStdCall ca_pend ( ca_real timeout, int early )
444 {
445  if ( early ) {
446  return ca_pend_io ( timeout );
447  }
448  else {
449  return ca_pend_event ( timeout );
450  }
451 }
452 
453 /*
454  * ca_pend_event ()
455  */
456 // extern "C"
457 int epicsStdCall ca_pend_event ( ca_real timeout )
458 {
459  ca_client_context *pcac;
460  int status = fetchClientContext ( &pcac );
461  if ( status != ECA_NORMAL ) {
462  return status;
463  }
464 
465  try {
466  // preserve past odd ball behavior of waiting forever when
467  // the delay is zero
468  if ( timeout == 0.0 ) {
469  while ( true ) {
470  pcac->pendEvent ( 60.0 );
471  }
472  }
473  return pcac->pendEvent ( timeout );
474  }
475  catch ( ... ) {
476  return ECA_INTERNAL;
477  }
478 }
479 
480 /*
481  * ca_pend_io ()
482  */
483 // extern "C"
484 int epicsStdCall ca_pend_io ( ca_real timeout )
485 {
486  ca_client_context *pcac;
487  int status = fetchClientContext ( &pcac );
488  if ( status != ECA_NORMAL ) {
489  return status;
490  }
491 
492  try {
493  // preserve past odd ball behavior of waiting forever when
494  // the delay is zero
495  if ( timeout == 0.0 ) {
496  return pcac->pendIO ( DBL_MAX );
497  }
498 
499  return pcac->pendIO ( timeout );
500  }
501  catch ( ... ) {
502  return ECA_INTERNAL;
503  }
504 }
505 
506 /*
507  * ca_flush_io ()
508  */
509 int epicsStdCall ca_flush_io ()
510 {
511  ca_client_context * pcac;
512  int caStatus = fetchClientContext (&pcac);
513  if ( caStatus != ECA_NORMAL ) {
514  return caStatus;
515  }
516 
517  epicsGuard < epicsMutex > guard ( pcac->mutex );
518  pcac->flush ( guard );
519 
520  return ECA_NORMAL;
521 }
522 
523 /*
524  * CA_TEST_IO ()
525  */
526 int epicsStdCall ca_test_io ()
527 {
528  ca_client_context *pcac;
529  int caStatus = fetchClientContext ( &pcac );
530  if ( caStatus != ECA_NORMAL ) {
531  return caStatus;
532  }
533 
534  if ( pcac->ioComplete () ) {
535  return ECA_IODONE;
536  }
537  else{
538  return ECA_IOINPROGRESS;
539  }
540 }
541 
542 /*
543  * CA_SIGNAL()
544  */
545 // extern "C"
546 void epicsStdCall ca_signal ( long ca_status, const char *message )
547 {
548  ca_signal_with_file_and_lineno ( ca_status, message, NULL, 0 );
549 }
550 
551 /*
552  * ca_message (long ca_status)
553  *
554  * - if it is an unknown error code then it possible
555  * that the error string generated below
556  * will be overwritten before (or while) the caller
557  * of this routine is calling this routine
558  * (if they call this routine again).
559  */
560 // extern "C"
561 const char * epicsStdCall ca_message ( long ca_status )
562 {
563  unsigned msgNo = CA_EXTRACT_MSG_NO ( ca_status );
564 
565  if ( msgNo < NELEMENTS (ca_message_text) ) {
566  return ca_message_text[msgNo];
567  }
568  else {
569  return "new CA message number known only by server - see caerr.h";
570  }
571 }
572 
573 /*
574  * ca_signal_with_file_and_lineno()
575  */
576 // extern "C"
577 void epicsStdCall ca_signal_with_file_and_lineno ( long ca_status,
578  const char *message, const char *pfilenm, int lineno )
579 {
580  ca_signal_formated ( ca_status, pfilenm, lineno, message );
581 }
582 
583 /*
584  * ca_signal_formated()
585  */
586 // extern "C"
587 void epicsStdCall ca_signal_formated ( long ca_status, const char *pfilenm,
588  int lineno, const char *pFormat, ... )
589 {
590  ca_client_context *pcac;
591 
592  if ( caClientContextId ) {
593  pcac = ( ca_client_context * ) epicsThreadPrivateGet ( caClientContextId );
594  }
595  else {
596  pcac = 0;
597  }
598 
599  va_list theArgs;
600  va_start ( theArgs, pFormat );
601  if ( pcac ) {
602  pcac->vSignal ( ca_status, pfilenm, lineno, pFormat, theArgs );
603  }
604  else {
605  fprintf ( stderr, "CA exception in thread w/o CA ctx: status=%s file=%s line=%d: \n",
606  ca_message ( ca_status ), pfilenm, lineno );
607  if ( pFormat ) {
608  vfprintf ( stderr, pFormat, theArgs );
609  }
610  }
611  va_end ( theArgs );
612 }
613 
614 /*
615  * CA_ADD_FD_REGISTRATION
616  *
617  * call their function with their argument whenever
618  * a new fd is added or removed
619  * (for a manager of the select system call under UNIX)
620  *
621  */
622 // extern "C"
623 int epicsStdCall ca_add_fd_registration ( CAFDHANDLER * func, void * arg )
624 {
625  ca_client_context *pcac;
626  int caStatus = fetchClientContext ( &pcac );
627  if ( caStatus != ECA_NORMAL ) {
628  return caStatus;
629  }
630 
631  pcac->registerForFileDescriptorCallBack ( func, arg );
632 
633  return ECA_NORMAL;
634 }
635 
636 /*
637  * ca_version()
638  * function that returns the CA version string
639  */
640 // extern "C"
641 const char * epicsStdCall ca_version ()
642 {
644 }
645 
646 /*
647  * ca_replace_printf_handler ()
648  */
649 // extern "C"
650 int epicsStdCall ca_replace_printf_handler ( caPrintfFunc *ca_printf_func )
651 {
652  ca_client_context *pcac;
653  int caStatus = fetchClientContext (&pcac);
654  if ( caStatus != ECA_NORMAL ) {
655  return caStatus;
656  }
657 
658  pcac->replaceErrLogHandler ( ca_printf_func );
659 
660  return ECA_NORMAL;
661 }
662 
663 /*
664  * ca_get_ioc_connection_count()
665  *
666  * returns the number of IOC's that CA is connected to
667  * (for testing purposes only)
668  */
669 // extern "C"
670 unsigned epicsStdCall ca_get_ioc_connection_count ()
671 {
672  ca_client_context * pcac;
673  int caStatus = fetchClientContext ( & pcac );
674  if ( caStatus != ECA_NORMAL ) {
675  return 0u;
676  }
677 
678  return pcac->circuitCount ();
679 }
680 
681 unsigned epicsStdCall ca_beacon_anomaly_count ()
682 {
683  ca_client_context * pcac;
684  int caStatus = fetchClientContext ( & pcac );
685  if ( caStatus != ECA_NORMAL ) {
686  return 0u;
687  }
688 
689  return pcac->beaconAnomaliesSinceProgramStart ();
690 }
691 
692 // extern "C"
693 int epicsStdCall ca_channel_status ( epicsThreadId /* tid */ )
694 {
695  ::printf ("The R3.14 EPICS OS abstraction API does not allow peeking at thread private storage of another thread.\n");
696  ::printf ("Please call \"ca_client_status ( unsigned level )\" from the subsystem specific diagnostic code.\n");
697  return ECA_ANACHRONISM;
698 }
699 
700 // extern "C"
701 int epicsStdCall ca_client_status ( unsigned level )
702 {
703  ca_client_context *pcac;
704  int caStatus = fetchClientContext ( &pcac );
705  if ( caStatus != ECA_NORMAL ) {
706  return caStatus;
707  }
708 
709  pcac->show ( level );
710  return ECA_NORMAL;
711 }
712 
713 int epicsStdCall ca_context_status ( ca_client_context * pcac, unsigned level )
714 {
715  pcac->show ( level );
716  return ECA_NORMAL;
717 }
718 
719 /*
720  * ca_current_context ()
721  *
722  * used when an auxillary thread needs to join a CA client context started
723  * by another thread
724  */
725 // extern "C"
726 struct ca_client_context * epicsStdCall ca_current_context ()
727 {
728  struct ca_client_context *pCtx;
729  if ( caClientContextId ) {
730  pCtx = ( struct ca_client_context * )
731  epicsThreadPrivateGet ( caClientContextId );
732  }
733  else {
734  pCtx = 0;
735  }
736  return pCtx;
737 }
738 
739 /*
740  * ca_attach_context ()
741  *
742  * used when an auxillary thread needs to join a CA client context started
743  * by another thread
744  */
745 // extern "C"
746 int epicsStdCall ca_attach_context ( struct ca_client_context * pCtx )
747 {
748  ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
749  if ( pcac && pCtx != 0 ) {
750  return ECA_ISATTACHED;
751  }
752  if ( ! pCtx->preemptiveCallbakIsEnabled() ) {
753  return ECA_NOTTHREADED;
754  }
755  epicsThreadPrivateSet ( caClientContextId, pCtx );
756  return ECA_NORMAL;
757 }
758 
759 void epicsStdCall ca_detach_context ()
760 {
761  if ( caClientContextId ) {
762  epicsThreadPrivateSet ( caClientContextId, 0 );
763  }
764 }
765 
767 {
768  ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
769  if ( ! pcac ) {
770  return 0;
771  }
772  return pcac->preemptiveCallbakIsEnabled ();
773 }
774 
775 
776 // extern "C"
777 void epicsStdCall ca_self_test ()
778 {
779  ca_client_context *pcac = (ca_client_context *) epicsThreadPrivateGet ( caClientContextId );
780  if ( ! pcac ) {
781  return;
782  }
783  pcac->selfTest ();
784 }
785 
787  DBR_SHORT, /* forces conversion fronm uint8 to int16 */
788  DBR_CHAR,
789  DBR_SHORT,
790  DBR_LONG, /* forces conversion fronm uint16 to int32 */
791  DBR_ENUM,
792  DBR_LONG,
793  DBR_LONG, /* very large unsigned number will not map */
794  DBR_FLOAT,
795  DBR_DOUBLE,
796  DBR_STRING,
797  DBR_STRING
798 };
799 
802  epicsInt16T,
804  epicsEnum16T,
805  epicsUInt8T,
806  epicsInt32T,
808 
810  epicsInt16T,
812  epicsEnum16T,
813  epicsUInt8T,
814  epicsInt32T,
816 
818  epicsInt16T,
820  epicsEnum16T,
821  epicsUInt8T,
822  epicsInt32T,
824 
826  epicsInt16T,
828  epicsEnum16T,
829  epicsUInt8T,
830  epicsInt32T,
832 
834  epicsInt16T,
836  epicsEnum16T,
837  epicsUInt8T,
838  epicsInt32T,
840 
841  epicsUInt16T,
842  epicsUInt16T,
844  epicsOldStringT
845 };
846 
847 const unsigned short dbr_size[LAST_BUFFER_TYPE+1] = {
848  sizeof(dbr_string_t), /* string max size */
849  sizeof(dbr_short_t), /* short */
850  sizeof(dbr_float_t), /* IEEE Float */
851  sizeof(dbr_enum_t), /* item number */
852  sizeof(dbr_char_t), /* character */
853 
854  sizeof(dbr_long_t), /* long */
855  sizeof(dbr_double_t), /* double */
856  sizeof(struct dbr_sts_string), /* string field with status */
857  sizeof(struct dbr_sts_short), /* short field with status */
858  sizeof(struct dbr_sts_float), /* float field with status */
859 
860  sizeof(struct dbr_sts_enum), /* item number with status */
861  sizeof(struct dbr_sts_char), /* char field with status */
862  sizeof(struct dbr_sts_long), /* long field with status */
863  sizeof(struct dbr_sts_double), /* double field with time */
864  sizeof(struct dbr_time_string), /* string field with time */
865 
866  sizeof(struct dbr_time_short), /* short field with time */
867  sizeof(struct dbr_time_float), /* float field with time */
868  sizeof(struct dbr_time_enum), /* item number with time */
869  sizeof(struct dbr_time_char), /* char field with time */
870  sizeof(struct dbr_time_long), /* long field with time */
871 
872  sizeof(struct dbr_time_double), /* double field with time */
873  sizeof(struct dbr_sts_string), /* graphic string info */
874  sizeof(struct dbr_gr_short), /* graphic short info */
875  sizeof(struct dbr_gr_float), /* graphic float info */
876  sizeof(struct dbr_gr_enum), /* graphic item info */
877 
878  sizeof(struct dbr_gr_char), /* graphic char info */
879  sizeof(struct dbr_gr_long), /* graphic long info */
880  sizeof(struct dbr_gr_double), /* graphic double info */
881  sizeof(struct dbr_sts_string), /* control string info */
882  sizeof(struct dbr_ctrl_short), /* control short info */
883 
884  sizeof(struct dbr_ctrl_float), /* control float info */
885  sizeof(struct dbr_ctrl_enum), /* control item info */
886  sizeof(struct dbr_ctrl_char), /* control char info */
887  sizeof(struct dbr_ctrl_long), /* control long info */
888  sizeof(struct dbr_ctrl_double), /* control double info */
889 
890  sizeof(dbr_put_ackt_t), /* put ackt */
891  sizeof(dbr_put_acks_t), /* put acks */
892  sizeof(struct dbr_stsack_string),/* string field with status/ack*/
893  sizeof(dbr_string_t), /* string max size */
894 };
895 
896 const unsigned short dbr_value_size[LAST_BUFFER_TYPE+1] = {
897  sizeof(dbr_string_t), /* string max size */
898  sizeof(dbr_short_t), /* short */
899  sizeof(dbr_float_t), /* IEEE Float */
900  sizeof(dbr_enum_t), /* item number */
901  sizeof(dbr_char_t), /* character */
902 
903  sizeof(dbr_long_t), /* long */
904  sizeof(dbr_double_t), /* double */
905  sizeof(dbr_string_t), /* string max size */
906  sizeof(dbr_short_t), /* short */
907  sizeof(dbr_float_t), /* IEEE Float */
908 
909  sizeof(dbr_enum_t), /* item number */
910  sizeof(dbr_char_t), /* character */
911  sizeof(dbr_long_t), /* long */
912  sizeof(dbr_double_t), /* double */
913  sizeof(dbr_string_t), /* string max size */
914 
915  sizeof(dbr_short_t), /* short */
916  sizeof(dbr_float_t), /* IEEE Float */
917  sizeof(dbr_enum_t), /* item number */
918  sizeof(dbr_char_t), /* character */
919  sizeof(dbr_long_t), /* long */
920 
921  sizeof(dbr_double_t), /* double */
922  sizeof(dbr_string_t), /* string max size */
923  sizeof(dbr_short_t), /* short */
924  sizeof(dbr_float_t), /* IEEE Float */
925  sizeof(dbr_enum_t), /* item number */
926 
927  sizeof(dbr_char_t), /* character */
928  sizeof(dbr_long_t), /* long */
929  sizeof(dbr_double_t), /* double */
930  sizeof(dbr_string_t), /* string max size */
931  sizeof(dbr_short_t), /* short */
932 
933  sizeof(dbr_float_t), /* IEEE Float */
934  sizeof(dbr_enum_t), /* item number */
935  sizeof(dbr_char_t), /* character */
936  sizeof(dbr_long_t), /* long */
937  sizeof(dbr_double_t), /* double */
938 
939  sizeof(dbr_ushort_t), /* put_ackt */
940  sizeof(dbr_ushort_t), /* put_acks */
941  sizeof(dbr_string_t), /* string max size */
942  sizeof(dbr_string_t), /* string max size */
943 };
944 
945 //extern "C"
947  dbr_class_string, /* string max size */
948  dbr_class_int, /* short */
949  dbr_class_float, /* IEEE Float */
950  dbr_class_int, /* item number */
951  dbr_class_int, /* character */
952  dbr_class_int, /* long */
953  dbr_class_float, /* double */
954 
955  dbr_class_string, /* string max size */
956  dbr_class_int, /* short */
957  dbr_class_float, /* IEEE Float */
958  dbr_class_int, /* item number */
959  dbr_class_int, /* character */
960  dbr_class_int, /* long */
961  dbr_class_float, /* double */
962 
963  dbr_class_string, /* string max size */
964  dbr_class_int, /* short */
965  dbr_class_float, /* IEEE Float */
966  dbr_class_int, /* item number */
967  dbr_class_int, /* character */
968  dbr_class_int, /* long */
969  dbr_class_float, /* double */
970 
971  dbr_class_string, /* string max size */
972  dbr_class_int, /* short */
973  dbr_class_float, /* IEEE Float */
974  dbr_class_int, /* item number */
975  dbr_class_int, /* character */
976  dbr_class_int, /* long */
977  dbr_class_float, /* double */
978 
979  dbr_class_string, /* string max size */
980  dbr_class_int, /* short */
981  dbr_class_float, /* IEEE Float */
982  dbr_class_int, /* item number */
983  dbr_class_int, /* character */
984  dbr_class_int, /* long */
985  dbr_class_float, /* double */
989  dbr_class_string, /* string max size */
990 };
991 
992 const unsigned short dbr_value_offset[LAST_BUFFER_TYPE+1] = {
993  0, /* string */
994  0, /* short */
995  0, /* IEEE Float */
996  0, /* item number */
997  0, /* character */
998  0, /* long */
999  0, /* IEEE double */
1000  (unsigned short) offsetof(dbr_sts_string,value[0]), /* string field with status */
1001  (unsigned short) offsetof(dbr_sts_short,value), /* short field with status */
1002  (unsigned short) offsetof(dbr_sts_float,value), /* float field with status */
1003  (unsigned short) offsetof(dbr_sts_enum,value), /* item number with status */
1004  (unsigned short) offsetof(dbr_sts_char,value), /* char field with status */
1005  (unsigned short) offsetof(dbr_sts_long,value), /* long field with status */
1006  (unsigned short) offsetof(dbr_sts_double,value), /* double field with time */
1007  (unsigned short) offsetof(dbr_time_string,value[0] ), /* string field with time */
1008  (unsigned short) offsetof(dbr_time_short,value), /* short field with time */
1009  (unsigned short) offsetof(dbr_time_float,value), /* float field with time */
1010  (unsigned short) offsetof(dbr_time_enum,value), /* item number with time */
1011  (unsigned short) offsetof(dbr_time_char,value), /* char field with time */
1012  (unsigned short) offsetof(dbr_time_long,value), /* long field with time */
1013  (unsigned short) offsetof(dbr_time_double,value), /* double field with time */
1014  (unsigned short) offsetof(dbr_sts_string,value[0]), /* graphic string info */
1015  (unsigned short) offsetof(dbr_gr_short,value), /* graphic short info */
1016  (unsigned short) offsetof(dbr_gr_float,value), /* graphic float info */
1017  (unsigned short) offsetof(dbr_gr_enum,value), /* graphic item info */
1018  (unsigned short) offsetof(dbr_gr_char,value), /* graphic char info */
1019  (unsigned short) offsetof(dbr_gr_long,value), /* graphic long info */
1020  (unsigned short) offsetof(dbr_gr_double,value), /* graphic double info */
1021  (unsigned short) offsetof(dbr_sts_string,value[0]), /* control string info */
1022  (unsigned short) offsetof(dbr_ctrl_short,value), /* control short info */
1023  (unsigned short) offsetof(dbr_ctrl_float,value), /* control float info */
1024  (unsigned short) offsetof(dbr_ctrl_enum,value), /* control item info */
1025  (unsigned short) offsetof(dbr_ctrl_char,value), /* control char info */
1026  (unsigned short) offsetof(dbr_ctrl_long,value), /* control long info */
1027  (unsigned short) offsetof(dbr_ctrl_double,value), /* control double info */
1028  0, /* put ackt */
1029  0, /* put acks */
1030  (unsigned short) offsetof(dbr_stsack_string,value[0]), /* string field with status */
1031  0, /* string */
1032 };
1033 
1034 const char *dbf_text[LAST_TYPE+3] = {
1035  "TYPENOTCONN",
1036  "DBF_STRING",
1037  "DBF_SHORT",
1038  "DBF_FLOAT",
1039  "DBF_ENUM",
1040  "DBF_CHAR",
1041  "DBF_LONG",
1042  "DBF_DOUBLE",
1043  "DBF_NO_ACCESS"
1044 };
1045 
1046 const char *dbf_text_invalid = "DBF_invalid";
1047 
1048 const short dbf_text_dim = (sizeof dbf_text)/(sizeof (char *));
1049 
1050 const char *dbr_text[LAST_BUFFER_TYPE+1] = {
1051  "DBR_STRING",
1052  "DBR_SHORT",
1053  "DBR_FLOAT",
1054  "DBR_ENUM",
1055  "DBR_CHAR",
1056  "DBR_LONG",
1057  "DBR_DOUBLE",
1058  "DBR_STS_STRING",
1059  "DBR_STS_SHORT",
1060  "DBR_STS_FLOAT",
1061  "DBR_STS_ENUM",
1062  "DBR_STS_CHAR",
1063  "DBR_STS_LONG",
1064  "DBR_STS_DOUBLE",
1065  "DBR_TIME_STRING",
1066  "DBR_TIME_SHORT",
1067  "DBR_TIME_FLOAT",
1068  "DBR_TIME_ENUM",
1069  "DBR_TIME_CHAR",
1070  "DBR_TIME_LONG",
1071  "DBR_TIME_DOUBLE",
1072  "DBR_GR_STRING",
1073  "DBR_GR_SHORT",
1074  "DBR_GR_FLOAT",
1075  "DBR_GR_ENUM",
1076  "DBR_GR_CHAR",
1077  "DBR_GR_LONG",
1078  "DBR_GR_DOUBLE",
1079  "DBR_CTRL_STRING",
1080  "DBR_CTRL_SHORT",
1081  "DBR_CTRL_FLOAT",
1082  "DBR_CTRL_ENUM",
1083  "DBR_CTRL_CHAR",
1084  "DBR_CTRL_LONG",
1085  "DBR_CTRL_DOUBLE",
1086  "DBR_PUT_ACKT",
1087  "DBR_PUT_ACKS",
1088  "DBR_STSACK_STRING",
1089  "DBR_CLASS_NAME"
1090 };
1091 
1092 const char *dbr_text_invalid = "DBR_invalid";
1093 
1094 const short dbr_text_dim = (sizeof dbr_text) / (sizeof (char *)) + 1;
double timeout
Definition: pvutils.cpp:25
#define DBR_CHAR
Definition: db_access.h:74
int epicsStdCall ca_task_exit()
Definition: access.cpp:251
#define DBR_STRING
Definition: db_access.h:69
int epicsStdCall ca_channel_status(epicsThreadId)
Definition: access.cpp:693
const char * dbr_text[LAST_BUFFER_TYPE+1]
Definition: access.cpp:1050
Definition: link.h:174
const unsigned short dbr_value_size[LAST_BUFFER_TYPE+1]
Definition: access.cpp:896
void caCh(struct connection_handler_args args)
Definition: cadef.h:57
const unsigned short dbr_size[LAST_BUFFER_TYPE+1]
Definition: access.cpp:847
Definition: cac.h:97
#define LAST_BUFFER_TYPE
Definition: db_access.h:113
void ca_init_client_context(void *)
Definition: access.cpp:129
unsigned epicsStdCall ca_beacon_anomaly_count()
Definition: access.cpp:681
#define CA_PRIORITY_DEFAULT
Definition: cadef.h:192
pvd::Status status
#define true
Definition: flexdef.h:84
#define ECA_INTERNAL
Definition: caerr.h:94
int lineno
Definition: antelope.c:33
#define ECA_IOINPROGRESS
Definition: caerr.h:120
ca_preemptive_callback_select
Definition: cadef.h:175
bool preemptiveCallbakIsEnabled() const
Definition: oldAccess.h:556
int epicsStdCall ca_create_channel(const char *name_str, caCh *conn_func, void *puser, capri priority, chid *chanptr)
Definition: access.cpp:288
#define CA_EXTRACT_MSG_NO(code)
Definition: caerr.h:54
LIBCOM_API void *epicsStdCall epicsThreadPrivateGet(epicsThreadPrivateId)
Definition: osdThread.c:973
int epicsStdCall ca_search_and_connect(const char *name_str, chid *chanptr, caCh *conn_func, void *puser)
Definition: access.cpp:279
ca_client_context & getClientCtx()
Definition: oldAccess.h:428
void epicsStdCall ca_self_test()
Definition: access.cpp:777
epicsFloat32 dbr_float_t
Definition: db_access.h:46
void caExceptionHandler(struct exception_handler_args)
Definition: cadef.h:251
#define ECA_ANACHRONISM
Definition: caerr.h:125
void caEventCallBackFunc(struct event_handler_args)
Definition: cadef.h:92
#define DBR_FLOAT
Definition: db_access.h:72
int epicsStdCall ca_pend_io(ca_real timeout)
Definition: access.cpp:484
unsigned epicsStdCall ca_get_ioc_connection_count()
Definition: access.cpp:670
#define printf
Definition: epicsStdio.h:41
pvd::StructureConstPtr type
#define ECA_IODONE
Definition: caerr.h:119
int printFormated(const char *pformat,...) const
#define NULL
Definition: catime.c:38
int epicsStdCall ca_add_masked_array_event(chtype type, arrayElementCount count, chid pChan, caEventCallBackFunc *pCallBack, void *pCallBackArg, ca_real, ca_real, ca_real, evid *monixptr, long mask)
Definition: access.cpp:418
void epicsStdCall ca_detach_context()
Definition: access.cpp:759
int epicsStdCall ca_attach_context(struct ca_client_context *pCtx)
Definition: access.cpp:746
const char * dbr_text_invalid
Definition: access.cpp:1092
void epicsStdCall ca_signal(long ca_status, const char *message)
Definition: access.cpp:546
int epicsStdCall ca_preemtive_callback_is_enabled()
Definition: access.cpp:766
Miscellaneous macro definitions.
#define CA_VERSION_STRING(MINOR_REVISION)
Definition: caProto.h:27
void CAFDHANDLER(void *parg, int fd, int opened)
Definition: cadef.h:657
void epicsStdCall ca_signal_with_file_and_lineno(long ca_status, const char *message, const char *pfilenm, int lineno)
Definition: access.cpp:577
int epicsStdCall ca_client_status(unsigned level)
Definition: access.cpp:701
bool ioComplete() const
Definition: oldAccess.h:561
void destructor(CallbackGuard &cbGuard, epicsGuard< epicsMutex > &mutexGuard)
#define CA_MINOR_PROTOCOL_REVISION
Definition: nciu.h:35
const char * ca_message_text[]
Definition: access.cpp:49
int epicsStdCall ca_context_create(ca_preemptive_callback_select premptiveCallbackSelect)
Definition: access.cpp:172
int epicsStdCall ca_pend_event(ca_real timeout)
Definition: access.cpp:457
double ca_real
Definition: cadef.h:49
#define EPICS_THREAD_ONCE_INIT
Definition: epicsThread.h:109
#define ECA_NORMAL
Definition: caerr.h:77
void epicsStdCall ca_signal_formated(long ca_status, const char *pfilenm, int lineno, const char *pFormat,...)
Definition: access.cpp:587
unsigned beaconAnomaliesSinceProgramStart() const
#define LAST_TYPE
Definition: db_access.h:64
int epicsStdCall ca_add_exception_event(caExceptionHandler *pfunc, void *arg)
Definition: access.cpp:402
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
int epicsStdCall ca_flush_io()
Definition: access.cpp:509
LIBCOM_API void epicsStdCall epicsThreadPrivateSet(epicsThreadPrivateId, void *)
Definition: osdThread.c:961
#define ECA_NOTTHREADED
Definition: caerr.h:134
const epicsType DBR_XXXXToEpicsType[LAST_BUFFER_TYPE+1]
Definition: access.cpp:800
#define DBR_DOUBLE
Definition: db_access.h:76
int epicsStdCall ca_pend(ca_real timeout, int early)
Definition: access.cpp:443
#define ECA_BADPRIORITY
Definition: caerr.h:133
const short dbr_text_dim
Definition: access.cpp:1094
unsigned capri
Definition: cadef.h:189
int epicsStdCall ca_replace_printf_handler(caPrintfFunc *ca_printf_func)
Definition: access.cpp:650
void initiateConnect(epicsGuard< epicsMutex > &)
Definition: oldAccess.h:447
#define DBR_SHORT
Definition: db_access.h:71
LIBCA_API int epicsStdCall ca_clear_subscription(evid pMon)
Extended replacement for the Posix exit and atexit routines.
epicsFloat64 dbr_double_t
Definition: db_access.h:47
int fetchClientContext(ca_client_context **ppcac)
Definition: access.cpp:137
int epicsStdCall ca_task_initialize(void)
Definition: access.cpp:166
int epicsStdCall ca_add_fd_registration(CAFDHANDLER *func, void *arg)
Definition: access.cpp:623
epicsOldString dbr_string_t
Definition: db_access.h:38
int epicsStdCall ca_clear_event(evid pMon)
Definition: access.cpp:431
#define NELEMENTS(A)
Definition: aToIPAddr.c:21
int caPrintfFunc(const char *pformat, va_list args)
Definition: cadef.h:821
epicsUInt8 dbr_char_t
Definition: db_access.h:39
int epicsStdCall ca_clear_channel(chid pChan)
Definition: access.cpp:363
epicsThreadPrivateId caClientContextId
Definition: access.cpp:46
void changeExceptionEvent(caExceptionHandler *pfunc, void *arg)
int pendEvent(const double &timeout)
#define DBR_ENUM
Definition: db_access.h:73
epicsUInt16 dbr_enum_t
Definition: db_access.h:43
unsigned long arrayElementCount
Definition: cacIO.h:57
#define ECA_ISATTACHED
Definition: caerr.h:130
const char *epicsStdCall ca_message(long ca_status)
Definition: access.cpp:561
const char *epicsStdCall ca_version()
Definition: access.cpp:641
long chtype
Definition: cadef.h:47
dbr_value_class
Definition: db_access.h:529
oldChannelNotify & channel() const
Definition: oldAccess.h:509
epicsType
Definition: epicsTypes.h:99
#define TYPENOTCONN
Definition: cadef.h:149
#define DBR_LONG
Definition: db_access.h:75
void flush(epicsGuard< epicsMutex > &)
epicsUInt16 dbr_ushort_t
Definition: db_access.h:41
unsigned circuitCount() const
void release(void *p)
Definition: tsFreeList.h:176
#define ECA_BADSTR
Definition: caerr.h:100
int epicsStdCall ca_modify_user_name(const char *)
Definition: access.cpp:223
int epicsStdCall ca_build_and_connect(const char *name_str, chtype get_type, arrayElementCount get_count, chid *chan, void *pvalue, caCh *conn_func, void *puser)
Definition: access.cpp:264
chid epicsStdCall ca_evid_to_chid(evid pMon)
Definition: access.cpp:437
#define stderr
Definition: epicsStdio.h:32
void replaceErrLogHandler(caPrintfFunc *ca_printf_func)
void registerForFileDescriptorCallBack(CAFDHANDLER *pFunc, void *pArg)
void eliminateExcessiveSendBacklog(epicsGuard< epicsMutex > &)
Definition: oldAccess.h:468
int epicsStdCall ca_context_status(ca_client_context *pcac, unsigned level)
Definition: access.cpp:713
epicsInt16 dbr_short_t
Definition: db_access.h:40
epicsInt32 dbr_long_t
Definition: db_access.h:44
void epicsStdCall ca_context_destroy()
Definition: access.cpp:232
int epicsStdCall ca_modify_host_name(const char *)
Definition: access.cpp:212
int pendIO(const double &timeout)
const int epicsTypeToDBR_XXXX[lastEpicsType+1]
Definition: access.cpp:786
struct ca_client_context *epicsStdCall ca_current_context()
Definition: access.cpp:726
void vSignal(int ca_status, const char *pfilenm, int lineno, const char *pFormat, va_list args)
LIBCOM_API epicsThreadPrivateId epicsStdCall epicsThreadPrivateCreate(void)
Definition: osdThread.c:934
LIBCA_API int epicsStdCall ca_create_subscription(chtype type, unsigned long count, chid chanId, long mask, caEventCallBackFunc *pFunc, void *pArg, evid *pEventID)
#define lastEpicsType
Definition: epicsTypes.h:113
#define ECA_UNAVAILINSERV
Definition: caerr.h:131
const short dbf_text_dim
Definition: access.cpp:1048
#define ECA_ALLOCMEM
Definition: caerr.h:83
int epicsStdCall ca_test_io()
Definition: access.cpp:526
const char * dbf_text_invalid
Definition: access.cpp:1046
const unsigned short dbr_value_offset[LAST_BUFFER_TYPE+1]
Definition: access.cpp:992
void show(unsigned level) const
const char * dbf_text[LAST_TYPE+3]
Definition: access.cpp:1034
LIBCOM_API epicsThreadId epicsStdCall epicsThreadGetIdSelf(void)
Definition: osdThread.c:810