jba 3/6/91
This commit is contained in:
@@ -77,8 +77,14 @@ static long read_ai(pai)
|
||||
case (DB_LINK) :
|
||||
options=0;
|
||||
nRequest=1;
|
||||
(void)dbGetLink(&(pai->inp.value.db_link),pai,DBR_FLOAT,
|
||||
status = dbGetLink(&(pai->inp.value.db_link),pai,DBR_DOUBLE,
|
||||
&(pai->val),&options,&nRequest);
|
||||
if(status!=0) {
|
||||
if(pai->nsev<VALID_ALARM) {
|
||||
pai->nsev = VALID_ALARM;
|
||||
pai->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
|
||||
@@ -75,8 +75,15 @@ static long read_ai(pai)
|
||||
case (DB_LINK) :
|
||||
options=0;
|
||||
nRequest=1;
|
||||
(void)dbGetLink(&(pai->inp.value.db_link),pai,DBR_LONG,
|
||||
status = dbGetLink(&(pai->inp.value.db_link),pai,DBR_LONG,
|
||||
&(pai->rval),&options,&nRequest);
|
||||
if(status!=0) {
|
||||
if(pai->nsev<VALID_ALARM) {
|
||||
pai->nsev = VALID_ALARM;
|
||||
pai->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
@@ -91,5 +98,5 @@ static long read_ai(pai)
|
||||
}
|
||||
}
|
||||
}
|
||||
return(2); /*don't convert*/
|
||||
return(0); /*don't convert*/
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ static long init_record(pao)
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pao->name);
|
||||
strcat(message,": devAoSoft (init_record) Illegal INP field");
|
||||
strcat(message,": devAoSoft (init_record) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
@@ -68,14 +68,21 @@ static long write_ao(pao)
|
||||
struct aoRecord *pao;
|
||||
{
|
||||
char message[100];
|
||||
long status;
|
||||
|
||||
/* ao.out must be a CONSTANT or a DB_LINK or a CA_LINK*/
|
||||
switch (pao->out.type) {
|
||||
case (CONSTANT) :
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
(void)dbPutLink(&pao->out.value.db_link,pao,DBR_FLOAT,
|
||||
&pao->val,1L);
|
||||
status = dbPutLink(&pao->out.value.db_link,pao,DBR_FLOAT,
|
||||
&pao->oval,1L);
|
||||
if(status!=0) {
|
||||
if(pao->nsev<MAJOR_ALARM) {
|
||||
pao->nsev = MAJOR_ALARM;
|
||||
pao->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
|
||||
@@ -56,7 +56,7 @@ static long init_record(pao)
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pao->name);
|
||||
strcat(message,": devAoVmiVme4100 (init_record) Illegal INP field");
|
||||
strcat(message,": devAoVmiVme4100 (init_record) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,8 @@ static long read_bi(pbi)
|
||||
struct biRecord *pbi;
|
||||
{
|
||||
char message[100];
|
||||
long options,nRequest;
|
||||
long status,options,nRequest;
|
||||
unsigned short val;
|
||||
|
||||
/* bi.inp must be a CONSTANT or a DB_LINK or a CA_LINK*/
|
||||
switch (pbi->inp.type) {
|
||||
@@ -75,8 +76,18 @@ static long read_bi(pbi)
|
||||
case (DB_LINK) :
|
||||
options=0;
|
||||
nRequest=1;
|
||||
(void)dbGetLink(&(pbi->inp.value.db_link),pbi,DBR_SHORT,
|
||||
&(pbi->val),&options,&nRequest);
|
||||
status = dbGetLink(&(pbi->inp.value.db_link),pbi,DBR_USHORT,
|
||||
&val,&options,&nRequest);
|
||||
if(status!=0) {
|
||||
if(pbi->nsev<VALID_ALARM) {
|
||||
pbi->nsev = VALID_ALARM;
|
||||
pbi->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (val==0) pbi->val = 0;
|
||||
else pbi->val = 1;
|
||||
}
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
|
||||
@@ -65,13 +65,20 @@ static long write_bo(pbo)
|
||||
struct boRecord *pbo;
|
||||
{
|
||||
char message[100];
|
||||
long status;
|
||||
|
||||
/* bo.out must be a CONSTANT or a DB_LINK or a CA_LINK*/
|
||||
switch (pbo->out.type) {
|
||||
case (CONSTANT) :
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
(void)dbPutLink(&pbo->out.value.db_link,pbo,DBR_USHORT,&pbo->val,1L);
|
||||
status = dbPutLink(&pbo->out.value.db_link,pbo,DBR_USHORT,&pbo->val,1L);
|
||||
if(status!=0) {
|
||||
if(pbo->nsev<MAJOR_ALARM) {
|
||||
pbo->nsev = MAJOR_ALARM;
|
||||
pbo->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
@@ -81,7 +88,7 @@ static long write_bo(pbo)
|
||||
pbo->nsta = SOFT_ALARM;
|
||||
if(pbo->stat!=SOFT_ALARM) {
|
||||
strcpy(message,pbo->name);
|
||||
strcat(message,": devBoSoft (write_bo) Illegal INP field");
|
||||
strcat(message,": devBoSoft (write_bo) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* devMbbiSoft.c */
|
||||
/* share/src/dev $Id$ */
|
||||
/* share/src/dev @(#)devMbbiSoft.c 1.2 11/30/90 */
|
||||
|
||||
/* devMbbiSoft.c - Device Support Routines for Soft Multibit Binary Input*/
|
||||
|
||||
@@ -65,17 +65,25 @@ static long read_mbbi(pmbbi)
|
||||
struct mbbiRecord *pmbbi;
|
||||
{
|
||||
char message[100];
|
||||
long options,nRequest;
|
||||
long status,options,nRequest;
|
||||
|
||||
/* mbbi.inp must be a CONSTANT or a DB_LINK or a CA_LINK*/
|
||||
switch (pmbbi->inp.type) {
|
||||
case (CONSTANT) :
|
||||
return(2);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
options=0;
|
||||
nRequest=1;
|
||||
(void)dbGetLink(&(pmbbi->inp.value.db_link),pmbbi,DBR_ULONG,
|
||||
status = dbGetLink(&(pmbbi->inp.value.db_link),pmbbi,DBR_ULONG,
|
||||
&(pmbbi->rval),&options,&nRequest);
|
||||
if(status!=0) {
|
||||
if(pmbbi->nsev<VALID_ALARM) {
|
||||
pmbbi->nsev = VALID_ALARM;
|
||||
pmbbi->nsta = LINK_ALARM;
|
||||
}
|
||||
return(2);
|
||||
}
|
||||
break;
|
||||
case (CA_LINK) :
|
||||
break;
|
||||
@@ -89,6 +97,7 @@ static long read_mbbi(pmbbi)
|
||||
errMessage(S_db_badField,message);
|
||||
}
|
||||
}
|
||||
return(2);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ static long init_record(pmbbo)
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pmbbo->name);
|
||||
strcat(message,": devMbboMpv902 (init_record) Illegal INP field");
|
||||
strcat(message,": devMbboMpv902 (init_record) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ static long init_record(pmbbo)
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pmbbo->name);
|
||||
strcat(message,": devMbboSoft (init_record) Illegal INP field");
|
||||
strcat(message,": devMbboSoft (init_record) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ static long init_record(pmbbo)
|
||||
break;
|
||||
default :
|
||||
strcpy(message,pmbbo->name);
|
||||
strcat(message,": devMbboXVme220 (init_record) Illegal INP field");
|
||||
strcat(message,": devMbboXVme220 (init_record) Illegal OUT field");
|
||||
errMessage(S_db_badField,message);
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -104,6 +105,7 @@ struct rset aiRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double};
|
||||
@@ -130,11 +132,6 @@ static long init_record(pai)
|
||||
struct aidset *pdset;
|
||||
long status;
|
||||
|
||||
/* initialize so that first alarm, archive, and monitor get generated*/
|
||||
pai->lalm = 1e30;
|
||||
pai->alst = 1e30;
|
||||
pai->mlst = 1e30;
|
||||
|
||||
if(!(pdset = (struct aidset *)(pai->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,pai,"ai: init_record");
|
||||
return(S_dev_noDSET);
|
||||
@@ -177,8 +174,9 @@ static long process(paddr)
|
||||
status=(*pdset->read_ai)(pai); /* read the new value */
|
||||
pai->pact = TRUE;
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(status==1) return(0);
|
||||
if(status==2) status=0; else convert(pai);
|
||||
if (status==0)convert(pai);
|
||||
else if(status==1) return(0);
|
||||
else if(status==2) status=0;
|
||||
|
||||
/* check for alarms */
|
||||
alarm(pai);
|
||||
@@ -218,9 +216,9 @@ static long get_value(pai,pvdes)
|
||||
struct aiRecord *pai;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_FLOAT;
|
||||
pvdes->field_type = DBF_DOUBLE;
|
||||
pvdes->no_elements=1;
|
||||
(float *)(pvdes->pvalue) = &pai->val;
|
||||
(double *)(pvdes->pvalue) = &pai->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -448,7 +446,7 @@ static void monitor(pai)
|
||||
|
||||
/* check for archive change */
|
||||
delta = pai->alst - pai->val;
|
||||
if(delta<0.0) delta = 0.0;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if (delta > pai->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
|
||||
@@ -80,6 +80,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -99,6 +100,7 @@ struct rset aoRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -131,12 +133,7 @@ static long init_record(pao)
|
||||
struct aoRecord *pao;
|
||||
{
|
||||
struct aodset *pdset;
|
||||
long status;
|
||||
|
||||
/* initialize so that first alarm, archive, and monitor get generated*/
|
||||
pao->lalm = 1e30;
|
||||
pao->alst = 1e30;
|
||||
pao->mlst = 1e30;
|
||||
long status=0;
|
||||
|
||||
if(!(pdset = (struct aodset *)(pao->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,pao,"ao: init_record");
|
||||
@@ -151,7 +148,7 @@ static long init_record(pao)
|
||||
if((status=(*pdset->init_record)(pao,process))) return(status);
|
||||
}
|
||||
/* get the intial value */
|
||||
if ((pao->dol.type == CONSTANT) && (pao->dol.value.value != 0)){
|
||||
if ((pao->dol.type == CONSTANT) && (pao->dol.value.value != udfFloat)){
|
||||
pao->val = pao->dol.value.value;
|
||||
}
|
||||
return(0);
|
||||
@@ -169,15 +166,10 @@ static long process(paddr)
|
||||
recGblRecordError(S_dev_missingSup,pao,"write_ao");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if(pao->pact == FALSE) {
|
||||
convert(pao);
|
||||
status=(*pdset->write_ao)(pao);
|
||||
} else {
|
||||
status=(*pdset->write_ao)(pao);
|
||||
pao->pact = TRUE;
|
||||
}
|
||||
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(pao->pact == FALSE) convert(pao);
|
||||
status=(*pdset->write_ao)(pao);
|
||||
pao->pact = TRUE;
|
||||
if(status==1) return(0);
|
||||
|
||||
/* check for alarms */
|
||||
@@ -369,6 +361,7 @@ static void convert(pao)
|
||||
}
|
||||
pao->val = value;
|
||||
|
||||
if(pao->oval == udfFloat) pao->oval = value;
|
||||
/* now set value equal to desired output value */
|
||||
/* apply the output rate of change */
|
||||
if (pao->oroc){
|
||||
@@ -384,7 +377,7 @@ static void convert(pao)
|
||||
|
||||
/* convert */
|
||||
if (pao->linr == LINEAR){
|
||||
if (pao->eslo == 0) pao->rval = 0;
|
||||
if (pao->eslo == 0.0) pao->rval = 0;
|
||||
else pao->rval = (value - pao->egul) / pao->eslo;
|
||||
}else{
|
||||
pao->rval = value;
|
||||
@@ -436,7 +429,7 @@ static void monitor(pao)
|
||||
|
||||
/* check for archive change */
|
||||
delta = pao->alst - pao->val;
|
||||
if(delta<0.0) delta = 0.0;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if (delta > pao->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
|
||||
@@ -73,6 +73,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
long get_enum_str();
|
||||
long get_enum_strs();
|
||||
long put_enum_str();
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -91,6 +92,7 @@ struct rset biRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -123,7 +125,6 @@ static long init_record(pbi)
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(pbi,process))) return(status);
|
||||
}
|
||||
pbi->mlst = -1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -197,14 +198,28 @@ static long get_enum_strs(paddr,pes)
|
||||
strncpy(pes->strs[1],pbi->onam,sizeof(pbi->onam));
|
||||
return(0);
|
||||
}
|
||||
static long put_enum_str(paddr,pstring)
|
||||
struct dbAddr *paddr;
|
||||
char *pstring;
|
||||
{
|
||||
struct biRecord *pbi=(struct biRecord *)paddr->precord;
|
||||
|
||||
if(strncmp(pstring,pbi->znam,sizeof(pbi->znam))==0) pbi->val = 0;
|
||||
else if(strncmp(pstring,pbi->onam,sizeof(pbi->onam))==0) pbi->val = 1;
|
||||
else return(S_db_badChoice);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
static void alarm(pbi)
|
||||
struct biRecord *pbi;
|
||||
{
|
||||
unsigned short val = pbi->val;
|
||||
|
||||
|
||||
if(val>1)return;
|
||||
/* check for state alarm */
|
||||
if (pbi->val == 0){
|
||||
if (val == 0){
|
||||
if (pbi->nsev<pbi->zsv){
|
||||
pbi->nsta = STATE_ALARM;
|
||||
pbi->nsev = pbi->zsv;
|
||||
@@ -217,11 +232,12 @@ static void alarm(pbi)
|
||||
}
|
||||
|
||||
/* check for cos alarm */
|
||||
if(val == pbi->lalm) return;
|
||||
if (pbi->nsev<pbi->cosv) {
|
||||
pbi->nsta = COS_ALARM;
|
||||
pbi->nsev = pbi->cosv;
|
||||
}
|
||||
|
||||
pbi->lalm = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
long get_enum_str();
|
||||
long get_enum_strs();
|
||||
long put_enum_str();
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -102,6 +103,7 @@ struct rset boRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -158,8 +160,8 @@ static long init_record(pbo)
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
/* get the intial value */
|
||||
if (pbo->dol.type == CONSTANT){
|
||||
if (pbo->dol.value.value != 0) pbo->val = 1;
|
||||
if (pbo->dol.type == CONSTANT & pbo->dol.value.value!=udfFloat){
|
||||
if (pbo->dol.value.value == 1) pbo->val = 1;
|
||||
else pbo->val = 0;
|
||||
}
|
||||
if( pdset->init_record ) {
|
||||
@@ -172,7 +174,6 @@ static long init_record(pbo)
|
||||
logMsg("dbNameToAddr failed in init_record for recBo\n");
|
||||
exit(1);
|
||||
}
|
||||
pbo->mlst = -1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -196,10 +197,19 @@ static long process(paddr)
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
short savepact=pbo->pact;
|
||||
unsigned short val;
|
||||
|
||||
pbo->pact = TRUE;
|
||||
(void)dbGetLink(&pbo->dol.value.db_link,pbo,
|
||||
DBR_SHORT,&(pbo->val),&options,&nRequest);
|
||||
status = dbGetLink(&pbo->dol.value.db_link,pbo,
|
||||
DBR_USHORT,&(pbo->val),&options,&nRequest);
|
||||
if(status) {
|
||||
if(pbo->nsev < VALID_ALARM) {
|
||||
pbo->nsev = VALID_ALARM;
|
||||
pbo->nsta = LINK_ALARM;
|
||||
}
|
||||
}
|
||||
else if(val==0) pbo->val = 0;
|
||||
else pbo->val = 1;
|
||||
pbo->pact = savepact;
|
||||
}
|
||||
|
||||
@@ -270,14 +280,26 @@ static long get_enum_strs(paddr,pes)
|
||||
strncpy(pes->strs[1],pbo->onam,sizeof(pbo->onam));
|
||||
return(0);
|
||||
}
|
||||
static long put_enum_str(paddr,pstring)
|
||||
struct dbAddr *paddr;
|
||||
char *pstring;
|
||||
{
|
||||
struct boRecord *pbo=(struct boRecord *)paddr->precord;
|
||||
|
||||
if(strncmp(pstring,pbo->znam,sizeof(pbo->znam))==0) pbo->val = 0;
|
||||
else if(strncmp(pstring,pbo->onam,sizeof(pbo->onam))==0) pbo->val = 1;
|
||||
else return(S_db_badChoice);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void alarm(pbo)
|
||||
struct boRecord *pbo;
|
||||
{
|
||||
unsigned short val = pbo->val;
|
||||
|
||||
|
||||
/* check for state alarm */
|
||||
if (pbo->val == 0){
|
||||
if (val == 0){
|
||||
if (pbo->nsev<pbo->zsv){
|
||||
pbo->nsta = STATE_ALARM;
|
||||
pbo->nsev = pbo->zsv;
|
||||
@@ -290,11 +312,12 @@ static void alarm(pbo)
|
||||
}
|
||||
|
||||
/* check for cos alarm */
|
||||
if(val == pbo->lalm) return;
|
||||
if (pbo->nsev<pbo->cosv) {
|
||||
pbo->nsta = COS_ALARM;
|
||||
pbo->nsev = pbo->cosv;
|
||||
}
|
||||
|
||||
pbo->lalm = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -106,6 +107,7 @@ struct rset calcRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -123,11 +125,6 @@ static long init_record(pcalc)
|
||||
short error_number;
|
||||
char rpbuf[80];
|
||||
|
||||
/* initialize so that first alarm, archive, and monitor get generated*/
|
||||
pcalc->lalm = 1e30;
|
||||
pcalc->alst = 1e30;
|
||||
pcalc->mlst = 1e30;
|
||||
|
||||
if(pcalc->inpa.type==CONSTANT) pcalc->a = pcalc->inpa.value.value;
|
||||
if(pcalc->inpb.type==CONSTANT) pcalc->b = pcalc->inpb.value.value;
|
||||
if(pcalc->inpc.type==CONSTANT) pcalc->c = pcalc->inpc.value.value;
|
||||
@@ -257,7 +254,7 @@ static void alarm(pcalc)
|
||||
float ftemp;
|
||||
float val=pcalc->val;
|
||||
|
||||
/* if difference is not > hysterisis don't bother */
|
||||
/* if difference is not > hysterisis use lalm not val */
|
||||
ftemp = pcalc->lalm - pcalc->val;
|
||||
if(ftemp<0.0) ftemp = -ftemp;
|
||||
if (ftemp < pcalc->hyst) val=pcalc->lalm;
|
||||
@@ -350,7 +347,7 @@ static void monitor(pcalc)
|
||||
}
|
||||
/* check for archive change */
|
||||
delta = pcalc->alst - pcalc->val;
|
||||
if(delta<0.0) delta = 0.0;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if (delta > pcalc->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
|
||||
@@ -79,6 +79,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
#define get_alarm_double NULL
|
||||
@@ -98,6 +99,7 @@ struct rset compressRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -119,7 +121,6 @@ static long init_record(pcompress)
|
||||
|
||||
/* This routine may get called twice. Once by cvt_dbaddr. Once by iocInit*/
|
||||
if(pcompress->bptr==NULL) {
|
||||
if(pcompress->nsam<=0) pcompress->nsam=1;
|
||||
pcompress->bptr = (float *)calloc(pcompress->nsam,sizeof(float));
|
||||
/* allocate memory for the summing buffer for conversions requiring it */
|
||||
if (pcompress->alg == AVERAGE){
|
||||
@@ -131,12 +132,6 @@ static long init_record(pcompress)
|
||||
|
||||
pcompress->wptr = (float *)calloc(pdbAddr->no_elements,sizeof(float));
|
||||
}
|
||||
/* initialize all counters */
|
||||
pcompress->nuse = 0;
|
||||
pcompress->off= 0;
|
||||
pcompress->inx = 0;
|
||||
pcompress->cvb = 0.0;
|
||||
pcompress->res = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ long process();
|
||||
#define get_precision NULL
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -84,6 +85,7 @@ struct rset fanoutRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
@@ -76,6 +76,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
long get_enum_str();
|
||||
long get_enum_strs();
|
||||
long put_enum_str();
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -95,6 +96,7 @@ struct rset mbbiRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -105,7 +107,7 @@ struct mbbidset { /* multi bit binary input dset */
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_mbbi;/*(-1,0,1)=>(failure,success,don't Continue*/
|
||||
DEVSUPFUN read_mbbi;/*(0,1,2)=>(success, asyn, success no convert)*/
|
||||
};
|
||||
void alarm();
|
||||
void monitor();
|
||||
@@ -120,7 +122,7 @@ static void init_common(pmbbi)
|
||||
pstate_values = &(pmbbi->zrvl);
|
||||
pmbbi->sdef = FALSE;
|
||||
for (i=0; i<16; i++) {
|
||||
if (*(pstate_values+i)) {
|
||||
if (*(pstate_values+i) != udfUlong) {
|
||||
pmbbi->sdef = TRUE;
|
||||
return;
|
||||
}
|
||||
@@ -135,8 +137,6 @@ static long init_record(pmbbi)
|
||||
long status;
|
||||
|
||||
init_common(pmbbi);
|
||||
pmbbi->mlst = -1;
|
||||
pmbbi->lalm = -1;
|
||||
if(!(pdset = (struct mbbidset *)(pmbbi->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,pmbbi,"mbbi: init_record");
|
||||
return(S_dev_noDSET);
|
||||
@@ -158,8 +158,7 @@ static long process(paddr)
|
||||
struct mbbiRecord *pmbbi=(struct mbbiRecord *)(paddr->precord);
|
||||
struct mbbidset *pdset = (struct mbbidset *)(pmbbi->dset);
|
||||
long status;
|
||||
unsigned long *pstate_values;
|
||||
short i,val;
|
||||
unsigned short val;
|
||||
|
||||
if( (pdset==NULL) || (pdset->read_mbbi==NULL) ) {
|
||||
pmbbi->pact=TRUE;
|
||||
@@ -169,26 +168,29 @@ static long process(paddr)
|
||||
|
||||
status=(*pdset->read_mbbi)(pmbbi); /* read the new value */
|
||||
pmbbi->pact = TRUE;
|
||||
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(status==1) return(0);
|
||||
if(status==0) { /* convert the value */
|
||||
unsigned long *pstate_values;
|
||||
short i;
|
||||
unsigned long rval = pmbbi->rval;
|
||||
|
||||
/* convert the value */
|
||||
if (pmbbi->sdef){
|
||||
pstate_values = &(pmbbi->zrvl);
|
||||
val = -1; /* initalize to unknown state*/
|
||||
for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == pmbbi->rval){
|
||||
if (pmbbi->sdef){
|
||||
pstate_values = &(pmbbi->zrvl);
|
||||
val = udfUshort; /* initalize to unknown state*/
|
||||
if(rval!=udfUlong)for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == rval){
|
||||
val = i;
|
||||
break;
|
||||
}
|
||||
pstate_values++;
|
||||
}
|
||||
}else{
|
||||
/* the raw value is the desired value */
|
||||
*((unsigned short *)(&val)) = (unsigned short)(pmbbi->rval);
|
||||
}
|
||||
pstate_values++;
|
||||
}
|
||||
}else{
|
||||
/* the raw value is the desired value */
|
||||
*((unsigned short *)(&val)) = (unsigned short)(pmbbi->rval);
|
||||
}
|
||||
pmbbi->val = val;
|
||||
}
|
||||
pmbbi->val = val;
|
||||
if(status == 2) status = 0;
|
||||
|
||||
/* check for alarms */
|
||||
alarm(pmbbi);
|
||||
@@ -265,6 +267,26 @@ static long get_enum_strs(paddr,pes)
|
||||
strncpy(pes->strs[i],psource,sizeof(pmbbi->zrst));
|
||||
return(0);
|
||||
}
|
||||
static long put_enum_str(paddr,pstring)
|
||||
struct dbAddr *paddr;
|
||||
char *pstring;
|
||||
{
|
||||
struct mbbiRecord *pmbbi=(struct mbbiRecord *)paddr->precord;
|
||||
char *pstate_name;
|
||||
short i;
|
||||
|
||||
if (pmbbi->sdef){
|
||||
pstate_name = pmbbi->zrst;
|
||||
for (i = 0; i < 16; i++){
|
||||
if(strncmp(pstate_name,pstring,sizeof(pmbbi->zrst))==0){
|
||||
pmbbi->val = i;
|
||||
return(0);
|
||||
}
|
||||
pstate_name += sizeof(pmbbi->zrst);
|
||||
}
|
||||
}
|
||||
return(S_db_badChoice);
|
||||
}
|
||||
|
||||
static void alarm(pmbbi)
|
||||
struct mbbiRecord *pmbbi;
|
||||
@@ -290,11 +312,13 @@ static void alarm(pmbbi)
|
||||
}
|
||||
|
||||
/* check for cos alarm */
|
||||
if(val == pmbbi->lalm) return;
|
||||
if (pmbbi->nsev<pmbbi->cosv){
|
||||
pmbbi->nsta = COS_ALARM;
|
||||
pmbbi->nsev = pmbbi->cosv;
|
||||
return;
|
||||
}
|
||||
pmbbi->lalm = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
long get_enum_str();
|
||||
long get_enum_strs();
|
||||
long put_enum_str();
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -99,6 +100,7 @@ struct rset mbboRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -127,7 +129,7 @@ static void init_common(pmbbo)
|
||||
pstate_values = &(pmbbo->zrvl);
|
||||
pmbbo->sdef = FALSE;
|
||||
for (i=0; i<16; i++) {
|
||||
if (*(pstate_values+i)) {
|
||||
if (*(pstate_values+i)!= udfUlong) {
|
||||
pmbbo->sdef = TRUE;
|
||||
return;
|
||||
}
|
||||
@@ -140,11 +142,9 @@ static long init_record(pmbbo)
|
||||
{
|
||||
struct mbbodset *pdset;
|
||||
long status;
|
||||
unsigned long *pstate_values;
|
||||
short i,rbv;
|
||||
unsigned short rbv;
|
||||
|
||||
init_common(pmbbo);
|
||||
pmbbo->mlst = -1;
|
||||
|
||||
if(!(pdset = (struct mbbodset *)(pmbbo->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,pmbbo,"mbbo: init_record");
|
||||
@@ -158,10 +158,14 @@ static long init_record(pmbbo)
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(pmbbo,process))) return(status);
|
||||
if (pmbbo->sdef){
|
||||
unsigned long *pstate_values;
|
||||
short i;
|
||||
unsigned long rval = pmbbo->rval;
|
||||
|
||||
pstate_values = &(pmbbo->zrvl);
|
||||
rbv = -1; /* initalize to unknown state*/
|
||||
for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == pmbbo->rval){
|
||||
rbv = udfUshort; /* initalize to unknown state*/
|
||||
if(rval!=udfUlong) for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == rval){
|
||||
rbv = i;
|
||||
break;
|
||||
}
|
||||
@@ -174,6 +178,9 @@ static long init_record(pmbbo)
|
||||
pmbbo->rbv = rbv;
|
||||
pmbbo->val = rbv;
|
||||
}
|
||||
if ((pmbbo->dol.type == CONSTANT) && (pmbbo->dol.value.value != udfFloat)){
|
||||
pmbbo->val = pmbbo->dol.value.value;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -183,8 +190,7 @@ static long process(paddr)
|
||||
struct mbboRecord *pmbbo=(struct mbboRecord *)(paddr->precord);
|
||||
struct mbbodset *pdset = (struct mbbodset *)(pmbbo->dset);
|
||||
long status;
|
||||
unsigned long *pstate_values;
|
||||
short i,rbv;
|
||||
unsigned short rbv;
|
||||
|
||||
if( (pdset==NULL) || (pdset->write_mbbo==NULL) ) {
|
||||
pmbbo->pact=TRUE;
|
||||
@@ -210,12 +216,16 @@ static long process(paddr)
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(status==1) return(0);
|
||||
|
||||
/* convert the value */
|
||||
/* calculate the readback value */
|
||||
if (pmbbo->sdef){
|
||||
unsigned long *pstate_values;
|
||||
short i;
|
||||
unsigned long rval = pmbbo->rval;
|
||||
|
||||
pstate_values = &(pmbbo->zrvl);
|
||||
rbv = -1; /* initalize to unknown state*/
|
||||
for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == pmbbo->rval){
|
||||
rbv = udfShort; /* initalize to unknown state*/
|
||||
if(rval!=udfUlong) for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == rval){
|
||||
rbv = i;
|
||||
break;
|
||||
}
|
||||
@@ -283,7 +293,7 @@ static long get_enum_str(paddr,pstring)
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
static long get_enum_strs(paddr,pes)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_enumStrs *pes;
|
||||
@@ -298,6 +308,26 @@ static long get_enum_strs(paddr,pes)
|
||||
strncpy(pes->strs[i],psource,sizeof(pmbbo->zrst));
|
||||
return(0);
|
||||
}
|
||||
static long put_enum_str(paddr,pstring)
|
||||
struct dbAddr *paddr;
|
||||
char *pstring;
|
||||
{
|
||||
struct mbboRecord *pmbbo=(struct mbboRecord *)paddr->precord;
|
||||
char *pstate_name;
|
||||
short i;
|
||||
|
||||
if (pmbbo->sdef){
|
||||
pstate_name = pmbbo->zrst;
|
||||
for (i = 0; i < 16; i++){
|
||||
if(strncmp(pstate_name,pstring,sizeof(pmbbo->zrst))==0){
|
||||
pmbbo->val = i;
|
||||
return(0);
|
||||
}
|
||||
pstate_name += sizeof(pmbbo->zrst);
|
||||
}
|
||||
}
|
||||
return(S_db_badChoice);
|
||||
}
|
||||
|
||||
static void alarm(pmbbo)
|
||||
struct mbboRecord *pmbbo;
|
||||
@@ -323,11 +353,13 @@ static void alarm(pmbbo)
|
||||
}
|
||||
|
||||
/* check for cos alarm */
|
||||
if(val == pmbbo->lalm) return;
|
||||
if (pmbbo->nsev<pmbbo->cosv){
|
||||
pmbbo->nsta = COS_ALARM;
|
||||
pmbbo->nsev = pmbbo->cosv;
|
||||
return;
|
||||
}
|
||||
pmbbo->lalm = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -77,6 +78,7 @@ struct rset permissiveRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
@@ -61,6 +61,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -78,6 +79,7 @@ struct rset pidRSET={
|
||||
put_array_info,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_units,
|
||||
get_precision,
|
||||
get_graphic_double,
|
||||
@@ -93,11 +95,6 @@ long do_pid();
|
||||
static long init_record(ppid)
|
||||
struct pidRecord *ppid;
|
||||
{
|
||||
/* initialize so that first alarm, archive, and monitor get generated*/
|
||||
ppid->lalm = 1e30;
|
||||
ppid->alst = 1e30;
|
||||
ppid->mlst = 1e30;
|
||||
|
||||
/* initialize the setpoint for constant setpoint */
|
||||
if (ppid->stpl.type == CONSTANT)
|
||||
ppid->val = ppid->stpl.value.value;
|
||||
@@ -293,7 +290,7 @@ static void monitor(ppid)
|
||||
}
|
||||
/* check for archive change */
|
||||
delta = ppid->alst - ppid->val;
|
||||
if(delta<0.0) delta = 0.0;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if (delta > ppid->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
|
||||
@@ -62,6 +62,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -81,6 +82,7 @@ struct rset selRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -99,11 +101,6 @@ int do_sel();
|
||||
static long init_record(psel)
|
||||
struct selRecord *psel;
|
||||
{
|
||||
/* initialize so that first alarm, archive, and monitor get generated*/
|
||||
psel->lalm = 1e30;
|
||||
psel->alst = 1e30;
|
||||
psel->mlst = 1e30;
|
||||
|
||||
if(psel->inpa.type==CONSTANT) psel->a = psel->inpa.value.value;
|
||||
if(psel->inpb.type==CONSTANT) psel->b = psel->inpb.value.value;
|
||||
if(psel->inpc.type==CONSTANT) psel->c = psel->inpc.value.value;
|
||||
@@ -305,7 +302,7 @@ static void monitor(psel)
|
||||
}
|
||||
/* check for archive change */
|
||||
delta = psel->alst - psel->val;
|
||||
if(delta<0.0) delta = 0.0;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if (delta > psel->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
|
||||
@@ -59,6 +59,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -78,6 +79,7 @@ struct rset stateRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
@@ -62,6 +62,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -81,6 +82,7 @@ struct rset subRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
@@ -327,7 +329,7 @@ static void monitor(psub)
|
||||
}
|
||||
/* check for archive change */
|
||||
delta = psub->alst - psub->val;
|
||||
if(delta<0.0) delta = 0.0;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if (delta > psub->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
|
||||
@@ -70,6 +70,7 @@ long get_value();
|
||||
#define get_precision NULL
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
@@ -89,6 +90,7 @@ struct rset timerRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
@@ -76,6 +76,7 @@ long get_units();
|
||||
long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
@@ -95,6 +96,7 @@ struct rset waveformRSET={
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
Reference in New Issue
Block a user