/* * asynMasterOscillatorDrv.hh * * Created on: Sep 14, 2015 * Author: Hovanes Egiyan */ #ifndef ASYNMASTEROSCILLATORDRV_HH_ #define ASYNMASTEROSCILLATORDRV_HH_ /************/ /* Includes */ /************/ #include #include #include #include #include #include #include #include /* EPICS includes */ #include #include #include #include #include #include #include #include #include #include #include #include #include extern "C" { #include "jvme.h" #include "moLib.h" } #include #include #include #include #include #include #include #include #include "asynPortDriver.h" #include "MtxLock.hh" #include "MutexedClass.hh" class moVAsynPar; class asynMasterOscillatorDrv: public asynPortDriver, public MutexedClass { protected: class VMELock { VMELock() { vmeBusLock(); } ~VMELock() { vmeBusUnlock(); } void lock() { vmeBusLock(); } void unlock() { vmeBusUnlock(); } }; static std::string amodDriverName; // Name of the driver static unsigned amodParamNumber; // Number of parameters for MO board static unsigned amodMaxChannels; // Number of channels on the MO board // static unsigned long amodWaitTime; // Number of uSeconds for repeating the set requests. // Vector of asyn parameters std::vector amodParVec; bool amodExists; // Flag indicating if already exists unsigned amodBaseAddr; // Base address of the VME module epicsEventId amodEventID; // Event ID for waking up reading thread // Creates new vector of parameters for this driver virtual void createParVector(); // This is the main function for reading. It is executed // in a separate thread and fills the values. void readMasterOscillator(); public: // Asyn Port Driver constructor asynMasterOscillatorDrv(const std::string portName, const unsigned baseAddr); // destructor virtual ~asynMasterOscillatorDrv(); // These are the methods we override from asynPortDriver virtual asynStatus readUInt32Digital ( asynUser* pasynUser, epicsUInt32* value, epicsUInt32 mask ) ; virtual asynStatus writeUInt32Digital( asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask ); virtual asynStatus readFloat64 ( asynUser* pasynUser, epicsFloat64* value ) ; virtual asynStatus writeFloat64( asynUser *pasynUser, epicsFloat64 value ); inline virtual unsigned getZero( const unsigned channel ){return 0;} virtual unsigned resetBoard( const unsigned channel, const unsigned reset ); virtual unsigned getPrescale( const unsigned channel ); virtual unsigned setPrescale( const unsigned channel, const unsigned prescale ); virtual unsigned getInitialPrescale( const unsigned channel ); virtual unsigned setInitialPrescale( const unsigned channel, const unsigned prescale ); virtual unsigned getDutyMode( const unsigned channel ); virtual unsigned setDutyMode( const unsigned channel, const unsigned prescale ); virtual double getDutyCycle( const unsigned channel ); inline static std::string getDriverName() {return amodDriverName;} inline static unsigned getParamNumber() {return amodParamNumber;} inline static unsigned getMaxChannels() {return amodMaxChannels;} // Check if the driver with this port name already exists inline virtual bool driverExists() {return amodExists;} // return base address inline unsigned getBaseAddress() {return amodBaseAddr;} // This function simply calls the member function of the driver readMasterOscillator(). static void threadFunction( void *drvPvt ); //! Initialize VME bus connection static int initVME(); }; #endif /* ASYNMASTEROSCILLATORDRV_HH_ */