Initial revision
This commit is contained in:
189
src/rec/recEvent.c
Normal file
189
src/rec/recEvent.c
Normal file
@@ -0,0 +1,189 @@
|
||||
/* recEvent.c */
|
||||
/* share/src/rec $Id$ */
|
||||
|
||||
/* recEvent.c - Record Support Routines for Event records */
|
||||
/*
|
||||
* Author: Janet Anderson
|
||||
* Date: 12-13-91
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* .00 12-13-91 jba Initial definition
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <lstLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <devSup.h>
|
||||
#include <errMdef.h>
|
||||
#include <link.h>
|
||||
#include <recSup.h>
|
||||
#include <module_types.h>
|
||||
#include <eventRecord.h>
|
||||
|
||||
/* Create RSET - Record Support Entry Table*/
|
||||
#define report NULL
|
||||
#define initialize NULL
|
||||
long init_record();
|
||||
long process();
|
||||
#define special NULL
|
||||
long get_value();
|
||||
#define cvt_dbaddr NULL
|
||||
#define get_array_info NULL
|
||||
#define put_array_info NULL
|
||||
#define get_units NULL
|
||||
#define get_precision NULL
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
|
||||
struct rset eventRSET={
|
||||
RSETNUMBER,
|
||||
report,
|
||||
initialize,
|
||||
init_record,
|
||||
process,
|
||||
special,
|
||||
get_value,
|
||||
cvt_dbaddr,
|
||||
get_array_info,
|
||||
put_array_info,
|
||||
get_units,
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
struct eventdset { /* event input dset */
|
||||
long number;
|
||||
DEVSUPFUN dev_report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_event;/*(0,1)=> success, async */
|
||||
};
|
||||
void monitor();
|
||||
|
||||
static long init_record(pevent)
|
||||
struct eventRecord *pevent;
|
||||
{
|
||||
struct eventdset *pdset;
|
||||
long status;
|
||||
|
||||
if(!(pdset = (struct eventdset *)(pevent->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,pevent,"event: init_record");
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* must have read_event function defined */
|
||||
if( (pdset->number < 5) || (pdset->read_event == NULL) ) {
|
||||
recGblRecordError(S_dev_missingSup,pevent,"event: init_record");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(pevent,process))) return(status);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long process(paddr)
|
||||
struct dbAddr *paddr;
|
||||
{
|
||||
struct eventRecord *pevent=(struct eventRecord *)(paddr->precord);
|
||||
struct eventdset *pdset = (struct eventdset *)(pevent->dset);
|
||||
long status;
|
||||
|
||||
if( (pdset==NULL) || (pdset->read_event==NULL) ) {
|
||||
pevent->pact=TRUE;
|
||||
recGblRecordError(S_dev_missingSup,pevent,"read_event");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
|
||||
status=(*pdset->read_event)(pevent); /* read the new value */
|
||||
pevent->pact = TRUE;
|
||||
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if (status==1) return(0);
|
||||
|
||||
if(pevent->enum>0) post_event(enum);
|
||||
|
||||
tsLocalTime(&pevent->time);
|
||||
|
||||
/* check event list */
|
||||
monitor(pevent);
|
||||
|
||||
/* process the forward scan link record */
|
||||
if (pevent->flnk.type==DB_LINK) dbScanPassive(pevent->flnk.value.db_link.pdbAddr);
|
||||
|
||||
pevent->pact=FALSE;
|
||||
return(status);
|
||||
}
|
||||
|
||||
|
||||
static long get_value(pevent,pvdes)
|
||||
struct eventRecord *pevent;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_SHORT;
|
||||
pvdes->no_elements=1;
|
||||
pvdes->pvalue = (caddr_t)(&pevent->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
static void monitor(pevent)
|
||||
struct eventRecord *pevent;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
short stat,sevr,nsta,nsev;
|
||||
|
||||
/* get previous stat and sevr and new stat and sevr*/
|
||||
recGblResetSevr(pevent,stat,sevr,nsta,nsev);
|
||||
|
||||
/* Flags which events to fire on the value field */
|
||||
monitor_mask = 0;
|
||||
|
||||
/* alarm condition changed this scan */
|
||||
if (stat!=nsta || sevr!=nsev) {
|
||||
/* post events for alarm condition change*/
|
||||
monitor_mask = DBE_ALARM;
|
||||
/* post stat and nsev fields */
|
||||
db_post_events(pevent,&pevent->stat,DBE_VALUE);
|
||||
db_post_events(pevent,&pevent->sevr,DBE_VALUE);
|
||||
}
|
||||
|
||||
db_post_events(pevent,&(pevent->enum,monitor_mask|DBE_VALUE);
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user