From cd33cc8d296e44091b50ed050a9d9f42ed25db1d Mon Sep 17 00:00:00 2001 From: "Janet B. Anderson" Date: Fri, 4 Oct 1991 17:40:32 +0000 Subject: [PATCH] Initial revision --- src/dev/devAoSoftRaw.c | 103 ++++++++++++++++++++++++++ src/dev/devLiSoft.c | 130 +++++++++++++++++++++++++++++++++ src/dev/devLoSoft.c | 100 +++++++++++++++++++++++++ src/dev/devPtSoft.c | 103 ++++++++++++++++++++++++++ src/libCom/cvtBpt.c | 161 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 597 insertions(+) create mode 100644 src/dev/devAoSoftRaw.c create mode 100644 src/dev/devLiSoft.c create mode 100644 src/dev/devLoSoft.c create mode 100644 src/dev/devPtSoft.c create mode 100644 src/libCom/cvtBpt.c diff --git a/src/dev/devAoSoftRaw.c b/src/dev/devAoSoftRaw.c new file mode 100644 index 000000000..8d6a9d29b --- /dev/null +++ b/src/dev/devAoSoftRaw.c @@ -0,0 +1,103 @@ +/* devAoSoftRaw.c */ +/* share/src/dev $Id$ */ + +/* Device Support Routines for soft raw Analog Output Records*/ +/* + * Author: Janet Anderson + * Date: 09-25-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: + * ----------------- + * .01 mm-dd-yy iii Comment + * .02 mm-dd-yy iii Comment + * ... + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* Create the dset for devAoSoftRaw */ +long write_ao(); +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_ao; + DEVSUPFUN special_linconv; +}devAoSoftRaw={ + 6, + NULL, + NULL, + NULL, + NULL, + write_ao, + NULL}; + + +static long write_ao(pao) + struct aoRecord *pao; +{ + char message[100]; + long status; + + /* ao.out must be a CONSTANT or a DB_LINK or a CA_LINK*/ + switch (pao->out.type) { + case (CONSTANT) : + break; + case (DB_LINK) : + status = dbPutLink(&pao->out.value.db_link,pao,DBR_LONG, + &pao->rval,1L); + if(status!=0) { + if(pao->nsevnsev = VALID_ALARM; + pao->nsta = LINK_ALARM; + } + } + break; + case (CA_LINK) : + break; + default : + if(pao->nsevnsev = VALID_ALARM; + pao->nsta = SOFT_ALARM; + if(pao->stat!=SOFT_ALARM) { + strcpy(message,pao->name); + strcat(message,": devAoSoftRaw (write_ao) Illegal OUT field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/dev/devLiSoft.c b/src/dev/devLiSoft.c new file mode 100644 index 000000000..c6b149c4e --- /dev/null +++ b/src/dev/devLiSoft.c @@ -0,0 +1,130 @@ +/* devLiSoft.c */ +/* share/src/dev $Id$ */ + +/* devLiSoft.c - Device Support Routines for Soft Longin Input */ +/* + * Author: Janet Anderson + * Date: 09-23-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: + * ----------------- + * .01 mm-dd-yy iii Comment +*/ + + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +/* Create the dset for devLiSoft */ +long init_record(); +long read_longin(); + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_longin; +}devLiSoft={ + 5, + NULL, + NULL, + init_record, + NULL, + read_longin}; + +static long init_record(plongin) + struct longinRecord *plongin; +{ + char message[100]; + + /* longin.inp must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/ + switch (plongin->inp.type) { + case (CONSTANT) : + plongin->val = plongin->inp.value.value; + plongin->udf = FALSE; + break; + case (PV_LINK) : + break; + case (DB_LINK) : + break; + case (CA_LINK) : + break; + default : + strcpy(message,plongin->name); + strcat(message,": devLiSoft (init_record) Illegal INP field"); + errMessage(S_db_badField,message); + return(S_db_badField); + } + return(0); +} + +static long read_longin(plongin) + struct longinRecord *plongin; +{ + char message[100]; + long status=0,options,nRequest; + + /* longin.inp must be a CONSTANT or a DB_LINK or a CA_LINK*/ + switch (plongin->inp.type) { + case (CONSTANT) : + break; + case (DB_LINK) : + options=0; + nRequest=1; + status = dbGetLink(&(plongin->inp.value.db_link),plongin,DBR_LONG, + &plongin->val,&options,&nRequest); + if(status!=0) { + if(plongin->nsevnsev = VALID_ALARM; + plongin->nsta = LINK_ALARM; + } + } else plongin->udf = FALSE; + break; + case (CA_LINK) : + break; + default : + if(plongin->nsevnsev = VALID_ALARM; + plongin->nsta = SOFT_ALARM; + if(plongin->stat!=SOFT_ALARM) { + strcpy(message,plongin->name); + strcat(message,": devLiSoft (read_longin) Illegal INP field"); + errMessage(S_db_badField,message); + } + } + } + return(status); +} diff --git a/src/dev/devLoSoft.c b/src/dev/devLoSoft.c new file mode 100644 index 000000000..ebaf47c02 --- /dev/null +++ b/src/dev/devLoSoft.c @@ -0,0 +1,100 @@ +/* devLoSoft.c */ +/* share/src/dev $Id$ */ + +/* devLoSoft.c - Device Support Routines for Soft Longout Output */ +/* + * Author: Janet Anderson + * Date: 09-23-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 Lource + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 mm-dd-yy iii Comment +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +/* Create the dset for devLoSoft */ +long write_longout(); + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_longout; +}devLoSoft={ + 5, + NULL, + NULL, + NULL, + NULL, + write_longout}; + + +static long write_longout(plongout) + struct longoutRecord *plongout; +{ + char message[100]; + long status; + + /* longout.out must be a CONSTANT or a DB_LINK or a CA_LINK*/ + switch (plongout->out.type) { + case (CONSTANT) : + break; + case (DB_LINK) : + status = dbPutLink(&plongout->out.value.db_link,plongout,DBR_LONG, + &plongout->val,1L); + if(status!=0) { + if(plongout->nsevnsev = VALID_ALARM; + plongout->nsta = LINK_ALARM; + } + } + break; + case (CA_LINK) : + break; + default : + if(plongout->nsevnsev = VALID_ALARM; + plongout->nsta = SOFT_ALARM; + if(plongout->stat!=SOFT_ALARM) { + strcpy(message,plongout->name); + strcat(message,": devLoSoft (write_longout) Illegal OUT field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/dev/devPtSoft.c b/src/dev/devPtSoft.c new file mode 100644 index 000000000..49b2417c1 --- /dev/null +++ b/src/dev/devPtSoft.c @@ -0,0 +1,103 @@ +/* devPtSoft.c */ +/* share/src/dev $Id$ */ + +/* devPtSoft.c - Device Support Routines for Soft Pulse Generator Output */ +/* + * Author: Janet Anderson + * Date: 6-1-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: + * ----------------- + * .01 mm-dd-yy iii Comment + * .02 mm-dd-yy iii Comment + * ... + */ + + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +/* Create the dset for devPtSoft */ +long write_pt(); + +struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_pt; +}devPtSoft={ + 5, + NULL, + NULL, + NULL, + NULL, + write_pt}; + + +static long write_pt(ppt) + struct pulseTrainRecord *ppt; +{ + char message[100]; + long status; + + /* pt.out must be a CONSTANT or a DB_LINK or a CA_LINK*/ + switch (ppt->out.type) { + case (CONSTANT) : + break; + case (DB_LINK) : + status = dbPutLink(&ppt->out.value.db_link,ppt,DBR_SHORT,&ppt->val,1L); + if(status!=0) { + if(ppt->nsevnsev = VALID_ALARM; + ppt->nsta = LINK_ALARM; + } + } else ppt->udf=FALSE; + break; + case (CA_LINK) : + break; + default : + if(ppt->nsevnsev = VALID_ALARM; + ppt->nsta = SOFT_ALARM; + if(ppt->stat!=SOFT_ALARM) { + strcpy(message,ppt->name); + strcat(message,": devPtSoft (write_pt) Illegal OUT field"); + errMessage(S_db_badField,message); + } + } + } + return(0); +} diff --git a/src/libCom/cvtBpt.c b/src/libCom/cvtBpt.c new file mode 100644 index 000000000..70fffde81 --- /dev/null +++ b/src/libCom/cvtBpt.c @@ -0,0 +1,161 @@ +/* cvtBpt.c */ +/* share/libCom/cvtBpt $Id$ */ + +/* cvtBpt.c - Convert using breakpoint table +/* + * Author: Janet Anderson + * Date: 9-19-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: + * ----------------- + * nnn mm-dd-yy nnn Comment + */ +#include +#include +#include +#include + +#include +#include + + + +long cvtRawToEngBpt(pval,linr,init,ppbrk,plbrk) + double *pval; + short linr; + short init; + caddr_t *ppbrk; + short *plbrk; +{ + double val=*pval; + + struct brkTable *pbrkTable; + struct brkInt *pInt; + struct brkInt *pnxtInt; + short lbrk; + int number; + + if(linr < 2) return(-1); + if(init==TRUE) { /*must find breakpoint table*/ + if( !cvtTable || (cvtTable->number < linr) + || (!(cvtTable->papBrkTable[linr]))) { + errMessage(S_db_badField,"Breakpoint Table not Found"); + return(S_db_badField); + } + *ppbrk = (caddr_t)(cvtTable->papBrkTable[linr]); + /* Just start at the beginning */ + *plbrk=0; + } + + pbrkTable = (struct brkTable *)*ppbrk; + number = pbrkTable->number; + lbrk = *plbrk; +printf("DEBUG: cvtRawtoEngBpt = %d\n",number); + /*make sure we dont go off end of table*/ + if( (lbrk+1) >= number ) lbrk--; + pInt = pbrkTable->papBrkInt[lbrk]; + pnxtInt = pbrkTable->papBrkInt[lbrk+1]; + /* find entry for increased value */ + while( (pnxtInt->raw) <= val ) { + lbrk++; + pInt = pbrkTable->papBrkInt[lbrk]; + if( lbrk >= number-1) { + return(1); + } + pnxtInt = pbrkTable->papBrkInt[lbrk+1]; + } + while( (pInt->raw) > val) { + if(lbrk==0) { + return(1); + } + lbrk--; + pInt = pbrkTable->papBrkInt[lbrk]; + } + *plbrk = lbrk; + *pval = pInt->eng + (val - pInt->raw) * pInt->slope; + return(0); +} + +long cvtEngToRawBpt(pval,linr,init,ppbrk,plbrk) + double *pval; + short linr; + short init; + caddr_t *ppbrk; + short *plbrk; +{ + double val=*pval; + + struct brkTable *pbrkTable; + struct brkInt *pInt; + struct brkInt *pnxtInt; + short lbrk; + int number; + + + if(linr < 2) return(-1); + if(init==TRUE) { /*must find breakpoint table*/ + if( !cvtTable || (cvtTable->number < linr) + || (!(cvtTable->papBrkTable[linr]))) { + errMessage(S_db_badField,"Breakpoint Table not Found"); + return(S_db_badField); + } + *ppbrk = (caddr_t)(cvtTable->papBrkTable[linr]); + /* Just start at the beginning */ + *plbrk=0; + } + + pbrkTable = (struct brkTable *)*ppbrk; + number = pbrkTable->number; + lbrk = *plbrk; +printf("DEBUG: cvtEngToRawBpt = %d\n",number); + /*make sure we dont go off end of table*/ + if( (lbrk+1) >= number ) lbrk--; + pInt = pbrkTable->papBrkInt[lbrk]; + pnxtInt = pbrkTable->papBrkInt[lbrk+1]; + /* find entry for increased value */ + while( (pnxtInt->eng) <= val ) { + lbrk++; + pInt = pbrkTable->papBrkInt[lbrk]; + if( lbrk >= number-1) { + return(1); + } + pnxtInt = pbrkTable->papBrkInt[lbrk+1]; + } + while( (pInt->eng) > val) { + if(lbrk==0) { + return(1); + } + lbrk--; + pInt = pbrkTable->papBrkInt[lbrk]; + } + if(pInt->slope!=0){ + *plbrk = lbrk; + *pval = pInt->raw + (val - pInt->eng) / pInt->slope; + } + else { + return(1); + } + return(0); +}