Commit adding new record support code of aai, aao, dfanout, mbbiDirec, and mbboDirect.
This commit is contained in:
359
src/rec/recAai.c
Normal file
359
src/rec/recAai.c
Normal file
@@ -0,0 +1,359 @@
|
||||
/* recAai.c */
|
||||
|
||||
/* recAai.c - Record Support Routines for Array Analog In records */
|
||||
/*
|
||||
* Original Author: Dave Barker
|
||||
* Current Author: Dave Barker
|
||||
* Date: 10/24/93
|
||||
*
|
||||
* C E B A F
|
||||
*
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
* Newport News, Virginia, USA.
|
||||
*
|
||||
* Copyright SURA CEBAF 1993.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <dbScan.h>
|
||||
#include <devSup.h>
|
||||
#include <errMdef.h>
|
||||
#include <recSup.h>
|
||||
#include <aaiRecord.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();
|
||||
static long cvt_dbaddr();
|
||||
static long get_array_info();
|
||||
static long put_array_info();
|
||||
static long get_units();
|
||||
static long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
static long get_graphic_double();
|
||||
static long get_control_double();
|
||||
#define get_alarm_double NULL
|
||||
|
||||
struct rset aaiRSET={
|
||||
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 aaidset { /* aai dset */
|
||||
long number;
|
||||
DEVSUPFUN dev_report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN read_aai; /*returns: (-1,0)=>(failure,success)*/
|
||||
};
|
||||
|
||||
/*sizes of field types*/
|
||||
static int sizeofTypes[] = {0,1,1,2,2,4,4,4,8,2};
|
||||
|
||||
static void monitor();
|
||||
static long readValue();
|
||||
|
||||
/*Following from timing system */
|
||||
extern unsigned int gts_trigger_counter;
|
||||
|
||||
|
||||
static long init_record(paai,pass)
|
||||
struct aaiRecord *paai;
|
||||
int pass;
|
||||
{
|
||||
struct aaidset *pdset;
|
||||
long status;
|
||||
|
||||
if (pass==0){
|
||||
if(paai->nelm<=0) paai->nelm=1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* aai.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (paai->siml.type) {
|
||||
case (CONSTANT) :
|
||||
paai->simm = paai->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(paai->siml), (void *) paai, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)paai,
|
||||
"aai: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
/* aai.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (paai->siol.type) {
|
||||
case (CONSTANT) :
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(paai->siol), (void *) paai, "VAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)paai,
|
||||
"aai: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
/* must have dset defined */
|
||||
if(!(pdset = (struct aaidset *)(paai->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)paai,"aai: init_record");
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* must have read_aai function defined */
|
||||
if( (pdset->number < 5) || (pdset->read_aai == NULL) ) {
|
||||
recGblRecordError(S_dev_missingSup,(void *)paai,"aai: init_record");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if( pdset->init_record ) {
|
||||
/* init records sets the bptr to point to the data */
|
||||
if((status=(*pdset->init_record)(paai))) return(status);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long process(paai)
|
||||
struct aaiRecord *paai;
|
||||
{
|
||||
struct aaidset *pdset = (struct aaidset *)(paai->dset);
|
||||
long status;
|
||||
unsigned char pact=paai->pact;
|
||||
|
||||
if( (pdset==NULL) || (pdset->read_aai==NULL) ) {
|
||||
paai->pact=TRUE;
|
||||
recGblRecordError(S_dev_missingSup,(void *)paai,"read_aai");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
/* event throttling */
|
||||
if (paai->scan == SCAN_IO_EVENT){
|
||||
if ((paai->evnt != 0) && (gts_trigger_counter != 0)){
|
||||
if ((gts_trigger_counter % paai->evnt) != 0){
|
||||
status=readValue(paai);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( pact ) return(0);
|
||||
|
||||
status=readValue(paai); /* read the new value */
|
||||
|
||||
paai->udf=FALSE;
|
||||
tsLocalTime(&paai->time);
|
||||
|
||||
monitor(paai);
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(paai);
|
||||
|
||||
paai->pact=FALSE;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_value(paai,pvdes)
|
||||
struct aaiRecord *paai;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
|
||||
pvdes->no_elements=paai->nelm;
|
||||
pvdes->pvalue = paai->bptr;
|
||||
pvdes->field_type = paai->ftvl;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long cvt_dbaddr(paddr)
|
||||
struct dbAddr *paddr;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
paddr->pfield = (void *)(paai->bptr);
|
||||
paddr->no_elements = paai->nelm;
|
||||
paddr->field_type = paai->ftvl;
|
||||
if(paai->ftvl==0) paddr->field_size = MAX_STRING_SIZE;
|
||||
else paddr->field_size = sizeofTypes[paai->ftvl];
|
||||
paddr->dbr_field_type = paai->ftvl;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_array_info(paddr,no_elements,offset)
|
||||
struct dbAddr *paddr;
|
||||
long *no_elements;
|
||||
long *offset;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
*no_elements = paai->nelm;
|
||||
*offset = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long put_array_info(paddr,nNew)
|
||||
struct dbAddr *paddr;
|
||||
long nNew;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
paai->nelm = nNew;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_units(paddr,units)
|
||||
struct dbAddr *paddr;
|
||||
char *units;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
strncpy(units,paai->egu,sizeof(paai->egu));
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_precision(paddr,precision)
|
||||
struct dbAddr *paddr;
|
||||
long *precision;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
*precision = paai->prec;
|
||||
if(paddr->pfield==(void *)paai->bptr) return(0);
|
||||
recGblGetPrec(paddr,precision);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_graphic_double(paddr,pgd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_grDouble *pgd;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)paai->bptr){
|
||||
pgd->upper_disp_limit = paai->hopr;
|
||||
pgd->lower_disp_limit = paai->lopr;
|
||||
} else recGblGetGraphicDouble(paddr,pgd);
|
||||
return(0);
|
||||
}
|
||||
static long get_control_double(paddr,pcd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_ctrlDouble *pcd;
|
||||
{
|
||||
struct aaiRecord *paai=(struct aaiRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)paai->bptr){
|
||||
pcd->upper_ctrl_limit = paai->hopr;
|
||||
pcd->lower_ctrl_limit = paai->lopr;
|
||||
} else recGblGetControlDouble(paddr,pcd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void monitor(paai)
|
||||
struct aaiRecord *paai;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
|
||||
monitor_mask = recGblResetAlarms(paai);
|
||||
monitor_mask |= (DBE_LOG|DBE_VALUE);
|
||||
if(monitor_mask) db_post_events(paai,paai->bptr,monitor_mask);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static long readValue(paai)
|
||||
struct aaiRecord *paai;
|
||||
{
|
||||
long status;
|
||||
struct aaidset *pdset = (struct aaidset *) (paai->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
|
||||
if (paai->pact == TRUE){
|
||||
/* no asyn allowed, pact true means do not process */
|
||||
return(0);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(paai->siml),
|
||||
(void *)paai,DBR_ENUM,&(paai->simm),&options,&nRequest);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if (paai->simm == NO){
|
||||
/* Call dev support */
|
||||
status=(*pdset->read_aai)(paai);
|
||||
return(status);
|
||||
}
|
||||
if (paai->simm == YES){
|
||||
/* Simm processing split performed in devSup */
|
||||
/* Call dev support */
|
||||
status=(*pdset->read_aai)(paai);
|
||||
return(status);
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(paai,SOFT_ALARM,INVALID_ALARM);
|
||||
return(status);
|
||||
}
|
||||
recGblSetSevr(paai,SIMM_ALARM,paai->sims);
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
358
src/rec/recAao.c
Normal file
358
src/rec/recAao.c
Normal file
@@ -0,0 +1,358 @@
|
||||
/* recAao.c */
|
||||
|
||||
/* recAao.c - Record Support Routines for Array Analog Out records */
|
||||
/*
|
||||
* Original Author: Dave Barker
|
||||
* Current Author: Dave Barker
|
||||
* Date: 10/28/93
|
||||
*
|
||||
* C E B A F
|
||||
*
|
||||
* Continuous Electron Beam Accelerator Facility
|
||||
* Newport News, Virginia, USA.
|
||||
*
|
||||
* Copyright SURA CEBAF 1993.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <alarm.h>
|
||||
#include <dbDefs.h>
|
||||
#include <dbAccess.h>
|
||||
#include <dbFldTypes.h>
|
||||
#include <dbScan.h>
|
||||
#include <devSup.h>
|
||||
#include <errMdef.h>
|
||||
#include <recSup.h>
|
||||
#include <aaoRecord.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();
|
||||
static long cvt_dbaddr();
|
||||
static long get_array_info();
|
||||
static long put_array_info();
|
||||
static long get_units();
|
||||
static long get_precision();
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
static long get_graphic_double();
|
||||
static long get_control_double();
|
||||
#define get_alarm_double NULL
|
||||
|
||||
struct rset aaoRSET={
|
||||
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 aaodset { /* aao dset */
|
||||
long number;
|
||||
DEVSUPFUN dev_report;
|
||||
DEVSUPFUN init;
|
||||
DEVSUPFUN init_record; /*returns: (-1,0)=>(failure,success)*/
|
||||
DEVSUPFUN get_ioint_info;
|
||||
DEVSUPFUN write_aao; /*returns: (-1,0)=>(failure,success)*/
|
||||
};
|
||||
|
||||
/*sizes of field types*/
|
||||
static int sizeofTypes[] = {0,1,1,2,2,4,4,4,8,2};
|
||||
|
||||
static void monitor();
|
||||
static long writeValue();
|
||||
|
||||
/*Following from timing system */
|
||||
extern unsigned int gts_trigger_counter;
|
||||
|
||||
|
||||
static long init_record(paao,pass)
|
||||
struct aaoRecord *paao;
|
||||
int pass;
|
||||
{
|
||||
struct aaodset *pdset;
|
||||
long status;
|
||||
|
||||
if (pass==0){
|
||||
if(paao->nelm<=0) paao->nelm=1;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* aao.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (paao->siml.type) {
|
||||
case (CONSTANT) :
|
||||
paao->simm = paao->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(paao->siml), (void *) paao, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)paao,
|
||||
"aao: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
/* aao.siol must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (paao->siol.type) {
|
||||
case (CONSTANT) :
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(paao->siol), (void *) paao, "VAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)paao,
|
||||
"aao: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
/* must have dset defined */
|
||||
if(!(pdset = (struct aaodset *)(paao->dset))) {
|
||||
recGblRecordError(S_dev_noDSET,(void *)paao,"aao: init_record");
|
||||
return(S_dev_noDSET);
|
||||
}
|
||||
/* must have write_aao function defined */
|
||||
if( (pdset->number < 5) || (pdset->write_aao == NULL) ) {
|
||||
recGblRecordError(S_dev_missingSup,(void *)paao,"aao: init_record");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
if( pdset->init_record ) {
|
||||
/* init records sets the bptr to point to the data */
|
||||
if((status=(*pdset->init_record)(paao))) return(status);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long process(paao)
|
||||
struct aaoRecord *paao;
|
||||
{
|
||||
struct aaodset *pdset = (struct aaodset *)(paao->dset);
|
||||
long status;
|
||||
unsigned char pact=paao->pact;
|
||||
|
||||
if( (pdset==NULL) || (pdset->write_aao==NULL) ) {
|
||||
paao->pact=TRUE;
|
||||
recGblRecordError(S_dev_missingSup,(void *)paao,"write_aao");
|
||||
return(S_dev_missingSup);
|
||||
}
|
||||
/* event throttling */
|
||||
if (paao->scan == SCAN_IO_EVENT){
|
||||
if ((paao->evnt != 0) && (gts_trigger_counter != 0)){
|
||||
if ((gts_trigger_counter % paao->evnt) != 0){
|
||||
status=writeValue(paao);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( pact ) return(0);
|
||||
|
||||
status=writeValue(paao); /* write the data */
|
||||
|
||||
paao->udf=FALSE;
|
||||
tsLocalTime(&paao->time);
|
||||
|
||||
monitor(paao);
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(paao);
|
||||
|
||||
paao->pact=FALSE;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_value(paao,pvdes)
|
||||
struct aaoRecord *paao;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
|
||||
pvdes->no_elements=paao->nelm;
|
||||
pvdes->pvalue = paao->bptr;
|
||||
pvdes->field_type = paao->ftvl;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long cvt_dbaddr(paddr)
|
||||
struct dbAddr *paddr;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
paddr->pfield = (void *)(paao->bptr);
|
||||
paddr->no_elements = paao->nelm;
|
||||
paddr->field_type = paao->ftvl;
|
||||
if(paao->ftvl==0) paddr->field_size = MAX_STRING_SIZE;
|
||||
else paddr->field_size = sizeofTypes[paao->ftvl];
|
||||
paddr->dbr_field_type = paao->ftvl;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_array_info(paddr,no_elements,offset)
|
||||
struct dbAddr *paddr;
|
||||
long *no_elements;
|
||||
long *offset;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
*no_elements = paao->nelm;
|
||||
*offset = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long put_array_info(paddr,nNew)
|
||||
struct dbAddr *paddr;
|
||||
long nNew;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
paao->nelm = nNew;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_units(paddr,units)
|
||||
struct dbAddr *paddr;
|
||||
char *units;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
strncpy(units,paao->egu,sizeof(paao->egu));
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_precision(paddr,precision)
|
||||
struct dbAddr *paddr;
|
||||
long *precision;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
*precision = paao->prec;
|
||||
if(paddr->pfield==(void *)paao->bptr) return(0);
|
||||
recGblGetPrec(paddr,precision);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_graphic_double(paddr,pgd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_grDouble *pgd;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)paao->bptr){
|
||||
pgd->upper_disp_limit = paao->hopr;
|
||||
pgd->lower_disp_limit = paao->lopr;
|
||||
} else recGblGetGraphicDouble(paddr,pgd);
|
||||
return(0);
|
||||
}
|
||||
static long get_control_double(paddr,pcd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_ctrlDouble *pcd;
|
||||
{
|
||||
struct aaoRecord *paao=(struct aaoRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)paao->bptr){
|
||||
pcd->upper_ctrl_limit = paao->hopr;
|
||||
pcd->lower_ctrl_limit = paao->lopr;
|
||||
} else recGblGetControlDouble(paddr,pcd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void monitor(paao)
|
||||
struct aaoRecord *paao;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
|
||||
monitor_mask = recGblResetAlarms(paao);
|
||||
monitor_mask |= (DBE_LOG|DBE_VALUE);
|
||||
if(monitor_mask) db_post_events(paao,paao->bptr,monitor_mask);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static long writeValue(paao)
|
||||
struct aaoRecord *paao;
|
||||
{
|
||||
long status;
|
||||
struct aaodset *pdset = (struct aaodset *) (paao->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
|
||||
if (paao->pact == TRUE){
|
||||
/* no asyn allowed, pact true means do not process */
|
||||
return(0);
|
||||
}
|
||||
|
||||
status=recGblGetLinkValue(&(paao->siml),
|
||||
(void *)paao,DBR_ENUM,&(paao->simm),&options,&nRequest);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
if (paao->simm == NO){
|
||||
/* Call dev support */
|
||||
status=(*pdset->write_aao)(paao);
|
||||
return(status);
|
||||
}
|
||||
if (paao->simm == YES){
|
||||
/* Call dev support */
|
||||
status=(*pdset->write_aao)(paao);
|
||||
return(status);
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(paao,SOFT_ALARM,INVALID_ALARM);
|
||||
return(status);
|
||||
}
|
||||
recGblSetSevr(paao,SIMM_ALARM,paao->sims);
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
421
src/rec/recDfanout.c
Normal file
421
src/rec/recDfanout.c
Normal file
@@ -0,0 +1,421 @@
|
||||
/* recLongout.c */
|
||||
/* share/src/rec @(#)recLongout.c 1.16 6/4/93 */
|
||||
|
||||
/* recLongout.c - Record Support Routines for Longout records */
|
||||
/*
|
||||
* Author: Janet Anderson
|
||||
* Date: 9/23/91
|
||||
*
|
||||
* 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 11-11-91 jba Moved set and reset of alarm stat and sevr to macros
|
||||
* .02 02-05-92 jba Changed function arguments from paddr to precord
|
||||
* .03 02-28-92 jba ANSI C changes
|
||||
* .04 04-10-92 jba pact now used to test for asyn processing, not status
|
||||
* .05 04-18-92 jba removed process from dev init_record parms
|
||||
* .06 06-02-92 jba changed graphic/control limits for hihi,high,low,lolo
|
||||
* .07 07-15-92 jba changed VALID_ALARM to INVALID alarm
|
||||
* .08 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro
|
||||
* .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 08-14-92 jba Added simulation processing
|
||||
* .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 10-21-93 mhb Started with longout record to make the data fanout
|
||||
*/
|
||||
|
||||
|
||||
#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 <dfanoutRecord.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();
|
||||
#define get_precision NULL
|
||||
#define get_enum_str NULL
|
||||
#define get_enum_strs NULL
|
||||
#define put_enum_str NULL
|
||||
static long get_graphic_double();
|
||||
static long get_control_double();
|
||||
static long get_alarm_double();
|
||||
|
||||
struct rset dfanoutRSET={
|
||||
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 alarm();
|
||||
static void monitor();
|
||||
static long writeValue();
|
||||
static long push_values();
|
||||
|
||||
#define OUT_ARG_MAX 8
|
||||
|
||||
static char Ofldnames[OUT_ARG_MAX][FLDNAME_SZ] =
|
||||
{"OUTA", "OUTB", "OUTC", "OUTD", "OUTE", "OUTF", "OUTG", "OUTH"};
|
||||
|
||||
|
||||
static long init_record(pdfanout,pass)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
int pass;
|
||||
{
|
||||
struct link *plink;
|
||||
long status=0;
|
||||
int i;
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
/* dfanout.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pdfanout->siml.type) {
|
||||
case (CONSTANT) :
|
||||
pdfanout->simm = pdfanout->siml.value.value;
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pdfanout->siml), (void *) pdfanout, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pdfanout,
|
||||
"dfanout: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
plink = &pdfanout->outa;
|
||||
for (i=0; i<OUT_ARG_MAX; i++, plink++) {
|
||||
if (plink->type == PV_LINK) {
|
||||
status = dbCaAddOutlink(plink, (void *) pdfanout, Ofldnames[i]);
|
||||
if (status) return(status);
|
||||
}
|
||||
}
|
||||
|
||||
/* dfanout.siol may be a PV_LINK */
|
||||
if (pdfanout->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(pdfanout->siol), (void *) pdfanout, "VAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
|
||||
/* get the initial value dol is a constant*/
|
||||
if (pdfanout->dol.type == CONSTANT){
|
||||
pdfanout->val = pdfanout->dol.value.value;
|
||||
pdfanout->udf=FALSE;
|
||||
}
|
||||
if (pdfanout->dol.type == PV_LINK)
|
||||
{
|
||||
status = dbCaAddInlink(&(pdfanout->dol), (void *) pdfanout, "VAL");
|
||||
if(status) return(status);
|
||||
} /* endif */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long process(pdfanout)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
{
|
||||
long status=0;
|
||||
unsigned char pact=pdfanout->pact;
|
||||
|
||||
if (!pdfanout->pact && pdfanout->omsl == CLOSED_LOOP){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
|
||||
status = recGblGetLinkValue(&(pdfanout->dol),(void *)pdfanout,
|
||||
DBR_LONG,&(pdfanout->val),&options,&nRequest);
|
||||
if(RTN_SUCCESS(status)) pdfanout->udf=FALSE;
|
||||
}
|
||||
|
||||
/* check for alarms */
|
||||
alarm(pdfanout);
|
||||
|
||||
if (pdfanout->nsev < INVALID_ALARM )
|
||||
status=writeValue(pdfanout); /* write the new value */
|
||||
else {
|
||||
switch (pdfanout->ivoa) {
|
||||
case (IVOA_CONTINUE) :
|
||||
status=writeValue(pdfanout); /* write the new value */
|
||||
break;
|
||||
case (IVOA_NO_OUTPUT) :
|
||||
break;
|
||||
case (IVOA_OUTPUT_IVOV) :
|
||||
if(pdfanout->pact == FALSE){
|
||||
pdfanout->val=pdfanout->ivov;
|
||||
}
|
||||
status=writeValue(pdfanout); /* write the new value */
|
||||
break;
|
||||
default :
|
||||
status=-1;
|
||||
recGblRecordError(S_db_badField,(void *)pdfanout,
|
||||
"dfanout:process Illegal IVOA field");
|
||||
}
|
||||
}
|
||||
|
||||
/* check if device support set pact */
|
||||
if ( !pact && pdfanout->pact ) return(0);
|
||||
pdfanout->pact = TRUE;
|
||||
|
||||
tsLocalTime(&pdfanout->time);
|
||||
|
||||
/* check for alarms */
|
||||
alarm(pdfanout);
|
||||
/* check event list */
|
||||
monitor(pdfanout);
|
||||
|
||||
/* process the forward scan link record */
|
||||
recGblFwdLink(pdfanout);
|
||||
|
||||
/* Push out the data to all the forward links */
|
||||
status = push_values(pdfanout);
|
||||
|
||||
pdfanout->pact=FALSE;
|
||||
return(status);
|
||||
}
|
||||
|
||||
static long get_value(pdfanout,pvdes)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
struct valueDes *pvdes;
|
||||
{
|
||||
pvdes->field_type = DBF_LONG;
|
||||
pvdes->no_elements=1;
|
||||
(long *)(pvdes->pvalue) = &pdfanout->val;
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_units(paddr,units)
|
||||
struct dbAddr *paddr;
|
||||
char *units;
|
||||
{
|
||||
struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord;
|
||||
|
||||
strncpy(units,pdfanout->egu,sizeof(pdfanout->egu));
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_graphic_double(paddr,pgd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_grDouble *pgd;
|
||||
{
|
||||
struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)&pdfanout->val
|
||||
|| paddr->pfield==(void *)&pdfanout->hihi
|
||||
|| paddr->pfield==(void *)&pdfanout->high
|
||||
|| paddr->pfield==(void *)&pdfanout->low
|
||||
|| paddr->pfield==(void *)&pdfanout->lolo){
|
||||
pgd->upper_disp_limit = pdfanout->hopr;
|
||||
pgd->lower_disp_limit = pdfanout->lopr;
|
||||
} else recGblGetGraphicDouble(paddr,pgd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static long get_control_double(paddr,pcd)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_ctrlDouble *pcd;
|
||||
{
|
||||
struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)&pdfanout->val
|
||||
|| paddr->pfield==(void *)&pdfanout->hihi
|
||||
|| paddr->pfield==(void *)&pdfanout->high
|
||||
|| paddr->pfield==(void *)&pdfanout->low
|
||||
|| paddr->pfield==(void *)&pdfanout->lolo){
|
||||
pcd->upper_ctrl_limit = pdfanout->hopr;
|
||||
pcd->lower_ctrl_limit = pdfanout->lopr;
|
||||
} else recGblGetControlDouble(paddr,pcd);
|
||||
return(0);
|
||||
}
|
||||
static long get_alarm_double(paddr,pad)
|
||||
struct dbAddr *paddr;
|
||||
struct dbr_alDouble *pad;
|
||||
{
|
||||
struct dfanoutRecord *pdfanout=(struct dfanoutRecord *)paddr->precord;
|
||||
|
||||
if(paddr->pfield==(void *)&pdfanout->val){
|
||||
pad->upper_alarm_limit = pdfanout->hihi;
|
||||
pad->upper_warning_limit = pdfanout->high;
|
||||
pad->lower_warning_limit = pdfanout->low;
|
||||
pad->lower_alarm_limit = pdfanout->lolo;
|
||||
} else recGblGetAlarmDouble(paddr,pad);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void alarm(pdfanout)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
{
|
||||
double val;
|
||||
float hyst, lalm, hihi, high, low, lolo;
|
||||
unsigned short hhsv, llsv, hsv, lsv;
|
||||
|
||||
if(pdfanout->udf == TRUE ){
|
||||
recGblSetSevr(pdfanout,UDF_ALARM,INVALID_ALARM);
|
||||
return;
|
||||
}
|
||||
hihi = pdfanout->hihi; lolo = pdfanout->lolo; high = pdfanout->high; low = pdfanout->low;
|
||||
hhsv = pdfanout->hhsv; llsv = pdfanout->llsv; hsv = pdfanout->hsv; lsv = pdfanout->lsv;
|
||||
val = pdfanout->val; hyst = pdfanout->hyst; lalm = pdfanout->lalm;
|
||||
|
||||
/* alarm condition hihi */
|
||||
if (hhsv && (val >= hihi || ((lalm==hihi) && (val >= hihi-hyst)))){
|
||||
if (recGblSetSevr(pdfanout,HIHI_ALARM,pdfanout->hhsv)) pdfanout->lalm = hihi;
|
||||
return;
|
||||
}
|
||||
|
||||
/* alarm condition lolo */
|
||||
if (llsv && (val <= lolo || ((lalm==lolo) && (val <= lolo+hyst)))){
|
||||
if (recGblSetSevr(pdfanout,LOLO_ALARM,pdfanout->llsv)) pdfanout->lalm = lolo;
|
||||
return;
|
||||
}
|
||||
|
||||
/* alarm condition high */
|
||||
if (hsv && (val >= high || ((lalm==high) && (val >= high-hyst)))){
|
||||
if (recGblSetSevr(pdfanout,HIGH_ALARM,pdfanout->hsv)) pdfanout->lalm = high;
|
||||
return;
|
||||
}
|
||||
|
||||
/* alarm condition low */
|
||||
if (lsv && (val <= low || ((lalm==low) && (val <= low+hyst)))){
|
||||
if (recGblSetSevr(pdfanout,LOW_ALARM,pdfanout->lsv)) pdfanout->lalm = low;
|
||||
return;
|
||||
}
|
||||
|
||||
/* we get here only if val is out of alarm by at least hyst */
|
||||
pdfanout->lalm = val;
|
||||
return;
|
||||
}
|
||||
|
||||
static void monitor(pdfanout)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
{
|
||||
unsigned short monitor_mask;
|
||||
|
||||
long delta;
|
||||
|
||||
monitor_mask = recGblResetAlarms(pdfanout);
|
||||
monitor_mask |= (DBE_LOG|DBE_VALUE);
|
||||
if(monitor_mask)
|
||||
db_post_events(pdfanout,pdfanout->val,monitor_mask);
|
||||
|
||||
/* check for value change */
|
||||
delta = pdfanout->mlst - pdfanout->val;
|
||||
if(delta<0) delta = -delta;
|
||||
if (delta > pdfanout->mdel) {
|
||||
/* post events for value change */
|
||||
monitor_mask |= DBE_VALUE;
|
||||
/* update last value monitored */
|
||||
pdfanout->mlst = pdfanout->val;
|
||||
}
|
||||
/* check for archive change */
|
||||
delta = pdfanout->alst - pdfanout->val;
|
||||
if(delta<0) delta = -delta;
|
||||
if (delta > pdfanout->adel) {
|
||||
/* post events on value field for archive change */
|
||||
monitor_mask |= DBE_LOG;
|
||||
/* update last archive value monitored */
|
||||
pdfanout->alst = pdfanout->val;
|
||||
}
|
||||
|
||||
/* send out monitors connected to the value field */
|
||||
if (monitor_mask){
|
||||
db_post_events(pdfanout,&pdfanout->val,monitor_mask);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static long writeValue(pdfanout)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
{
|
||||
long status;
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
status=recGblGetLinkValue(&(pdfanout->siml),
|
||||
(void *)pdfanout,DBR_ENUM,&(pdfanout->simm),&options,&nRequest);
|
||||
if (!RTN_SUCCESS(status))
|
||||
return(status);
|
||||
|
||||
if (pdfanout->simm == YES){
|
||||
status=recGblPutLinkValue(&(pdfanout->siol),
|
||||
(void *)pdfanout,DBR_LONG,&(pdfanout->val),&nRequest);
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pdfanout,SOFT_ALARM,INVALID_ALARM);
|
||||
return(status);
|
||||
}
|
||||
recGblSetSevr(pdfanout,SIMM_ALARM,pdfanout->sims);
|
||||
|
||||
return(status);
|
||||
}
|
||||
static long push_values(pdfanout)
|
||||
struct dfanoutRecord *pdfanout;
|
||||
{
|
||||
struct link *plink; /* structure of the link field */
|
||||
long nRequest=1;
|
||||
int i;
|
||||
long status;
|
||||
|
||||
for(i=0, plink=&(pdfanout->outa); i<OUT_ARG_MAX; i++, plink++) {
|
||||
status=recGblPutLinkValue(plink,(void *)pdfanout,DBR_LONG,
|
||||
&(pdfanout->val),&nRequest);
|
||||
if (!RTN_SUCCESS(status)) return(-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recMbbiDirect.c */
|
||||
/* base/src/rec $Id$ */
|
||||
/* share/src/rec @(#)recMbbiDirect.c 1.2 1/4/94 */
|
||||
|
||||
/* recMbbiDirect.c - Record Support routines for mbboDirect records */
|
||||
/*
|
||||
@@ -31,7 +31,7 @@
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* (modifications to mbbi apply, see mbbi record)
|
||||
* 1. 10-20-93 mcn "Created" by borrowing mbbi record code
|
||||
* 1. mcn "Created" by borrowing mbbi record code, and modifying it.
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
@@ -111,8 +111,6 @@ static void refresh_bits(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) {
|
||||
@@ -140,22 +138,38 @@ static long init_record(pmbbiDirect,pass)
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
if (pmbbiDirect->siml.type == CONSTANT) {
|
||||
/* mbbi.siml must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pmbbiDirect->siml.type) {
|
||||
case (CONSTANT) :
|
||||
pmbbiDirect->simm = pmbbiDirect->siml.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbiDirect->siml), (void *) pmbbiDirect, DBR_ENUM, "SIMM");
|
||||
if (status) return(status);
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pmbbiDirect->siml), (void *) pmbbiDirect, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pmbbiDirect,
|
||||
"mbbiDirect: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
if (pmbbiDirect->siol.type == CONSTANT) {
|
||||
/* mbbi.siol must be a CONSTANT or a PV_LINK or a DB_LINK or a CA_LINK*/
|
||||
switch (pmbbiDirect->siol.type) {
|
||||
case (CONSTANT) :
|
||||
pmbbiDirect->sval = pmbbiDirect->siol.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbbiDirect->siol), (void *) pmbbiDirect, DBR_USHORT, "SVAL");
|
||||
|
||||
if (status)
|
||||
return(status);
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pmbbiDirect->siol), (void *) pmbbiDirect, "SVAL");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pmbbiDirect,
|
||||
"mbbiDirect: init_record Illegal SIOL field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
if(!(pdset = (struct mbbidset *)(pmbbiDirect->dset))) {
|
||||
@@ -198,7 +212,7 @@ static long process(pmbbiDirect)
|
||||
if ( !pact && pmbbiDirect->pact ) return(0);
|
||||
pmbbiDirect->pact = TRUE;
|
||||
|
||||
recGblGetTimeStamp(pmbbiDirect);
|
||||
tsLocalTime(&pmbbiDirect->time);
|
||||
|
||||
if(status==0) { /* convert the value */
|
||||
unsigned long rval = pmbbiDirect->rval;
|
||||
@@ -240,6 +254,9 @@ static void monitor(pmbbiDirect)
|
||||
*/
|
||||
|
||||
monitor_mask = recGblResetAlarms(pmbbiDirect);
|
||||
monitor_mask |= (DBE_LOG|DBE_VALUE);
|
||||
if(monitor_mask)
|
||||
db_post_events(pmbbiDirect,pmbbiDirect->val,monitor_mask);
|
||||
|
||||
/* check for value change */
|
||||
if (pmbbiDirect->mlst != pmbbiDirect->val) {
|
||||
@@ -249,10 +266,10 @@ static void monitor(pmbbiDirect)
|
||||
pmbbiDirect->mlst = pmbbiDirect->val;
|
||||
}
|
||||
/* send out monitors connected to the value field */
|
||||
if (monitor_mask) {
|
||||
if (monitor_mask){
|
||||
db_post_events(pmbbiDirect,&pmbbiDirect->val,monitor_mask);
|
||||
}
|
||||
if(pmbbiDirect->oraw != pmbbiDirect->rval) {
|
||||
if(pmbbiDirect->oraw!=pmbbiDirect->rval) {
|
||||
db_post_events(pmbbiDirect,&pmbbiDirect->rval,monitor_mask|DBE_VALUE);
|
||||
pmbbiDirect->oraw = pmbbiDirect->rval;
|
||||
}
|
||||
@@ -264,6 +281,8 @@ static long readValue(pmbbiDirect)
|
||||
{
|
||||
long status;
|
||||
struct mbbidset *pdset = (struct mbbidset *) (pmbbiDirect->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pmbbiDirect->pact == TRUE){
|
||||
status=(*pdset->read_mbbi)(pmbbiDirect);
|
||||
@@ -271,7 +290,8 @@ static long readValue(pmbbiDirect)
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetFastLink(&(pmbbiDirect->siml), (void *)pmbbiDirect, &(pmbbiDirect->simm));
|
||||
status=recGblGetLinkValue(&(pmbbiDirect->siml),
|
||||
(void *)pmbbiDirect,DBR_ENUM,&(pmbbiDirect->simm),&options,&nRequest);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -281,13 +301,14 @@ static long readValue(pmbbiDirect)
|
||||
return(status);
|
||||
}
|
||||
if (pmbbiDirect->simm == YES){
|
||||
status=recGblGetFastLink(&(pmbbiDirect->siol), (void *)pmbbiDirect, &(pmbbiDirect->sval));
|
||||
|
||||
if (status==0) {
|
||||
status=recGblGetLinkValue(&(pmbbiDirect->siol),
|
||||
(void *)pmbbiDirect,DBR_USHORT,&(pmbbiDirect->sval),&options,&nRequest);
|
||||
if (status==0){
|
||||
pmbbiDirect->val=pmbbiDirect->sval;
|
||||
pmbbiDirect->udf=FALSE;
|
||||
refresh_bits(pmbbiDirect);
|
||||
}
|
||||
status=2; /* don't convert */
|
||||
status=2; /* dont convert */
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pmbbiDirect,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* recMbboDirect.c */
|
||||
/* base/src/rec $Id$ */
|
||||
/* share/src/rec @(#)recMbboDirect.c 1.2 1/4/94 */
|
||||
|
||||
/* recMbboDirect.c - Record Support for mbboDirect records */
|
||||
/*
|
||||
@@ -115,39 +115,41 @@ static long init_record(pmbboDirect,pass)
|
||||
|
||||
if (pass==0) return(0);
|
||||
|
||||
if (pmbboDirect->siml.type == CONSTANT) {
|
||||
/* mbbo.siml must be a CONSTANT or a PV_LINK or a DB_LINK */
|
||||
switch (pmbboDirect->siml.type) {
|
||||
case (CONSTANT) :
|
||||
pmbboDirect->simm = pmbboDirect->siml.value.value;
|
||||
}
|
||||
else {
|
||||
status = recGblInitFastInLink(&(pmbboDirect->siml), (void *) pmbboDirect, DBR_ENUM, "SIMM");
|
||||
if (status) return(status);
|
||||
break;
|
||||
case (PV_LINK) :
|
||||
status = dbCaAddInlink(&(pmbboDirect->siml), (void *) pmbboDirect, "SIMM");
|
||||
if(status) return(status);
|
||||
break;
|
||||
case (DB_LINK) :
|
||||
break;
|
||||
default :
|
||||
recGblRecordError(S_db_badField,(void *)pmbboDirect,
|
||||
"mbboDirect: init_record Illegal SIML field");
|
||||
return(S_db_badField);
|
||||
}
|
||||
|
||||
status = recGblInitFastOutLink(&(pmbboDirect->siol), (void *) pmbboDirect, DBR_USHORT, "VAL");
|
||||
if (status)
|
||||
return(status);
|
||||
/* mbbo.siol may be a PV_LINK */
|
||||
if (pmbboDirect->siol.type == PV_LINK){
|
||||
status = dbCaAddOutlink(&(pmbboDirect->siol), (void *) pmbboDirect, "VAL");
|
||||
if(status) return(status);
|
||||
}
|
||||
|
||||
if (!(pdset = (struct mbbodset *)(pmbboDirect->dset))) {
|
||||
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) ) {
|
||||
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) {
|
||||
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++) {
|
||||
@@ -182,14 +184,18 @@ static long process(pmbboDirect)
|
||||
}
|
||||
|
||||
if (!pmbboDirect->pact) {
|
||||
if(pmbboDirect->dol.type != CONSTANT && pmbboDirect->omsl==CLOSED_LOOP) {
|
||||
if(pmbboDirect->dol.type==DB_LINK && pmbboDirect->omsl==CLOSED_LOOP){
|
||||
long options=0;
|
||||
long nRequest=1;
|
||||
long status;
|
||||
unsigned short val;
|
||||
|
||||
status = recGblGetFastLink(&pmbboDirect->dol, (void *)pmbboDirect, &val);
|
||||
pmbboDirect->pact = TRUE;
|
||||
status = dbGetLink(&pmbboDirect->dol.value.db_link,(struct dbCommon *)pmbboDirect,DBR_USHORT,
|
||||
&val,&options,&nRequest);
|
||||
pmbboDirect->pact = FALSE;
|
||||
if(status==0) {
|
||||
pmbboDirect->val = val;
|
||||
pmbboDirect->udf = FALSE;
|
||||
pmbboDirect->val= val;
|
||||
}
|
||||
}
|
||||
/* convert val to rval */
|
||||
@@ -202,7 +208,7 @@ static long process(pmbboDirect)
|
||||
if ( !pact && pmbboDirect->pact ) return(0);
|
||||
pmbboDirect->pact = TRUE;
|
||||
|
||||
recGblGetTimeStamp(pmbboDirect);
|
||||
tsLocalTime(&pmbboDirect->time);
|
||||
/* check event list */
|
||||
monitor(pmbboDirect);
|
||||
/* process the forward scan link record */
|
||||
@@ -240,8 +246,6 @@ static long special(paddr,after)
|
||||
/* zero field */
|
||||
pmbboDirect->val &= ~offset;
|
||||
}
|
||||
|
||||
pmbboDirect->udf = FALSE;
|
||||
|
||||
convert(pmbboDirect);
|
||||
return(0);
|
||||
@@ -250,8 +254,8 @@ static long special(paddr,after)
|
||||
* If OMSL changes from closed_loop to supervisory,
|
||||
* reload value field with B0 - B15
|
||||
*/
|
||||
bit = &(pmbboDirect->b0);
|
||||
if (pmbboDirect->omsl == SUPERVISORY) {
|
||||
bit = &(pmbboDirect->b0);
|
||||
for (i=0; i<NUM_BITS; i++, offset = offset << 1, bit++) {
|
||||
if (*bit)
|
||||
pmbboDirect->val |= offset;
|
||||
@@ -283,9 +287,12 @@ static void monitor(pmbboDirect)
|
||||
unsigned short monitor_mask;
|
||||
|
||||
monitor_mask = recGblResetAlarms(pmbboDirect);
|
||||
monitor_mask |= (DBE_LOG|DBE_VALUE);
|
||||
if(monitor_mask)
|
||||
db_post_events(pmbboDirect,pmbboDirect->val,monitor_mask);
|
||||
|
||||
/* check for value change */
|
||||
if (pmbboDirect->mlst != pmbboDirect->val) {
|
||||
if (pmbboDirect->mlst != pmbboDirect->val){
|
||||
/* post events for value change and archive change */
|
||||
monitor_mask |= (DBE_VALUE | DBE_LOG);
|
||||
/* update last value monitored */
|
||||
@@ -322,13 +329,16 @@ static long writeValue(pmbboDirect)
|
||||
{
|
||||
long status;
|
||||
struct mbbodset *pdset = (struct mbbodset *) (pmbboDirect->dset);
|
||||
long nRequest=1;
|
||||
long options=0;
|
||||
|
||||
if (pmbboDirect->pact == TRUE){
|
||||
status=(*pdset->write_mbbo)(pmbboDirect);
|
||||
return(status);
|
||||
}
|
||||
|
||||
status=recGblGetFastLink(&(pmbboDirect->siml), (void *)pmbboDirect, &(pmbboDirect->simm));
|
||||
status=recGblGetLinkValue(&(pmbboDirect->siml),
|
||||
(void *)pmbboDirect,DBR_ENUM,&(pmbboDirect->simm),&options,&nRequest);
|
||||
if (status)
|
||||
return(status);
|
||||
|
||||
@@ -337,7 +347,8 @@ static long writeValue(pmbboDirect)
|
||||
return(status);
|
||||
}
|
||||
if (pmbboDirect->simm == YES){
|
||||
status=recGblPutFastLink(&(pmbboDirect->siol), (void *)pmbboDirect, &(pmbboDirect->val));
|
||||
status=recGblPutLinkValue(&(pmbboDirect->siol),
|
||||
(void *)pmbboDirect,DBR_USHORT,&(pmbboDirect->val),&nRequest);
|
||||
} else {
|
||||
status=-1;
|
||||
recGblSetSevr(pmbboDirect,SOFT_ALARM,INVALID_ALARM);
|
||||
|
||||
Reference in New Issue
Block a user