mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-15 03:48:42 +01:00
Dev/verify shm (#1276)
* removed verify, update, fixed getUser to be a free function, generated commands, python bindings yet to do * python bindings * fixed tests * minor * minor * format
This commit is contained in:
@@ -61,6 +61,54 @@ void freeSharedMemory(const int detectorIndex, const int moduleIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string getUserDetails(const int detectorIndex) {
|
||||
|
||||
int numModules = 0;
|
||||
defs::detectorType type = defs::GENERIC;
|
||||
pid_t pid = -1;
|
||||
std::string hostname = "Unknown";
|
||||
std::string user = "Unknown";
|
||||
std::string date = "Unknown";
|
||||
|
||||
SharedMemory<sharedDetector> detectorShm(detectorIndex, -1);
|
||||
if (detectorShm.exists()) {
|
||||
detectorShm.openSharedMemory(false);
|
||||
if (detectorShm()->shmversion < DETECTOR_SHMAPIVERSION) {
|
||||
detectorShm.unmapSharedMemory();
|
||||
throw SharedMemoryError(
|
||||
"Detector Shared memory version too old to get user details!");
|
||||
}
|
||||
numModules = detectorShm()->totalNumberOfModules;
|
||||
type = detectorShm()->detType;
|
||||
pid = detectorShm()->lastPID;
|
||||
user = detectorShm()->lastUser;
|
||||
date = detectorShm()->lastDate;
|
||||
|
||||
detectorShm.unmapSharedMemory();
|
||||
}
|
||||
|
||||
for (int imod = 0; imod != numModules; ++imod) {
|
||||
SharedMemory<sharedModule> moduleShm(detectorIndex, imod);
|
||||
moduleShm.openSharedMemory(false);
|
||||
if (moduleShm()->shmversion < MODULE_SHMAPIVERSION) {
|
||||
LOG(logWARNING) << "Module Shared Memory too old to get hostname";
|
||||
} else {
|
||||
hostname = moduleShm()->hostname;
|
||||
}
|
||||
moduleShm.unmapSharedMemory();
|
||||
}
|
||||
|
||||
std::ostringstream userDetails;
|
||||
userDetails << "Detector Index: " << detectorIndex << "\n"
|
||||
<< "Number of Modules: " << numModules << "\n"
|
||||
<< "Type: " << type << "\n"
|
||||
<< "PID: " << pid << "\n"
|
||||
<< "User: " << user << "\n"
|
||||
<< "Date: " << date << "\n"
|
||||
<< "Hostname: " << hostname << "\n";
|
||||
return userDetails.str();
|
||||
}
|
||||
|
||||
using defs = slsDetectorDefs;
|
||||
|
||||
Detector::Detector(int shm_id) : pimpl(make_unique<DetectorImpl>(shm_id)) {}
|
||||
@@ -2828,8 +2876,6 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getMeasurementTime, pos);
|
||||
}
|
||||
|
||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||
|
||||
std::vector<uint16_t> Detector::getValidPortNumbers(uint16_t start_port) {
|
||||
int num_sockets_per_detector = getNumberofUDPInterfaces({}).tsquash(
|
||||
"Number of UDP Interfaces is not consistent among modules");
|
||||
|
||||
Reference in New Issue
Block a user