#ifndef __BOARD_VASYNPAR_HH__ #define __BOARD_VASYNPAR_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 "new" #include "boost/function.hpp" #include "boost/bind.hpp" #include "asynDrvBoard.hh" #include "MtxLock.hh" #include "MutexedClass.hh" // Base class for asyn parameters template class boardVAsynPar : public MutexedClass { public: // define a type to the member function of jlab board // typedef uint32_t (BoardClass::*bvapRdPtr)(); // typedef uint32_t (BoardClass::*bvapWtPtr)(uint32_t); // typedef boost::function< vector(unsigned)> bvapRdPtrType; // typedef boost::function< vector(double, unsigned)> bvapWtPtrType; protected: // boost::function bvapReadFun; //! Address of the function to call for reading // boost::function bvapWriteFun; //! Address of the function to call for writing int bvapParNum; //! Asyn driver parameter index string bvapParName; //! Asyn parameter name epicsUInt32 bvapMask; //! Mask for reading int bvapElmNum; //! Number of elements the driver will return bool bvapSingleChannel; //! Flag to indicate that this parameter is single channel public: static epicsUInt32 bvapAllBitMask; //! Enable all 32 bits public: boardVAsynPar() : bvapParNum(-1), bvapParName(""), bvapMask( bvapAllBitMask), bvapElmNum(0), bvapSingleChannel(true) { } // This is the main constructor. It only initialized the parameters of the asyn parameter. // This method is expected to be called before the corresponding AsynDriver is created, therefore // actual creation of the parameter for an asyn driver should happen later from the AsynDriver's // constructor. This weird feature is because of the way AsynPortDriver class is organized. boardVAsynPar(string parName, int parNum, epicsUInt32 mask = bvapAllBitMask ) : bvapParNum(parNum), bvapParName( parName), bvapMask(mask), bvapElmNum(0), bvapSingleChannel( true) { return; } boardVAsynPar(const boardVAsynPar& par) : bvapParNum( par.bvapParNum), bvapParName(par.bvapParName), bvapMask( par.bvapMask), bvapElmNum(par.bvapElmNum), bvapSingleChannel( par.bvapSingleChannel) { return; } virtual ~boardVAsynPar() { closeMutex(); } virtual boardVAsynPar& operator=(const boardVAsynPar& argPar) { boardVAsynPar& par = const_cast(argPar); // Remove constness MtxLock selfObjLock(mcMutex); MtxLock otherObjLock(par.mcMutex); bvapParNum = par.bvapParNum; bvapParName = par.bvapParName; bvapMask = par.bvapMask; bvapElmNum = par.bvapElmNum; bvapSingleChannel = par.bvapSingleChannel; return *this; } virtual asynStatus Write(asynDrvBoard* driver, unsigned channel = 0, void* value = 0, epicsUInt32 mask = bvapAllBitMask) = 0; virtual asynStatus Read(asynDrvBoard* driver, unsigned channel = 0, void* value = 0, epicsUInt32* mask = 0) = 0; inline string GetName() { MtxLock objLock(mcMutex); return bvapParName; } inline string SetName(string name) { MtxLock objLock(mcMutex); return (bvapParName = name); } inline int GetNumber() { MtxLock objLock(mcMutex); return bvapParNum; } inline int SetNumber(int num) { MtxLock objLock(mcMutex); return (bvapParNum = num); } inline epicsUInt32 GetMask() { MtxLock objLock(mcMutex); return bvapMask; } inline epicsUInt32 SetMask(epicsUInt32 mask) { MtxLock objLock(mcMutex); return (bvapMask = mask); } inline bool IsSingleChannel() { MtxLock objLock(mcMutex); return bvapSingleChannel; } virtual void Connect2Driver(asynDrvBoard* driver) = 0; static epicsUInt32 GetAllBitMask() { MtxLock classLock(mcClassMutex); return bvapAllBitMask; } }; #endif /* __BOARD_VASYNPAR_HH__ */