jba changes as of 4/4/91
This commit is contained in:
+11
-6
@@ -174,9 +174,10 @@ static long process(paddr)
|
||||
status=(*pdset->read_ai)(pai); /* read the new value */
|
||||
pai->pact = TRUE;
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if (status==0)convert(pai);
|
||||
else if(status==1) return(0);
|
||||
else if(status==2) status=0;
|
||||
if (status==1) return(0);
|
||||
tsLocalTime(&pai->time);
|
||||
if (status==0) convert(pai);
|
||||
else if (status==2) status=0;
|
||||
|
||||
/* check for alarms */
|
||||
alarm(pai);
|
||||
@@ -200,11 +201,12 @@ static long special(paddr,after)
|
||||
|
||||
switch(special_type) {
|
||||
case(SPC_LINCONV):
|
||||
if(pdset->number<6 || !(pdset->special_linconv)) {
|
||||
if(pdset->number<6) {
|
||||
recGblDbaddrError(S_db_noMod,paddr,"ai: special");
|
||||
return(S_db_noMod);
|
||||
}
|
||||
pai->init=TRUE;
|
||||
if(!(pdset->special_linconv)) return(0);
|
||||
return((*pdset->special_linconv)(pai,after));
|
||||
default:
|
||||
recGblDbaddrError(S_db_badChoice,paddr,"ai: special");
|
||||
@@ -341,11 +343,14 @@ static void convert(pai)
|
||||
struct aiRecord *pai;
|
||||
{
|
||||
double val;
|
||||
float aslo=pai->aslo;
|
||||
float aoff=pai->aoff;
|
||||
|
||||
|
||||
val = pai->rval + pai->roff;
|
||||
/* adjust slope and offset */
|
||||
if(pai->aslo != 0.0) val = val * pai->aslo + pai->aoff;
|
||||
if(aslo < 0.0 || aslo>udfFtest) val = val * aslo;
|
||||
if(aoff < 0.0 || aoff>udfFtest) val = val + aoff;
|
||||
|
||||
/* convert raw to engineering units and signal units */
|
||||
if(pai->linr == 0) {
|
||||
@@ -401,7 +406,7 @@ struct aiRecord *pai;
|
||||
|
||||
/* apply smoothing algorithm */
|
||||
if (pai->smoo != 0.0){
|
||||
if (pai->init == 0) pai->val = val; /* initial condition */
|
||||
if (pai->init == TRUE) pai->val = val; /* initial condition */
|
||||
pai->val = val * (1.00 - pai->smoo) + (pai->val * pai->smoo);
|
||||
}else{
|
||||
pai->val = val;
|
||||
|
||||
+15
-12
@@ -140,7 +140,8 @@ static long init_record(pao)
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* get the initial value if dol is a constant*/
|
||||
if (pao->dol.type == CONSTANT){
|
||||
if (pao->dol.type == CONSTANT &&
|
||||
(pao->dol.value.value<=0.0 || pao->dol.value.value>udfFtest)){
|
||||
pao->val = pao->dol.value.value;
|
||||
}
|
||||
/* must have write_ao function defined */
|
||||
@@ -181,6 +182,7 @@ static long process(paddr)
|
||||
}
|
||||
pao->pact = TRUE;
|
||||
if(status==1) return(0);
|
||||
tsLocalTime(&pao->time);
|
||||
|
||||
/* check for alarms */
|
||||
alarm(pao);
|
||||
@@ -206,10 +208,11 @@ static long special(paddr,after)
|
||||
|
||||
switch(special_type) {
|
||||
case(SPC_LINCONV):
|
||||
if(pdset->number<6 || !(pdset->special_linconv)) {
|
||||
if(pdset->number<6 ) {
|
||||
recGblDbaddrError(S_db_noMod,paddr,"ao: special");
|
||||
return(S_db_noMod);
|
||||
}
|
||||
if(!(pdset->special_linconv)) return(0);
|
||||
return((*pdset->special_linconv)(pao,after));
|
||||
default:
|
||||
recGblDbaddrError(S_db_badChoice,paddr,"ao: special");
|
||||
@@ -221,9 +224,9 @@ static long get_value(pao,pvdes)
|
||||
struct aoRecord *pao;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_FLOAT;
|
||||
pvdes->field_type = DBF_DOUBLE;
|
||||
pvdes->no_elements=1;
|
||||
(float *)(pvdes->pvalue) = &pao->val;
|
||||
(double *)(pvdes->pvalue) = &pao->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -285,10 +288,10 @@ static long get_alarm_double(paddr,pad)
|
||||
static void alarm(pao)
|
||||
struct aoRecord *pao;
|
||||
{
|
||||
float ftemp;
|
||||
float val=pao->val;
|
||||
double ftemp;
|
||||
double val=pao->val;
|
||||
|
||||
if(val>0.0 && val<udfFtest){
|
||||
if(val>0.0 && val<udfDtest){
|
||||
if (pao->nsev<VALID_ALARM){
|
||||
pao->nsta = SOFT_ALARM;
|
||||
pao->nsev = VALID_ALARM;
|
||||
@@ -347,7 +350,7 @@ static void alarm(pao)
|
||||
static int convert(pao)
|
||||
struct aoRecord *pao;
|
||||
{
|
||||
float value;
|
||||
double value;
|
||||
|
||||
if ((pao->dol.type == DB_LINK) && (pao->omsl == CLOSED_LOOP)){
|
||||
long nRequest;
|
||||
@@ -359,7 +362,7 @@ static int convert(pao)
|
||||
nRequest=1;
|
||||
save_pact = pao->pact;
|
||||
pao->pact = TRUE;
|
||||
status = dbGetLink(&pao->dol.value.db_link,pao,DBR_FLOAT,
|
||||
status = dbGetLink(&pao->dol.value.db_link,pao,DBR_DOUBLE,
|
||||
&value,&options,&nRequest);
|
||||
pao->pact = save_pact;
|
||||
if(status) {
|
||||
@@ -387,10 +390,10 @@ static int convert(pao)
|
||||
}
|
||||
pao->val = value;
|
||||
|
||||
if(pao->oval>0.0 && pao->oval<udfFtest) pao->oval = value;
|
||||
if(pao->oval>0.0 && pao->oval<udfDtest) pao->oval = value;
|
||||
/* now set value equal to desired output value */
|
||||
/* apply the output rate of change */
|
||||
if (pao->oroc<0.0 || pao->oroc>=udfFtest){/*must be defined and >0*/
|
||||
if ( pao->oroc>=udfDtest){/*must be defined and >0*/
|
||||
float diff;
|
||||
|
||||
diff = value - pao->oval;
|
||||
@@ -418,7 +421,7 @@ static void monitor(pao)
|
||||
struct aoRecord *pao;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
float delta;
|
||||
double delta;
|
||||
short stat,sevr,nsta,nsev;
|
||||
|
||||
/* get previous stat and sevr and new stat and sevr*/
|
||||
|
||||
+2
-1
@@ -145,12 +145,13 @@ static long process(paddr)
|
||||
|
||||
status=(*pdset->read_bi)(pbi); /* read the new value */
|
||||
pbi->pact = TRUE;
|
||||
if (status==1) return(0);
|
||||
tsLocalTime(&pbi->time);
|
||||
if(status==0) { /* convert rval to val */
|
||||
if(pbi->rval==0) pbi->val =0;
|
||||
else pbi->val = 1;
|
||||
}
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
else if(status==1) return(0);
|
||||
else if(status==2) status=0;
|
||||
/* check for alarms */
|
||||
alarm(pbi);
|
||||
|
||||
+2
-1
@@ -162,7 +162,7 @@ static long init_record(pbo)
|
||||
}
|
||||
/* get the initial value */
|
||||
if (pbo->dol.type == CONSTANT
|
||||
&& (pbo->dol.value.value<0.0 || pbo->dol.value.value>=udfFtest)){
|
||||
&& (pbo->dol.value.value<=0.0 || pbo->dol.value.value>=udfFtest)){
|
||||
if (pbo->dol.value.value == 0) pbo->val = 0;
|
||||
else pbo->val = 1;
|
||||
}
|
||||
@@ -231,6 +231,7 @@ static long process(paddr)
|
||||
pbo->pact = TRUE;
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(status==1) return(0);
|
||||
tsLocalTime(&pbo->time);
|
||||
wait_time = (int)(pbo->high) * vxTicksPerSecond; /* seconds to ticks */
|
||||
if(pbo->val==1 && wait_time>0) {
|
||||
struct callback *pcallback;
|
||||
|
||||
@@ -154,6 +154,7 @@ static long process(paddr)
|
||||
}
|
||||
}
|
||||
}
|
||||
tsLocalTime(&pcalc->time);
|
||||
/* check for alarms */
|
||||
alarm(pcalc);
|
||||
/* check event list */
|
||||
|
||||
@@ -176,6 +176,7 @@ static long process(paddr)
|
||||
|
||||
/* check event list */
|
||||
if(status!=1) {
|
||||
tsLocalTime(&pcompress->time);
|
||||
monitor(pcompress);
|
||||
/* process the forward scan link record */
|
||||
if (pcompress->flnk.type==DB_LINK) dbScanPassive(pcompress->flnk.value.db_link.pdbAddr);
|
||||
@@ -242,7 +243,8 @@ static long get_array_info(paddr,no_elements,offset)
|
||||
struct compressRecord *pcompress=(struct compressRecord *)paddr->precord;
|
||||
|
||||
*no_elements = pcompress->nuse;
|
||||
*offset = pcompress->off;
|
||||
if(pcompress->nuse==pcompress->nsam) *offset = pcompress->off;
|
||||
else *offset = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ static long process(paddr)
|
||||
pfanout->nsta = SOFT_ALARM;
|
||||
}
|
||||
}
|
||||
tsLocalTime(&pfanout->time);
|
||||
/* check monitors*/
|
||||
/* get previous stat and sevr and new stat and sevr*/
|
||||
stat=pfanout->stat;
|
||||
|
||||
+3
-2
@@ -137,7 +137,6 @@ static long init_record(pmbbi)
|
||||
long status;
|
||||
int i;
|
||||
|
||||
init_common(pmbbi);
|
||||
if(!(pdset = (struct mbbidset *)(pmbbi->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,pmbbi,"mbbi: init_record");
|
||||
return(S_dev_noDSET);
|
||||
@@ -156,6 +155,7 @@ static long init_record(pmbbi)
|
||||
if( pdset->init_record ) {
|
||||
if((status=(*pdset->init_record)(pmbbi,process))) return(status);
|
||||
}
|
||||
init_common(pmbbi);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -174,6 +174,8 @@ static long process(paddr)
|
||||
|
||||
status=(*pdset->read_mbbi)(pmbbi); /* read the new value */
|
||||
pmbbi->pact = TRUE;
|
||||
if (status==1) return(0);
|
||||
tsLocalTime(&pmbbi->time);
|
||||
if(status==0) { /* convert the value */
|
||||
unsigned long *pstate_values;
|
||||
short i;
|
||||
@@ -197,7 +199,6 @@ static long process(paddr)
|
||||
pmbbi->val = (unsigned short)rval;
|
||||
}
|
||||
}
|
||||
else if(status==1) return(0);
|
||||
else if(status == 2) status = 0;
|
||||
|
||||
/* check for alarms */
|
||||
|
||||
+16
-13
@@ -156,7 +156,7 @@ static long init_record(pmbbo)
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if ((pmbbo->dol.type == CONSTANT)
|
||||
&& (pmbbo->dol.value.value<0.0 || pmbbo->dol.value.value>=udfFtest)){
|
||||
&& (pmbbo->dol.value.value<=0.0 || pmbbo->dol.value.value>=udfFtest)){
|
||||
pmbbo->val = pmbbo->dol.value.value;
|
||||
}
|
||||
/* initialize mask*/
|
||||
@@ -169,26 +169,28 @@ static long init_record(pmbbo)
|
||||
unsigned long rval;
|
||||
|
||||
if((status=(*pdset->init_record)(pmbbo,process))) return(status);
|
||||
/* init_record might set status */
|
||||
init_common(pmbbo);
|
||||
rval = pmbbo->rval;
|
||||
if(pmbbo->shft>0 && rval!=udfUlong) rval >>= pmbbo->shft;
|
||||
if (pmbbo->sdef){
|
||||
unsigned long *pstate_values;
|
||||
short i;
|
||||
if(rval!=udfUlong) {
|
||||
if(pmbbo->shft>0) rval >>= pmbbo->shft;
|
||||
if (pmbbo->sdef){
|
||||
unsigned long *pstate_values;
|
||||
short i;
|
||||
|
||||
pstate_values = &(pmbbo->zrvl);
|
||||
pmbbo->val = udfUshort; /* initalize to unknown state*/
|
||||
if(rval!=udfUlong) {
|
||||
pstate_values = &(pmbbo->zrvl);
|
||||
pmbbo->val = udfUshort; /* initalize to unknown state*/
|
||||
for (i = 0; i < 16; i++){
|
||||
if (*pstate_values == rval){
|
||||
pmbbo->val = i;
|
||||
break;
|
||||
}
|
||||
pstate_values++;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
/* the raw is the desired val */
|
||||
pmbbo->val = (unsigned short)rval;
|
||||
}
|
||||
}else{
|
||||
/* the raw is the desired val */
|
||||
pmbbo->val = (unsigned short)rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
@@ -257,6 +259,7 @@ DONT_WRITE:
|
||||
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(status==1) return(0);
|
||||
tsLocalTime(&pmbbo->time);
|
||||
/* check for alarms */
|
||||
alarm(pmbbo);
|
||||
/* check event list */
|
||||
|
||||
@@ -91,6 +91,7 @@ static long process(paddr)
|
||||
struct permissiveRecord *ppermissive=(struct permissiveRecord *)(paddr->precord);
|
||||
|
||||
ppermissive->pact=TRUE;
|
||||
tsLocalTime(&ppermissive->time);
|
||||
monitor(ppermissive);
|
||||
if (ppermissive->flnk.type==DB_LINK)
|
||||
dbScanPassive(ppermissive->flnk.value.db_link.pdbAddr);
|
||||
|
||||
+8
-7
@@ -120,6 +120,7 @@ static long process(paddr)
|
||||
return(0);
|
||||
}
|
||||
|
||||
tsLocalTime(&ppid->time);
|
||||
/* check for alarms */
|
||||
alarm(ppid);
|
||||
|
||||
@@ -304,12 +305,12 @@ static void monitor(ppid)
|
||||
if (monitor_mask){
|
||||
db_post_events(ppid,&ppid->val,monitor_mask);
|
||||
}
|
||||
delta = ppid->oout - ppid->out;
|
||||
delta = ppid->odm - ppid->dm;
|
||||
if(delta<0.0) delta = -delta;
|
||||
if(delta > ppid->odel) {
|
||||
ppid->oout = ppid->out;
|
||||
ppid->odm = ppid->dm;
|
||||
monitor_mask = DBE_LOG|DBE_VALUE;
|
||||
db_post_events(ppid,&ppid->out,monitor_mask);
|
||||
db_post_events(ppid,&ppid->dm,monitor_mask);
|
||||
db_post_events(ppid,&ppid->p,monitor_mask);
|
||||
db_post_events(ppid,&ppid->i,monitor_mask);
|
||||
db_post_events(ppid,&ppid->d,monitor_mask);
|
||||
@@ -337,7 +338,7 @@ static void monitor(ppid)
|
||||
* delM(n) = KP*((E(n)-E(n-1)) + E(n)*dT(n)*KI
|
||||
* + KD*((E(n)-E(n-1))/dT(n) - (E(n-1)-E(n-2))/dT(n-1))
|
||||
* or using variables defined in following
|
||||
* out = kp*(de + e*dt*ki + kd*(de/dt - dep/dtp)
|
||||
* dm = kp*(de + e*dt*ki + kd*(de/dt - dep/dtp)
|
||||
*/
|
||||
|
||||
static long do_pid(ppid)
|
||||
@@ -355,7 +356,7 @@ struct pidRecord *ppid;
|
||||
float ep; /*previous error */
|
||||
float de; /*change in error */
|
||||
float dep; /*prev change in error */
|
||||
float out; /*output value */
|
||||
float dm; /*output value */
|
||||
float p; /*proportional contribution*/
|
||||
float i; /*integral contribution*/
|
||||
float d; /*derivative contribution*/
|
||||
@@ -421,14 +422,14 @@ struct pidRecord *ppid;
|
||||
i = kp*e*dt*ki;
|
||||
if(dtp>0.0 && dt>0.0) d = kp*kd*(de/dt - dep/dtp);
|
||||
else d = 0.0;
|
||||
out = p + i + d;
|
||||
dm = p + i + d;
|
||||
/* update record*/
|
||||
ppid->ct = ct;
|
||||
ppid->dt = dt;
|
||||
ppid->err = e;
|
||||
ppid->derr = de;
|
||||
ppid->cval = cval;
|
||||
ppid->out = out;
|
||||
ppid->dm = dm;
|
||||
ppid->p = p;
|
||||
ppid->i = i;
|
||||
ppid->d = d;
|
||||
|
||||
@@ -128,6 +128,7 @@ static long process(paddr)
|
||||
}
|
||||
}
|
||||
|
||||
tsLocalTime(&psel->time);
|
||||
/* check for alarms */
|
||||
alarm(psel);
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ static long process(paddr)
|
||||
struct stateRecord *pstate=(struct stateRecord *)(paddr->precord);
|
||||
|
||||
pstate->pact=TRUE;
|
||||
tsLocalTime(&pstate->time);
|
||||
monitor(pstate);
|
||||
/* process the forward scan link record */
|
||||
if (pstate->flnk.type==DB_LINK) dbScanPassive(pstate->flnk.value.db_link.pdbAddr);
|
||||
|
||||
@@ -134,6 +134,7 @@ static long process(paddr)
|
||||
/* the init is set when the readback returns */
|
||||
if (psm->init == 0){
|
||||
init_sm(psm);
|
||||
tsLocalTime(&psm->time);
|
||||
monitor(psm);
|
||||
return(0);
|
||||
}
|
||||
@@ -145,6 +146,7 @@ static long process(paddr)
|
||||
velocity_sm(psm);
|
||||
|
||||
|
||||
tsLocalTime(&psm->time);
|
||||
/* check event list */
|
||||
monitor(psm);
|
||||
|
||||
@@ -605,11 +607,11 @@ struct steppermotorRecord *psm;
|
||||
}
|
||||
|
||||
/* fetch the desired value if there is a database link */
|
||||
if (psm->dvl.type == DB_LINK && psm->omsl == CLOSED_LOOP){
|
||||
if (psm->dol.type == DB_LINK && psm->omsl == CLOSED_LOOP){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
|
||||
if(dbGetLink(&(psm->dvl.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)){
|
||||
if(dbGetLink(&(psm->dol.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)){
|
||||
if (psm->nsev < MAJOR_ALARM) {
|
||||
psm->nsta = READ_ALARM;
|
||||
psm->nsev = MAJOR_ALARM;
|
||||
@@ -681,11 +683,11 @@ struct steppermotorRecord *psm;
|
||||
if (psm->out.type != VME_IO) return;
|
||||
|
||||
/* fetch the desired value if there is a database link */
|
||||
if (psm->dvl.type == DB_LINK && psm->omsl == CLOSED_LOOP){
|
||||
if (psm->dol.type == DB_LINK && psm->omsl == CLOSED_LOOP){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
|
||||
if(dbGetLink(&(psm->dvl.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)) {
|
||||
if(dbGetLink(&(psm->dol.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)) {
|
||||
if (psm->nsev < MAJOR_ALARM) {
|
||||
psm->nsta = READ_ALARM;
|
||||
psm->nsev = MAJOR_ALARM;
|
||||
|
||||
@@ -157,6 +157,7 @@ static long process(paddr)
|
||||
if(status==0) status = do_sub(psub);
|
||||
psub->pact = TRUE;
|
||||
if(status==1) return(0);
|
||||
tsLocalTime(&psub->time);
|
||||
/* check for alarms */
|
||||
alarm(psub);
|
||||
/* check event list */
|
||||
|
||||
@@ -125,6 +125,7 @@ static long process(paddr)
|
||||
|
||||
/* write the new value */
|
||||
write_timer(ptimer);
|
||||
tsLocalTime(&ptimer->time);
|
||||
|
||||
/* check event list */
|
||||
monitor(ptimer);
|
||||
|
||||
+2
-13
@@ -79,7 +79,7 @@ long get_precision();
|
||||
#define put_enum_str NULL
|
||||
long get_graphic_double();
|
||||
long get_control_double();
|
||||
long get_alarm_double();
|
||||
#define get_alarm_double NULL
|
||||
|
||||
struct rset waveformRSET={
|
||||
RSETNUMBER,
|
||||
@@ -166,6 +166,7 @@ static long process(paddr)
|
||||
pwf->pact = TRUE;
|
||||
/* status is one if an asynchronous record is being processed*/
|
||||
if(status==1) return(0);
|
||||
tsLocalTime(&pwf->time);
|
||||
|
||||
monitor(pwf);
|
||||
/* process the forward scan link record */
|
||||
@@ -265,18 +266,6 @@ static long get_control_double(paddr,pcd)
|
||||
pcd->lower_ctrl_limit = pwf->lopr;
|
||||
return(0);
|
||||
}
|
||||
static long get_alarm_double(paddr,pgd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_alDouble *pgd;
|
||||
{
|
||||
struct waveformRecord *pwf=(struct waveformRecord *)paddr->precord;
|
||||
|
||||
pgd->upper_alarm_limit = 0.0;
|
||||
pgd->upper_warning_limit = 0.0;
|
||||
pgd->lower_warning_limit = 0.0;
|
||||
pgd->lower_alarm_limit = 0.0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void monitor(pwf)
|
||||
struct waveformRecord *pwf;
|
||||
|
||||
Reference in New Issue
Block a user