This is Unofficial EPICS BASE Doxygen Site
asSubRecordFunctions.c
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 Versions 3.13.7
7 * and higher are distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /* asSubRecordFunctions.c */
11 
12 /* Author: Marty Kraimer Date: 01MAY2000 */
13 
14 #include <stddef.h>
15 #include <stdlib.h>
16 #include <stdarg.h>
17 #include <stdio.h>
18 #include <string.h>
19 
20 #include "dbAccess.h"
21 #include "cantProceed.h"
22 #include "callback.h"
23 #include "alarm.h"
24 #include "errlog.h"
25 #include "dbEvent.h"
26 #include "recSup.h"
27 #include "recGbl.h"
28 #include "registryFunction.h"
29 #include "asLib.h"
30 #include "asDbLib.h"
31 #include "subRecord.h"
32 #include "epicsExport.h"
33 
34 /* The following is provided for access security*/
35 /*It allows a CA client to force access security initialization*/
36 
37 static void myCallback(epicsCallback *pcallback)
38 {
39  ASDBCALLBACK *pasdbcallback = (ASDBCALLBACK *)pcallback;
40  subRecord *precord;
41  rset *prset;
42 
43  callbackGetUser(precord,pcallback);
44  prset=(rset *)(precord->rset);
45  precord->val = 0.0;
46  if(pasdbcallback->status) {
47  recGblSetSevr(precord,READ_ALARM,precord->brsv);
48  recGblRecordError(pasdbcallback->status,precord,"asInit Failed");
49  }
50  dbScanLock((dbCommon *)precord);
51  (*prset->process)((dbCommon *)precord);
52  dbScanUnlock((dbCommon *)precord);
53 }
54 
55 long asSubInit(subRecord *precord,void *process)
56 {
57  ASDBCALLBACK *pcallback;
58 
59  pcallback = (ASDBCALLBACK *)callocMustSucceed(
60  1,sizeof(ASDBCALLBACK),"asSubInit");
61  precord->dpvt = (void *)pcallback;
62  callbackSetCallback(myCallback,&pcallback->callback);
63  callbackSetUser(precord,&pcallback->callback);
64  return(0);
65 }
66 
67 long asSubProcess(subRecord *precord)
68 {
69  ASDBCALLBACK *pcallback = (ASDBCALLBACK *)precord->dpvt;
70 
71  if(!precord->pact && precord->val==1.0) {
72  db_post_events(precord,&precord->val,DBE_VALUE);
73  callbackSetPriority(precord->prio,&pcallback->callback);
74  asInitAsyn(pcallback);
75  precord->pact=TRUE;
76  return(1);
77  }
78  db_post_events(precord,&precord->val,DBE_VALUE);
79  return(0);
80 }
81 
82 static registryFunctionRef asSubRef[] = {
83  {"asSubInit",(REGISTRYFUNCTION)asSubInit},
84  {"asSubProcess",(REGISTRYFUNCTION)asSubProcess}
85 };
86 
87 static void asSub(void)
88 {
89  registryFunctionRefAdd(asSubRef,NELEMENTS(asSubRef));
90 }
void(* REGISTRYFUNCTION)(void)
#define READ_ALARM
Definition: alarm.h:92
epicsExportRegistrar(asSub)
int asInitAsyn(ASDBCALLBACK *pcallback)
Definition: asDbLib.c:187
long(* process)()
Definition: recSup.h:72
long asSubInit(subRecord *precord, void *process)
epicsCallback callback
Definition: asDbLib.h:21
#define DBE_VALUE
Definition: caeventmask.h:38
long asSubProcess(subRecord *precord)
LIBCOM_API void * callocMustSucceed(size_t count, size_t size, const char *msg)
A calloc() that never returns NULL.
Definition: cantProceed.c:22
#define NELEMENTS(A)
Definition: aToIPAddr.c:21
long status
Definition: asDbLib.h:22
#define TRUE
Definition: dbDefs.h:27
Definition: recSup.h:67
Routines for code that can&#39;t continue or return after an error.
epicsShareFunc int registryFunctionRefAdd(registryFunctionRef ref[], int nfunctions)
Exporting IOC objects.