/* File: drvuScopeBias.h * Author: Hovanes Egiyan, Jefferson Lab * Date: 10-Jan-2014 * * Purpose: * This module provides the driver support for the asyn device support layer * for UConn bias voltages. This asyn driver will be using drvuScopeBiasBoard * driver class to dynamically crate the EPICS DB and to update the EPICS records. * */ #ifndef _DRV_USCOPE_BIAS_HH_ #define _DRV_USCOPE_BIAS_HH_ /************/ /* Includes */ /************/ #include #include #include #include #include #include /* EPICS includes */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // include header file for the MpodCrate driver //#include "drvMPOD.hh" #include "MtxLock.hh" #include #include #include #include using namespace std; /***************/ /* Definitions */ /***************/ #define uScopeBiasBoardNumberString "BIAS_BOARD_NUMBER" // C-function with global scope that calls the member function void readBiasParameters( void *drvPtr ); // AsynPortDriver for MPOD global parameters // it inherits from asynPortDriver class drvuScopeBias : public asynPortDriver { protected: epicsEventId dubEventID; //! Event ID for waking up reading thread pthread_mutex_t dubMutex; //! Mutex for an object pthread_mutexattr_t dubMtxAttr; //! Mutex attributes for an object static pthread_mutex_t dubClassMutex; //! Class mutex for this class static pthread_mutexattr_t dubClassMtxAttr; //! Class mutex attributes static string dubbDriverName; //! Name of this driver static string dubDirDB; //! Path to be used when dynamically loading DB files static string dubFileNameDB; //! Template DB filename static drvuScopeBias* dubInstancePtr; //! Pointer to the instance static string dubPortName; //! Port name for this class, can only be one // Main Constructor to be called when creation of a driver is requested from IOC script drvuScopeBias(); //! Main Constructor to be called when creation of a driver is requested from IOC script drvuScopeBias( const char* pName ); //! Initialize the mutex for the object void initMutex(); //! Destroy the mutex for the object void closeMutex(); //! Lock the class mutex for this class inline static int classLock() { return pthread_mutex_lock( &dubClassMutex ); } //! Unlock the class mutex for this class inline static int classUnlock() { return pthread_mutex_unlock( &dubClassMutex ); } public: //! Destructor ~drvuScopeBias(); //! Print out the report for this AsynPortDriver virtual void report( FILE *fp, int details ); //! This is the main function for reading. It is executed //! in a separate thread and fills the values. void readBiasParameters(); //! Dynamically load records using template EPICS DB files static int loadRecords(); //1 Return the only instance of the class static drvuScopeBias* getInstance(); //! Initialize global mutex static int initGlobalMutex(); inline static string getDirDB() { MtxLock classLock( dubClassMutex ); return dubDirDB; } #define FIRST_USCOPE_BIAS_PARAM uScopeBiasBoardNumber_ int uScopeBiasBoardNumber_ ; #define LAST_USCOPE_BIAS_PARAM uScopeBiasBoardNumber_ #define NUM_USCOPE_BIAS_PARAMS (&LAST_USCOPE_BIAS_PARAM - &FIRST_USCOPE_BIAS_PARAM + 1) }; /***********************/ /* Function prototypes */ /***********************/ /* External functions */ /* iocsh functions */ extern "C" { int dbLoadRecordsMPOD( const char *dummy ); } #endif