Initial revision
This commit is contained in:
164
src/dev/devWfJoergerVtr1.c
Normal file
164
src/dev/devWfJoergerVtr1.c
Normal file
@ -0,0 +1,164 @@
|
||||
/* devWfJoergerVtr1.c */
|
||||
/* share/src/dev $Id$ */
|
||||
|
||||
/* devWfJoergerVtr1.c - Device Support Routines */
|
||||
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <module_types.h>
|
||||
#include <waveformRecord.h>
|
||||
|
||||
long init_record();
|
||||
long read_wf();
|
||||
long arm_wf();
|
||||
|
||||
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_wf;
|
||||
} devWfJoergerVtr1={
|
||||
5,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_wf};
|
||||
/* control block for callback */
|
||||
struct callback{
|
||||
struct dbAddr dbAddr;
|
||||
void (*process)();
|
||||
};
|
||||
|
||||
/*
|
||||
* Macro to access the Joerger memory using word addressing.
|
||||
* Returns either byte of a short using only short word addressing
|
||||
* this is necessary to avoid bus errors
|
||||
*/
|
||||
#define get_a_byte(a) (((long)a & 0x01)? \
|
||||
(*(unsigned short *)(a-1) & 0xff) : (*(unsigned short *)(a) >> 8))
|
||||
|
||||
|
||||
|
||||
static void myCallback(pcallback,no_read,pdata)
|
||||
struct callback *pcallback;
|
||||
int no_read;
|
||||
unsigned char *pdata;
|
||||
{
|
||||
struct waveformRecord *pwf=
|
||||
(struct waveformRecord *)(pcallback->dbAddr.precord);
|
||||
short ftvl = pwf->ftvl;
|
||||
int i;
|
||||
|
||||
if(!pwf->busy) return;
|
||||
dbScanLock(pwf);
|
||||
pwf->busy = FALSE;
|
||||
if(ftvl==DBF_CHAR || ftvl==DBF_UCHAR) {
|
||||
unsigned char source;
|
||||
unsigned char *pdest=(unsigned char *)pwf->bptr;
|
||||
|
||||
for(i=0; i<no_read; i++) {
|
||||
source = get_a_byte(pdata);
|
||||
*pdest++ = source;
|
||||
}
|
||||
pwf->nord = no_read; /* number of values read */
|
||||
} else if(ftvl==DBF_SHORT || ftvl==DBF_USHORT) {
|
||||
unsigned char source;
|
||||
unsigned short *pdest=(unsigned short *)pwf->bptr;
|
||||
|
||||
for(i=0; i<no_read; i++) {
|
||||
source = get_a_byte(pdata);
|
||||
*pdest++ = source;
|
||||
}
|
||||
pwf->nord = no_read; /* number of values read */
|
||||
} else {
|
||||
recGblRecSupError(S_db_badField,&pcallback->dbAddr,
|
||||
"read_wf - illegal ftvl");
|
||||
if(pwf->nsev<MAJOR_ALARM ) {
|
||||
pwf->nsta = READ_ALARM;
|
||||
pwf->nsev = MAJOR_ALARM;
|
||||
|
||||
}
|
||||
}
|
||||
(pcallback->process)(&pcallback->dbAddr);
|
||||
dbScanUnlock(pwf);
|
||||
}
|
||||
|
||||
static long init_record(pwf,process)
|
||||
struct waveformRecord *pwf;
|
||||
void (*process)();
|
||||
{
|
||||
char message[100];
|
||||
struct callback *pcallback;
|
||||
|
||||
/* wf.inp must be an VME_IO */
|
||||
switch (pwf->inp.type) {
|
||||
case (VME_IO) :
|
||||
pcallback = (struct callback *)(calloc(1,sizeof(struct callback *)));
|
||||
pwf->dpvt = (caddr_t)pcallback;
|
||||
if(dbNameToAddr(pwf->name,&(pcallback->dbAddr))) {
|
||||
logMsg("dbNameToAddr failed in init_record for devWfJoergerVtr1\n");
|
||||
exit(1);
|
||||
}
|
||||
pcallback->process = process;
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pwf->name);
|
||||
strcat(message,": devWfJoergerVtr1 (init_record) Illegal INP field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long read_wf(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
{
|
||||
char message[100];
|
||||
struct callback *pcallback=(struct callback *)(pwf->dpvt);
|
||||
unsigned short value;
|
||||
struct vmeio *pvmeio;
|
||||
long status;
|
||||
|
||||
|
||||
if(pwf->busy) return(1);
|
||||
status = 0;
|
||||
/* determine if wave form is to be rearmed*/
|
||||
/* If not active then request rearm */
|
||||
if(!pwf->pact) status = arm_wf(pwf);
|
||||
/* if already active then call is from myCallback. check rarm*/
|
||||
else if(pwf->rarm) {
|
||||
(void)arm_wf(pwf);
|
||||
pwf->rarm = 0;
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
static long arm_wf(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
{
|
||||
struct vmeio *pvmeio = (struct vmeio *)&(pwf->inp.value);
|
||||
|
||||
pwf->busy = TRUE;
|
||||
if(wf_driver(JGVTR1,pvmeio->card,myCallback,pwf->dpvt)<0){
|
||||
if(pwf->nsev<MAJOR_ALARM ) {
|
||||
pwf->nsta = READ_ALARM;
|
||||
pwf->nsev = MAJOR_ALARM;
|
||||
|
||||
}
|
||||
pwf->busy = FALSE;
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
93
src/dev/devWfSoft.c
Normal file
93
src/dev/devWfSoft.c
Normal file
@ -0,0 +1,93 @@
|
||||
/* devWfSoft.c */
|
||||
/* share/src/dev $Id$ */
|
||||
|
||||
/* devWfSoft.c - Device Support Routines for soft Waveform Records*/
|
||||
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <waveformRecord.h>
|
||||
|
||||
/* Create the dset for devWfSoft */
|
||||
long init_record();
|
||||
long read_wf();
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_wf;
|
||||
}devWfSoft={
|
||||
5,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_wf};
|
||||
|
||||
|
||||
static long init_record(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
{
|
||||
char message[100];
|
||||
|
||||
/* wf.inp must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pwf->inp.type) {
|
||||
case (CONSTANT) :
|
||||
pwf->nord = 0;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pwf->name);
|
||||
strcat(message,": devWfSoft (init_record) Illegal INP field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long read_wf(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
{
|
||||
char message[100];
|
||||
long status,options,nRequest;
|
||||
|
||||
/* wf.inp must be a CONSTANT or a DB_LINK or a CA_LINK*/
|
||||
switch (pwf->inp.type) {
|
||||
case (CONSTANT) :
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
options=0;
|
||||
nRequest=pwf->nelm;
|
||||
(void)dbGetLink(&(pwf->inp.value.db_link),pwf,pwf->ftvl,
|
||||
pwf->bptr,&options,&nRequest);
|
||||
pwf->nord = nRequest;
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
default :
|
||||
if(pwf->nsev<MAJOR_ALARM) {
|
||||
pwf->nsev = MAJOR_ALARM;
|
||||
pwf->nsta = SOFT_ALARM;
|
||||
if(pwf->stat!=SOFT_ALARM) {
|
||||
strcpy(message,pwf->name);
|
||||
strcat(message,": devWfSoft (read_wf) Illegal INP field");
|
||||
errMessage(S_db_badField,message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
139
src/dev/devWfXy566Sc.c
Normal file
139
src/dev/devWfXy566Sc.c
Normal file
@ -0,0 +1,139 @@
|
||||
/* devWfXy566Sc.c */
|
||||
/* share/src/dev $Id$ */
|
||||
|
||||
/* devWfXy566Sc.c - Device Support Routines */
|
||||
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <devSup.h>
|
||||
#include <link.h>
|
||||
#include <module_types.h>
|
||||
#include <waveformRecord.h>
|
||||
|
||||
long init_record();
|
||||
long read_wf();
|
||||
long arm_wf();
|
||||
|
||||
|
||||
struct {
|
||||
long number;
|
||||
DEVSUPFUN report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record;
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_wf;
|
||||
} devWfXy566Sc={
|
||||
5,
|
||||
NULL,
|
||||
NULL,
|
||||
init_record,
|
||||
NULL,
|
||||
read_wf};
|
||||
/* control block for callback */
|
||||
struct callback{
|
||||
struct dbAddr dbAddr;
|
||||
void (*process)();
|
||||
};
|
||||
|
||||
|
||||
static void myCallback(pcallback,no_read,pdata)
|
||||
struct callback *pcallback;
|
||||
int no_read;
|
||||
unsigned char *pdata;
|
||||
{
|
||||
struct waveformRecord *pwf=
|
||||
(struct waveformRecord *)(pcallback->dbAddr.precord);
|
||||
short ftvl = pwf->ftvl;
|
||||
|
||||
if(!pwf->busy) return;
|
||||
dbScanLock(pwf);
|
||||
pwf->busy = FALSE;
|
||||
if(ftvl==DBF_SHORT || ftvl==DBF_USHORT) {
|
||||
bcopy(pdata,pwf->bptr,no_read*2);
|
||||
pwf->nord = no_read; /* number of values read */
|
||||
} else {
|
||||
recGblRecSupError(S_db_badField,&pcallback->dbAddr,
|
||||
"read_wf - illegal ftvl");
|
||||
if(pwf->nsev<MAJOR_ALARM ) {
|
||||
pwf->nsta = READ_ALARM;
|
||||
pwf->nsev = MAJOR_ALARM;
|
||||
|
||||
}
|
||||
}
|
||||
(pcallback->process)(&pcallback->dbAddr);
|
||||
dbScanUnlock(pwf);
|
||||
}
|
||||
|
||||
static long init_record(pwf,process)
|
||||
struct waveformRecord *pwf;
|
||||
void (*process)();
|
||||
{
|
||||
char message[100];
|
||||
struct callback *pcallback;
|
||||
|
||||
/* wf.inp must be an VME_IO */
|
||||
switch (pwf->inp.type) {
|
||||
case (VME_IO) :
|
||||
pcallback = (struct callback *)(calloc(1,sizeof(struct callback *)));
|
||||
pwf->dpvt = (caddr_t)pcallback;
|
||||
if(dbNameToAddr(pwf->name,&(pcallback->dbAddr))) {
|
||||
logMsg("dbNameToAddr failed in init_record for devWfXy566Sc\n");
|
||||
exit(1);
|
||||
}
|
||||
pcallback->process = process;
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pwf->name);
|
||||
strcat(message,": devWfXy566Sc (init_record) Illegal INP field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long read_wf(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
{
|
||||
char message[100];
|
||||
struct callback *pcallback=(struct callback *)(pwf->dpvt);
|
||||
unsigned short value;
|
||||
struct vmeio *pvmeio;
|
||||
long status;
|
||||
|
||||
|
||||
if(pwf->busy) return(1);
|
||||
status = 0;
|
||||
/* determine if wave form is to be rearmed*/
|
||||
/* If not active then request rearm */
|
||||
if(!pwf->pact) status = arm_wf(pwf);
|
||||
/* if already active then call is from myCallback. check rarm*/
|
||||
else if(pwf->rarm) {
|
||||
(void)arm_wf(pwf);
|
||||
pwf->rarm = 0;
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
static long arm_wf(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
{
|
||||
struct vmeio *pvmeio = (struct vmeio *)&(pwf->inp.value);
|
||||
|
||||
pwf->busy = TRUE;
|
||||
if(wf_driver(XY566WF,pvmeio->card,myCallback,pwf->dpvt)<0) {
|
||||
if(pwf->nsev<MAJOR_ALARM ) {
|
||||
pwf->nsta = READ_ALARM;
|
||||
pwf->nsev = MAJOR_ALARM;
|
||||
|
||||
}
|
||||
pwf->busy = FALSE;
|
||||
return(0);
|
||||
}
|
||||
return(1);
|
||||
}
|
Reference in New Issue
Block a user