/* * jlabBoard.hh * * Created on: June 16, 2014 * Author: * * This class provides interface that EPICS support will use to monitor * and control the JLAB boards. * All methods, including accessors, need to be thread-safe since they * may be executing simultaneously on multiple threads. */ #ifndef _jlabBoard_HH_ #define _jlabBoard_HH_ #include #include #include #include #include #include #include "jlabROCSharedMemoryWrapper.hh" using namespace std; class jlabBoard { public: // Constructor. Create the board object specified by the base address // Create all channel objects on that board and fill the channel vector. // Throws an exception if fails to create the object. jlabBoard(uint32_t locSlotNumber, jlabROCSharedMemoryWrapper* locROCSharedMemoryWrapper); // Destructor. Destroys this board. virtual ~jlabBoard(); // Return boards type FADC250_v2, JlabDisc_v2 or whatever virtual string GetType(void) = 0; // Return the 32-bit status word for this board virtual uint32_t GetStatus(void); // Return the number of channels this board is serving static uint32_t GetNumberOfChannels(void); // Return the slot number of the board virtual uint32_t GetSlotNumber(void); // Start reading the scaler data for this board from VME bus virtual void StartScalers( const string scalerType = "" ) = 0; // Stop reading the scaler data for this board from VME bus virtual void StopScalers( const string scalerType = "" ) = 0; // Return scaler values for particular channel for this board, in Hz or raw // Time is in seconds // Scalar Type: Readout1, Readout2, Trigger1, Trigger2 virtual vector GetScalers(uint32_t locChannel, string locScalarType, vector& locTimes, bool locOutputInHzFlag = true) = 0; virtual double GetScaler(uint32_t locChannel, string locScalarType, bool locOutputInHzFlag = true) = 0; // Return clock counts for this board virtual vector GetClockCounts(void) = 0; // Set thresholds for particular type of thresholds for all channels virtual void SetThresholds( const double threshold, const string threshType = "" ) = 0; // Set thresholds for particular type of threshold for a single channel virtual void SetThreshold( const unsigned chanNumber, const double threshold, const string threshType ) = 0; // Get a vector of thresholds for a particular type of thresholds virtual vector GetThresholds( const string threshType ) = 0; // Get the values of threshold for a single channel of a particular threshold type virtual double GetThreshold( const unsigned chanNumb, const string threshType ) = 0; // Get the frequency at which the scalars are latched for this board virtual double GetLatchingFrequency(void); // Set latching frequency for this board virtual void SetLatchingFrequency(double); virtual double GetUpdateTime() { return 1.0; } // Nested Class for holding mutex's class jlabMutexHolder { public: jlabMutexHolder(pthread_mutex_t* locMutex) : dMutex(locMutex) { if(dMutex != NULL) pthread_mutex_lock(dMutex); } ~jlabMutexHolder() { if(dMutex != NULL) pthread_mutex_unlock(dMutex); } private: jlabMutexHolder(void){} //cannot call default constructor pthread_mutex_t* dMutex; }; protected: // Prevent copying boards jlabBoard(const jlabBoard& board); jlabBoard& operator=(const jlabBoard& board); uint32_t dSlotNumber; jlabROCSharedMemoryWrapper* dROCSharedMemoryWrapper; pthread_mutex_t dMemoryMutex; pthread_mutexattr_t dMemoryMutexAttributes; }; inline jlabBoard::jlabBoard(uint32_t locSlotNumber, jlabROCSharedMemoryWrapper* locROCSharedMemoryWrapper) : dSlotNumber(locSlotNumber), dROCSharedMemoryWrapper(locROCSharedMemoryWrapper) { // Initiliaze mutex pthread_mutexattr_init(&dMemoryMutexAttributes); pthread_mutexattr_setpshared(&dMemoryMutexAttributes, PTHREAD_PROCESS_PRIVATE); pthread_mutex_init(&dMemoryMutex, &dMemoryMutexAttributes); } inline jlabBoard::~jlabBoard(void) { pthread_mutex_destroy(&dMemoryMutex); pthread_mutexattr_destroy(&dMemoryMutexAttributes); } // DEFINE ME inline uint32_t jlabBoard::GetStatus(void) { return 0; } inline uint32_t jlabBoard::GetSlotNumber(void) { return dSlotNumber; } inline uint32_t jlabBoard::GetNumberOfChannels(void) { return 0; } // DEFINE ME inline double jlabBoard::GetLatchingFrequency(void) { return 0.0; } // DEFINE ME inline void jlabBoard::SetLatchingFrequency(double) { return; } #endif /* _JLABBOARD_HH_ */