Allen Bradley support completele rewritten
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
267
src/dev/devAB1771IFE.c
Normal file
267
src/dev/devAB1771IFE.c
Normal file
@@ -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 <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dbDefs.h>
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <drvAb.h>
|
||||
#include <aiRecord.h>
|
||||
|
||||
/* 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));
|
||||
}
|
||||
195
src/dev/devAB1771IL.c
Normal file
195
src/dev/devAB1771IL.c
Normal file
@@ -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 <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dbDefs.h>
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <drvAb.h>
|
||||
#include <aiRecord.h>
|
||||
|
||||
/* 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<<pabio->signal))
|
||||
|| (pdata->orange&(1<<pabio->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);
|
||||
}
|
||||
216
src/dev/devAB1771IR.c
Normal file
216
src/dev/devAB1771IR.c
Normal file
@@ -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 <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dbDefs.h>
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <drvAb.h>
|
||||
#include <aiRecord.h>
|
||||
|
||||
/* 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<<signal)) value = - value;
|
||||
prec->rval = value;
|
||||
mask = (1 << pabio->signal);
|
||||
if((pdata->status & (1<<signal))
|
||||
||(pdata->status & (0x100<<signal))){
|
||||
recGblSetSevr(prec,HW_LIMIT_ALARM,INVALID_ALARM);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
LOCAL long init_1771Ir(struct aiRecord *prec, const char *card_type,
|
||||
unsigned short config)
|
||||
{
|
||||
struct abio *pabio;
|
||||
devPvt *pdevPvt;
|
||||
abStatus drvStatus;
|
||||
long status=0;
|
||||
void *drvPvt;
|
||||
|
||||
if (prec->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));
|
||||
}
|
||||
268
src/dev/devAB1771IXE.c
Normal file
268
src/dev/devAB1771IXE.c
Normal file
@@ -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 <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dbDefs.h>
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <drvAb.h>
|
||||
#include <aiRecord.h>
|
||||
|
||||
/* 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<<pabio->signal))) rval = -rval;
|
||||
if((pdata->out_of_range&(1<<pabio->signal))
|
||||
|| (pdata->out_of_range&(0x100<<pabio->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 <IXE_NUM_CVTTYPES) {
|
||||
indCvt = prec->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);
|
||||
}
|
||||
196
src/dev/devAB1771OFE.c
Normal file
196
src/dev/devAB1771OFE.c
Normal file
@@ -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 <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sysLib.h>
|
||||
#include <taskLib.h>
|
||||
|
||||
#include <dbDefs.h>
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <drvAb.h>
|
||||
#include <aoRecord.h>
|
||||
|
||||
/* 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);
|
||||
}
|
||||
617
src/dev/devABBINARY.c
Normal file
617
src/dev/devABBINARY.c
Normal file
@@ -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 <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <dbDefs.h>
|
||||
#include <alarm.h>
|
||||
#include <cvtTable.h>
|
||||
#include <dbAccess.h>
|
||||
#include <recSup.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <drvAb.h>
|
||||
#include <dbCommon.h>
|
||||
#include <biRecord.h>
|
||||
#include <boRecord.h>
|
||||
#include <mbbiRecord.h>
|
||||
#include <mbboRecord.h>
|
||||
#include <mbbiDirectRecord.h>
|
||||
#include <mbboDirectRecord.h>
|
||||
|
||||
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);
|
||||
}
|
||||
1377
src/dev/devAllenBradleyOLD.c
Normal file
1377
src/dev/devAllenBradleyOLD.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user