support special_linconv for ai and ao
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
static long init();
|
||||
static long init_record();
|
||||
static long read_ai();
|
||||
static long special_linconv();
|
||||
|
||||
struct {
|
||||
long number;
|
||||
@@ -48,11 +49,10 @@ struct {
|
||||
init_record,
|
||||
NULL,
|
||||
read_ai,
|
||||
NULL};
|
||||
special_linconv};
|
||||
|
||||
|
||||
static long init(after)
|
||||
int after;
|
||||
static long init( int after)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_ON
|
||||
@@ -61,12 +61,10 @@ int after;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long init_record(pai)
|
||||
struct aiRecord *pai;
|
||||
static long init_record(struct aiRecord *pai)
|
||||
{
|
||||
struct camacio *pcamacio;
|
||||
struct dinfo *pcio;
|
||||
int fsd;
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devAiCamac (init_record) Called.\n");
|
||||
#endif
|
||||
@@ -74,7 +72,7 @@ int fsd;
|
||||
/* ai.inp must be a CAMAC_IO */
|
||||
switch (pai->inp.type) {
|
||||
case (CAMAC_IO) :
|
||||
pcio = (struct dinfo *)malloc(sizeof(struct dinfo));
|
||||
pcio = (struct dinfo *)calloc(1,sizeof(struct dinfo));
|
||||
if (pcio == NULL) {
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devAiCamac (init_record): malloc failed.\n");
|
||||
@@ -97,13 +95,13 @@ int fsd;
|
||||
return(DO_NOT_CONVERT); /* cdreg failed if ext is zero */
|
||||
}
|
||||
|
||||
sscanf((char *)pcamacio->parm, "%i",&fsd);
|
||||
if (fsd > 0) {
|
||||
if (!(fsd & (fsd+1))) fsd++; /* camac card count should be 2's power */
|
||||
pai->eslo = (pai->eguf - pai->egul)/fsd;
|
||||
sscanf((char *)pcamacio->parm, "%i",&pcio->fsd);
|
||||
if (pcio->fsd > 0) {
|
||||
if (!(pcio->fsd & (pcio->fsd+1))) pcio->fsd++; /* camac card count should be 2's power */
|
||||
pai->eslo = (pai->eguf - pai->egul)/pcio->fsd;
|
||||
}
|
||||
|
||||
for (pcio->mask=1; pcio->mask < fsd; pcio->mask=pcio->mask<<1);
|
||||
for (pcio->mask=1; pcio->mask < pcio->fsd; pcio->mask=pcio->mask<<1);
|
||||
pcio->mask--;
|
||||
|
||||
pcio->f = pcamacio->f;
|
||||
@@ -119,24 +117,33 @@ int fsd;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long read_ai(pai)
|
||||
struct aiRecord *pai;
|
||||
static long read_ai(struct aiRecord *pai)
|
||||
{
|
||||
register struct dinfo *pcio;
|
||||
struct dinfo *pcio;
|
||||
int q;
|
||||
|
||||
pcio = (struct dinfo *)pai->dpvt;
|
||||
|
||||
if(!(pcio->ext)) return(DO_NOT_CONVERT);
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG) printf("devAiCamac (read_ai): f=%d ext=%ld mask=%ld\n",
|
||||
if ( CDEBUG) printf("devAiCamac (read_ai): f=%d ext=%d mask=%d\n",
|
||||
pcio->f, pcio->ext, pcio->mask);
|
||||
#endif
|
||||
q=0;
|
||||
cfsa(pcio->f, pcio->ext, &(pai->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pai->rval), &q);
|
||||
pai->rval &= pcio->mask;
|
||||
|
||||
|
||||
if(q) return(CONVERT);
|
||||
else return(DO_NOT_CONVERT);
|
||||
}
|
||||
|
||||
static long special_linconv(struct aiRecord *pai,int after)
|
||||
{
|
||||
struct dinfo *pcio = (struct dinfo *)pai->dpvt;
|
||||
|
||||
if(!after) return(0);
|
||||
/* set linear conversion slope*/
|
||||
if(pcio->fsd!=0) pai->eslo = (pai->eguf - pai->egul)/pcio->fsd;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,7 @@ struct {
|
||||
write_ao,
|
||||
special_linconv};
|
||||
|
||||
static long init(after)
|
||||
int after;
|
||||
static long init(int after)
|
||||
{
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devAoCamac (init) called, pass=%d\n", after);
|
||||
@@ -65,12 +64,10 @@ int after;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long init_record(pao)
|
||||
struct aoRecord *pao;
|
||||
static long init_record(struct aoRecord *pao)
|
||||
{
|
||||
struct camacio *pcamacio;
|
||||
struct dinfo *pcio;
|
||||
int fsd;
|
||||
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devAoCamac (init_record) called.\n");
|
||||
@@ -79,7 +76,7 @@ int fsd;
|
||||
/* ao.out must be a CAMAC_IO */
|
||||
switch (pao->out.type) {
|
||||
case (CAMAC_IO) :
|
||||
pcio = (struct dinfo *)malloc(sizeof(struct dinfo));
|
||||
pcio = (struct dinfo *)calloc(1,sizeof(struct dinfo));
|
||||
if (pcio == NULL) {
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devAoCamac (init_record): malloc failed.\n");
|
||||
@@ -95,15 +92,15 @@ int fsd;
|
||||
cdreg(&(pcio->ext), pcamacio->b, pcamacio->c, pcamacio->n, pcamacio->a);
|
||||
|
||||
if(!(pcio->ext)) return(DO_NOT_CONVERT);
|
||||
sscanf((char *)pcamacio->parm, "%i",&fsd);
|
||||
sscanf((char *)pcamacio->parm, "%i",&pcio->fsd);
|
||||
|
||||
/* fsd = (int)atoi((char *)pcamacio->parm); */
|
||||
if (fsd > 0) {
|
||||
if (!(fsd & (fsd+1))) fsd++;
|
||||
pao->eslo=(pao->eguf - pao->egul)/fsd;
|
||||
/* pcio->fsd = (int)atoi((char *)pcamacio->parm); */
|
||||
if (pcio->fsd > 0) {
|
||||
if (!(pcio->fsd & (pcio->fsd+1))) pcio->fsd++;
|
||||
pao->eslo=(pao->eguf - pao->egul)/pcio->fsd;
|
||||
}
|
||||
|
||||
for (pcio->mask=1; pcio->mask<fsd; pcio->mask=pcio->mask<<1);
|
||||
for (pcio->mask=1; pcio->mask<pcio->fsd; pcio->mask=pcio->mask<<1);
|
||||
pcio->mask--;
|
||||
|
||||
pcio->f = pcamacio->f;
|
||||
@@ -120,10 +117,9 @@ int fsd;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long write_ao(pao)
|
||||
struct aoRecord *pao;
|
||||
static long write_ao(struct aoRecord *pao)
|
||||
{
|
||||
register struct dinfo *pcio;
|
||||
struct dinfo *pcio;
|
||||
int q;
|
||||
|
||||
pcio = (struct dinfo *)pao->dpvt;
|
||||
@@ -131,7 +127,7 @@ int q;
|
||||
|
||||
pao->rval &= pcio->mask;
|
||||
q = 0;
|
||||
cfsa(pcio->f, pcio->ext, &(pao->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pao->rval), &q);
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devAoCamac (write_ao): f=%d ext=%ld mask=%ld value=%d\n",
|
||||
pcio->f, pcio->ext, pcio->mask, pao->rval);
|
||||
@@ -140,10 +136,12 @@ int q;
|
||||
else return(DO_NOT_CONVERT);
|
||||
}
|
||||
|
||||
static long special_linconv(pao,after)
|
||||
struct aoRecord *pao;
|
||||
int after;
|
||||
static long special_linconv(struct aoRecord *pao, int after)
|
||||
{
|
||||
/* Stub routine, added for consistency. */
|
||||
struct dinfo *pcio = (struct dinfo *)pao->dpvt;
|
||||
|
||||
if(!after) return(0);
|
||||
/* set linear conversion slope*/
|
||||
if(pcio->fsd!=0) pao->eslo = (pao->eguf - pao->egul)/pcio->fsd;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ int q;
|
||||
pcio->f, pcio->ext, pbi->mask);
|
||||
#endif
|
||||
q=0;
|
||||
cfsa(pcio->f, pcio->ext, &(pbi->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pbi->rval), &q);
|
||||
pbi->rval &= pbi->mask;
|
||||
|
||||
if(q) return(CONVERT);
|
||||
|
||||
@@ -124,7 +124,7 @@ int q;
|
||||
|
||||
pbo->rval &= pbo->mask;
|
||||
q = 0;
|
||||
cfsa(pcio->f, pcio->ext, &(pbo->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pbo->rval), &q);
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devBoCamac (write_bo): f=%d ext=%ld mask=%ld value=%d\n",
|
||||
pcio->f, pcio->ext, pbo->mask, pbo->rval);
|
||||
|
||||
@@ -43,6 +43,7 @@ static int sizeofTypes[] = {0,1,1,2,2,4,4,4,8,2};
|
||||
|
||||
struct dinfo{
|
||||
short f;
|
||||
long ext;
|
||||
long mask;
|
||||
int ext;
|
||||
int mask;
|
||||
int fsd; /*full scale for ai and ao*/
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ int q;
|
||||
pcio->f, pcio->ext, pcio->mask);
|
||||
#endif
|
||||
q=0;
|
||||
cfsa(pcio->f, pcio->ext, &(plongin->val), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(plongin->val), &q);
|
||||
plongin->val &= pcio->mask;
|
||||
|
||||
if(q) return(CONVERT);
|
||||
|
||||
@@ -127,7 +127,7 @@ int q;
|
||||
|
||||
plongout->val &= pcio->mask;
|
||||
q = 0;
|
||||
cfsa(pcio->f, pcio->ext, &(plongout->val), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(plongout->val), &q);
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devLoCamac (write_longout): f=%d ext=%ld mask=%ld value=%d\n",
|
||||
pcio->f, pcio->ext, pcio->mask, plongout->val);
|
||||
|
||||
@@ -124,7 +124,7 @@ unsigned long val;
|
||||
pcio->f, pcio->ext, pmbbi->mask);
|
||||
#endif
|
||||
q=0;
|
||||
cfsa(pcio->f, pcio->ext, &val, &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&val, &q);
|
||||
if(q)
|
||||
{
|
||||
pmbbi->rval = val&pmbbi->mask;
|
||||
|
||||
@@ -129,7 +129,7 @@ int q;
|
||||
pcio->f, pcio->ext, pcio->mask);
|
||||
#endif
|
||||
q=0;
|
||||
cfsa(pcio->f, pcio->ext, &(pmbbidirect->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pmbbidirect->rval), &q);
|
||||
pmbbidirect->rval &= pcio->mask;
|
||||
|
||||
if(q) return(CONVERT);
|
||||
|
||||
@@ -124,7 +124,7 @@ int q;
|
||||
if(!(pcio->ext)) return(DO_NOT_CONVERT);
|
||||
|
||||
q = 0;
|
||||
cfsa(pcio->f, pcio->ext, &(pmbbo->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pmbbo->rval), &q);
|
||||
#ifdef DEBUG_ON
|
||||
if ( CDEBUG)printf("devMbboCamac (write_mbbo): f=%d ext=%ld mask=%ld value=%d\n",
|
||||
pcio->f, pcio->ext, pcio->mask, pmbbo->val);
|
||||
|
||||
@@ -126,7 +126,7 @@ int q;
|
||||
if(!(pcio->ext)) return(DO_NOT_CONVERT);
|
||||
|
||||
q = 0;
|
||||
cfsa(pcio->f, pcio->ext, &(pmbbodirect->rval), &q);
|
||||
cfsa(pcio->f, pcio->ext, (int *)&(pmbbodirect->rval), &q);
|
||||
#ifdef DEBUG_ON
|
||||
if(CDEBUG)printf("devMbboDirectCamac (write_mbbodirect): f=%d ext=%ld mask=%ld value=%d\n",
|
||||
pcio->f, pcio->ext, pcio->mask, pmbbodirect->rval);
|
||||
|
||||
Reference in New Issue
Block a user