diff --git a/src/dev/Makefile.Vx b/src/dev/Makefile.Vx index 2a20db5c2..c9e4ffdd0 100644 --- a/src/dev/Makefile.Vx +++ b/src/dev/Makefile.Vx @@ -2,7 +2,7 @@ EPICS = ../../../.. include Target.include include $(EPICS)/config/CONFIG_BASE -USR_INCLUDES = -I../../drv/old -I../../drv/ansi +USR_INCLUDES = -I../../drv/ansi -I../../drv/old # SRCS.c += ../devAaiCamac.c # SRCS.c += ../devAiCamac.c @@ -15,7 +15,6 @@ SRCS.c += ../devAiTestAsyn.c SRCS.c += ../devAiXy566Di.c SRCS.c += ../devAiXy566DiL.c SRCS.c += ../devAiXy566Se.c -SRCS.c += ../devAllenBradley.c # SRCS.c += ../devAaoCamac.c # SRCS.c += ../devAoCamac.c SRCS.c += ../devAoSoft.c @@ -96,6 +95,12 @@ SRCS.c += ../devWfSoft.c SRCS.c += ../devWfTestAsyn.c SRCS.c += ../devWfXy566Sc.c SRCS.c += ../devXy240.c +SRCS.c += ../devAB1771IFE.c +SRCS.c += ../devAB1771IL.c +SRCS.c += ../devAB1771IR.c +SRCS.c += ../devAB1771IXE.c +SRCS.c += ../devAB1771OFE.c +SRCS.c += ../devABBINARY.c # OBJS += devAaiCamac.o # OBJS += devAiCamac.o @@ -108,7 +113,6 @@ OBJS += devAiTestAsyn.o OBJS += devAiXy566Di.o OBJS += devAiXy566DiL.o OBJS += devAiXy566Se.o -OBJS += devAllenBradley.o # OBJS += devAaoCamac.o # OBJS += devAoCamac.o OBJS += devAoSoft.o @@ -189,6 +193,12 @@ OBJS += devWfSoft.o OBJS += devWfTestAsyn.o OBJS += devWfXy566Sc.o OBJS += devXy240.o +OBJS += devAB1771IFE.o +OBJS += devAB1771IL.o +OBJS += devAB1771IR.o +OBJS += devAB1771IXE.o +OBJS += devAB1771OFE.o +OBJS += devABBINARY.o PROD = devSup diff --git a/src/dev/devAB1771IFE.c b/src/dev/devAB1771IFE.c new file mode 100644 index 000000000..99128a378 --- /dev/null +++ b/src/dev/devAB1771IFE.c @@ -0,0 +1,267 @@ +/* devAB1771IFE.c */ +/* + * Original Author: Bob Dalesio + * Current Author: Bob Dalesio, Marty Kraimer + * Date: 3/6/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 12-01-94 lrd combine the device support that was resident + * in the driver and device support to + significantly reduce the amount of code + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dsets*/ +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt); +LOCAL long init_1771IfeDiff(struct aiRecord *prec); +LOCAL long init_1771Ife0to5V(struct aiRecord *prec); +LOCAL long init_1771IfeMa(struct aiRecord *prec); +LOCAL long init_1771IfeSe(struct aiRecord *prec); +LOCAL long linconv_1771Ife(struct aiRecord *prec, int after); +LOCAL long read_1771Ife(struct aiRecord *prec); + +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_ai; + DEVSUPFUN special_linconv;} ABAIDSET; + +ABAIDSET devAiAb1771Ife={6, 0, 0, init_1771IfeDiff, + ioinfo_ai, read_1771Ife, linconv_1771Ife}; +ABAIDSET devAiAb1771Ife0to5V={6, 0, 0, init_1771Ife0to5V, + ioinfo_ai, read_1771Ife, linconv_1771Ife}; +ABAIDSET devAiAb1771IfeMa={6, 0, 0, init_1771IfeMa, + ioinfo_ai, read_1771Ife, linconv_1771Ife}; +ABAIDSET devAiAb1771IfeSe={6, 0, 0, init_1771IfeSe, + ioinfo_ai, read_1771Ife, linconv_1771Ife}; + +#define IFE_SCAN_RATE 1 +#define IFE_INITMSG_LENGTH 37 +#define IFE_DIFF_READMSG_LENGTH 12 +#define IFE_SE_READMSG_LENGTH 20 + +struct ab1771Ife_read { + unsigned short diag; /* diagnostic word */ + unsigned short urange; /* low byte - under range channels */ + unsigned short orange; /* low byte - over range channels */ + unsigned short sign; /* low byte - polarity 1 = negative */ + short data[16]; /* 16 data values (can be signed) */ +}; + +/* IFE Differential Initialization Message - from the IFE Manual */ +LOCAL short ab1771IfeDiff_initmsg[IFE_INITMSG_LENGTH] = { + 0xffff, 0xffff, /* -10 to 10 volts (signals 0 - 15) */ + 0x0700, /* signed magnitude - differential */ + 0xffff, 0x0000, /* scaled 0 - 4095 (12 bits) */ + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095 +}; +/* 1771 - IFE 0 to 5 Volt */ +LOCAL short ab1771Ife0to5v_initmsg[IFE_INITMSG_LENGTH] = { + 0x5555, 0x5555, /* 0 to 5 volts (signals 0 - 15) */ + 0x0700, /* signed magnitude - differential */ + 0x0000, 0x0000, /* scaled 0 - 4095 (12 bits) */ + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095 +}; +/* 1771 - IFE MilliAmp */ +LOCAL short ab1771IfeMa_initmsg[IFE_INITMSG_LENGTH] = { + 0x0000, 0x0000, /* 4 - 20 Ma (signals 0 - 15) */ + 0x0700, /* signed magnitude - differential */ + 0x0000, 0x0000, /* scaled 0 - 4095 (12 bits) */ + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095 +}; +/* 1771 - IFE Single Ended (-10 to 10 Volts) */ +LOCAL short ab1771IfeSe_initmsg[IFE_INITMSG_LENGTH] = { + 0xffff, 0xffff, /* 0 to 5 volts (signals 0 - 15) */ + 0x0600, /* signed magnitude - differential */ + 0xffff, 0x0000, /* scaled 0 - 4095 (12 bits) */ + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095 +}; + +typedef struct { + void *drvPvt; + IOSCANPVT ioscanpvt; + unsigned short read_msg_len; + unsigned short *pread_msg; +} devPvt; + +LOCAL void devCallback(void * drvPvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + if(!pdevPvt) return; + scanIoRequest(pdevPvt->ioscanpvt); +} + +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)prec->dpvt; + if(!pdevPvt) return(0); + *ppvt = pdevPvt->ioscanpvt; + return(0); +} + +LOCAL long read_1771Ife(struct aiRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt= (devPvt *)prec->dpvt; + abStatus drvStatus; + struct ab1771Ife_read *pdata; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->getStatus)(pdevPvt->drvPvt); + pdata = (struct ab1771Ife_read *)pdevPvt->pread_msg; + if(drvStatus != abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + prec->rval = pdata->data[pabio->signal]; + if( (pdata->orange & (1 << pabio->signal)) + || (pdata->urange & (1 << pabio->signal)) ) + recGblSetSevr(prec,HW_LIMIT_ALARM,INVALID_ALARM); + return(0); +} + +LOCAL long linconv_1771Ife(struct aiRecord *prec, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + prec->eslo = (prec->eguf -prec->egul)/4095.0; + return(0); +} + +LOCAL long init_1771Ife(struct aiRecord *prec, const char *card_type, + unsigned short *pinit_msg, unsigned short read_size) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + + /* ai.inp must be an AB_IO */ + if (prec->inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, + "devAiAb1771Ife (init_record) Illegal INP field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + prec->eslo = (prec->eguf -prec->egul)/4095.0; + /* pointer to the data addess structure */ + pabio = (struct abio *)&(prec->inp.value); + + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeAi,card_type,devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + pdevPvt->read_msg_len = read_size; + pdevPvt->pread_msg = calloc(read_size,sizeof(unsigned short)); + drvStatus = (*pabDrv->startScan)(drvPvt,IFE_SCAN_RATE, + pinit_msg,IFE_INITMSG_LENGTH,pdevPvt->pread_msg ,read_size); + if(drvStatus!=abSuccess) { + status = S_db_badField; + recGblRecordError(S_db_badField,(void *)prec, + "devAiAb1771Ife (init_record) startScan"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ife (init_record) registerCard"); + break; + } + return(status); +} + +LOCAL long init_1771IfeDiff(struct aiRecord *prec) +{ + return(init_1771Ife(prec,"IFEDIFF",&ab1771IfeDiff_initmsg[0], + IFE_DIFF_READMSG_LENGTH)); +} + +LOCAL long init_1771Ife0to5V(struct aiRecord *prec) +{ + return(init_1771Ife(prec,"IFE0to5V",&ab1771Ife0to5v_initmsg[0], + IFE_DIFF_READMSG_LENGTH)); +} + +LOCAL long init_1771IfeMa(struct aiRecord *prec) +{ + return(init_1771Ife(prec,"IFEMA",&ab1771IfeMa_initmsg[0], + IFE_DIFF_READMSG_LENGTH)); +} + +LOCAL long init_1771IfeSe(struct aiRecord *prec) +{ + return(init_1771Ife(prec,"IFESE",&ab1771IfeSe_initmsg[0], + IFE_SE_READMSG_LENGTH)); +} diff --git a/src/dev/devAB1771IL.c b/src/dev/devAB1771IL.c new file mode 100644 index 000000000..ba7464f17 --- /dev/null +++ b/src/dev/devAB1771IL.c @@ -0,0 +1,195 @@ +/* devAB1771IL.c */ +/* + * Original Author: Bob Dalesio + * Current Author: Bob Dalesio, Marty Kraimer + * Date: 3/6/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 12-01-94 lrd combine the device support that was resident + * in the driver and device support to + significantly reduce the amount of code + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dsets*/ +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt); +LOCAL long init_1771Il(struct aiRecord *prec); +LOCAL long linconv_1771Il(struct aiRecord *prec, int after); +LOCAL long read_1771Il(struct aiRecord *prec); + +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_ai; + DEVSUPFUN special_linconv;} ABAIDSET; + +ABAIDSET devAiAb1771Il={6, 0, 0, init_1771Il, + ioinfo_ai, read_1771Il, linconv_1771Il}; + +#define IL_SCAN_RATE 4 +#define IL_INITMSG_LENGTH 19 +#define IL_READMSG_LENGTH 12 + +#define IL_RANGE 0xffff /* volt inp for all channels -10 - 10V */ +#define IL_DATA_FORMAT 0x600 /* signed magnitude binary */ +struct ab1771il_read { + unsigned short diag; /* diagnostic word */ + unsigned short urange; /* low byte - under range channels */ + unsigned short orange; /* low byte - over range channels */ + unsigned short sign; /* low byte - polarity 1 = negative */ + short data[8]; /* 8 data values (can be signed) */ +}; + +typedef struct { + void *drvPvt; + IOSCANPVT ioscanpvt; + unsigned short read_msg[IL_READMSG_LENGTH]; + unsigned short *pinit_msg; +} devPvt; + +LOCAL unsigned short initMsg[IL_INITMSG_LENGTH] = { + IL_RANGE,IL_DATA_FORMAT,0x0ff, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095, + 0, 0x4095, 0, 0x4095, 0, 0x4095, 0, 0x4095 +}; + +LOCAL void devCallback(void * drvPvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + if(!pdevPvt) return; + scanIoRequest(pdevPvt->ioscanpvt); +} + +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)prec->dpvt; + if(!pdevPvt) return(0); + *ppvt = pdevPvt->ioscanpvt; + return(0); +} + +LOCAL long read_1771Il(struct aiRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt= (devPvt *)prec->dpvt; + abStatus drvStatus; + struct ab1771il_read *pdata; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->getStatus)(pdevPvt->drvPvt); + pdata = (struct ab1771il_read *)&pdevPvt->read_msg[0]; + if(drvStatus != abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + prec->rval = pdata->data[pabio->signal]; + if((pdata->urange&(1<signal)) + || (pdata->orange&(1<signal)) ) + recGblSetSevr(prec,HW_LIMIT_ALARM,INVALID_ALARM); + return(0); +} + +static long linconv_1771Il(struct aiRecord *prec, int after) +{ + + /* set linear conversion slope*/ + prec->eslo = (prec->eguf -prec->egul)/4095.0; + return(0); +} + +LOCAL long init_1771Il(struct aiRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + + /* ai.inp must be an AB_IO */ + if (prec->inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, + "devAiAb1771Il (init_record) Illegal INP field"); + return(S_db_badField); + } + prec->eslo = (prec->eguf -prec->egul)/4095.0; + /* pointer to the data addess structure */ + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeAi,"IL",devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + pdevPvt->pinit_msg = initMsg; + drvStatus = (*pabDrv->startScan)(drvPvt,IL_SCAN_RATE, + pdevPvt->pinit_msg,IL_INITMSG_LENGTH, + &pdevPvt->read_msg[0],IL_READMSG_LENGTH); + if(drvStatus != abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Il (init_record) startScan"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Il (init_record) registerCard"); + break; + } + return(status); +} diff --git a/src/dev/devAB1771IR.c b/src/dev/devAB1771IR.c new file mode 100644 index 000000000..9e573ea9a --- /dev/null +++ b/src/dev/devAB1771IR.c @@ -0,0 +1,216 @@ +/* devAB1771IR.c */ +/* + * Original Author: Bob Dalesio + * Current Author: Bob Dalesio, Marty Kraimer + * Date: 3/6/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 12-01-94 lrd combine the device support that was resident + * in the driver and device support to + significantly reduce the amount of code + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dsets*/ +LOCAL long init_1771Ir(struct aiRecord *prec, const char *card_type, + unsigned short config); +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt); +LOCAL long init_1771IrPlatinum(struct aiRecord *prec); +LOCAL long init_1771IrCopper(struct aiRecord *prec); +LOCAL long read_1771Ir(struct aiRecord *prec); + +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_ai; + DEVSUPFUN special_linconv;} ABAIDSET; + +ABAIDSET devAiAb1771IrPlatinum={6, 0, 0, init_1771IrPlatinum, + ioinfo_ai, read_1771Ir, 0}; +ABAIDSET devAiAb1771IrCopper={6, 0, 0, init_1771IrCopper, + ioinfo_ai, read_1771Ir, 0}; + +#define IR_SCAN_RATE 5 +#define IR_INITMSG_LENGTH 1 +#define IR_READMSG_LENGTH 8 + +/*Register definitions*/ +#define IR_UNITS_DEGF 0x40 +#define IR_UNITS_OHMS 0x80 +#define IR_COPPER 0x100 +#define IR_SIGNED 0x400 + + +struct ab1771Ir_read { + unsigned short status; /* status and over/under range */ + unsigned short pol_over; /* polarity and overflow */ + short data[6]; /* current values */ +}; + +typedef struct { + void *drvPvt; + IOSCANPVT ioscanpvt; + unsigned short read_msg[IR_READMSG_LENGTH]; + unsigned short write_msg; +} devPvt; + +LOCAL void devCallback(void * drvPvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + if(!pdevPvt) return; + scanIoRequest(pdevPvt->ioscanpvt); +} + +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)prec->dpvt; + if(!pdevPvt) return(0); + *ppvt = pdevPvt->ioscanpvt; + return(0); +} + +LOCAL long read_1771Ir(struct aiRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt= (devPvt *)prec->dpvt; + abStatus drvStatus; + struct ab1771Ir_read *pdata; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->getStatus)(pdevPvt->drvPvt); + pdata = (struct ab1771Ir_read *)&pdevPvt->read_msg; + if(drvStatus != abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + }else{ + unsigned short mask; + short value; + unsigned short signal = pabio->signal; + + value = (short)pdata->data[signal]; + if(pdata->pol_over& (0x100<rval = value; + mask = (1 << pabio->signal); + if((pdata->status & (1<status & (0x100<inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, + "devAiAb1771Ir (init_record) Illegal INP field"); + return(S_db_badField); + } + prec->linr = 0; + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeAi,card_type,devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + if(pabio->parm[0]=='C') { + strcpy(prec->egu,"degC"); + } else if(pabio->parm[0]=='O') { + config |= IR_UNITS_OHMS; + strcpy(prec->egu,"ohms"); + } else { + config |= IR_UNITS_DEGF; + strcpy(prec->egu,"degF"); + } + config |= IR_SIGNED; + pdevPvt->write_msg = config; + drvStatus = (*pabDrv->startScan)(drvPvt,IR_SCAN_RATE, + &pdevPvt->write_msg,IR_INITMSG_LENGTH, + pdevPvt->read_msg,IR_READMSG_LENGTH); + if(drvStatus != abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ir (init_record) startScan"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ir (init_record) registerCard"); + break; + } + return(status); +} + +LOCAL long init_1771IrPlatinum(struct aiRecord *prec) +{ + return(init_1771Ir(prec,"IRPLATINUM",0)); +} + +LOCAL long init_1771IrCopper(struct aiRecord *prec) +{ + return(init_1771Ir(prec,"IRCOPPER",IR_COPPER)); +} diff --git a/src/dev/devAB1771IXE.c b/src/dev/devAB1771IXE.c new file mode 100644 index 000000000..eb2410168 --- /dev/null +++ b/src/dev/devAB1771IXE.c @@ -0,0 +1,268 @@ +/* devAB1771IXE.c */ +/* + * Original Author: Bob Dalesio + * Current Author: Bob Dalesio, Marty Kraimer + * Date: 3/6/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 12-01-94 lrd combine the device support that was resident + * in the driver and device support to + significantly reduce the amount of code + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dsets*/ +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt); +LOCAL long init_1771Ixe(struct aiRecord *prec); +LOCAL long linconv_1771Ixe(struct aiRecord *prec, int after); +LOCAL long read_1771Ixe(struct aiRecord *prec); + +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_ai; + DEVSUPFUN special_linconv;} ABAIDSET; + +ABAIDSET devAiAb1771Ixe={6, 0, 0, init_1771Ixe, + ioinfo_ai, read_1771Ixe, linconv_1771Ixe}; + +#define IXE_HALFSEC_RATE 5 +#define IXE_1SEC_RATE 10 +#define IXE_INITMSG_LENGTH 19 +#define IXE_READMSG_LENGTH 12 +#define IXE_NUM_CVTTYPES 14 + +typedef struct { + void *drvPvt; + IOSCANPVT ioscanpvt; + unsigned short init_msg[IXE_INITMSG_LENGTH]; + unsigned short read_msg[IXE_READMSG_LENGTH]; + unsigned short indCvt; +} devPvt; + +/* xxxxxxxxxxxxxTTT - Thermocouple Types */ +#define IXE_MILLI 0x0000 /* Millivolt input */ +#define IXE_E 0x0001 /* "E" Thermocouple */ +#define IXE_J 0x0002 /* "J" Thermocouple */ +#define IXE_K 0x0003 /* "K" Thermocouple */ +#define IXE_T 0x0004 /* "T" Thermocouple */ +#define IXE_R 0x0005 /* "R" Thermocouple */ +#define IXE_S 0x0006 /* "S" Thermocouple */ +/* xxxxxxxCxxxxxxxx - Conversion into degrees F or C */ +#define IXE_DEGC 0x0000 +#define IXE_DEGF 0x0100 +/* xxxxxFFxxxxxxxxx - Data Format */ +#define IXE_SIGNED 0x0400 /* signed magnitude " " */ +/* SSSSSxxxxxxxxxxx - Scan Rate */ +#define IXE_HALFSEC 0x2800 /* sample time = 0.5 seconds */ +#define IXE_1SEC 0x5000 /* sample time = 1.0 seconds */ +#define IXE_2SECS 0xa000 /* sample time = 2.0 seconds */ +#define IXE_3SECS 0xf000 /* sample time = 3.0 seconds */ + +#define IXE_STATUS 0xff +struct ab1771Ixe_read { + unsigned short pol_stat; /* status - polarity word */ + unsigned short out_of_range; /* under - over range channels */ + unsigned short alarms; /* inputs outside alarm limits */ + short data[8]; /* current values */ + unsigned short cjcw; /* cold junction cal word */ +}; + +/*NOTE: The following degfinitions assumes that the allowed convert types +are defined as follows: +K_DGF=2, K_DGC=3, J_DGF=4, J_DGC=5, E_DGF=6, E_DGC=7, T_DGF=8, +T_DGC=9, R_DGF=10, R_DGC=11, S_DGF=12, S_DGC=13, +THIS IS A REAL KLUDGE. WE SHOULD FIND A BETTER WAY */ +LOCAL unsigned short ixe_cvt[IXE_NUM_CVTTYPES] = { + IXE_MILLI | IXE_SIGNED | IXE_HALFSEC, + IXE_MILLI | IXE_SIGNED | IXE_HALFSEC, + IXE_K | IXE_DEGF | IXE_SIGNED | IXE_HALFSEC, + IXE_K | IXE_DEGC | IXE_SIGNED | IXE_HALFSEC, + IXE_J | IXE_DEGF | IXE_SIGNED | IXE_HALFSEC, + IXE_J | IXE_DEGC | IXE_SIGNED | IXE_HALFSEC, + IXE_E | IXE_DEGF | IXE_SIGNED | IXE_HALFSEC, + IXE_E | IXE_DEGC | IXE_SIGNED | IXE_HALFSEC, + IXE_T | IXE_DEGF | IXE_SIGNED | IXE_HALFSEC, + IXE_T | IXE_DEGC | IXE_SIGNED | IXE_HALFSEC, + IXE_R | IXE_DEGF | IXE_SIGNED | IXE_HALFSEC, + IXE_R | IXE_DEGC | IXE_SIGNED | IXE_HALFSEC, + IXE_S | IXE_DEGF | IXE_SIGNED | IXE_HALFSEC, + IXE_S | IXE_DEGC | IXE_SIGNED | IXE_HALFSEC +}; +LOCAL const char* cardName[IXE_NUM_CVTTYPES] = { + "IXE_MV","IXE_MV","IXE_KDEGF","IXE_KDEGC", + "IXE_JDEGF","IXE_JDEGC","IXE_EDEGF","IXE_EDEGC", + "IXE_TDEGF","IXE_TDEGC","IXE_RDEGF","IXE_RDEGC", + "IXS_TDEGF","IXE_SDEGC" +}; +LOCAL unsigned short scanRate[IXE_NUM_CVTTYPES] = { + IXE_HALFSEC_RATE,IXE_HALFSEC_RATE,IXE_HALFSEC_RATE,IXE_HALFSEC_RATE, + IXE_HALFSEC_RATE,IXE_HALFSEC_RATE,IXE_HALFSEC_RATE,IXE_HALFSEC_RATE, + IXE_HALFSEC_RATE,IXE_HALFSEC_RATE, + IXE_HALFSEC_RATE,IXE_HALFSEC_RATE,IXE_HALFSEC_RATE,IXE_HALFSEC_RATE +}; + +LOCAL void devCallback(void * drvPvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + if(!pdevPvt) return; + scanIoRequest(pdevPvt->ioscanpvt); +} + +LOCAL long ioinfo_ai(int cmd,struct aiRecord *prec,IOSCANPVT *ppvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)prec->dpvt; + if(!pdevPvt) return(0); + *ppvt = pdevPvt->ioscanpvt; + return(0); +} + +LOCAL long read_1771Ixe(struct aiRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt= (devPvt *)prec->dpvt; + abStatus drvStatus; + struct ab1771Ixe_read *pdata; + long status; + unsigned short indCvt; + short rval; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + indCvt = pdevPvt->indCvt; + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->getStatus)(pdevPvt->drvPvt); + pdata = (struct ab1771Ixe_read *)&pdevPvt->read_msg[0]; + if(drvStatus != abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + rval = pdata->data[pabio->signal]; + if((pdata->pol_stat&(0x100<signal))) rval = -rval; + if((pdata->out_of_range&(1<signal)) + || (pdata->out_of_range&(0x100<signal)) ) { + recGblSetSevr(prec,HW_LIMIT_ALARM,INVALID_ALARM); + } + if(indCvt!=0) { + prec->val = prec->rval = rval; + prec->udf = FALSE; + status=2; /*don't convert*/ + } else { + prec->rval = rval + 10000; + status = 0; + } + return(status); +} + +static long linconv_1771Ixe(struct aiRecord *prec, int after) +{ + + /* set linear conversion slope*/ + prec->eslo = (prec->eguf -prec->egul)/20000.0; + return(0); +} + +LOCAL long init_1771Ixe(struct aiRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + unsigned short indCvt; + + /* ai.inp must be an AB_IO */ + if (prec->inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, + "devAiAb1771Ixe (init_record) Illegal INP field"); + return(S_db_badField); + } + /*If conversion type is 2,...,IXE_NUM_CVTTYPES Ixe performs the conversion*/ + /* THIS SHOULD BE CHANGED */ + if(prec->linr>=2 && prec->linr linr; + prec->linr = 0; + } else { + indCvt = 0; + } + prec->eslo = (prec->eguf -prec->egul)/20000.0; + /* pointer to the data addess structure */ + pabio = (struct abio *)&(prec->inp.value); + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeAi,cardName[indCvt],devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + pdevPvt->indCvt = indCvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + pdevPvt->init_msg[0] = ixe_cvt[indCvt]; + drvStatus = (*pabDrv->startScan)(drvPvt,scanRate[indCvt], + &pdevPvt->init_msg[0],IXE_INITMSG_LENGTH, + &pdevPvt->read_msg[0],IXE_READMSG_LENGTH); + if(drvStatus != abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ixe (init_record) startScan"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ixe (init_record) registerCard"); + break; + } + return(status); +} diff --git a/src/dev/devAB1771OFE.c b/src/dev/devAB1771OFE.c new file mode 100644 index 000000000..26118b8dc --- /dev/null +++ b/src/dev/devAB1771OFE.c @@ -0,0 +1,196 @@ +/* devAB1771OFE.c */ +/* + * Original Author: Bob Dalesio + * Current Author: Bob Dalesio, Marty Kraimer + * Date: 3/6/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 12-01-94 lrd combine the device support that was resident in the driver and + * device support to significantly reduce the amount of code + * ... + */ + + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dsets*/ +LOCAL long init_1771Ofe(struct aoRecord *pao); +LOCAL long write_1771Ofe(struct aoRecord *pao); +LOCAL long linconv_1771Ofe(struct aoRecord *pao, int after); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_ao; + DEVSUPFUN special_linconv; +}ABAODSET; + +ABAODSET devAoAb1771Ofe={ 6, NULL, NULL, init_1771Ofe, NULL, + write_1771Ofe, linconv_1771Ofe}; + +#define UPDATE_RATE 100 +#define READ_MSG_LEN 5 +#define WRITE_MSG_LEN 5 + + +/* defines and structures for analog outputs */ +/* configuration word 5 for the OFE module */ +/* FxxxHHHHLLLLPPPP */ +/* F - Data Format */ +/* 0x0 specifies BCD */ +/* 0x1 specifies Binary */ +/* HHHH - Max Scaling Polarity */ +/* LLLL - Min Scaling Polarity */ +/* PPPP - Value Polarity */ +#define OFE_BINARY 0x8000 /* talk binary instead of BCD */ +#define OFE_SCALING 0x0000 /* all positive */ + +typedef struct { + void *drvPvt; + unsigned short read_msg[READ_MSG_LEN]; + unsigned short write_msg[WRITE_MSG_LEN]; +}devPvt; + +LOCAL long init_1771Ofe(struct aoRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + int failed; + int i; + + if (prec->out.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, + "devAiAb1771Ife (init_record) Illegal INP field"); + return(S_db_badField); + } + /* set linear conversion slope*/ + prec->eslo = (prec->eguf -prec->egul)/4095.0; + /* pointer to the data addess structure */ + pabio = (struct abio *)&(prec->out.value); + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeAo,"OFE",NULL,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + drvStatus = (*pabDrv->getStatus)(drvPvt); + if(drvStatus==abSuccess) { + prec->rval = (unsigned short)pdevPvt->read_msg[pabio->signal]; + } else { + status = 2; + } + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + pdevPvt->write_msg[4] = OFE_BINARY | OFE_SCALING; + drvStatus = (*pabDrv->startScan)(drvPvt,UPDATE_RATE, + pdevPvt->write_msg,WRITE_MSG_LEN, + pdevPvt->read_msg ,READ_MSG_LEN); + if(drvStatus!=abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ife (init_record) startScan"); + break; + } + /*wait for up to 1 seconds*/ + for(failed=0; failed<10; failed++) { + taskDelay(vxTicksPerSecond/10); + drvStatus = (*pabDrv->getStatus)(drvPvt); + if(drvStatus==abSuccess) { + prec->rval=(unsigned short)pdevPvt->read_msg[pabio->signal]; + for(i=0;i<4;i++) { + pdevPvt->write_msg[i] = pdevPvt->read_msg[i]; + } + write_1771Ofe(prec); + status = 2; + break; + } + } + status = 0; + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec, + "devAiAb1771Ife (init_record) registerCard"); + break; + } + return(status); +} + +LOCAL long write_1771Ofe(struct aoRecord *prec) +{ + struct abio *pabio; + devPvt *pdevPvt = (devPvt *)prec->dpvt; + abStatus drvStatus; + void *drvPvt; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); /*dont convert*/ + } + drvPvt = pdevPvt->drvPvt; + pabio = (struct abio *)&(prec->out.value); + pdevPvt->write_msg[pabio->signal] = prec->rval; + drvStatus = (*pabDrv->updateAo)(drvPvt); + if(drvStatus!=abSuccess) { + if(recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (prec->stat!=WRITE_ALARM || prec->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)prec,"abDrv(updateAo)"); + } + return(0); +} + + +LOCAL long linconv_1771Ofe(struct aoRecord *prec, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + prec->eslo = (prec->eguf -prec->egul)/4095.0; + return(0); +} diff --git a/src/dev/devABBINARY.c b/src/dev/devABBINARY.c new file mode 100644 index 000000000..7ddfed754 --- /dev/null +++ b/src/dev/devABBINARY.c @@ -0,0 +1,617 @@ +/* devABBINARY.c */ +/* + * Original Author: Bob Dalesio + * Current Author: Bob Dalesio, Marty Kraimer + * Date: 3/6/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 12-01-94 lrd combine the device support that was resident in the driver and + * device support to significantly reduce the amount of code + * ... + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + void *drvPvt; + IOSCANPVT ioscanpvt; +}devPvt; + + +/* Create the dsets*/ +LOCAL long ioinfo(int cmd, struct dbCommon *prec, IOSCANPVT *ppvt); +LOCAL long read_bi(struct biRecord *prec); +LOCAL long init_bi08(struct biRecord *prec); +LOCAL long init_bi16(struct biRecord *prec); +LOCAL long init_bi32(struct biRecord *prec); +LOCAL long init_bi(struct biRecord *prec,abNumBits nBits); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_bi;} ABBIDSET; + +ABBIDSET devBiAb= { 5, 0, 0, init_bi08, ioinfo, read_bi}; +ABBIDSET devBiAb16= { 5, 0, 0, init_bi16, ioinfo, read_bi}; +ABBIDSET devBiAb32= { 5, 0, 0, init_bi32, ioinfo, read_bi}; + +LOCAL long read_mbbi(struct mbbiRecord *prec); +LOCAL long init_mbbi08(struct mbbiRecord *prec); +LOCAL long init_mbbi16(struct mbbiRecord *prec); +LOCAL long init_mbbi32(struct mbbiRecord *prec); +LOCAL long init_mbbi(struct mbbiRecord *prec,abNumBits nBits); +ABBIDSET devMbbiAb= { 5, 0, 0, init_mbbi08, ioinfo, read_mbbi}; +ABBIDSET devMbbiAb16={ 5, 0, 0, init_mbbi16, ioinfo, read_mbbi}; +ABBIDSET devMbbiAb32={ 5, 0, 0, init_mbbi32, ioinfo, read_mbbi}; + +LOCAL long read_mbbiDirect(struct mbbiDirectRecord *prec); +LOCAL long init_mbbiDirect08(struct mbbiDirectRecord *prec); +LOCAL long init_mbbiDirect16(struct mbbiDirectRecord *prec); +LOCAL long init_mbbiDirect32(struct mbbiDirectRecord *prec); +LOCAL long init_mbbiDirect(struct mbbiDirectRecord *prec,abNumBits nBits); +ABBIDSET devMbbiDirectAb= { 5,0,0, init_mbbiDirect08,ioinfo, read_mbbiDirect}; +ABBIDSET devMbbiDirectAb16={ 5,0,0, init_mbbiDirect16,ioinfo, read_mbbiDirect}; +ABBIDSET devMbbiDirectAb32={ 5,0,0, init_mbbiDirect32,ioinfo, read_mbbiDirect}; + +LOCAL long write_bo(struct boRecord *prec); +LOCAL long init_bo08(struct boRecord *prec); +LOCAL long init_bo16(struct boRecord *prec); +LOCAL long init_bo32(struct boRecord *prec); +LOCAL long init_bo(struct boRecord *prec,abNumBits nBits); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_bo; +} ABBODSET; + +ABBODSET devBoAb= { 5, 0, 0, init_bo08, 0, write_bo}; +ABBODSET devBoAb16= { 5, 0, 0, init_bo16, 0, write_bo}; +ABBODSET devBoAb32= { 5, 0, 0, init_bo32, 0, write_bo}; + +LOCAL long write_mbbo(struct mbboRecord *prec); +LOCAL long init_mbbo08(struct mbboRecord *prec); +LOCAL long init_mbbo16(struct mbboRecord *prec); +LOCAL long init_mbbo32(struct mbboRecord *prec); +LOCAL long init_mbbo(struct mbboRecord *prec,abNumBits nBits); +ABBODSET devMbboAb= { 5, 0, 0, init_mbbo08, 0, write_mbbo}; +ABBODSET devMbboAb16={ 5, 0, 0, init_mbbo16, 0, write_mbbo}; +ABBODSET devMbboAb32={ 5, 0, 0, init_mbbo32, 0, write_mbbo}; + +LOCAL long write_mbboDirect(struct mbboDirectRecord *prec); +LOCAL long init_mbboDirect08(struct mbboDirectRecord *prec); +LOCAL long init_mbboDirect16(struct mbboDirectRecord *prec); +LOCAL long init_mbboDirect32(struct mbboDirectRecord *prec); +LOCAL long init_mbboDirect(struct mbboDirectRecord *prec,abNumBits nBits); +ABBODSET devMbboDirectAb= { 5, 0, 0, init_mbboDirect08, 0, write_mbboDirect}; +ABBODSET devMbboDirectAb16={ 5, 0, 0, init_mbboDirect16, 0, write_mbboDirect}; +ABBODSET devMbboDirectAb32={ 5, 0, 0, init_mbboDirect32, 0, write_mbboDirect}; + +LOCAL void devCallback(void * drvPvt) +{ + devPvt *pdevPvt; + + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + if(!pdevPvt) return; + if(!pdevPvt->ioscanpvt) return; + scanIoRequest(pdevPvt->ioscanpvt); +} + +LOCAL long ioinfo(int cmd, struct dbCommon *prec, IOSCANPVT *ppvt) +{ + devPvt *pdevPvt; + + pdevPvt = prec->dpvt; + if(!pdevPvt) return(0); + *ppvt = pdevPvt->ioscanpvt; + return(0); +} +LOCAL long init_bi08(struct biRecord *prec) +{ + return(init_bi(prec, abBit8)); +} +LOCAL long init_bi16(struct biRecord *prec) +{ + return(init_bi(prec, abBit16)); +} +LOCAL long init_bi32(struct biRecord *prec) +{ + return(init_bi(prec, abBit32)); +} + +LOCAL long init_mbbi08(struct mbbiRecord *prec) +{ + return(init_mbbi(prec, abBit8)); +} +LOCAL long init_mbbi16(struct mbbiRecord *prec) +{ + return(init_mbbi(prec, abBit16)); +} +LOCAL long init_mbbi32(struct mbbiRecord *prec) +{ + return(init_mbbi(prec, abBit32)); +} + +LOCAL long init_mbbiDirect08(struct mbbiDirectRecord *prec) +{ + return(init_mbbiDirect(prec, abBit8)); +} +LOCAL long init_mbbiDirect16(struct mbbiDirectRecord *prec) +{ + return(init_mbbiDirect(prec, abBit16)); +} +LOCAL long init_mbbiDirect32(struct mbbiDirectRecord *prec) +{ + return(init_mbbiDirect(prec, abBit32)); +} + +LOCAL long init_bo08(struct boRecord *prec) +{ + return(init_bo(prec, abBit8)); +} +LOCAL long init_bo16(struct boRecord *prec) +{ + return(init_bo(prec, abBit16)); +} +LOCAL long init_bo32(struct boRecord *prec) +{ + return(init_bo(prec, abBit32)); +} + +LOCAL long init_mbbo08(struct mbboRecord *prec) +{ + return(init_mbbo(prec, abBit8)); +} +LOCAL long init_mbbo16(struct mbboRecord *prec) +{ + return(init_mbbo(prec, abBit16)); +} +LOCAL long init_mbbo32(struct mbboRecord *prec) +{ + return(init_mbbo(prec, abBit32)); +} + +LOCAL long init_mbboDirect08(struct mbboDirectRecord *prec) +{ + return(init_mbboDirect(prec, abBit8)); +} +LOCAL long init_mbboDirect16(struct mbboDirectRecord *prec) +{ + return(init_mbboDirect(prec, abBit16)); +} +LOCAL long init_mbboDirect32(struct mbboDirectRecord *prec) +{ + return(init_mbboDirect(prec, abBit32)); +} + +LOCAL long read_bi(struct biRecord *prec) +{ + devPvt *pdevPvt = (devPvt *)prec->dpvt; + void *drvPvt; + abStatus drvStatus; + unsigned long value; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); + } + drvPvt = pdevPvt->drvPvt; + drvStatus = (*pabDrv->readBi)(drvPvt,&value,prec->mask); + if(drvStatus!=abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); + } + prec->rval = value; + return(0); +} +LOCAL long init_bi(struct biRecord *prec,abNumBits nBits) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + + if (prec->inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, + "init_record: bad INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(prec->inp.value); + prec->mask=1; + prec->mask <<= pabio->signal; + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeBi,"BINARY",devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + drvStatus = (*pabDrv->setNbits)(drvPvt,nBits); + if(drvStatus!=abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record setNbits"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record registerCard"); + break; + } + return(status); +} + +LOCAL long read_mbbi(struct mbbiRecord *prec) +{ + devPvt *pdevPvt = (devPvt *)prec->dpvt; + void *drvPvt; + abStatus drvStatus; + unsigned long value; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); + } + drvPvt = pdevPvt->drvPvt; + drvStatus = (*pabDrv->readBi)(drvPvt,&value,prec->mask); + if(drvStatus!=abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); + } + prec->rval = value; + return(0); +} +LOCAL long init_mbbi(struct mbbiRecord *prec,abNumBits nBits) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + + if (prec->inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, "Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(prec->inp.value); + prec->shft = prec->inp.value.abio.signal; + prec->mask <<= prec->shft; + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeBi,"BINARY",devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + drvStatus = (*pabDrv->setNbits)(drvPvt,nBits); + if(drvStatus!=abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record setNbits"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record registerCard"); + break; + } + return(status); +} + +LOCAL long read_mbbiDirect(struct mbbiDirectRecord *prec) +{ + devPvt *pdevPvt = (devPvt *)prec->dpvt; + void *drvPvt; + abStatus drvStatus; + unsigned long value; + + if(!pdevPvt) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); + } + drvPvt = pdevPvt->drvPvt; + drvStatus = (*pabDrv->readBi)(drvPvt,&value,prec->mask); + if(drvStatus!=abSuccess) { + recGblSetSevr(prec,READ_ALARM,INVALID_ALARM); + return(2); + } + prec->rval = value; + return(0); +} +LOCAL long init_mbbiDirect(struct mbbiDirectRecord *prec,abNumBits nBits) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + + if (prec->inp.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, "Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(prec->inp.value); + prec->shft = prec->inp.value.abio.signal; + prec->mask <<= prec->shft; + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeBi,"BINARY",devCallback,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + scanIoInit(&pdevPvt->ioscanpvt); + drvStatus = (*pabDrv->setNbits)(drvPvt,nBits); + if(drvStatus!=abSuccess) { + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record setNbits"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record registerCard"); + break; + } + return(status); +} + +LOCAL long write_bo(struct boRecord *prec) +{ + devPvt *pdevPvt = (devPvt *)prec->dpvt; + void *drvPvt; + abStatus drvStatus; + + if(!pdevPvt) { + recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM); + return(0); + } + drvPvt = pdevPvt->drvPvt; + drvStatus = (*pabDrv->updateBo)(drvPvt,prec->rval,prec->mask); + if(drvStatus!=abSuccess) { + recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM); + } + return(0); +} +LOCAL long init_bo(struct boRecord *prec,abNumBits nBits) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + unsigned long value; + + if (prec->out.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, "Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(prec->out.value); + prec->mask = 1; + prec->mask <<= pabio->signal; + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeBo,"BINARY",NULL,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + drvStatus = (*pabDrv->setNbits)(drvPvt,nBits); + if(drvStatus!=abSuccess) { + recGblRecordError(S_db_badField,(void *)prec, + "init_record setNbits"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record registerCard"); + return(status); + } + drvStatus = (*pabDrv->readBo)(drvPvt,&value,prec->mask); + if(drvStatus==abSuccess) { + prec->rval = value; + status = 0; + } else { + status = 2; + } + return(status); +} + +LOCAL long write_mbbo(struct mbboRecord *prec) +{ + devPvt *pdevPvt = (devPvt *)prec->dpvt; + void *drvPvt; + abStatus drvStatus; + + if(!pdevPvt) { + recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM); + return(0); + } + drvPvt = pdevPvt->drvPvt; + drvStatus = (*pabDrv->updateBo)(drvPvt,prec->rval,prec->mask); + if(drvStatus!=abSuccess) { + recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM); + } + return(0); +} +LOCAL long init_mbbo(struct mbboRecord *prec,abNumBits nBits) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + unsigned long value; + + if (prec->out.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, "Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(prec->out.value); + prec->shft = prec->out.value.abio.signal; + prec->mask <<= prec->shft; + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeBo,"BINARY",NULL,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + drvStatus = (*pabDrv->setNbits)(drvPvt,nBits); + if(drvStatus!=abSuccess) { + recGblRecordError(S_db_badField,(void *)prec, + "init_record setNbits"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record registerCard"); + return(status); + } + drvStatus = (*pabDrv->readBo)(drvPvt,&value,prec->mask); + if(drvStatus==abSuccess) { + prec->rval = value; + status = 0; + } else { + status = 2; + } + return(status); +} + +LOCAL long write_mbboDirect(struct mbboDirectRecord *prec) +{ + devPvt *pdevPvt = (devPvt *)prec->dpvt; + void *drvPvt; + abStatus drvStatus; + unsigned long value = prec->rval; + + if(!pdevPvt) { + recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM); + return(0); + } + drvPvt = pdevPvt->drvPvt; + drvStatus = (*pabDrv->updateBo)(drvPvt,value,prec->mask); + if(drvStatus!=abSuccess) { + recGblSetSevr(prec,WRITE_ALARM,INVALID_ALARM); + } + return(0); +} +LOCAL long init_mbboDirect(struct mbboDirectRecord *prec,abNumBits nBits) +{ + struct abio *pabio; + devPvt *pdevPvt; + abStatus drvStatus; + long status=0; + void *drvPvt; + unsigned long value; + + if (prec->out.type != AB_IO){ + recGblRecordError(S_db_badField,(void *)prec, "Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(prec->out.value); + prec->shft = prec->out.value.abio.signal; + prec->mask <<= prec->shft; + drvStatus = (*pabDrv->registerCard)(pabio->link,pabio->adapter, + pabio->card,typeBo,"BINARY",NULL,&drvPvt); + switch(drvStatus) { + case abSuccess : + pdevPvt = (devPvt *)(*pabDrv->getUserPvt)(drvPvt); + prec->dpvt = pdevPvt; + break; + case abNewCard : + pdevPvt = calloc(1,sizeof(devPvt)); + pdevPvt->drvPvt = drvPvt; + prec->dpvt = pdevPvt; + (*pabDrv->setUserPvt)(drvPvt,(void *)pdevPvt); + drvStatus = (*pabDrv->setNbits)(drvPvt,nBits); + if(drvStatus!=abSuccess) { + recGblRecordError(S_db_badField,(void *)prec, + "init_record setNbits"); + } + break; + default: + status = S_db_badField; + recGblRecordError(status,(void *)prec,"init_record registerCard"); + return(status); + } + drvStatus = (*pabDrv->readBo)(drvPvt,&value,prec->mask); + if(drvStatus==abSuccess) { + prec->rval = value; + status = 0; + } else { + status = 2; + } + return(status); +} diff --git a/src/dev/devAllenBradleyOLD.c b/src/dev/devAllenBradleyOLD.c new file mode 100644 index 000000000..2bf0d8d35 --- /dev/null +++ b/src/dev/devAllenBradleyOLD.c @@ -0,0 +1,1377 @@ +/* devAllenBradley.c */ +/* base/src/dev $Id$ */ + +/* devAllenBradley.c - Device Support Routines for Allen Bradley*/ +/* + * Original Author: Bob Dalesio + * Current Author: Marty Kraimer + * Date: 3/6/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 08-27-92 mrk Combined all Allen Bradley devive support + * .02 02-08-94 mrk Issue Hardware Errors BUT prevent Error Message Storms + * .03 03-30-94 mcn support for devMbboDirect and devMbbiDirect + * .04 04-13-94 mrk Fixed IXE problems + * ... + */ + + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Create the dsets*/ +static long init_1771Ife(); +static long read_1771Ife(); +static long linconv_1771Ife(); +static long init_1771Ife0to5V(); +static long read_1771Ife0to5V(); +static long linconv_1771Ife0to5V(); +static long init_1771IfeMa(); +static long read_1771IfeMa(); +static long linconv_1771IfeMa(); +static long init_1771IfeSe(); +static long read_1771IfeSe(); +static long linconv_1771IfeSe(); +static long init_1771Il(); +static long read_1771Il(); +static long linconv_1771Il(); +static long init_1771Ixe(); +static long read_1771Ixe(); +static long linconv_1771Ixe(); +static long init_1771IrPlatinum(); +static long read_1771IrPlatinum(); +static long init_1771IrCopper(); +static long read_1771IrCopper(); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_ai; + DEVSUPFUN special_linconv;} ABAIDSET; +ABAIDSET devAiAb1771Ife= {6, NULL, NULL, init_1771Ife, NULL, + read_1771Ife, linconv_1771Ife}; +ABAIDSET devAiAb1771Ife0to5V= {6, NULL, NULL, init_1771Ife0to5V,NULL, + read_1771Ife0to5V, linconv_1771Ife0to5V}; +ABAIDSET devAiAb1771IfeMa= {6, NULL, NULL, init_1771IfeMa,NULL, + read_1771IfeMa, linconv_1771IfeMa}; +ABAIDSET devAiAb1771IfeSe= {6, NULL, NULL, init_1771IfeSe, NULL, + read_1771IfeSe, linconv_1771IfeSe}; +ABAIDSET devAiAb1771Il= {6, NULL, NULL, init_1771Il, NULL, + read_1771Il, linconv_1771Il}; +ABAIDSET devAiAb1771Ixe= {6, NULL, NULL, init_1771Ixe, NULL, + read_1771Ixe, linconv_1771Ixe}; +ABAIDSET devAiAb1771IrPlatinum= {6, NULL, NULL, init_1771IrPlatinum, NULL, + read_1771IrPlatinum, NULL}; +ABAIDSET devAiAb1771IrCopper= {6, NULL, NULL, init_1771IrCopper, NULL, + read_1771IrCopper, NULL}; + +static long init_1771Ofe(); +static int read_1771Ofe(); +static long write_1771Ofe(); +static long linconv_1771Ofe(); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_ao; + DEVSUPFUN special_linconv;} ABAODSET; +ABAIDSET devAoAb1771Ofe={ 6, NULL, NULL, init_1771Ofe, NULL, + write_1771Ofe, linconv_1771Ofe}; + +static long init_bi(); +static long ioinfo_bi(); +static long read_bi(); +static long init_bi16(); +static long ioinfo_bi16(); +static long read_bi16(); +static long init_mbbi(); +static long init_mbbiDirect(); +static long ioinfo_mbbi(); +static long ioinfo_mbbiDirect(); +static long read_mbbi(); +static long read_mbbiDirect(); +static long init_mbbi16(); +static long init_mbbiDirect16(); +static long ioinfo_mbbi16(); +static long ioinfo_mbbiDirect16(); +static long read_mbbi16(); +static long read_mbbiDirect16(); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN read_bi;} ABBIDSET; + +ABBIDSET devBiAb={ 5, NULL, NULL, init_bi, ioinfo_bi, read_bi}; +ABBIDSET devBiAb16={ 5, NULL, NULL, init_bi16, ioinfo_bi16, read_bi16}; +ABBIDSET devMbbiAb={ 5, NULL, NULL, init_mbbi, ioinfo_mbbi, read_mbbi}; +ABBIDSET devMbbiDirectAb={ 5, NULL, NULL, init_mbbiDirect, ioinfo_mbbiDirect, read_mbbiDirect}; +ABBIDSET devMbbiAb16={ 5, NULL, NULL, init_mbbi16, ioinfo_mbbi16, read_mbbi16}; +ABBIDSET devMbbiDirectAb16={ 5, NULL, NULL, init_mbbiDirect16, ioinfo_mbbiDirect16, read_mbbiDirect16}; + +static long init_bo(); +static long write_bo(); +static long init_bo16(); +static long write_bo16(); +static long init_mbbo(); +static long init_mbboDirect(); +static long write_mbbo(); +static long write_mbboDirect(); +static long init_mbbo16(); +static long init_mbboDirect16(); +static long write_mbbo16(); +static long write_mbboDirect16(); +typedef struct { + long number; + DEVSUPFUN report; + DEVSUPFUN init; + DEVSUPFUN init_record; + DEVSUPFUN get_ioint_info; + DEVSUPFUN write_bo;} ABBODSET; + +ABBODSET devBoAb={ 5, NULL, NULL, init_bo, NULL, write_bo}; +ABBODSET devBoAb16={ 5, NULL, NULL, init_bo16, NULL, write_bo16}; +ABBODSET devMbboAb={ 5, NULL, NULL, init_mbbo, NULL, write_mbbo}; +ABBODSET devMbboDirectAb={ 5, NULL, NULL, init_mbboDirect, NULL, write_mbboDirect}; +ABBODSET devMbboAb16={ 5, NULL, NULL, init_mbbo16, NULL, write_mbbo16}; +ABBODSET devMbboDirectAb16={ 5, NULL, NULL, init_mbboDirect16, NULL, write_mbboDirect16}; + + +static long init_1771Ife(struct aiRecord *pai) +{ + unsigned short value; + struct abio *pabio; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771Ife (init_record) Illegal INP field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + pabio = (struct abio *)&(pai->inp.value); + ab_aidriver(AB1771IFE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + return(0); +} + +static long read_1771Ife(struct aiRecord *pai) +{ + struct abio *pabio; + int status; + unsigned short value; + + + pabio = (struct abio *)&(pai->inp.value); + status = ab_aidriver(AB1771IFE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + if(status==0 || status==-2) pai->rval = value; + if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status=2; /*dont convert*/ + }else if(status==-2) { + status=0; + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + } + return(status); +} + + +static long linconv_1771Ife(struct aiRecord *pai, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + return(0); +} + +static long init_1771Ife0to5V(struct aiRecord *pai) +{ + unsigned short value; + struct abio *pabio; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771Ife0to5V (init_record) Illegal INP field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + pabio = (struct abio *)&(pai->inp.value); + ab_aidriver(AB1771IFE_0to5V,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + return(0); +} + +static long read_1771Ife0to5V(struct aiRecord *pai) +{ + struct abio *pabio; + int status; + unsigned short value; + + + pabio = (struct abio *)&(pai->inp.value); + status=ab_aidriver(AB1771IFE_0to5V,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + if(status==0 || status==-2) pai->rval = value; + if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status=2; /*dont convert*/ + }else if(status==-2) { + status=0; + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + } + return(status); +} + + +static long linconv_1771Ife0to5V(struct aiRecord *pai, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + return(0); +} + +static long init_1771IfeMa(struct aiRecord *pai) +{ + unsigned short value; + struct abio *pabio; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771IfeMa (init_record) Illegal INP field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + pabio = (struct abio *)&(pai->inp.value); + ab_aidriver(AB1771IFE_4to20MA,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + return(0); +} + +static long read_1771IfeMa(struct aiRecord *pai) +{ + struct abio *pabio; + int status; + unsigned short value; + + + pabio = (struct abio *)&(pai->inp.value); + status=ab_aidriver(AB1771IFE_4to20MA,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + if(status==0 || status==-2) pai->rval = value; + if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status=2; /*dont convert*/ + }else if(status==-2) { + status=0; + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + } + return(status); +} + + +static long linconv_1771IfeMa(struct aiRecord *pai, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + return(0); +} + +static long init_1771IfeSe(struct aiRecord *pai) +{ + unsigned short value; + struct abio *pabio; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771IfeSe (init_record) Illegal INP field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + pabio = (struct abio *)&(pai->inp.value); + ab_aidriver(AB1771IFE_SE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + return(0); +} + +static long read_1771IfeSe(struct aiRecord *pai) +{ + struct abio *pabio; + int status; + unsigned short value; + + + pabio = (struct abio *)&(pai->inp.value); + status = ab_aidriver(AB1771IFE_SE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + if(status==0 || status==-2) pai->rval = value; + if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status = 2; /*don`t convert*/ + }else if(status==-2) { + status=0; + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + } + return(status); +} + + +static long linconv_1771IfeSe(struct aiRecord *pai, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + return(0); +} + +static long init_1771Il(struct aiRecord *pai) +{ + unsigned short value; + struct abio *pabio; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771Il (init_record) Illegal INP field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + pabio = (struct abio *)&(pai->inp.value); + ab_aidriver(AB1771IL,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + return(0); +} + +static long read_1771Il(struct aiRecord *pai) +{ + struct abio *pabio; + int status; + unsigned short value; + + + pabio = (struct abio *)&(pai->inp.value); + status = ab_aidriver(AB1771IL,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,pai->linr); + if(status==0 || status==-2) pai->rval = value; + if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status = 2; /*don't convert*/ + }else if(status==-2) { + status=0; + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + } + return(status); +} + +static long linconv_1771Il(struct aiRecord *pai, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/4095.0; + return(0); +} + +static long init_1771Ixe(struct aiRecord *pai) +{ + short value; + struct abio *pabio; + short linr; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771Ixe (init_record) Illegal INP field"); + return(S_db_badField); + } + + + /* If conversion type is 2,...,13 the Ixe performs the conversion*/ + /* In this case lets set linr = no conversion and use lbrk to tell*/ + /* allen bradley driver the correct conversion. */ + /* THIS SHOULD BE CHANGED */ + linr=pai->linr; + if(linr==0 || linr>13 ) { + pai->eslo=0.0; + pai->lbrk=0; + } + else if (linr==1) { + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/20000.0; + } + else if( linr>=2 && linr<=13 ) { + pai->linr=0; /* make sure record processing routine does not convert*/ + pai->lbrk=linr; + } + + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + pabio = (struct abio *)&(pai->inp.value); + linr=pai->linr; + if(linr==0) linr=pai->lbrk; + ab_aidriver(AB1771IXE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,linr); + return(0); +} + +static long read_1771Ixe(struct aiRecord *pai) +{ + short linr; + struct abio *pabio; + long status; + short value; + + + linr=pai->linr; + if(linr==0) linr=pai->lbrk; + else if(linr>13) linr = 0; /*use breakpoint table*/ + pabio = (struct abio *)&(pai->inp.value); + status=ab_aidriver(AB1771IXE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,linr); + if(status==-2) { + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + status = 0; + } + if(status==0) { + if(linr<=1)pai->rval = value + 10000; + else { + pai->val = value; + pai->udf = FALSE; + status=2; /*don't convert*/ + } + } else if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status = 2; /*don't convert*/ + } + return(status); +} + +static long linconv_1771Ixe(struct aiRecord *pai, int after) +{ + short lbrk = pai->lbrk; + + if(lbrk>=2 && lbrk<=13) { + recGblRecordError(S_db_badField,(void *)pai,"DSET: special_linconv"); + return(S_db_badField); + } + if(!after) return(0); + /* set linear conversion slope*/ + pai->eslo = (pai->eguf -pai->egul)/20000.0; + return(0); +} + +static long init_1771IrPlatinum(struct aiRecord *pai) +{ + short value; + struct abio *pabio; + short conversion; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771IrPlatinum (init_record) Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(pai->inp.value); + if(pabio->parm[0]=='C') { + conversion=IR_degC; + strcpy(pai->egu,"degC"); + } else if(pabio->parm[0]=='O') { + conversion = IR_Ohms; + strcpy(pai->egu,"ohms"); + } else { + conversion = 0; + strcpy(pai->egu,"degF"); + } + pai->linr = 0; + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + ab_aidriver(AB1771IrPlatinum,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,conversion); + return(0); +} + +static long read_1771IrPlatinum(struct aiRecord *pai) +{ + struct abio *pabio; + long status; + short value; + short conversion; + + + pabio = (struct abio *)&(pai->inp.value); + if(pabio->parm[0]=='C') conversion=IR_degC; + else if(pabio->parm[0]=='O') conversion = IR_Ohms; + else conversion = 0; + status=ab_aidriver(AB1771IrPlatinum,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,conversion); + if(status==-2) { + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + status = 0; + } + if(status==0) { + if(conversion==IR_Ohms) pai->val = ((double)value)/100.0; + else pai->val = ((double)value)/10.0; + pai->udf = FALSE; + status=2; /*don't convert*/ + } else if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status = 2; /*don't convert*/ + } + return(status); +} + +static long init_1771IrCopper(struct aiRecord *pai) +{ + short value; + struct abio *pabio; + short conversion; + + /* ai.inp must be an AB_IO */ + switch (pai->inp.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pai, + "devAiAb1771IrCopper (init_record) Illegal INP field"); + return(S_db_badField); + } + pabio = (struct abio *)&(pai->inp.value); + if(pabio->parm[0]=='C') { + conversion=IR_degC; + strcpy(pai->egu,"degC"); + } else if(pabio->parm[0]=='O') { + conversion = IR_Ohms; + strcpy(pai->egu,"ohms"); + } else { + conversion = 0; + strcpy(pai->egu,"degF"); + } + pai->linr = 0; + /* call driver so that it configures card */ + /* The driver returns error for first call for a card. Ignore it. */ + ab_aidriver(AB1771IrCopper,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,conversion); + return(0); +} + +static long read_1771IrCopper(struct aiRecord *pai) +{ + struct abio *pabio; + long status; + short value; + short conversion; + + + pabio = (struct abio *)&(pai->inp.value); + if(pabio->parm[0]=='C') conversion=IR_degC; + else if(pabio->parm[0]=='O') conversion = IR_Ohms; + else conversion = 0; + status=ab_aidriver(AB1771IrCopper,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value,conversion); + if(status==-2) { + recGblSetSevr(pai,HW_LIMIT_ALARM,INVALID_ALARM); + status = 0; + } + if(status==0) { + if(conversion==IR_Ohms) pai->val = ((double)value)/100.0; + else pai->val = ((double)value)/10.0; + pai->udf = FALSE; + status=2; /*don't convert*/ + } else if(status==-1) { + if(recGblSetSevr(pai,READ_ALARM,INVALID_ALARM) && errVerbose + && (pai->stat!=READ_ALARM || pai->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pai,"ab_aidriver Error"); + status = 2; /*don't convert*/ + } + return(status); +} + +static long init_1771Ofe(struct aoRecord *pao) +{ + + /* ao.out must be an AB_IO */ + switch (pao->out.type) { + case (AB_IO) : + break; + default : + recGblRecordError(S_db_badField,(void *)pao, + "devAoAb1771Ofe (init_record) Illegal OUT field"); + return(S_db_badField); + } + + /* set linear conversion slope*/ + pao->eslo = (pao->eguf -pao->egul)/4095.0; + + /* call driver so that it configures card */ + if (read_1771Ofe(pao)==0) return(0); + else return(2); + return(0); +} + +static long write_1771Ofe(struct aoRecord *pao) +{ + struct abio *pabio; + int status; + int value; + + pabio = (struct abio *)&(pao->out.value); + value = pao->rval; + status = ab_aodriver(AB1771OFE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,value); + if(status==-1) { + if(recGblSetSevr(pao,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pao->stat!=WRITE_ALARM || pao->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pao,"ab_aodriver Error"); + }else if(status==-2) { + status=0; + recGblSetSevr(pao,HW_LIMIT_ALARM,INVALID_ALARM); + } + return(0); +} + + +static long linconv_1771Ofe(struct aoRecord *pao, int after) +{ + + if(!after) return(0); + /* set linear conversion slope*/ + pao->eslo = (pao->eguf -pao->egul)/4095.0; + return(0); +} + +static int read_1771Ofe(pao) +struct aoRecord *pao; +{ + unsigned short value; + struct abio *pabio = &pao->out.value.abio; + short failed; + + /* get the value from the ao driver */ + /* if this is the first channel on the card being read, */ + /* the block transfer from the ever so wonderful, Allen */ + /* Bradley IO, will not be ready. So we wait. The read */ + /* should only fail when the first channel on the card */ + /* is accessed. It typically fails only once. */ + failed = 0; + while ((ab_aoread(AB1771OFE,pabio->link,pabio->adapter, + pabio->card,pabio->signal,pabio->plc_flag,&value) < 0) + && (failed < 3)){ + failed++; + taskDelay(10); + } + if (failed >= 3) { + recGblSetSevr(pao,READ_ALARM,INVALID_ALARM); + return(-1); + } + pao->rval = value; + return(0); +} + +static long init_bi(struct biRecord *pbi) +{ + struct abio *pabio; + + /* bi.inp must be an AB_IO */ + switch (pbi->inp.type) { + case (AB_IO) : + pabio = (struct abio *)&(pbi->inp.value); + pbi->mask=1; + pbi->mask <<= pabio->signal; + break; + default : + recGblRecordError(S_db_badField,(void *)pbi, + "devBiAb (init_record) Illegal INP field"); + return(S_db_badField); + } + return(0); +} + +static long ioinfo_bi( + int cmd, + struct biRecord *pbi, + IOSCANPVT *ppvt) +{ + struct abio *pabio; + long value; + + pabio = (struct abio *)&(pbi->inp.value); + ab_bi_getioscanpvt(pabio->link,pabio->adapter,pabio->card,ppvt); + /*call ab_bidriver so that it knows it has a binary input*/ + if(cmd==0) { + (void) ab_bidriver(ABBI_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pbi->mask,&value); + } + return(0); +} + +static long read_bi(struct biRecord *pbi) +{ + struct abio *pabio; + int status; + long value; + + + pabio = (struct abio *)&(pbi->inp.value); + status = ab_bidriver(ABBI_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pbi->mask,&value); + if(status==0) { + pbi->rval = value; + return(0); + } else { + if(recGblSetSevr(pbi,READ_ALARM,INVALID_ALARM) && errVerbose + && (pbi->stat!=READ_ALARM || pbi->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pbi,"ab_bidriver Error"); + return(2); + } +} + +static long init_bi16(struct biRecord *pbi) +{ + struct abio *pabio; + + /* bi.inp must be an AB_IO */ + switch (pbi->inp.type) { + case (AB_IO) : + pabio = (struct abio *)&(pbi->inp.value); + pbi->mask=1; + pbi->mask <<= pabio->signal; + break; + default : + recGblRecordError(S_db_badField,(void *)pbi, + "devBiAb16 (init_record) Illegal INP field"); + return(S_db_badField); + } + return(0); +} + +static long ioinfo_bi16( + int cmd, + struct biRecord *pbi, + IOSCANPVT *ppvt) +{ + struct abio *pabio; + long value; + + pabio = (struct abio *)&(pbi->inp.value); + ab_bi_getioscanpvt(pabio->link,pabio->adapter,pabio->card,ppvt); + /*call ab_bidriver so that it knows it has a binary input*/ + if(cmd==0) { + (void) ab_bidriver(ABBI_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pbi->mask,&value); + } + return(0); +} + +static long read_bi16(struct biRecord *pbi) +{ + struct abio *pabio; + int status; + long value; + + + pabio = (struct abio *)&(pbi->inp.value); + status = ab_bidriver(ABBI_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pbi->mask,&value); + if(status==0) { + pbi->rval = value; + return(0); + } else { + if(recGblSetSevr(pbi,READ_ALARM,INVALID_ALARM) && errVerbose + && (pbi->stat!=READ_ALARM || pbi->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pbi,"ab_bidriver Error"); + return(2); + } +} + +static long init_mbbi(struct mbbiRecord *pmbbi) +{ + + /* mbbi.inp must be an AB_IO */ + switch (pmbbi->inp.type) { + case (AB_IO) : + pmbbi->shft = pmbbi->inp.value.abio.signal; + pmbbi->mask <<= pmbbi->shft; + break; + default : + recGblRecordError(S_db_badField,(void *)pmbbi, + "devMbbiAb (init_record) Illegal INP field"); + return(S_db_badField); + } + return(0); +} + +static long ioinfo_mbbi( + int cmd, + struct mbbiRecord *pmbbi, + IOSCANPVT *ppvt) +{ + struct abio *pabio; + unsigned long value; + + pabio = (struct abio *)&(pmbbi->inp.value); + ab_bi_getioscanpvt(pabio->link,pabio->adapter,pabio->card,ppvt); + /*call ab_bidriver so that it knows it has a binary input*/ + if(cmd==0) { + (void) ab_bidriver(ABBI_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + } + return(0); +} + +static long read_mbbi(struct mbbiRecord *pmbbi) +{ + struct abio *pabio; + int status; + unsigned long value; + + + pabio = (struct abio *)&(pmbbi->inp.value); + status = ab_bidriver(ABBI_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + if(status==0) { + pmbbi->rval = value; + return(0); + } else { + if(recGblSetSevr(pmbbi,READ_ALARM,INVALID_ALARM) && errVerbose + && (pmbbi->stat!=READ_ALARM || pmbbi->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbi,"ab_bidriver Error"); + return(2); + } +} + +static long init_mbbiDirect(struct mbbiDirectRecord *pmbbi) +{ + + /* mbbi.inp must be an AB_IO */ + switch (pmbbi->inp.type) { + case (AB_IO) : + pmbbi->shft = pmbbi->inp.value.abio.signal; + pmbbi->mask <<= pmbbi->shft; + break; + default : + recGblRecordError(S_db_badField,(void *)pmbbi, + "devMbbiDirectAb (init_record) Illegal INP field"); + return(S_db_badField); + } + return(0); +} + +static long ioinfo_mbbiDirect( + int cmd, + struct mbbiDirectRecord *pmbbi, + IOSCANPVT *ppvt) +{ + struct abio *pabio; + unsigned long value; + + pabio = (struct abio *)&(pmbbi->inp.value); + ab_bi_getioscanpvt(pabio->link,pabio->adapter,pabio->card,ppvt); + /*call ab_bidriver so that it knows it has a binary input*/ + if(cmd==0) { + (void) ab_bidriver(ABBI_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + } + return(0); +} + +static long read_mbbiDirect(struct mbbiDirectRecord *pmbbi) +{ + struct abio *pabio; + int status; + unsigned long value; + + + pabio = (struct abio *)&(pmbbi->inp.value); + status = ab_bidriver(ABBI_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + if(status==0) { + pmbbi->rval = value; + return(0); + } else { + if(recGblSetSevr(pmbbi,READ_ALARM,INVALID_ALARM) && errVerbose + && (pmbbi->stat!=READ_ALARM || pmbbi->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbi,"ab_bidriver Error"); + return(2); + } +} + +static long init_mbbi16(struct mbbiRecord *pmbbi) +{ + + /* mbbi.inp must be an AB_IO */ + switch (pmbbi->inp.type) { + case (AB_IO) : + pmbbi->shft = pmbbi->inp.value.abio.signal; + pmbbi->mask <<= pmbbi->shft; + break; + default : + recGblRecordError(S_db_badField,(void *)pmbbi, + "devMbbiAb16 (init_record) Illegal INP field"); + return(S_db_badField); + } + return(0); +} + +static long ioinfo_mbbi16( + int cmd, + struct mbbiRecord *pmbbi, + IOSCANPVT *ppvt) +{ + struct abio *pabio; + unsigned long value; + + pabio = (struct abio *)&(pmbbi->inp.value); + ab_bi_getioscanpvt(pabio->link,pabio->adapter,pabio->card,ppvt); + /*call ab_bidriver so that it knows it has a binary input*/ + if(cmd==0) { + (void) ab_bidriver(ABBI_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + } + return(0); +} + +static long read_mbbi16(struct mbbiRecord *pmbbi) +{ + struct abio *pabio; + int status; + unsigned long value; + + pabio = (struct abio *)&(pmbbi->inp.value); + status = ab_bidriver(ABBI_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + if(status==0) { + pmbbi->rval = value; + return(0); + } else { + if(recGblSetSevr(pmbbi,READ_ALARM,INVALID_ALARM) && errVerbose + && (pmbbi->stat!=READ_ALARM || pmbbi->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbi,"ab_bidriver Error"); + return(2); + } +} + +static long init_mbbiDirect16(struct mbbiDirectRecord *pmbbi) +{ + + /* mbbi.inp must be an AB_IO */ + switch (pmbbi->inp.type) { + case (AB_IO) : + pmbbi->shft = pmbbi->inp.value.abio.signal; + pmbbi->mask <<= pmbbi->shft; + break; + default : + recGblRecordError(S_db_badField,(void *)pmbbi, + "devMbbiDirectAb16 (init_record) Illegal INP field"); + return(S_db_badField); + } + return(0); +} + +static long ioinfo_mbbiDirect16( + int cmd, + struct mbbiDirectRecord *pmbbi, + IOSCANPVT *ppvt) +{ + struct abio *pabio; + unsigned long value; + + pabio = (struct abio *)&(pmbbi->inp.value); + ab_bi_getioscanpvt(pabio->link,pabio->adapter,pabio->card,ppvt); + /*call ab_bidriver so that it knows it has a binary input*/ + if(cmd==0) { + (void) ab_bidriver(ABBI_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + } + return(0); +} + +static long read_mbbiDirect16(struct mbbiDirectRecord *pmbbi) +{ + struct abio *pabio; + int status; + unsigned long value; + + pabio = (struct abio *)&(pmbbi->inp.value); + status = ab_bidriver(ABBI_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbi->mask,&value); + if(status==0) { + pmbbi->rval = value; + return(0); + } else { + if(recGblSetSevr(pmbbi,READ_ALARM,INVALID_ALARM) && errVerbose + && (pmbbi->stat!=READ_ALARM || pmbbi->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbi,"ab_bidriver Error"); + return(2); + } +} + +static long init_bo(struct boRecord *pbo) +{ + unsigned long value; + struct abio *pabio; + int status=0; + + /* bo.out must be an AB_IO */ + switch (pbo->out.type) { + case (AB_IO) : + pabio = (struct abio *)&(pbo->out.value); + /* read the value via the ab driver */ + pbo->mask = 1; + pbo->mask <<= pabio->signal; + status = ab_boread(ABBO_08_BIT,pabio->link,pabio->adapter, + pabio->card,&value,pbo->mask); + if(status == 0) pbo->rval = value; + else status=2; + break; + default : + status=S_db_badField; + recGblRecordError(status,(void *)pbo,"devBoAb (init_record) Illegal OUT field"); + } + return(status); +} + +static long write_bo(struct boRecord *pbo) +{ + struct abio *pabio; + int status; + + + pabio = (struct abio *)&(pbo->out.value); + status = ab_bodriver(ABBO_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pbo->rval,pbo->mask); + if(status!=0) { + if(recGblSetSevr(pbo,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pbo->stat!=WRITE_ALARM || pbo->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pbo,"ab_bodriver Error"); + } + return(0); +} + +static long init_bo16(struct boRecord *pbo) +{ + unsigned long value; + struct abio *pabio; + int status=0; + + /* bo.out must be an AB_IO */ + switch (pbo->out.type) { + case (AB_IO) : + pabio = (struct abio *)&(pbo->out.value); + /* read the value via the ab driver */ + pbo->mask = 1; + pbo->mask <<= pabio->signal; + status = ab_boread(ABBO_16_BIT,pabio->link,pabio->adapter, + pabio->card,&value,pbo->mask); + if(status == 0) pbo->rval = value; + else status = 2; + break; + default : + status = S_db_badField; + recGblRecordError(status,(void *)pbo, + "devBoAb16 (init_record) Illegal OUT field"); + } + return(status); +} + +static long write_bo16(struct boRecord *pbo) +{ + struct abio *pabio; + int status; + + + pabio = (struct abio *)&(pbo->out.value); + status = ab_bodriver(ABBO_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pbo->rval,pbo->mask); + if(status!=0) { + if(recGblSetSevr(pbo,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pbo->stat!=WRITE_ALARM || pbo->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pbo,"ab_bodriver Error"); + } + return(0); +} + +static long init_mbbo(struct mbboRecord *pmbbo) +{ + unsigned long value; + struct abio *pabio; + int status=0; + + /* mbbo.out must be an AB_IO */ + switch (pmbbo->out.type) { + case (AB_IO) : + pabio = &(pmbbo->out.value.abio); + pmbbo->shft = pabio->signal; + pmbbo->mask <<= pmbbo->shft; + status = ab_boread(ABBO_08_BIT,pabio->link,pabio->adapter,pabio->card,&value,pmbbo->mask); + if(status==0) pmbbo->rval = value; + else status = 2; + break; + default : + status = S_db_badField; + recGblRecordError(status,(void *)pmbbo, + "devMbboAb (init_record) Illegal OUT field"); + } + return(status); +} + +static long write_mbbo(struct mbboRecord *pmbbo) +{ + struct abio *pabio; + int status; + unsigned long value; + + + pabio = &(pmbbo->out.value.abio); + status = ab_bodriver(ABBO_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbo->rval,pmbbo->mask); + if(status!=0) { + if(recGblSetSevr(pmbbo,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pmbbo->stat!=WRITE_ALARM || pmbbo->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbo,"ab_bodriver Error"); + } + return(0); +} + +static long init_mbboDirect(struct mbboDirectRecord *pmbbo) +{ + unsigned long value; + struct abio *pabio; + int status=0; + + /* mbbo.out must be an AB_IO */ + switch (pmbbo->out.type) { + case (AB_IO) : + pabio = &(pmbbo->out.value.abio); + pmbbo->shft = pabio->signal; + pmbbo->mask <<= pmbbo->shft; + status = ab_boread(ABBO_08_BIT,pabio->link,pabio->adapter,pabio->card,&value,pmbbo->mask); + if(status==0) pmbbo->rval = value; + else status = 2; + break; + default : + status = S_db_badField; + recGblRecordError(status,(void *)pmbbo, + "devMbboDirectAb (init_record) Illegal OUT field"); + } + return(status); +} + +static long write_mbboDirect(struct mbboDirectRecord *pmbbo) +{ + struct abio *pabio; + int status; + unsigned long value; + + + pabio = &(pmbbo->out.value.abio); + status = ab_bodriver(ABBO_08_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbo->rval,pmbbo->mask); + if(status!=0) { + if(recGblSetSevr(pmbbo,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pmbbo->stat!=WRITE_ALARM || pmbbo->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbo,"ab_bodriver Error"); + } + return(0); +} + +static long init_mbbo16(struct mbboRecord *pmbbo) +{ + unsigned long value; + struct abio *pabio; + int status=0; + + /* mbbo.out must be an AB_IO */ + switch (pmbbo->out.type) { + case (AB_IO) : + pabio = &(pmbbo->out.value.abio); + pmbbo->shft = pabio->signal; + pmbbo->mask <<= pmbbo->shft; + status = ab_boread(ABBO_16_BIT,pabio->link,pabio->adapter,pabio->card,&value,pmbbo->mask); + if(status==0) pmbbo->rval = value; + else status = 2; + break; + default : + status = S_db_badField; + recGblRecordError(status,(void *)pmbbo, + "devMbboAb16 (init_record) Illegal OUT field"); + } + return(status); +} + +static long write_mbbo16(struct mbboRecord *pmbbo) +{ + struct abio *pabio; + int status; + + + pabio = &(pmbbo->out.value.abio); + status = ab_bodriver(ABBO_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbo->rval,pmbbo->mask); + if(status!=0) { + if(recGblSetSevr(pmbbo,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pmbbo->stat!=WRITE_ALARM || pmbbo->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbo,"ab_bodriver Error"); + } + return(0); +} + +static long init_mbboDirect16(struct mbboDirectRecord *pmbbo) +{ + unsigned long value; + struct abio *pabio; + int status=0; + + /* mbbo.out must be an AB_IO */ + switch (pmbbo->out.type) { + case (AB_IO) : + pabio = &(pmbbo->out.value.abio); + pmbbo->shft = pabio->signal; + pmbbo->mask <<= pmbbo->shft; + status = ab_boread(ABBO_16_BIT,pabio->link,pabio->adapter,pabio->card,&value,pmbbo->mask); + if(status==0) pmbbo->rval = value; + else status = 2; + break; + default : + status = S_db_badField; + recGblRecordError(status,(void *)pmbbo, + "devMbboDirectAb16 (init_record) Illegal OUT field"); + } + return(status); +} + +static long write_mbboDirect16(struct mbboDirectRecord *pmbbo) +{ + struct abio *pabio; + int status; + + + pabio = &(pmbbo->out.value.abio); + status = ab_bodriver(ABBO_16_BIT,pabio->link,pabio->adapter, + pabio->card,pabio->plc_flag,pmbbo->rval,pmbbo->mask); + if(status!=0) { + if(recGblSetSevr(pmbbo,WRITE_ALARM,INVALID_ALARM) && errVerbose + && (pmbbo->stat!=WRITE_ALARM || pmbbo->sevr!=INVALID_ALARM)) + recGblRecordError(-1,(void *)pmbbo,"ab_bodriver Error"); + } + return(0); +} +