#ifndef __CHASSIS_VASYNPAR_HH__ #define __CHASSIS_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 "asynDrvChassis.hh" #include "MtxLock.hh" #include "MutexedClass.hh" // Base class for asyn parameters template class chassisVAsynPar : public MutexedClass { public: // define a type to the member function of vmeChassis typedef uint32_t (vmeChassis::*cvapRdPtr)(); typedef uint32_t (vmeChassis::*cvapWtPtr)(uint32_t); protected: cvapRdPtr cvapReadFun; //! Address of the function to call for reading cvapWtPtr cvapWriteFun; //! Address of the function to call for writing int cvapParNum; //! Asyn driver parameter index string cvapParName; //! Asyn parameter name epicsUInt32 cvapMask; //! Mask for reading int cvapElmNum; //! Number of elements the driver will return bool cvapSingleChannel; //! Flag to indicate that this parameter is single channel public: static epicsUInt32 cvapAllBitMask; //! Enable all 32 bits public: chassisVAsynPar() : cvapReadFun(0), cvapWriteFun(0), cvapParNum(-1), cvapParName(""), cvapMask( cvapAllBitMask), cvapElmNum(0), cvapSingleChannel(true) { // InitMutex(); } // 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. chassisVAsynPar(string parName, int parNum, cvapRdPtr readFun, cvapWtPtr writeFun, epicsUInt32 mask) : cvapReadFun(readFun), cvapWriteFun(writeFun), cvapParNum(parNum), cvapParName( parName), cvapMask(mask), cvapElmNum(0), cvapSingleChannel( true) { // InitMutex(); } chassisVAsynPar(const chassisVAsynPar& par) : cvapReadFun(par.cvapReadFun), cvapWriteFun(par.cvapWriteFun), cvapParNum( par.cvapParNum), cvapParName(par.cvapParName), cvapMask( par.cvapMask), cvapElmNum(par.cvapElmNum), cvapSingleChannel( par.cvapSingleChannel) { // InitMutex(); } virtual ~chassisVAsynPar() { closeMutex(); } virtual chassisVAsynPar& operator=(const chassisVAsynPar& argPar) { chassisVAsynPar& par = const_cast(argPar); // Remove constness MtxLock selfObjLock(mcMutex); MtxLock otherObjLock(par.mcMutex); cvapReadFun = par.cvapReadFun; cvapWriteFun = par.cvapWriteFun; cvapParNum = par.cvapParNum; cvapParName = par.cvapParName; cvapMask = par.cvapMask; cvapElmNum = par.cvapElmNum; cvapSingleChannel = par.cvapSingleChannel; return *this; } virtual asynStatus Write(asynDrvChassis* driver, void* value = 0, epicsUInt32 mask = cvapAllBitMask) = 0; virtual asynStatus Read(asynDrvChassis* driver, void* value = 0, epicsUInt32* mask = 0) = 0; inline string GetName() { MtxLock objLock(mcMutex); return cvapParName; } inline string SetName(string name) { MtxLock objLock(mcMutex); return (cvapParName = name); } inline int GetNumber() { MtxLock objLock(mcMutex); return cvapParNum; } inline int SetNumber(int num) { MtxLock objLock(mcMutex); return (cvapParNum = num); } inline epicsUInt32 GetMask() { MtxLock objLock(mcMutex); return cvapMask; } inline epicsUInt32 SetMask(epicsUInt32 mask) { MtxLock objLock(mcMutex); return (cvapMask = mask); } inline bool IsSingleChannel() { MtxLock objLock(mcMutex); return cvapSingleChannel; } virtual void Connect2Driver(asynDrvChassis* driver) = 0; static epicsUInt32 GetAllBitMask() { MtxLock classLock(mcClassMutex); return cvapAllBitMask; } }; #endif /* __CHASSIS_VASYNPAR_HH__ */