#include #include #include #include "errMdef.h" #include "devLib.h" #include "dbAccess.h" #include "dbScan.h" /* for SCAN_IO_EVENT */ #include "callback.h" #include "cvtTable.h" #include "link.h" #include "alarm.h" #include "recSup.h" #include "devSup.h" #include "dbCommon.h" #include "mbboRecord.h" #include "epicsExport.h" #include "epicsInterrupt.h" #include #include "drvPac.h" LOCAL long init_mbbo(struct mbboRecord *prec); LOCAL long mbbo_ioinfo(int cmd, struct mbboRecord *prec, IOSCANPVT *ppvt); LOCAL long write_mbbo(struct mbboRecord *prec); typedef struct mbboPac_s { int type; } mbboPac_t; typedef struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read_write; } MBBIDIRECTDSET; MBBIDIRECTDSET devMbboPac = {5, NULL, NULL, init_mbbo, mbbo_ioinfo, write_mbbo}; epicsExportAddress(dset, devMbboPac); #ifdef DEBUG_PRINT int devMbboPacFlag = 4; #endif int mbOverwriting = FALSE; LOCAL int mbboRecordsWithIOScanCount = 0; /*int pacGetMbboRecordsWithIOScanCount() { return mbboRecordsWithIOScanCount; }*/ LOCAL long init_mbbo ( struct mbboRecord *pmbbo ) { mbboPac_t *pmbbop; /* Allocate the memory for this records private data structure */ pmbbop = (mbboPac_t *) malloc(sizeof(mbboPac_t)); if (pmbbop == NULL) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("init_mbbo: %s: out of memory\n", pmbbo->name)); #endif return S_dev_noMemory; } /* Read the DBLINK "out" field to get the type */ sscanf(pmbbo->out.value.instio.string, "%d", &(pmbbop->type)); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboPacFlag, ("init_mbbo: %s: has parm: %s\n", pmbbo->name, pmbbo->out.value.instio.string)); DEBUGPRINT(DP_INFO, devMbboPacFlag, ("init_mbbo: %s's dpvt has type: %d\n", pmbbo->name, pmbbop->type)); #endif /* Tell the record about its private data structure */ pmbbo->dpvt = pmbbop; return OK; } LOCAL long mbbo_ioinfo ( int cmd, struct mbboRecord *pmbbo, IOSCANPVT *ppvt ) { /*mbboRecordsWithIOScanCount++; */ #ifdef SCANIO *ppvt = pacGetIoScanPvt(); #endif return OK; } LOCAL long write_mbbo ( struct mbboRecord *pmbbo) { int rc; mbboPac_t *pmbbop; /* ptr to record's private data structure */ /* Set this to facilitate easy access to dataAddress field */ pmbbop = (mbboPac_t *) pmbbo->dpvt; switch (pmbbop->type) { case 0: rc = pacSetTriggerMode((int)pmbbo->val); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboPacFlag, ("write_mbbo: %s: setting trigger mode to: %d\n", pmbbo->name, (int) pmbbo->val)); #endif #ifdef DEBUG_PRINT if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("write_mbbo: %s: unable to set trigger mode to: %d\n", pmbbo->name, (int) pmbbo->val)); /*pmbbo->sevr = INVALID;*/ } #endif break; case 1: rc = pacSetOperationMode((int)pmbbo->val); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboPacFlag, ("write_mbbo: %s: setting operation mode to: %d\n", pmbbo->name, (int) pmbbo->val)); #endif #ifdef DEBUG_PRINT if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("write_mbbo: %s: unable to set operation mode to: %d\n", pmbbo->name, (int) pmbbo->val)); /* pmbbo->sevr = INVALID;*/ } #endif break; case 2: rc = pacSetCalibrationControl((int)pmbbo->val); #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboPacFlag, ("write_mbbo: %s: setting calibration control to: %d\n", pmbbo->name, (int) pmbbo->val)); #endif #ifdef DEBUG_PRINT if (rc == ERROR) { DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("write_mbbo: %s: unable to set calibration control to: %d\n", pmbbo->name, (int) pmbbo->val)); /*pmbbo->sevr = INVALID;*/ } #endif break; case 3: rc = pacSetSelectedWf((int)(pmbbo->val)); if (rc != OK) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("write_mbbo: %s: load waveforms[%d] from file\n", pmbbo->name, (int)(pmbbo->val))); #endif } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboPacFlag, ("write_mbbo: %s: flnking to FAN_WF to load waveforms[%d] from file\n", pmbbo->name, (int)(pmbbo->val))); #endif break; case 4: rc = pacSetSelectedCwf((int)(pmbbo->val)); if (rc != OK) { #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("write_mbbo: %s: load waveforms[%d] from file\n", pmbbo->name, (int)(pmbbo->val))); #endif } #ifdef DEBUG_PRINT DEBUGPRINT(DP_INFO, devMbboPacFlag, ("write_mbbo: %s: flnking to FAN_CWF to load cal waveforms from file\n", pmbbo->name)); #endif break; case 5: rc = pacSetDiagMode((int)(pmbbo->val)); break; default: #ifdef DEBUG_PRINT DEBUGPRINT(DP_ERROR, devMbboPacFlag, ("write_mbbo: %s: unrecognized value in type: %d\n", pmbbo->name, (int) pmbbop->type)); #endif /*pmbbo->sevr = INVALID;*/ return ERROR; } return OK; }