00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 00003 #ifndef ROLLING_MULTIPLEXING_DATA_MANAGER_H_ 00004 #define ROLLING_MULTIPLEXING_DATA_MANAGER_H_ 00005 00006 #include <fesa-core/Synchronization/MultiplexingDataManager.h> 00007 00008 namespace fesa 00009 { 00010 00023 class RollingMultiplexingDataManager : public MultiplexingDataManager 00024 { 00025 public: 00026 00031 RollingMultiplexingDataManager(int32_t depth); 00032 00038 virtual int32_t computeMemorySize() = 0; 00039 00045 virtual void mapMemory(char* address) = 0; 00046 00053 int32_t findCycleIdBackward(int32_t cycleId); 00054 00061 int32_t findCycleStampBackward(int64_t cycleStamp); 00062 00063 // /*! 00064 // * \brief This method finds the cycleId, passed by argument, starting from the first position 00065 // * \param cycleId the CycleID we are searching for 00066 // * \return the corresponding slot, -1 if not found 00067 // */ 00068 // int findCyleId(long cycleId); 00069 // 00070 // /*! 00071 // * \brief This method finds the cycleId, passed by argument, starting from the first position 00072 // * \param cycleStamp the cycleStamp we are searching for 00073 // * \return the corresponding slot, -1 if not found 00074 // */ 00075 // int findCyleStamp(long long cycleStamp); 00076 00077 // /*! 00078 // * \brief This method puts the cycleId passed by argument into the currentPosition 00079 // * \param cycleId the CycleID we want to put 00080 // * \return the slot where the ID was put, -1 on error 00081 // */ 00082 // int putCycleId(long cycleId); 00083 // 00084 // /*! 00085 // * \brief This method puts the cycleStamp passed by argument into the currentPosition 00086 // * \param cycleStamp the cycleStamp we want to put 00087 // * \return the slot where the stamp was put, -1 on error 00088 // */ 00089 // int putCycleStamp(long long cycleStamp); 00093 int64_t getCycleStamp(int32_t position); 00094 00098 int32_t nextPosition(int64_t cycleStamp, int32_t cycleId); 00102 int32_t getCurrentPosition(); 00103 00108 int32_t getDepth(); 00109 00114 int32_t getCurrentCycleId(); 00115 00120 // std::pair<long, long long> getLastCycleInfo(); 00121 00122 /* 00123 * \brief This method sets the cycle ID of the current slot 00124 * \param cycleId the CycleID we want to put 00125 * \return the current cycle ID 00126 */ 00127 void setCurrentCycleId(int32_t cycleId); 00128 00129 protected: 00130 00134 int32_t* currentIdsCol_; 00135 00139 int64_t* currentCycleStampsCol_; 00140 00144 int32_t depth_; 00145 00149 int32_t* currentId_; 00150 00154 AbstractMutex* mutex_; 00155 00159 int32_t* currentPosition_; 00160 00161 }; 00162 00163 inline int32_t RollingMultiplexingDataManager::getDepth() 00164 { 00165 return depth_; 00166 } 00167 00168 inline int32_t RollingMultiplexingDataManager::getCurrentCycleId() 00169 { 00170 return *currentId_; 00171 } 00172 inline void RollingMultiplexingDataManager::setCurrentCycleId(int32_t currentId) 00173 { 00174 *currentId_ = currentId; 00175 } 00176 inline int32_t RollingMultiplexingDataManager::getCurrentPosition() 00177 { 00178 return *currentPosition_; 00179 } 00180 00181 inline int64_t RollingMultiplexingDataManager::getCycleStamp(int32_t position) 00182 { 00183 return *(currentCycleStampsCol_ + position); 00184 } 00185 00186 } // fesa 00187 00188 #endif // ROLLING_MULTIPLEXING_DATA_MANAGER_H_