ShmRollingMultiplexingDataManager.cpp

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #include <fesa-core/Synchronization/ShmRollingMultiplexingDataManager.h>
00004 
00005 #include <fesa-core/Utilities/SharedMutex.h>
00006 
00007 
00008 namespace fesa
00009 {
00010 
00011 ShmRollingMultiplexingDataManager::ShmRollingMultiplexingDataManager(int32_t depth) :
00012     RollingMultiplexingDataManager(depth)
00013 {
00014 
00015 }
00016 
00017 int32_t ShmRollingMultiplexingDataManager::computeMemorySize()
00018 {
00019 
00020     int32_t memorySize = SharedMutex::getSize();
00021     // current index
00022     memorySize += static_cast<int32_t>(sizeof(int32_t));
00023 
00024     memorySize += static_cast<int32_t>(sizeof(int32_t));
00025 
00026     // cycles slots
00027     memorySize += static_cast<int32_t>(sizeof(int32_t)) * depth_;
00028     // time stamp slots
00029     memorySize += static_cast<int32_t>(sizeof(int64_t)) * depth_;
00030 
00031     return memorySize;
00032 
00033 }
00034 
00035 void ShmRollingMultiplexingDataManager::mapMemory(char* address)
00036 {
00037 
00038     mutex_ = new SharedMutex((void*) address);
00039 
00040     currentPosition_ = (int32_t*) (address + SharedMutex::getSize());
00041     *currentPosition_ = 0;
00042 
00043     currentId_ = (int32_t*) ((char*) currentPosition_ + sizeof(int32_t));
00044     *currentId_ = -1;
00045 
00046     currentIdsCol_ = (int32_t*) ((char*) currentId_ + sizeof(int32_t));
00047     currentCycleStampsCol_ = (int64_t*) ((char*) currentIdsCol_ + sizeof(int32_t) * depth_);
00048 }
00049 
00050 } // fesa

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1