mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 15:20:02 +02:00
shm naming
This commit is contained in:
parent
74fde0a77c
commit
1a712e1aa6
@ -22,8 +22,8 @@
|
|||||||
#include <sys/stat.h> // fstat
|
#include <sys/stat.h> // fstat
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define SHM_MULTI_PREFIX "/slsDetectorPackage_multi_"
|
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
|
||||||
#define SHM_SLS_PREFIX "_sls_"
|
#define SHM_MODULE_PREFIX "_module_"
|
||||||
#define SHM_ENV_NAME "SLSDETNAME"
|
#define SHM_ENV_NAME "SLSDETNAME"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -35,13 +35,10 @@ template <typename T> class SharedMemory {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* moduleid of -1 creates a detector only shared memory
|
||||||
* creates the single/multi detector shared memory name
|
|
||||||
* @param multiId multi detector id
|
|
||||||
* @param slsId sls detector id, -1 if a multi detector shared memory
|
|
||||||
*/
|
*/
|
||||||
SharedMemory(int multiId, int slsId) {
|
SharedMemory(int detectorId, int moduleIndex) {
|
||||||
name = ConstructSharedMemoryName(multiId, slsId);
|
name = ConstructSharedMemoryName(detectorId, moduleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,11 +205,11 @@ template <typename T> class SharedMemory {
|
|||||||
/**
|
/**
|
||||||
* Create Shared memory name
|
* Create Shared memory name
|
||||||
* throws exception if name created is longer than required 255(manpages)
|
* throws exception if name created is longer than required 255(manpages)
|
||||||
* @param multiId multi detector id
|
* @param detectorId detector id
|
||||||
* @param slsId sls detector id, -1 if a multi detector shared memory
|
* @param moduleIndex module id, -1 if a detector shared memory
|
||||||
* @returns shared memory name
|
* @returns shared memory name
|
||||||
*/
|
*/
|
||||||
std::string ConstructSharedMemoryName(int multiId, int slsId) {
|
std::string ConstructSharedMemoryName(int detectorId, int moduleIndex) {
|
||||||
|
|
||||||
// using environment path
|
// using environment path
|
||||||
std::string sEnvPath;
|
std::string sEnvPath;
|
||||||
@ -223,11 +220,11 @@ template <typename T> class SharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (slsId < 0)
|
if (moduleIndex < 0)
|
||||||
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
|
ss << SHM_DETECTOR_PREFIX << detectorId << sEnvPath;
|
||||||
else
|
else
|
||||||
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId
|
ss << SHM_DETECTOR_PREFIX << detectorId << SHM_MODULE_PREFIX
|
||||||
<< sEnvPath;
|
<< moduleIndex << sEnvPath;
|
||||||
|
|
||||||
std::string temp = ss.str();
|
std::string temp = ss.str();
|
||||||
if (temp.length() > NAME_MAX_LENGTH) {
|
if (temp.length() > NAME_MAX_LENGTH) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user