diff --git a/src/rec/Makefile b/src/rec/Makefile index 8cca632b9..dbb0378bd 100644 --- a/src/rec/Makefile +++ b/src/rec/Makefile @@ -1,7 +1,97 @@ TOP=../.. -include $(TOP)/config/CONFIG_BASE +include $(TOP)/configure/CONFIG -include $(TOP)/config/RULES_ARCHS + +INC += egDefs.h +INC += erDefs.h +INC += ereventDefs.h + +USER_DBDFLAGS += -I .. -I $(EPICS_BASE)/dbd +RECTYPES += aaiRecord.h +RECTYPES += aaoRecord.h +RECTYPES += aiRecord.h +RECTYPES += aoRecord.h +RECTYPES += biRecord.h +RECTYPES += boRecord.h +RECTYPES += calcRecord.h +RECTYPES += calcoutRecord.h +RECTYPES += compressRecord.h +RECTYPES += dfanoutRecord.h +RECTYPES += egRecord.h +RECTYPES += egeventRecord.h +RECTYPES += erRecord.h +RECTYPES += ereventRecord.h +RECTYPES += eventRecord.h +RECTYPES += fanoutRecord.h +RECTYPES += gsubRecord.h +RECTYPES += histogramRecord.h +RECTYPES += longinRecord.h +RECTYPES += longoutRecord.h +RECTYPES += mbbiRecord.h +RECTYPES += mbbiDirectRecord.h +RECTYPES += mbboRecord.h +RECTYPES += mbboDirectRecord.h +RECTYPES += palRecord.h +RECTYPES += permissiveRecord.h +RECTYPES += pidRecord.h +RECTYPES += pulseCounterRecord.h +RECTYPES += pulseDelayRecord.h +RECTYPES += pulseTrainRecord.h +RECTYPES += selRecord.h +RECTYPES += seqRecord.h +RECTYPES += stateRecord.h +RECTYPES += steppermotorRecord.h +RECTYPES += stringinRecord.h +RECTYPES += stringoutRecord.h +RECTYPES += subRecord.h +RECTYPES += subArrayRecord.h +RECTYPES += timerRecord.h +RECTYPES += waveformRecord.h + +USR_INCLUDES = -I../drv/ansi -I../../drv/old + +IOC_PROD_vxWorks += aaiRecord.o +IOC_PROD_vxWorks += aaoRecord.o +IOC_PROD_vxWorks += aiRecord.o +IOC_PROD_vxWorks += aoRecord.o +IOC_PROD_vxWorks += biRecord.o +IOC_PROD_vxWorks += boRecord.o +IOC_PROD_vxWorks += calcRecord.o +IOC_PROD_vxWorks += calcoutRecord.o +IOC_PROD_vxWorks += compressRecord.o +IOC_PROD_vxWorks += dfanoutRecord.o +IOC_PROD_vxWorks += egRecord.o +IOC_PROD_vxWorks += egeventRecord.o +IOC_PROD_vxWorks += erRecord.o +IOC_PROD_vxWorks += ereventRecord.o +IOC_PROD_vxWorks += eventRecord.o +IOC_PROD_vxWorks += fanoutRecord.o +IOC_PROD_vxWorks += gsubRecord.o +IOC_PROD_vxWorks += histogramRecord.o +IOC_PROD_vxWorks += longinRecord.o +IOC_PROD_vxWorks += longoutRecord.o +IOC_PROD_vxWorks += mbbiRecord.o +IOC_PROD_vxWorks += mbbiDirectRecord.o +IOC_PROD_vxWorks += mbboRecord.o +IOC_PROD_vxWorks += mbboDirectRecord.o +IOC_PROD_vxWorks += palRecord.o +IOC_PROD_vxWorks += permissiveRecord.o +IOC_PROD_vxWorks += pidRecord.o +IOC_PROD_vxWorks += pulseCounterRecord.o +IOC_PROD_vxWorks += pulseDelayRecord.o +IOC_PROD_vxWorks += pulseTrainRecord.o +IOC_PROD_vxWorks += selRecord.o +IOC_PROD_vxWorks += seqRecord.o +IOC_PROD_vxWorks += stateRecord.o +IOC_PROD_vxWorks += steppermotorRecord.o +IOC_PROD_vxWorks += stringinRecord.o +IOC_PROD_vxWorks += stringoutRecord.o +IOC_PROD_vxWorks += subRecord.o +IOC_PROD_vxWorks += subArrayRecord.o +IOC_PROD_vxWorks += timerRecord.o +IOC_PROD_vxWorks += waveformRecord.o + +include $(TOP)/configure/RULES_BUILD diff --git a/src/rec/Makefile.Host b/src/rec/Makefile.Host deleted file mode 100644 index c9788f389..000000000 --- a/src/rec/Makefile.Host +++ /dev/null @@ -1,54 +0,0 @@ -TOP = ../../.. -include $(TOP)/config/CONFIG_BASE - -INC += egDefs.h -INC += erDefs.h -INC += ereventDefs.h -INC += recDynLink.h - -USER_DBDFLAGS += -I .. -I $(EPICS_BASE)/dbd -RECTYPES += aaiRecord.h -RECTYPES += aaoRecord.h -RECTYPES += aiRecord.h -RECTYPES += aoRecord.h -RECTYPES += biRecord.h -RECTYPES += boRecord.h -RECTYPES += calcRecord.h -RECTYPES += calcoutRecord.h -RECTYPES += compressRecord.h -RECTYPES += dfanoutRecord.h -RECTYPES += egRecord.h -RECTYPES += egeventRecord.h -RECTYPES += erRecord.h -RECTYPES += ereventRecord.h -RECTYPES += eventRecord.h -RECTYPES += fanoutRecord.h -RECTYPES += gsubRecord.h -RECTYPES += histogramRecord.h -RECTYPES += longinRecord.h -RECTYPES += longoutRecord.h -RECTYPES += mbbiRecord.h -RECTYPES += mbbiDirectRecord.h -RECTYPES += mbboRecord.h -RECTYPES += mbboDirectRecord.h -RECTYPES += palRecord.h -RECTYPES += permissiveRecord.h -RECTYPES += pidRecord.h -RECTYPES += pulseCounterRecord.h -RECTYPES += pulseDelayRecord.h -RECTYPES += pulseTrainRecord.h -RECTYPES += scanRecord.h -RECTYPES += selRecord.h -RECTYPES += seqRecord.h -RECTYPES += stateRecord.h -RECTYPES += steppermotorRecord.h -RECTYPES += stringinRecord.h -RECTYPES += stringoutRecord.h -RECTYPES += subRecord.h -RECTYPES += subArrayRecord.h -RECTYPES += timerRecord.h -RECTYPES += waitRecord.h -RECTYPES += waveformRecord.h - -include $(TOP)/config/RULES.Host - diff --git a/src/rec/Makefile.Vx b/src/rec/Makefile.Vx deleted file mode 100644 index a6f8fc319..000000000 --- a/src/rec/Makefile.Vx +++ /dev/null @@ -1,62 +0,0 @@ -TOP = ../../.. -include $(TOP)/config/CONFIG_BASE - -USR_INCLUDES = -I../drv/ansi -I../../drv/old - -INC += egDefs.h -INC += erDefs.h -INC += ereventDefs.h -INC += recDynLink.h - -USER_DBDFLAGS += -I .. -I $(EPICS_BASE)/dbd - -SRCS.c += ../aaiRecord.c -SRCS.c += ../aaoRecord.c -SRCS.c += ../aiRecord.c -SRCS.c += ../aoRecord.c -SRCS.c += ../biRecord.c -SRCS.c += ../boRecord.c -SRCS.c += ../calcRecord.c -SRCS.c += ../calcoutRecord.c -SRCS.c += ../compressRecord.c -SRCS.c += ../dfanoutRecord.c -SRCS.c += ../egRecord.c -SRCS.c += ../egeventRecord.c -SRCS.c += ../erRecord.c -SRCS.c += ../ereventRecord.c -SRCS.c += ../eventRecord.c -SRCS.c += ../fanoutRecord.c -SRCS.c += ../gsubRecord.c -SRCS.c += ../histogramRecord.c -SRCS.c += ../longinRecord.c -SRCS.c += ../longoutRecord.c -SRCS.c += ../mbbiRecord.c -SRCS.c += ../mbbiDirectRecord.c -SRCS.c += ../mbboRecord.c -SRCS.c += ../mbboDirectRecord.c -SRCS.c += ../palRecord.c -SRCS.c += ../permissiveRecord.c -SRCS.c += ../pidRecord.c -SRCS.c += ../pulseCounterRecord.c -SRCS.c += ../pulseDelayRecord.c -SRCS.c += ../pulseTrainRecord.c -SRCS.c += ../scanRecord.c -SRCS.c += ../selRecord.c -SRCS.c += ../seqRecord.c -SRCS.c += ../stateRecord.c -SRCS.c += ../steppermotorRecord.c -SRCS.c += ../stringinRecord.c -SRCS.c += ../stringoutRecord.c -SRCS.c += ../subRecord.c -SRCS.c += ../subArrayRecord.c -SRCS.c += ../timerRecord.c -SRCS.c += ../waitRecord.c -SRCS.c += ../recWaitCa.c -SRCS.c += ../recDynLink.c -SRCS.c += ../recDynLinkTest.c -SRCS.c += ../waveformRecord.c - -PROD = $(SRCS.c:../%.c=%.o) - -include $(TOP)/config/RULES.Vx - diff --git a/src/rec/aaiRecord.c b/src/rec/aaiRecord.c index 142531366..0cddeb91e 100644 --- a/src/rec/aaiRecord.c +++ b/src/rec/aaiRecord.c @@ -38,11 +38,10 @@ * ----------------- */ -#include -#include -#include -#include +#include #include +#include +#include #include #include "dbDefs.h" diff --git a/src/rec/aaoRecord.c b/src/rec/aaoRecord.c index cd22cf05d..605e7d306 100644 --- a/src/rec/aaoRecord.c +++ b/src/rec/aaoRecord.c @@ -38,24 +38,24 @@ * ----------------- */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbFldTypes.h" +#include "dbScan.h" +#include "dbEvent.h" +#include "devSup.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "aaoRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/aiRecord.c b/src/rec/aiRecord.c index 609c13e2e..1c88f3fe2 100644 --- a/src/rec/aiRecord.c +++ b/src/rec/aiRecord.c @@ -72,10 +72,10 @@ * .33 03-29-94 mcn converted to fast links */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include "dbDefs.h" diff --git a/src/rec/aoRecord.c b/src/rec/aoRecord.c index 2d0149765..32f6970cc 100644 --- a/src/rec/aoRecord.c +++ b/src/rec/aoRecord.c @@ -70,12 +70,11 @@ * out of fetch_value. */ -#include #include #include +#include #include #include -#include #include "dbDefs.h" #include "epicsPrint.h" diff --git a/src/rec/biRecord.c b/src/rec/biRecord.c index cb5d80498..9d374d747 100644 --- a/src/rec/biRecord.c +++ b/src/rec/biRecord.c @@ -56,24 +56,24 @@ * .22 03-29-94 mcn Converted to Fast Links */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbFldTypes.h" +#include "dbEvent.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "biRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/boRecord.c b/src/rec/boRecord.c index 443c02901..7c2a36368 100644 --- a/src/rec/boRecord.c +++ b/src/rec/boRecord.c @@ -67,29 +67,29 @@ * .31 04-05-94 mrk ANSI changes to callback routines */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" +#include "osiWatchdog.h" +#include "osiClock.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "callback.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "boRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "menuIvoa.h" /* Create RSET - Record Support Entry Table*/ #define report NULL @@ -144,7 +144,7 @@ struct bodset { /* binary output dset */ struct callback { CALLBACK callback; struct dbCommon *precord; - WDOG_ID wd_id; + watchdogId wd_id; }; static void alarm(); @@ -162,13 +162,14 @@ static void myCallback(pcallback) dbScanLock((struct dbCommon *)pbo); if(pbo->pact) { - wait_time = (int)((pbo->high) * vxTicksPerSecond);/* seconds to ticks */ + wait_time = (int)(pbo->high * clockGetRate()); if (pbo->val==1 && wait_time>0) { struct callback *pcallback; pcallback = (struct callback *)(pbo->rpvt); - if(pcallback->wd_id==NULL) pcallback->wd_id = wdCreate(); + if(pcallback->wd_id==NULL) pcallback->wd_id = watchdogCreate(); callbackSetPriority(pbo->prio, &pcallback->callback); - wdStart(pcallback->wd_id, wait_time, (FUNCPTR)callbackRequest, (int)pcallback); + watchdogStart(pcallback->wd_id, wait_time, + (WATCHDOGFUNC)callbackRequest, (void *)pcallback); } } else { pbo->val = 0; @@ -303,13 +304,14 @@ static long process(pbo) pbo->pact = TRUE; recGblGetTimeStamp(pbo); - wait_time = (int)((pbo->high) * vxTicksPerSecond); /* seconds to ticks */ + wait_time = (int)(pbo->high * clockGetRate()); if (pbo->val==1 && wait_time>0) { struct callback *pcallback; pcallback = (struct callback *)(pbo->rpvt); - if(pcallback->wd_id==NULL) pcallback->wd_id = wdCreate(); + if(pcallback->wd_id==0) pcallback->wd_id = watchdogCreate(); callbackSetPriority(pbo->prio, &pcallback->callback); - wdStart(pcallback->wd_id, wait_time, (FUNCPTR)callbackRequest, (int)pcallback); + watchdogStart(pcallback->wd_id, wait_time, + (WATCHDOGFUNC)callbackRequest, (void *)pcallback); } /* check event list */ monitor(pbo); diff --git a/src/rec/calcRecord.c b/src/rec/calcRecord.c index 8ac3ea765..0d97ce096 100644 --- a/src/rec/calcRecord.c +++ b/src/rec/calcRecord.c @@ -72,10 +72,10 @@ * .30 05-24-94 jba Added recGblRecordError messages for postfix status */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include "dbDefs.h" diff --git a/src/rec/calcoutRecord.c b/src/rec/calcoutRecord.c index ad076d750..8d00193e3 100644 --- a/src/rec/calcoutRecord.c +++ b/src/rec/calcoutRecord.c @@ -41,33 +41,31 @@ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include - -#include "alarm.h" -#include "dbDefs.h" -#include "dbAccess.h" -#include "dbEvent.h" -#include "dbScan.h" -#include "errMdef.h" -#include "recSup.h" -#include "special.h" -#include "callback.h" -#include "taskwd.h" -#include "postfix.h" +#include "alarm.h" +#include "osiWatchdog.h" +#include "osiClock.h" +#include "dbDefs.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbScan.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" +#include "callback.h" +#include "taskwd.h" +#include "postfix.h" #define GEN_SIZE_OFFSET -#include "calcoutRecord.h" +#include "calcoutRecord.h" #undef GEN_SIZE_OFFSET -#include "menuIvoa.h" +#include "menuIvoa.h" /* Create RSET - Record Support Entry Table*/ #define report NULL @@ -128,9 +126,9 @@ struct rset calcoutRSET={ struct rpvtStruct { CALLBACK doOutCb; - WDOG_ID wd_id_0; + watchdogId wd_id_0; CALLBACK checkLinkCb; - WDOG_ID wd_id_1; + watchdogId wd_id_1; short wd_id_1_LOCK; short caLinkStat; /* NO_CA_LINKS,CA_LINKS_ALL_OK,CA_LINKS_NOT_OK */ }; @@ -210,16 +208,16 @@ static long init_record(pcalc,pass) callbackSetCallback(checkLinksCallback, &prpvt->checkLinkCb); callbackSetPriority(0, &prpvt->checkLinkCb); callbackSetUser(pcalc, &prpvt->checkLinkCb); - prpvt->wd_id_0 = wdCreate(); - prpvt->wd_id_1 = wdCreate(); + prpvt->wd_id_0 = watchdogCreate(); + prpvt->wd_id_1 = watchdogCreate(); prpvt->wd_id_1_LOCK = 0; /* Can't do this. Sometimes initialization is not done after 1 second and then dbScanLock will complain !!! if(prpvt->caLinkStat == CA_LINKS_NOT_OK) { - wdStart(prpvt->wd_id_1, 60, (FUNCPTR)callbackRequest, - (int)(&prpvt->checkLinkCb)); + watchdogStart(prpvt->wd_id_1, clockGetRate(), (WATCHDOGFUNC)callbackRequest, + (void *)(&prpvt->checkLinkCb)); prpvt->wd_id_1_LOCK = 1; } */ @@ -291,10 +289,11 @@ static long process(pcalc) if(pcalc->odly > 0.0) { pcalc->dlya = 1; db_post_events(pcalc,&pcalc->dlya,DBE_VALUE); - wdDelay = pcalc->odly * sysClkRateGet(); + wdDelay = (int)(pcalc->odly * clockGetRate()); callbackSetPriority(pcalc->prio, &prpvt->doOutCb); - wdStart(prpvt->wd_id_0, wdDelay, (FUNCPTR)callbackRequest, - (int)(&prpvt->doOutCb)); + watchdogStart(prpvt->wd_id_0, wdDelay, + (WATCHDOGFUNC)callbackRequest, + (void *)(&prpvt->doOutCb)); } else { execOutput(pcalc); @@ -397,8 +396,8 @@ static long special(paddr,after) *plinkValid = calcoutINAV_EXT_NC; /* DO_CALLBACK, if not already scheduled */ if(!prpvt->wd_id_1_LOCK) { - wdStart(prpvt->wd_id_1, 30, (FUNCPTR)callbackRequest, - (int)(&prpvt->checkLinkCb)); + watchdogStart(prpvt->wd_id_1, clockGetRate()/2, (WATCHDOGFUNC)callbackRequest, + (void *)(&prpvt->checkLinkCb)); prpvt->wd_id_1_LOCK = 1; prpvt->caLinkStat = CA_LINKS_NOT_OK; } @@ -770,8 +769,8 @@ static void checkLinks(pcalc) if(!prpvt->wd_id_1_LOCK && caLinkNc) { /* Schedule another CALLBACK */ prpvt->wd_id_1_LOCK = 1; - wdStart(prpvt->wd_id_1, 30, (FUNCPTR)callbackRequest, - (int)(&prpvt->checkLinkCb)); + watchdogStart(prpvt->wd_id_1, clockGetRate()/2, (WATCHDOGFUNC)callbackRequest, + (void *)(&prpvt->checkLinkCb)); } } diff --git a/src/rec/choiceWait.h b/src/rec/choiceWait.h deleted file mode 100644 index aee992c44..000000000 --- a/src/rec/choiceWait.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Author: Ned Arnold - * Date: 4-28-94 - * - * 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 mm-dd-yy iii Comment - */ - -#ifndef INC_WAITchoice_h -#define INC_WAITchoice 1 - -#define REC_WAIT_OUT_OPT 0 -#define REC_WAIT_OUT_OPT_EVERY 0 -#define REC_WAIT_OUT_OPT_CHANGE 1 -#define REC_WAIT_OUT_OPT_WHEN_ZERO 2 -#define REC_WAIT_OUT_OPT_WHEN_NZERO 3 -#define REC_WAIT_OUT_OPT_CHG_TO_ZERO 4 -#define REC_WAIT_OUT_OPT_CHG_TO_NZERO 5 - -#define REC_WAIT_DATA_OPT 1 -#define REC_WAIT_DATA_OPT_VAL 0 -#define REC_WAIT_DATA_OPT_DOL 1 - -#define REC_WAIT_INPP 2 -#define REC_WAIT_INPP_NPROC 0 -#define REC_WAIT_INPP_PROC 1 - -#define REC_WAIT_DYNL 3 -#define REC_WAIT_DYNL_OK 0 -#define REC_WAIT_DYNL_NC 1 -#define REC_WAIT_DYNL_NO_PV 2 - -/* DON'T CHANGE THESE DEFINITIONS !!!! */ -/* Indexes used to process dynamic links */ -/* Must start above 103, because SPC_CALC = 103 */ -#define REC_WAIT_A 110 -#define REC_WAIT_B 111 -#define REC_WAIT_C 112 -#define REC_WAIT_D 113 -#define REC_WAIT_E 114 -#define REC_WAIT_F 115 -#define REC_WAIT_G 116 -#define REC_WAIT_H 117 -#define REC_WAIT_I 118 -#define REC_WAIT_J 119 -#define REC_WAIT_K 120 -#define REC_WAIT_L 121 -#define REC_WAIT_O 122 -#define REC_WAIT_P 123 - -#endif diff --git a/src/rec/compressRecord.c b/src/rec/compressRecord.c index 135439357..eb0502804 100644 --- a/src/rec/compressRecord.c +++ b/src/rec/compressRecord.c @@ -59,26 +59,25 @@ * implemented) */ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbStaticLib.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "special.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "compressRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/dfanoutRecord.c b/src/rec/dfanoutRecord.c index 4fe26f47e..b6043cfcc 100644 --- a/src/rec/dfanoutRecord.c +++ b/src/rec/dfanoutRecord.c @@ -12,25 +12,24 @@ * .02 May 10, 96 jt Bug Fix */ - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include"dbAccess.h" +#include"dbEvent.h" +#include"dbFldTypes.h" +#include"devSup.h" +#include"errMdef.h" +#include"recSup.h" +#include"special.h" #define GEN_SIZE_OFFSET -#include +#include"dfanoutRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/egRecord.c b/src/rec/egRecord.c index 0478c311e..1d6dc9887 100644 --- a/src/rec/egRecord.c +++ b/src/rec/egRecord.c @@ -54,26 +54,27 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). * */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include"alarm.h" +#include"dbAccess.h" +#include"dbEvent.h" +#include"dbFldTypes.h" +#include"devSup.h" +#include"errMdef.h" +#include"recSup.h" +#include"module_types.h" #define GEN_SIZE_OFFSET -#include +#include"egRecord.h" #undef GEN_SIZE_OFFSET -#include +#include"egDefs.h" #define STATIC static diff --git a/src/rec/egeventRecord.c b/src/rec/egeventRecord.c index 73e560b31..b6e234283 100644 --- a/src/rec/egeventRecord.c +++ b/src/rec/egeventRecord.c @@ -53,26 +53,27 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). * */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" -#include +#include "egRecord.h" #define GEN_SIZE_OFFSET -#include +#include "egeventRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "egDefs.h" #define STATIC static diff --git a/src/rec/erRecord.c b/src/rec/erRecord.c index e33377242..8fbf1a2d0 100644 --- a/src/rec/erRecord.c +++ b/src/rec/erRecord.c @@ -53,25 +53,26 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). * Date: 9/27/93 */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "module_types.h" +#include "erDefs.h" #define GEN_SIZE_OFFSET -#include +#include "erRecord.h" #undef GEN_SIZE_OFFSET #define STATIC static diff --git a/src/rec/ereventRecord.c b/src/rec/ereventRecord.c index 4cc0ff4a0..02691d056 100644 --- a/src/rec/ereventRecord.c +++ b/src/rec/ereventRecord.c @@ -53,24 +53,25 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). * Date: 8/27/93 */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" -#include +#include "ereventDefs.h" #define GEN_SIZE_OFFSET -#include +#include "ereventRecord.h" #undef GEN_SIZE_OFFSET #define STATIC static diff --git a/src/rec/eventRecord.c b/src/rec/eventRecord.c index da91ed1fc..55230a47c 100644 --- a/src/rec/eventRecord.c +++ b/src/rec/eventRecord.c @@ -38,23 +38,24 @@ * .06 03-29-94 mcn converted to fast links */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include"alarm.h" +#include"dbAccess.h" +#include"dbEvent.h" +#include"dbScan.h" +#include"dbFldTypes.h" +#include"devSup.h" +#include"errMdef.h" +#include"recSup.h" #define GEN_SIZE_OFFSET -#include +#include"eventRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/fanoutRecord.c b/src/rec/fanoutRecord.c index da7f6c4fe..3f24596a5 100644 --- a/src/rec/fanoutRecord.c +++ b/src/rec/fanoutRecord.c @@ -47,23 +47,24 @@ * .17 03-29-94 mcn converted to fast links */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "fanoutRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "dbCommon.h" /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/gsubRecord.c b/src/rec/gsubRecord.c index f5b4486c3..0132a6636 100644 --- a/src/rec/gsubRecord.c +++ b/src/rec/gsubRecord.c @@ -34,25 +34,23 @@ * currently does not support callback. */ -#include -#include -#include -#include -#include -#include -#include /* for sysSymTbl*/ -#include /* for N_TEXT */ +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include +#include "registry.h" +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "gsubRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ @@ -106,10 +104,7 @@ static long init_record(psub,pass) int pass; { FUNCPTR psubroutine; - char sub_type; - char temp[40]; int status; - STATUS ret; struct link *plink; int i; float *pvalue; @@ -125,13 +120,8 @@ static long init_record(psub,pass) } /* convert the initialization subroutine name */ - temp[0] = 0; /* all global variables start with _ */ - if (psub->inam[0] != '_'){ - strcpy(temp,"_"); - } - strcat(temp,psub->inam); - ret = symFindByNameEPICS(sysSymTbl,temp,(void *)&psub->sadr,(void *)&sub_type); - if ((ret !=OK) || ((sub_type & N_TEXT) == 0)){ + psub->sadr = registryFind(0,psub->inam); + if(psub->sadr==0) { recGblRecordError(S_db_BadSub,(void *)psub,"recGsub(init_record)"); return(S_db_BadSub); } @@ -139,21 +129,16 @@ static long init_record(psub,pass) /* invoke the initialization subroutine */ psubroutine = (FUNCPTR)(psub->sadr); status = psubroutine(pcallbackdummy, pcallbackdummy, - &(psub->a),&(psub->b),&(psub->c),&(psub->d),&(psub->e), &(psub->f),&(psub->val)); + &(psub->a),&(psub->b),&(psub->c),&(psub->d),&(psub->e), + &(psub->f),&(psub->val)); /* convert the subroutine name to an address and type */ /* convert the processing subroutine name */ - temp[0] = 0; /* all global variables start with _ */ - if (psub->snam[0] != '_'){ - strcpy(temp,"_"); - } - strcat(temp,psub->snam); - ret = symFindByNameEPICS(sysSymTbl,temp,(void *)&psub->sadr,(void *)&sub_type); - if ((ret < 0) || ((sub_type & N_TEXT) == 0)){ + psub->sadr = registryFind(0,psub->snam); + if(psub->sadr==0) { recGblRecordError(S_db_BadSub,(void *)psub,"recGsub(init_record)"); return(S_db_BadSub); } - psub->styp = sub_type; return(0); } diff --git a/src/rec/gsubRecord.dbd b/src/rec/gsubRecord.dbd index f9056bf5f..784960cb4 100644 --- a/src/rec/gsubRecord.dbd +++ b/src/rec/gsubRecord.dbd @@ -25,11 +25,6 @@ recordtype(gsub) { interest(4) extra("void * sadr") } - field(STYP,DBF_SHORT) { - prompt("Subr symbol type") - special(SPC_NOMOD) - interest(3) - } field(INPA,DBF_INLINK) { prompt("Input A") promptgroup(GUI_INPUTS) diff --git a/src/rec/histogramRecord.c b/src/rec/histogramRecord.c index 94727a439..f4949a5b9 100644 --- a/src/rec/histogramRecord.c +++ b/src/rec/histogramRecord.c @@ -40,30 +40,30 @@ * .09 01-24-94 mcn Converted to Fast Links */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "osiWatchdog.h" +#include "osiClock.h" +#include "alarm.h" +#include "callback.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "epicsPrint.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "special.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "histogramRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ @@ -121,7 +121,7 @@ struct callback { void (*callback)(); int priority; struct dbAddr dbAddr; - WDOG_ID wd_id; + watchdogId wd_id; }; /* @@ -137,8 +137,6 @@ static void wdogCallback(pcallback) struct callback *pcallback; { struct histogramRecord *phistogram=(struct histogramRecord *)(pcallback->dbAddr.precord); - float wait_time; - /* force post events for any count change */ if(phistogram->mcnt>0){ dbScanLock((struct dbCommon *)phistogram); @@ -150,8 +148,9 @@ static void wdogCallback(pcallback) if(phistogram->sdel>0) { /* start new watchdog timer on monitor */ - wait_time = (float)(phistogram->sdel * vxTicksPerSecond); - wdStart(pcallback->wd_id,wait_time,(FUNCPTR)callbackRequest,(int)pcallback); + watchdogStart(pcallback->wd_id, + (int)(phistogram->sdel *clockGetRate()), + (WATCHDOGFUNC)callbackRequest,(void *)pcallback); } return; @@ -160,7 +159,6 @@ static long wdogInit(phistogram) struct histogramRecord *phistogram; { struct callback *pcallback; - float wait_time; if(phistogram->wdog==NULL && phistogram->sdel>0) { /* initialize a watchdog timer */ @@ -169,7 +167,7 @@ static long wdogInit(phistogram) if(!pcallback) return -1; pcallback->callback = wdogCallback; pcallback->priority = priorityLow; - pcallback->wd_id = wdCreate(); + pcallback->wd_id = watchdogCreate(); dbNameToAddr(phistogram->name,&(pcallback->dbAddr)); } @@ -177,12 +175,13 @@ static long wdogInit(phistogram) pcallback = (struct callback *)phistogram->wdog; if(!pcallback) return -1; - wdCancel(pcallback->wd_id); + watchdogCancel(pcallback->wd_id); if( phistogram->sdel>0) { /* start new watchdog timer on monitor */ - wait_time = (float)(phistogram->sdel * vxTicksPerSecond); - wdStart(pcallback->wd_id,wait_time,(FUNCPTR)callbackRequest,(int)pcallback); + watchdogStart(pcallback->wd_id, + (int)(phistogram->sdel * clockGetRate()), + (WATCHDOGFUNC)callbackRequest,(void *)pcallback); } return 0; } diff --git a/src/rec/longinRecord.c b/src/rec/longinRecord.c index 47f19137d..c71727721 100644 --- a/src/rec/longinRecord.c +++ b/src/rec/longinRecord.c @@ -44,24 +44,23 @@ * .13 03-29-94 mcn Converted to Fast Links */ - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "longinRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/longoutRecord.c b/src/rec/longoutRecord.c index 8af4ad347..8b4cacea1 100644 --- a/src/rec/longoutRecord.c +++ b/src/rec/longoutRecord.c @@ -43,25 +43,25 @@ * .14 09-18-92 jba pact now set in recGblGetLinkValue * .15 03-29-94 mcn converted to fast links */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "longoutRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "menuIvoa.h" /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/mbbiDirectRecord.c b/src/rec/mbbiDirectRecord.c index 8bfb909d6..beb61ca91 100644 --- a/src/rec/mbbiDirectRecord.c +++ b/src/rec/mbbiDirectRecord.c @@ -34,24 +34,24 @@ * 2. jt May 20,96 Bug Fix */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "mbbiDirectRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/mbbiRecord.c b/src/rec/mbbiRecord.c index 95bed7cd4..da8d8f35a 100644 --- a/src/rec/mbbiRecord.c +++ b/src/rec/mbbiRecord.c @@ -55,24 +55,24 @@ * .22 03-29-94 mcn converted to fast links. */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "mbbiRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/mbboDirectRecord.c b/src/rec/mbboDirectRecord.c index 482ec73da..38aabd131 100644 --- a/src/rec/mbboDirectRecord.c +++ b/src/rec/mbboDirectRecord.c @@ -34,24 +34,24 @@ * 1. mcn "Created" by borrowing mbbo record code, and modifying it. */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "mbboDirectRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/mbboRecord.c b/src/rec/mbboRecord.c index 1d633bae7..04dca5089 100644 --- a/src/rec/mbboRecord.c +++ b/src/rec/mbboRecord.c @@ -61,26 +61,26 @@ * .26 03-29-94 mcn Converted to Fast Links */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "mbboRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "menuIvoa.h" /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/palRecord.c b/src/rec/palRecord.c index ad7f23460..f5e40dafb 100644 --- a/src/rec/palRecord.c +++ b/src/rec/palRecord.c @@ -32,24 +32,24 @@ * .01 04-19-94 mcn R3.12ified */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" +#include "pal.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "palRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/permissiveRecord.c b/src/rec/permissiveRecord.c index 1b3916c43..70a1366c4 100644 --- a/src/rec/permissiveRecord.c +++ b/src/rec/permissiveRecord.c @@ -37,20 +37,21 @@ * .05 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "permissiveRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/pidRecord.c b/src/rec/pidRecord.c index e4a7e8db7..4b7eaeda4 100644 --- a/src/rec/pidRecord.c +++ b/src/rec/pidRecord.c @@ -44,24 +44,23 @@ * .12 03-29-94 mcn Converted to fast links */ -#include -#include -#include -#include -#include -/*since tickLib is not defined just define tickGet*/ -unsigned long tickGet(); +#include +#include +#include +#include +#include #include "dbDefs.h" +#include "osiClock.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "pidRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ @@ -374,7 +373,7 @@ struct pidRecord *ppid; /* compute time difference and make sure it is large enough*/ ctp = ppid->ct; - ct = tickGet(); + ct = clockGetCurrentTick(); if(ctp==0) {/*this happens the first time*/ dt=0.0; } else { @@ -384,7 +383,7 @@ struct pidRecord *ppid; dt = (unsigned long)(0xffffffff) - ctp; dt = dt + ct + 1; } - dt = dt/vxTicksPerSecond; + dt = dt/clockGetRate(); if(dtmdt) return(1); } /* get the rest of values needed */ diff --git a/src/rec/pulseCounterRecord.c b/src/rec/pulseCounterRecord.c index 93b26d155..4a306b93a 100644 --- a/src/rec/pulseCounterRecord.c +++ b/src/rec/pulseCounterRecord.c @@ -38,24 +38,24 @@ * .07 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "callback.h" #define GEN_SIZE_OFFSET -#include +#include "pulseCounterRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/pulseDelayRecord.c b/src/rec/pulseDelayRecord.c index 4a2ac4398..523139261 100644 --- a/src/rec/pulseDelayRecord.c +++ b/src/rec/pulseDelayRecord.c @@ -41,7 +41,7 @@ * .10 10-20-92 jbk added get_enum funcs, allowed defaults in fields */ -#include +#include #include #include #include diff --git a/src/rec/pulseTrainRecord.c b/src/rec/pulseTrainRecord.c index 8d8dbf65b..45e8bcb87 100644 --- a/src/rec/pulseTrainRecord.c +++ b/src/rec/pulseTrainRecord.c @@ -44,22 +44,23 @@ * .13 10-18-92 jba pact now set in recGblGetLinkValue */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "pulseTrainRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/recDynLink.c b/src/rec/recDynLink.c deleted file mode 100644 index 2ec2055f3..000000000 --- a/src/rec/recDynLink.c +++ /dev/null @@ -1,538 +0,0 @@ -/*recDynLink.c*/ -/***************************************************************** - COPYRIGHT NOTIFICATION -***************************************************************** - -(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO - -This software was developed under a United States Government license -described on the COPYRIGHT_UniversityOfChicago file included as part -of this distribution. -**********************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/*Definitions to map between old and new database access*/ -/*because we are using CA must include db_access.h*/ -/* new field types */ -#define newDBF_STRING 0 -#define newDBF_CHAR 1 -#define newDBF_UCHAR 2 -#define newDBF_SHORT 3 -#define newDBF_USHORT 4 -#define newDBF_LONG 5 -#define newDBF_ULONG 6 -#define newDBF_FLOAT 7 -#define newDBF_DOUBLE 8 -#define newDBF_ENUM 9 - -/* new data request buffer types */ -#define newDBR_STRING newDBF_STRING -#define newDBR_CHAR newDBF_CHAR -#define newDBR_UCHAR newDBF_UCHAR -#define newDBR_SHORT newDBF_SHORT -#define newDBR_USHORT newDBF_USHORT -#define newDBR_LONG newDBF_LONG -#define newDBR_ULONG newDBF_ULONG -#define newDBR_FLOAT newDBF_FLOAT -#define newDBR_DOUBLE newDBF_DOUBLE -#define newDBR_ENUM newDBF_ENUM -#define VALID_newDB_REQ(x) ((x >= 0) && (x <= newDBR_ENUM)) -static short mapNewToOld[newDBR_ENUM+1] = { - DBF_STRING,DBF_CHAR,DBF_CHAR,DBF_SHORT,DBF_SHORT, - DBF_LONG,DBF_LONG,DBF_FLOAT,DBF_DOUBLE,DBF_ENUM}; - -extern int interruptAccept; - -int recDynLinkQsize = 256; - -LOCAL int inpTaskId=0; -LOCAL int outTaskId=0; -LOCAL RING_ID inpRingQ; -LOCAL RING_ID outRingQ; -LOCAL SEM_ID wakeUpSem; - -typedef enum{cmdSearch,cmdClear,cmdPut} cmdType; -typedef enum{ioInput,ioOutput}ioType; -typedef enum{stateStarting,stateSearching,stateGetting,stateConnected}stateType; - -typedef struct dynLinkPvt{ - FAST_LOCK lock; - char *pvname; - chid chid; - evid evid; - recDynCallback searchCallback; - recDynCallback monitorCallback; - TS_STAMP timestamp; - short status; - short severity; - void *pbuffer; - size_t nRequest; - short dbrType; - double graphicLow,graphHigh; - double controlLow,controlHigh; - char units[MAX_UNITS_SIZE]; - short precision; - ioType io; - stateType state; - short scalar; -} dynLinkPvt; - -/*For cmdClear data is chid. For all other commands precDynLink*/ -typedef struct { - union { - recDynLink *precDynLink; - dynLinkPvt *pdynLinkPvt; - }data; - cmdType cmd; -}ringBufCmd; - -LOCAL void recDynLinkStartInput(void); -LOCAL void recDynLinkStartOutput(void); -LOCAL void connectCallback(struct connection_handler_args cha); -LOCAL void getCallback(struct event_handler_args eha); -LOCAL void monitorCallback(struct event_handler_args eha); -LOCAL void recDynLinkInp(void); -LOCAL void recDynLinkOut(void); - -long recDynLinkAddInput(recDynLink *precDynLink,char *pvname, - short dbrType,int options, - recDynCallback searchCallback,recDynCallback monitorCallback) -{ - dynLinkPvt *pdynLinkPvt; - struct dbAddr dbaddr; - ringBufCmd cmd; - - - if(options&rdlDBONLY && db_name_to_addr(pvname,&dbaddr))return(-1); - if(!inpTaskId) recDynLinkStartInput(); - if(precDynLink->pdynLinkPvt) recDynLinkClear(precDynLink); - pdynLinkPvt = (dynLinkPvt *)calloc(1,sizeof(dynLinkPvt)); - if(!pdynLinkPvt) { - printf("recDynLinkAddInput can't allocate storage"); - taskSuspend(0); - } - FASTLOCKINIT(&pdynLinkPvt->lock); - precDynLink->pdynLinkPvt = pdynLinkPvt; - pdynLinkPvt->pvname = pvname; - pdynLinkPvt->dbrType = dbrType; - pdynLinkPvt->searchCallback = searchCallback; - pdynLinkPvt->monitorCallback = monitorCallback; - pdynLinkPvt->io = ioInput; - pdynLinkPvt->scalar = (options&rdlSCALAR) ? TRUE : FALSE; - pdynLinkPvt->state = stateStarting; - cmd.data.precDynLink = precDynLink; - cmd.cmd = cmdSearch; - if(rngBufPut(inpRingQ,(void *)&cmd,sizeof(cmd)) != sizeof(cmd)) - errMessage(0,"recDynLinkAddInput: rngBufPut error"); - return(0); -} - -long recDynLinkAddOutput(recDynLink *precDynLink,char *pvname, - short dbrType,int options, - recDynCallback searchCallback) -{ - dynLinkPvt *pdynLinkPvt; - struct dbAddr dbaddr; - ringBufCmd cmd; - - - if(options&rdlDBONLY && db_name_to_addr(pvname,&dbaddr))return(-1); - if(!outTaskId) recDynLinkStartOutput(); - if(precDynLink->pdynLinkPvt) recDynLinkClear(precDynLink); - pdynLinkPvt = (dynLinkPvt *)calloc(1,sizeof(dynLinkPvt)); - if(!pdynLinkPvt) { - printf("recDynLinkAddOutput can't allocate storage"); - taskSuspend(0); - } - FASTLOCKINIT(&pdynLinkPvt->lock); - precDynLink->pdynLinkPvt = pdynLinkPvt; - pdynLinkPvt->pvname = pvname; - pdynLinkPvt->dbrType = dbrType; - pdynLinkPvt->searchCallback = searchCallback; - pdynLinkPvt->io = ioOutput; - pdynLinkPvt->scalar = (options&rdlSCALAR) ? TRUE : FALSE; - pdynLinkPvt->state = stateStarting; - cmd.data.precDynLink = precDynLink; - cmd.cmd = cmdSearch; - if(rngBufPut(outRingQ,(void *)&cmd,sizeof(cmd)) != sizeof(cmd)) - errMessage(0,"recDynLinkAddInput: rngBufPut error"); - semGive(wakeUpSem); - return(0); -} - -long recDynLinkClear(recDynLink *precDynLink) -{ - dynLinkPvt *pdynLinkPvt; - ringBufCmd cmd; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(!pdynLinkPvt) { - printf("recDynLinkClear. recDynLinkSearch was never called\n"); - taskSuspend(0); - } - if(pdynLinkPvt->chid) ca_puser(pdynLinkPvt->chid) = NULL; - cmd.data.pdynLinkPvt = pdynLinkPvt; - cmd.cmd = cmdClear; - if(pdynLinkPvt->io==ioInput) { - if(rngBufPut(inpRingQ,(void *)&cmd,sizeof(cmd)) != sizeof(cmd)) - errMessage(0,"recDynLinkClear: rngBufPut error"); - } else { - if(rngBufPut(outRingQ,(void *)&cmd,sizeof(cmd)) != sizeof(cmd)) - errMessage(0,"recDynLinkClear: rngBufPut error"); - } - precDynLink->pdynLinkPvt = NULL; - return(0); -} - -long recDynLinkConnectionStatus(recDynLink *precDynLink) -{ - dynLinkPvt *pdynLinkPvt; - long status; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - status = (ca_state(pdynLinkPvt->chid)==cs_conn) ? 0 : -1; - return(status); -} - -long recDynLinkGetNelem(recDynLink *precDynLink,size_t *nelem) -{ - dynLinkPvt *pdynLinkPvt; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(ca_state(pdynLinkPvt->chid)!=cs_conn) return(-1); - *nelem = ca_element_count(pdynLinkPvt->chid); - return(0); -} - -long recDynLinkGetControlLimits(recDynLink *precDynLink, - double *low,double *high) -{ - dynLinkPvt *pdynLinkPvt; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(pdynLinkPvt->state!=stateConnected) return(-1); - if(low) *low = pdynLinkPvt->controlLow; - if(high) *high = pdynLinkPvt->controlHigh; - return(0); -} - -long recDynLinkGetGraphicLimits(recDynLink *precDynLink, - double *low,double *high) -{ - dynLinkPvt *pdynLinkPvt; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(pdynLinkPvt->state!=stateConnected) return(-1); - if(low) *low = pdynLinkPvt->graphicLow; - if(high) *high = pdynLinkPvt->graphHigh; - return(0); -} - -long recDynLinkGetPrecision(recDynLink *precDynLink,int *prec) -{ - dynLinkPvt *pdynLinkPvt; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(pdynLinkPvt->state!=stateConnected) return(-1); - if(prec) *prec = pdynLinkPvt->precision; - return(0); -} - -long recDynLinkGetUnits(recDynLink *precDynLink,char *units,int maxlen) -{ - dynLinkPvt *pdynLinkPvt; - int maxToCopy; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(pdynLinkPvt->state!=stateConnected) return(-1); - maxToCopy = MAX_UNITS_SIZE; - if(maxlenunits,maxToCopy); - if(maxToCopypdynLinkPvt; - caStatus = (ca_state(pdynLinkPvt->chid)==cs_conn) ? 0 : -1; - if(caStatus) goto all_done; - if(*nRequest > pdynLinkPvt->nRequest) { - *nRequest = pdynLinkPvt->nRequest; - } - FASTLOCK(&pdynLinkPvt->lock); - memcpy(pbuffer,pdynLinkPvt->pbuffer, - (*nRequest * dbr_size[mapNewToOld[pdynLinkPvt->dbrType]])); - if(timestamp) *timestamp = pdynLinkPvt->timestamp; /*array copy*/ - if(status) *status = pdynLinkPvt->status; - if(severity) *severity = pdynLinkPvt->severity; - FASTUNLOCK(&pdynLinkPvt->lock); -all_done: - return(caStatus); -} - -long recDynLinkPut(recDynLink *precDynLink,void *pbuffer,size_t nRequest) -{ - dynLinkPvt *pdynLinkPvt; - long status; - ringBufCmd cmd; - - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(pdynLinkPvt->io!=ioOutput || pdynLinkPvt->state!=stateConnected) { - status = -1; - } else { - status = (ca_state(pdynLinkPvt->chid)==cs_conn) ? 0 : -1; - } - if(status) goto all_done; - if(pdynLinkPvt->scalar) nRequest = 1; - if(nRequest>ca_element_count(pdynLinkPvt->chid)) - nRequest = ca_element_count(pdynLinkPvt->chid); - pdynLinkPvt->nRequest = nRequest; - memcpy(pdynLinkPvt->pbuffer,pbuffer, - (nRequest * dbr_size[mapNewToOld[pdynLinkPvt->dbrType]])); - cmd.data.precDynLink = precDynLink; - cmd.cmd = cmdPut; - if(rngBufPut(outRingQ,(void *)&cmd,sizeof(cmd)) != sizeof(cmd)) - errMessage(0,"recDynLinkPut: rngBufPut error"); - semGive(wakeUpSem); -all_done: - return(status); -} - -LOCAL void recDynLinkStartInput(void) -{ - if((inpRingQ = rngCreate(sizeof(ringBufCmd) * recDynLinkQsize)) == NULL) { - errMessage(0,"recDynLinkStart failed"); - exit(1); - } - inpTaskId = taskSpawn("recDynINP",CA_CLIENT_PRI-1,VX_FP_TASK, - CA_CLIENT_STACK,(FUNCPTR)recDynLinkInp,0,0,0,0,0,0,0,0,0,0); - if(inpTaskId==ERROR) { - errMessage(0,"recDynLinkStartInput: taskSpawn Failure\n"); - } -} - -LOCAL void recDynLinkStartOutput(void) -{ - if((wakeUpSem=semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) - errMessage(0,"semBcreate failed in recDynLinkStart"); - if((outRingQ = rngCreate(sizeof(ringBufCmd) * recDynLinkQsize)) == NULL) { - errMessage(0,"recDynLinkStartOutput failed"); - exit(1); - } - outTaskId = taskSpawn("recDynOUT",CA_CLIENT_PRI-1,VX_FP_TASK, - CA_CLIENT_STACK,(FUNCPTR)recDynLinkOut,0,0,0,0,0,0,0,0,0,0); - if(outTaskId==ERROR) { - errMessage(0,"recDynLinkStart: taskSpawn Failure\n"); - } -} - -LOCAL void connectCallback(struct connection_handler_args cha) -{ - chid chid = cha.chid; - recDynLink *precDynLink; - dynLinkPvt *pdynLinkPvt; - - precDynLink = (recDynLink *)ca_puser(cha.chid); - if(!precDynLink) return; - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(ca_state(chid)==cs_conn) { - pdynLinkPvt->state = stateGetting; - SEVCHK(ca_get_callback(DBR_CTRL_DOUBLE,chid,getCallback,precDynLink), - "ca_get_callback"); - } else { - if(pdynLinkPvt->searchCallback) - (pdynLinkPvt->searchCallback)(precDynLink); - } -} - -LOCAL void getCallback(struct event_handler_args eha) -{ - struct dbr_ctrl_double *pdata = (struct dbr_ctrl_double *)eha.dbr; - recDynLink *precDynLink; - dynLinkPvt *pdynLinkPvt; - size_t nRequest; - - precDynLink = (recDynLink *)ca_puser(eha.chid); - if(!precDynLink) return; - pdynLinkPvt = precDynLink->pdynLinkPvt; - pdynLinkPvt -> graphicLow = pdata->lower_disp_limit; - pdynLinkPvt -> graphHigh = pdata->upper_disp_limit; - pdynLinkPvt -> controlLow = pdata->lower_ctrl_limit; - pdynLinkPvt -> controlHigh = pdata->upper_ctrl_limit; - pdynLinkPvt -> precision = pdata->precision; - strncpy(pdynLinkPvt->units,pdata->units,MAX_UNITS_SIZE); - if(pdynLinkPvt->scalar) { - pdynLinkPvt->nRequest = 1; - } else { - pdynLinkPvt->nRequest = ca_element_count(pdynLinkPvt->chid); - } - nRequest = pdynLinkPvt->nRequest; - pdynLinkPvt->pbuffer = calloc(nRequest, - dbr_size[mapNewToOld[pdynLinkPvt->dbrType]]); - if(pdynLinkPvt->io==ioInput) { - SEVCHK(ca_add_array_event( - dbf_type_to_DBR_TIME(mapNewToOld[pdynLinkPvt->dbrType]), - pdynLinkPvt->nRequest, - pdynLinkPvt->chid,monitorCallback,precDynLink, - 0.0,0.0,0.0, - &pdynLinkPvt->evid),"ca_add_array_event"); - } - pdynLinkPvt->state = stateConnected; - if(pdynLinkPvt->searchCallback) (pdynLinkPvt->searchCallback)(precDynLink); -} - -LOCAL void monitorCallback(struct event_handler_args eha) -{ - recDynLink *precDynLink; - dynLinkPvt *pdynLinkPvt; - long count = eha.count; - const void *pbuffer = eha.dbr; - struct dbr_time_string *pdbr_time_string; - void *pdata; - short timeType; - - precDynLink = (recDynLink *)ca_puser(eha.chid); - if(!precDynLink) return; - pdynLinkPvt = precDynLink->pdynLinkPvt; - if(pdynLinkPvt->pbuffer) { - FASTLOCK(&pdynLinkPvt->lock); - if(count>=pdynLinkPvt->nRequest) - count = pdynLinkPvt->nRequest; - pdbr_time_string = (struct dbr_time_string *)pbuffer; - timeType = dbf_type_to_DBR_TIME(mapNewToOld[pdynLinkPvt->dbrType]); - pdata = (void *)((char *)pbuffer + dbr_value_offset[timeType]); - pdynLinkPvt->timestamp = pdbr_time_string->stamp; /*array copy*/ - pdynLinkPvt->status = pdbr_time_string->status; - pdynLinkPvt->severity = pdbr_time_string->severity; - memcpy(pdynLinkPvt->pbuffer,pdata, - (count * dbr_size[mapNewToOld[pdynLinkPvt->dbrType]])); - FASTUNLOCK(&pdynLinkPvt->lock); - } - if(pdynLinkPvt->monitorCallback) - (*pdynLinkPvt->monitorCallback)(precDynLink); -} - -LOCAL void recDynLinkInp(void) -{ - int status; - recDynLink *precDynLink; - dynLinkPvt *pdynLinkPvt; - ringBufCmd cmd; - - taskwdInsert(taskIdSelf(),NULL,NULL); - SEVCHK(ca_task_initialize(),"ca_task_initialize"); - while(TRUE) { - while (rngNBytes(inpRingQ)>=sizeof(cmd) && interruptAccept){ - if(rngBufGet(inpRingQ,(void *)&cmd,sizeof(cmd)) - !=sizeof(cmd)) { - errMessage(0,"recDynLinkTask: rngBufGet error"); - continue; - } - if(cmd.cmd==cmdClear) { - pdynLinkPvt = cmd.data.pdynLinkPvt; - if(pdynLinkPvt->chid) - SEVCHK(ca_clear_channel(pdynLinkPvt->chid), - "ca_clear_channel"); - free(pdynLinkPvt->pbuffer); - free((void *)pdynLinkPvt); - continue; - } - precDynLink = cmd.data.precDynLink; - pdynLinkPvt = precDynLink->pdynLinkPvt; - switch(cmd.cmd) { - case(cmdSearch) : - SEVCHK(ca_search_and_connect(pdynLinkPvt->pvname, - &pdynLinkPvt->chid, connectCallback,precDynLink), - "ca_search_and_connect"); - break; - default: - epicsPrintf("Logic error statement in recDynLinkTask\n"); - } - } - status = ca_pend_event(.1); - if(status!=ECA_NORMAL && status!=ECA_TIMEOUT) - SEVCHK(status,"ca_pend_event"); - } -} - -LOCAL void recDynLinkOut(void) -{ - int status; - recDynLink *precDynLink; - dynLinkPvt *pdynLinkPvt; - ringBufCmd cmd; - int caStatus; - - taskwdInsert(taskIdSelf(),NULL,NULL); - SEVCHK(ca_task_initialize(),"ca_task_initialize"); - while(TRUE) { - semTake(wakeUpSem,sysClkRateGet()); - while (rngNBytes(outRingQ)>=sizeof(cmd) && interruptAccept){ - if(rngBufGet(outRingQ,(void *)&cmd,sizeof(cmd)) - !=sizeof(cmd)) { - errMessage(0,"recDynLinkTask: rngBufGet error"); - continue; - } - if(cmd.cmd==cmdClear) { - pdynLinkPvt = cmd.data.pdynLinkPvt; - if(pdynLinkPvt->chid) - SEVCHK(ca_clear_channel(pdynLinkPvt->chid), - "ca_clear_channel"); - free(pdynLinkPvt->pbuffer); - free((void *)pdynLinkPvt); - continue; - } - precDynLink = cmd.data.precDynLink; - pdynLinkPvt = precDynLink->pdynLinkPvt; - switch(cmd.cmd) { - case(cmdSearch) : - SEVCHK(ca_search_and_connect(pdynLinkPvt->pvname, - &pdynLinkPvt->chid, connectCallback,precDynLink), - "ca_search_and_connect"); - break; - case(cmdPut) : - caStatus = ca_array_put( - mapNewToOld[pdynLinkPvt->dbrType], - pdynLinkPvt->nRequest,pdynLinkPvt->chid, - pdynLinkPvt->pbuffer); - if(caStatus!=ECA_NORMAL) { - epicsPrintf("recDynLinkTask pv=%s CA Error %s\n", - pdynLinkPvt->pvname,ca_message(caStatus)); - } - break; - default: - epicsPrintf("Logic error statement in recDynLinkTask\n"); - } - } - status = ca_pend_event(.00001); - if(status!=ECA_NORMAL && status!=ECA_TIMEOUT) - SEVCHK(status,"ca_pend_event"); - } -} diff --git a/src/rec/recDynLink.h b/src/rec/recDynLink.h deleted file mode 100644 index e4fe17414..000000000 --- a/src/rec/recDynLink.h +++ /dev/null @@ -1,51 +0,0 @@ -/*recDynLink.c*/ -/***************************************************************** - COPYRIGHT NOTIFICATION -***************************************************************** - -(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO - -This software was developed under a United States Government license -described on the COPYRIGHT_UniversityOfChicago file included as part -of this distribution. -*******************************************************************/ -#ifndef INCrecDynLinkh -#define INCrecDynLinkh - -#include -typedef struct recDynLink{ - void *puserPvt; - void *pdynLinkPvt; -} recDynLink; -typedef void (*recDynCallback)(recDynLink *); - -#define rdlDBONLY 0x1 -#define rdlSCALAR 0x2 - -long recDynLinkAddInput(recDynLink *precDynLink,char *pvname, - short dbrType,int options, - recDynCallback searchCallback,recDynCallback monitorCallback); -long recDynLinkAddOutput(recDynLink *precDynLink,char *pvname, - short dbrType,int options, - recDynCallback searchCallback); -long recDynLinkClear(recDynLink *precDynLink); -/*The following routine returns (0,-1) for (connected,not connected)*/ -long recDynLinkConnectionStatus(recDynLink *precDynLink); -/*thye following routine returns (0,-1) if (connected,not connected)*/ -long recDynLinkGetNelem(recDynLink *precDynLink,size_t *nelem); -/*The following 4 routines return (0,-1) if data (is, is not) yet available*/ -/*searchCallback is not called until this info is available*/ -long recDynLinkGetControlLimits(recDynLink *precDynLink, - double *low,double *high); -long recDynLinkGetGraphicLimits(recDynLink *precDynLink, - double *low,double *high); -long recDynLinkGetPrecision(recDynLink *precDynLink,int *prec); -long recDynLinkGetUnits(recDynLink *precDynLink,char *units,int maxlen); - -/*get only valid mfor rdlINPUT. put only valid for rdlOUTPUT*/ -long recDynLinkGet(recDynLink *precDynLink, - void *pbuffer, size_t *nRequest, - TS_STAMP *timestamp,short *status,short *severity); -long recDynLinkPut(recDynLink *precDynLink,void *pbuffer,size_t nRequest); - -#endif /*INCrecDynLinkh*/ diff --git a/src/rec/recDynLinkTest.c b/src/rec/recDynLinkTest.c deleted file mode 100644 index fab38b346..000000000 --- a/src/rec/recDynLinkTest.c +++ /dev/null @@ -1,192 +0,0 @@ -/*recDynLinkTest.c */ -/***************************************************************** - COPYRIGHT NOTIFICATION -***************************************************************** - -(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO - -This software was developed under a United States Government license -described on the COPYRIGHT_UniversityOfChicago file included as part -of this distribution. -***********************************************************************/ -#include -#include -#include -#include -#include - -#include "dbDefs.h" -#include "epicsPrint.h" -#include -#include -#include - -/*The remainder of this source module is test code */ -typedef struct userPvt { - char *pvname; - double *pbuffer; - size_t nRequest; -}userPvt; - -LOCAL void mymonitorCallback(recDynLink *precDynLink) -{ - userPvt *puserPvt; - long status; - size_t nRequest; - TS_STAMP timestamp; - short AlarmStatus,AlarmSeverity; - int i; - char timeStr[40]; - - puserPvt = (userPvt *)precDynLink->puserPvt; - printf("mymonitorCallback: %s\n",puserPvt->pvname); - if(recDynLinkConnectionStatus(precDynLink)!=0) { - printf(" not connected\n"); - return; - } - nRequest = puserPvt->nRequest; - status = recDynLinkGet(precDynLink,puserPvt->pbuffer,&nRequest, - ×tamp,&AlarmStatus,&AlarmSeverity); - if(status) { - printf("recDynLinkGet returned illegal status\n"); - return; - } - tsStampToText(×tamp,TS_TEXT_MMDDYY,timeStr); - printf("date %s status %hd severity %hd ", - timeStr,AlarmStatus,AlarmSeverity); - for(i=0; inRequest; i++) { - printf(" %f",puserPvt->pbuffer[i]); - } - printf("\n"); -} - -LOCAL void mysearchCallback(recDynLink *precDynLink) -{ - userPvt *puserPvt; - size_t nelem; - double controlLow,controlHigh; - double graphicLow,graphicHigh; - int prec; - char units[20]; - long status; - - puserPvt = (userPvt *)precDynLink->puserPvt; - printf("mysearchCallback: %s ",puserPvt->pvname); - if(recDynLinkConnectionStatus(precDynLink)==0) { - printf("connected\n"); - status = recDynLinkGetNelem(precDynLink,&nelem); - if(status) { - printf("recDynLinkGetNelem failed\n"); - }else{ - printf("nelem = %u\n",nelem); - } - status=recDynLinkGetControlLimits(precDynLink,&controlLow,&controlHigh); - if(status) { - printf("recDynLinkGetControlLimits failed\n"); - }else{ - printf("controlLow %f controlHigh %f\n",controlLow,controlHigh); - } - status=recDynLinkGetGraphicLimits(precDynLink,&graphicLow,&graphicHigh); - if(status) { - printf("recDynLinkGetGraphicLimits failed\n"); - }else{ - printf("graphicLow %f graphicHigh %f\n",graphicLow,graphicHigh); - } - status = recDynLinkGetPrecision(precDynLink,&prec); - if(status) { - printf("recDynLinkGetPrecision failed\n"); - }else{ - printf("prec = %d\n",prec); - } - status = recDynLinkGetUnits(precDynLink,units,20); - if(status) { - printf("recDynLinkGetUnits failed\n"); - }else{ - printf("units = %s\n",units); - } - } else { - printf(" not connected\n"); - } -} - -LOCAL recDynLink getDynlink = {NULL,NULL}; -LOCAL recDynLink putDynlink = {NULL,NULL}; - -int recDynTestInput(char *pvname,int nRequest) -{ - userPvt *puserPvt= getDynlink.puserPvt; - long status; - int options=0; - - if(puserPvt) { - recDynLinkClear(&getDynlink); - free(puserPvt->pbuffer); - free(getDynlink.puserPvt); - getDynlink.puserPvt = NULL; - } - getDynlink.puserPvt = puserPvt = (userPvt *)calloc(1,sizeof(userPvt)); - puserPvt->pbuffer = calloc(nRequest,sizeof(double)); - puserPvt->nRequest = nRequest; - puserPvt->pvname = pvname; - if(nRequest==1) options=rdlSCALAR;; - status = recDynLinkAddInput(&getDynlink,pvname, - DBR_DOUBLE,options, - mysearchCallback,mymonitorCallback); - if(status) return(status); - return(status); -} - -int recDynTestNewOutput(char *pvname,int nRequest) -{ - userPvt *puserPvt= putDynlink.puserPvt; - long status; - int options=0; - - if(puserPvt) { - recDynLinkClear(&putDynlink); - free(puserPvt->pbuffer); - free(putDynlink.puserPvt); - putDynlink.puserPvt = NULL; - } - putDynlink.puserPvt = puserPvt = (userPvt *)calloc(1,sizeof(userPvt)); - puserPvt->pbuffer = calloc(nRequest,sizeof(double)); - puserPvt->nRequest = nRequest; - puserPvt->pvname = pvname; - if(nRequest==1) options=rdlSCALAR;; - status = recDynLinkAddOutput(&putDynlink,pvname, - DBR_DOUBLE,options,mysearchCallback); - return(status); -} - -int recDynTestOutput(int startValue) -{ - userPvt *puserPvt= putDynlink.puserPvt; - long status; - int i; - - for(i=0; inRequest; i++) puserPvt->pbuffer[i] = startValue + i; - status = recDynLinkPut(&putDynlink,puserPvt->pbuffer,puserPvt->nRequest); - return(status); -} - -int recDynTestClearInput(void) -{ - userPvt *puserPvt= getDynlink.puserPvt; - - recDynLinkClear(&getDynlink); - free(puserPvt->pbuffer); - free(getDynlink.puserPvt); - getDynlink.puserPvt = NULL; - return(0); -} - -int recDynTestClearOutput(void) -{ - userPvt *puserPvt= putDynlink.puserPvt; - - recDynLinkClear(&putDynlink); - free(puserPvt->pbuffer); - free(putDynlink.puserPvt); - putDynlink.puserPvt = NULL; - return(0); -} diff --git a/src/rec/recWaitCa.c b/src/rec/recWaitCa.c deleted file mode 100644 index 4b413852f..000000000 --- a/src/rec/recWaitCa.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 07-27-95 nda made QUEUE_SIZE a global variable so it could - * be changed at boot time for LOTS OF WAIT records - * - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dbDefs.h" -#include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include - -extern int interruptAccept; - -int recWaitCaQsize = 256; - -LOCAL int taskid=0; -LOCAL RING_ID ringQ; -LOCAL FAST_LOCK lock; - -typedef enum {cmdNone,cmdAdd,cmdRemove} COMMAND; - -typedef struct { - RECWAITCA *pcamonitor; - chid chid; - evid evid; - COMMAND cmd; - int hasMonitor; - struct dbr_sts_double rtndata; /*Not currently used */ -} CAPVT; - -void recWaitCaTask(void); - -LOCAL void eventCallback(struct event_handler_args eha) -{ - const struct dbr_sts_double *pdata = eha.dbr; - CAPVT *pcapvt; - RECWAITCA *pcamonitor; - - pcapvt = (CAPVT *)eha.usr; - pcamonitor = pcapvt->pcamonitor; - (pcamonitor->callback)(pcamonitor, pcamonitor->inputIndex, pdata->value); -} - -LOCAL void recWaitCaStart(void) -{ - FASTLOCKINIT(&lock); - if((ringQ = rngCreate(sizeof(void *) * recWaitCaQsize)) == NULL) { - errMessage(0,"recWaitCaStart failed"); - exit(1); - } - taskid = taskSpawn("recWaitCaTask",CA_CLIENT_PRI-1,VX_FP_TASK, - CA_CLIENT_STACK,(FUNCPTR)recWaitCaTask,0,0,0,0,0,0,0,0,0,0); - if(taskid==ERROR) { - errMessage(0,"recWaitCaStart: taskSpawn Failure\n"); - } -} - -long recWaitCaAdd(RECWAITCA *pcamonitor) -{ - CAPVT *pcapvt; - - if(!taskid) recWaitCaStart(); - FASTLOCK(&lock); - pcapvt = pcamonitor->recWaitCaPvt; - if(pcapvt == NULL) { - pcapvt = calloc(1,sizeof(CAPVT)); - pcamonitor->recWaitCaPvt = pcapvt; - pcapvt->pcamonitor = pcamonitor; - } - pcapvt->cmd = cmdAdd; - if(rngBufPut(ringQ,(void *)&pcapvt,sizeof(pcapvt)) - !=sizeof(pcamonitor)) errMessage(0,"recWaitCaAdd: rngBufPut error"); - FASTUNLOCK(&lock); - return(0); -} - -long recWaitCaDelete(RECWAITCA *pcamonitor) -{ - CAPVT *pcapvt = pcamonitor->recWaitCaPvt; - - FASTLOCK(&lock); - pcapvt->cmd = cmdRemove; - if(rngBufPut(ringQ,(void *)&pcapvt,sizeof(pcapvt)) - !=sizeof(pcamonitor)) errMessage(0,"recWaitCaDelete: rngBufPut error"); - FASTUNLOCK(&lock); - return(0); -} - -/*LOCAL */ -void recWaitCaTask(void) -{ - CAPVT *pcapvt; - RECWAITCA *pcamonitor; - int status; - - taskwdInsert(taskIdSelf(),NULL,NULL); - SEVCHK(ca_task_initialize(),"ca_task_initialize"); - while(TRUE) { - while (rngNBytes(ringQ)>=sizeof(pcapvt) && interruptAccept){ - if(rngBufGet(ringQ,(void *)&pcapvt,sizeof(pcapvt)) - !=sizeof(pcapvt)) { - errMessage(0,"recWaitCaTask: rngBufGet error"); - continue; - } - FASTLOCK(&lock); - pcamonitor = pcapvt->pcamonitor; - if(pcapvt->cmd==cmdAdd) { - if(pcapvt->hasMonitor - && (strcmp(pcamonitor->channame,ca_name(pcapvt->chid))!=0)) { - SEVCHK(ca_clear_channel(pcapvt->chid),"ca_clear_channel"); - pcapvt->hasMonitor = FALSE; - } - if(!pcapvt->hasMonitor) { - SEVCHK(ca_build_and_connect(pcamonitor->channame, - TYPENOTCONN,0,&pcapvt->chid,0,NULL,pcapvt), - "ca_build_and_connect"); - SEVCHK(ca_add_event(DBR_STS_DOUBLE,pcapvt->chid, - eventCallback,pcapvt,&pcapvt->evid), - "ca_add_event"); - pcapvt->hasMonitor = TRUE; - } - } else if (pcapvt->cmd==cmdRemove && pcapvt->hasMonitor) { - SEVCHK(ca_clear_channel(pcapvt->chid),"ca_clear_channel"); - pcapvt->hasMonitor = FALSE; - } - FASTUNLOCK(&lock); - } - status = ca_pend_event(.1); - if(status!=ECA_NORMAL && status!=ECA_TIMEOUT) - SEVCHK(status,"ca_pend_event"); - } -} - -static void myCallback(struct recWaitCa *pcamonitor, char inputIndex, double monData) -{ - printf("myCallback: %s index=%d\n",pcamonitor->channame, - pcamonitor->inputIndex); -} - -int testCaMonitor(char *name,char *name2,int delay) -{ - RECWAITCA *pcamonitor; - long status; - - pcamonitor = calloc(1,sizeof(RECWAITCA)); - pcamonitor->channame = calloc(1,100); - pcamonitor->callback = myCallback; - strcpy(pcamonitor->channame,name); - status = recWaitCaAdd(pcamonitor); - if(status) errMessage(status,"testCaMonitor error"); - taskDelay(10); - status = recWaitCaDelete(pcamonitor); - if(status) errMessage(status,"testCaMonitor error"); - if(delay>0) taskDelay(delay); - status = recWaitCaAdd(pcamonitor); - if(status) errMessage(status,"testCaMonitor error"); - taskDelay(10); - status = recWaitCaDelete(pcamonitor); - if(status) errMessage(status,"testCaMonitor error"); - if(delay>0) taskDelay(delay); - if(name2) strcpy(pcamonitor->channame,name2); - status = recWaitCaAdd(pcamonitor); - if(status) errMessage(status,"testCaMonitor error"); - taskDelay(10); - status = recWaitCaDelete(pcamonitor); - if(status) errMessage(status,"testCaMonitor error"); - if(delay>0) taskDelay(delay); - return(0); -} diff --git a/src/rec/recWaitCa.h b/src/rec/recWaitCa.h deleted file mode 100644 index 8d2e5c5e2..000000000 --- a/src/rec/recWaitCa.h +++ /dev/null @@ -1,10 +0,0 @@ -typedef struct recWaitCa{ - char *channame; - char inputIndex; - void (*callback)(struct recWaitCa *pcamonitor, char inputIndex, double monData); - void *userPvt; - void *recWaitCaPvt; -} RECWAITCA; - -long recWaitCaAdd(RECWAITCA *pcamonitor); -long recWaitCaDelete(RECWAITCA *pcamonitor); diff --git a/src/rec/scanRecord.c b/src/rec/scanRecord.c deleted file mode 100644 index 2e6a8ee7b..000000000 --- a/src/rec/scanRecord.c +++ /dev/null @@ -1,3310 +0,0 @@ - -/* - * Original Author: Ned D. Arnold - * Date: 07-18-94 - * - * 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 07-18-94 nda significantly expanded functionality from prototype - * .02 08-18-94 nda Starting with R3.11.6, dbGetField locks the record - * before fetching the data. This can cause deadlocks - * within a database. Change all dbGetField() to dbGet() - * .03 08-23-94 nda added code for checking/adjusting linear scan - * params (it gets a little messy !) - * .04 08-25-94 nda Added check of scan positions vs Positioner Control - * Limits - * .05 08-29-94 nda Added "viewScanPos" that puts desired positions - * in D1 array any time a scan parameter is changed - * .06 10-03-94 nda added code for enumerated string .CMND. Changed - * .EXSC to a SHORT in record definition. Added VERSION - * for .VERS field (1.06) to keep track of version. - * .07 10-21-94 nda changed linear scan parameter algorithms so changing - * start/end modifies step/width unless frozen. This - * seems more intuitive. - * .08 12-06-94 nda added support for .FFO .When set to 1, frzFlag values - * are saved in recPvtStruct. Restored when FFO set to 0. - * .09 02-02-95 nda fixed order of posting monitors to be what people - * expect (i.e. .cpt, .pxdv, .dxcv) - * .10 02-10-95 nda fixed on-the-fly so 1st step is to end position - * .11 02-21-95 nda added "Return To Start" flag. If set, positioners - * will be commanded to the start pos after the scan. - * .12 03-02-95 nda added positioner readback arrays (PxRA). These arrays - * will contain actual readback positions (if RxPV are - * defined. If not, the desired positions will be loaded - * into them. - * .13 03-02-95 nda Post .val field when a new point is complete during a - * scan. This will assist in poin by point plots. - * .14 03-02-95 nda Bug fix on filling PxRA's. ALWAYS CALL CHECK_MOTORS. - * .15 03-15-95 nda If no readback PV (RxPV) is specified, copy desired - * value (PxDV) to current value (RxCV). Now, plotting - * programs can always monitor RxCV. - * .16 04-03-95 nda If PV field = DESC, change to VAL - * - * 3.00 08-28-95 nda > Significant rewrite to add Channel Access - * for dynamic links using recDynLink.c . All - * inputs are now "monitored" via Channel Access. - * > Name Valid field is used to keep track of PV - * connection status: 0-PV_OK, - * 1-NotConnected, 2-NO_PV - * > added relative/absolute mode on positioners - * > added retrace options of stay/start/prior - * > supports 15 detectors - * > added "preview scan" - * > added "Before Scan" and "After Scan" links - * > fetch DRVL/DRVH/prec/egu from dynamic links - * > when posting arrays at end of scan, use DBE_LOG, too - * > Record timeStamp only at beginning of scan - * > Record positioner readbacks when reading detectors - * > "TIME" or "time" in a readback PV records time - * - * 3.01 03-07-96 nda Rearrange order of precedence of linear scan parameters - * per Tim Mooney's memo duplicated at end of this file - * - * 3.02 03-12-96 nda If scan request and any PV's are PV_NC, callback 3 - * seconds later ... if still PV_NC, abort. Also, if any - * control PV's (positioners, readbacks, detctr triggers) - * lose connection during a scan, abort scan. - * - * 3.02 03-12-96 nda Changed detector reading to accommodate the possibility - * of connections "coming and going" during a scan: If a - * detector PV is valid at the beginning of the scan, the - * value will be read each point. If the PV is not - * connected for a given point, a zero will be stored. - * Previously, nothing would be stored, which left old - * data in the array for those points. Any detector PV's - * added during a scan will be ignored until the next scan - * - * 3.02 03-12-96 nda Writing a 3 to the .CMND field will clear all PV's, - * set all positioners to LINEAR & ABSOLUTE, resets all - * freeze flags & .FFO, sets .SCAN to Passive,RETRACE=stay - * - * 3.03 04-26-96 tmm Writing a 4 to the .CMND field will clear positioner - * PV's, set all positioners to LINEAR & ABSOLUTE, reset - * all freeze flags & .FFO, set .SCAN to Passive, set - * RETRACE=stay - * - * 3.13 _______ nda changes for 3.13 - * 03-15-96 - remove pads from detFields structure - * - use fieldOffset indexes - */ - -#define VERSION 3.13 - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dbDefs.h" -#include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define GEN_SIZE_OFFSET -#include -#undef GEN_SIZE_OFFSET -#include -#include -#include /* also includes timers.h and tsDefs.h */ - -#include - - -/*************************** - Declare constants -***************************/ -#define DEF_WF_SIZE 100 -#define PVN_SIZE 40 - -#define POSITIONER 0 -#define READBACK 1 -#define DETECTOR 2 -#define TRIGGER 3 -#define FWD_LINK 4 - -#define NUM_POS 4 -#define NUM_RDKS 4 -#define NUM_DET 15 -#define NUM_TRGS 2 -#define NUM_MISC 2 /* Before Scan PV, After Scan PV */ -#define NUM_PVS (NUM_POS + NUM_RDKS + NUM_DET + NUM_TRGS + NUM_MISC) -/* Determine total # of dynLinks (each positioner requires two: IN & OUT */ -#define NUM_LINKS (NUM_PVS + NUM_POS) - -/* Define special type constants for first and last dynamic PV name */ -#define FIRST_PV REC_SC_P1 -#define LAST_PV REC_SC_AS - -/* Predefine some index numbers */ -#define P1_IN 0 -#define P2_IN 1 -#define P3_IN 2 -#define P4_IN 3 -#define R1_IN (NUM_POS) -#define R2_IN (NUM_POS + 1) -#define R3_IN (NUM_POS + 2) -#define R4_IN (NUM_POS + 3) -#define D1_IN (NUM_POS + NUM_RDKS) - -#define T1_OUT (D1_IN + NUM_DET) -#define T2_OUT (T1_OUT + 1) - -#define BS_OUT (T1_OUT + NUM_TRGS) -#define AS_OUT (BS_OUT + 1) - -/* Added four recDynLinks at the end of PV's for positioner outs */ -#define P1_OUT (NUM_PVS) -#define P2_OUT (P1_OUT + 1) -#define P3_OUT (P2_OUT + 1) -#define P4_OUT (P3_OUT + 1) - -#define MIN_MON 3 /* # of ticks between monitor postings. 3 = 50 ms */ - -#define PV_OK REC_SCAN_DYNL_OK /* from choiceScan.h */ -#define PV_NC REC_SCAN_DYNL_NC /* from choiceScan.h */ -#define NO_PV REC_SCAN_DYNL_NO_PV /* from choiceScan.h */ - -#define A_BUFFER 0 -#define B_BUFFER 1 - -#define IDLE 0 -#define INIT_SCAN 1 -#define BEFORE_SCAN 2 -#define MOVE_MOTORS 3 -#define CHECK_MOTORS 4 -#define TRIG_DETCTRS 5 -#define READ_DETCTRS 6 -#define AFTER_SCAN 7 -#define PREVIEW 8 -#define SCAN_PENDING 9 - -#define CLEAR_MSG 0 -#define CHECK_LIMITS 1 -#define PREVIEW_SCAN 2 /* Preview the SCAN positions */ -#define CLEAR_RECORD 3 /* Clear PV's, frzFlags, modes, abs/rel, etc */ -#define CLEAR_POSITIONERS 4 /* Clear positioner PV's, frzFlags, modes, abs/rel, etc */ - -#define DBE_VAL_LOG (DBE_VALUE | DBE_LOG) - - -/* Create RSET - Record Support Entry Table*/ -#define report NULL -#define initialize NULL -static long init_record(); -static long process(); -static long special(); -#define get_value NULL -static long cvt_dbaddr(); -static long get_array_info(); -static long put_array_info(); -static long get_units(); -static long get_precision(); -static long get_enum_str(); -static long get_enum_strs(); -static long put_enum_str(); -static long get_graphic_double(); -static long get_control_double(); -static long get_alarm_double(); - -struct rset scanRSET={ - 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 -}; - -typedef struct recDynLinkPvt { - struct scanRecord *pscan; /* pointer to scan record */ - unsigned short linkIndex; /* specifies which dynamic link */ - unsigned short linkType; /* Positioner, Rdbk, Trig, Det */ - struct dbAddr *pAddr; /* Pointer to dbAddr for local PV's */ - long dbAddrNv; /* Zero if dbNameToAddr succeeded */ - unsigned long nelem; /* # of elements for this PV */ - unsigned short ts; /* if 1, use timestamp as value */ - short fldOffset; /* For arrays, offset from pscan, used - for get_array_info, cvt_dbaddr */ -}recDynLinkPvt; - -typedef struct dynLinkInfo { - DBRunits - DBRprecision - DBRgrDouble - DBRctrlDouble - float value; -}dynLinkInfo; - -typedef struct posBuffers { - double *pFill; - double *pBufA; - double *pBufB; -} posBuffers; - -typedef struct detBuffers { - float *pFill; - float *pBufA; - float *pBufB; - int size; - short vector; -} detBuffers; - - -/* the following structure must match EXACTLY with the order and type of - fields defined in scanRecord.h for each positioner (even including - the "Created Pad"s */ - -typedef struct posFields { - double p_pp; /* P1 Previous Position */ - double p_cv; /* P1 Current Value */ - double p_dv; /* P1 Desired Value */ - double p_lv; /* P1 Last Value Posted */ - double p_sp; /* P1 Start Position */ - double p_si; /* P1 Step Increment */ - double p_ep; /* P1 End Position */ - double p_cp; /* P1 Center Position */ - double p_wd; /* P1 Scan Width */ - double r_cv; /* P1 Readback Value */ - double r_lv; /* P1 Rdbk Last Val Pst */ - double r_dl; /* P1 Readback Delta */ - double p_hr; /* P1 High Oper Range */ - double p_lr; /* P1 Low Oper Range */ - double * p_pa; /* P1 Step Array */ - double * p_ra; /* P1 Readback Array */ - unsigned short p_fs; /* P1 Freeze Start Pos */ - unsigned short p_fi; /* P1 Freeze Step Inc */ - unsigned short p_fe; /* P1 Freeze End Pos */ - unsigned short p_fc; /* P1 Freeze Center Pos */ - unsigned short p_fw; /* P1 Freeze Width */ - unsigned short p_sm; /* P1 Step Mode */ - unsigned short p_ar; /* P1 Absolute/Relative */ - char p_eu[16]; /* P1 Engineering Units */ - short p_pr; /* P1 Display Precision */ -}posFields; - -/* the following structure must match EXACTLY with the order and type of - fields defined in scanRecord.h for each detector (even including - the "Created Pad"s */ - -typedef struct detFields { - double d_hr; /* D1 High Oper Range */ - double d_lr; /* D1 Low Oper Range */ - float * d_da; /* D1 Data Array */ - float d_cv; /* D1 Current Value */ - float d_lv; /* D1 Last Value Posted */ - unsigned long d_ne; /* D1 # of Elements/Pt */ - char d_eu[16]; /* D1 Engineering Units */ - short d_pr; /* D1 Display Precision */ -}detFields; - - -typedef struct recPvtStruct { - /* THE CODE ASSUMES doPutsCallback is THE FIRST THING IN THIS STRUCTURE!*/ - CALLBACK doPutsCallback;/* do output links callback structure */ - WDOG_ID wd_id; /* watchdog for delay if PV_NC and .EXSC */ - struct scanRecord *pscan; /* ptr to record which needs work done */ - short phase; /* what to do to the above record */ - short validBuf; /* which data array buffer is valid */ - recDynLink caLinkStruct[NUM_LINKS]; /* req'd for recDynLink */ - posBuffers posBufPtr[NUM_POS]; - detBuffers detBufPtr[NUM_DET]; - unsigned short valPosPvs; /* # of valid positioners */ - unsigned short valRdbkPvs; /* # of valid Readbacks */ - unsigned short valDetPvs; /* # of valid Detectors */ - unsigned short valTrigPvs; /* # of valid Det Triggers */ - unsigned short acqDet[NUM_DET]; /* which detectors to acquire */ - dynLinkInfo *pDynLinkInfo; - short pffo; /* previous state of ffo */ - short fpts; /* backup copy of all freeze flags */ - unsigned short prevSm[NUM_POS]; /* previous states of p_sm */ - posFields posParms[NUM_POS]; /* backup copy of all pos. parms */ - unsigned long tablePts[NUM_POS]; /* # of pts loaded in P_PA */ - short onTheFly; - float *nullArray; - unsigned long tickStart; /* used to time the scan */ - char movPos[NUM_POS]; /* used to indicate interactive move */ - unsigned char scanErr; - unsigned char badOutputPv; /* positioner, detector trig, readbk */ - unsigned char badInputPv; /* detector BAD_PV */ - char nptsCause; /* who caused the "# of points to change: - -1:operator; 0-3 Positioners*/ -}recPvtStruct; - -/* forward declarations */ - -static void checkMonitors(); -static long initScan(); -static void contScan(); -static void endScan(); -static void doPuts(); -static void adjLinParms(); -static void changedNpts(); -static long checkScanLimits(); -static void saveFrzFlags(); -static void resetFrzFlags(); -static void restoreFrzFlags(); - -static void previewScan(struct scanRecord *pscan); - -static void lookupPV(struct scanRecord *pscan, unsigned short i); -static void checkConnections(struct scanRecord *pscan); -static void pvSearchCallback(recDynLink *precDynLink); -static void posMonCallback(recDynLink *precDynLink); -static void restorePosParms(struct scanRecord *pscan, unsigned short i); -static void savePosParms(struct scanRecord *pscan, unsigned short i); -static void zeroPosParms(struct scanRecord *pscan, unsigned short i); - -/* variables ... */ -long recScanDebug=0; -long recScanViewPos=0; -long recScanDontCheckLimits=0; - - -static long init_record(pscan,pass) - struct scanRecord *pscan; - int pass; -{ - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields; - detFields *pDetFields; - - char *ppvn[PVN_SIZE]; - unsigned short *pPvStat; - unsigned short i; - - recDynLinkPvt *puserPvt; - - - if (pass==0) { - pscan->vers = VERSION; - if(pscan->mpts < 100) pscan->mpts = DEF_WF_SIZE; - - /* First time through, rpvt needs initialized */ - pscan->rpvt = calloc(1, sizeof(recPvtStruct)); - precPvt = (recPvtStruct *)pscan->rpvt; - - precPvt->phase = IDLE; - - precPvt->prevSm[0] = pscan->p1sm; - precPvt->prevSm[1] = pscan->p2sm; - precPvt->prevSm[2] = pscan->p3sm; - precPvt->prevSm[3] = pscan->p4sm; - - precPvt->pscan = pscan; - - precPvt->pDynLinkInfo = (dynLinkInfo *)calloc(1, sizeof(dynLinkInfo)); - - /* init the private area of the caLinkStruct's */ - for(i=0;i<(NUM_LINKS); i++) { - precPvt->caLinkStruct[i].puserPvt - = calloc(1,sizeof(struct recDynLinkPvt)); - puserPvt = (recDynLinkPvt *)precPvt->caLinkStruct[i].puserPvt; - puserPvt->pscan = pscan; - puserPvt->linkIndex = i; - puserPvt->pAddr = calloc(1, sizeof(struct dbAddr)); - puserPvt->dbAddrNv = -1; - if (i < R1_IN) puserPvt->linkType = POSITIONER; - else if(i < D1_IN) puserPvt->linkType = READBACK; - else if(i < T1_OUT) puserPvt->linkType = DETECTOR; - else if(i < BS_OUT) puserPvt->linkType = TRIGGER; - else if(i < P1_OUT) puserPvt->linkType = FWD_LINK; - } - - pscan->p1pa = (double *) calloc(pscan->mpts, sizeof(double)); - pscan->p2pa = (double *) calloc(pscan->mpts, sizeof(double)); - pscan->p3pa = (double *) calloc(pscan->mpts, sizeof(double)); - pscan->p4pa = (double *) calloc(pscan->mpts, sizeof(double)); - - /* Readbacks need double buffering. Allocate space and initialize */ - /* fill pointer and readback array pointers */ - precPvt->validBuf = A_BUFFER; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; iposBufPtr[i].pBufA = - (double *) calloc(pscan->mpts, sizeof(double)); - precPvt->posBufPtr[i].pBufB = - (double *) calloc(pscan->mpts, sizeof(double)); - - pPosFields->p_ra = precPvt->posBufPtr[i].pBufA; - precPvt->posBufPtr[i].pFill = precPvt->posBufPtr[i].pBufB; - } - - /* allocate arrays for 4 detectors assuming nelem = 1 */ - /* (previewScan uses the first four detectors) */ - /* For now, just point other detectors to a NULL array */ - - precPvt->nullArray = (float *) calloc(pscan->mpts, sizeof(float)); - pDetFields = (detFields *)&pscan->d1hr; - for(i=0; icaLinkStruct[D1_IN+i].puserPvt; - if(i<4) { - precPvt->detBufPtr[i].pBufA = - (float *) calloc(pscan->mpts, sizeof(float)); - precPvt->detBufPtr[i].pBufB = - (float *) calloc(pscan->mpts, sizeof(float)); - puserPvt->nelem = 1; - } - else { - precPvt->detBufPtr[i].pBufA = precPvt->nullArray; - precPvt->detBufPtr[i].pBufB = precPvt->nullArray; - puserPvt->nelem = 0; - } - pDetFields->d_da = precPvt->detBufPtr[i].pBufA; - precPvt->detBufPtr[i].pFill = precPvt->detBufPtr[i].pBufB; - } - - return(0); - } - - callbackSetCallback(doPuts, &precPvt->doPutsCallback); - callbackSetPriority(pscan->prio, &precPvt->doPutsCallback); - precPvt->wd_id = wdCreate(); - - /* initialize all linear scan fields */ - precPvt->nptsCause = -1; /* resolve all positioner parameters */ - changedNpts(pscan); - - if(pscan->ffo) { - saveFrzFlags(pscan); - resetFrzFlags(pscan); - } - - /* init field values */ - pscan->exsc = 0; - pscan->pxsc = 0; - - *ppvn = &pscan->p1pv[0]; - pPvStat = &pscan->p1nv; - - /* check all dynLink PV's for non-NULL */ - for(i=0;irpvt; - long status = 0; - - - /* Decide what to do. */ - if(precPvt->phase == SCAN_PENDING) return(status); - /* Brand new scan */ - if ((pscan->pxsc == 0) && (pscan->exsc == 1)) { - precPvt->phase = INIT_SCAN; - /* use TimeStamp to record beginning of scan */ - recGblGetTimeStamp(pscan); - initScan(pscan); - } - - /* Before Scan Fwd Link is complete, initScan again */ - else if(precPvt->phase == BEFORE_SCAN) { - initScan(pscan); - } - - else if ((pscan->pxsc == 1) && (pscan->exsc == 0)) { - sprintf(pscan->smsg,"Scan aborted by operator"); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - endScan(pscan); - } - - else if (pscan->exsc == 1) { - if(precPvt->badOutputPv) { - pscan->alrt = 1; - db_post_events(pscan,&pscan->alrt, DBE_VALUE); - sprintf(pscan->smsg,"Lost connection to Control PV"); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - pscan->exsc = 0; - db_post_events(pscan,&pscan->exsc, DBE_VALUE); - endScan(pscan); - } - else { - contScan(pscan); - } - } - - checkMonitors(pscan); - - /* do forward link on last scan aquisition */ - if ((pscan->pxsc == 1) && (pscan->exsc == 0)) { - recGblFwdLink(pscan); /* process the forward scan link record */ - if(recScanDebug) { - printf("Scan Time = %.2f ms\n", - (float)((tickGet()-(precPvt->tickStart))*16.67)); - } - - } - - pscan->pxsc = pscan->exsc; - recGblResetAlarms(pscan); - - pscan->pact = FALSE; - return(status); -} - -static long special(paddr,after) - struct dbAddr *paddr; - int after; -{ - struct scanRecord *pscan = (struct scanRecord *)(paddr->precord); - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - recDynLinkPvt *puserPvt; - posFields *pPosFields; - int special_type = paddr->special; - char *ppvn[PVN_SIZE]; - unsigned short *pPvStat; - unsigned short oldStat; - short i = -1; - long status; - unsigned char prevAlrt; - - if(!after) { - precPvt->pffo = pscan->ffo; /* save previous ffo flag */ - return(0); - } - - if(recScanDebug > 5) printf("special(),special_type = %d\n",special_type); - switch(special_type) { - case(SPC_MOD): - if(paddr->pfield==(void *)&pscan->exsc) { - /* If aborting, scanOnce immediately */ - if(!pscan->exsc) { - scanOnce(pscan); - /* If .EXSC, only scanOnce if IDLE OR PREVIEW */ - } else if((precPvt->phase == IDLE) || (precPvt->phase == PREVIEW)) { - checkConnections(pscan); - if(precPvt->badOutputPv || precPvt->badInputPv) { - /* postpone the scan for 5 seconds via watchdog */ - pscan->alrt = 1; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - strcpy(pscan->smsg,"Some PV's not connected ..."); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - precPvt->phase = SCAN_PENDING; - wdStart(precPvt->wd_id,(3 * sysClkRateGet()), - (FUNCPTR)callbackRequest, - (int)(&precPvt->doPutsCallback)); - } - else { - pscan->alrt = 0; - db_post_events(pscan,&pscan->alrt, DBE_VALUE); - scanOnce(pscan); - } - } - return(0); - } else if(paddr->pfield==(void *)&pscan->cmnd) { - if(pscan->cmnd == CLEAR_MSG) { - pscan->alrt = 0; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - strcpy(pscan->smsg,""); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - } - else if((pscan->cmnd == CHECK_LIMITS) && !(pscan->exsc)) { - prevAlrt = pscan->alrt; - pscan->alrt = 0; - checkScanLimits(pscan); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(pscan->alrt != prevAlrt) { - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - } - else if((pscan->cmnd == PREVIEW_SCAN) && !(pscan->exsc)) { - /* get_array_info() needs to know that we're previewing */ - precPvt->phase = PREVIEW; - previewScan(pscan); - } - else if(((pscan->cmnd == CLEAR_RECORD) || - (pscan->cmnd == CLEAR_POSITIONERS)) && - !(pscan->exsc)) { - /* clear PV's, frzFlags, modes, etc */ - pscan->scan = 0; - db_post_events(pscan,&pscan->scan,DBE_VALUE); - resetFrzFlags(pscan); - pscan->p1sm = 0; - db_post_events(pscan,&pscan->p1sm,DBE_VALUE); - pscan->p1ar = 0; - db_post_events(pscan,&pscan->p1ar,DBE_VALUE); - pscan->p2sm = 0; - db_post_events(pscan,&pscan->p2sm,DBE_VALUE); - pscan->p2ar = 0; - db_post_events(pscan,&pscan->p2ar,DBE_VALUE); - pscan->p3sm = 0; - db_post_events(pscan,&pscan->p3sm,DBE_VALUE); - pscan->p3ar = 0; - db_post_events(pscan,&pscan->p3ar,DBE_VALUE); - pscan->p4sm = 0; - db_post_events(pscan,&pscan->p4sm,DBE_VALUE); - pscan->p4ar = 0; - db_post_events(pscan,&pscan->p4ar,DBE_VALUE); - pscan->pasm = 0; - db_post_events(pscan,&pscan->pasm,DBE_VALUE); - pscan->ffo = 0; - db_post_events(pscan,&pscan->ffo,DBE_VALUE); - for(i=0; icaLinkStruct[i].puserPvt; - if((pscan->cmnd == CLEAR_RECORD) || - ((pscan->cmnd == CLEAR_POSITIONERS) && - (puserPvt->linkType == POSITIONER))) { - /* clear this PV */ - pPvStat = &pscan->p1nv + i; /* pointer arithmetic */ - oldStat = *pPvStat; - *ppvn = &pscan->p1pv[0] + (i*PVN_SIZE); - *ppvn[0] = NULL; - db_post_events(pscan,*ppvn,DBE_VALUE); - if(*pPvStat != NO_PV) { - /* PV is now NULL but didn't used to be */ - *pPvStat = NO_PV; /* PV just cleared */ - if(*pPvStat != oldStat) { - db_post_events(pscan,pPvStat,DBE_VALUE); - } - if(puserPvt->dbAddrNv) { /*Clear if non-local */ - recDynLinkClear(&precPvt->caLinkStruct[i]); - /* Positioners have two recDynLinks */ - if(icaLinkStruct[i+NUM_PVS]); - } - else puserPvt->dbAddrNv = -1; - } - else { - /* PV is NULL, but previously MAY have been "time" */ - puserPvt->ts = 0; - } - } - } - } - else if(paddr->pfield==(void *)&pscan->prio) { - callbackSetPriority(pscan->prio, &precPvt->doPutsCallback); - return(0); - } - return(0); - } - /* Check to see if it was a command to send to the positioner */ - else if(paddr->pfield==(void *)&pscan->p1dv) i = P1_IN; - else if(paddr->pfield==(void *)&pscan->p2dv) i = P2_IN; - else if(paddr->pfield==(void *)&pscan->p3dv) i = P3_IN; - else if(paddr->pfield==(void *)&pscan->p4dv) i = P4_IN; - - /* if a positioner command and not scanning .... */ - if((i>=0) && ((precPvt->phase==IDLE) || (precPvt->phase==PREVIEW))) { - pPvStat = &precPvt->pscan->p1nv + i; - pPosFields = (posFields *)&precPvt->pscan->p1pp + i; - if(*pPvStat == PV_OK) { - puserPvt = precPvt->caLinkStruct[i].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[i+P1_OUT], - &(pPosFields->p_dv), 1); - } else { - /* Must use the callback task ... */ - precPvt->movPos[i] = 1; - callbackRequest(&precPvt->doPutsCallback); - } - } - } - - - break; - - case(SPC_SC_MO): /* Step Mode changed for a positioner */ - - pPosFields = (posFields *)&precPvt->pscan->p1pp; - for(i=0; ipfield==(void *)&pPosFields->p_sm) { - /* Entering Table mode ? */ - if((pPosFields->p_sm == REC_SCAN_MO_TAB) && - (precPvt->prevSm[i] != REC_SCAN_MO_TAB)) { - savePosParms(pscan, (unsigned short) i); - zeroPosParms(pscan, (unsigned short) i); - precPvt->prevSm[i] = pPosFields->p_sm; - if(precPvt->tablePts[i] < pscan->npts) { - sprintf(pscan->smsg,"Pts in P%d Table < # of Steps",i+1); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(!pscan->alrt) { - pscan->alrt = 1; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - } - } - /* Leaving Table mode ? */ - else if((pPosFields->p_sm != REC_SCAN_MO_TAB) && - (precPvt->prevSm[i] == REC_SCAN_MO_TAB)) { - restorePosParms(pscan, (unsigned short) i); - prevAlrt = pscan->alrt; - precPvt->nptsCause = -1; - changedNpts(pscan); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(pscan->alrt != prevAlrt) { - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - precPvt->prevSm[i] = pPosFields->p_sm; - } - } - } - break; - - case(SPC_SC_S): /* linear scan parameter change */ - case(SPC_SC_I): - case(SPC_SC_E): - case(SPC_SC_C): - case(SPC_SC_W): - /* resolve linear scan parameters affected by this fields change */ - prevAlrt = pscan->alrt; - pscan->alrt = 0; - strcpy(pscan->smsg,""); - adjLinParms(paddr); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(pscan->alrt != prevAlrt) { - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - if(recScanViewPos) { - previewScan(pscan); - } - break; - - case(SPC_SC_N): - /* adjust all linear scan parameters per new # of steps */ - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - db_post_events(pscan,&pscan->npts,DBE_VALUE); - } - prevAlrt = pscan->alrt; - pscan->alrt = 0; - strcpy(pscan->smsg,""); - precPvt->nptsCause = -1; /* resolve all positioner parameters */ - changedNpts(pscan); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(pscan->alrt != prevAlrt) { - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - if(recScanViewPos) { - previewScan(pscan); - } - break; - - case(SPC_SC_FFO): - /* Freeze Flag Override field */ - if((pscan->ffo) && (!precPvt->pffo)) { - saveFrzFlags(pscan); - resetFrzFlags(pscan); - } - else if(!pscan->ffo && precPvt->pffo) /* only on 1->0 */ - restoreFrzFlags(pscan); - - break; - - case(SPC_SC_F): - /* Freeze Flag Override field */ - if(pscan->ffo) - resetFrzFlags(pscan); - - break; - - - default: - /* Check for a dynamic link PV change */ - if((special_type >= FIRST_PV) && (special_type <= LAST_PV)) { - i = special_type - FIRST_PV; - puserPvt = (recDynLinkPvt *)precPvt->caLinkStruct[i].puserPvt; - pPvStat = &pscan->p1nv + i; /* pointer arithmetic */ - oldStat = *pPvStat; - *ppvn = &pscan->p1pv[0] + (i*PVN_SIZE); - if(*ppvn[0] != NULL) { - if(recScanDebug > 5) printf("Search during special \n"); - *pPvStat = PV_NC; - /* force flags to indicate PV_NC until callback happens */ - if((ibadOutputPv = 1; - } - else { - precPvt->badInputPv = 1; - } - /* need to post_event before recDynLinkAddXxx because - SearchCallback could happen immediatley */ - if(*pPvStat != oldStat) { - db_post_events(pscan,pPvStat,DBE_VALUE); - } - lookupPV(pscan, i); - } - else if(*pPvStat != NO_PV) { - /* PV is now NULL but didn't used to be */ - *pPvStat = NO_PV; /* PV just cleared */ - if(*pPvStat != oldStat) { - db_post_events(pscan,pPvStat,DBE_VALUE); - } - if(puserPvt->dbAddrNv) { /*Clear if non-local */ - recDynLinkClear(&precPvt->caLinkStruct[i]); - /* Positioners have two recDynLinks */ - if(icaLinkStruct[i+NUM_PVS]); - } - else puserPvt->dbAddrNv = -1; - } - else { - /* PV is NULL, but previously MAY have been "time" */ - puserPvt->ts = 0; - } - } - } -return(0); -} - -static long cvt_dbaddr(paddr) - struct dbAddr *paddr; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - - posFields *pPosFields = (posFields *)&pscan->p1pp; - detFields *pDetFields = (detFields *)&pscan->d1hr; - short fieldOffset; - unsigned short i; - - fieldOffset = ((dbFldDes *)(paddr->pfldDes))->offset; - - /* for the double buffered arrays, must use the field offset - because you don't know what the pointer will be */ - - for(i=0; i < NUM_DET; i++, pDetFields++) { - if(((char *)&pDetFields->d_da - (char *)pscan) == fieldOffset) { - paddr->pfield = pDetFields->d_da; - paddr->no_elements = pscan->mpts; - paddr->field_type = DBF_FLOAT; - paddr->field_size = sizeof(float); - paddr->dbr_field_type = DBF_FLOAT; - return(0); - } - } - - for(i=0; i < NUM_POS; i++, pPosFields++) { - if(((char *)&pPosFields->p_pa - (char *)pscan) == fieldOffset) { - paddr->pfield = (void *)(pPosFields->p_pa); - paddr->no_elements = pscan->mpts; - paddr->field_type = DBF_DOUBLE; - paddr->field_size = sizeof(double); - paddr->dbr_field_type = DBF_DOUBLE; - } else if(((char *)&pPosFields->p_ra - (char *)pscan) == fieldOffset) { - paddr->pfield = (void *)(pPosFields->p_ra); - paddr->no_elements = pscan->mpts; - paddr->field_type = DBF_DOUBLE; - paddr->field_size = sizeof(double); - paddr->dbr_field_type = DBF_DOUBLE; - } - } - return(0); -} - -static long get_array_info(paddr,no_elements,offset) - struct dbAddr *paddr; - long *no_elements; - long *offset; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - detFields *pDetFields = (detFields *)&pscan->d1hr; - posFields *pPosFields = (posFields *)&pscan->p1pp; - short fieldOffset; - unsigned short *pPvStat; - unsigned short i; - - /* This routine is called because someone wants an array. Determine - which array they are interested by comparing the address of the - field to the array pointers */ - - fieldOffset = ((dbFldDes *)(paddr->pfldDes))->offset; - - pPvStat = &precPvt->pscan->d1nv; - for(i=0; i < NUM_DET; i++, pDetFields++, pPvStat++) { - if(((char *)&pDetFields->d_da - (char *)pscan) == fieldOffset) { - if((precPvt->acqDet[i]) || - ((iphase == PREVIEW))) { - if(precPvt->validBuf) - paddr->pfield = precPvt->detBufPtr[i].pBufB; - else - paddr->pfield = precPvt->detBufPtr[i].pBufA; - } else { - paddr->pfield = precPvt->nullArray; - } - *no_elements = pscan->mpts; - *offset = 0; - return(0); - } - } - for(i=0; i < NUM_POS; i++, pPosFields++) { - if(((char *)&pPosFields->p_ra - (char *)pscan) == fieldOffset) { - if(precPvt->validBuf) - paddr->pfield = precPvt->posBufPtr[i].pBufB; - else - paddr->pfield = precPvt->posBufPtr[i].pBufA; - - *no_elements = pscan->mpts; - *offset = 0; - return(0); - } - } - - if (paddr->pfield == pscan->p1pa) { - *no_elements = pscan->mpts; - *offset = 0; - } else if (paddr->pfield == pscan->p2pa) { - *no_elements = pscan->mpts; - *offset = 0; - } else if (paddr->pfield == pscan->p3pa) { - *no_elements = pscan->mpts; - *offset = 0; - } else if (paddr->pfield == pscan->p4pa) { - *no_elements = pscan->mpts; - *offset = 0; - } else { - *no_elements = 0; - *offset = 0; - } - - return(0); -} - -static long put_array_info(paddr,nNew) - struct dbAddr *paddr; - long nNew; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp; - short fieldOffset; - unsigned short i; - - /* This routine is called because someone wrote a table to the - "positioner" array p_pa. Determine which positioner and store - nelem for future use. Also check against current npts */ - - fieldOffset = ((dbFldDes *)(paddr->pfldDes))->offset; - - for(i=0; i < NUM_POS; i++, pPosFields++) { - if(((char *)&pPosFields->p_pa - (char *)pscan) == fieldOffset) { - precPvt->tablePts[i] = nNew; - if(nNew < pscan->npts) { - sprintf(pscan->smsg,"Pts in P%d Table < # of Steps", i+1); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(!pscan->alrt) { - pscan->alrt = 1; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - } else { - strcpy(pscan->smsg,""); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(pscan->alrt) { - pscan->alrt = 0; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - } - return(0); - } - } - return(0); -} - - -static long get_enum_str(paddr,pstring) - struct dbAddr *paddr; - char *pstring; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - - if(paddr->pfield==(void *)&pscan->cmnd) - { - sprintf(pstring, "%d",pscan->cmnd); - } - else - { - strcpy(pstring,"No string"); - } - return(0); -} -static long get_enum_strs(paddr,pes) - struct dbAddr *paddr; - struct dbr_enumStrs *pes; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - - if(paddr->pfield==(void *)&pscan->cmnd) - { - memset(pes->strs,'\0',sizeof(pes->strs)); - strncpy(pes->strs[0],"0-Clear Msg",sizeof("0-Clear Msg")); - strncpy(pes->strs[1],"1-Check Limits",sizeof("1-Check Limits")); - pes->no_str = 2; - } - else - { - strcpy(pes->strs[0],"No string"); - pes->no_str=1; - } - - return(0); -} - -static long put_enum_str(paddr,pstring) - struct dbAddr *paddr; - char *pstring; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - - if(paddr->pfield==(void *)&pscan->cmnd) - { - if(sscanf(pstring,"%hu",&pscan->cmnd)<=0) - return(S_db_badChoice); - } - else - { - return(S_db_badChoice); - } - - return(0); -} - -static long get_units(paddr,units) - struct dbAddr *paddr; - char *units; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - posFields *pPosFields = (posFields *)&pscan->p1pp; - detFields *pDetFields = (detFields *)&pscan->d1hr; - short fieldOffset; - short i; - - - /* Use the field offset to see which detector or positioner it is */ - fieldOffset = ((dbFldDes *)(paddr->pfldDes))->offset; - - for(i=0; i < NUM_POS; i++, pPosFields++) { - if((fieldOffset >= ((char *)&pPosFields->p_pp - (char *)pscan)) && - (fieldOffset <= ((char *)&pPosFields->p_pr - (char *)pscan))) { - strncpy(units, pPosFields->p_eu, 7); - units[7] = NULL; - return(0); - } - } - for(i=0; i < NUM_DET; i++, pDetFields++) { - if((fieldOffset >= ((char *)&pDetFields->d_hr - (char *)pscan)) && - (fieldOffset <= ((char *)&pDetFields->d_pr - (char *)pscan))) { - strncpy(units, pDetFields->d_eu, 7); - units[7] = NULL; - return(0); - } - } - - return(0); -} - -static long get_precision(paddr,precision) - struct dbAddr *paddr; - long *precision; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - posFields *pPosFields = (posFields *)&pscan->p1pp; - detFields *pDetFields = (detFields *)&pscan->d1hr; - short fieldOffset; - short i; - - - /* Use the field offset to see which detector or positioner it is */ - fieldOffset = ((dbFldDes *)(paddr->pfldDes))->offset; - - for(i=0; i < NUM_POS; i++, pPosFields++) { - if((fieldOffset >= ((char *)&pPosFields->p_pp - (char *)pscan)) && - (fieldOffset <= ((char *)&pPosFields->p_pr - (char *)pscan))) { - *precision = pPosFields->p_pr; - return(0); - } - } - for(i=0; i < NUM_DET; i++, pDetFields++) { - if((fieldOffset >= ((char *)&pDetFields->d_hr - (char *)pscan)) && - (fieldOffset <= ((char *)&pDetFields->d_pr - (char *)pscan))) { - *precision = pDetFields->d_pr; - return(0); - } - } - - *precision = 2; - return(0); -} - -static long get_graphic_double(paddr,pgd) - struct dbAddr *paddr; - struct dbr_grDouble *pgd; -{ - struct scanRecord *pscan=(struct scanRecord *)paddr->precord; - posFields *pPosFields = (posFields *)&pscan->p1pp; - detFields *pDetFields = (detFields *)&pscan->d1hr; - short fieldOffset; - short i; - - - /* Use the field offset to see which detector or positioner it is */ - fieldOffset = ((dbFldDes *)(paddr->pfldDes))->offset; - - for(i=0; i < NUM_POS; i++, pPosFields++) { - if((fieldOffset >= ((char *)&pPosFields->p_pp - (char *)pscan)) && - (fieldOffset <= ((char *)&pPosFields->p_pr - (char *)pscan))) { - pgd->upper_disp_limit = pPosFields->p_hr; - pgd->lower_disp_limit = pPosFields->p_lr; - return(0); - } - } - for(i=0; i < NUM_DET; i++, pDetFields++) { - if((fieldOffset >= ((char *)&pDetFields->d_hr - (char *)pscan)) && - (fieldOffset <= ((char *)&pDetFields->d_pr - (char *)pscan))) { - pgd->upper_disp_limit = pDetFields->d_hr; - pgd->lower_disp_limit = pDetFields->d_lr; - return(0); - } - } - - recGblGetGraphicDouble(paddr,pgd); - return(0); -} - -static long get_control_double(paddr,pcd) - struct dbAddr *paddr; - struct dbr_ctrlDouble *pcd; -{ - /* for testing .... */ - /* return upper_disp_limit and lower_disp_limit as control limits */ - struct dbr_grDouble grDblStruct; - long status; - - status = get_graphic_double(paddr,&grDblStruct); - pcd->upper_ctrl_limit = grDblStruct.upper_disp_limit; - pcd->lower_ctrl_limit = grDblStruct.lower_disp_limit; - - return(0); -} - -static long get_alarm_double(paddr,pad) - struct dbAddr *paddr; - struct dbr_alDouble *pad; -{ - recGblGetAlarmDouble(paddr,pad); - return(0); -} - - -static void checkMonitors(pscan) - struct scanRecord *pscan; -{ - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - detFields *pDetFields = (detFields *)&pscan->d1hr; - posFields *pPosFields = (posFields *)&pscan->p1pp; - unsigned long now; - int i; - - /* If last posting time is > MIN_MON, check to see if any dynamic fields - have changed (also post monitors on end of scan)*/ - - now=tickGet(); - if(((now - pscan->tolp) > MIN_MON) || - ((pscan->pxsc == 1) && (pscan->exsc == 0))) { - pscan->tolp = now; - - /* check all detectors */ - for(i=0; i < NUM_DET; i++, pDetFields++) { - if(fabs(pDetFields->d_lv - pDetFields->d_cv) > 0) { - db_post_events(pscan,&pDetFields->d_cv, DBE_VALUE); - pDetFields->d_lv = pDetFields->d_cv; - } - } - - /* check all positioners and readbacks */ - for(i=0; i < NUM_POS; i++, pPosFields++) { - if(fabs(pPosFields->p_lv - pPosFields->p_dv) > 0) { - db_post_events(pscan,&pPosFields->p_dv, DBE_VALUE); - pPosFields->p_lv = pPosFields->p_dv; - } - if(fabs(pPosFields->r_lv - pPosFields->r_cv) > 0) { - db_post_events(pscan,&pPosFields->r_cv, DBE_VALUE); - pPosFields->r_lv = pPosFields->r_cv; - } - } - - if(pscan->pcpt != pscan->cpt) { - db_post_events(pscan,&pscan->cpt, DBE_VALUE); - pscan->pcpt = pscan->cpt; - } - - /* Post a monitor on VAL to indicate new point */ - /* (checking pxsc skips the first pass when D_CV's are - not valid and also catches the last point after exsc == 0 */ - if(pscan->pxsc) { - db_post_events(pscan,&pscan->val, DBE_VALUE); - } - } - - /* if this is the end of a scan, post data arrays */ - /* post these with DBE_LOG option for archiver */ - if ((pscan->pxsc == 1) && (pscan->exsc == 0)) { - - /* Must post events on both pointers, since toggle */ - db_post_events(pscan,precPvt->posBufPtr[0].pBufA, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[0].pBufB, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[1].pBufA, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[1].pBufB, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[2].pBufA, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[2].pBufB, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[3].pBufA, DBE_VAL_LOG); - db_post_events(pscan,precPvt->posBufPtr[3].pBufB, DBE_VAL_LOG); - - for(i=0; idetBufPtr[i].pBufA, DBE_VAL_LOG); - db_post_events(pscan,precPvt->detBufPtr[i].pBufB, DBE_VAL_LOG); - } - /* I must also post a monitor on the NULL array, because some - clients connected to D?PV's without valid PV's ! */ - db_post_events(pscan, precPvt->nullArray, DBE_VALUE); - - /* post alert if changed */ - if(precPvt->scanErr) { - pscan->alrt = precPvt->scanErr; - db_post_events(pscan,&pscan->alrt, DBE_VALUE); - } - - if (pscan->pxsc != pscan->exsc) - db_post_events(pscan,&pscan->exsc, DBE_VALUE); - - } -} - - -/************************************************************** - * lookupPV() - * This is the routine that looks up newly entered "dynamic" - * links. A dbNameToAddr call is done first to - * see if the PV resides on this IOC. Much better performance is - * obtained by using dbGet/dbPutField rather than the recDynLink - * library for local PV's. If the dbNameToAddr fails, - * recDynLinkAddInput is used. - * - * For positioners: - * If the PV is local, the dbAddr is used for puts and gets ( - * to get the "previous positioner" before a scan starts. A - * recDynLinkInput is also used to monitor the positioner - * for changes made from other places. - * This value is stored in p_cv. - * If the PV is not local, a recDynLinkOutput and a - * recDynLinkInput are used. The recDynLinkInput has a - * monitor callback routine for p_cv, but a get is used - * to find the previous position. - * - * For Readbacks: - * If the PV name starts with TIME or time, set a flag that - * indicates that the timestamp should be used as the - * readback value. - * Otherwise, do a PV lookup. - **************************************************************/ -static void lookupPV(struct scanRecord *pscan, unsigned short i) -{ - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - recDynLinkPvt *puserPvt; - char *ppvn[PVN_SIZE]; - char *pdesc = ".DESC"; - char *pval = ".VAL"; - char *pTIME = "TIME"; - char *ptime = "time"; - char *pdot; - unsigned short *pPvStat; - - /* Point to correct places by using index i */ - *ppvn = &pscan->p1pv[0] + (i * PVN_SIZE); - pPvStat = &pscan->p1nv + i; /* pointer arithmetic */ - puserPvt = (recDynLinkPvt *)precPvt->caLinkStruct[i].puserPvt; - - /* If PV field name = DESC, change to VAL */ - pdot = strrchr(*ppvn, '.'); - if(pdot!=NULL) { - if(strncmp(pdot, pdesc, 5) == 0) { - strcpy(pdot, pval); - db_post_events(pscan, *ppvn, DBE_VALUE); - } - } - - /* See if it's a local PV */ - puserPvt->dbAddrNv = dbNameToAddr(*ppvn, puserPvt->pAddr); - if(recScanDebug) { - printf("PV: %s ,dbNameToAddr returned %lx\n",*ppvn, puserPvt->dbAddrNv); - } - - switch(puserPvt->linkType) { - case POSITIONER: - if(puserPvt->dbAddrNv) { - recDynLinkAddOutput(&precPvt->caLinkStruct[i+NUM_PVS], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback); - recDynLinkAddInput(&precPvt->caLinkStruct[i], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback, posMonCallback); - }else { - /* Add a monitor anyway, so p_cv can be kept up to date */ - recDynLinkAddInput(&precPvt->caLinkStruct[i], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback, posMonCallback); - } - break; - - case READBACK: - /* Check to see if it equals "time" */ - if((strncmp(*ppvn, pTIME, 4)==0) || (strncmp(*ppvn, ptime, 4)==0)) { - puserPvt->ts = 1; - *pPvStat = NO_PV; - db_post_events(pscan, pPvStat, DBE_VALUE); - break; /* don't do lookups or pvSearchCallback */ - } else { - puserPvt->ts = 0; - } - if(puserPvt->dbAddrNv) { - recDynLinkAddInput(&precPvt->caLinkStruct[i], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback, NULL); - }else { - pvSearchCallback(&precPvt->caLinkStruct[i]); - } - break; - - case DETECTOR: - if(puserPvt->dbAddrNv) { - recDynLinkAddInput(&precPvt->caLinkStruct[i], *ppvn, - DBR_FLOAT, rdlSCALAR, pvSearchCallback, NULL); - }else { - pvSearchCallback(&precPvt->caLinkStruct[i]); - } - break; - - case TRIGGER: - case FWD_LINK: - if(puserPvt->dbAddrNv) { - recDynLinkAddOutput(&precPvt->caLinkStruct[i], *ppvn, - DBR_FLOAT, rdlSCALAR, pvSearchCallback); - }else { - pvSearchCallback(&precPvt->caLinkStruct[i]); - } - break; - } -} - - -LOCAL void pvSearchCallback(recDynLink *precDynLink) -{ - - recDynLinkPvt *puserPvt = (recDynLinkPvt *)precDynLink->puserPvt; - struct scanRecord *pscan = puserPvt->pscan; - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp; - detFields *pDetFields = (detFields *)&pscan->d1hr; - unsigned short index = puserPvt->linkIndex; - unsigned short detIndex; - unsigned short *pPvStat; - unsigned short oldValid; - size_t nelem; - long status; - long nRequest = 1; - long options = DBR_UNITS | DBR_PRECISION | DBR_GR_DOUBLE | - DBR_CTRL_DOUBLE ; - int precision; - - pPvStat = &pscan->p1nv + index; /* pointer arithmetic */ - - oldValid = *pPvStat; - if(puserPvt->dbAddrNv && recDynLinkConnectionStatus(precDynLink)) { - *pPvStat = PV_NC; - checkConnections(pscan); - if(recScanDebug) printf("Search Callback: No Connection\n"); - if(*pPvStat != oldValid) { - db_post_events(pscan, pPvStat, DBE_VALUE); - } - return; - } - else { - *pPvStat = PV_OK; - checkConnections(pscan); - if(recScanDebug) printf("Search Callback: Success\n"); - } - if(*pPvStat != oldValid) { - db_post_events(pscan, pPvStat, DBE_VALUE); - } - - /* Do other stuff, depending on the Link Type */ - switch(puserPvt->linkType) { - case POSITIONER: /* indexes 0,1,2,3 and 25,26,27,28 */ - /* Positioners have an IN and an OUT. Only do the in's */ - if(index > P4_IN) - break; - else { - pPosFields += index; - } - - /* Get control limits, precision, and egu */ - if(puserPvt->dbAddrNv) { - /* use the recDynLink lib */ - recDynLinkGetUnits(precDynLink, pPosFields->p_eu, 8); - recDynLinkGetPrecision(precDynLink, &precision); - pPosFields->p_pr = precision; - recDynLinkGetControlLimits(precDynLink, - &pPosFields->p_lr, &pPosFields->p_hr); - } else { - status = dbGet(puserPvt->pAddr, DBR_FLOAT, - precPvt->pDynLinkInfo, - &options, &nRequest, NULL); - if(status == OK) { - strcpy(pPosFields->p_eu, precPvt->pDynLinkInfo->units); - pPosFields->p_pr = precPvt->pDynLinkInfo->precision; - pPosFields->p_hr = precPvt->pDynLinkInfo->upper_ctrl_limit; - pPosFields->p_lr = precPvt->pDynLinkInfo->lower_ctrl_limit; - } - } - db_post_events(pscan,&pPosFields->p_eu, DBE_VALUE); - db_post_events(pscan,&pPosFields->p_pr, DBE_VALUE); - db_post_events(pscan,&pPosFields->p_hr, DBE_VALUE); - db_post_events(pscan,&pPosFields->p_lr, DBE_VALUE); - - break; - - case READBACK: - break; - - case DETECTOR: - /* Derive pointer to appropriate detector fields */ - detIndex = index - D1_IN; - pDetFields += detIndex; /* pointer arithmetic */ - - /* Get display limits, precision, and egu */ - if(puserPvt->dbAddrNv) { - /* use the recDynLink lib */ - recDynLinkGetUnits(precDynLink, pDetFields->d_eu, 8); - recDynLinkGetPrecision(precDynLink, &precision); - pDetFields->d_pr = precision; - recDynLinkGetGraphicLimits(precDynLink, - &pDetFields->d_lr, &pDetFields->d_hr); - } else { - status = dbGet(puserPvt->pAddr, DBR_FLOAT, - precPvt->pDynLinkInfo, - &options, &nRequest, NULL); - if(status == OK) { - strcpy(pDetFields->d_eu, precPvt->pDynLinkInfo->units); - pDetFields->d_pr = precPvt->pDynLinkInfo->precision; - pDetFields->d_hr = precPvt->pDynLinkInfo->upper_disp_limit; - pDetFields->d_lr = precPvt->pDynLinkInfo->lower_disp_limit; - } - } - db_post_events(pscan,&pDetFields->d_eu, DBE_VALUE); - db_post_events(pscan,&pDetFields->d_pr, DBE_VALUE); - db_post_events(pscan,&pDetFields->d_hr, DBE_VALUE); - db_post_events(pscan,&pDetFields->d_lr, DBE_VALUE); - - /* get # of elements, re-allocate array as necessary */ - if(puserPvt->dbAddrNv) { - status = recDynLinkGetNelem(precDynLink, &nelem); - } - else { - nelem = puserPvt->pAddr->no_elements; - } - - if(nelem > 1) { - printf("NOT READY FOR VECTORS YET !!!\n"); - nelem = 1; /* force it to be a scalar for now */ - } - if(nelem > puserPvt->nelem) { - /* - if(puserPvt->nelem) { - printf("Freeing memory for dynLink %d \n", index); - free(pDetFields->d_da); - } - */ - - printf("Allocating memory for dynLink %d\n ", index); - pDetFields->d_da=(float *)calloc(pscan->mpts*nelem,sizeof(float)); - precPvt->detBufPtr[detIndex].pBufA = - (float *) calloc(pscan->mpts, sizeof(float)); - precPvt->detBufPtr[detIndex].pBufB = - (float *) calloc(pscan->mpts, sizeof(float)); - - if(!(precPvt->detBufPtr[detIndex].pBufA) || - !(precPvt->detBufPtr[detIndex].pBufB)) { - /* MEMORY ALLOCATION FAILED */ - printf("MEMORY ALLOCATION FAILED \n"); - puserPvt->nelem = 0; - } - else { - puserPvt->nelem = nelem; - if(precPvt->validBuf) - precPvt->detBufPtr[detIndex].pFill = - precPvt->detBufPtr[detIndex].pBufA; - else - precPvt->detBufPtr[detIndex].pFill = - precPvt->detBufPtr[detIndex].pBufB; - } - } - break; - - case TRIGGER: - case FWD_LINK: - break; - } - - -} - -LOCAL void posMonCallback(recDynLink *precDynLink) -{ - - recDynLinkPvt *puserPvt = (recDynLinkPvt *)precDynLink->puserPvt; - struct scanRecord *pscan = puserPvt->pscan; - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - unsigned short index = puserPvt->linkIndex; - posFields *pPosFields = (posFields *)&pscan->p1pp + index; - long status; - size_t nRequest = 1; - - - /* update p_cv with current positioner value */ - /* NOTE: For fast scans, these will get lost, because it is the low - priority channel access task that is doing these callbacks */ - status = recDynLinkGet(&precPvt->caLinkStruct[index], - &pPosFields->p_cv, &nRequest, 0, 0, 0); - db_post_events(pscan,&pPosFields->p_cv, DBE_VALUE); -} - - -static void checkConnections(struct scanRecord *pscan) -{ - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - unsigned short *pPvStat; - unsigned char badOutputPv = 0; - unsigned char badInputPv = 0; - unsigned short i; - - pPvStat = &pscan->p1nv; - - for(i=1; i <= NUM_POS; i++, pPvStat++) { - if(*pPvStat == PV_NC) badOutputPv = 1; - } - /* let pPvStat continue to increment into Readbacks */ - for(i=1; i <= NUM_POS; i++, pPvStat++) { - if(*pPvStat == PV_NC) badOutputPv = 1; - } - /* let pPvStat continue to increment into Detectors */ - for(i=1; i <= NUM_DET; i++, pPvStat++) { - if(*pPvStat == PV_NC) badInputPv = 1; - } - /* let pPvStat continue to increment into Triggers */ - for(i=1; i <= NUM_TRGS; i++, pPvStat++) { - if(*pPvStat == PV_NC) badOutputPv = 1; - } - - precPvt->badOutputPv = badOutputPv; - precPvt->badInputPv = badInputPv; -} - - - -/********************** SCAN Initialization ********************************/ -/* - * If a "Before Scan Link PV" is defined, this routine will be called twice, - * once before the link is processed and once after. The starting positions - * and limits are calculated each time, in case the link caused something to - * change. - * - */ -static long initScan(pscan) -struct scanRecord *pscan; -{ - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields; - long status; - unsigned short *pPvStat; - int i; - - - /* General initialization ... */ - if(recScanDebug) { - precPvt->tickStart = tickGet(); - } - - pscan->cpt = 0; /* reset point counter */ - precPvt->scanErr = 0; - - /* determine highest valid positioner, readback, trigger, and detector */ - precPvt->valPosPvs = 0; - precPvt->valRdbkPvs = 0; - precPvt->valDetPvs = 0; - precPvt->valTrigPvs = 0; - pPvStat = &pscan->p1nv; - - for(i=1; i <= NUM_POS; i++, pPvStat++) { - if(*pPvStat == PV_OK) precPvt->valPosPvs = i; - } - /* let pPvStat continue to increment into Readbacks */ - for(i=1; i <= NUM_POS; i++, pPvStat++) { - if(*pPvStat == PV_OK) precPvt->valRdbkPvs = i; - } - /* let pPvStat continue to increment into Detectors */ - /* flag which detectors should be acquired during scan */ - for(i=1; i <= NUM_DET; i++, pPvStat++) { - if(*pPvStat == PV_OK) { - precPvt->valDetPvs = i; - precPvt->acqDet[i-1] = 1; - } - else { - precPvt->acqDet[i-1] = 0; - } - } - /* let pPvStat continue to increment into Triggers */ - for(i=1; i <= NUM_TRGS; i++, pPvStat++) { - if(*pPvStat == PV_OK) precPvt->valTrigPvs = i; - } - - /* if more readbacks than positioners, set valPosPvs to valRdbkPvs */ - if(precPvt->valRdbkPvs > precPvt->valPosPvs) { - precPvt->valPosPvs = precPvt->valRdbkPvs; - } - - if(recScanDebug > 10) { - printf("Positioners : %u\n",precPvt->valPosPvs); - printf("Readbacks : %u\n",precPvt->valRdbkPvs); - printf("Detectors : %u\n",precPvt->valDetPvs); - printf("Triggers : %u\n",precPvt->valTrigPvs); - } - - /* checkScanLimits must be called to update the current value of each - positioner into p_pp. If recScanDontCheckLimits is set, it will return - successful w/o actually checking */ - - if((status = checkScanLimits(pscan))) { - pscan->exsc = 0; /* limits didn't pass, abort scan */ - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - db_post_events(pscan,&pscan->exsc,DBE_VALUE); - precPvt->phase = IDLE; - return(status); - } - - /* Then calculate the starting position */ - precPvt->onTheFly = 0; /* clear onTheFly flag */ - pPvStat = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; i < precPvt->valPosPvs; i++, pPosFields++, pPvStat++) { - if(*pPvStat == PV_OK) { - /* Figure out starting positions for each positioner */ - if(pPosFields->p_sm == REC_SCAN_MO_TAB) { - if(pPosFields->p_ar) { - pPosFields->p_dv = pPosFields->p_pp + pPosFields->p_pa[0]; - } - else { - pPosFields->p_dv = pPosFields->p_pa[0]; - } - } - else { - if(pPosFields->p_ar) { - pPosFields->p_dv = pPosFields->p_pp + pPosFields->p_sp; - } - else { - pPosFields->p_dv = pPosFields->p_sp; - } - } - db_post_events(pscan,&pPosFields->p_dv,DBE_VALUE); - if(pPosFields->p_sm == REC_SCAN_MO_OTF) { - precPvt->onTheFly |= 1; /* set flag if onTheFly */ - } - } - } - - if((pscan->bsnv == PV_OK) && (precPvt->phase == INIT_SCAN)) { - precPvt->phase = BEFORE_SCAN; - sprintf(pscan->smsg,"Before Scan FLNK ..."); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - } - else { - precPvt->phase = MOVE_MOTORS; - sprintf(pscan->smsg,"Scanning ..."); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - } - /* request callback to do dbPutFields */ - callbackRequest(&precPvt->doPutsCallback); - return(OK); -} - -static void contScan(pscan) -struct scanRecord *pscan; -{ - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp; - detFields *pDetFields = (detFields *)&pscan->d1hr; - recDynLinkPvt *puserPvt; - TS_STAMP currentTs; - unsigned short *pPvStat; - unsigned short *pPvStatPos; - unsigned short i; - long status; - size_t nRequest = 1; - - switch (precPvt->phase) { - case TRIG_DETCTRS: - /* go output to detector trigger fields */ - callbackRequest(&precPvt->doPutsCallback); - return; - - case CHECK_MOTORS: - if(recScanDebug >=5) { - printf("CHECK_MOTORS - Point %d\n",precPvt->pscan->cpt); - } - /* check if a readback PV and a delta are specified */ - pPvStat = &pscan->r1nv; - pPvStatPos = &pscan->p1nv; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStatPos++, pPvStat++) { - if((pPosFields->r_dl != 0) && - (*pPvStat == PV_OK) && - (*pPvStatPos == PV_OK)) { - puserPvt = precPvt->caLinkStruct[i+NUM_POS].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkGet(&precPvt->caLinkStruct[i+NUM_POS], - &pPosFields->r_cv, &nRequest, 0, 0, 0); - } - else { - status = dbGet(puserPvt->pAddr,DBR_DOUBLE, &pPosFields->r_cv, - 0,0,NULL); - } - - if((pPosFields->r_dl > 0) && - (fabs(pPosFields->p_dv-pPosFields->r_cv) > pPosFields->r_dl)) { - sprintf(pscan->smsg,"SCAN Aborted: P1 Readback > delta"); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - precPvt->scanErr = 1; - endScan(pscan); - return; - } - } - } - - /* if there is a valid detector trigger ... */ - /* AND we are NOT in onTheFly */ - /* OR we are doing Point 0 */ - /* go trigger detectors and wait for the next process */ - if(precPvt->valTrigPvs && (!precPvt->onTheFly || (pscan->cpt==0))) { - /* do detector trigger fields */ - precPvt->phase = TRIG_DETCTRS; - callbackRequest(&precPvt->doPutsCallback); - return; - } - - /* if no validTrigPvs, fall through to READ_DETCTRS */ - /* if on-the-fly mode, fall through to READ_DETCTRS */ - - case READ_DETCTRS: - if(recScanDebug >=5) { - printf("READ_DETCTRS - Point %d\n",precPvt->pscan->cpt); - } - /* Store the appropriate value into the positioner readback array */ - /* from RxCV or PxDV or TIME */ - pPvStat = &pscan->r1nv; - pPvStatPos = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStatPos++, pPvStat++) { - /* if readback PV is OK, use that value */ - if(*pPvStat == PV_OK) { - puserPvt = precPvt->caLinkStruct[i+NUM_POS].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkGet(&precPvt->caLinkStruct[i+NUM_POS], - &pPosFields->r_cv, &nRequest, 0, 0, 0); - } - else { - status = dbGet(puserPvt->pAddr,DBR_DOUBLE, &pPosFields->r_cv, - 0,0,NULL); - } - - precPvt->posBufPtr[i].pFill[pscan->cpt] = pPosFields->r_cv; - - } - - /* Does the readback PV = "time" ? */ - else if(((recDynLinkPvt *) - (precPvt->caLinkStruct[i+NUM_POS].puserPvt))->ts) { - TSgetTimeStamp((int)precPvt->pscan->tse, - (struct timespec*)¤tTs); - TsDiffAsDouble(&pPosFields->r_cv, ¤tTs, &pscan->time); - precPvt->posBufPtr[i].pFill[pscan->cpt] = pPosFields->r_cv; - } - - /* Is the positioner PV valid ? */ - else if(*pPvStatPos == PV_OK) { - /* stuff array with desired value */ - /* if onTheFly and cpt>0,add the step increment to the previous*/ - if((pPosFields->p_sm != REC_SCAN_MO_OTF) || (pscan->cpt == 0)) { - pPosFields->r_cv = pPosFields->p_dv; - precPvt->posBufPtr[i].pFill[pscan->cpt] = pPosFields->r_cv; - } else { - pPosFields->r_cv = - precPvt->posBufPtr[i].pFill[pscan->cpt-1] + pPosFields->p_si; - precPvt->posBufPtr[i].pFill[pscan->cpt] = pPosFields->r_cv; - } - } - else { - /* Neither PV is valid, store a 0 */ - pPosFields->r_cv = 0; - precPvt->posBufPtr[i].pFill[pscan->cpt] = pPosFields->r_cv; - } - } - - /* read each valid detector PV, place data in buffered array */ - status = 0; - pPvStat = &pscan->d1nv; - pDetFields = (detFields *)&pscan->d1hr; - for(i=0; i < precPvt->valDetPvs; i++, pDetFields++, pPvStat++) { - if(precPvt->acqDet[i] && (precPvt->detBufPtr[i].pFill != NULL)) { - if(*pPvStat == PV_OK) { - puserPvt = precPvt->caLinkStruct[i+D1_IN].puserPvt; - if(puserPvt->dbAddrNv) { - status |= recDynLinkGet(&precPvt->caLinkStruct[i+D1_IN], - &pDetFields->d_cv, &nRequest, 0, 0, 0); - } - else { - status |= dbGet(puserPvt->pAddr, DBR_FLOAT, &pDetFields->d_cv, - 0,0, NULL); - } - } - else { - pDetFields->d_cv = 0; - } - precPvt->detBufPtr[i].pFill[pscan->cpt] = pDetFields->d_cv; - } - } - - pscan->udf=0; - - pscan->cpt++; - /* Has number of points been reached ? */ - if(pscan->cpt < (pscan->npts)) { - /* determine next desired position for each positioner */ - pPosFields = (posFields *)&pscan->p1pp; - pPvStat = &pscan->p1nv; - - /* figure out next position */ - for(i=0; i < precPvt->valPosPvs; i++, pPosFields++, pPvStat++) { - if(*pPvStat == PV_OK) { - switch(pPosFields->p_sm) { - case REC_SCAN_MO_LIN: - pPosFields->p_dv = pPosFields->p_dv + pPosFields->p_si; - break; - case REC_SCAN_MO_TAB: - if(pPosFields->p_ar) { - pPosFields->p_dv = pPosFields->p_pp + - pPosFields->p_pa[pscan->cpt]; - } - else { - pPosFields->p_dv = pPosFields->p_pa[pscan->cpt]; - } - break; - case REC_SCAN_MO_OTF: - if(pPosFields->p_ar) { - pPosFields->p_dv = pPosFields->p_pp + - pPosFields->p_ep; - } - else { - pPosFields->p_dv = pPosFields->p_ep; - } - break; - } - } - } - - /* request callback to move motors to new positions */ - precPvt->phase = MOVE_MOTORS; - /* For onTheFly, it will fall through to TRIG_DETCTRS */ - /* after MOVE_MOTORS */ - callbackRequest(&precPvt->doPutsCallback); - return; - } - else { - endScan(pscan); /* scan is successfully complete */ - sprintf(pscan->smsg,"SCAN Complete"); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - precPvt->scanErr = 0; - return; - } - } -} - -static void endScan(pscan) -struct scanRecord *pscan; -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - int counter; - unsigned short *pPvStat, i; - detFields *pDetFields; - - - /* Done with scan. Do we want to fill the remainder of the - array with 0 or something ? */ - /* It turns out that medm plots the whole array, so for it - to look right the remainder of the arrays will be filled - with the last values. This will cause medm to plot the - same point over and over again, but it will look correct */ - - counter = pscan->cpt; - if(recScanDebug) { - printf("endScan(): Fill Counter - %d\n",counter); - } - while (counter < pscan->mpts) { - /* Fill valid detector arrays with last value */ - pDetFields = (detFields *)&pscan->d1hr; - pPvStat = &pscan->d1nv; - for(i=0; i < precPvt->valDetPvs; i++, pDetFields++, pPvStat++) { - if(precPvt->acqDet[i]) { - precPvt->detBufPtr[i].pFill[counter] = pDetFields->d_cv; - } - } - /* Fill in the readback arrays with last values */ - precPvt->posBufPtr[0].pFill[counter] = - precPvt->posBufPtr[0].pFill[counter-1]; - - precPvt->posBufPtr[1].pFill[counter] = - precPvt->posBufPtr[1].pFill[counter-1]; - - precPvt->posBufPtr[2].pFill[counter] = - precPvt->posBufPtr[2].pFill[counter-1]; - - precPvt->posBufPtr[3].pFill[counter] = - precPvt->posBufPtr[3].pFill[counter-1]; - - counter++; - } - - /* Switch validBuf flag and fill pointers */ - if(precPvt->validBuf == A_BUFFER) { - precPvt->validBuf = B_BUFFER; - precPvt->posBufPtr[0].pFill = precPvt->posBufPtr[0].pBufA; - precPvt->posBufPtr[1].pFill = precPvt->posBufPtr[1].pBufA; - precPvt->posBufPtr[2].pFill = precPvt->posBufPtr[2].pBufA; - precPvt->posBufPtr[3].pFill = precPvt->posBufPtr[3].pBufA; - for(i=0; i < NUM_DET; i++) { - precPvt->detBufPtr[i].pFill = precPvt->detBufPtr[i].pBufA; - } - } else { - precPvt->validBuf = A_BUFFER; - precPvt->posBufPtr[0].pFill = precPvt->posBufPtr[0].pBufB; - precPvt->posBufPtr[1].pFill = precPvt->posBufPtr[1].pBufB; - precPvt->posBufPtr[2].pFill = precPvt->posBufPtr[2].pBufB; - precPvt->posBufPtr[3].pFill = precPvt->posBufPtr[3].pBufB; - for(i=0; i < NUM_DET; i++) { - precPvt->detBufPtr[i].pFill = precPvt->detBufPtr[i].pBufB; - } - } - - pscan->exsc = 0; /* done with scan */ - - /* Check the "after scan flag to see what to do about the positioners */ - /* Also see if there is an After Scan Link to process */ - - if(pscan->pasm || (pscan->asnv == PV_OK)) { - precPvt->phase = AFTER_SCAN; - /* request callback to do dbPutFields */ - callbackRequest(&precPvt->doPutsCallback); - } - else { - precPvt->phase = IDLE; - } - return; - -} - - -/**************************************************************************** - * - * This is the code that is executed to initiate the next - * step in the scan or trigger detectors (does the "puts" to the - * reassignable links). Since the recDynLinkPut request is actually - * done with a separate task, one need not worry about lock sets. - * - * Note that the argument (which is the address of the CALLBACK structure), - * is interpreted to be a pointer to the record private area. - * - ***************************************************************************/ -void doPuts(precPvt) - recPvtStruct *precPvt; -{ - struct scanRecord *pscan = precPvt->pscan; - recDynLinkPvt *puserPvt; - posFields *pPosFields; - unsigned short *pPvStat; - int i; - long status; - - switch (precPvt->phase) { - case MOVE_MOTORS: - if(recScanDebug >=5) { - printf("MOVE_MOTORS - Point %d\n",precPvt->pscan->cpt); - } - /* Schedule the next phase as CHECK_MOTORS */ - precPvt->phase = CHECK_MOTORS; - - pPosFields = (posFields *)&precPvt->pscan->p1pp; - pPvStat = &precPvt->pscan->p1nv; - - /* for each valid positioner, write the desired position */ - /* if positioner is "on-the-fly", only write if step 0 or 1 */ - for(i=0; i < precPvt->valPosPvs; i++, pPosFields++, pPvStat++) { - if((*pPvStat == PV_OK) && - (!((pPosFields->p_sm == REC_SCAN_MO_OTF) && - (precPvt->pscan->cpt > 1)) || precPvt->phase == AFTER_SCAN)) { - puserPvt = precPvt->caLinkStruct[i].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[i+P1_OUT], - &(pPosFields->p_dv), 1); - } else { - status = dbPutField(puserPvt->pAddr,DBF_DOUBLE, - &(pPosFields->p_dv), 1); - } - } - } - - if(!(precPvt->onTheFly && precPvt->pscan->cpt)) - break; - /* Fall through to TRIG_DETCTRS if in onTheFly mode and flying */ - - case TRIG_DETCTRS: - if(recScanDebug >=5) { - printf("TRIG_DETCTRS - Point %d\n",precPvt->pscan->cpt); - } - /* Schedule the next phase */ - if(!precPvt->onTheFly || (precPvt->pscan->cpt == 0)) { - precPvt->phase = READ_DETCTRS; - } - else { - precPvt->phase = CHECK_MOTORS; - } - - /* for each valid detector trigger, write the desired value */ - if(!precPvt->pscan->t1nv) { - puserPvt = precPvt->caLinkStruct[T1_OUT].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[T1_OUT], - &(precPvt->pscan->t1cd), 1); - } else { - status = dbPutField(puserPvt->pAddr,DBF_FLOAT, - &(precPvt->pscan->t1cd), 1); - } - } - if(!precPvt->pscan->t2nv) { - puserPvt = precPvt->caLinkStruct[T2_OUT].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[T2_OUT], - &(precPvt->pscan->t2cd), 1); - } else { - status = dbPutField(puserPvt->pAddr,DBF_FLOAT, - &(precPvt->pscan->t2cd), 1); - } - } - break; - - case BEFORE_SCAN: - if(recScanDebug >=5) printf("BEFORE_SCAN Fwd Lnk\n"); - if(precPvt->pscan->bsnv == OK) { - puserPvt = precPvt->caLinkStruct[BS_OUT].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[BS_OUT], - &(precPvt->pscan->bscd), 1); - } else { - status = dbPutField(puserPvt->pAddr,DBF_FLOAT, - &(precPvt->pscan->bscd), 1); - } - } - /* Leave the phase at BEFORE_SCAN */ - break; - - case AFTER_SCAN: - /* If Retrace indicates motors must move ... */ - if(precPvt->pscan->pasm) { - if(recScanDebug >=5) printf("RETRACE\n"); - pPosFields = (posFields *)&precPvt->pscan->p1pp; - pPvStat = &precPvt->pscan->p1nv; - for(i=0; i < precPvt->valPosPvs; i++, pPosFields++, pPvStat++) { - if(*pPvStat == PV_OK) { - /* Figure out where to go ... */ - if(precPvt->pscan->pasm == REC_SCAN_AS_BS) { - pPosFields->p_dv = pPosFields->p_pp; - } else { - if(pPosFields->p_sm == REC_SCAN_MO_TAB) { - if(pPosFields->p_ar) { - pPosFields->p_dv = - pPosFields->p_pp + pPosFields->p_pa[0]; - } - else { - pPosFields->p_dv = pPosFields->p_pa[0]; - } - } - else { - if(pPosFields->p_ar) { - pPosFields->p_dv = - pPosFields->p_pp + pPosFields->p_sp; - } - else { - pPosFields->p_dv = pPosFields->p_sp; - } - } - } - - /* Command motor */ - puserPvt = precPvt->caLinkStruct[i].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[i+P1_OUT], - &(pPosFields->p_dv), 1); - } else { - status = dbPutField(puserPvt->pAddr,DBF_DOUBLE, - &(pPosFields->p_dv), 1); - } - } - } - } - - /* If an After Scan Link PV is valid, execute it */ - if(precPvt->pscan->asnv == PV_OK) { - if(recScanDebug >=5) printf("AFTER_SCAN Fwd Lnk\n"); - puserPvt = precPvt->caLinkStruct[AS_OUT].puserPvt; - if(puserPvt->dbAddrNv) { - status = recDynLinkPut(&precPvt->caLinkStruct[AS_OUT], - &(precPvt->pscan->ascd), 1); - } else { - status = dbPutField(puserPvt->pAddr,DBF_FLOAT, - &(precPvt->pscan->ascd), 1); - } - } - - precPvt->phase = IDLE; - break; - - case IDLE: - case PREVIEW: - /* This must be a request to move a positioner interactivly ... */ - - pPvStat = &precPvt->pscan->p1nv; - pPosFields = (posFields *)&precPvt->pscan->p1pp; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStat++) { - if((*pPvStat == PV_OK) && precPvt->movPos[i]) { - puserPvt = precPvt->caLinkStruct[i].puserPvt; - status = dbPutField(puserPvt->pAddr,DBF_DOUBLE, - &(pPosFields->p_dv), 1); - precPvt->movPos[i] = 0; - } - } - break; - - case SCAN_PENDING: - checkConnections(pscan); - /* If .EXSC == 0, or no longer in SCAN_PENDING */ - if((!pscan->exsc) || (precPvt->phase != SCAN_PENDING)) { - if(recScanDebug) printf("scanPending - no effect\n"); - return; - } - - precPvt->phase = IDLE; - - /* Only scanOnce if no bad PV's */ - if(pscan->exsc && !precPvt->badOutputPv && !precPvt->badInputPv) { - pscan->alrt = 0; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - strcpy(pscan->smsg,""); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - scanOnce(pscan); - if(recScanDebug) printf("scanPending - start scan\n"); - } - else { - pscan->exsc = 0; - db_post_events(pscan,&pscan->exsc,DBE_VALUE); - sprintf(pscan->smsg,"Scan aborted, PV(s) not connected"); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(recScanDebug) printf("scanPending - end scan\n"); - } - break; - default: - break; - } -} - - - - -/* routine to resolve and adjust linear scan definition. - * Might get complicated !!! - */ - -static void adjLinParms(paddr) - struct dbAddr *paddr; -{ - struct scanRecord *pscan = (struct scanRecord *)(paddr->precord); - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - struct posFields *pParms = (posFields *)&precPvt->pscan->p1pp; - - int special_type = paddr->special; - int i; - int foundOne = 0; - - /* determine which positioner */ - for(i=0; ipfield >= (void *)&pParms->p_pp) && - (paddr->pfield <= (void *)&pParms->p_pr)) { - - foundOne = 1; - break; - } - } - if(!foundOne) return; /* couldn't determine positioner */ - - if(pParms->p_sm == REC_SCAN_MO_TAB) { - /* if positioner is in table mode, zero parms and return */ - zeroPosParms(pscan, (unsigned short) i); - sprintf(pscan->smsg,"Positioner #%1d is in Table Mode !",i+1); - pscan->alrt = 1; - return; - } - - if(recScanDebug) printf("Positioner %d\n",i); - switch(special_type) { - case(SPC_SC_S): /* start position changed */ - /* if step increment/center/width are not frozen, change them */ - if(!pParms->p_fi && !pParms->p_fc && !pParms->p_fw) { - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - return; - /* if # of points/center/width are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fc && !pParms->p_fw) { - pscan->npts = ((pParms->p_ep - pParms->p_sp)/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points!",i+1); - /* adjust changed field to be consistent */ - pParms->p_sp = pParms->p_ep-(pParms->p_si * (pscan->npts - 1)); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - /* if end/center are not frozen, change them */ - } else if(!pParms->p_fe && !pParms->p_fc) { - pParms->p_ep = pParms->p_sp + - ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - return; - /* if step increment/end/width are not frozen, change them */ - } else if(!pParms->p_fi && !pParms->p_fe && !pParms->p_fw) { - pParms->p_wd = (pParms->p_cp - pParms->p_sp) * 2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_si = pParms->p_wd/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pParms->p_ep = (pParms->p_sp + pParms->p_wd); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - return; - /* if # of points/end/width are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fe && !pParms->p_fw) { - pscan->npts = ((pParms->p_cp - pParms->p_sp)*2/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points!",i+1); - /* adjust changed field to be consistent */ - pParms->p_sp=pParms->p_cp-((pParms->p_si*(pscan->npts - 1))/2); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - } - break; - - case(SPC_SC_I): /* step increment changed */ - /* if # of points is not frozen, change it */ - if(!pscan->fpts) { - pscan->npts = ((pParms->p_ep - pParms->p_sp)/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - /* if end/center/width are not frozen, change them */ - } else if(!pParms->p_fe && !pParms->p_fc && !pParms->p_fw) { - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - return; - /* if start/center/width are not frozen, change them */ - } else if(!pParms->p_fs && !pParms->p_fc && !pParms->p_fw) { - pParms->p_sp = pParms->p_ep - ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - return; - /* if start/end/width are not frozen, change them */ - } else if(!pParms->p_fs && !pParms->p_fe && !pParms->p_fw) { - pParms->p_sp = pParms->p_cp - ((pscan->npts - 1) * pParms->p_si)/2; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - return; - } else { /* too constrained !! */ - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - sprintf(pscan->smsg,"P%1d SCAN Parameters Too Constrained !",i+1); - pscan->alrt = 1; - return; - } - break; - - case(SPC_SC_E): /* end position changed */ - /* if step increment/center/width are not frozen, change them */ - if(!pParms->p_fi && !pParms->p_fc && !pParms->p_fw) { - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - return; - /* if # of points/center/width are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fc && !pParms->p_fw) { - pscan->npts = ((pParms->p_ep - pParms->p_sp)/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_ep=pParms->p_sp + (pParms->p_si * (pscan->npts - 1)); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - /* if start/center are not frozen, change them */ - } else if(!pParms->p_fs && !pParms->p_fc) { - pParms->p_sp = pParms->p_ep - ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - return; - /* if step start/width/increment are not frozen, change them */ - } else if(!pParms->p_fs && !pParms->p_fw && !pParms->p_fi) { - pParms->p_wd = (pParms->p_ep - pParms->p_cp) * 2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_sp = pParms->p_ep - pParms->p_wd; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - return; - /* if # of points/start/width are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fs && !pParms->p_fw) { - pscan->npts=(((pParms->p_ep - pParms->p_cp)*2)/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_ep=pParms->p_cp+(pParms->p_si * (pscan->npts - 1)/2); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_cp) * 2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_sp = pParms->p_ep - pParms->p_wd; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - } else { /* too constrained !! */ - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - sprintf(pscan->smsg,"P%1d SCAN Parameters Too Constrained !",i+1); - pscan->alrt = 1; - return; - } - break; - - case(SPC_SC_C): /* center position changed */ - /* if start/end are not frozen, change them */ - if(!pParms->p_fs && !pParms->p_fe) { - pParms->p_sp = pParms->p_cp - ((pscan->npts - 1) * pParms->p_si)/2; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - return; - /* if end/inc/width are not frozen, change them */ - } else if(!pParms->p_fe && !pParms->p_fi && !pParms->p_fw) { - pParms->p_wd = (pParms->p_cp - pParms->p_sp)*2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_ep = pParms->p_sp + pParms->p_wd; - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - return; - /* if start/inc/width are not frozen, change them */ - } else if(!pParms->p_fs && !pParms->p_fi && !pParms->p_fw) { - pParms->p_wd = (pParms->p_ep - pParms->p_cp)*2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_sp = pParms->p_ep - pParms->p_wd; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - return; - /* if # of points/end/width are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fe && !pParms->p_fw) { - pscan->npts=(((pParms->p_cp - pParms->p_sp)*2)/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_cp=pParms->p_sp+(pParms->p_si * (pscan->npts - 1)/2); - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_wd = (pParms->p_cp - pParms->p_sp) * 2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_ep = pParms->p_sp + pParms->p_wd; - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - /* if # of points/start/width are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fs && !pParms->p_fw) { - pscan->npts=(((pParms->p_ep - pParms->p_cp)*2)/(pParms->p_si)) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_cp=pParms->p_ep-(pParms->p_si * (pscan->npts - 1)/2); - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_cp) * 2; - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pParms->p_sp = pParms->p_ep - pParms->p_wd; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - } else { /* too constrained !! */ - pParms->p_cp = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - sprintf(pscan->smsg,"P%1d SCAN Parameters Too Constrained !",i+1); - pscan->alrt = 1; - return; - } - break; - - case(SPC_SC_W): /* width position changed */ - /* if step start/inc/end are not frozen, change them */ - if(!pParms->p_fs && !pParms->p_fi && !pParms->p_fe) { - pParms->p_si = pParms->p_wd/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pParms->p_sp = pParms->p_cp - ((pscan->npts - 1) * pParms->p_si)/2; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - return; - /* if # of points/start/end are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fs && !pParms->p_fe) { - pscan->npts = (pParms->p_wd/pParms->p_si) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_wd = (pParms->p_si * (pscan->npts - 1)); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_sp = pParms->p_cp - ((pscan->npts - 1) * pParms->p_si)/2; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - /* if center/end/inc are not frozen, change them */ - } else if(!pParms->p_fc && !pParms->p_fe && !pParms->p_fi) { - pParms->p_si = pParms->p_wd/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - return; - /* if start/center/inc are not frozen, change them */ - } else if(!pParms->p_fs && !pParms->p_fc && !pParms->p_fi) { - pParms->p_si = pParms->p_wd/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - pParms->p_sp = pParms->p_ep - ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - return; - /* if # of points/center/end are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fc && !pParms->p_fe) { - pscan->npts = (pParms->p_wd/pParms->p_si) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_wd = (pParms->p_si * (pscan->npts - 1)); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - /* if # of points/start/center are not frozen, change them */ - } else if(!pscan->fpts && !pParms->p_fs && !pParms->p_fc) { - pscan->npts = (pParms->p_wd/pParms->p_si) + 1; - if(pscan->npts > pscan->mpts) { - pscan->npts = pscan->mpts; - sprintf(pscan->smsg,"P%1d Request Exceeded Maximum Points !",i+1); - /* adjust changed field to be consistent */ - pParms->p_wd = (pParms->p_si * (pscan->npts - 1)); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - pscan->alrt = 1; - } - db_post_events(pscan,&pscan->npts,DBE_VALUE); - pParms->p_sp = pParms->p_ep - ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - precPvt->nptsCause = i; /* indicate cause of # of points changed */ - changedNpts(pscan); - return; - } else { /* too constrained !! */ - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - sprintf(pscan->smsg,"P%1d SCAN Parameters Too Constrained !",i+1); - pscan->alrt = 1; - return; - } - break; - - default: - return; - } -} - - - -/* This routine attempts to bring all linear scan parameters into - * "consistency". It is used at init and when the # of pts changes. - * If the number of points changed because of a change in a Positioner's - * scan parameters, that positioner is skipped to make sure that there is - * no conflict with that logic. Any positioner in TABLE mode is also skipped. - * - * Any positioner that is in TABLE mode is checked to make sure the last - * table loaded into p_pa had enough points for the new npts. If not, the - * operator is warned - * - */ - -static void changedNpts(pscan) - struct scanRecord *pscan; -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pParms = (posFields *)&pscan->p1pp; - int i; - unsigned short freezeState = 0; - - /* for each positioner, calculate scan params as best as we can */ - /* if the positioner is in table mode, don't touch linear scan parms !*/ - for(i=0; ip_sm == REC_SCAN_MO_TAB) { - if(precPvt->tablePts[i] < pscan->npts) { - sprintf(pscan->smsg,"Pts in P%d Table < # of Steps",i+1); - if(!pscan->alrt) { - pscan->alrt = 1; - } - } - } - /* Skip the positioner that caused this */ - else if(i != precPvt->nptsCause) { - /* Adjust linear scan params as best we can */ - - /* develop freezeState switching word ... */ - /* START_FRZ | STEP_FRZ | END_FRZ | CENTER_FRZ | WIDTH_FRZ */ - - freezeState = (pParms->p_fs << 4) | - (pParms->p_fi << 3) | - (pParms->p_fe << 2) | - (pParms->p_fc << 1) | - (pParms->p_fw); - - if(recScanDebug) { - printf("Freeze State of P%1d = 0x%hx \n",i,freezeState); - } - - /* a table describing what happens is at the end of the file */ - switch(freezeState) { - case(0): - case(1): /* if center or width is frozen, but not inc , ... */ - case(2): - case(3): - case(4): - case(5): /* if end/center or end/width are frozen, but not inc, */ - case(6): - case(7): - case(16): - case(17): /*if start/center or start/width are frozen, but not inc*/ - case(18): - case(19): - case(20): - case(21): - case(22): - case(23): - pParms->p_si = (pParms->p_ep - pParms->p_sp)/(pscan->npts - 1); - db_post_events(pscan,&pParms->p_si,DBE_VALUE); - break; - - case(8): /* end/center/width unfrozen, change them */ - case(24): - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - break; - - case(12): /* start/center/width are not frozen, change them */ - pParms->p_sp = pParms->p_ep - ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_cp = (pParms->p_ep + pParms->p_sp)/2; - db_post_events(pscan,&pParms->p_cp,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - break; - - case(10): /* if center is frozen, but not width/start/end , ... */ - pParms->p_sp = pParms->p_cp - ((pscan->npts - 1) * pParms->p_si)/2; - db_post_events(pscan,&pParms->p_sp,DBE_VALUE); - pParms->p_ep = pParms->p_sp + ((pscan->npts - 1) * pParms->p_si); - db_post_events(pscan,&pParms->p_ep,DBE_VALUE); - pParms->p_wd = (pParms->p_ep - pParms->p_sp); - db_post_events(pscan,&pParms->p_wd,DBE_VALUE); - break; - - /* The following freezeStates are known to be "Too Constrained" */ - /* 9,11,13,14,15,25,26,27,28,29,30,31 */ - default: /* too constrained !! */ - sprintf(pscan->smsg,"P%1d SCAN Parameters Too Constrained !",i+1); - pscan->alrt = 1; - break; - } - - } - } -} - - - -static long checkScanLimits(pscan) - struct scanRecord *pscan; -{ - - recDynLinkPvt *puserPvt; - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp; - unsigned short *pPvStat = &pscan->p1nv; - - - /* for each valid positioner, fetch control limits */ - long status; - size_t nRequest = 1; - int i,j; - double value; - - if(recScanDebug) { - if(!pscan->p1nv) - printf("P1 Control Limits : %.4f %.4f\n", - pscan->p1lr, pscan->p1hr); - if(!pscan->p2nv) - printf("P2 Control Limits : %.4f %.4f\n", - pscan->p2lr, pscan->p2hr); - if(!pscan->p3nv) - printf("P3 Control Limits : %.4f %.4f\n", - pscan->p3lr, pscan->p3hr); - if(!pscan->p4nv) - printf("P4 Control Limits : %.4f %.4f\n", - pscan->p4lr, pscan->p4hr); - } - - /* Update "previous position" of positioners to use in relative mode */ - pPvStat = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStat++) { - if(*pPvStat == PV_OK) { - puserPvt = precPvt->caLinkStruct[i].puserPvt; - if(puserPvt->dbAddrNv) { - status |= recDynLinkGet(&precPvt->caLinkStruct[i], - &pPosFields->p_pp, &nRequest, 0, 0, 0); - } - else { - status |= dbGet(puserPvt->pAddr, DBR_DOUBLE, &pPosFields->p_pp, - 0,0, NULL); - } - db_post_events(pscan,&pPosFields->p_pp,DBE_VALUE); - } - } - - /* If recScanDontCheckLimits flag is set and EXSC = 1, don't proceed */ - if(recScanDontCheckLimits && pscan->exsc) return(OK); - - /* First check if any pos'rs are in Table mode with insufficient points*/ - pPvStat = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStat++) { - if((*pPvStat == PV_OK) && - (pPosFields->p_sm == REC_SCAN_MO_TAB) && - (precPvt->tablePts[i] < pscan->npts)) { - sprintf(pscan->smsg,"Pts in P%d Table < # of Steps",i+1); - db_post_events(pscan,&pscan->smsg,DBE_VALUE); - if(!pscan->alrt) { - pscan->alrt = 1; - db_post_events(pscan,&pscan->alrt,DBE_VALUE); - } - return(ERROR); - } - } - - /* check each point of scan against control limits. */ - /* Stop on first error */ - - pPvStat = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStat++) { - if(*pPvStat == PV_OK) { - for(j=0; jnpts; j++) { - /* determine next desired position for each positioner */ - switch(pPosFields->p_sm) { - case REC_SCAN_MO_LIN: - if(pPosFields->p_ar) { - value = (pPosFields->p_pp + pPosFields->p_sp) + - (j * pPosFields->p_si); - } else { - value = pPosFields->p_sp + (j * pPosFields->p_si); - } - break; - - case REC_SCAN_MO_TAB: - if(pPosFields->p_ar) { - value = pPosFields->p_pp + pPosFields->p_pa[j]; - } else { - value = pPosFields->p_pa[j]; - } - break; - - case REC_SCAN_MO_OTF: - if(pPosFields->p_ar) { - if(j == 0) value = pPosFields->p_pp + pPosFields->p_sp; - else value = pPosFields->p_pp + pPosFields->p_ep; - } else { - if(j == 0) value = pPosFields->p_sp; - else value = pPosFields->p_ep; - } - break; - - default: - value = 0; - } - - if((pPosFields->p_lr != 0) && (value < pPosFields->p_lr)) { - sprintf(pscan->smsg,"P%-d Value < LO_Limit @ point %1d",i+1,j); - pscan->alrt = 1; - return(ERROR); - } - else if((pPosFields->p_hr != 0) && (value > pPosFields->p_hr)) { - sprintf(pscan->smsg,"P%-d Value > HI_Limit @ point %1d",i+1,j); - pscan->alrt = 1; - return(ERROR); - } - } - } - } - - /* No errors if we made it here ... */ - sprintf(pscan->smsg,"SCAN Values within limits"); - return(OK); - -} - - -/* This routine show a "preview" of the scan positions by - * loading the detector arrays (d_da) with the scan positions at each - * point and loading the readback arrays (p_ra) with the step #. - * A plot of d_da vs p_ra will provide a graphical view of the scan - * ranges. - * - */ - -static void previewScan(pscan) - struct scanRecord *pscan; -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - recDynLinkPvt *puserPvt; - posFields *pPosFields; - detFields *pDetFields; - unsigned short *pPvStat; - double *pPosBuf; - float *pDetBuf; - float value; - int i,j; - long status; - size_t nRequest = 1; - - /* Update "previous position" of positioners to use in relative mode */ - pPvStat = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStat++) { - if(*pPvStat == PV_OK) { - puserPvt = precPvt->caLinkStruct[i].puserPvt; - if(puserPvt->dbAddrNv) { - status |= recDynLinkGet(&precPvt->caLinkStruct[i], - &pPosFields->p_pp, &nRequest, 0, 0, 0); - } - else { - status |= dbGet(puserPvt->pAddr, DBR_DOUBLE, &pPosFields->p_pp, - 0,0, NULL); - } - db_post_events(pscan,&pPosFields->p_pp,DBE_VALUE); - } - } - - /* Run through entire scan for each valid positioner */ - pPvStat = &pscan->p1nv; - pPosFields = (posFields *)&pscan->p1pp; - pDetFields = (detFields *)&pscan->d1hr; - for(i=0; i < NUM_POS; i++, pPosFields++, pPvStat++, pDetFields++) { - if(*pPvStat == PV_OK) { - /* must use the current buffer pointer */ - if(precPvt->validBuf) { - pPosBuf = precPvt->posBufPtr[i].pBufB; - pDetBuf = precPvt->detBufPtr[i].pBufB; - } - else { - pPosBuf = precPvt->posBufPtr[i].pBufA; - pDetBuf = precPvt->detBufPtr[i].pBufA; - } - for(j=0; jnpts; j++) { - /* determine next desired position for each positioner */ - switch(pPosFields->p_sm) { - case REC_SCAN_MO_LIN: - if(pPosFields->p_ar) { - value = (pPosFields->p_pp + pPosFields->p_sp) + - (j * pPosFields->p_si); - } else { - value = pPosFields->p_sp + (j * pPosFields->p_si); - } - break; - - case REC_SCAN_MO_TAB: - if(pPosFields->p_ar) { - value = pPosFields->p_pp + pPosFields->p_pa[j]; - } else { - value = pPosFields->p_pa[j]; - } - break; - - case REC_SCAN_MO_OTF: - if(pPosFields->p_ar) { - if(j == 0) value = pPosFields->p_pp + pPosFields->p_sp; - else value = pPosFields->p_pp + pPosFields->p_ep; - } else { - if(j == 0) value = pPosFields->p_sp; - else value = pPosFields->p_ep; - } - break; - - default: - value = 0; - } - pPosBuf[j] = j; - pDetBuf[j] = value; - } - /* now fill the rest of the array(s) with the last values */ - for(j=j; jmpts;j++) { - pPosBuf[j] = pPosBuf[j-1]; - pDetBuf[j] = pDetBuf[j-1]; - } - db_post_events(pscan, precPvt->posBufPtr[i].pBufA, DBE_VALUE); - db_post_events(pscan, precPvt->posBufPtr[i].pBufB, DBE_VALUE); - db_post_events(pscan, precPvt->detBufPtr[i].pBufA, DBE_VALUE); - db_post_events(pscan, precPvt->detBufPtr[i].pBufB, DBE_VALUE); - /* I must also post a monitor on the NULL array, because some - clients connected to D?PV's without valid PV's ! */ - db_post_events(pscan, precPvt->nullArray, DBE_VALUE); - } - } -} - -static void saveFrzFlags(pscan) - struct scanRecord *pscan; -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp; - int i; - - - /* save state of each freeze flag */ - precPvt->fpts = pscan->fpts; - for(i=0; iposParms[i].p_fs = pPosFields->p_fs; - precPvt->posParms[i].p_fi = pPosFields->p_fi; - precPvt->posParms[i].p_fc = pPosFields->p_fc; - precPvt->posParms[i].p_fe = pPosFields->p_fe; - precPvt->posParms[i].p_fw = pPosFields->p_fw; - } -} - -static void savePosParms(struct scanRecord *pscan, unsigned short i) -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp + i; - - /* save state of linear scan parameters 0 */ - /* Do this when in table mode so operator is not confused */ - precPvt->posParms[i].p_sp = pPosFields->p_sp; - precPvt->posParms[i].p_si = pPosFields->p_si; - precPvt->posParms[i].p_ep = pPosFields->p_ep; - precPvt->posParms[i].p_cp = pPosFields->p_cp; - precPvt->posParms[i].p_wd = pPosFields->p_wd; -} - -static void zeroPosParms(struct scanRecord *pscan, unsigned short i) -{ - - posFields *pPosFields = (posFields *)&pscan->p1pp + i; - - /* set them to 0 */ - /* Do this when in table mode so operator is not confused */ - pPosFields->p_sp = 0; - db_post_events(pscan,&pPosFields->p_sp, DBE_VALUE); - pPosFields->p_si = 0; - db_post_events(pscan,&pPosFields->p_si, DBE_VALUE); - pPosFields->p_ep = 0; - db_post_events(pscan,&pPosFields->p_ep, DBE_VALUE); - pPosFields->p_cp = 0; - db_post_events(pscan,&pPosFields->p_cp, DBE_VALUE); - pPosFields->p_wd = 0; - db_post_events(pscan,&pPosFields->p_wd, DBE_VALUE); -} - -static void resetFrzFlags(pscan) - struct scanRecord *pscan; -{ - - posFields *pPosFields = (posFields *)&pscan->p1pp; - int i; - - /* reset each frzFlag, post monitor if changed */ - - if(pscan->fpts) { - pscan->fpts = 0; - db_post_events(pscan,&pscan->fpts, DBE_VALUE); - } - - for(i=0; ip_fs) { - pPosFields->p_fs = 0; - db_post_events(pscan,&pPosFields->p_fs, DBE_VALUE); - } - - if(pPosFields->p_fi) { - pPosFields->p_fi = 0; - db_post_events(pscan,&pPosFields->p_fi, DBE_VALUE); - } - - if(pPosFields->p_fc) { - pPosFields->p_fc = 0; - db_post_events(pscan,&pPosFields->p_fc, DBE_VALUE); - } - - if(pPosFields->p_fe) { - pPosFields->p_fe = 0; - db_post_events(pscan,&pPosFields->p_fe, DBE_VALUE); - } - - if(pPosFields->p_fw) { - pPosFields->p_fw = 0; - db_post_events(pscan,&pPosFields->p_fw, DBE_VALUE); - } - } -} - - -/* Restores Freeze Flags to the state they were in */ -static void restoreFrzFlags(pscan) - struct scanRecord *pscan; -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp; - int i; - - - /* restore state of each freeze flag, post if changed */ - pscan->fpts = precPvt->fpts; - if(pscan->fpts) { - db_post_events(pscan,&pscan->fpts, DBE_VALUE); - } - - for(i=0; ip_fs = precPvt->posParms[i].p_fs; - if(pPosFields->p_fs) { - db_post_events(pscan,&pPosFields->p_fs, DBE_VALUE); - } - - pPosFields->p_fi = precPvt->posParms[i].p_fi; - if(pPosFields->p_fi) { - db_post_events(pscan,&pPosFields->p_fi, DBE_VALUE); - } - - pPosFields->p_fc = precPvt->posParms[i].p_fc; - if(pPosFields->p_fc) { - db_post_events(pscan,&pPosFields->p_fc, DBE_VALUE); - } - - pPosFields->p_fe = precPvt->posParms[i].p_fe; - if(pPosFields->p_fe) { - db_post_events(pscan,&pPosFields->p_fe, DBE_VALUE); - } - - pPosFields->p_fw = precPvt->posParms[i].p_fw; - if(pPosFields->p_fw) { - db_post_events(pscan,&pPosFields->p_fw, DBE_VALUE); - } - - } -} - -/* Restores Position Parms after leaving table mode (for 1 positioner) */ -static void restorePosParms(struct scanRecord *pscan, unsigned short i) -{ - - recPvtStruct *precPvt = (recPvtStruct *)pscan->rpvt; - posFields *pPosFields = (posFields *)&pscan->p1pp + i; - - pPosFields->p_sp = precPvt->posParms[i].p_sp; - db_post_events(pscan,&pPosFields->p_sp, DBE_VALUE); - - pPosFields->p_si = precPvt->posParms[i].p_si; - db_post_events(pscan,&pPosFields->p_si, DBE_VALUE); - - pPosFields->p_ep = precPvt->posParms[i].p_ep; - db_post_events(pscan,&pPosFields->p_ep, DBE_VALUE); - - pPosFields->p_cp = precPvt->posParms[i].p_cp; - db_post_events(pscan,&pPosFields->p_cp, DBE_VALUE); - - pPosFields->p_wd = precPvt->posParms[i].p_wd; - db_post_events(pscan,&pPosFields->p_wd, DBE_VALUE); - -} - - - - - - - -/* Memo from Tim Mooney suggesting change in order of precedence */ - -/* - -Ned, - -Current effects of scan-parameter changes are summarized below, along -with the effects I think might be preferable. The ideas are to make NPTS -nearly as easy to change as is INCR, to make END easier to change than -is START, and to prefer changing INCR in response to a change of NPTS -whenever permissible. - -If an indirect change in NPTS would make it larger than MPTS, I think -NPTS ideally should be regarded as frozen, rather than being set to -MPTS. I don't feel all that strongly about this, since I think it -might be more of a pain to code than it's worth. - -Comments on any of this? - -Tim - -==================================================================== -changing now affects should affect --------------------------------------------------------------- -START -> INCR CENTER WIDTH INCR CENTER WIDTH - or END CENTER CENTER NPTS WIDTH - or INCR END WIDTH END CENTER - or NPTS CENTER WIDTH INCR END WIDTH - or NPTS END WIDTH NPTS END WIDTH - or CENTER END - or -INCR -> CENTER END WIDTH NPTS - or START CENTER WIDTH CENTER END WIDTH - or START END WIDTH START CENTER WIDTH - or NPTS START END WIDTH - or -CENTER -> START END START END - or START INCR WIDTH END INCR WIDTH - or END INCR WIDTH START INCR WIDTH - or NPTS START WIDTH NPTS END WIDTH - or NPTS END WIDTH NPTS START WIDTH - or -END -> INCR CENTER WIDTH INCR CENTER WIDTH - or START CENTER WIDTH NPTS CENTER WIDTH - or START WIDTH INCR START CENTER - or NPTS START WIDTH START WIDTH INCR - or NPTS CENTER WIDTH NPTS START WIDTH - or START CENTER - or -WIDTH -> START END INCR START END INCR - or CENTER END INCR START END NPTS - or START CENTER INCR CENTER END INCR - or NPTS START END START CENTER INCR - or NPTS CENTER END NPTS CENTER END - or NPTS START CENTER NPTS START CENTER - or - -NPTS: given -SIECW (Start,Incr,End,Center,Width freeze-switch states; '1' = 'frozen') ---------------------------------------------------------------- -00000 (0) END CENTER WIDTH INCR -00001 (1) INCR INCR -00010 (2) START END WIDTH INCR -00011 (3) INCR INCR -00100 (4) START CENTER WIDTH INCR -00101 (5) INCR INCR -00110 (6) INCR INCR -00111 (7) INCR INCR -01000 (8) END CENTER WIDTH END CENTER WIDTH -01001 (9) -01010 (10) START END WIDTH START END WIDTH -01011 (11) -01100 (12) START CENTER WIDTH START CENTER WIDTH -01101 (13) -01110 (14) -01111 (15) -10000 (16) END CENTER WIDTH INCR -10001 (17) INCR INCR -10010 (18) INCR INCR -10011 (19) INCR INCR -10100 (20) INCR INCR -10101 (21) INCR INCR -10110 (22) INCR INCR -10111 (23) INCR INCR -11000 (24) END CENTER WIDTH END CENTER WIDTH -11001 (25) -11010 (26) -11011 (27) -11100 (28) -11101 (29) -11110 (30) -11111 (31) - - -*/ - diff --git a/src/rec/scanRecord.dbd b/src/rec/scanRecord.dbd deleted file mode 100644 index 25d2768e0..000000000 --- a/src/rec/scanRecord.dbd +++ /dev/null @@ -1,1921 +0,0 @@ -menu(scanP1SM) { - choice(scanP1SM_Linear,"Linear") - choice(scanP1SM_Table,"Table") - choice(scanP1SM_On_The_Fly,"On-The-Fly") -} -menu(scanFPTS) { - choice(scanFPTS_No,"No") - choice(scanFPTS_Freeze,"Freeze") -} -menu(scanFFO) { - choice(scanFFO_Use_F_Flags,"Use F-Flags") - choice(scanFFO_Override,"Override") -} -menu(scanPASM) { - choice(scanPASM_Stay,"Stay") - choice(scanPASM_Start_Pos,"Start Pos") - choice(scanPASM_Prior_Pos,"Prior Pos") -} -menu(scanP1AR) { - choice(scanP1AR_Absolute,"Absolute") - choice(scanP1AR_Relative,"Relative") -} -menu(scanP1NV) { - choice(scanP1NV_PV_OK,"PV OK") - choice(scanP1NV_PV_BAD,"PV BAD") - choice(scanP1NV_No_PV,"No PV") -} -recordtype(scan) { - include "dbCommon.dbd" - field(VERS,DBF_DOUBLE) { - prompt("Code Version") - special(SPC_NOMOD) - initial("3") - } - field(VAL,DBF_DOUBLE) { - prompt("Value Field") - } - field(SMSG,DBF_STRING) { - prompt("Record State Msg") - interest(1) - size(40) - } - field(CMND,DBF_ENUM) { - prompt("Command Field") - asl(ASL0) - special(SPC_MOD) - interest(1) - } - field(ALRT,DBF_UCHAR) { - prompt("Operator Alert") - special(SPC_NOMOD) - } - field(RPVT,DBF_NOACCESS) { - prompt("Ptr to Pvt Struct") - special(SPC_NOMOD) - interest(4) - extra("void * rpvt") - } - field(MPTS,DBF_SHORT) { - prompt("Max # of Points") - promptgroup(GUI_LINKS) - special(SPC_NOMOD) - interest(1) - initial("100") - } - field(EXSC,DBF_SHORT) { - prompt("Execute Scan") - asl(ASL0) - special(SPC_MOD) - interest(1) - } - field(PXSC,DBF_UCHAR) { - prompt("Previous XScan") - special(SPC_NOMOD) - } - field(NPTS,DBF_SHORT) { - prompt("Number of Points") - promptgroup(GUI_LINKS) - asl(ASL0) - special(116) - interest(1) - initial("100") - } - field(FPTS,DBF_MENU) { - prompt("Freeze Num of Points") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - initial("Freeze") - } - field(FFO,DBF_MENU) { - prompt("Freeze Flag Override") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(117) - interest(1) - menu(scanFFO) - } - field(CPT,DBF_SHORT) { - prompt("Current Point") - special(SPC_NOMOD) - interest(1) - } - field(DPT,DBF_SHORT) { - prompt("Desired Point") - special(119) - interest(1) - } - field(PCPT,DBF_SHORT) { - prompt("Point ofLast Posting") - special(SPC_NOMOD) - interest(1) - } - field(PASM,DBF_MENU) { - prompt("After Scan Mode") - promptgroup(GUI_OUTPUT) - asl(ASL0) - interest(1) - menu(scanPASM) - } - field(TOLP,DBF_ULONG) { - prompt("Time of Last Posting") - special(SPC_NOMOD) - interest(1) - } - field(P1PV,DBF_STRING) { - prompt("Positioner 1 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(130) - interest(1) - size(40) - } - field(P2PV,DBF_STRING) { - prompt("Positioner 2 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(131) - interest(1) - size(40) - } - field(P3PV,DBF_STRING) { - prompt("Positioner 3 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(132) - interest(1) - size(40) - } - field(P4PV,DBF_STRING) { - prompt("Positioner 4 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(133) - interest(1) - size(40) - } - field(R1PV,DBF_STRING) { - prompt("P1 Readback PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(134) - interest(1) - size(40) - } - field(R2PV,DBF_STRING) { - prompt("P2 Readback PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(135) - interest(1) - size(40) - } - field(R3PV,DBF_STRING) { - prompt("P3 Readback PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(136) - interest(1) - size(40) - } - field(R4PV,DBF_STRING) { - prompt("P4 Readback PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(137) - interest(1) - size(40) - } - field(D1PV,DBF_STRING) { - prompt("Detector 1 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(138) - interest(1) - size(40) - } - field(D2PV,DBF_STRING) { - prompt("Detector 2 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(139) - interest(1) - size(40) - } - field(D3PV,DBF_STRING) { - prompt("Detector 3 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(140) - interest(1) - size(40) - } - field(D4PV,DBF_STRING) { - prompt("Detector 4 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(141) - interest(1) - size(40) - } - field(D5PV,DBF_STRING) { - prompt("Detector 5 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(142) - interest(1) - size(40) - } - field(D6PV,DBF_STRING) { - prompt("Detector 6 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(143) - interest(1) - size(40) - } - field(D7PV,DBF_STRING) { - prompt("Detector 7 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(144) - interest(1) - size(40) - } - field(D8PV,DBF_STRING) { - prompt("Detector 8 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(145) - interest(1) - size(40) - } - field(D9PV,DBF_STRING) { - prompt("Detector 9 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(146) - interest(1) - size(40) - } - field(DAPV,DBF_STRING) { - prompt("Detector 10 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(147) - interest(1) - size(40) - } - field(DBPV,DBF_STRING) { - prompt("Detector 11 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(148) - interest(1) - size(40) - } - field(DCPV,DBF_STRING) { - prompt("Detector 12 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(149) - interest(1) - size(40) - } - field(DDPV,DBF_STRING) { - prompt("Detector 13 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(150) - interest(1) - size(40) - } - field(DEPV,DBF_STRING) { - prompt("Detector 14 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(151) - interest(1) - size(40) - } - field(DFPV,DBF_STRING) { - prompt("Detector 15 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(152) - interest(1) - size(40) - } - field(T1PV,DBF_STRING) { - prompt("Trigger 1 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(153) - interest(1) - size(40) - } - field(T2PV,DBF_STRING) { - prompt("Trigger 2 PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(154) - interest(1) - size(40) - } - field(BSPV,DBF_STRING) { - prompt("Before Scan PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(155) - interest(1) - size(40) - } - field(ASPV,DBF_STRING) { - prompt("After Scan PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(156) - interest(1) - size(40) - } - field(P1NV,DBF_MENU) { - prompt("P1 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(P2NV,DBF_MENU) { - prompt("P2 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(P3NV,DBF_MENU) { - prompt("P3 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(P4NV,DBF_MENU) { - prompt("P4 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(R1NV,DBF_MENU) { - prompt("R1 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(R2NV,DBF_MENU) { - prompt("R2 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(R3NV,DBF_MENU) { - prompt("R3 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(R4NV,DBF_MENU) { - prompt("R4 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D1NV,DBF_MENU) { - prompt("D1 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D2NV,DBF_MENU) { - prompt("D2 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D3NV,DBF_MENU) { - prompt("D3 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D4NV,DBF_MENU) { - prompt("D4 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D5NV,DBF_MENU) { - prompt("D5 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D6NV,DBF_MENU) { - prompt("D6 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D7NV,DBF_MENU) { - prompt("D7 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D8NV,DBF_MENU) { - prompt("D8 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(D9NV,DBF_MENU) { - prompt("D9 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(DANV,DBF_MENU) { - prompt("D10 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(DBNV,DBF_MENU) { - prompt("D11 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(DCNV,DBF_MENU) { - prompt("D12 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(DDNV,DBF_MENU) { - prompt("D13 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(DENV,DBF_MENU) { - prompt("D14 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(DFNV,DBF_MENU) { - prompt("D15 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(T1NV,DBF_MENU) { - prompt("T1 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(T2NV,DBF_MENU) { - prompt("T2 PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(BSNV,DBF_MENU) { - prompt("BeforeScan PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(ASNV,DBF_MENU) { - prompt("After Scan PV Status") - special(SPC_NOMOD) - interest(1) - menu(scanP1NV) - } - field(P1PP,DBF_DOUBLE) { - prompt("P1 Previous Position") - special(SPC_NOMOD) - interest(1) - } - field(P1CV,DBF_DOUBLE) { - prompt("P1 Current Value") - special(SPC_NOMOD) - interest(1) - } - field(P1DV,DBF_DOUBLE) { - prompt("P1 Desired Value") - special(SPC_MOD) - interest(1) - } - field(P1LV,DBF_DOUBLE) { - prompt("P1 Last Value Posted") - special(SPC_NOMOD) - interest(1) - } - field(P1SP,DBF_DOUBLE) { - prompt("P1 Start Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(111) - interest(1) - } - field(P1SI,DBF_DOUBLE) { - prompt("P1 Step Increment") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(112) - interest(1) - } - field(P1EP,DBF_DOUBLE) { - prompt("P1 End Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(113) - interest(1) - } - field(P1CP,DBF_DOUBLE) { - prompt("P1 Center Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(114) - interest(1) - } - field(P1WD,DBF_DOUBLE) { - prompt("P1 Scan Width") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(115) - interest(1) - } - field(R1CV,DBF_DOUBLE) { - prompt("P1 Readback Value") - special(SPC_NOMOD) - interest(1) - } - field(R1LV,DBF_DOUBLE) { - prompt("P1 Rdbk Last Val Pst") - special(SPC_NOMOD) - interest(1) - } - field(R1DL,DBF_DOUBLE) { - prompt("P1 Readback Delta") - promptgroup(GUI_INPUTS) - asl(ASL0) - interest(1) - } - field(P1HR,DBF_DOUBLE) { - prompt("P1 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P1LR,DBF_DOUBLE) { - prompt("P1 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P1PA,DBF_NOACCESS) { - prompt("P1 Step Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p1pa") - } - field(P1RA,DBF_NOACCESS) { - prompt("P1 Readback Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p1ra") - } - field(P1FS,DBF_MENU) { - prompt("P1 Freeze Start Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P1FI,DBF_MENU) { - prompt("P1 Freeze Step Inc") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P1FE,DBF_MENU) { - prompt("P1 Freeze End Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P1FC,DBF_MENU) { - prompt("P1 Freeze Center Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P1FW,DBF_MENU) { - prompt("P1 Freeze Width") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P1SM,DBF_MENU) { - prompt("P1 Step Mode") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(120) - interest(1) - menu(scanP1SM) - } - field(P1AR,DBF_MENU) { - prompt("P1 Absolute/Relative") - promptgroup(GUI_OUTPUT) - asl(ASL0) - interest(1) - menu(scanP1AR) - } - field(P1EU,DBF_STRING) { - prompt("P1 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(P1PR,DBF_SHORT) { - prompt("P1 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(P2PP,DBF_DOUBLE) { - prompt("P2 Previous Position") - special(SPC_NOMOD) - interest(1) - } - field(P2CV,DBF_DOUBLE) { - prompt("P2 Current Value") - special(SPC_NOMOD) - interest(1) - } - field(P2DV,DBF_DOUBLE) { - prompt("P2 Desired Value") - special(SPC_MOD) - interest(1) - } - field(P2LV,DBF_DOUBLE) { - prompt("P2 Last Value Posted") - special(SPC_NOMOD) - interest(1) - } - field(P2SP,DBF_DOUBLE) { - prompt("P2 Start Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(111) - interest(1) - } - field(P2SI,DBF_DOUBLE) { - prompt("P2 Step Increment") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(112) - interest(1) - } - field(P2EP,DBF_DOUBLE) { - prompt("P2 End Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(113) - interest(1) - } - field(P2CP,DBF_DOUBLE) { - prompt("P2 Center Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(114) - interest(1) - } - field(P2WD,DBF_DOUBLE) { - prompt("P2 Scan Width") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(115) - interest(1) - } - field(R2CV,DBF_DOUBLE) { - prompt("P2 Readback Value") - special(SPC_NOMOD) - interest(1) - } - field(R2LV,DBF_DOUBLE) { - prompt("P2 Rdbk Last Val Pst") - special(SPC_NOMOD) - interest(1) - } - field(R2DL,DBF_DOUBLE) { - prompt("P2 Readback Delta") - promptgroup(GUI_INPUTS) - asl(ASL0) - interest(1) - } - field(P2HR,DBF_DOUBLE) { - prompt("P2 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P2LR,DBF_DOUBLE) { - prompt("P2 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P2PA,DBF_NOACCESS) { - prompt("P2 Step Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p2pa") - } - field(P2RA,DBF_NOACCESS) { - prompt("P2 Readback Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p2ra") - } - field(P2FS,DBF_MENU) { - prompt("P2 Freeze Start Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P2FI,DBF_MENU) { - prompt("P2 Freeze Step Inc") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P2FE,DBF_MENU) { - prompt("P2 Freeze End Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P2FC,DBF_MENU) { - prompt("P2 Freeze Center Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P2FW,DBF_MENU) { - prompt("P2 Freeze Width") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P2SM,DBF_MENU) { - prompt("P2 Step Mode") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(120) - interest(1) - menu(scanP1SM) - } - field(P2AR,DBF_MENU) { - prompt("P2 Absolute/Relative") - promptgroup(GUI_OUTPUT) - asl(ASL0) - interest(1) - menu(scanP1AR) - } - field(P2EU,DBF_STRING) { - prompt("P2 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(P2PR,DBF_SHORT) { - prompt("P2 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(P3PP,DBF_DOUBLE) { - prompt("P3 Previous Position") - special(SPC_NOMOD) - interest(1) - } - field(P3CV,DBF_DOUBLE) { - prompt("P3 Current Value") - special(SPC_NOMOD) - interest(1) - } - field(P3DV,DBF_DOUBLE) { - prompt("P3 Desired Value") - special(SPC_MOD) - interest(1) - } - field(P3LV,DBF_DOUBLE) { - prompt("P3 Last Value Posted") - special(SPC_NOMOD) - interest(1) - } - field(P3SP,DBF_DOUBLE) { - prompt("P3 Start Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(111) - interest(1) - } - field(P3SI,DBF_DOUBLE) { - prompt("P3 Step Increment") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(112) - interest(1) - } - field(P3EP,DBF_DOUBLE) { - prompt("P3 End Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(113) - interest(1) - } - field(P3CP,DBF_DOUBLE) { - prompt("P3 Center Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(114) - interest(1) - } - field(P3WD,DBF_DOUBLE) { - prompt("P3 Scan Width") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(115) - interest(1) - } - field(R3CV,DBF_DOUBLE) { - prompt("P3 Readback Value") - special(SPC_NOMOD) - interest(1) - } - field(R3LV,DBF_DOUBLE) { - prompt("P3 Rdbk Last Val Pst") - special(SPC_NOMOD) - interest(1) - } - field(R3DL,DBF_DOUBLE) { - prompt("P3 Readback Delta") - promptgroup(GUI_INPUTS) - asl(ASL0) - interest(1) - } - field(P3HR,DBF_DOUBLE) { - prompt("P3 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P3LR,DBF_DOUBLE) { - prompt("P3 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P3PA,DBF_NOACCESS) { - prompt("P3 Step Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p3pa") - } - field(P3RA,DBF_NOACCESS) { - prompt("P3 Readback Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p3ra") - } - field(P3FS,DBF_MENU) { - prompt("P3 Freeze Start Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P3FI,DBF_MENU) { - prompt("P3 Freeze Step Inc") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P3FE,DBF_MENU) { - prompt("P3 Freeze End Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P3FC,DBF_MENU) { - prompt("P3 Freeze Center Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P3FW,DBF_MENU) { - prompt("P3 Freeze Width") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P3SM,DBF_MENU) { - prompt("P3 Step Mode") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(120) - interest(1) - menu(scanP1SM) - } - field(P3AR,DBF_MENU) { - prompt("P3 Absolute/Relative") - promptgroup(GUI_OUTPUT) - asl(ASL0) - interest(1) - menu(scanP1AR) - } - field(P3EU,DBF_STRING) { - prompt("P3 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(P3PR,DBF_SHORT) { - prompt("P3 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(P4PP,DBF_DOUBLE) { - prompt("P4 Previous Position") - special(SPC_NOMOD) - interest(1) - } - field(P4CV,DBF_DOUBLE) { - prompt("P4 Current Value") - special(SPC_NOMOD) - interest(1) - } - field(P4DV,DBF_DOUBLE) { - prompt("P4 Desired Value") - special(SPC_MOD) - interest(1) - } - field(P4LV,DBF_DOUBLE) { - prompt("P4 Last Value Posted") - special(SPC_NOMOD) - interest(1) - } - field(P4SP,DBF_DOUBLE) { - prompt("P4 Start Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(111) - interest(1) - } - field(P4SI,DBF_DOUBLE) { - prompt("P4 Step Increment") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(112) - interest(1) - } - field(P4EP,DBF_DOUBLE) { - prompt("P4 End Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(113) - interest(1) - } - field(P4CP,DBF_DOUBLE) { - prompt("P4 Center Position") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(114) - interest(1) - } - field(P4WD,DBF_DOUBLE) { - prompt("P4 Scan Width") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(115) - interest(1) - } - field(R4CV,DBF_DOUBLE) { - prompt("P4 Readback Value") - special(SPC_NOMOD) - interest(1) - } - field(R4LV,DBF_DOUBLE) { - prompt("P4 Rdbk Last Val Pst") - special(SPC_NOMOD) - interest(1) - } - field(R4DL,DBF_DOUBLE) { - prompt("P4 Readback Delta") - promptgroup(GUI_INPUTS) - asl(ASL0) - interest(1) - } - field(P4HR,DBF_DOUBLE) { - prompt("P4 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P4LR,DBF_DOUBLE) { - prompt("P4 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(P4PA,DBF_NOACCESS) { - prompt("P4 Step Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p4pa") - } - field(P4RA,DBF_NOACCESS) { - prompt("P4 Readback Array") - asl(ASL0) - special(SPC_DBADDR) - extra("double * p4ra") - } - field(P4FS,DBF_MENU) { - prompt("P4 Freeze Start Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P4FI,DBF_MENU) { - prompt("P4 Freeze Step Inc") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P4FE,DBF_MENU) { - prompt("P4 Freeze End Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P4FC,DBF_MENU) { - prompt("P4 Freeze Center Pos") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P4FW,DBF_MENU) { - prompt("P4 Freeze Width") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(118) - interest(1) - menu(scanFPTS) - } - field(P4SM,DBF_MENU) { - prompt("P4 Step Mode") - promptgroup(GUI_OUTPUT) - asl(ASL0) - special(120) - interest(1) - menu(scanP1SM) - } - field(P4AR,DBF_MENU) { - prompt("P4 Absolute/Relative") - promptgroup(GUI_OUTPUT) - asl(ASL0) - interest(1) - menu(scanP1AR) - } - field(P4EU,DBF_STRING) { - prompt("P4 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(P4PR,DBF_SHORT) { - prompt("P4 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D1HR,DBF_DOUBLE) { - prompt("D1 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D1LR,DBF_DOUBLE) { - prompt("D1 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D1DA,DBF_NOACCESS) { - prompt("D1 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d1da") - } - field(D1CV,DBF_FLOAT) { - prompt("D1 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D1LV,DBF_FLOAT) { - prompt("D1 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D1NE,DBF_ULONG) { - prompt("D1 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D1EU,DBF_STRING) { - prompt("D1 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D1PR,DBF_SHORT) { - prompt("D1 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D2HR,DBF_DOUBLE) { - prompt("D2 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D2LR,DBF_DOUBLE) { - prompt("D2 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D2DA,DBF_NOACCESS) { - prompt("D2 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d2da") - } - field(D2CV,DBF_FLOAT) { - prompt("D2 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D2LV,DBF_FLOAT) { - prompt("D2 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D2NE,DBF_ULONG) { - prompt("D2 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D2EU,DBF_STRING) { - prompt("D2 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D2PR,DBF_SHORT) { - prompt("D2 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D3HR,DBF_DOUBLE) { - prompt("D3 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D3LR,DBF_DOUBLE) { - prompt("D3 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D3DA,DBF_NOACCESS) { - prompt("D3 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d3da") - } - field(D3CV,DBF_FLOAT) { - prompt("D3 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D3LV,DBF_FLOAT) { - prompt("D3 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D3NE,DBF_ULONG) { - prompt("D3 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D3EU,DBF_STRING) { - prompt("D3 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D3PR,DBF_SHORT) { - prompt("D3 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D4HR,DBF_DOUBLE) { - prompt("D4 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D4LR,DBF_DOUBLE) { - prompt("D4 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D4DA,DBF_NOACCESS) { - prompt("D4 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d4da") - } - field(D4CV,DBF_FLOAT) { - prompt("D4 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D4LV,DBF_FLOAT) { - prompt("D4 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D4NE,DBF_ULONG) { - prompt("D4 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D4EU,DBF_STRING) { - prompt("D4 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D4PR,DBF_SHORT) { - prompt("D4 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D5HR,DBF_DOUBLE) { - prompt("D5 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D5LR,DBF_DOUBLE) { - prompt("D5 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D5DA,DBF_NOACCESS) { - prompt("D5 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d5da") - } - field(D5CV,DBF_FLOAT) { - prompt("D5 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D5LV,DBF_FLOAT) { - prompt("D5 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D5NE,DBF_ULONG) { - prompt("D5 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D5EU,DBF_STRING) { - prompt("D5 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D5PR,DBF_SHORT) { - prompt("D5 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D6HR,DBF_DOUBLE) { - prompt("D6 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D6LR,DBF_DOUBLE) { - prompt("D6 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D6DA,DBF_NOACCESS) { - prompt("D6 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d6da") - } - field(D6CV,DBF_FLOAT) { - prompt("D6 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D6LV,DBF_FLOAT) { - prompt("D6 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D6NE,DBF_ULONG) { - prompt("D6 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D6EU,DBF_STRING) { - prompt("D6 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D6PR,DBF_SHORT) { - prompt("D6 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D7HR,DBF_DOUBLE) { - prompt("D7 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D7LR,DBF_DOUBLE) { - prompt("D7 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D7DA,DBF_NOACCESS) { - prompt("D7 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d7da") - } - field(D7CV,DBF_FLOAT) { - prompt("D7 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D7LV,DBF_FLOAT) { - prompt("D7 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D7NE,DBF_ULONG) { - prompt("D7 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D7EU,DBF_STRING) { - prompt("D7 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D7PR,DBF_SHORT) { - prompt("D7 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D8HR,DBF_DOUBLE) { - prompt("D8 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D8LR,DBF_DOUBLE) { - prompt("D8 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D8DA,DBF_NOACCESS) { - prompt("D8 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d8da") - } - field(D8CV,DBF_FLOAT) { - prompt("D8 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D8LV,DBF_FLOAT) { - prompt("D8 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D8NE,DBF_ULONG) { - prompt("D8 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D8EU,DBF_STRING) { - prompt("D8 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D8PR,DBF_SHORT) { - prompt("D8 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(D9HR,DBF_DOUBLE) { - prompt("D9 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D9LR,DBF_DOUBLE) { - prompt("D9 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(D9DA,DBF_NOACCESS) { - prompt("D9 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * d9da") - } - field(D9CV,DBF_FLOAT) { - prompt("D9 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D9LV,DBF_FLOAT) { - prompt("D9 Last Value Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D9NE,DBF_ULONG) { - prompt("D9 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(D9EU,DBF_STRING) { - prompt("D9 Engineering Units") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(D9PR,DBF_SHORT) { - prompt("D9 Display Precision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(DAHR,DBF_DOUBLE) { - prompt("D10 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DALR,DBF_DOUBLE) { - prompt("D10 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DADA,DBF_NOACCESS) { - prompt("D10 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * dada") - } - field(DACV,DBF_FLOAT) { - prompt("D10 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DALV,DBF_FLOAT) { - prompt("D10 LastValue Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DANE,DBF_ULONG) { - prompt("D10 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DAEU,DBF_STRING) { - prompt("D10 EngineeringUnits") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(DAPR,DBF_SHORT) { - prompt("D10 DisplayPrecision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(DBHR,DBF_DOUBLE) { - prompt("D11 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DBLR,DBF_DOUBLE) { - prompt("D11 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DBDA,DBF_NOACCESS) { - prompt("D11 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * dbda") - } - field(DBCV,DBF_FLOAT) { - prompt("D11 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DBLV,DBF_FLOAT) { - prompt("D11 LastValue Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DBNE,DBF_ULONG) { - prompt("D11 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DBEU,DBF_STRING) { - prompt("D11 EngineeringUnits") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(DBPR,DBF_SHORT) { - prompt("D11 DisplayPrecision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(DCHR,DBF_DOUBLE) { - prompt("D12 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DCLR,DBF_DOUBLE) { - prompt("D12 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DCDA,DBF_NOACCESS) { - prompt("D12 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * dcda") - } - field(DCCV,DBF_FLOAT) { - prompt("D12 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DCLV,DBF_FLOAT) { - prompt("D12 LastValue Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DCNE,DBF_ULONG) { - prompt("D12 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DCEU,DBF_STRING) { - prompt("D12 EngineeringUnits") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(DCPR,DBF_SHORT) { - prompt("D12 DisplayPrecision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(DDHR,DBF_DOUBLE) { - prompt("D13 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DDLR,DBF_DOUBLE) { - prompt("D13 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DDDA,DBF_NOACCESS) { - prompt("D13 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * ddda") - } - field(DDCV,DBF_FLOAT) { - prompt("D13 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DDLV,DBF_FLOAT) { - prompt("D13 LastValue Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DDNE,DBF_ULONG) { - prompt("D13 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DDEU,DBF_STRING) { - prompt("D13 EngineeringUnits") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(DDPR,DBF_SHORT) { - prompt("D13 DisplayPrecision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(DEHR,DBF_DOUBLE) { - prompt("D14 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DELR,DBF_DOUBLE) { - prompt("D14 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DEDA,DBF_NOACCESS) { - prompt("D14 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * deda") - } - field(DECV,DBF_FLOAT) { - prompt("D14 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DELV,DBF_FLOAT) { - prompt("D14 LastValue Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DENE,DBF_ULONG) { - prompt("D14 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DEEU,DBF_STRING) { - prompt("D14 EngineeringUnits") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(DEPR,DBF_SHORT) { - prompt("D14 DisplayPrecision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(DFHR,DBF_DOUBLE) { - prompt("D15 High Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DFLR,DBF_DOUBLE) { - prompt("D15 Low Oper Range") - promptgroup(GUI_CONVERT) - asl(ASL0) - interest(1) - } - field(DFDA,DBF_NOACCESS) { - prompt("D15 Data Array") - asl(ASL0) - special(SPC_DBADDR) - extra("float * dfda") - } - field(DFCV,DBF_FLOAT) { - prompt("D15 Current Value") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DFLV,DBF_FLOAT) { - prompt("D15 LastValue Posted") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DFNE,DBF_ULONG) { - prompt("D15 # of Elements/Pt") - asl(ASL0) - special(SPC_NOMOD) - interest(1) - } - field(DFEU,DBF_STRING) { - prompt("D15 EngineeringUnits") - promptgroup(GUI_COMPRESS) - asl(ASL0) - interest(1) - size(16) - } - field(DFPR,DBF_SHORT) { - prompt("D15 DisplayPrecision") - promptgroup(GUI_HIST) - asl(ASL0) - interest(1) - } - field(T1CD,DBF_FLOAT) { - prompt("T1 Cmnd") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(SPC_MOD) - interest(1) - } - field(T2CD,DBF_FLOAT) { - prompt("T2 Cmnd") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(SPC_MOD) - interest(1) - } - field(BSCD,DBF_FLOAT) { - prompt("Before Scan Cmnd") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(SPC_MOD) - interest(1) - } - field(ASCD,DBF_FLOAT) { - prompt("After Scan Cmnd") - promptgroup(GUI_INPUTS) - asl(ASL0) - special(SPC_MOD) - interest(1) - } -} diff --git a/src/rec/selRecord.c b/src/rec/selRecord.c index 53d0940d1..afe42b644 100644 --- a/src/rec/selRecord.c +++ b/src/rec/selRecord.c @@ -48,22 +48,22 @@ * .15 03-29-94 mcn converted to fast links */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "selRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/seqRecord.c b/src/rec/seqRecord.c index 762dd0748..77d306186 100644 --- a/src/rec/seqRecord.c +++ b/src/rec/seqRecord.c @@ -30,30 +30,28 @@ * .02 04-19-94 jrw Added value fields and monitors on them * .01 09-21-92 jrw created */ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "osiWatchdog.h" +#include "osiClock.h" +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" +#include "callback.h" #define GEN_SIZE_OFFSET -#include +#include "seqRecord.h" #undef GEN_SIZE_OFFSET int seqRecDebug = 0; @@ -99,7 +97,7 @@ struct linkDesc { /* Callback structure used by the watchdog function to queue link processing */ struct callbackSeq { CALLBACK callBack; /* used for the callback task */ - WDOG_ID wd_id; /* Watchdog udes for delays */ + watchdogId wd_id; /* Watchdog udes for delays */ struct linkDesc *plinks[NUM_LINKS+1]; /* Pointers to links to process */ int index; }; @@ -123,6 +121,7 @@ int pass; { int index; struct linkDesc *plink; + struct callbackSeq *pcallbackSeq; if (pass==0) return(0); @@ -131,10 +130,10 @@ int pass; /* Allocate a callback structure for use in processing */ pseq->dpvt = (void *)malloc(sizeof(struct callbackSeq)); - - ((struct callbackSeq *) (pseq->dpvt))->callBack.callback = processCallback; - ((struct callbackSeq *) (pseq->dpvt))->callBack.user = (void *) pseq; - ((struct callbackSeq *) (pseq->dpvt))->wd_id = wdCreate(); + pcallbackSeq = (struct callbackSeq *)pseq->dpvt; + pcallbackSeq->callBack.callback = processCallback; + pcallbackSeq->callBack.user = (void *) pseq; + pcallbackSeq->wd_id = watchdogCreate(); /* Get link selection if sell is a constant and nonzero */ if (pseq->sell.type==CONSTANT) @@ -317,8 +316,9 @@ struct seqRecord *pseq; if (pcb->plinks[pcb->index]->dly > 0.0) { /* Use the watch-dog as a delay mechanism */ - wdDelay = pcb->plinks[pcb->index]->dly * sysClkRateGet(); - wdStart(pcb->wd_id, wdDelay, (FUNCPTR)watchDog, (int)(&(pcb->callBack))); + wdDelay = (int)(pcb->plinks[pcb->index]->dly * clockGetRate()); + watchdogStart(pcb->wd_id, wdDelay, + (WATCHDOGFUNC)watchDog, (void *)(&(pcb->callBack))); } else { diff --git a/src/rec/stateRecord.c b/src/rec/stateRecord.c index 26ce326ef..42cb71b9a 100644 --- a/src/rec/stateRecord.c +++ b/src/rec/stateRecord.c @@ -37,22 +37,22 @@ * .05 07-16-92 jba added invalid alarm fwd link test and chngd fwd lnk to macro */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "stateRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/steppermotorRecord.c b/src/rec/steppermotorRecord.c index 10a16ab1f..62262f4b4 100644 --- a/src/rec/steppermotorRecord.c +++ b/src/rec/steppermotorRecord.c @@ -100,27 +100,27 @@ * steps. Dev/Drv sup will interpret meaning */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "dbScan.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" +#include "special.h" #define GEN_SIZE_OFFSET -#include +#include "steppermotorRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "steppermotor.h" /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/stringinRecord.c b/src/rec/stringinRecord.c index 9cbc6f080..6b58034a0 100644 --- a/src/rec/stringinRecord.c +++ b/src/rec/stringinRecord.c @@ -40,23 +40,23 @@ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "stringinRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/stringoutRecord.c b/src/rec/stringoutRecord.c index bab110aa1..5f4f22b26 100644 --- a/src/rec/stringoutRecord.c +++ b/src/rec/stringoutRecord.c @@ -45,25 +45,25 @@ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "stringoutRecord.h" #undef GEN_SIZE_OFFSET -#include +#include "menuIvoa.h" /* Create RSET - Record Support Entry Table*/ #define report NULL diff --git a/src/rec/subArrayRecord.c b/src/rec/subArrayRecord.c index 7742893b1..51cea85af 100644 --- a/src/rec/subArrayRecord.c +++ b/src/rec/subArrayRecord.c @@ -36,25 +36,24 @@ * ----------------- */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "dbScan.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "subArrayRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ diff --git a/src/rec/subRecord.c b/src/rec/subRecord.c index c3dd61ff3..7e23faf60 100644 --- a/src/rec/subRecord.c +++ b/src/rec/subRecord.c @@ -47,26 +47,24 @@ * .15 03-30-94 mcn converted to fast links */ -#include -#include -#include -#include -#include -#include -#include /* for sysSymTbl*/ -#include /* for N_TEXT */ +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include +#include "registry.h" +#include "alarm.h" +#include "dbAccess.h" +#include "epicsPrint.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "subRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ @@ -120,10 +118,7 @@ static long init_record(psub,pass) int pass; { FUNCPTR psubroutine; - char sub_type; - char temp[40]; long status = 0; - STATUS ret; struct link *plink; int i; double *pvalue; @@ -140,13 +135,8 @@ static long init_record(psub,pass) if(strlen(psub->inam)!=0) { /* convert the initialization subroutine name */ - temp[0] = 0; /* all global variables start with _ */ - if (psub->inam[0] != '_'){ - strcpy(temp,"_"); - } - strcat(temp,psub->inam); - ret = symFindByNameEPICS(sysSymTbl,temp,(void *)&psub->sadr,(void *)&sub_type); - if ((ret !=OK) || ((sub_type & N_TEXT) == 0)){ + psub->sadr = registryFind(0,psub->inam); + if(psub->sadr==0) { recGblRecordError(S_db_BadSub,(void *)psub,"recSub(init_record)"); return(S_db_BadSub); } @@ -161,19 +151,11 @@ static long init_record(psub,pass) psub->pact = TRUE; return(0); } - /* convert the subroutine name to an address and type */ - /* convert the processing subroutine name */ - temp[0] = 0; /* all global variables start with _ */ - if (psub->snam[0] != '_'){ - strcpy(temp,"_"); - } - strcat(temp,psub->snam); - ret = symFindByNameEPICS(sysSymTbl,temp,(void *)&psub->sadr,(void *)&sub_type); - if ((ret < 0) || ((sub_type & N_TEXT) == 0)){ + psub->sadr = registryFind(0,psub->snam); + if(psub->sadr==0) { recGblRecordError(S_db_BadSub,(void *)psub,"recSub(init_record)"); return(S_db_BadSub); } - psub->styp = sub_type; return(0); } diff --git a/src/rec/subRecord.dbd b/src/rec/subRecord.dbd index c267417c8..7413141c6 100644 --- a/src/rec/subRecord.dbd +++ b/src/rec/subRecord.dbd @@ -25,11 +25,6 @@ recordtype(sub) { interest(4) extra("void * sadr") } - field(STYP,DBF_SHORT) { - prompt("Subr symbol type") - special(SPC_NOMOD) - interest(3) - } field(INPA,DBF_INLINK) { prompt("Input A") promptgroup(GUI_INPUTS) diff --git a/src/rec/timerRecord.c b/src/rec/timerRecord.c index a410e3f52..57d7e6fc5 100644 --- a/src/rec/timerRecord.c +++ b/src/rec/timerRecord.c @@ -54,10 +54,11 @@ * .20 03-30-94 mcn converted to fast links */ -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" diff --git a/src/rec/waitRecord.c b/src/rec/waitRecord.c deleted file mode 100644 index b46415faf..000000000 --- a/src/rec/waitRecord.c +++ /dev/null @@ -1,817 +0,0 @@ -/* recWait.c */ -/* - * Original Author: Ned Arnold - * Date: 05-31-94 - * - * 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: - * ----------------- - * 1.01 05-31-94 nda initial try - * 1.02 07-11-94 mrk/nda added "process on input change" feature - * 1.03 08-16-94 mrk/nda continuing "process on input change" feature - * 1.04 08-16-94 nda record does not get notified when a SCAN - * related field changes,so for now we have to - * always add Monitors - * 1.05 08-18-94 nda Starting with R3.11.6, dbGetField locks the - * record before fetching the data. This can - * cause deadlocks within a database. Change all - * dbGetField() to dbGet() - * 1.06 08-19-94 nda added Output data option of VAL or DOL - * 1.07 09-14-94 nda corrected bug that caused SCAN_DISABLE to - * lock up the record forever - * 1.08 02-01-95 nda added VERS and ODLY (output execution delay) - * 1.09 02-15-95 nda added INxP to specify which inputs should - * cause the record to process when in I/O INTR - * 2.00 02-20-95 nda added queuing to SCAN_IO_EVENT mode so no - * transitions of data would be missed. - * 2.01 08-07-95 nda Multiple records with DOLN's didn't work, - * added calloc for dola structure. - * 3.00 08-28-95 nda Significant rewrite to add Channel Access - * for dynamic links using recDynLink.c . All - * inputs are now "monitored" via Channel Access. - * Removed some "callbacks" because recDynLink - * lib uses it's own task context. - * INxV field is used to keep track of PV - * connection status: 0-PV_OK, - * 1-NotConnected, 2-NO_PV - * 3.01 10-03-95 nda Also post monitors on .la, .lb, .lc etc - * when new values are written - * - * - */ - -#define VERSION 3.01 - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dbDefs.h" -#include "epicsPrint.h" -#include "alarm.h" -#include "dbAccess.h" -#include "dbEvent.h" -#include "dbScan.h" -#include "dbDefs.h" -#include "dbFldTypes.h" -#include "devSup.h" -#include "errMdef.h" -#include "rngLib.h" -#include "recSup.h" -#include "special.h" -#include "callback.h" -#include "taskwd.h" -#include "postfix.h" - -#include "choiceWait.h" -#define GEN_SIZE_OFFSET -#include "waitRecord.h" -#undef GEN_SIZE_OFFSET -#include "recDynLink.h" - - -/* Create RSET - Record Support Entry Table*/ -#define report NULL -#define initialize NULL -static long init_record(); -static long process(); -static long special(); -#define get_value NULL -#define cvt_dbaddr NULL -#define get_array_info NULL -#define put_array_info NULL -#define get_units NULL -static long get_precision(); -#define get_enum_str NULL -#define get_enum_strs NULL -#define put_enum_str NULL -static long get_graphic_double(); -#define get_control_double NULL -static long get_alarm_double(); - -struct rset waitRSET={ - 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 -}; - -/* Create DSET for "soft channel" to allow for IO Event (this is to implement - the feature of processing the record when an input changes) */ - -static long get_ioint_info(); -struct { - long number; - DEVSUPFUN dev_report; - DEVSUPFUN init_dev; - DEVSUPFUN dev_init_record; - DEVSUPFUN get_ioint_info; - DEVSUPFUN read_event; -}devWaitIoEvent={ - 5, - NULL, - NULL, - NULL, - get_ioint_info, - NULL}; - - -/* DEFINES */ -#define ARG_MAX 12 /* Number of input arguments of the record */ -#define IN_PVS 1 /* Number of other input dynamic links(DOLN) */ -#define OUT_PVS 1 /* Number of "non-input" dynamic links(OUTN) */ -#define DOL_INDEX ARG_MAX -#define OUT_INDEX (ARG_MAX + IN_PVS) -#define NUM_LINKS (ARG_MAX + IN_PVS + OUT_PVS) -#define PVN_SIZE 40 /*must match the length defined in waitRecord.db*/ -#define Q_SIZE 50 -#define PV_OK REC_WAIT_DYNL_OK /* from choiceWait.h */ -#define PV_NC REC_WAIT_DYNL_NC /* from choiceWait.h */ -#define NO_PV REC_WAIT_DYNL_NO_PV /* from choiceWait.h */ - -/********************************************** - Declare constants and structures -***********************************************/ - -/* callback structures and record private data */ -struct cbStruct { - CALLBACK doOutCb; /* cback struct for doing the OUT link*/ - CALLBACK ioProcCb; /* cback struct for io_event scanning */ - struct waitRecord *pwait; /* pointer to wait record */ - WDOG_ID wd_id; /* Watchdog used for delays */ - recDynLink caLinkStruct[NUM_LINKS]; /* req'd for recDynLink*/ - RING_ID monitorQ; /* queue to store ca callback data */ - IOSCANPVT ioscanpvt; /* used for IO_EVENT scanning */ - int outputWait;/* waiting to do output */ - int procPending;/*record processing is pending */ - unsigned long tickStart; /* used for timing */ -}; - - -typedef struct recDynLinkPvt { - struct waitRecord *pwait; /* pointer to wait record */ - unsigned short linkIndex; /* specifies which dynamic link */ -}recDynLinkPvt; - - -static long get_ioint_info(cmd,pwait,ppvt) - int cmd; - struct waitRecord *pwait; - IOSCANPVT *ppvt; -{ - *ppvt = (((struct cbStruct *)pwait->cbst)->ioscanpvt); - return(0); -} - - -/* This is the data that will be put on the work queue ring buffer */ -struct qStruct { - char inputIndex; - double monData; -}; - - -int recWaitDebug=0; -int recWaitCacheMode=0; -static void schedOutput(struct waitRecord *pwait); -static void execOutput(struct cbStruct *pcbst); -static int fetch_values(struct waitRecord *pwait); -static void monitor(struct waitRecord *pwait); -static long initSiml(); -static void ioIntProcess(CALLBACK *pioProcCb); - -static void pvSearchCallback(recDynLink *precDynLink); -static void inputChanged(recDynLink *precDynLink); - - -static long init_record(pwait,pass) - struct waitRecord *pwait; - int pass; -{ - struct cbStruct *pcbst; - long status = 0; - int i; - - char *ppvn[PVN_SIZE]; - unsigned short *pPvStat; - - recDynLinkPvt *puserPvt; - - short error_number; - - if (pass==0) { - pwait->vers = VERSION; - - pwait->cbst = calloc(1,sizeof(struct cbStruct)); - - /* init the private area of the caLinkStruct's */ - for(i=0;icbst)->caLinkStruct[i].puserPvt - = calloc(1,sizeof(struct recDynLinkPvt)); - puserPvt = ((struct cbStruct *)pwait->cbst)->caLinkStruct[i].puserPvt; - puserPvt->pwait = pwait; - puserPvt->linkIndex = i; - } - - /* do scanIoInit here because init_dev doesn't know which record */ - scanIoInit(&(((struct cbStruct *)pwait->cbst)->ioscanpvt)); - - return(0); - } - - /* This is pass == 1, so pwait->cbst is valid */ - - pcbst = (struct cbStruct *)pwait->cbst; - - pwait->clcv=postfix(pwait->calc,pwait->rpcl,&error_number); - if(pwait->clcv){ - recGblRecordError(S_db_badField,(void *)pwait, - "wait: init_record: Illegal CALC field"); - } - db_post_events(pwait,&pwait->clcv,DBE_VALUE); - - callbackSetCallback(execOutput, &pcbst->doOutCb); - callbackSetPriority(pwait->prio, &pcbst->doOutCb); - callbackSetCallback(ioIntProcess, &pcbst->ioProcCb); - callbackSetPriority(pwait->prio, &pcbst->ioProcCb); - callbackSetUser(pwait, &pcbst->ioProcCb); - pcbst->pwait = pwait; - pcbst->wd_id = wdCreate(); - if((pcbst->monitorQ=rngCreate(sizeof(struct qStruct)*Q_SIZE)) == NULL) { - errMessage(0,"recWait can't create ring buffer"); - exit(1); - } - - if (status=initSiml(pwait)) return(status); - - /* reset miscellaneous flags */ - pcbst->outputWait = 0; - pcbst->procPending = 0; - - pwait->init = TRUE; - - /* Do initial lookup of PV Names using recDynLink lib */ - - *ppvn = &pwait->inan[0]; - pPvStat = &pwait->inav; - - /* check all dynLinks for non-NULL */ - for(i=0;icaLinkStruct[i], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback, inputChanged); - } - else { - recDynLinkAddOutput(&pcbst->caLinkStruct[i], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback); - } - if(recWaitDebug > 5) printf("Search during init\n"); - } - else { - *pPvStat = NO_PV; - } - } - pwait->init = TRUE; - return(0); -} - -static long process(pwait) - struct waitRecord *pwait; -{ - short async = FALSE; - long status; - - pwait->pact = TRUE; - - /* Check for simulation mode */ - status=dbGetLink(&(pwait->siml),DBR_ENUM,&(pwait->simm),0,0); - - /* reset procPending before getting values */ - ((struct cbStruct *)pwait->cbst)->procPending = 0; - - if(pwait->simm == NO) { - if(fetch_values(pwait)==0) { - if(calcPerform(&pwait->a,&pwait->val,pwait->rpcl)) { - recGblSetSevr(pwait,CALC_ALARM,INVALID_ALARM); - } else pwait->udf = FALSE; - } - else { - recGblSetSevr(pwait,READ_ALARM,INVALID_ALARM); - } - } - else { /* SIMULATION MODE */ - status = dbGetLink(&(pwait->siol),DBR_DOUBLE,&(pwait->sval),0,0); - if (status==0){ - pwait->val=pwait->sval; - pwait->udf=FALSE; - } - recGblSetSevr(pwait,SIMM_ALARM,pwait->sims); - } - - /* decide whether to write Output PV */ - switch(pwait->oopt) { - case REC_WAIT_OUT_OPT_EVERY: - schedOutput(pwait); - async = TRUE; - break; - case REC_WAIT_OUT_OPT_CHANGE: - if(fabs(pwait->oval - pwait->val) > pwait->mdel) { - schedOutput(pwait); - async = TRUE; - } - break; - case REC_WAIT_OUT_OPT_CHG_TO_ZERO: - if((pwait->oval != 0) && (pwait->val == 0)) { - schedOutput(pwait); - async = TRUE; - } - break; - case REC_WAIT_OUT_OPT_CHG_TO_NZERO: - if((pwait->oval == 0) && (pwait->val != 0)) { - schedOutput(pwait); - async = TRUE; - } - break; - case REC_WAIT_OUT_OPT_WHEN_ZERO: - if(!pwait->val) { - schedOutput(pwait); - async = TRUE; - } - break; - case REC_WAIT_OUT_OPT_WHEN_NZERO: - if(pwait->val) { - schedOutput(pwait); - async = TRUE; - } - break; - default: - break; - } - - pwait->oval = pwait->val; - - recGblGetTimeStamp(pwait); - /* check event list */ - monitor(pwait); - - if (!async) { - pwait->pact = FALSE; - } - return(0); -} - -static long special(paddr,after) - struct dbAddr *paddr; - int after; -{ - struct waitRecord *pwait = (struct waitRecord *)(paddr->precord); - struct cbStruct *pcbst = (struct cbStruct *)pwait->cbst; - int special_type = paddr->special; - char *ppvn[PVN_SIZE]; - unsigned short *pPvStat; - unsigned short oldStat; - int index; - short error_number; - - if(recWaitDebug) printf("entering special %d \n",after); - - if(!after) { /* this is called before ca changes the field */ - - /* check if changing any dynamic link names */ - /* This is where one would do a recDynLinkClear, but it is - not required prior to a new search */ - return(0); - } - - /* this is executed after ca changed the field */ - if((special_type >= REC_WAIT_A) && - (special_type < (REC_WAIT_A + NUM_LINKS))) { - index = special_type - REC_WAIT_A; /* index of input */ - pPvStat = &pwait->inav + index; /* pointer arithmetic */ - oldStat = *pPvStat; - *ppvn = &pwait->inan[0] + (index*PVN_SIZE); - if(*ppvn[0] != NULL) { - if(recWaitDebug > 5) printf("Search during special \n"); - *pPvStat = PV_NC; - /* need to post_event before recDynLinkAddXxx because - SearchCallback could happen immediatley */ - if(*pPvStat != oldStat) { - db_post_events(pwait,pPvStat,DBE_VALUE); - } - if(indexcaLinkStruct[index], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback, inputChanged); - } - else { - recDynLinkAddOutput(&pcbst->caLinkStruct[index], *ppvn, - DBR_DOUBLE, rdlSCALAR, pvSearchCallback); - } - } - else if(*pPvStat != NO_PV) { - /* PV is now NULL but didn't used to be */ - *pPvStat = NO_PV; /* PV just cleared */ - if(*pPvStat != oldStat) { - db_post_events(pwait,pPvStat,DBE_VALUE); - } - recDynLinkClear(&pcbst->caLinkStruct[index]); - } - return(0); - } - else if(special_type == SPC_CALC) { - pwait->clcv=postfix(pwait->calc,pwait->rpcl,&error_number); - if(pwait->clcv){ - recGblRecordError(S_db_badField,(void *)pwait, - "wait: init_record: Illegal CALC field"); - } - db_post_events(pwait,&pwait->clcv,DBE_VALUE); - return(0); - } - else if(paddr->pfield==(void *)&pwait->prio) { - callbackSetPriority(pwait->prio, &pcbst->doOutCb); - callbackSetPriority(pwait->prio, &pcbst->ioProcCb); - return(0); - } - else { - recGblDbaddrError(S_db_badChoice,paddr,"wait: special"); - return(S_db_badChoice); - return(0); - } -} - -static long get_precision(paddr,precision) - struct dbAddr *paddr; - long *precision; -{ - struct waitRecord *pwait=(struct waitRecord *)paddr->precord; - - *precision = pwait->prec; - if(paddr->pfield == (void *)&pwait->val) { - *precision = pwait->prec; - } - else if(paddr->pfield == (void *)&pwait->odly) { - *precision = 3; - } - return(0); -} - -static long get_graphic_double(paddr,pgd) - struct dbAddr *paddr; - struct dbr_grDouble *pgd; -{ - struct waitRecord *pwait=(struct waitRecord *)paddr->precord; - - if (paddr->pfield==(void *)&pwait->val) { - pgd->upper_disp_limit = pwait->hopr; - pgd->lower_disp_limit = pwait->lopr; - } else recGblGetGraphicDouble(paddr,pgd); - return(0); -} - -static long get_alarm_double(paddr,pad) - struct dbAddr *paddr; - struct dbr_alDouble *pad; -{ - recGblGetAlarmDouble(paddr,pad); - return(0); -} - -static void monitor(pwait) - struct waitRecord *pwait; -{ - unsigned short monitor_mask; - double delta; - double *pnew; - double *pprev; - int i; - - monitor_mask = recGblResetAlarms(pwait); - /* check for value change */ - delta = pwait->mlst - pwait->val; - if(delta<0.0) delta = -delta; - if (delta > pwait->mdel) { - /* post events for value change */ - monitor_mask |= DBE_VALUE; - /* update last value monitored */ - pwait->mlst = pwait->val; - } - /* check for archive change */ - delta = pwait->alst - pwait->val; - if(delta<0.0) delta = -delta; - if (delta > pwait->adel) { - /* post events on value field for archive change */ - monitor_mask |= DBE_LOG; - /* update last archive value monitored */ - pwait->alst = pwait->val; - } - - /* send out monitors connected to the value field */ - if (monitor_mask){ - db_post_events(pwait,&pwait->val,monitor_mask); - } - /* check all input fields for changes */ - for(i=0, pnew=&pwait->a, pprev=&pwait->la; isiml.type == CONSTANT) { - recGblInitConstantLink(&pwait->siml,DBF_USHORT,&pwait->simm); - } - - /* wait.siol must be a CONSTANT or a PV_LINK or a DB_LINK */ - if (pwait->siol.type == CONSTANT) { - recGblInitConstantLink(&pwait->siol,DBF_DOUBLE,&pwait->sval); - } - - return(0); -} - -static int fetch_values(pwait) -struct waitRecord *pwait; -{ - struct cbStruct *pcbst = (struct cbStruct *)pwait->cbst; - double *pvalue; - unsigned short *pPvStat; - unsigned short *piointInc; /* include for IO_INT ? */ - long status=0; - size_t nRequest=1; - int i; - - piointInc = &pwait->inap; - for(i=0, pvalue=&pwait->a, pPvStat = &pwait->inav; - iscan != SCAN_IO_EVENT) || - ((pwait->scan == SCAN_IO_EVENT) && !*piointInc))) { - if(recWaitDebug > 5) printf("Fetching input %d \n",i); - status = recDynLinkGet(&pcbst->caLinkStruct[i], pvalue, - &nRequest, 0, 0, 0); - } - if (!RTN_SUCCESS(status)) return(status); - } - return(0); -} - -/*************************************************************************** - * - * The following functions schedule and/or request the execution of the - * output PV and output event based on the Output Execution Delay (ODLY). - * If .odly > 0, a watchdog is scheduled; if 0, execOutput() is called - * immediately. - * NOTE: THE RECORD REMAINS "ACTIVE" WHILE WAITING ON THE WATCHDOG - * - **************************************************************************/ -static void schedOutput(pwait) - struct waitRecord *pwait; -{ - -struct cbStruct *pcbst = (struct cbStruct *)pwait->cbst; - -int wdDelay; - - if(pwait->odly > 0.0) { - /* Use the watch-dog as a delay mechanism */ - pcbst->outputWait = 1; - wdDelay = pwait->odly * sysClkRateGet(); - wdStart(pcbst->wd_id, wdDelay, (FUNCPTR)execOutput, (int)(pwait->cbst)); - } else { - execOutput(pwait->cbst); - } -} - -/*************************************************************************** - * - * This code calls recDynLinkPut to execute the output link. Since requests - * recDynLinkPut are done via another task, one need not worry about - * lock sets. - * - ***************************************************************************/ -void execOutput(pcbst) - struct cbStruct *pcbst; -{ -long status; -size_t nRequest = 1; -double oldDold; - - /* if output link is valid , decide between VAL and DOL */ - if(!pcbst->pwait->outv) { - if(pcbst->pwait->dopt) { - if(!pcbst->pwait->dolv) { - oldDold = pcbst->pwait->dold; - status = recDynLinkGet(&pcbst->caLinkStruct[DOL_INDEX], - &(pcbst->pwait->dold), &nRequest, 0, 0, 0); - if(pcbst->pwait->dold != oldDold) - db_post_events(pcbst->pwait,&pcbst->pwait->dold,DBE_VALUE); - } - status = recDynLinkPut(&pcbst->caLinkStruct[OUT_INDEX], - &(pcbst->pwait->dold), 1); - } else { - status = recDynLinkPut(&pcbst->caLinkStruct[OUT_INDEX], - &(pcbst->pwait->val), 1); - } - } - - /* post event if output event != 0 */ - if(pcbst->pwait->oevt > 0) { - post_event((int)pcbst->pwait->oevt); - } - - recGblFwdLink(pcbst->pwait); - pcbst->pwait->pact = FALSE; - pcbst->outputWait = 0; - - /* If I/O Interrupt scanned, see if any inputs changed during delay */ - if((pcbst->pwait->scan == SCAN_IO_EVENT) && (pcbst->procPending == 1)) { - scanOnce(pcbst->pwait); - } - - return; -} - - - -/* This routine is called by the recDynLink task whenver a monitored input - * changes. If the particular input is flagged to cause record processing, - * The input index and new data are put on a work queue, and a callback - * request is issued to the routine ioIntProcess - */ - -static void inputChanged(recDynLink *precDynLink) -{ - struct waitRecord *pwait = ((recDynLinkPvt *)precDynLink->puserPvt)->pwait; - struct cbStruct *pcbst = (struct cbStruct *)pwait->cbst; - double monData; - size_t nRequest; - char index; - unsigned short *piointInc; - - if(pwait->scan != SCAN_IO_EVENT) return; - - index = (char)((recDynLinkPvt *)precDynLink->puserPvt)->linkIndex; - - piointInc = &pwait->inap + index; /* pointer arithmetic */ - if(*piointInc == 0) return; /* input cause processing ???*/ - - /* put input index and monitored data on processing queue */ - recDynLinkGet(precDynLink, &monData, &nRequest, 0, 0, 0); - if(recWaitDebug>5) - printf("queuing monitor on %d = %f\n",index,monData); - if(rngBufPut(pcbst->monitorQ, (void *)&index, sizeof(char)) - != sizeof(char)) errMessage(0,"recWait rngBufPut error"); - if(rngBufPut(pcbst->monitorQ, (void *)&monData, sizeof(double)) - != sizeof(double)) errMessage(0,"recWait rngBufPut error"); - callbackRequest(&pcbst->ioProcCb); -} - - -/* This routine performs the record processing when in SCAN_IO_EVENT. An - event queue is built by inputChanged() and emptied here so each change - of an input causes the record to process. -*/ -static void ioIntProcess(CALLBACK *pioProcCb) -{ - - struct waitRecord *pwait; - struct cbStruct *pcbst; - - char inputIndex; - double monData; - double *pInput; - - callbackGetUser(pwait, pioProcCb); - pcbst = (struct cbStruct *)pwait->cbst; - pInput = &pwait->a; /* a pointer to the first input field */ - - if(pwait->scan != SCAN_IO_EVENT) return; - - if(!recWaitCacheMode) { - if(rngBufGet(pcbst->monitorQ, (void *)&inputIndex, sizeof(char)) - != sizeof(char)) errMessage(0, "recWait: rngBufGet error"); - if(rngBufGet(pcbst->monitorQ, (void *)&monData, sizeof(double)) - != sizeof(double)) errMessage(0, "recWait: rngBufGet error"); - - if(recWaitDebug>=5) - printf("processing on %d = %f (%f)\n", - inputIndex, monData,pwait->val); - - pInput += inputIndex; /* pointer arithmetic for appropriate input */ - dbScanLock((struct dbCommon *)pwait); - *pInput = monData; /* put data in input data field */ - - /* Process the record, unless busy waiting to do the output link */ - if(pcbst->outputWait) { - pcbst->procPending = 1; - if(recWaitDebug) printf("record busy, setting procPending\n"); - } - else { - dbProcess((struct dbCommon *)pwait); /* process the record */ - } - dbScanUnlock((struct dbCommon *)pwait); - } - else { - if(recWaitDebug>=5) printf("processing (cached)\n"); - dbScanLock((struct dbCommon *)pwait); - dbProcess((struct dbCommon *)pwait); /* process the record */ - dbScanUnlock((struct dbCommon *)pwait); - } - -} - - -LOCAL void pvSearchCallback(recDynLink *precDynLink) -{ - - recDynLinkPvt *puserPvt = (recDynLinkPvt *)precDynLink->puserPvt; - struct waitRecord *pwait = puserPvt->pwait; - unsigned short index = puserPvt->linkIndex; - unsigned short *pPvStat; - unsigned short oldValid; - - pPvStat = &pwait->inav + index; /* pointer arithmetic */ - puserPvt = (recDynLinkPvt *)precDynLink->puserPvt; - - oldValid = *pPvStat; - if(recDynLinkConnectionStatus(precDynLink)) { - *pPvStat = PV_NC; - if(recWaitDebug) printf("Search Callback: No Connection\n"); - } - else { - *pPvStat = PV_OK; - if(recWaitDebug) printf("Search Callback: Success\n"); - } - if(*pPvStat != oldValid) { - db_post_events(pwait, pPvStat, DBE_VALUE); - } - -} - - diff --git a/src/rec/waitRecord.dbd b/src/rec/waitRecord.dbd deleted file mode 100644 index 8ba2df5a7..000000000 --- a/src/rec/waitRecord.dbd +++ /dev/null @@ -1,517 +0,0 @@ -menu(waitOOPT) { - choice(waitOOPT_Every_Time,"Every Time") - choice(waitOOPT_On_Change,"On Change") - choice(waitOOPT_When_Zero,"When Zero") - choice(waitOOPT_When_Non_zero,"When Non-zero") - choice(waitOOPT_Transition_To_Zero,"Transition To Zero") - choice(waitOOPT_Transition_To_Non_zero,"Transition To Non-zero") -} -menu(waitDOPT) { - choice(waitDOPT_Use_VAL,"Use VAL") - choice(waitDOPT_Use_DOL,"Use DOL") -} -menu(waitINAP) { - choice(waitINAP_No,"No") - choice(waitINAP_Yes,"Yes") -} -menu(waitINAV) { - choice(waitINAV_PV_OK,"PV OK") - choice(waitINAV_PV_BAD,"PV BAD") - choice(waitINAV_No_PV,"No PV") -} -recordtype(wait) { - include "dbCommon.dbd" - field(VERS,DBF_FLOAT) { - prompt("Code Version") - special(SPC_NOMOD) - initial("1") - } - field(HOPR,DBF_FLOAT) { - prompt("High Operating Range") - promptgroup(GUI_ALARMS) - asl(ASL0) - interest(1) - } - field(LOPR,DBF_FLOAT) { - prompt("Low Operating Range") - promptgroup(GUI_BITS1) - asl(ASL0) - interest(1) - } - field(INIT,DBF_SHORT) { - prompt("Initialized?") - special(SPC_NOMOD) - interest(3) - } - field(CBST,DBF_NOACCESS) { - prompt("Pointer to cbStruct") - special(SPC_NOMOD) - interest(4) - extra("void * cbst") - } - field(INAN,DBF_STRING) { - prompt("INPA PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(110) - interest(1) - size(40) - } - field(INBN,DBF_STRING) { - prompt("INPB PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(111) - interest(1) - size(40) - } - field(INCN,DBF_STRING) { - prompt("INPC PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(112) - interest(1) - size(40) - } - field(INDN,DBF_STRING) { - prompt("INPD PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(113) - interest(1) - size(40) - } - field(INEN,DBF_STRING) { - prompt("INPE PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(114) - interest(1) - size(40) - } - field(INFN,DBF_STRING) { - prompt("INPF PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(115) - interest(1) - size(40) - } - field(INGN,DBF_STRING) { - prompt("INPG PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(116) - interest(1) - size(40) - } - field(INHN,DBF_STRING) { - prompt("INPH PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(117) - interest(1) - size(40) - } - field(ININ,DBF_STRING) { - prompt("INPI PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(118) - interest(1) - size(40) - } - field(INJN,DBF_STRING) { - prompt("INPJ PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(119) - interest(1) - size(40) - } - field(INKN,DBF_STRING) { - prompt("INPK PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(120) - interest(1) - size(40) - } - field(INLN,DBF_STRING) { - prompt("INPL PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(121) - interest(1) - size(40) - } - field(DOLN,DBF_STRING) { - prompt("DOL PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(122) - interest(1) - size(40) - } - field(OUTN,DBF_STRING) { - prompt("OUT PV Name") - promptgroup(GUI_CALC) - asl(ASL0) - special(123) - interest(1) - size(40) - } - field(INAV,DBF_MENU) { - prompt("INPA PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INBV,DBF_MENU) { - prompt("INPB PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INCV,DBF_MENU) { - prompt("INPC PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INDV,DBF_MENU) { - prompt("INPD PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INEV,DBF_MENU) { - prompt("INPE PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INFV,DBF_MENU) { - prompt("INPF PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INGV,DBF_MENU) { - prompt("INPG PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INHV,DBF_MENU) { - prompt("INPH PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INIV,DBF_MENU) { - prompt("INPI PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INJV,DBF_MENU) { - prompt("INPJ PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INKV,DBF_MENU) { - prompt("INPK PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(INLV,DBF_MENU) { - prompt("INPL PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(DOLV,DBF_MENU) { - prompt("DOL PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(OUTV,DBF_MENU) { - prompt("OUT PV Status") - special(SPC_NOMOD) - interest(1) - menu(waitINAV) - } - field(A,DBF_DOUBLE) { - prompt("Value of Input A") - pp(TRUE) - } - field(B,DBF_DOUBLE) { - prompt("Value of Input B") - pp(TRUE) - } - field(C,DBF_DOUBLE) { - prompt("Value of Input C") - pp(TRUE) - } - field(D,DBF_DOUBLE) { - prompt("Value of Input D") - pp(TRUE) - } - field(E,DBF_DOUBLE) { - prompt("Value of Input E") - pp(TRUE) - } - field(F,DBF_DOUBLE) { - prompt("Value of Input F") - pp(TRUE) - } - field(G,DBF_DOUBLE) { - prompt("Value of Input G") - pp(TRUE) - } - field(H,DBF_DOUBLE) { - prompt("Value of Input H") - pp(TRUE) - } - field(I,DBF_DOUBLE) { - prompt("Value of Input I") - pp(TRUE) - } - field(J,DBF_DOUBLE) { - prompt("Value of Input J") - pp(TRUE) - } - field(K,DBF_DOUBLE) { - prompt("Value of Input K") - pp(TRUE) - } - field(L,DBF_DOUBLE) { - prompt("Value of Input L") - pp(TRUE) - } - field(LA,DBF_DOUBLE) { - prompt("Last Val of Input A") - } - field(LB,DBF_DOUBLE) { - prompt("Last Val of Input B") - } - field(LC,DBF_DOUBLE) { - prompt("Last Val of Input C") - } - field(LD,DBF_DOUBLE) { - prompt("Last Val of Input D") - } - field(LE,DBF_DOUBLE) { - prompt("Last Val of Input E") - } - field(LF,DBF_DOUBLE) { - prompt("Last Val of Input F") - } - field(LG,DBF_DOUBLE) { - prompt("Last Val of Input G") - } - field(LH,DBF_DOUBLE) { - prompt("Last Val of Input H") - } - field(LI,DBF_DOUBLE) { - prompt("Last Val of Input I") - } - field(LJ,DBF_DOUBLE) { - prompt("Last Val of Input J") - } - field(LK,DBF_DOUBLE) { - prompt("Last Val of Input K") - } - field(LL,DBF_DOUBLE) { - prompt("Last Val of Input L") - } - field(INAP,DBF_MENU) { - prompt("INPA causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INBP,DBF_MENU) { - prompt("INPB causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INCP,DBF_MENU) { - prompt("INPC causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INDP,DBF_MENU) { - prompt("INPD causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INEP,DBF_MENU) { - prompt("INPE causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INFP,DBF_MENU) { - prompt("INPF causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INGP,DBF_MENU) { - prompt("INPG causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INHP,DBF_MENU) { - prompt("INPH causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INIP,DBF_MENU) { - prompt("INPI causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INJP,DBF_MENU) { - prompt("INPJ causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INKP,DBF_MENU) { - prompt("INPK causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(INLP,DBF_MENU) { - prompt("INPL causes I/O INTR") - promptgroup(GUI_CALC) - interest(1) - menu(waitINAP) - initial("Yes") - } - field(CALC,DBF_STRING) { - prompt("Calculation") - promptgroup(GUI_CLOCK) - asl(ASL0) - special(SPC_CALC) - size(36) - } - field(RPCL,DBF_NOACCESS) { - prompt("Reverse Polish Calc") - special(SPC_NOMOD) - interest(4) - extra("char rpcl[184]") - } - field(CLCV,DBF_LONG) { - prompt("CALC Valid") - interest(1) - } - field(VAL,DBF_DOUBLE) { - prompt("Value Field") - } - field(OVAL,DBF_DOUBLE) { - prompt("Old Value") - } - field(PREC,DBF_SHORT) { - prompt("Display Precision") - promptgroup(GUI_COMMON) - interest(1) - } - field(OOPT,DBF_MENU) { - prompt("Output Execute Opt") - promptgroup(GUI_CALC) - interest(1) - menu(waitOOPT) - } - field(ODLY,DBF_FLOAT) { - prompt("Output Execute Delay") - promptgroup(GUI_ALARMS) - asl(ASL0) - interest(1) - } - field(DOPT,DBF_MENU) { - prompt("Output Data Option") - promptgroup(GUI_CALC) - interest(1) - menu(waitDOPT) - } - field(DOLD,DBF_DOUBLE) { - prompt("Desired Output Data") - promptgroup(GUI_CLOCK) - asl(ASL0) - interest(1) - } - field(OEVT,DBF_USHORT) { - prompt("Event To Issue") - promptgroup(GUI_CLOCK) - asl(ASL0) - } - field(ADEL,DBF_DOUBLE) { - prompt("Archive Deadband") - promptgroup(GUI_CLOCK) - interest(1) - } - field(MDEL,DBF_DOUBLE) { - prompt("Monitor Deadband") - promptgroup(GUI_CLOCK) - interest(1) - } - field(ALST,DBF_DOUBLE) { - prompt("Last Value Archived") - special(SPC_NOMOD) - interest(3) - } - field(MLST,DBF_DOUBLE) { - prompt("Last Val Monitored") - special(SPC_NOMOD) - interest(3) - } - field(SIOL,DBF_INLINK) { - prompt("Sim Input Specifctn") - promptgroup(GUI_PULSE) - interest(1) - } - field(SVAL,DBF_DOUBLE) { - prompt("Simulation Value") - } - field(SIML,DBF_INLINK) { - prompt("Sim Mode Location") - promptgroup(GUI_PULSE) - interest(1) - } - field(SIMM,DBF_MENU) { - prompt("Simulation Mode") - interest(1) - menu(menuYesNo) - } - field(SIMS,DBF_MENU) { - prompt("Sim mode Alarm Svrty") - promptgroup(GUI_SELECT) - interest(2) - menu(menuAlarmSevr) - } -} diff --git a/src/rec/waveformRecord.c b/src/rec/waveformRecord.c index 2a8a8cded..28bd427ad 100644 --- a/src/rec/waveformRecord.c +++ b/src/rec/waveformRecord.c @@ -60,25 +60,24 @@ * .20 09-14-92 jba nord set only for db links */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "dbDefs.h" #include "epicsPrint.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "alarm.h" +#include "dbAccess.h" +#include "dbEvent.h" +#include "dbFldTypes.h" +#include "dbScan.h" +#include "devSup.h" +#include "errMdef.h" +#include "recSup.h" #define GEN_SIZE_OFFSET -#include +#include "waveformRecord.h" #undef GEN_SIZE_OFFSET /* Create RSET - Record Support Entry Table*/ #define report NULL