Los Alamos Record Support Merge for R3.12
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* recAi.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recAi.c - Record Support Routines for Analog Input records */
|
||||
/*
|
||||
@@ -69,6 +69,7 @@
|
||||
* .30 07-21-92 jba changed alarm limits for non val related fields
|
||||
* .31 08-06-92 jba New algorithm for calculating analog alarms
|
||||
* .32 08-13-92 jba Added simulation processing
|
||||
* .33 03-29-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -160,37 +161,21 @@ static long init_record(pai,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* ai.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pai->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pai->siml.type == CONSTANT) {
|
||||
pai->simm = pai->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pai->siml), (void *) pai, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pai,
|
||||
"ai: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pai->siml), (void *) pai, DBR_ENUM, "SIMM");
|
||||
if (status) return(status);
|
||||
}
|
||||
|
||||
/* ai.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pai->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (pai->siol.type == CONSTANT) {
|
||||
pai->sval = pai->siol.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pai->siol), (void *) pai, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pai,
|
||||
"ai: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pai->siol), (void *) pai, DBR_DOUBLE, "SVAL");
|
||||
if (status) return(status);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct aidset *)(pai->dset))) {
|
||||
@@ -226,7 +211,7 @@ static long process(pai)
|
||||
/* event throttling */
|
||||
/*Will not work with new event systems*/
|
||||
/*
|
||||
if (pai->scan == SCAN_IO_EVENT){
|
||||
if (pai->scan == SCAN_IO_EVENT) {
|
||||
if ((pai->evnt != 0) && (gts_trigger_counter != 0)){
|
||||
if ((gts_trigger_counter % pai->evnt) != 0){
|
||||
return(0);
|
||||
@@ -484,16 +469,14 @@ static long readValue(pai)
|
||||
{
|
||||
long status;
|
||||
struct aidset *pdset = (struct aidset *) (pai->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pai->pact == TRUE){
|
||||
status=(*pdset->read_ai)(pai);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pai->siml),
|
||||
(void *)pai,DBR_ENUM,&(pai->simm),&options,&nRequest);
|
||||
status = recGblGetFastLink(&(pai->siml), (void *)pai, &(pai->simm));
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -502,8 +485,7 @@ static long readValue(pai)
|
||||
return(status);
|
||||
}
|
||||
if (pai->simm == YES){
|
||||
status=recGblGetLinkValue(&(pai->siol),
|
||||
(void *)pai,DBR_DOUBLE,&(pai->sval),&options,&nRequest);
|
||||
status = recGblGetFastLink(&(pai->siol), (void *)pai, &(pai->sval));
|
||||
if (status==0){
|
||||
pai->val=pai->sval;
|
||||
pai->udf=FALSE;
|
||||
|
||||
106
src/rec/recAo.c
106
src/rec/recAo.c
@@ -1,5 +1,5 @@
|
||||
/* recAo.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recAo.c - Record Support Routines for Analog Output records */
|
||||
/*
|
||||
@@ -66,7 +66,8 @@
|
||||
* .33 08-19-92 jba Added code for invalid alarm output action
|
||||
* .34 10-15-93 jba modified oroc test to work on the mv162
|
||||
* .35 03-03-94 mrk Added aslo and aoff
|
||||
|
||||
* .36 03-29-94 mcn Fast links. Moved omsl and dol.type check
|
||||
* out of fetch_value.
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -157,45 +158,43 @@ static long init_record(pao,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* ao.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pao->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pao->siml.type == CONSTANT) {
|
||||
pao->simm = pao->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pao->siml), (void *) pao, "SIMM");
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pao->siml), (void *) pao, DBR_ENUM, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pao,
|
||||
"ao: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
/* ao.siol may be a PV_LINK */
|
||||
if (pao->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(pao->siol), (void *) pao, "OVAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
status = recGblInitFastOutLink(&(pao->siol), (void *) pao, DBR_DOUBLE, "OVAL");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if(!(pdset = (struct aodset *)(pao->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)pao,"ao: init_record");
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* get the initial value if dol is a constant*/
|
||||
if (pao->dol.type == CONSTANT ){
|
||||
if (pao->dol.type == CONSTANT) {
|
||||
pao->udf = FALSE;
|
||||
pao->val = pao->dol.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pao->dol), (void *) pao,
|
||||
DBR_DOUBLE, "VAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* must have write_ao function defined */
|
||||
if( (pdset->number < 6) || (pdset->write_ao ==NULL) ) {
|
||||
if ((pdset->number < 6) || (pdset->write_ao ==NULL)) {
|
||||
recGblRecordError(S_dev_missingSup,(void *)pao,"ao: init_record");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
pao->init = TRUE;
|
||||
|
||||
if( pdset->init_record ) {
|
||||
if (pdset->init_record) {
|
||||
status=(*pdset->init_record)(pao);
|
||||
switch(status){
|
||||
case(0): /* convert */
|
||||
@@ -233,16 +232,23 @@ static long process(pao)
|
||||
unsigned char pact=pao->pact;
|
||||
double value;
|
||||
|
||||
if( (pdset==NULL) || (pdset->write_ao==NULL) ) {
|
||||
if ((pdset==NULL) || (pdset->write_ao==NULL)) {
|
||||
pao->pact=TRUE;
|
||||
recGblRecordError(S_dev_missingSup,(void *)pao,"write_ao");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
|
||||
/* fetch value and convert*/
|
||||
if(pao->pact == FALSE){
|
||||
fetch_value(pao,&value);
|
||||
convert(pao,&value);
|
||||
if (pao->pact == FALSE) {
|
||||
if ((pao->dol.type != CONSTANT) &&
|
||||
(pao->omsl == CLOSED_LOOP)) {
|
||||
|
||||
fetch_value(pao, &value);
|
||||
}
|
||||
else {
|
||||
value = pao->val;
|
||||
}
|
||||
convert(pao, &value);
|
||||
}
|
||||
|
||||
/* check for alarms */
|
||||
@@ -446,28 +452,26 @@ static void fetch_value(pao,pvalue)
|
||||
struct aoRecord *pao;
|
||||
double *pvalue;
|
||||
{
|
||||
short save_pact;
|
||||
long status;
|
||||
|
||||
if ((pao->dol.type == DB_LINK) && (pao->omsl == CLOSED_LOOP)){
|
||||
long nRequest;
|
||||
long options;
|
||||
short save_pact;
|
||||
long status;
|
||||
save_pact = pao->pact;
|
||||
pao->pact = TRUE;
|
||||
|
||||
/* don't allow dbputs to val field */
|
||||
pao->val=pao->pval;
|
||||
|
||||
status = recGblGetFastLink(&pao->dol, (void *) pao, pvalue);
|
||||
pao->pact = save_pact;
|
||||
|
||||
if (status) {
|
||||
recGblSetSevr(pao,LINK_ALARM,INVALID_ALARM);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pao->oif == OUTPUT_INCREMENTAL)
|
||||
*pvalue += pao->val;
|
||||
|
||||
options=0;
|
||||
nRequest=1;
|
||||
save_pact = pao->pact;
|
||||
pao->pact = TRUE;
|
||||
/* don't allow dbputs to val field */
|
||||
pao->val=pao->pval;
|
||||
status = dbGetLink(&pao->dol.value.db_link,(struct dbCommon *)pao,DBR_DOUBLE,
|
||||
pvalue,&options,&nRequest);
|
||||
pao->pact = save_pact;
|
||||
if(status) {
|
||||
recGblSetSevr(pao,LINK_ALARM,INVALID_ALARM);
|
||||
return;
|
||||
}
|
||||
if (pao->oif == OUTPUT_INCREMENTAL) *pvalue += pao->val;
|
||||
} else *pvalue = pao->val;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -500,7 +504,7 @@ static void convert(pao,pvalue)
|
||||
pao->oval = value;
|
||||
|
||||
/* convert */
|
||||
if (pao->linr == 0){
|
||||
if (pao->linr == 0) {
|
||||
; /* do nothing*/
|
||||
} else if (pao->linr == 1){
|
||||
if (pao->eslo == 0.0) value = 0;
|
||||
@@ -572,16 +576,13 @@ static long writeValue(pao)
|
||||
{
|
||||
long status;
|
||||
struct aodset *pdset = (struct aodset *) (pao->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pao->pact == TRUE){
|
||||
status=(*pdset->write_ao)(pao);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pao->siml),
|
||||
(void *)pao,DBR_ENUM,&(pao->simm),&options,&nRequest);
|
||||
status = recGblGetFastLink(&(pao->siml), (void *)pao, &(pao->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -590,8 +591,7 @@ static long writeValue(pao)
|
||||
return(status);
|
||||
}
|
||||
if (pao->simm == YES){
|
||||
status=recGblPutLinkValue(&(pao->siol),
|
||||
(void *)pao,DBR_DOUBLE,&(pao->oval),&nRequest);
|
||||
status = recGblPutFastLink(&(pao->siol), (void *)pao, &(pao->oval));
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pao,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* recBi.c */
|
||||
/* share/src/rec $Id$ */
|
||||
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recBi.c - Record Support Routines for Binary Input records */
|
||||
/*
|
||||
* Original Author: Bob Dalesio
|
||||
@@ -53,6 +53,7 @@
|
||||
* .19 07-15-92 jba changed VALID_ALARM to INVALID alarm
|
||||
* .20 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .21 08-13-92 jba Added simulation processing
|
||||
* .22 03-29-94 mcn Converted to Fast Links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -130,37 +131,23 @@ static long init_record(pbi,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* bi.siml must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pbi->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pbi->siml.type == CONSTANT) {
|
||||
pbi->simm = pbi->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pbi->siml), (void *) pbi, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pbi,
|
||||
"bi: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pbi->siml), (void *) pbi, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* bi.siol must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pbi->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (pbi->siol.type == CONSTANT) {
|
||||
pbi->sval = pbi->siol.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pbi->siol), (void *) pbi, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pbi,
|
||||
"bi: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pbi->siol), (void *) pbi, DBR_USHORT, "SVAL");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct bidset *)(pbi->dset))) {
|
||||
@@ -323,16 +310,13 @@ static long readValue(pbi)
|
||||
{
|
||||
long status;
|
||||
struct bidset *pdset = (struct bidset *) (pbi->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pbi->pact == TRUE){
|
||||
status=(*pdset->read_bi)(pbi);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pbi->siml),
|
||||
(void *)pbi,DBR_ENUM,&(pbi->simm),&options,&nRequest);
|
||||
status = recGblGetFastLink(&(pbi->siml), (void *)pbi, &(pbi->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -341,8 +325,7 @@ static long readValue(pbi)
|
||||
return(status);
|
||||
}
|
||||
if (pbi->simm == YES){
|
||||
status=recGblGetLinkValue(&(pbi->siol),
|
||||
(void *)pbi,DBR_USHORT,&(pbi->sval),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pbi->siol), (void *)pbi, &(pbi->sval));
|
||||
if (status==0){
|
||||
pbi->val=pbi->sval;
|
||||
pbi->udf=FALSE;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* recBo.c */
|
||||
/* share/src/rec $Id$ */
|
||||
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recBo.c - Record Support Routines for Binary Output records */
|
||||
/*
|
||||
* Original Author: Bob Dalesio
|
||||
@@ -63,7 +63,8 @@
|
||||
* .27 08-14-92 jba Added simulation processing
|
||||
* .28 08-19-92 jba Added code for invalid alarm output action
|
||||
* .29 11-01-93 jba Added get_precision routine
|
||||
* .30 04-05-94 mrk ANSI changes to callback routines
|
||||
* .30 03-29-94 mcn Converted to fast links
|
||||
* .31 04-05-94 mrk ANSI changes to callback routines
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -171,27 +172,19 @@ static long init_record(pbo,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* bo.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pbo->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pbo->siml.type == CONSTANT) {
|
||||
pbo->simm = pbo->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pbo->siml), (void *) pbo, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pbo,
|
||||
"bo: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pbo->siml), (void *) pbo, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* bo.siol may be a PV_LINK */
|
||||
if (pbo->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(pbo->siol), (void *) pbo, "VAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
/* bo.siol */
|
||||
status = recGblInitFastOutLink(&(pbo->siol), (void *) pbo, DBR_USHORT, "VAL");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if(!(pdset = (struct bodset *)(pbo->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)pbo,"bo: init_record");
|
||||
@@ -203,11 +196,18 @@ static long init_record(pbo,pass)
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
/* get the initial value */
|
||||
if (pbo->dol.type == CONSTANT){
|
||||
if (pbo->dol.type == CONSTANT) {
|
||||
if (pbo->dol.value.value == 0) pbo->val = 0;
|
||||
else pbo->val = 1;
|
||||
pbo->udf = FALSE;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pbo->dol), (void *) pbo, DBR_USHORT, "VAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
pcallback = (struct callback *)(calloc(1,sizeof(struct callback)));
|
||||
pbo->rpvt = (void *)pcallback;
|
||||
callbackSetCallback(myCallback,&pcallback->callback);
|
||||
@@ -238,14 +238,11 @@ static long process(pbo)
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if (!pbo->pact) {
|
||||
if((pbo->dol.type == DB_LINK) && (pbo->omsl == CLOSED_LOOP)){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
if ((pbo->dol.type != CONSTANT) && (pbo->omsl == CLOSED_LOOP)){
|
||||
unsigned short val;
|
||||
|
||||
pbo->pact = TRUE;
|
||||
status = dbGetLink(&pbo->dol.value.db_link,(struct dbCommon *)pbo,
|
||||
DBR_USHORT,&val,&options,&nRequest);
|
||||
status = recGblGetFastLink(&pbo->dol, (void *) pbo, &val);
|
||||
pbo->pact = FALSE;
|
||||
if(status==0){
|
||||
pbo->val = val;
|
||||
@@ -298,12 +295,12 @@ static long process(pbo)
|
||||
|
||||
recGblGetTimeStamp(pbo);
|
||||
wait_time = (int)((pbo->high) * vxTicksPerSecond); /* seconds to ticks */
|
||||
if(pbo->val==1 && wait_time>0) {
|
||||
if (pbo->val==1 && wait_time>0) {
|
||||
struct callback *pcallback;
|
||||
pcallback = (struct callback *)(pbo->rpvt);
|
||||
if(pcallback->wd_id==NULL) pcallback->wd_id = wdCreate();
|
||||
callbackSetPriority(pbo->prio,&pcallback->callback);
|
||||
wdStart(pcallback->wd_id,wait_time,(FUNCPTR)callbackRequest,(int)pcallback);
|
||||
callbackSetPriority(pbo->prio, &pcallback->callback);
|
||||
wdStart(pcallback->wd_id, wait_time, (FUNCPTR)callbackRequest, (int)pcallback);
|
||||
}
|
||||
/* check event list */
|
||||
monitor(pbo);
|
||||
@@ -436,16 +433,13 @@ static long writeValue(pbo)
|
||||
{
|
||||
long status;
|
||||
struct bodset *pdset = (struct bodset *) (pbo->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pbo->pact == TRUE){
|
||||
status=(*pdset->write_bo)(pbo);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pbo->siml),
|
||||
(void *)pbo,DBR_ENUM,&(pbo->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pbo->siml), (void *)pbo, &(pbo->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -454,8 +448,7 @@ static long writeValue(pbo)
|
||||
return(status);
|
||||
}
|
||||
if (pbo->simm == YES){
|
||||
status=recGblPutLinkValue(&(pbo->siol),
|
||||
(void *)pbo,DBR_USHORT,&(pbo->val),&nRequest);
|
||||
status=recGblPutFastLink(&(pbo->siol), (void *)pbo, &(pbo->val));
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pbo,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recCalc.c */
|
||||
/* share/src/rec @(#)recCalc.c 1.15 4/6/92 */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recCalc.c - Record Support Routines for Calculation records */
|
||||
/*
|
||||
@@ -153,13 +153,14 @@ static long init_record(pcalc,pass)
|
||||
plink = &pcalc->inpa;
|
||||
pvalue = &pcalc->a;
|
||||
for(i=0; i<ARG_MAX; i++, plink++, pvalue++) {
|
||||
if(plink->type==CONSTANT)
|
||||
if (plink->type == CONSTANT) {
|
||||
*pvalue = plink->value.value;
|
||||
if (plink->type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(plink, (void *) pcalc, Fldnames[i]);
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(plink, (void *) pcalc, DBR_DOUBLE, Fldnames[i]);
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
status=postfix(pcalc->calc,rpbuf,&error_number);
|
||||
if(status){
|
||||
@@ -417,14 +418,12 @@ struct calcRecord *pcalc;
|
||||
{
|
||||
struct link *plink; /* structure of the link field */
|
||||
double *pvalue;
|
||||
long status=0,options=0,nRequest=1;
|
||||
long status = 0;
|
||||
int i;
|
||||
|
||||
for(i=0, plink=&pcalc->inpa, pvalue=&pcalc->a; i<ARG_MAX; i++, plink++, pvalue++) {
|
||||
|
||||
if(plink->type!=CONSTANT)
|
||||
status = recGblGetLinkValue(plink,(void *)pcalc,
|
||||
DBR_DOUBLE,pvalue,&options,&nRequest);
|
||||
status = recGblGetFastLink(plink, (void *)pcalc, pvalue);
|
||||
|
||||
if (!RTN_SUCCESS(status)) return(status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recCompress.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recCompress.c - Record Support Routines for Compression records*/
|
||||
/*
|
||||
@@ -458,7 +458,7 @@ long no_elements;
|
||||
inx++;
|
||||
if(pcompress->n<=0)pcompress->n=1;
|
||||
n = pcompress->n;
|
||||
if(inx<n) {
|
||||
if (inx<n) {
|
||||
pcompress->inx = inx;
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recEvent.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recEvent.c - Record Support Routines for Event records */
|
||||
/*
|
||||
@@ -35,6 +35,7 @@
|
||||
* .03 04-18-92 jba removed process from dev init_record parms
|
||||
* .04 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .05 08-17-92 jba added simulation mode handling
|
||||
* .06 03-29-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -112,38 +113,23 @@ static long init_record(pevent,pass)
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* event.siml must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pevent->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pevent->siml.type == CONSTANT) {
|
||||
pevent->simm = pevent->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pevent->siml), (void *) pevent, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pevent,
|
||||
"event: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pevent->siml), (void *) pevent, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* event.siol must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pevent->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (pevent->siol.type == CONSTANT) {
|
||||
pevent->sval = pevent->siol.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pevent->siol), (void *) pevent, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pevent,
|
||||
"event: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pevent->siol), (void *) pevent, DBR_USHORT, "SVAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
if( (pdset=(struct eventdset *)(pevent->dset)) && (pdset->init_record) )
|
||||
@@ -206,16 +192,14 @@ static long readValue(pevent)
|
||||
{
|
||||
long status;
|
||||
struct eventdset *pdset = (struct eventdset *) (pevent->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pevent->pact == TRUE){
|
||||
status=(*pdset->read_event)(pevent);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pevent->siml),
|
||||
(void *)pevent,DBR_ENUM,&(pevent->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pevent->siml), (void *)pevent, &(pevent->simm));
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -224,9 +208,8 @@ static long readValue(pevent)
|
||||
return(status);
|
||||
}
|
||||
if (pevent->simm == YES){
|
||||
status=recGblGetLinkValue(&(pevent->siol),
|
||||
(void *)pevent,DBR_USHORT,&(pevent->sval),&options,&nRequest);
|
||||
if (status==0){
|
||||
status=recGblGetFastLink(&(pevent->siol), (void *)pevent, &(pevent->sval));
|
||||
if (status==0) {
|
||||
pevent->val=pevent->sval;
|
||||
pevent->udf=FALSE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* recFanout.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recFanout.c - Record Support Routines for Fanout records */
|
||||
/*
|
||||
* Original Author: Bob Dalesio
|
||||
@@ -45,7 +46,7 @@
|
||||
* .14 07-15-92 jba changed VALID_ALARM to INVALID alarm
|
||||
* .15 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .16 09-10-92 jba replaced fetch link selection with call to recGblGetLinkValue
|
||||
|
||||
* .17 03-29-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -115,14 +116,15 @@ static long init_record(pfanout,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* get link selection if sell is a constant and nonzero*/
|
||||
if (pfanout->sell.type==CONSTANT && pfanout->sell.value.value!=0 ){
|
||||
pfanout->seln = pfanout->sell.value.value;
|
||||
if (pfanout->sell.type == CONSTANT) {
|
||||
if (pfanout->sell.value.value != 0)
|
||||
pfanout->seln = pfanout->sell.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pfanout->sell), (void *) pfanout, DBR_USHORT, "SELN");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
if (pfanout->sell.type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(&(pfanout->sell), (void *) pfanout, "SELN");
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recGsub.c */
|
||||
/* share/src/rec @(#)recGsub.c 1.18 9/14/92 */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recGsub.c - Record Support Routines for Subroutine records */
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recHistogram.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recHistogram.c - Record Support Routines for Histogram records */
|
||||
/*
|
||||
@@ -37,6 +37,7 @@
|
||||
* .06 07-15-92 jba changed VALID_ALARM to INVALID alarm
|
||||
* .07 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .08 08-13-92 jba Added simulation processing
|
||||
* .09 01-24-94 mcn Converted to Fast Links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -191,38 +192,23 @@ static long init_record(phistogram,pass)
|
||||
wdStart(pcallback->wd_id,wait_time,(FUNCPTR)callbackRequest,(int)pcallback);
|
||||
}
|
||||
|
||||
/* histogram.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (phistogram->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (phistogram->siml.type == CONSTANT) {
|
||||
phistogram->simm = phistogram->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(phistogram->siml), (void *) phistogram, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)phistogram,
|
||||
"histogram: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(phistogram->siml), (void *) phistogram, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* histogram.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (phistogram->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (phistogram->siol.type == CONSTANT) {
|
||||
phistogram->sval = phistogram->siol.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(phistogram->siol), (void *) phistogram, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)phistogram,
|
||||
"histogram: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(phistogram->siol), (void *) phistogram, DBR_DOUBLE, "SVAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* must have device support defined */
|
||||
@@ -413,16 +399,14 @@ static long readValue(phistogram)
|
||||
{
|
||||
long status;
|
||||
struct histogramdset *pdset = (struct histogramdset *) (phistogram->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (phistogram->pact == TRUE){
|
||||
status=(*pdset->read_histogram)(phistogram);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(phistogram->siml),
|
||||
(void *)phistogram,DBR_ENUM,&(phistogram->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(phistogram->siml), (void *)phistogram, &(phistogram->simm));
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -431,8 +415,7 @@ static long readValue(phistogram)
|
||||
return(status);
|
||||
}
|
||||
if (phistogram->simm == YES){
|
||||
status=recGblGetLinkValue(&(phistogram->siol),
|
||||
(void *)phistogram,DBR_DOUBLE,&(phistogram->sval),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(phistogram->siol), (void *)phistogram, &(phistogram->sval));
|
||||
if (status==0){
|
||||
phistogram->sgnl=phistogram->sval;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recLongin.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recLongin.c - Record Support Routines for Longin records */
|
||||
/*
|
||||
@@ -41,6 +41,7 @@
|
||||
* .10 07-21-92 jba changed alarm limits for non val related fields
|
||||
* .11 08-06-92 jba New algorithm for calculating analog alarms
|
||||
* .12 08-13-92 jba Added simulation processing
|
||||
* .13 03-29-94 mcn Converted to Fast Links
|
||||
*/
|
||||
|
||||
|
||||
@@ -122,37 +123,21 @@ static long init_record(plongin,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* longin.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (plongin->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (plongin->siml.type == CONSTANT) {
|
||||
plongin->simm = plongin->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(plongin->siml), (void *) plongin, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)plongin,
|
||||
"longin: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(plongin->siml), (void *) plongin, DBR_ENUM, "SIMM");
|
||||
if (status) return(status);
|
||||
}
|
||||
|
||||
/* longin.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (plongin->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (plongin->siol.type == CONSTANT) {
|
||||
plongin->sval = plongin->siol.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(plongin->siol), (void *) plongin, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)plongin,
|
||||
"longin: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(plongin->siol), (void *) plongin, DBR_LONG, "SVAL");
|
||||
if (status) return(status);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct longindset *)(plongin->dset))) {
|
||||
@@ -354,18 +339,15 @@ static void monitor(plongin)
|
||||
static long readValue(plongin)
|
||||
struct longinRecord *plongin;
|
||||
{
|
||||
long status;
|
||||
struct longindset *pdset = (struct longindset *) (plongin->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
long status;
|
||||
struct longindset *pdset = (struct longindset *) (plongin->dset);
|
||||
|
||||
if (plongin->pact == TRUE){
|
||||
status=(*pdset->read_longin)(plongin);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(plongin->siml),
|
||||
(void *)plongin,DBR_ENUM,&(plongin->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(plongin->siml), (void *)plongin, &(plongin->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -374,9 +356,9 @@ static long readValue(plongin)
|
||||
return(status);
|
||||
}
|
||||
if (plongin->simm == YES){
|
||||
status=recGblGetLinkValue(&(plongin->siol),
|
||||
(void *)plongin,DBR_LONG,&(plongin->sval),&options,&nRequest);
|
||||
if (status==0){
|
||||
status=recGblGetFastLink(&(plongin->siol), (void *)plongin, &(plongin->sval));
|
||||
|
||||
if (status==0) {
|
||||
plongin->val=plongin->sval;
|
||||
plongin->udf=FALSE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recLongout.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recLongout.c - Record Support Routines for Longout records */
|
||||
/*
|
||||
@@ -43,6 +43,7 @@
|
||||
* .12 08-19-92 jba Added code for invalid alarm output action
|
||||
* .13 09-10-92 jba modified fetch of val from dol to call recGblGetLinkValue
|
||||
* .14 09-18-92 jba pact now set in recGblGetLinkValue
|
||||
* .15 03-29-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
|
||||
@@ -124,27 +125,16 @@ static long init_record(plongout,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* longout.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (plongout->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (plongout->siml.type == CONSTANT) {
|
||||
plongout->simm = plongout->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(plongout->siml), (void *) plongout, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)plongout,
|
||||
"longout: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(plongout->siml), (void *) plongout, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* longout.siol may be a PV_LINK */
|
||||
if (plongout->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(plongout->siol), (void *) plongout, "VAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
status = recGblInitFastOutLink(&(plongout->siol), (void *) plongout, DBR_LONG, "VAL");
|
||||
|
||||
if(!(pdset = (struct longoutdset *)(plongout->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)plongout,"longout: init_record");
|
||||
@@ -156,15 +146,14 @@ static long init_record(plongout,pass)
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
/* get the initial value dol is a constant*/
|
||||
if (plongout->dol.type == CONSTANT){
|
||||
if (plongout->dol.type == CONSTANT) {
|
||||
plongout->val = plongout->dol.value.value;
|
||||
plongout->udf=FALSE;
|
||||
}
|
||||
if (plongout->dol.type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(&(plongout->dol), (void *) plongout, "VAL");
|
||||
else {
|
||||
status = recGblInitFastInLink(&(plongout->dol), (void *) plongout, DBR_LONG, "VAL");
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
}
|
||||
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(plongout))) return(status);
|
||||
@@ -184,13 +173,13 @@ static long process(plongout)
|
||||
recGblRecordError(S_dev_missingSup,(void *)plongout,"write_longout");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if (!plongout->pact && plongout->omsl == CLOSED_LOOP){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
if (!plongout->pact && plongout->omsl == CLOSED_LOOP) {
|
||||
|
||||
status = recGblGetLinkValue(&(plongout->dol),(void *)plongout,
|
||||
DBR_LONG,&(plongout->val),&options,&nRequest);
|
||||
if(RTN_SUCCESS(status)) plongout->udf=FALSE;
|
||||
status = recGblGetFastLink(&(plongout->dol), (void *)plongout,
|
||||
&(plongout->val));
|
||||
|
||||
if (RTN_SUCCESS(status))
|
||||
plongout->udf=FALSE;
|
||||
}
|
||||
|
||||
/* check for alarms */
|
||||
@@ -386,16 +375,13 @@ static long writeValue(plongout)
|
||||
{
|
||||
long status;
|
||||
struct longoutdset *pdset = (struct longoutdset *) (plongout->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (plongout->pact == TRUE){
|
||||
status=(*pdset->write_longout)(plongout);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(plongout->siml),
|
||||
(void *)plongout,DBR_ENUM,&(plongout->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(plongout->siml), (void *)plongout, &(plongout->simm));
|
||||
if (!RTN_SUCCESS(status))
|
||||
return(status);
|
||||
|
||||
@@ -404,8 +390,7 @@ static long writeValue(plongout)
|
||||
return(status);
|
||||
}
|
||||
if (plongout->simm == YES){
|
||||
status=recGblPutLinkValue(&(plongout->siol),
|
||||
(void *)plongout,DBR_LONG,&(plongout->val),&nRequest);
|
||||
status=recGblPutFastLink(&(plongout->siol), (void *)plongout, &(plongout->val));
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(plongout,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recMbbi.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recMbbi.c - Record Support Routines for multi bit binary Input records */
|
||||
/*
|
||||
@@ -54,6 +54,7 @@
|
||||
* .19 07-15-92 jba changed VALID_ALARM to INVALID alarm
|
||||
* .20 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .21 08-14-92 jba Added simulation processing
|
||||
* .22 03-29-94 mcn converted to fast links.
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -152,37 +153,23 @@ static long init_record(pmbbi,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* mbbi.siml must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pmbbi->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pmbbi->siml.type == CONSTANT) {
|
||||
pmbbi->simm = pmbbi->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pmbbi->siml), (void *) pmbbi, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pmbbi,
|
||||
"mbbi: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbi->siml), (void *) pmbbi, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* mbbi.siol must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pmbbi->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (pmbbi->siol.type == CONSTANT) {
|
||||
pmbbi->sval = pmbbi->siol.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pmbbi->siol), (void *) pmbbi, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pmbbi,
|
||||
"mbbi: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbi->siol), (void *) pmbbi, DBR_USHORT, "SVAL");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct mbbidset *)(pmbbi->dset))) {
|
||||
@@ -408,16 +395,13 @@ static long readValue(pmbbi)
|
||||
{
|
||||
long status;
|
||||
struct mbbidset *pdset = (struct mbbidset *) (pmbbi->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pmbbi->pact == TRUE){
|
||||
status=(*pdset->read_mbbi)(pmbbi);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pmbbi->siml),
|
||||
(void *)pmbbi,DBR_ENUM,&(pmbbi->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pmbbi->siml), (void *)pmbbi, &(pmbbi->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -426,8 +410,7 @@ static long readValue(pmbbi)
|
||||
return(status);
|
||||
}
|
||||
if (pmbbi->simm == YES){
|
||||
status=recGblGetLinkValue(&(pmbbi->siol),
|
||||
(void *)pmbbi,DBR_USHORT,&(pmbbi->sval),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pmbbi->siol), (void *)pmbbi, &(pmbbi->sval));
|
||||
if (status==0){
|
||||
pmbbi->val=pmbbi->sval;
|
||||
pmbbi->udf=FALSE;
|
||||
|
||||
299
src/rec/recMbbiDirect.c
Normal file
299
src/rec/recMbbiDirect.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/* recMbbiDirect.c */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recMbbiDirect.c - Record Support routines for mbboDirect records */
|
||||
/*
|
||||
* Original Author: Bob Dalesio
|
||||
* Current Author: Matthew Needes
|
||||
* Date: 10-07-93
|
||||
*
|
||||
* 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:
|
||||
* -----------------
|
||||
* (modifications to mbbi apply, see mbbi record)
|
||||
* 1. 10-20-93 mcn "Created" by borrowing mbbi record code
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <lstLib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <devSup.h>
|
||||
#include <errMdef.h>
|
||||
#include <recSup.h>
|
||||
#include <special.h>
|
||||
#include <mbbiDirectRecord.h>
|
||||
|
||||
/* Create RSET - Record Support Entry Table*/
|
||||
#define report NULL
|
||||
#define initialize NULL
|
||||
static long init_record();
|
||||
static long process();
|
||||
#define special NULL
|
||||
static long get_value();
|
||||
#define cvt_dbaddr NULL
|
||||
#define get_array_info NULL
|
||||
#define put_array_info NULL
|
||||
#define get_units NULL
|
||||
#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
|
||||
|
||||
struct rset mbbiDirectRSET={
|
||||
RSETNUMBER,
|
||||
report,
|
||||
initialize,
|
||||
init_record,
|
||||
process,
|
||||
special,
|
||||
get_value,
|
||||
cvt_dbaddr,
|
||||
get_array_info,
|
||||
put_array_info,
|
||||
get_units,
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
struct mbbidset { /* multi bit binary input dset */
|
||||
long number;
|
||||
DEVSUPFUN dev_report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_mbbi;/*(0,2)=>(success, success no convert)*/
|
||||
};
|
||||
|
||||
static void refresh_bits();
|
||||
static void monitor();
|
||||
static long readValue();
|
||||
|
||||
#define NUM_BITS 16
|
||||
|
||||
/* refreshes all the bit fields based on a hardware value */
|
||||
static void refresh_bits(pmbbiDirect)
|
||||
struct mbbiDirectRecord *pmbbiDirect;
|
||||
{
|
||||
int i, mask = 1;
|
||||
char *bit;
|
||||
|
||||
pmbbiDirect->udf = FALSE;
|
||||
|
||||
bit = &(pmbbiDirect->b0);
|
||||
for (i=0; i<NUM_BITS; i++, mask = mask << 1, bit++) {
|
||||
if (pmbbiDirect->val & mask) {
|
||||
if (*bit == 0) {
|
||||
*bit = 1;
|
||||
db_post_events(pmbbiDirect,bit,DBE_VALUE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (*bit != 0) {
|
||||
*bit = 0;
|
||||
db_post_events(pmbbiDirect,bit,DBE_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static long init_record(pmbbiDirect,pass)
|
||||
struct mbbiDirectRecord *pmbbiDirect;
|
||||
int pass;
|
||||
{
|
||||
struct mbbidset *pdset;
|
||||
long status;
|
||||
int i;
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
if (pmbbiDirect->siml.type == CONSTANT) {
|
||||
pmbbiDirect->simm = pmbbiDirect->siml.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbiDirect->siml), (void *) pmbbiDirect, DBR_ENUM, "SIMM");
|
||||
if (status) return(status);
|
||||
}
|
||||
|
||||
if (pmbbiDirect->siol.type == CONSTANT) {
|
||||
pmbbiDirect->sval = pmbbiDirect->siol.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbiDirect->siol), (void *) pmbbiDirect, DBR_USHORT, "SVAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct mbbidset *)(pmbbiDirect->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)pmbbiDirect,"mbbiDirect: init_record");
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* must have read_mbbi function defined */
|
||||
if( (pdset->number < 5) || (pdset->read_mbbi == NULL) ) {
|
||||
recGblRecordError(S_dev_missingSup,(void *)pmbbiDirect,"mbbiDirect: init_record");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
/* initialize mask*/
|
||||
pmbbiDirect->mask = 0;
|
||||
for (i=0; i<pmbbiDirect->nobt; i++) {
|
||||
pmbbiDirect->mask <<= 1; /* shift left 1 bit*/
|
||||
pmbbiDirect->mask |= 1; /* set low order bit*/
|
||||
}
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(pmbbiDirect))) return(status);
|
||||
refresh_bits(pmbbiDirect);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long process(pmbbiDirect)
|
||||
struct mbbiDirectRecord *pmbbiDirect;
|
||||
{
|
||||
struct mbbidset *pdset = (struct mbbidset *)(pmbbiDirect->dset);
|
||||
long status;
|
||||
unsigned char pact=pmbbiDirect->pact;
|
||||
|
||||
if( (pdset==NULL) || (pdset->read_mbbi==NULL) ) {
|
||||
pmbbiDirect->pact=TRUE;
|
||||
recGblRecordError(S_dev_missingSup,(void *)pmbbiDirect,"read_mbbi");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
|
||||
status=readValue(pmbbiDirect); /* read the new value */
|
||||
/* check if device support set pact */
|
||||
if ( !pact && pmbbiDirect->pact ) return(0);
|
||||
pmbbiDirect->pact = TRUE;
|
||||
|
||||
recGblGetTimeStamp(pmbbiDirect);
|
||||
|
||||
if(status==0) { /* convert the value */
|
||||
unsigned long rval = pmbbiDirect->rval;
|
||||
|
||||
if(pmbbiDirect->shft>0) rval >>= pmbbiDirect->shft;
|
||||
pmbbiDirect->val = (unsigned short)rval;
|
||||
|
||||
}
|
||||
else if(status == 2) status = 0;
|
||||
|
||||
/* check event list */
|
||||
monitor(pmbbiDirect);
|
||||
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(pmbbiDirect);
|
||||
|
||||
pmbbiDirect->pact=FALSE;
|
||||
return(status);
|
||||
}
|
||||
|
||||
static long get_value(pmbbiDirect,pvdes)
|
||||
struct mbbiDirectRecord *pmbbiDirect;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_USHORT;
|
||||
pvdes->no_elements=1;
|
||||
(unsigned short *)(pvdes->pvalue) = &pmbbiDirect->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void monitor(pmbbiDirect)
|
||||
struct mbbiDirectRecord *pmbbiDirect;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
|
||||
/*
|
||||
* Monitors for Bit Fields are done in the refresh_bits()
|
||||
* routine.
|
||||
*/
|
||||
|
||||
monitor_mask = recGblResetAlarms(pmbbiDirect);
|
||||
|
||||
/* check for value change */
|
||||
if (pmbbiDirect->mlst != pmbbiDirect->val) {
|
||||
/* post events for value change and archive change */
|
||||
monitor_mask |= (DBE_VALUE | DBE_LOG);
|
||||
/* update last value monitored */
|
||||
pmbbiDirect->mlst = pmbbiDirect->val;
|
||||
}
|
||||
/* send out monitors connected to the value field */
|
||||
if (monitor_mask) {
|
||||
db_post_events(pmbbiDirect,&pmbbiDirect->val,monitor_mask);
|
||||
}
|
||||
if(pmbbiDirect->oraw != pmbbiDirect->rval) {
|
||||
db_post_events(pmbbiDirect,&pmbbiDirect->rval,monitor_mask|DBE_VALUE);
|
||||
pmbbiDirect->oraw = pmbbiDirect->rval;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static long readValue(pmbbiDirect)
|
||||
struct mbbiDirectRecord *pmbbiDirect;
|
||||
{
|
||||
long status;
|
||||
struct mbbidset *pdset = (struct mbbidset *) (pmbbiDirect->dset);
|
||||
|
||||
if (pmbbiDirect->pact == TRUE){
|
||||
status=(*pdset->read_mbbi)(pmbbiDirect);
|
||||
refresh_bits(pmbbiDirect);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetFastLink(&(pmbbiDirect->siml), (void *)pmbbiDirect, &(pmbbiDirect->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if (pmbbiDirect->simm == NO){
|
||||
status=(*pdset->read_mbbi)(pmbbiDirect);
|
||||
refresh_bits(pmbbiDirect);
|
||||
return(status);
|
||||
}
|
||||
if (pmbbiDirect->simm == YES){
|
||||
status=recGblGetFastLink(&(pmbbiDirect->siol), (void *)pmbbiDirect, &(pmbbiDirect->sval));
|
||||
|
||||
if (status==0) {
|
||||
pmbbiDirect->val=pmbbiDirect->sval;
|
||||
refresh_bits(pmbbiDirect);
|
||||
}
|
||||
status=2; /* don't convert */
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pmbbiDirect,SOFT_ALARM,INVALID_ALARM);
|
||||
return(status);
|
||||
}
|
||||
recGblSetSevr(pmbbiDirect,SIMM_ALARM,pmbbiDirect->sims);
|
||||
|
||||
return(status);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recMbbo.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recMbbo.c - Record Support Routines for multi bit binary Output records */
|
||||
/*
|
||||
@@ -58,6 +58,7 @@
|
||||
* .23 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .24 08-14-92 jba Added simulation processing
|
||||
* .25 08-19-92 jba Added code for invalid alarm output action
|
||||
* .26 03-29-94 mcn Converted to Fast Links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -160,27 +161,19 @@ static long init_record(pmbbo,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* mbbo.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pmbbo->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pmbbo->siml.type == CONSTANT) {
|
||||
pmbbo->simm = pmbbo->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pmbbo->siml), (void *) pmbbo, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pmbbo,
|
||||
"mbbo: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbo->siml), (void *) pmbbo, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* mbbo.siol may be a PV_LINK */
|
||||
if (pmbbo->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(pmbbo->siol), (void *) pmbbo, "VAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
status = recGblInitFastOutLink(&(pmbbo->siol), (void *) pmbbo, DBR_USHORT, "VAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if(!(pdset = (struct mbbodset *)(pmbbo->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)pmbbo,"mbbo: init_record");
|
||||
@@ -195,6 +188,13 @@ static long init_record(pmbbo,pass)
|
||||
pmbbo->val = pmbbo->dol.value.value;
|
||||
pmbbo->udf = FALSE;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbo->dol), (void *) pmbbo, DBR_USHORT, "VAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* initialize mask*/
|
||||
pmbbo->mask = 0;
|
||||
for (i=0; i<pmbbo->nobt; i++) {
|
||||
@@ -248,16 +248,11 @@ static long process(pmbbo)
|
||||
}
|
||||
|
||||
if (!pmbbo->pact) {
|
||||
if(pmbbo->dol.type==DB_LINK && pmbbo->omsl==CLOSED_LOOP){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
if (pmbbo->dol.type != CONSTANT && pmbbo->omsl == CLOSED_LOOP) {
|
||||
long status;
|
||||
unsigned short val;
|
||||
|
||||
pmbbo->pact = TRUE;
|
||||
status = dbGetLink(&pmbbo->dol.value.db_link,(struct dbCommon *)pmbbo,DBR_USHORT,
|
||||
&val,&options,&nRequest);
|
||||
pmbbo->pact = FALSE;
|
||||
status = recGblGetFastLink(&pmbbo->dol, (void *) pmbbo, &val);
|
||||
if(status==0) {
|
||||
pmbbo->val= val;
|
||||
pmbbo->udf= FALSE;
|
||||
@@ -478,16 +473,13 @@ static long writeValue(pmbbo)
|
||||
{
|
||||
long status;
|
||||
struct mbbodset *pdset = (struct mbbodset *) (pmbbo->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pmbbo->pact == TRUE){
|
||||
status=(*pdset->write_mbbo)(pmbbo);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pmbbo->siml),
|
||||
(void *)pmbbo,DBR_ENUM,&(pmbbo->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pmbbo->siml), (void *)pmbbo, &(pmbbo->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -496,8 +488,7 @@ static long writeValue(pmbbo)
|
||||
return(status);
|
||||
}
|
||||
if (pmbbo->simm == YES){
|
||||
status=recGblPutLinkValue(&(pmbbo->siol),
|
||||
(void *)pmbbo,DBR_USHORT,&(pmbbo->val),&nRequest);
|
||||
status=recGblPutFastLink(&(pmbbo->siol), (void *)pmbbo, &(pmbbo->val));
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pmbbo,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
349
src/rec/recMbboDirect.c
Normal file
349
src/rec/recMbboDirect.c
Normal file
@@ -0,0 +1,349 @@
|
||||
/* recMbboDirect.c */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recMbboDirect.c - Record Support for mbboDirect records */
|
||||
/*
|
||||
* Original Author: Bob Dalesio
|
||||
* Current Author: Matthew Needes
|
||||
* Date: 10-06-93
|
||||
*
|
||||
* 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:
|
||||
* -----------------
|
||||
* (modifications to mbbo apply, see mbbo record)
|
||||
* 1. mcn "Created" by borrowing mbbo record code, and modifying it.
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <lstLib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <devSup.h>
|
||||
#include <errMdef.h>
|
||||
#include <recSup.h>
|
||||
#include <special.h>
|
||||
#include <mbboDirectRecord.h>
|
||||
|
||||
/* Create RSET - Record Support Entry Table*/
|
||||
#define report NULL
|
||||
#define initialize NULL
|
||||
static long init_record();
|
||||
static long process();
|
||||
static long special();
|
||||
static long get_value();
|
||||
#define cvt_dbaddr NULL
|
||||
#define get_array_info NULL
|
||||
#define put_array_info NULL
|
||||
#define get_units NULL
|
||||
#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
|
||||
|
||||
struct rset mbboDirectRSET={
|
||||
RSETNUMBER,
|
||||
report,
|
||||
initialize,
|
||||
init_record,
|
||||
process,
|
||||
special,
|
||||
get_value,
|
||||
cvt_dbaddr,
|
||||
get_array_info,
|
||||
put_array_info,
|
||||
get_units,
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
struct mbbodset { /* multi bit binary output dset */
|
||||
long number;
|
||||
DEVSUPFUN dev_report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record; /*returns: (0,2)=>(success,success no convert)*/
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN write_mbbo; /*returns: (0,2)=>(success,success no convert)*/
|
||||
};
|
||||
|
||||
|
||||
static void convert();
|
||||
static void monitor();
|
||||
static long writeValue();
|
||||
|
||||
#define NUM_BITS 16
|
||||
|
||||
static long init_record(pmbboDirect,pass)
|
||||
struct mbboDirectRecord *pmbboDirect;
|
||||
int pass;
|
||||
{
|
||||
struct mbbodset *pdset;
|
||||
long status = 0;
|
||||
int i;
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
if (pmbboDirect->siml.type == CONSTANT) {
|
||||
pmbboDirect->simm = pmbboDirect->siml.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbboDirect->siml), (void *) pmbboDirect, DBR_ENUM, "SIMM");
|
||||
if (status) return(status);
|
||||
}
|
||||
|
||||
status = recGblInitFastOutLink(&(pmbboDirect->siol), (void *) pmbboDirect, DBR_USHORT, "VAL");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if (!(pdset = (struct mbbodset *)(pmbboDirect->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)pmbboDirect,"mbboDirect: init_record");
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* must have write_mbbo function defined */
|
||||
if ((pdset->number < 5) || (pdset->write_mbbo == NULL) ) {
|
||||
recGblRecordError(S_dev_missingSup,(void *)pmbboDirect,"mbboDirect: init_record");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
|
||||
if (pmbboDirect->dol.type == CONSTANT) {
|
||||
pmbboDirect->val = pmbboDirect->dol.value.value;
|
||||
pmbboDirect->udf = FALSE;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbboDirect->dol), (void *) pmbboDirect, DBR_USHORT, "VAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* initialize mask*/
|
||||
pmbboDirect->mask = 0;
|
||||
for (i=0; i<pmbboDirect->nobt; i++) {
|
||||
pmbboDirect->mask <<= 1; /* shift left 1 bit*/
|
||||
pmbboDirect->mask |= 1; /* set low order bit*/
|
||||
}
|
||||
if(pdset->init_record) {
|
||||
unsigned long rval;
|
||||
|
||||
status=(*pdset->init_record)(pmbboDirect);
|
||||
/* init_record might set status */
|
||||
if(status==0){
|
||||
rval = pmbboDirect->rval;
|
||||
if(pmbboDirect->shft>0) rval >>= pmbboDirect->shft;
|
||||
pmbboDirect->val = (unsigned short)rval;
|
||||
} else if (status == 2) status = 0;
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
static long process(pmbboDirect)
|
||||
struct mbboDirectRecord *pmbboDirect;
|
||||
{
|
||||
struct mbbodset *pdset = (struct mbbodset *)(pmbboDirect->dset);
|
||||
long status=0;
|
||||
unsigned char pact=pmbboDirect->pact;
|
||||
|
||||
if( (pdset==NULL) || (pdset->write_mbbo==NULL) ) {
|
||||
pmbboDirect->pact=TRUE;
|
||||
recGblRecordError(S_dev_missingSup,(void *)pmbboDirect,"write_mbbo");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
|
||||
if (!pmbboDirect->pact) {
|
||||
if(pmbboDirect->dol.type != CONSTANT && pmbboDirect->omsl==CLOSED_LOOP) {
|
||||
long status;
|
||||
unsigned short val;
|
||||
|
||||
status = recGblGetFastLink(&pmbboDirect->dol, (void *)pmbboDirect, &val);
|
||||
if(status==0) {
|
||||
pmbboDirect->val = val;
|
||||
pmbboDirect->udf = FALSE;
|
||||
}
|
||||
}
|
||||
/* convert val to rval */
|
||||
convert(pmbboDirect);
|
||||
}
|
||||
|
||||
status=writeValue(pmbboDirect);
|
||||
|
||||
/* check if device support set pact */
|
||||
if ( !pact && pmbboDirect->pact ) return(0);
|
||||
pmbboDirect->pact = TRUE;
|
||||
|
||||
recGblGetTimeStamp(pmbboDirect);
|
||||
/* check event list */
|
||||
monitor(pmbboDirect);
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(pmbboDirect);
|
||||
pmbboDirect->pact=FALSE;
|
||||
return(status);
|
||||
}
|
||||
|
||||
static long special(paddr,after)
|
||||
struct dbAddr *paddr;
|
||||
int after;
|
||||
{
|
||||
struct mbboDirectRecord *pmbboDirect = (struct mbboDirectRecord *)(paddr->precord);
|
||||
int special_type = paddr->special, offset = 1, i;
|
||||
char *bit;
|
||||
|
||||
if(!after) return(0);
|
||||
switch(special_type) {
|
||||
case(SPC_MOD):
|
||||
/*
|
||||
* Set a bit in VAL corresponding to the bit changed
|
||||
* offset equals the offset in bit array. Only do
|
||||
* this if in supervisory mode.
|
||||
*/
|
||||
if (pmbboDirect->omsl == CLOSED_LOOP)
|
||||
return(0);
|
||||
|
||||
offset = 1 << (((int)paddr->pfield) - ((int) &(pmbboDirect->b0)));
|
||||
|
||||
if (*((char *)paddr->pfield)) {
|
||||
/* set field */
|
||||
pmbboDirect->val |= offset;
|
||||
}
|
||||
else {
|
||||
/* zero field */
|
||||
pmbboDirect->val &= ~offset;
|
||||
}
|
||||
|
||||
pmbboDirect->udf = FALSE;
|
||||
|
||||
convert(pmbboDirect);
|
||||
return(0);
|
||||
case(SPC_RESET):
|
||||
/*
|
||||
* If OMSL changes from closed_loop to supervisory,
|
||||
* reload value field with B0 - B15
|
||||
*/
|
||||
if (pmbboDirect->omsl == SUPERVISORY) {
|
||||
bit = &(pmbboDirect->b0);
|
||||
for (i=0; i<NUM_BITS; i++, offset = offset << 1, bit++) {
|
||||
if (*bit)
|
||||
pmbboDirect->val |= offset;
|
||||
else
|
||||
pmbboDirect->val &= ~offset;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
default:
|
||||
recGblDbaddrError(S_db_badChoice,paddr,"mbboDirect: special");
|
||||
return(S_db_badChoice);
|
||||
}
|
||||
}
|
||||
|
||||
static long get_value(pmbboDirect,pvdes)
|
||||
struct mbboDirectRecord *pmbboDirect;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_USHORT;
|
||||
pvdes->no_elements=1;
|
||||
(unsigned short *)(pvdes->pvalue) = &pmbboDirect->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void monitor(pmbboDirect)
|
||||
struct mbboDirectRecord *pmbboDirect;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
|
||||
monitor_mask = recGblResetAlarms(pmbboDirect);
|
||||
|
||||
/* check for value change */
|
||||
if (pmbboDirect->mlst != pmbboDirect->val) {
|
||||
/* post events for value change and archive change */
|
||||
monitor_mask |= (DBE_VALUE | DBE_LOG);
|
||||
/* update last value monitored */
|
||||
pmbboDirect->mlst = pmbboDirect->val;
|
||||
}
|
||||
/* send out monitors connected to the value field */
|
||||
if (monitor_mask){
|
||||
db_post_events(pmbboDirect,&pmbboDirect->val,monitor_mask);
|
||||
}
|
||||
if(pmbboDirect->oraw!=pmbboDirect->rval) {
|
||||
db_post_events(pmbboDirect,&pmbboDirect->rval,monitor_mask|DBE_VALUE);
|
||||
pmbboDirect->oraw = pmbboDirect->rval;
|
||||
}
|
||||
if(pmbboDirect->orbv!=pmbboDirect->rbv) {
|
||||
db_post_events(pmbboDirect,&pmbboDirect->rbv,monitor_mask|DBE_VALUE);
|
||||
pmbboDirect->orbv = pmbboDirect->rbv;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void convert(pmbboDirect)
|
||||
struct mbboDirectRecord *pmbboDirect;
|
||||
{
|
||||
/* convert val to rval */
|
||||
pmbboDirect->rval = (unsigned long)(pmbboDirect->val);
|
||||
if(pmbboDirect->shft>0)
|
||||
pmbboDirect->rval <<= pmbboDirect->shft;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static long writeValue(pmbboDirect)
|
||||
struct mbboDirectRecord *pmbboDirect;
|
||||
{
|
||||
long status;
|
||||
struct mbbodset *pdset = (struct mbbodset *) (pmbboDirect->dset);
|
||||
|
||||
if (pmbboDirect->pact == TRUE){
|
||||
status=(*pdset->write_mbbo)(pmbboDirect);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetFastLink(&(pmbboDirect->siml), (void *)pmbboDirect, &(pmbboDirect->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if (pmbboDirect->simm == NO){
|
||||
status=(*pdset->write_mbbo)(pmbboDirect);
|
||||
return(status);
|
||||
}
|
||||
if (pmbboDirect->simm == YES){
|
||||
status=recGblPutFastLink(&(pmbboDirect->siol), (void *)pmbboDirect, &(pmbboDirect->val));
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pmbboDirect,SOFT_ALARM,INVALID_ALARM);
|
||||
return(status);
|
||||
}
|
||||
recGblSetSevr(pmbboDirect,SIMM_ALARM,pmbboDirect->sims);
|
||||
|
||||
return(status);
|
||||
}
|
||||
244
src/rec/recPal.c
Normal file
244
src/rec/recPal.c
Normal file
@@ -0,0 +1,244 @@
|
||||
/* recPal.c */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recPal.c - Record Support Routines for Pal Emulation records */
|
||||
/*
|
||||
* Original Author: Matthew Stettler
|
||||
* Date: 12-02-93
|
||||
*
|
||||
* 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 04-19-94 mcn R3.12ified
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <lstLib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <errMdef.h>
|
||||
#include <recSup.h>
|
||||
#include <special.h>
|
||||
#include <palRecord.h>
|
||||
|
||||
/* Create RSET - Record Support Entry Table*/
|
||||
#define report NULL
|
||||
#define initialize NULL
|
||||
static long init_record();
|
||||
static long process();
|
||||
#define special NULL
|
||||
static long get_value();
|
||||
#define cvt_dbaddr NULL
|
||||
#define get_array_info NULL
|
||||
#define put_array_info NULL
|
||||
static long get_units();
|
||||
static long get_precision();
|
||||
#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
|
||||
|
||||
struct rset palRSET={
|
||||
RSETNUMBER,
|
||||
report,
|
||||
initialize,
|
||||
init_record,
|
||||
process,
|
||||
special,
|
||||
get_value,
|
||||
cvt_dbaddr,
|
||||
get_array_info,
|
||||
put_array_info,
|
||||
get_units,
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
static void monitor();
|
||||
static int fetch_values();
|
||||
struct pal * palinit();
|
||||
|
||||
|
||||
#define ARG_MAX 12
|
||||
/* Fldnames should have as many as ARG_MAX */
|
||||
static char Fldnames[ARG_MAX][FLDNAME_SZ] =
|
||||
{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"};
|
||||
#define OUT_MAX 12
|
||||
|
||||
|
||||
static long init_record(ppal,pass)
|
||||
struct palRecord *ppal;
|
||||
int pass;
|
||||
{
|
||||
long status;
|
||||
struct link *plink;
|
||||
int i;
|
||||
double *pvalue;
|
||||
short error_number;
|
||||
char rpbuf[184];
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
plink = &ppal->inpa;
|
||||
pvalue = &ppal->a;
|
||||
for(i=0; i<ARG_MAX; i++, plink++, pvalue++) {
|
||||
if (plink->type==CONSTANT) {
|
||||
*pvalue = plink->value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(plink, (void *) ppal, DBR_DOUBLE, Fldnames[i]);
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
}
|
||||
if ((ppal->pptr = palinit(ppal->jedf,ppal->name,&ppal->a0)) == 0)
|
||||
return -1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long process(ppal)
|
||||
struct palRecord *ppal;
|
||||
{
|
||||
unsigned char *temp;
|
||||
int i;
|
||||
double *tptr;
|
||||
|
||||
ppal->pact = TRUE;
|
||||
|
||||
if (fetch_values(ppal)==0)
|
||||
{
|
||||
if(pal(ppal->pptr,&ppal->a,12,&ppal->val))
|
||||
printf("palrec - error, pptr = %x\n",ppal->pptr);
|
||||
ppal->udf = FALSE;
|
||||
}
|
||||
for (i = 0, temp = &ppal->q0; i < OUT_MAX; i++, temp++)
|
||||
{
|
||||
*temp = (ppal->val>>i) & 1;
|
||||
/*printf("%x ",*temp);*/
|
||||
}
|
||||
/*printf("\n");*/
|
||||
recGblGetTimeStamp(ppal);
|
||||
/* check event list */
|
||||
monitor(ppal);
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(ppal);
|
||||
ppal->pact = FALSE;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_value(ppal,pvdes)
|
||||
struct palRecord *ppal;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_ULONG;
|
||||
pvdes->no_elements=1;
|
||||
(double *)(pvdes->pvalue) = &ppal->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_units(paddr,units)
|
||||
struct dbAddr *paddr;
|
||||
char *units;
|
||||
{
|
||||
struct palRecord *ppal=(struct palRecord *)paddr->precord;
|
||||
|
||||
strncpy(units,ppal->egu,sizeof(ppal->egu));
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_precision(paddr,precision)
|
||||
struct dbAddr *paddr;
|
||||
long *precision;
|
||||
{
|
||||
struct palRecord *ppal=(struct palRecord *)paddr->precord;
|
||||
|
||||
*precision = ppal->prec;
|
||||
if(paddr->pfield == (void *)&ppal->val) return(0);
|
||||
recGblGetPrec(paddr,precision);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void monitor(ppal)
|
||||
struct palRecord *ppal;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
double delta;
|
||||
short stat,sevr,nsta,nsev;
|
||||
double *pnew;
|
||||
double *pprev;
|
||||
int i;
|
||||
unsigned char *temp;
|
||||
|
||||
monitor_mask = recGblResetAlarms(ppal);
|
||||
|
||||
/* check for value change */
|
||||
if (ppal->val != ppal->mlst)
|
||||
{
|
||||
monitor_mask |= DBE_VALUE; /* post events for value change */
|
||||
}
|
||||
|
||||
/* send out monitors connected to the value field */
|
||||
if (monitor_mask)
|
||||
{
|
||||
db_post_events(ppal,&ppal->val,monitor_mask);
|
||||
for (i = 0, temp = &ppal->q0; i < OUT_MAX; i++, temp++)
|
||||
if (((ppal->mlst>>i) & 1) ^ *temp) /* check each bit */
|
||||
db_post_events(ppal,temp,monitor_mask);
|
||||
ppal->mlst = ppal->val; /* update last value monitored */
|
||||
}
|
||||
/* check all input fields for changes*/
|
||||
for(i=0, pnew=&ppal->a, pprev=&ppal->la; i<ARG_MAX; i++, pnew++, pprev++)
|
||||
if(*pnew != *pprev)
|
||||
{
|
||||
db_post_events(ppal,pnew,monitor_mask|DBE_VALUE);
|
||||
*pprev = *pnew;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int fetch_values(ppal)
|
||||
struct palRecord *ppal;
|
||||
{
|
||||
struct link *plink; /* structure of the link field */
|
||||
double *pvalue,sval;
|
||||
long status;
|
||||
int i,j;
|
||||
|
||||
for(i=0, plink=&ppal->inpa, pvalue=&ppal->a; i<ARG_MAX; i++, plink++, pvalue++) {
|
||||
|
||||
status = recGblGetFastLink(plink, (void *)ppal, pvalue);
|
||||
if (!RTN_SUCCESS(status)) return(status);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recPermissive.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recPermissive.c - Record Support Routines for Permissive records */
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recPid.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recPid.c - Record Support Routines for Pid records */
|
||||
/*
|
||||
@@ -41,6 +41,7 @@
|
||||
* .09 07-21-92 jba changed alarm limits for non val related fields
|
||||
* .10 08-06-92 jba New algorithm for calculating analog alarms
|
||||
* .11 09-10-92 jba modified fetch of VAL from STPL to call recGblGetLinkValue
|
||||
* .12 03-29-94 mcn Converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -118,12 +119,18 @@ static long init_record(ppid,pass)
|
||||
ppid->val = ppid->stpl.value.value;
|
||||
ppid->udf = FALSE;
|
||||
}
|
||||
if (ppid->stpl.type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(&(ppid->stpl), (void *) ppid, "VAL");
|
||||
if(status) return(status);
|
||||
else {
|
||||
status = recGblInitFastInLink(&(ppid->stpl), (void *) ppid, DBR_FLOAT, "VAL");
|
||||
if (status)
|
||||
return(status);
|
||||
} /* endif */
|
||||
|
||||
if (ppid->cvl.type != CONSTANT) {
|
||||
status = recGblInitFastInLink(&(ppid->cvl), (void *) ppid, DBR_FLOAT, "VAL");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -357,7 +364,7 @@ static void monitor(ppid)
|
||||
static long do_pid(ppid)
|
||||
struct pidRecord *ppid;
|
||||
{
|
||||
long status,options,nRequest;
|
||||
long status;
|
||||
unsigned long ctp; /*clock ticks previous */
|
||||
unsigned long ct; /*clock ticks */
|
||||
float cval; /*actual value */
|
||||
@@ -378,19 +385,15 @@ struct pidRecord *ppid;
|
||||
if (ppid->cvl.type != DB_LINK) { /* nothing to control*/
|
||||
if (recGblSetSevr(ppid,SOFT_ALARM,INVALID_ALARM)) return(0);
|
||||
}
|
||||
options=0;
|
||||
nRequest=1;
|
||||
if(dbGetLink(&(ppid->cvl.value.db_link),(struct dbCommon *)ppid,DBR_FLOAT,
|
||||
&cval,&options,&nRequest)!=NULL) {
|
||||
if (recGblGetFastLink(&(ppid->cvl), (void *) ppid, &cval)) {
|
||||
recGblSetSevr(ppid,LINK_ALARM,INVALID_ALARM);
|
||||
return(0);
|
||||
}
|
||||
/* fetch the setpoint */
|
||||
if(ppid->smsl == CLOSED_LOOP){
|
||||
options=0;
|
||||
nRequest=1;
|
||||
status = recGblGetLinkValue(&(ppid->stpl),(void *)ppid,DBR_FLOAT,
|
||||
&(ppid->val),&options,&nRequest);
|
||||
status = recGblGetFastLink(&(ppid->stpl), (void *)ppid,
|
||||
&(ppid->val));
|
||||
|
||||
if (RTN_SUCCESS(status)) ppid->udf=FALSE;
|
||||
}
|
||||
val = ppid->val;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* recPulseCounter.c */
|
||||
/* share/src/rec $Id$ */
|
||||
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recPulseCounter.c - Record Support Routines for PulseCounter records */
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recPulseDelay.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recPulser.c - Record Support Routines for PulseDelay records */
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recPulseTrain.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recPulser.c - Record Support Routines for PulseTrain records */
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recSel.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recSel.c - Record Support Routines for Select records */
|
||||
/*
|
||||
@@ -45,6 +45,7 @@
|
||||
* .12 08-06-92 jba New algorithm for calculating analog alarms
|
||||
* .13 09-10-92 jba Changed algorithms to use all a-l which are defined
|
||||
* .14 10-10-92 jba replaced code with recGblGetLinkValue call
|
||||
* .15 03-29-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -130,24 +131,27 @@ static long init_record(psel,pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* get seln initial value if nvl is a constant*/
|
||||
if (psel->nvl.type == CONSTANT ) psel->seln = psel->nvl.value.value;
|
||||
if (psel->nvl.type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(&(psel->nvl), (void *) psel, "SELN");
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
if (psel->nvl.type == CONSTANT ) {
|
||||
psel->seln = psel->nvl.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(psel->nvl), (void *) psel, DBR_USHORT, "SELN");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
plink = &psel->inpa;
|
||||
pvalue = &psel->a;
|
||||
for(i=0; i<SEL_MAX; i++, plink++, pvalue++) {
|
||||
*pvalue = 1e+30;
|
||||
if(plink->type==CONSTANT && plink->value.value != 0.)
|
||||
if (plink->type==CONSTANT && plink->value.value != 0.) {
|
||||
*pvalue = plink->value.value;
|
||||
if (plink->type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(plink, (void *) psel, Fldnames[i]);
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(plink, (void *) psel, DBR_DOUBLE, Fldnames[i]);
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -452,8 +456,6 @@ struct selRecord *psel; /* pointer to selection record */
|
||||
static int fetch_values(psel)
|
||||
struct selRecord *psel;
|
||||
{
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
struct link *plink;
|
||||
double *pvalue;
|
||||
int i;
|
||||
@@ -464,23 +466,18 @@ struct selRecord *psel;
|
||||
/* If select mechanism is SELECTED only get selected input*/
|
||||
if(psel->selm == SELECTED) {
|
||||
/* fetch the select index */
|
||||
status=recGblGetLinkValue(&(psel->nvl),(void *)psel,DBR_USHORT,
|
||||
&(psel->seln),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(psel->nvl), (void *)psel, &(psel->seln));
|
||||
if (!RTN_SUCCESS(status)) return(status);
|
||||
|
||||
plink += psel->seln;
|
||||
pvalue += psel->seln;
|
||||
|
||||
status=recGblGetLinkValue(plink,(void *)psel,DBR_DOUBLE,
|
||||
pvalue,&options,&nRequest);
|
||||
status=recGblGetFastLink(plink, (void *)psel, pvalue);
|
||||
return(status);
|
||||
}
|
||||
/* fetch all inputs*/
|
||||
for(i=0; i<SEL_MAX; i++, plink++, pvalue++) {
|
||||
options=0;
|
||||
nRequest=1;
|
||||
status=recGblGetLinkValue(plink,(void *)psel,DBR_DOUBLE,
|
||||
pvalue,&options,&nRequest);
|
||||
status=recGblGetFastLink(plink,(void *)psel, pvalue);
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recState.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recState.c - Record Support Routines for State records */
|
||||
/*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recSteppermotor.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recSteppermotor.c - Record Support Routines for Steppermotor records */
|
||||
/*
|
||||
@@ -93,6 +93,7 @@
|
||||
* .35 08-06-93 mrk vel mode: Call recGblFwdLink only when motor
|
||||
* Stops
|
||||
* .36 09-15-93 mrk call monitor when starting
|
||||
* .37 03-29-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -203,11 +204,15 @@ static long init_record(psm,pass)
|
||||
psm->udf = FALSE;
|
||||
psm->val = psm->dol.value.value;
|
||||
}
|
||||
if (psm->dol.type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(&(psm->dol), (void *) psm, "VAL");
|
||||
if(status) return(status);
|
||||
else {
|
||||
status = recGblInitFastInLink(&(psm->dol), (void *) psm, DBR_FLOAT, "VAL");
|
||||
if (status)
|
||||
return(status);
|
||||
} /* endif */
|
||||
|
||||
/* initialize readback link */
|
||||
status = recGblInitFastInLink(&(psm->rdbl), (void *) psm, DBR_FLOAT, "VAL");
|
||||
|
||||
init_sm(psm);
|
||||
return(0);
|
||||
}
|
||||
@@ -707,7 +712,7 @@ struct steppermotorRecord *psm;
|
||||
{
|
||||
struct smdset *pdset = (struct smdset *)(psm->dset);
|
||||
int acceleration,velocity;
|
||||
long status,options=0,nRequest=1;
|
||||
long status;
|
||||
|
||||
|
||||
/* emergency stop */
|
||||
@@ -755,9 +760,8 @@ struct steppermotorRecord *psm;
|
||||
}
|
||||
|
||||
/* fetch the desired value if there is a database link */
|
||||
if (psm->omsl == CLOSED_LOOP){
|
||||
status=recGblGetLinkValue(&(psm->dol),(void *)psm,DBR_FLOAT,
|
||||
&(psm->val),&options,&nRequest);
|
||||
if (psm->omsl == CLOSED_LOOP) {
|
||||
status=recGblGetFastLink(&(psm->dol), (void *)psm, &(psm->val));
|
||||
if (!RTN_SUCCESS(status)) return;
|
||||
psm->udf = FALSE;
|
||||
}
|
||||
@@ -810,12 +814,11 @@ struct steppermotorRecord *psm;
|
||||
struct smdset *pdset = (struct smdset *)(psm->dset);
|
||||
float chng_vel;
|
||||
int acceleration,velocity;
|
||||
long status,options=0,nRequest=1;
|
||||
long status;
|
||||
|
||||
/* fetch the desired value if there is a database link */
|
||||
if (psm->omsl == CLOSED_LOOP){
|
||||
status=recGblGetLinkValue(&(psm->dol),(void *)psm,DBR_FLOAT,
|
||||
&(psm->val),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(psm->dol), (void *)psm, &(psm->val));
|
||||
if (!RTN_SUCCESS(status)) return;
|
||||
psm->udf = FALSE;
|
||||
}
|
||||
@@ -888,9 +891,6 @@ struct steppermotorRecord *psm;
|
||||
|
||||
/* get readback position */
|
||||
if (psm->rdbl.type == DB_LINK){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
|
||||
/* when readback comes from another field of this record */
|
||||
/* the fetch will fail if the record is uninitialized */
|
||||
/* also - prdl (process readback location) should be set */
|
||||
@@ -898,15 +898,15 @@ struct steppermotorRecord *psm;
|
||||
|
||||
reset = psm->init;
|
||||
if (reset == 0) psm->init = 1;
|
||||
if(dbGetLink(&(psm->rdbl.value.db_link),(struct dbCommon *)psm,DBR_FLOAT,
|
||||
&new_pos,&options,&nRequest)){
|
||||
if(recGblGetFastLink(&(psm->rdbl),(void *)psm, &new_pos)) {
|
||||
recGblSetSevr(psm,READ_ALARM,INVALID_ALARM);
|
||||
psm->init = reset;
|
||||
return;
|
||||
}
|
||||
psm->init = reset;
|
||||
/* default is the motor position returned from the driver */
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
new_pos = psm->mpos;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recStringin.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recStringin.c - Record Support Routines for Stringin records */
|
||||
/*
|
||||
@@ -36,6 +36,7 @@
|
||||
* .05 04-18-92 jba removed process from dev init_record parms
|
||||
* .06 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .07 08-13-92 jba Added simulation processing
|
||||
* .08 03-29-94 mcn Added fast links
|
||||
*/
|
||||
|
||||
|
||||
@@ -114,40 +115,26 @@ static long init_record(pstringin,pass)
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* stringin.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pstringin->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pstringin->siml.type == CONSTANT) {
|
||||
pstringin->simm = pstringin->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pstringin->siml), (void *) pstringin, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pstringin,
|
||||
"stringin: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pstringin->siml), (void *) pstringin, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* stringin.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pstringin->siol.type) {
|
||||
case (CONSTANT) :
|
||||
if (pstringin->siol.type == CONSTANT) {
|
||||
if (pstringin->siol.value.value!=0.0 ){
|
||||
sprintf(pstringin->sval,"%-14.7g",pstringin->siol.value.value);
|
||||
}
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pstringin->siol), (void *) pstringin, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pstringin,
|
||||
"stringin: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pstringin->siol), (void *) pstringin, DBR_STRING, "SVAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct stringindset *)(pstringin->dset))) {
|
||||
@@ -224,17 +211,13 @@ static long readValue(pstringin)
|
||||
{
|
||||
long status;
|
||||
struct stringindset *pdset = (struct stringindset *) (pstringin->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
|
||||
if (pstringin->pact == TRUE){
|
||||
status=(*pdset->read_stringin)(pstringin);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pstringin->siml),
|
||||
(void *)pstringin,DBR_ENUM,&(pstringin->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pstringin->siml), (void *)pstringin, &(pstringin->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -243,9 +226,8 @@ static long readValue(pstringin)
|
||||
return(status);
|
||||
}
|
||||
if (pstringin->simm == YES){
|
||||
status=recGblGetLinkValue(&(pstringin->siol),
|
||||
(void *)pstringin,DBR_STRING,pstringin->sval,&options,&nRequest);
|
||||
if (status==0){
|
||||
status=recGblGetFastLink(&(pstringin->siol), (void *)pstringin, pstringin->sval);
|
||||
if (status==0) {
|
||||
strcpy(pstringin->val,pstringin->sval);
|
||||
pstringin->udf=FALSE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recStringout.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recStringout.c - Record Support Routines for Stringout records */
|
||||
/*
|
||||
@@ -40,7 +40,8 @@
|
||||
* .09 08-14-92 jba Added simulation processing
|
||||
* .10 08-19-92 jba Added code for invalid alarm output action
|
||||
* .11 10-10-92 jba replaced code for get of VAL from DOL with recGblGetLinkValue call
|
||||
* .12 10-18-92 jba pact noew set in recGblGetLinkValue
|
||||
* .12 10-18-92 jba pact now set in recGblGetLinkValue
|
||||
* .13 03-30-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
|
||||
@@ -119,28 +120,16 @@ static long init_record(pstringout,pass)
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* stringout.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pstringout->siml.type) {
|
||||
case (CONSTANT) :
|
||||
if (pstringout->siml.type == CONSTANT) {
|
||||
pstringout->simm = pstringout->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pstringout->siml), (void *) pstringout, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pstringout,
|
||||
"stringout: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pstringout->siml), (void *) pstringout, DBR_ENUM, "SIMM");
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* stringout.siol may be a PV_LINK */
|
||||
if (pstringout->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(pstringout->siol), (void *) pstringout, "VAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
status = recGblInitFastOutLink(&(pstringout->siol), (void *) pstringout, DBR_STRING, "VAL");
|
||||
|
||||
if(!(pdset = (struct stringoutdset *)(pstringout->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)pstringout,"stringout: init_record");
|
||||
@@ -263,16 +252,13 @@ static long writeValue(pstringout)
|
||||
{
|
||||
long status;
|
||||
struct stringoutdset *pdset = (struct stringoutdset *) (pstringout->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pstringout->pact == TRUE){
|
||||
status=(*pdset->write_stringout)(pstringout);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(pstringout->siml),
|
||||
(void *)pstringout,DBR_ENUM,&(pstringout->simm),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(pstringout->siml), (void *)pstringout, &(pstringout->simm));
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -281,8 +267,7 @@ static long writeValue(pstringout)
|
||||
return(status);
|
||||
}
|
||||
if (pstringout->simm == YES){
|
||||
status=recGblPutLinkValue(&(pstringout->siol),
|
||||
(void *)pstringout,DBR_STRING,pstringout->val,&nRequest);
|
||||
status=recGblPutFastLink(&(pstringout->siol), (void *)pstringout, pstringout->val);
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pstringout,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recSub.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recSub.c - Record Support Routines for Subroutine records */
|
||||
/*
|
||||
@@ -44,6 +44,7 @@
|
||||
* .12 08-06-92 jba New algorithm for calculating analog alarms
|
||||
* .13 08-06-92 jba monitor now posts events for changes in a-l
|
||||
* .14 10-10-92 jba replaced code with recGblGetLinkValue call
|
||||
* .15 03-30-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -131,11 +132,14 @@ static long init_record(psub,pass)
|
||||
plink = &psub->inpa;
|
||||
pvalue = &psub->a;
|
||||
for(i=0; i<ARG_MAX; i++, plink++, pvalue++) {
|
||||
if(plink->type==CONSTANT) *pvalue = plink->value.value;
|
||||
if (plink->type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(plink, (void *) psub, Fldnames[i]);
|
||||
if(status) return(status);
|
||||
if (plink->type==CONSTANT) {
|
||||
*pvalue = plink->value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(plink, (void *) psub, DBR_DOUBLE, Fldnames[i]);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
} /* endif */
|
||||
}
|
||||
|
||||
@@ -393,13 +397,11 @@ struct subRecord *psub;
|
||||
{
|
||||
struct link *plink; /* structure of the link field */
|
||||
double *pvalue;
|
||||
long options=0,nRequest=1;
|
||||
int i;
|
||||
long status;
|
||||
|
||||
for(i=0, plink=&psub->inpa, pvalue=&psub->a; i<ARG_MAX; i++, plink++, pvalue++) {
|
||||
status=recGblGetLinkValue(plink,(void *)psub,DBR_DOUBLE,
|
||||
pvalue,&options,&nRequest);
|
||||
status=recGblGetFastLink(plink, (void *)psub, pvalue);
|
||||
if (!RTN_SUCCESS(status)) return(-1);
|
||||
}
|
||||
return(0);
|
||||
|
||||
751
src/rec/recSwitch.c
Normal file
751
src/rec/recSwitch.c
Normal file
@@ -0,0 +1,751 @@
|
||||
/* recSwitch.c */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recSwitch.c - Record Support Routines for Switch records */
|
||||
/*
|
||||
* Author: Matthew Needes
|
||||
* Date: 9-21-93
|
||||
*
|
||||
* 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:
|
||||
* -----------------
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <types.h>
|
||||
#include <stdioLib.h>
|
||||
#include <lstLib.h>
|
||||
#include <string.h>
|
||||
#include <wdLib.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <devSup.h>
|
||||
#include <errMdef.h>
|
||||
#include <recSup.h>
|
||||
#include <special.h>
|
||||
#include <callback.h>
|
||||
#include <switchRecord.h>
|
||||
|
||||
/* RSET - Record Support Entry Table */
|
||||
#define report NULL
|
||||
#define initialize NULL
|
||||
static long init_record();
|
||||
static long process();
|
||||
static long special();
|
||||
static long get_value();
|
||||
#define cvt_dbaddr NULL
|
||||
#define get_array_info NULL
|
||||
#define put_array_info NULL
|
||||
#define get_units NULL
|
||||
static long get_precision();
|
||||
static long get_enum_str();
|
||||
static long get_enum_strs();
|
||||
#define put_enum_str NULL
|
||||
#define get_graphic_double NULL
|
||||
#define get_control_double NULL
|
||||
#define get_alarm_double NULL
|
||||
|
||||
struct rset switchRSET = {
|
||||
RSETNUMBER,
|
||||
report,
|
||||
initialize,
|
||||
init_record,
|
||||
process,
|
||||
special,
|
||||
get_value,
|
||||
cvt_dbaddr,
|
||||
get_array_info,
|
||||
put_array_info,
|
||||
get_units,
|
||||
get_precision,
|
||||
get_enum_str,
|
||||
get_enum_strs,
|
||||
put_enum_str,
|
||||
get_graphic_double,
|
||||
get_control_double,
|
||||
get_alarm_double };
|
||||
|
||||
static long init_state();
|
||||
static long output_and_watch();
|
||||
static long check_readback();
|
||||
static void monitor();
|
||||
static void callback();
|
||||
static void watchdog();
|
||||
|
||||
/* defs for initialization choices */
|
||||
#define INIT_RESET 0
|
||||
#define INIT_SET 1
|
||||
#define INIT_READBACK 2
|
||||
|
||||
/* defs for readback set threshold */
|
||||
#define ABOVE 0
|
||||
#define BELOW 1
|
||||
|
||||
/* defs for transition fail action choices */
|
||||
#define FAIL_FOLLOW_RDBK 0
|
||||
#define FAIL_KEEP_VALUE 1
|
||||
|
||||
/* state definitions for switch */
|
||||
#define UNINITIALIZED 0
|
||||
#define SET 1
|
||||
#define RESET 2
|
||||
#define RESET_TO_SET 3
|
||||
#define SET_TO_RESET 4
|
||||
|
||||
/* states above this number signify transition */
|
||||
#define TRANS_STATE 2
|
||||
|
||||
/* number of strings */
|
||||
#define STRING_COUNT 5
|
||||
|
||||
/*
|
||||
* Bitmask to check to see if the switch
|
||||
* is set or in the process of setting.
|
||||
*/
|
||||
#define TO_SET 0x01
|
||||
|
||||
/* private structure in record */
|
||||
struct PVT {
|
||||
CALLBACK callback;
|
||||
WDOG_ID watchdog;
|
||||
};
|
||||
|
||||
/* post an event on a field */
|
||||
#define MON_FIELD(CUR,PREV) \
|
||||
if ((CUR) != (PREV)) { \
|
||||
db_post_events(pswitch, &(CUR), DBE_VALUE); \
|
||||
(PREV) = (CUR); }
|
||||
|
||||
/* initialize record */
|
||||
static long init_record(
|
||||
struct switchRecord *pswitch,
|
||||
int pass
|
||||
)
|
||||
{
|
||||
long status;
|
||||
|
||||
/* ignore second pass */
|
||||
if (!pass)
|
||||
return(0);
|
||||
|
||||
/* initialize readback input link */
|
||||
status = recGblInitFastInLink(&pswitch->rbkl, (void *) pswitch, DBR_DOUBLE, "RBKV");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* initialize master reset link */
|
||||
status = recGblInitFastInLink(&pswitch->mrsl, (void *) pswitch, DBR_UCHAR, "MRSV");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* initialize master set link */
|
||||
status = recGblInitFastInLink(&pswitch->mstl, (void *) pswitch, DBR_UCHAR, "MSTV");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* initialize reset link */
|
||||
status = recGblInitFastInLink(&pswitch->rstl, (void *) pswitch, DBR_UCHAR, "RSTV");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* initialize set link */
|
||||
status = recGblInitFastInLink(&pswitch->setl, (void *) pswitch, DBR_UCHAR, "SETV");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* initialize toggle link */
|
||||
status = recGblInitFastInLink(&pswitch->togl, (void *) pswitch, DBR_UCHAR, "TOGV");
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* clear alarm severity */
|
||||
pswitch->sevr = NO_ALARM;
|
||||
|
||||
/*
|
||||
* Allocate private structure
|
||||
*/
|
||||
pswitch->pvt = (void *) malloc(sizeof(struct PVT));
|
||||
|
||||
if (!pswitch->pvt)
|
||||
return(S_rec_outMem);
|
||||
|
||||
/*
|
||||
* Create watchdog
|
||||
*/
|
||||
((struct PVT *)pswitch->pvt)->watchdog = (void *) wdCreate();
|
||||
|
||||
if (!((struct PVT *)pswitch->pvt)->watchdog)
|
||||
return(S_rec_outMem);
|
||||
|
||||
/*
|
||||
* Initialize EPICS callback
|
||||
*/
|
||||
callbackSetCallback(callback, &((struct PVT *)pswitch->pvt)->callback);
|
||||
callbackSetUser(pswitch, &((struct PVT *)pswitch->pvt)->callback);
|
||||
callbackSetPriority(pswitch->prio, &((struct PVT *)pswitch->pvt)->callback);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* initialize record's state */
|
||||
static long init_state(struct switchRecord *pswitch)
|
||||
{
|
||||
long status = 0;
|
||||
|
||||
/* set initial state */
|
||||
switch (pswitch->ini) {
|
||||
case INIT_RESET:
|
||||
pswitch->val = SET_TO_RESET;
|
||||
pswitch->pint = RESET;
|
||||
pswitch->outv = pswitch->offv;
|
||||
status = output_and_watch(pswitch);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
break;
|
||||
case INIT_SET:
|
||||
pswitch->val = RESET_TO_SET;
|
||||
pswitch->pint = SET;
|
||||
pswitch->outv = pswitch->onv;
|
||||
status = output_and_watch(pswitch);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
break;
|
||||
case INIT_READBACK:
|
||||
/*
|
||||
* If uninitialized, get state from readback
|
||||
*/
|
||||
status = recGblGetFastLink(&pswitch->rbkl, (void *) pswitch,
|
||||
&pswitch->rbkv);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if (pswitch->dthr == BELOW)
|
||||
pswitch->pint = pswitch->val = (pswitch->rbkv <= pswitch->rthr) ? SET : RESET;
|
||||
else
|
||||
pswitch->pint = pswitch->val = (pswitch->rbkv >= pswitch->rthr) ? SET : RESET;
|
||||
|
||||
pswitch->outv = (pswitch->val == SET) ? pswitch->onv : pswitch->offv;
|
||||
|
||||
/*
|
||||
* Drive output
|
||||
*/
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return(0);
|
||||
break;
|
||||
}
|
||||
|
||||
pswitch->udf = FALSE;
|
||||
|
||||
pswitch->intn = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* process record */
|
||||
static long process(struct switchRecord *pswitch)
|
||||
{
|
||||
long status = 0;
|
||||
unsigned char value = 0;
|
||||
|
||||
pswitch->pact = TRUE;
|
||||
|
||||
/* initialize record if not already initialized */
|
||||
if (pswitch->val == UNINITIALIZED)
|
||||
status = init_state(pswitch);
|
||||
|
||||
/*
|
||||
* Check master set and reset links.
|
||||
*/
|
||||
status = recGblGetFastLink(&pswitch->mrsl, (void *) pswitch,
|
||||
&pswitch->mrsv);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
MON_FIELD(pswitch->mrsv, pswitch->lmrs);
|
||||
|
||||
status = recGblGetFastLink(&pswitch->mstl, (void *) pswitch,
|
||||
&pswitch->mstv);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
MON_FIELD(pswitch->mstv, pswitch->lmst);
|
||||
|
||||
/* Check master reset value */
|
||||
if (pswitch->mrsv) {
|
||||
pswitch->pint = RESET;
|
||||
|
||||
if (pswitch->val & TO_SET) {
|
||||
if (pswitch->val > TRANS_STATE) {
|
||||
wdCancel((WDOG_ID) ((struct PVT *)pswitch->pvt)->watchdog);
|
||||
}
|
||||
pswitch->val = SET_TO_RESET;
|
||||
pswitch->outv = pswitch->offv;
|
||||
status = output_and_watch(pswitch);
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
else if (pswitch->aftt == FAIL_KEEP_VALUE) {
|
||||
pswitch->outv = pswitch->offv;
|
||||
pswitch->nsta = pswitch->nsev = 0;
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
}
|
||||
|
||||
pswitch->setv = pswitch->rstv = pswitch->togv = 0;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Check master set link
|
||||
*/
|
||||
if (pswitch->mstv) {
|
||||
pswitch->pint = SET;
|
||||
if (!(pswitch->val & TO_SET)) {
|
||||
if (pswitch->val > TRANS_STATE) {
|
||||
wdCancel((WDOG_ID) ((struct PVT *)pswitch->pvt)->watchdog);
|
||||
}
|
||||
pswitch->val = RESET_TO_SET;
|
||||
pswitch->outv = pswitch->onv;
|
||||
status = output_and_watch(pswitch);
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
else if (pswitch->aftt == FAIL_KEEP_VALUE) {
|
||||
pswitch->outv = pswitch->onv;
|
||||
pswitch->nsta = pswitch->nsev = 0;
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
}
|
||||
|
||||
pswitch->setv = pswitch->rstv = pswitch->togv = 0;
|
||||
}
|
||||
/*
|
||||
* Check input links if record is in closed loop mode
|
||||
*/
|
||||
else {
|
||||
if (pswitch->omsl == CLOSED_LOOP) {
|
||||
/*
|
||||
* Check set/reset/toggle input links - and check monitor
|
||||
*/
|
||||
status = recGblGetFastLink(&pswitch->rstl, (void *) pswitch, &pswitch->rstv);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
MON_FIELD(pswitch->rstv, pswitch->lrst);
|
||||
|
||||
status = recGblGetFastLink(&pswitch->setl, (void *) pswitch, &pswitch->setv);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
MON_FIELD(pswitch->setv, pswitch->lsst);
|
||||
|
||||
status = recGblGetFastLink(&pswitch->togl, (void *) pswitch, &pswitch->togv);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
MON_FIELD(pswitch->togv, pswitch->ltog);
|
||||
|
||||
pswitch->intn = 1;
|
||||
}
|
||||
/*
|
||||
* If "intention" is set, a non-master switch has been
|
||||
* modified (by a put, for example). Check the switches.
|
||||
*/
|
||||
if (pswitch->intn) {
|
||||
/*
|
||||
* Ignore command if in transition state and ignore flag set
|
||||
*/
|
||||
if (!((pswitch->val > TRANS_STATE) && pswitch->iti)) {
|
||||
if (pswitch->rstv) {
|
||||
/* reset */
|
||||
pswitch->pint = RESET;
|
||||
if (pswitch->val & TO_SET) {
|
||||
if (pswitch->val > TRANS_STATE) {
|
||||
wdCancel((WDOG_ID) ((struct PVT *)pswitch->pvt)->watchdog);
|
||||
}
|
||||
pswitch->val = SET_TO_RESET;
|
||||
pswitch->outv = pswitch->offv;
|
||||
status = output_and_watch(pswitch);
|
||||
}
|
||||
else if (pswitch->aftt == FAIL_KEEP_VALUE) {
|
||||
pswitch->outv = pswitch->offv;
|
||||
pswitch->nsta = pswitch->nsev = 0;
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pswitch->setv) {
|
||||
/* set */
|
||||
pswitch->pint = SET;
|
||||
if (!(pswitch->val & TO_SET)) {
|
||||
if (pswitch->val > TRANS_STATE) {
|
||||
wdCancel((WDOG_ID) ((struct PVT *)pswitch->pvt)->watchdog);
|
||||
}
|
||||
pswitch->val = RESET_TO_SET;
|
||||
pswitch->outv = pswitch->onv;
|
||||
status = output_and_watch(pswitch);
|
||||
}
|
||||
else if (pswitch->aftt == FAIL_KEEP_VALUE) {
|
||||
pswitch->outv = pswitch->onv;
|
||||
pswitch->nsta = pswitch->nsev = 0;
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pswitch->togv) {
|
||||
/* toggle */
|
||||
if (pswitch->val > TRANS_STATE) {
|
||||
wdCancel((WDOG_ID) ((struct PVT *)pswitch->pvt)->watchdog);
|
||||
}
|
||||
if (pswitch->val & TO_SET) {
|
||||
pswitch->pint = RESET;
|
||||
pswitch->val = SET_TO_RESET;
|
||||
pswitch->outv = pswitch->offv;
|
||||
}
|
||||
else {
|
||||
pswitch->pint = SET;
|
||||
pswitch->val = RESET_TO_SET;
|
||||
pswitch->outv = pswitch->onv;
|
||||
}
|
||||
status = output_and_watch(pswitch);
|
||||
}
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
pswitch->setv = pswitch->rstv = pswitch->togv = 0;
|
||||
|
||||
/*
|
||||
* Intention resets when setv, rstv, togv are activated,
|
||||
* and only after mstv/mrsv are cleared
|
||||
*/
|
||||
pswitch->intn = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not check readback if the link isn't specified or
|
||||
* if a watchdog is in existence.
|
||||
*/
|
||||
if (pswitch->rbkl.type != CONSTANT && pswitch->val <= TRANS_STATE) {
|
||||
status = check_readback(pswitch);
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* store time in record */
|
||||
recGblGetTimeStamp(pswitch);
|
||||
|
||||
/* alarm checking is done in check_readback */
|
||||
|
||||
/*
|
||||
* check event list - though some monitors are
|
||||
* performed in other areas of the code.
|
||||
*/
|
||||
monitor(pswitch);
|
||||
|
||||
/* process forward link */
|
||||
recGblFwdLink(pswitch);
|
||||
|
||||
pswitch->pact = FALSE;
|
||||
return(status);
|
||||
}
|
||||
|
||||
/* special processing */
|
||||
static long special(
|
||||
struct dbAddr *paddr,
|
||||
int after
|
||||
)
|
||||
{
|
||||
if (after && ((struct switchRecord *) paddr->precord)->omsl == SUPERVISORY) {
|
||||
((struct switchRecord *) paddr->precord)->intn = 1;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* monitor fields */
|
||||
static void monitor(struct switchRecord *pswitch)
|
||||
{
|
||||
int monitor_mask = 0;
|
||||
short stat, sevr, nsta, nsev;
|
||||
|
||||
if (pswitch->aftt == FAIL_FOLLOW_RDBK) {
|
||||
monitor_mask = recGblResetAlarms(pswitch);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* recGblResetAlarms() is not used here, because alarm resets
|
||||
* are not supposed to be done when this record is processed.
|
||||
* (i.e. nsta and nsev are not set to zero) However, these
|
||||
* alarms are reset in check_readback().
|
||||
*/
|
||||
stat = pswitch->stat; sevr = pswitch->sevr; nsta = pswitch->nsta;
|
||||
nsev = pswitch->nsev; pswitch->stat = nsta; pswitch->sevr = nsev;
|
||||
|
||||
/*
|
||||
* Check alarm condition -
|
||||
* normally done automatically by recGblResetAlarms()
|
||||
*/
|
||||
if (stat != nsta || sevr != nsev) {
|
||||
monitor_mask |= DBE_ALARM;
|
||||
db_post_events(pswitch, &pswitch->stat, DBE_VALUE);
|
||||
db_post_events(pswitch, &pswitch->sevr, DBE_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* check value */
|
||||
if (pswitch->val != pswitch->mlst) {
|
||||
/* trigger monitor on value */
|
||||
monitor_mask |= (DBE_VALUE | DBE_LOG);
|
||||
pswitch->mlst = pswitch->val;
|
||||
}
|
||||
|
||||
if (monitor_mask) {
|
||||
db_post_events(pswitch, &pswitch->val, monitor_mask);
|
||||
}
|
||||
|
||||
/* check outv */
|
||||
MON_FIELD(pswitch->outv, pswitch->lout);
|
||||
}
|
||||
|
||||
/* get state */
|
||||
static long get_value(
|
||||
struct switchRecord *pswitch,
|
||||
struct valueDes *pvdes
|
||||
)
|
||||
{
|
||||
pvdes->field_type = DBF_ENUM;
|
||||
pvdes->no_elements = 1;
|
||||
(unsigned short *)(pvdes->pvalue) = &pswitch->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* get precision */
|
||||
static long get_precision(
|
||||
struct dbAddr *paddr,
|
||||
long *precision
|
||||
)
|
||||
{
|
||||
struct switchRecord *pswitch = (struct switchRecord *) paddr->precord;
|
||||
|
||||
if (paddr->pfield == &pswitch->xtim)
|
||||
*precision = pswitch->prec;
|
||||
else
|
||||
*precision = 0;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* get state string */
|
||||
static long get_enum_str(
|
||||
struct dbAddr *paddr,
|
||||
char *dest
|
||||
)
|
||||
{
|
||||
struct switchRecord *pswitch = (struct switchRecord *) paddr->precord;
|
||||
char *string;
|
||||
|
||||
if (pswitch->val < STRING_COUNT-1) {
|
||||
string = pswitch->ssi + (pswitch->val * sizeof(pswitch->ssi));
|
||||
strncpy(dest, string, sizeof(pswitch->ssi));
|
||||
}
|
||||
else {
|
||||
strcpy(dest, "Illegal Value");
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* get all strings */
|
||||
static long get_enum_strs(
|
||||
struct dbAddr *paddr,
|
||||
struct dbr_enumStrs *pes
|
||||
)
|
||||
{
|
||||
struct switchRecord *pswitch = (struct switchRecord *) paddr->precord;
|
||||
char *string;
|
||||
int i;
|
||||
short count = 0;
|
||||
|
||||
memset(pes->strs, '\0', sizeof(pes->strs));
|
||||
string = pswitch->ssi;
|
||||
for (i=0; i<STRING_COUNT; i++) {
|
||||
strncpy(pes->strs[i], string, sizeof(pswitch->ssi));
|
||||
if (*string)
|
||||
count = i + 1;
|
||||
string += sizeof(pswitch->ssi);
|
||||
}
|
||||
pes->no_str = count;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* output to "switch" link, and set watchdog */
|
||||
static long output_and_watch(struct switchRecord *pswitch)
|
||||
{
|
||||
long status;
|
||||
|
||||
/* Process switch forward link */
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
|
||||
if (pswitch->rbkl.type == CONSTANT) {
|
||||
pswitch->val = (pswitch->val == SET_TO_RESET) ? RESET : SET;
|
||||
}
|
||||
else {
|
||||
if (pswitch->xtim) {
|
||||
/* activate watchdog */
|
||||
wdStart((WDOG_ID) ((struct PVT *)pswitch->pvt)->watchdog,
|
||||
(int) pswitch->xtim * sysClkRateGet(),
|
||||
(FUNCPTR) watchdog, (int) pswitch);
|
||||
}
|
||||
else {
|
||||
/* check readback immediately */
|
||||
status = check_readback(pswitch);
|
||||
if (status)
|
||||
return(status);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* check readback value */
|
||||
static long check_readback(struct switchRecord *pswitch)
|
||||
{
|
||||
long status;
|
||||
int condition;
|
||||
|
||||
/* get readback */
|
||||
status = recGblGetFastLink(&pswitch->rbkl, (void *) pswitch, &pswitch->rbkv);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
/* choose which condition to check */
|
||||
condition = (pswitch->dthr == BELOW) ? (pswitch->rbkv <= pswitch->rthr) : (pswitch->rbkv >= pswitch->rthr);
|
||||
|
||||
/* check readback value */
|
||||
if (condition) {
|
||||
if (pswitch->pint == SET) {
|
||||
/* Switch set properly */
|
||||
pswitch->val = SET;
|
||||
pswitch->nsta = pswitch->nsev = 0;
|
||||
}
|
||||
else {
|
||||
/* SET ALARM - Was supposed to be reset, but was found to be set */
|
||||
recGblSetSevr(pswitch, STATE_ALARM, pswitch->srfs);
|
||||
pswitch->val = SET;
|
||||
}
|
||||
|
||||
/* Drive output to what it should be given readback, if FOLLOW RDBK set */
|
||||
if (pswitch->aftt == FAIL_FOLLOW_RDBK) {
|
||||
if (pswitch->outv != pswitch->onv) {
|
||||
pswitch->outv = pswitch->onv;
|
||||
|
||||
/* drive output */
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
}
|
||||
pswitch->pint = SET;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (pswitch->pint == RESET) {
|
||||
/* switch reset properly */
|
||||
pswitch->val = RESET;
|
||||
pswitch->nsta = pswitch->nsev = 0;
|
||||
}
|
||||
else {
|
||||
/* SET ALARM - Was supposed to be set, but was found to be reset */
|
||||
recGblSetSevr(pswitch, STATE_ALARM, pswitch->rsfs);
|
||||
pswitch->val = RESET;
|
||||
}
|
||||
|
||||
/* Drive output to what it should be given readback, if FOLLOW RDBK set */
|
||||
if (pswitch->aftt == FAIL_FOLLOW_RDBK) {
|
||||
if (pswitch->outv != pswitch->offv) {
|
||||
pswitch->outv = pswitch->offv;
|
||||
|
||||
/* drive output */
|
||||
if (pswitch->swtc.type == DB_LINK) {
|
||||
dbScanPassive((void *) pswitch, ((struct dbAddr *)pswitch->swtc.value.db_link.pdbAddr)->precord);
|
||||
}
|
||||
}
|
||||
pswitch->pint = RESET;
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* callback */
|
||||
static void callback(CALLBACK *pcallback)
|
||||
{
|
||||
struct switchRecord *pswitch;
|
||||
|
||||
/*
|
||||
* Retrieve pointer to record from callback structure.
|
||||
* This value is fixed at initialization, and will
|
||||
* not be changed, so the database does not have to
|
||||
* be locked for this actiion.
|
||||
*/
|
||||
callbackGetUser((void *) pswitch, pcallback);
|
||||
|
||||
/* lock the database */
|
||||
dbScanLock((struct dbCommon *) pswitch);
|
||||
|
||||
/* check the readback value */
|
||||
check_readback(pswitch);
|
||||
|
||||
/* monitor any changes */
|
||||
monitor(pswitch);
|
||||
|
||||
/* unlock database */
|
||||
dbScanUnlock((struct dbCommon *) pswitch);
|
||||
}
|
||||
|
||||
/* watchdog process adds callback to queue */
|
||||
static void watchdog(struct switchRecord *pswitch)
|
||||
{
|
||||
callbackRequest(&((struct PVT *)pswitch->pvt)->callback);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recTimer.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recTimer.c - Record Support Routines for Timer records */
|
||||
/*
|
||||
@@ -51,6 +51,7 @@
|
||||
* .18 10-10-92 jba replaced get of trdl from torg code with recGblGetLinkValue call
|
||||
* .19 09-02-93 mcn Changed DSET structure for timers, moved code that bypassed
|
||||
* device support into new device support (major improvement).
|
||||
* .20 03-30-94 mcn converted to fast links
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -138,12 +139,11 @@ static long init_record(ptimer, pass)
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* get the delay initial value if torg is a constant*/
|
||||
if (ptimer->torg.type == CONSTANT ){
|
||||
if (ptimer->torg.type == CONSTANT) {
|
||||
ptimer->trdl = ptimer->torg.value.value;
|
||||
}
|
||||
if (ptimer->torg.type == PV_LINK )
|
||||
{
|
||||
status = dbCaAddInlink(&(ptimer->torg), (void *) ptimer, "TRDL");
|
||||
else {
|
||||
status = recGblInitFastInLink(&(ptimer->torg), (void *) ptimer, DBR_FLOAT, "TRDL");
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
|
||||
@@ -280,14 +280,11 @@ static long read_timer(struct timerRecord *ptimer)
|
||||
static long write_timer(struct timerRecord *ptimer)
|
||||
{
|
||||
struct tmdset *pdset;
|
||||
long status,options,nRequest;
|
||||
long status;
|
||||
|
||||
/* get the delay from trigger source */
|
||||
if (ptimer->torg.type == DB_LINK) {
|
||||
options=0;
|
||||
nRequest=1;
|
||||
status=recGblGetLinkValue(&(ptimer->torg),(void *)ptimer,DBR_FLOAT,
|
||||
&(ptimer->trdl),&options,&nRequest);
|
||||
status=recGblGetFastLink(&(ptimer->torg), (void *)ptimer, &(ptimer->trdl));
|
||||
if (!RTN_SUCCESS(status)) return status;
|
||||
}
|
||||
|
||||
@@ -297,7 +294,7 @@ static long write_timer(struct timerRecord *ptimer)
|
||||
}
|
||||
|
||||
/* should we maintain through a reboot */
|
||||
if (ptimer->main && ptimer->rdt1 && ptimer->rpw1){
|
||||
if (ptimer->main && ptimer->rdt1 && ptimer->rpw1) {
|
||||
ptimer->dut1 = ptimer->rdt1 - ptimer->trdl;
|
||||
ptimer->opw1 = ptimer->rpw1;
|
||||
ptimer->main = 0; /* only kept on the first write */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recWaveform.c */
|
||||
/* share/src/rec $Id$ */
|
||||
/* base/src/rec $Id$ */
|
||||
|
||||
/* recWaveform.c - Record Support Routines for Waveform records */
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user