From 350301e9f942ff3ae83cfadbdbc98857c0832cb4 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Mon, 3 Dec 1990 08:47:50 +0000 Subject: [PATCH] Initial revision --- src/dev/devWfJoergerVtr1.c | 164 +++++++++++++++++++++++++++++++++++++ src/dev/devWfSoft.c | 93 +++++++++++++++++++++ src/dev/devWfXy566Sc.c | 139 +++++++++++++++++++++++++++++++ 3 files changed, 396 insertions(+) create mode 100644 src/dev/devWfJoergerVtr1.c create mode 100644 src/dev/devWfSoft.c create mode 100644 src/dev/devWfXy566Sc.c diff --git a/src/dev/devWfJoergerVtr1.c b/src/dev/devWfJoergerVtr1.c new file mode 100644 index 000000000..7079e995d --- /dev/null +++ b/src/dev/devWfJoergerVtr1.c @@ -0,0 +1,164 @@ +/* devWfJoergerVtr1.c */ +/* share/src/dev $Id$ */ + +/* devWfJoergerVtr1.c - Device Support Routines */ + + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +long init_record(); +long read_wf(); +long arm_wf(); + + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_wf; +} devWfJoergerVtr1={ + 5, + NULL, + NULL, + init_record, + NULL, + read_wf}; +/* control block for callback */ +struct callback{ + struct dbAddr dbAddr; + void (*process)(); +}; + +/* + * Macro to access the Joerger memory using word addressing. + * Returns either byte of a short using only short word addressing + * this is necessary to avoid bus errors + */ +#define get_a_byte(a) (((long)a & 0x01)? \ + (*(unsigned short *)(a-1) & 0xff) : (*(unsigned short *)(a) >> 8)) + + + +static void myCallback(pcallback,no_read,pdata) + struct callback *pcallback; + int no_read; + unsigned char *pdata; +{ + struct waveformRecord *pwf= + (struct waveformRecord *)(pcallback->dbAddr.precord); + short ftvl = pwf->ftvl; + int i; + + if(!pwf->busy) return; + dbScanLock(pwf); + pwf->busy = FALSE; + if(ftvl==DBF_CHAR || ftvl==DBF_UCHAR) { + unsigned char source; + unsigned char *pdest=(unsigned char *)pwf->bptr; + + for(i=0; inord = no_read; /* number of values read */ + } else if(ftvl==DBF_SHORT || ftvl==DBF_USHORT) { + unsigned char source; + unsigned short *pdest=(unsigned short *)pwf->bptr; + + for(i=0; inord = no_read; /* number of values read */ + } else { + recGblRecSupError(S_db_badField,&pcallback->dbAddr, + "read_wf - illegal ftvl"); + if(pwf->nsevnsta = READ_ALARM; + pwf->nsev = MAJOR_ALARM; + + } + } + (pcallback->process)(&pcallback->dbAddr); + dbScanUnlock(pwf); +} + +static long init_record(pwf,process) + struct waveformRecord *pwf; + void (*process)(); +{ + char message[100]; + struct callback *pcallback; + + /* wf.inp must be an VME_IO */ + switch (pwf->inp.type) { + case (VME_IO) : + pcallback = (struct callback *)(calloc(1,sizeof(struct callback *))); + pwf->dpvt = (caddr_t)pcallback; + if(dbNameToAddr(pwf->name,&(pcallback->dbAddr))) { + logMsg("dbNameToAddr failed in init_record for devWfJoergerVtr1\n"); + exit(1); + } + pcallback->process = process; + break; + default : + strcpy(message,pwf->name); + strcat(message,": devWfJoergerVtr1 (init_record) Illegal INP field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long read_wf(pwf) + struct waveformRecord *pwf; +{ + char message[100]; + struct callback *pcallback=(struct callback *)(pwf->dpvt); + unsigned short value; + struct vmeio *pvmeio; + long status; + + + if(pwf->busy) return(1); + status = 0; + /* determine if wave form is to be rearmed*/ + /* If not active then request rearm */ + if(!pwf->pact) status = arm_wf(pwf); + /* if already active then call is from myCallback. check rarm*/ + else if(pwf->rarm) { + (void)arm_wf(pwf); + pwf->rarm = 0; + } + return(status); +} + +static long arm_wf(pwf) +struct waveformRecord *pwf; +{ + struct vmeio *pvmeio = (struct vmeio *)&(pwf->inp.value); + + pwf->busy = TRUE; + if(wf_driver(JGVTR1,pvmeio->card,myCallback,pwf->dpvt)<0){ + if(pwf->nsevnsta = READ_ALARM; + pwf->nsev = MAJOR_ALARM; + + } + pwf->busy = FALSE; + return(0); + } + return(1); +} diff --git a/src/dev/devWfSoft.c b/src/dev/devWfSoft.c new file mode 100644 index 000000000..8b71ca9a8 --- /dev/null +++ b/src/dev/devWfSoft.c @@ -0,0 +1,93 @@ +/* devWfSoft.c */ +/* share/src/dev $Id$ */ + +/* devWfSoft.c - Device Support Routines for soft Waveform Records*/ + + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* Create the dset for devWfSoft */ +long init_record(); +long read_wf(); +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_wf; +}devWfSoft={ + 5, + NULL, + NULL, + init_record, + NULL, + read_wf}; + + +static long init_record(pwf) + struct waveformRecord *pwf; +{ + char message[100]; + + /* wf.inp must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/ + switch (pwf->inp.type) { + case (CONSTANT) : + pwf->nord = 0; + break; + case (PV_LINK) : + break; + case (DB_LINK) : + break; + case (CA_LINK) : + break; + default : + strcpy(message,pwf->name); + strcat(message,": devWfSoft (init_record) Illegal INP field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long read_wf(pwf) + struct waveformRecord *pwf; +{ + char message[100]; + long status,options,nRequest; + + /* wf.inp must be a CONSTANT or a DB_LINK or a CA_LINK*/ + switch (pwf->inp.type) { + case (CONSTANT) : + break; + case (DB_LINK) : + options=0; + nRequest=pwf->nelm; + (void)dbGetLink(&(pwf->inp.value.db_link),pwf,pwf->ftvl, + pwf->bptr,&options,&nRequest); + pwf->nord = nRequest; + break; + case (CA_LINK) : + break; + default : + if(pwf->nsevnsev = MAJOR_ALARM; + pwf->nsta = SOFT_ALARM; + if(pwf->stat!=SOFT_ALARM) { + strcpy(message,pwf->name); + strcat(message,": devWfSoft (read_wf) Illegal INP field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/dev/devWfXy566Sc.c b/src/dev/devWfXy566Sc.c new file mode 100644 index 000000000..3fbe537ed --- /dev/null +++ b/src/dev/devWfXy566Sc.c @@ -0,0 +1,139 @@ +/* devWfXy566Sc.c */ +/* share/src/dev $Id$ */ + +/* devWfXy566Sc.c - Device Support Routines */ + + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +long init_record(); +long read_wf(); +long arm_wf(); + + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_wf; +} devWfXy566Sc={ + 5, + NULL, + NULL, + init_record, + NULL, + read_wf}; +/* control block for callback */ +struct callback{ + struct dbAddr dbAddr; + void (*process)(); +}; + + +static void myCallback(pcallback,no_read,pdata) + struct callback *pcallback; + int no_read; + unsigned char *pdata; +{ + struct waveformRecord *pwf= + (struct waveformRecord *)(pcallback->dbAddr.precord); + short ftvl = pwf->ftvl; + + if(!pwf->busy) return; + dbScanLock(pwf); + pwf->busy = FALSE; + if(ftvl==DBF_SHORT || ftvl==DBF_USHORT) { + bcopy(pdata,pwf->bptr,no_read*2); + pwf->nord = no_read; /* number of values read */ + } else { + recGblRecSupError(S_db_badField,&pcallback->dbAddr, + "read_wf - illegal ftvl"); + if(pwf->nsevnsta = READ_ALARM; + pwf->nsev = MAJOR_ALARM; + + } + } + (pcallback->process)(&pcallback->dbAddr); + dbScanUnlock(pwf); +} + +static long init_record(pwf,process) + struct waveformRecord *pwf; + void (*process)(); +{ + char message[100]; + struct callback *pcallback; + + /* wf.inp must be an VME_IO */ + switch (pwf->inp.type) { + case (VME_IO) : + pcallback = (struct callback *)(calloc(1,sizeof(struct callback *))); + pwf->dpvt = (caddr_t)pcallback; + if(dbNameToAddr(pwf->name,&(pcallback->dbAddr))) { + logMsg("dbNameToAddr failed in init_record for devWfXy566Sc\n"); + exit(1); + } + pcallback->process = process; + break; + default : + strcpy(message,pwf->name); + strcat(message,": devWfXy566Sc (init_record) Illegal INP field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long read_wf(pwf) + struct waveformRecord *pwf; +{ + char message[100]; + struct callback *pcallback=(struct callback *)(pwf->dpvt); + unsigned short value; + struct vmeio *pvmeio; + long status; + + + if(pwf->busy) return(1); + status = 0; + /* determine if wave form is to be rearmed*/ + /* If not active then request rearm */ + if(!pwf->pact) status = arm_wf(pwf); + /* if already active then call is from myCallback. check rarm*/ + else if(pwf->rarm) { + (void)arm_wf(pwf); + pwf->rarm = 0; + } + return(status); +} + +static long arm_wf(pwf) +struct waveformRecord *pwf; +{ + struct vmeio *pvmeio = (struct vmeio *)&(pwf->inp.value); + + pwf->busy = TRUE; + if(wf_driver(XY566WF,pvmeio->card,myCallback,pwf->dpvt)<0) { + if(pwf->nsevnsta = READ_ALARM; + pwf->nsev = MAJOR_ALARM; + + } + pwf->busy = FALSE; + return(0); + } + return(1); +}