rxr sls namespace (#457)

* rxr src files and classes (detectordata, ZmqSocket) added to sls namespace

* moving defines inside namespace

* moving defines inside namespace, added helpdacs to namespace

* added namespace to gui

* gui also updated

* removed unnecessary sls:: when already in sls namespace for slsDetectoSoftware, receverSoftware, slsDetectorGui and slsSupportlib
This commit is contained in:
Dhanya Thattil
2022-05-18 11:48:38 +02:00
committed by GitHub
parent fcc7f7aef8
commit 4259363169
88 changed files with 1200 additions and 923 deletions

View File

@ -10,10 +10,10 @@
#include <memory>
#include <vector>
class detectorData;
namespace sls {
using ns = std::chrono::nanoseconds;
class detectorData;
class DetectorImpl;
class MacAddr;
class IpAddr;
@ -884,7 +884,7 @@ class Detector {
void setRxLock(bool value, Positions pos = {});
/** Client IP Address that last communicated with the receiver */
Result<sls::IpAddr> getRxLastClientIP(Positions pos = {}) const;
Result<IpAddr> getRxLastClientIP(Positions pos = {}) const;
/** Get thread ids from the receiver in order of [parent, tcp, listener 0,
* processor 0, streamer 0, listener 1, processor 1, streamer 1, arping]. If
@ -1919,7 +1919,7 @@ class Detector {
void setDetectorLock(bool lock, Positions pos = {});
/** Client IP Address that last communicated with the detector */
Result<sls::IpAddr> getLastClientIP(Positions pos = {}) const;
Result<IpAddr> getLastClientIP(Positions pos = {}) const;
/** Execute a command on the detector server console */
Result<std::string> executeCommand(const std::string &value,

View File

@ -4,6 +4,8 @@
#include <cstdint>
#include <string>
namespace sls {
/**
@short data structure to hold the detector data after postprocessing
*/
@ -51,3 +53,5 @@ class detectorData {
bool completeImage;
std::array<int,4> rxRoi{{-1, -1, -1, -1}};
};
} // namespace sls

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,8 @@
#include <string>
#include <vector>
namespace sls {
/** Macro to make an integer command.
* CMDNAME name of the function that does the command
* GETFCN Detector function to get
@ -53,7 +55,7 @@
os << args[0] << '\n'; \
} \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -75,9 +77,9 @@
WrongNumberOfParameters(1); \
} \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
throw sls::RuntimeError("cannot put"); \
throw RuntimeError("cannot put"); \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -102,7 +104,7 @@
det->SETFCN(args[0], std::vector<int>{det_id}); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -128,7 +130,7 @@
det->SETFCN(val, std::vector<int>{det_id}); \
os << ToStringHex(val, 16) << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -154,7 +156,7 @@
det->SETFCN(val, std::vector<int>{det_id}); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -180,7 +182,7 @@
det->SETFCN(val, std::vector<int>{det_id}); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -206,7 +208,7 @@
det->SETFCN(val, det_id); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -232,7 +234,7 @@
det->SETFCN(val, det_id); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -252,7 +254,7 @@
os << OutString(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
if (det_id != -1) { \
throw sls::RuntimeError( \
throw RuntimeError( \
"Cannot execute this at module level"); \
} \
if (args.size() != 1) { \
@ -262,7 +264,7 @@
det->SETFCN(val); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -273,7 +275,7 @@
std::ostringstream os; \
os << cmd << ' '; \
if (det_id != -1) { \
throw sls::RuntimeError("Cannot execute this at module level"); \
throw RuntimeError("Cannot execute this at module level"); \
} \
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
@ -291,7 +293,7 @@
det->SETFCN(val); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -317,7 +319,7 @@
det->SETFCN(INDEX, val, std::vector<int>{det_id}); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -345,7 +347,7 @@
std::vector<int>{det_id}); \
os << args[0] << ' ' << args[1] << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -356,12 +358,12 @@
std::ostringstream os; \
os << cmd << ' '; \
if (det_id != -1) { \
throw sls::RuntimeError("Cannot execute this at module level"); \
throw RuntimeError("Cannot execute this at module level"); \
} \
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \
throw sls::RuntimeError("Cannot get"); \
throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
if (!args.empty()) { \
WrongNumberOfParameters(0); \
@ -369,7 +371,7 @@
det->SETFCN(); \
os << "successful\n"; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -382,7 +384,7 @@
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \
throw sls::RuntimeError("Cannot get"); \
throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
if (!args.empty()) { \
WrongNumberOfParameters(0); \
@ -390,7 +392,7 @@
det->SETFCN(std::vector<int>{det_id}); \
os << "successful\n"; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -401,12 +403,12 @@
std::ostringstream os; \
os << cmd << ' '; \
if (det_id != -1) { \
throw sls::RuntimeError("Cannot execute this at module level"); \
throw RuntimeError("Cannot execute this at module level"); \
} \
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \
throw sls::RuntimeError("Cannot get"); \
throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
if (args.size() != 1) { \
WrongNumberOfParameters(1); \
@ -414,7 +416,7 @@
det->SETFCN(args[0]); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -427,7 +429,7 @@
if (action == slsDetectorDefs::HELP_ACTION) \
os << HLPSTR << '\n'; \
else if (action == slsDetectorDefs::GET_ACTION) { \
throw sls::RuntimeError("Cannot get"); \
throw RuntimeError("Cannot get"); \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
if (args.size() != 1) { \
WrongNumberOfParameters(1); \
@ -435,7 +437,7 @@
det->SETFCN(args[0], std::vector<int>{det_id}); \
os << args.front() << '\n'; \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -454,9 +456,9 @@
auto t = det->GETFCN(std::vector<int>{det_id}); \
os << OutString(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
throw sls::RuntimeError("Cannot put"); \
throw RuntimeError("Cannot put"); \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -473,11 +475,11 @@
WrongNumberOfParameters(0); \
} \
auto t = det->GETFCN(); \
os << sls::ToString(t) << '\n'; \
os << ToString(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
throw sls::RuntimeError("Cannot put"); \
throw RuntimeError("Cannot put"); \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -496,9 +498,9 @@
auto t = det->GETFCN(std::vector<int>{det_id}); \
os << OutStringHex(t) << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
throw sls::RuntimeError("Cannot put"); \
throw RuntimeError("Cannot put"); \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
@ -516,15 +518,13 @@
auto t = det->GETFCN(VAL, std::vector<int>{det_id}); \
os << OutString(t) << APPEND << '\n'; \
} else if (action == slsDetectorDefs::PUT_ACTION) { \
throw sls::RuntimeError("Cannot put"); \
throw RuntimeError("Cannot put"); \
} else { \
throw sls::RuntimeError("Unknown action"); \
throw RuntimeError("Unknown action"); \
} \
return os.str(); \
}
namespace sls {
class CmdProxy {
public:
explicit CmdProxy(Detector *ptr) : det(ptr) {}
@ -558,7 +558,7 @@ class CmdProxy {
return ToStringHex(value, width);
}
template <typename V> std::string OutString(const sls::Result<V> &value) {
template <typename V> std::string OutString(const Result<V> &value) {
if (value.equal())
return ToString(value.front());
return ToString(value);
@ -1251,7 +1251,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
settings, getSettings, setSettings,
sls::StringTo<slsDetectorDefs::detectorSettings>,
StringTo<slsDetectorDefs::detectorSettings>,
"[standard, fast, highgain, dynamicgain, lowgain, "
"mediumgain, veryhighgain, highgain0, "
"fixgain1, fixgain2, forceswitchg1, forceswitchg2, "
@ -1354,7 +1354,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
timing, getTimingMode, setTimingMode,
sls::StringTo<slsDetectorDefs::timingMode>,
StringTo<slsDetectorDefs::timingMode>,
"[auto|trigger|gating|burst_trigger]\n\tTiming Mode of "
"detector.\n\t[Jungfrau][Gotthard][Ctb][Moench][Gotthard2] "
"[auto|trigger]\n\t[Mythen3] "
@ -1726,7 +1726,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
rx_discardpolicy, getRxFrameDiscardPolicy, setRxFrameDiscardPolicy,
sls::StringTo<slsDetectorDefs::frameDiscardPolicy>,
StringTo<slsDetectorDefs::frameDiscardPolicy>,
"[nodiscard (default)|discardempty|discardpartial(fastest)]\n\tFrame "
"discard policy of receiver. nodiscard does not discard frames, "
"discardempty discards empty frames, discardpartial discards partial "
@ -1776,7 +1776,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
fformat, getFileFormat, setFileFormat,
sls::StringTo<slsDetectorDefs::fileFormat>,
StringTo<slsDetectorDefs::fileFormat>,
"[binary|hdf5]\n\tFile format of data file. For HDF5, package must be "
"compiled with HDF5 flags. Default is binary.");
@ -1992,13 +1992,13 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
gainmode, getGainMode, setGainMode,
sls::StringTo<slsDetectorDefs::gainMode>,
StringTo<slsDetectorDefs::gainMode>,
"[dynamicgain|forceswitchg1|forceswitchg2|fixg1|fixg2|fixg0]\n\t["
"Jungfrau] Gain mode.\n\tCAUTION: Do not use fixg0 without caution, "
"you can damage the detector!!!");
INTEGER_COMMAND_VEC_ID(filtercells, getNumberOfFilterCells,
setNumberOfFilterCells, sls::StringTo<int>,
setNumberOfFilterCells, StringTo<int>,
"[0-12]\n\t[Jungfrau] Set Filter Cell. Only for "
"chipv1.1. Advanced user Command");
@ -2034,7 +2034,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
timingsource, getTimingSource, setTimingSource,
sls::StringTo<slsDetectorDefs::timingSourceType>,
StringTo<slsDetectorDefs::timingSourceType>,
"[internal|external]\n\t[Gotthard2] Timing source. Internal is crystal "
"and external is system timing. Default is internal.");
@ -2121,7 +2121,7 @@ class CmdProxy {
INTEGER_COMMAND_VEC_ID(
romode, getReadoutMode, setReadoutMode,
sls::StringTo<slsDetectorDefs::readoutMode>,
StringTo<slsDetectorDefs::readoutMode>,
"[analog|digital|analog_digital]\n\t[CTB] Readout mode. "
"Default is analog.");

View File

@ -56,7 +56,7 @@ void freeSharedMemory(int detectorIndex, int moduleIndex) {
using defs = slsDetectorDefs;
Detector::Detector(int shm_id)
: pimpl(sls::make_unique<DetectorImpl>(shm_id)) {}
: pimpl(make_unique<DetectorImpl>(shm_id)) {}
Detector::~Detector() = default;
@ -66,7 +66,7 @@ void Detector::freeSharedMemory() { pimpl->freeSharedMemory(); }
void Detector::loadConfig(const std::string &fname) {
int shm_id = getShmId();
freeSharedMemory();
pimpl = sls::make_unique<DetectorImpl>(shm_id);
pimpl = make_unique<DetectorImpl>(shm_id);
LOG(logINFO) << "Loading configuration file: " << fname;
loadParameters(fname);
}
@ -871,7 +871,7 @@ Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
void Detector::setNumberofUDPInterfaces(int n, Positions pos) {
if (getDetectorType().squash() != defs::JUNGFRAU) {
throw sls::RuntimeError(
throw RuntimeError(
"Cannot set number of udp interfaces for this detector.");
}
// also called by vetostream (for gotthard2)
@ -951,7 +951,7 @@ Result<UdpDestination> Detector::getDestinationUDPList(const uint32_t entry,
void Detector::setDestinationUDPList(const UdpDestination dest,
const int module_id) {
if (module_id == -1 && size() > 1) {
throw sls::RuntimeError("Cannot set this parameter at detector level.");
throw RuntimeError("Cannot set this parameter at detector level.");
}
pimpl->Parallel(&Module::setDestinationUDPList, {module_id}, dest);
}
@ -1194,7 +1194,7 @@ void Detector::setRxLock(bool value, Positions pos) {
pimpl->Parallel(&Module::setReceiverLock, pos, value);
}
Result<sls::IpAddr> Detector::getRxLastClientIP(Positions pos) const {
Result<IpAddr> Detector::getRxLastClientIP(Positions pos) const {
return pimpl->Parallel(&Module::getReceiverLastClientIP, pos);
}
@ -2278,7 +2278,7 @@ void Detector::resetFPGA(Positions pos) {
void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Detector Server (no tftp)...";
std::vector<char> buffer = readBinaryFile(fname, "Update Detector Server");
std::string filename = sls::getFileNameFromFilePath(fname);
std::string filename = getFileNameFromFilePath(fname);
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
if (getDetectorType().squash() != defs::EIGER) {
rebootController(pos);
@ -2287,7 +2287,7 @@ void Detector::updateDetectorServer(const std::string &fname, Positions pos) {
void Detector::updateKernel(const std::string &fname, Positions pos) {
LOG(logINFO) << "Updating Kernel...";
std::vector<char> buffer = sls::readBinaryFile(fname, "Update Kernel");
std::vector<char> buffer = readBinaryFile(fname, "Update Kernel");
pimpl->Parallel(&Module::updateKernel, pos, buffer);
rebootController(pos);
}
@ -2302,7 +2302,7 @@ void Detector::updateFirmwareAndServer(const std::string &sname,
LOG(logINFO) << "Updating Firmware and Detector Server (no tftp)...";
LOG(logINFO) << "Updating Detector Server (no tftp)...";
std::vector<char> buffer = readBinaryFile(sname, "Update Detector Server");
std::string filename = sls::getFileNameFromFilePath(sname);
std::string filename = getFileNameFromFilePath(sname);
pimpl->Parallel(&Module::updateDetectorServer, pos, buffer, filename);
programFPGA(fname, false, pos);
}
@ -2390,7 +2390,7 @@ void Detector::setDetectorLock(bool lock, Positions pos) {
pimpl->Parallel(&Module::setLockDetector, pos, lock);
}
Result<sls::IpAddr> Detector::getLastClientIP(Positions pos) const {
Result<IpAddr> Detector::getLastClientIP(Positions pos) const {
return pimpl->Parallel(&Module::getLastClientIP, pos);
}

View File

@ -186,7 +186,7 @@ void DetectorImpl::initializeMembers(bool verify) {
for (int i = 0; i < shm()->totalNumberOfModules; i++) {
try {
modules.push_back(
sls::make_unique<Module>(detectorIndex, i, verify));
make_unique<Module>(detectorIndex, i, verify));
} catch (...) {
modules.clear();
throw;
@ -199,11 +199,11 @@ void DetectorImpl::updateUserdetails() {
memset(shm()->lastUser, 0, sizeof(shm()->lastUser));
memset(shm()->lastDate, 0, sizeof(shm()->lastDate));
try {
sls::strcpy_safe(shm()->lastUser, exec("whoami").c_str());
sls::strcpy_safe(shm()->lastDate, exec("date").c_str());
strcpy_safe(shm()->lastUser, exec("whoami").c_str());
strcpy_safe(shm()->lastDate, exec("date").c_str());
} catch (...) {
sls::strcpy_safe(shm()->lastUser, "errorreading");
sls::strcpy_safe(shm()->lastDate, "errorreading");
strcpy_safe(shm()->lastUser, "errorreading");
strcpy_safe(shm()->lastDate, "errorreading");
}
}
@ -279,7 +279,7 @@ void DetectorImpl::addModule(const std::string &hostname) {
int port = DEFAULT_PORTNO;
std::string host = hostname;
auto res = sls::split(hostname, ':');
auto res = split(hostname, ':');
if (res.size() > 1) {
host = res[0];
port = StringTo<int>(res[1]);
@ -303,12 +303,12 @@ void DetectorImpl::addModule(const std::string &hostname) {
// gotthard cannot have more than 2 modules (50um=1, 25um=2
if ((type == GOTTHARD || type == GOTTHARD2) && modules.size() > 2) {
freeSharedMemory();
throw sls::RuntimeError("Gotthard cannot have more than 2 modules");
throw RuntimeError("Gotthard cannot have more than 2 modules");
}
auto pos = modules.size();
modules.emplace_back(
sls::make_unique<Module>(type, detectorIndex, pos, false));
make_unique<Module>(type, detectorIndex, pos, false));
shm()->totalNumberOfModules = modules.size();
modules[pos]->setControlPort(port);
modules[pos]->setStopPort(port + 1);
@ -334,7 +334,7 @@ void DetectorImpl::updateDetectorSize() {
const slsDetectorDefs::xy modSize = modules[0]->getNumberOfChannels();
if (modSize.x == 0 || modSize.y == 0) {
throw sls::RuntimeError(
throw RuntimeError(
"Module size for x or y dimensions is 0. Unable to proceed in "
"updating detector size. ");
}
@ -458,7 +458,7 @@ int DetectorImpl::createReceivingDataSockets() {
portnum += (iSocket % numUDPInterfaces);
try {
zmqSocket.push_back(
sls::make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces]
make_unique<ZmqSocket>(modules[iSocket / numUDPInterfaces]
->getClientStreamingIP()
.str()
.c_str(),
@ -468,7 +468,7 @@ int DetectorImpl::createReceivingDataSockets() {
if (hwm >= 0) {
zmqSocket[iSocket]->SetReceiveHighWaterMark(hwm);
if (zmqSocket[iSocket]->GetReceiveHighWaterMark() != hwm) {
throw sls::ZmqSocketError("Could not set zmq rcv hwm to " +
throw ZmqSocketError("Could not set zmq rcv hwm to " +
std::to_string(hwm));
}
}
@ -566,8 +566,8 @@ void DetectorImpl::readFrameFromReceiver() {
// allocate
size = zHeader.imageSize;
multisize = size * zmqSocket.size();
image = sls::make_unique<char[]>(size);
multiframe = sls::make_unique<char[]>(multisize);
image = make_unique<char[]>(size);
multiframe = make_unique<char[]>(multisize);
memset(multiframe.get(), 0xFF, multisize);
// dynamic range
dynamicRange = zHeader.dynamicRange;
@ -1037,7 +1037,7 @@ int DetectorImpl::getClientStreamingHwm() const {
return shm()->zmqHwm;
}
// enabled
sls::Result<int> result;
Result<int> result;
result.reserve(zmqSocket.size());
for (auto &it : zmqSocket) {
result.push_back(it->GetReceiveHighWaterMark());
@ -1048,7 +1048,7 @@ int DetectorImpl::getClientStreamingHwm() const {
void DetectorImpl::setClientStreamingHwm(const int limit) {
if (limit < -1) {
throw sls::RuntimeError(
throw RuntimeError(
"Cannot set hwm to less than -1 (-1 is lib default).");
}
// update shm
@ -1062,7 +1062,7 @@ void DetectorImpl::setClientStreamingHwm(const int limit) {
it->SetReceiveHighWaterMark(limit);
if (it->GetReceiveHighWaterMark() != limit) {
shm()->zmqHwm = -1;
throw sls::ZmqSocketError("Could not set zmq rcv hwm to " +
throw ZmqSocketError("Could not set zmq rcv hwm to " +
std::to_string(limit));
}
}
@ -1336,7 +1336,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
}
// get srcSize to print progress
ssize_t srcSize = sls::getFileSize(src, "Program FPGA");
ssize_t srcSize = getFileSize(src, "Program FPGA");
// create temp destination file
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
@ -1417,7 +1417,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
return buffer;
}
sls::Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
Result<int> DetectorImpl::getDefaultDac(defs::dacIndex index,
defs::detectorSettings sett,
Positions pos) {
return Parallel(&Module::getDefaultDac, pos, index, sett);

View File

@ -6,10 +6,7 @@
#include "sls/Result.h"
#include "sls/logger.h"
#include "sls/sls_detector_defs.h"
#include "CtbConfig.h"
class ZmqSocket;
class detectorData;
#include <memory>
#include <mutex>
@ -17,18 +14,19 @@ class detectorData;
#include <string>
#include <thread>
#include <vector>
#define DETECTOR_SHMAPIVERSION 0x190809
#define DETECTOR_SHMVERSION 0x220505
#define SHORT_STRING_LENGTH 50
#include <future>
#include <numeric>
namespace sls {
class ZmqSocket;
class detectorData;
class Module;
#define DETECTOR_SHMAPIVERSION 0x190809
#define DETECTOR_SHMVERSION 0x220505
#define SHORT_STRING_LENGTH 50
/**
* @short structure allocated in shared memory to store detector settings
* for IPC and cache
@ -88,12 +86,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
template <class CT> struct NonDeduced { using type = CT; };
template <typename RT, typename... CT>
sls::Result<RT> Parallel(RT (sls::Module::*somefunc)(CT...),
Result<RT> Parallel(RT (Module::*somefunc)(CT...),
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) {
if (modules.empty())
throw sls::RuntimeError("No modules added");
throw RuntimeError("No modules added");
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(modules.size());
@ -103,11 +101,11 @@ class DetectorImpl : public virtual slsDetectorDefs {
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= modules.size())
throw sls::RuntimeError("Module out of range");
throw RuntimeError("Module out of range");
futures.push_back(std::async(std::launch::async, somefunc,
modules[i].get(), Args...));
}
sls::Result<RT> result;
Result<RT> result;
result.reserve(positions.size());
for (auto &i : futures) {
result.push_back(i.get());
@ -116,12 +114,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
}
template <typename RT, typename... CT>
sls::Result<RT> Parallel(RT (sls::Module::*somefunc)(CT...) const,
Result<RT> Parallel(RT (Module::*somefunc)(CT...) const,
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const {
if (modules.empty())
throw sls::RuntimeError("No modules added");
throw RuntimeError("No modules added");
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(modules.size());
@ -131,11 +129,11 @@ class DetectorImpl : public virtual slsDetectorDefs {
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= modules.size())
throw sls::RuntimeError("Module out of range");
throw RuntimeError("Module out of range");
futures.push_back(std::async(std::launch::async, somefunc,
modules[i].get(), Args...));
}
sls::Result<RT> result;
Result<RT> result;
result.reserve(positions.size());
for (auto &i : futures) {
result.push_back(i.get());
@ -144,12 +142,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
}
template <typename... CT>
void Parallel(void (sls::Module::*somefunc)(CT...),
void Parallel(void (Module::*somefunc)(CT...),
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) {
if (modules.empty())
throw sls::RuntimeError("No modules added");
throw RuntimeError("No modules added");
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(modules.size());
@ -159,7 +157,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= modules.size())
throw sls::RuntimeError("Module out of range");
throw RuntimeError("Module out of range");
futures.push_back(std::async(std::launch::async, somefunc,
modules[i].get(), Args...));
}
@ -169,12 +167,12 @@ class DetectorImpl : public virtual slsDetectorDefs {
}
template <typename... CT>
void Parallel(void (sls::Module::*somefunc)(CT...) const,
void Parallel(void (Module::*somefunc)(CT...) const,
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const {
if (modules.empty())
throw sls::RuntimeError("No modules added");
throw RuntimeError("No modules added");
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(modules.size());
@ -184,7 +182,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= modules.size())
throw sls::RuntimeError("Module out of range");
throw RuntimeError("Module out of range");
futures.push_back(std::async(std::launch::async, somefunc,
modules[i].get(), Args...));
}
@ -298,7 +296,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
std::vector<char> readProgrammingFile(const std::string &fname);
void setNumberofUDPInterfaces(int n, Positions pos);
sls::Result<int> getDefaultDac(defs::dacIndex index,
Result<int> getDefaultDac(defs::dacIndex index,
defs::detectorSettings sett,
Positions pos = {});
void setDefaultDac(defs::dacIndex index, int defaultValue,
@ -396,9 +394,9 @@ class DetectorImpl : public virtual slsDetectorDefs {
defs::xy calculatePosition(int moduleIndex, defs::xy geometry) const;
const int detectorIndex{0};
sls::SharedMemory<sharedDetector> shm{0, -1};
sls::SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
std::vector<std::unique_ptr<sls::Module>> modules;
SharedMemory<sharedDetector> shm{0, -1};
SharedMemory<CtbConfig> ctb_shm{0, -1, CtbConfig::shm_tag()};
std::vector<std::unique_ptr<Module>> modules;
/** data streaming (down stream) enabled in client (zmq sckets created) */
bool client_downstream{false};

View File

@ -2,6 +2,8 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "sls/string_utils.h"
namespace sls {
std::string GetHelpDac(std::string dac) {
if (sls::is_int(dac)) {
return std::string("[dac name] [dac or mV value] [(optional unit) mV] "
@ -303,4 +305,6 @@ std::string GetHelpDac(std::string dac) {
// clang-format on
throw sls::RuntimeError("Unknown dac command");
}
}
} // namespace sls

View File

@ -68,7 +68,7 @@ std::string Module::getHostname() const { return shm()->hostname; }
void Module::setHostname(const std::string &hostname,
const bool initialChecks) {
sls::strcpy_safe(shm()->hostname, hostname.c_str());
strcpy_safe(shm()->hostname, hostname.c_str());
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.close();
try {
@ -117,7 +117,7 @@ int64_t Module::getReceiverSoftwareVersion() const {
slsDetectorDefs::detectorType
Module::getTypeFromDetector(const std::string &hostname, int cport) {
LOG(logDEBUG1) << "Getting Module type ";
sls::ClientSocket socket("Detector", hostname, cport);
ClientSocket socket("Detector", hostname, cport);
socket.Send(F_GET_DETECTOR_TYPE);
socket.Receive<int>(); // TODO! Should we look at this OK/FAIL?
auto retval = socket.Receive<detectorType>();
@ -443,7 +443,7 @@ std::string Module::getSettingsDir() const {
}
std::string Module::setSettingsDir(const std::string &dir) {
sls::strcpy_safe(shm()->settingsDir, dir.c_str());
strcpy_safe(shm()->settingsDir, dir.c_str());
return shm()->settingsDir;
}
@ -894,7 +894,7 @@ std::vector<int64_t> Module::getFramesCaughtByReceiver() const {
std::vector<int64_t> retval(nports);
client.Receive(retval);
LOG(logDEBUG1) << "Frames caught of Receiver" << moduleIndex << ": "
<< sls::ToString(retval);
<< ToString(retval);
return retval;
}
}
@ -916,7 +916,7 @@ std::vector<int64_t> Module::getNumMissingPackets() const {
std::vector<int64_t> retval(nports);
client.Receive(retval);
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex
<< ": " << sls::ToString(retval);
<< ": " << ToString(retval);
return retval;
}
}
@ -938,7 +938,7 @@ std::vector<int64_t> Module::getReceiverCurrentFrameIndex() const {
std::vector<int64_t> retval(nports);
client.Receive(retval);
LOG(logDEBUG1) << "Frame index of Receiver" << moduleIndex << ": "
<< sls::ToString(retval);
<< ToString(retval);
return retval;
}
}
@ -1002,8 +1002,8 @@ void Module::selectUDPInterface(int n) {
sendToDetector(F_SET_INTERFACE_SEL, n, nullptr);
}
sls::IpAddr Module::getSourceUDPIP() const {
return sendToDetector<sls::IpAddr>(F_GET_SOURCE_UDP_IP);
IpAddr Module::getSourceUDPIP() const {
return sendToDetector<IpAddr>(F_GET_SOURCE_UDP_IP);
}
void Module::setSourceUDPIP(const IpAddr ip) {
@ -1013,8 +1013,8 @@ void Module::setSourceUDPIP(const IpAddr ip) {
sendToDetector(F_SET_SOURCE_UDP_IP, ip, nullptr);
}
sls::IpAddr Module::getSourceUDPIP2() const {
return sendToDetector<sls::IpAddr>(F_GET_SOURCE_UDP_IP2);
IpAddr Module::getSourceUDPIP2() const {
return sendToDetector<IpAddr>(F_GET_SOURCE_UDP_IP2);
}
void Module::setSourceUDPIP2(const IpAddr ip) {
@ -1024,33 +1024,33 @@ void Module::setSourceUDPIP2(const IpAddr ip) {
sendToDetector(F_SET_SOURCE_UDP_IP2, ip, nullptr);
}
sls::MacAddr Module::getSourceUDPMAC() const {
return sendToDetector<sls::MacAddr>(F_GET_SOURCE_UDP_MAC);
MacAddr Module::getSourceUDPMAC() const {
return sendToDetector<MacAddr>(F_GET_SOURCE_UDP_MAC);
}
void Module::setSourceUDPMAC(const sls::MacAddr mac) {
void Module::setSourceUDPMAC(const MacAddr mac) {
if (mac == 0) {
throw RuntimeError("Invalid source udp mac address");
}
sendToDetector(F_SET_SOURCE_UDP_MAC, mac, nullptr);
}
sls::MacAddr Module::getSourceUDPMAC2() const {
return sendToDetector<sls::MacAddr>(F_GET_SOURCE_UDP_MAC2);
MacAddr Module::getSourceUDPMAC2() const {
return sendToDetector<MacAddr>(F_GET_SOURCE_UDP_MAC2);
}
void Module::setSourceUDPMAC2(const sls::MacAddr mac) {
void Module::setSourceUDPMAC2(const MacAddr mac) {
if (mac == 0) {
throw RuntimeError("Invalid source udp mac address2");
}
sendToDetector(F_SET_SOURCE_UDP_MAC2, mac, nullptr);
}
sls::UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<sls::UdpDestination>(F_GET_DEST_UDP_LIST, entry);
UdpDestination Module::getDestinationUDPList(const uint32_t entry) const {
return sendToDetector<UdpDestination>(F_GET_DEST_UDP_LIST, entry);
}
void Module::setDestinationUDPList(const sls::UdpDestination dest) {
void Module::setDestinationUDPList(const UdpDestination dest) {
// set them in the default way so the receivers are also set up
if (dest.entry == 0) {
if (dest.port != 0) {
@ -1090,8 +1090,8 @@ void Module::setFirstUDPDestination(const int value) {
sendToDetector(F_SET_UDP_FIRST_DEST, value, nullptr);
}
sls::IpAddr Module::getDestinationUDPIP() const {
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP);
IpAddr Module::getDestinationUDPIP() const {
return sendToDetector<IpAddr>(F_GET_DEST_UDP_IP);
}
void Module::setDestinationUDPIP(const IpAddr ip) {
@ -1104,7 +1104,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
}
sendToDetector(F_SET_DEST_UDP_IP, ip, nullptr);
if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU);
MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
LOG(logINFO) << "Setting destination udp mac of Module " << moduleIndex
<< " to " << retval;
@ -1112,8 +1112,8 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
}
}
sls::IpAddr Module::getDestinationUDPIP2() const {
return sendToDetector<sls::IpAddr>(F_GET_DEST_UDP_IP2);
IpAddr Module::getDestinationUDPIP2() const {
return sendToDetector<IpAddr>(F_GET_DEST_UDP_IP2);
}
void Module::setDestinationUDPIP2(const IpAddr ip) {
@ -1127,7 +1127,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
}
sendToDetector(F_SET_DEST_UDP_IP2, ip, nullptr);
if (shm()->useReceiverFlag) {
sls::MacAddr retval(0LU);
MacAddr retval(0LU);
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex
<< " to " << retval;
@ -1135,8 +1135,8 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
}
}
sls::MacAddr Module::getDestinationUDPMAC() const {
return sendToDetector<sls::MacAddr>(F_GET_DEST_UDP_MAC);
MacAddr Module::getDestinationUDPMAC() const {
return sendToDetector<MacAddr>(F_GET_DEST_UDP_MAC);
}
void Module::setDestinationUDPMAC(const MacAddr mac) {
@ -1146,8 +1146,8 @@ void Module::setDestinationUDPMAC(const MacAddr mac) {
sendToDetector(F_SET_DEST_UDP_MAC, mac, nullptr);
}
sls::MacAddr Module::getDestinationUDPMAC2() const {
return sendToDetector<sls::MacAddr>(F_GET_DEST_UDP_MAC2);
MacAddr Module::getDestinationUDPMAC2() const {
return sendToDetector<MacAddr>(F_GET_DEST_UDP_MAC2);
}
void Module::setDestinationUDPMAC2(const MacAddr mac) {
@ -1279,19 +1279,19 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
if (receiverIP == "none") {
memset(shm()->rxHostname, 0, MAX_STR_LENGTH);
sls::strcpy_safe(shm()->rxHostname, "none");
strcpy_safe(shm()->rxHostname, "none");
shm()->useReceiverFlag = false;
return;
}
// start updating
std::string host = receiverIP;
auto res = sls::split(host, ':');
auto res = split(host, ':');
if (res.size() > 1) {
host = res[0];
shm()->rxTCPPort = std::stoi(res[1]);
}
sls::strcpy_safe(shm()->rxHostname, host.c_str());
strcpy_safe(shm()->rxHostname, host.c_str());
shm()->useReceiverFlag = true;
checkReceiverVersionCompatibility();
@ -1307,7 +1307,7 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
memset(retval.hostname, 0, sizeof(retval.hostname));
strcpy_safe(retval.hostname, shm()->hostname);
sls::MacAddr retvals[2];
MacAddr retvals[2];
sendToReceiver(F_SETUP_RECEIVER, retval, retvals);
// update Modules with dest mac
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
@ -1393,8 +1393,8 @@ void Module::setReceiverLock(bool lock) {
sendToReceiver<int>(F_LOCK_RECEIVER, static_cast<int>(lock));
}
sls::IpAddr Module::getReceiverLastClientIP() const {
return sendToReceiver<sls::IpAddr>(F_GET_LAST_RECEIVER_CLIENT_IP);
IpAddr Module::getReceiverLastClientIP() const {
return sendToReceiver<IpAddr>(F_GET_LAST_RECEIVER_CLIENT_IP);
}
std::array<pid_t, NUM_RX_THREAD_IDS> Module::getReceiverThreadIds() const {
@ -1443,7 +1443,7 @@ void Module::setFilePath(const std::string &path) {
throw RuntimeError("Cannot set empty file path");
}
char args[MAX_STR_LENGTH]{};
sls::strcpy_safe(args, path.c_str());
strcpy_safe(args, path.c_str());
sendToReceiver(F_SET_RECEIVER_FILE_PATH, args, nullptr);
}
@ -1458,7 +1458,7 @@ void Module::setFileName(const std::string &fname) {
throw RuntimeError("Cannot set empty file name prefix");
}
char args[MAX_STR_LENGTH]{};
sls::strcpy_safe(args, fname.c_str());
strcpy_safe(args, fname.c_str());
sendToReceiver(F_SET_RECEIVER_FILE_NAME, args, nullptr);
}
@ -1555,11 +1555,11 @@ void Module::setReceiverStreamingPort(int port) {
sendToReceiver(F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
}
sls::IpAddr Module::getReceiverStreamingIP() const {
return sendToReceiver<sls::IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
IpAddr Module::getReceiverStreamingIP() const {
return sendToReceiver<IpAddr>(F_GET_RECEIVER_STREAMING_SRC_IP);
}
void Module::setReceiverStreamingIP(const sls::IpAddr ip) {
void Module::setReceiverStreamingIP(const IpAddr ip) {
if (ip == 0) {
throw RuntimeError("Invalid receiver zmq ip address");
}
@ -1574,9 +1574,9 @@ int Module::getClientStreamingPort() const { return shm()->zmqport; }
void Module::setClientStreamingPort(int port) { shm()->zmqport = port; }
sls::IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
IpAddr Module::getClientStreamingIP() const { return shm()->zmqip; }
void Module::setClientStreamingIP(const sls::IpAddr ip) {
void Module::setClientStreamingIP(const IpAddr ip) {
if (ip == 0) {
throw RuntimeError("Invalid client zmq ip address");
}
@ -2420,18 +2420,18 @@ void Module::setExternalSampling(bool value) {
}
std::vector<int> Module::getReceiverDbitList() const {
return sendToReceiver<sls::StaticVector<int, MAX_RX_DBIT>>(
return sendToReceiver<StaticVector<int, MAX_RX_DBIT>>(
F_GET_RECEIVER_DBIT_LIST);
}
void Module::setReceiverDbitList(std::vector<int> list) {
LOG(logDEBUG1) << "Setting Receiver Dbit List";
if (list.size() > 64) {
throw sls::RuntimeError("Dbit list size cannot be greater than 64\n");
throw RuntimeError("Dbit list size cannot be greater than 64\n");
}
for (auto &it : list) {
if (it < 0 || it > 63) {
throw sls::RuntimeError(
throw RuntimeError(
"Dbit list value must be between 0 and 63\n");
}
}
@ -2439,7 +2439,7 @@ void Module::setReceiverDbitList(std::vector<int> list) {
auto last = std::unique(begin(list), end(list));
list.erase(last, list.end());
sls::StaticVector<int, MAX_RX_DBIT> arg = list;
StaticVector<int, MAX_RX_DBIT> arg = list;
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
}
@ -2628,7 +2628,7 @@ void Module::setAdditionalJsonHeader(
std::string Module::getAdditionalJsonParameter(const std::string &key) const {
char arg[SHORT_STR_LENGTH]{};
sls::strcpy_safe(arg, key.c_str());
strcpy_safe(arg, key.c_str());
char retval[SHORT_STR_LENGTH]{};
sendToReceiver(F_GET_ADDITIONAL_JSON_PARAMETER, arg, retval);
return retval;
@ -2644,8 +2644,8 @@ void Module::setAdditionalJsonParameter(const std::string &key,
"Key cannot be empty. Both can have max 2 characters");
}
char args[2][SHORT_STR_LENGTH]{};
sls::strcpy_safe(args[0], key.c_str());
sls::strcpy_safe(args[1], value.c_str());
strcpy_safe(args[0], key.c_str());
strcpy_safe(args[1], value.c_str());
sendToReceiver(F_SET_ADDITIONAL_JSON_PARAMETER, args, nullptr);
}
@ -2797,14 +2797,14 @@ void Module::setLockDetector(bool lock) {
sendToDetector<int>(F_LOCK_SERVER, static_cast<int>(lock));
}
sls::IpAddr Module::getLastClientIP() const {
return sendToDetector<sls::IpAddr>(F_GET_LAST_CLIENT_IP);
IpAddr Module::getLastClientIP() const {
return sendToDetector<IpAddr>(F_GET_LAST_CLIENT_IP);
}
std::string Module::executeCommand(const std::string &cmd) {
char arg[MAX_STR_LENGTH]{};
char retval[MAX_STR_LENGTH]{};
sls::strcpy_safe(arg, cmd.c_str());
strcpy_safe(arg, cmd.c_str());
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
<< "): Sending command " << cmd;
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
@ -3254,8 +3254,8 @@ void Module::initializeModuleStructure(detectorType type) {
shm()->numberOfModule.y = 0;
shm()->controlPort = DEFAULT_PORTNO;
shm()->stopPort = DEFAULT_PORTNO + 1;
sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
sls::strcpy_safe(shm()->rxHostname, "none");
strcpy_safe(shm()->settingsDir, getenv("HOME"));
strcpy_safe(shm()->rxHostname, "none");
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false;
shm()->numUDPInterfaces = 1;
@ -3310,7 +3310,7 @@ void Module::checkReceiverVersionCompatibility() {
sendToReceiver(F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr);
}
int Module::sendModule(sls_detector_module *myMod, sls::ClientSocket &client) {
int Module::sendModule(sls_detector_module *myMod, ClientSocket &client) {
constexpr TLogLevel level = logDEBUG1;
LOG(level) << "Sending Module";
int ts = 0;
@ -3381,7 +3381,7 @@ void Module::updateReceiverStreamingIP() {
auto ip = getReceiverStreamingIP();
if (ip == 0) {
// Hostname could be ip try to decode otherwise look up the hostname
ip = sls::IpAddr{shm()->rxHostname};
ip = IpAddr{shm()->rxHostname};
if (ip == 0) {
ip = HostnameToIp(shm()->rxHostname);
}
@ -3634,7 +3634,7 @@ void Module::sendProgram(bool blackfin, std::vector<char> buffer,
client.Send(filesize);
// send checksum
std::string checksum = sls::md5_calculate_checksum(buffer.data(), filesize);
std::string checksum = md5_calculate_checksum(buffer.data(), filesize);
LOG(logDEBUG1) << "Checksum:" << checksum;
char cChecksum[MAX_STR_LENGTH] = {0};
strcpy(cChecksum, checksum.c_str());

View File

@ -14,13 +14,13 @@
#include <map>
#include <vector>
namespace sls {
class ServerInterface;
#define MODULE_SHMAPIVERSION 0x190726
#define MODULE_SHMVERSION 0x200402
namespace sls {
/**
* @short structure allocated in shared memory to store Module settings for
* IPC and cache
@ -40,7 +40,7 @@ struct sharedModule {
int stopPort;
char settingsDir[MAX_STR_LENGTH];
/** list of the energies at which the Module has been trimmed */
sls::StaticVector<int, MAX_TRIMEN> trimEnergies;
StaticVector<int, MAX_TRIMEN> trimEnergies;
/** number of channels per chip */
slsDetectorDefs::xy nChan;
slsDetectorDefs::xy nChip;
@ -52,7 +52,7 @@ struct sharedModule {
/** Listening tcp port from gui (only data) */
int zmqport;
/** Listening tcp ip address from gui (only data) **/
sls::IpAddr zmqip;
IpAddr zmqip;
int numUDPInterfaces;
/** to inform rxr when stopping rxr */
bool stoppedFlag;
@ -223,28 +223,28 @@ class Module : public virtual slsDetectorDefs {
void setNumberofUDPInterfaces(int n);
int getSelectedUDPInterface() const;
void selectUDPInterface(int n);
sls::IpAddr getSourceUDPIP() const;
void setSourceUDPIP(const sls::IpAddr ip);
sls::IpAddr getSourceUDPIP2() const;
void setSourceUDPIP2(const sls::IpAddr ip);
sls::MacAddr getSourceUDPMAC() const;
void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac);
sls::UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const sls::UdpDestination dest);
IpAddr getSourceUDPIP() const;
void setSourceUDPIP(const IpAddr ip);
IpAddr getSourceUDPIP2() const;
void setSourceUDPIP2(const IpAddr ip);
MacAddr getSourceUDPMAC() const;
void setSourceUDPMAC(const MacAddr mac);
MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const MacAddr mac);
UdpDestination getDestinationUDPList(const uint32_t entry) const;
void setDestinationUDPList(const UdpDestination dest);
int getNumberofUDPDestinations() const;
void clearUDPDestinations();
int getFirstUDPDestination() const;
void setFirstUDPDestination(const int value);
sls::IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const sls::IpAddr ip);
sls::IpAddr getDestinationUDPIP2() const;
void setDestinationUDPIP2(const sls::IpAddr ip);
sls::MacAddr getDestinationUDPMAC() const;
void setDestinationUDPMAC(const sls::MacAddr mac);
sls::MacAddr getDestinationUDPMAC2() const;
void setDestinationUDPMAC2(const sls::MacAddr mac);
IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const IpAddr ip);
IpAddr getDestinationUDPIP2() const;
void setDestinationUDPIP2(const IpAddr ip);
MacAddr getDestinationUDPMAC() const;
void setDestinationUDPMAC(const MacAddr mac);
MacAddr getDestinationUDPMAC2() const;
void setDestinationUDPMAC2(const MacAddr mac);
int getDestinationUDPPort() const;
void setDestinationUDPPort(int udpport);
int getDestinationUDPPort2() const;
@ -286,7 +286,7 @@ class Module : public virtual slsDetectorDefs {
void setReceiverUDPSocketBufferSize(int udpsockbufsize);
bool getReceiverLock() const;
void setReceiverLock(bool lock);
sls::IpAddr getReceiverLastClientIP() const;
IpAddr getReceiverLastClientIP() const;
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
bool getRxArping() const;
void setRxArping(bool enable);
@ -334,12 +334,12 @@ class Module : public virtual slsDetectorDefs {
void setReceiverStreamingStartingFrame(int fnum);
int getReceiverStreamingPort() const;
void setReceiverStreamingPort(int port);
sls::IpAddr getReceiverStreamingIP() const;
void setReceiverStreamingIP(const sls::IpAddr ip);
IpAddr getReceiverStreamingIP() const;
void setReceiverStreamingIP(const IpAddr ip);
int getClientStreamingPort() const;
void setClientStreamingPort(int port);
sls::IpAddr getClientStreamingIP() const;
void setClientStreamingIP(const sls::IpAddr ip);
IpAddr getClientStreamingIP() const;
void setClientStreamingIP(const IpAddr ip);
int getReceiverStreamingHwm() const;
void setReceiverStreamingHwm(const int limit);
@ -589,7 +589,7 @@ class Module : public virtual slsDetectorDefs {
void setStopPort(int port_number);
bool getLockDetector() const;
void setLockDetector(bool lock);
sls::IpAddr getLastClientIP() const;
IpAddr getLastClientIP() const;
std::string executeCommand(const std::string &cmd);
int64_t getNumberOfFramesFromStart() const;
int64_t getActualTime() const;
@ -736,7 +736,7 @@ class Module : public virtual slsDetectorDefs {
void checkDetectorVersionCompatibility();
void checkReceiverVersionCompatibility();
void setModule(sls_detector_module &module, bool trimbits = true);
int sendModule(sls_detector_module *myMod, sls::ClientSocket &client);
int sendModule(sls_detector_module *myMod, ClientSocket &client);
void updateReceiverStreamingIP();
void updateRateCorrection();
@ -778,7 +778,7 @@ class Module : public virtual slsDetectorDefs {
const int timeRequired);
const int moduleIndex;
mutable sls::SharedMemory<sharedModule> shm{0, 0};
mutable SharedMemory<sharedModule> shm{0, 0};
static const int BLACKFIN_ERASE_FLASH_TIME = 65;
static const int BLACKFIN_WRITE_TO_FLASH_TIME = 30;
static const int NIOS_ERASE_FLASH_TIME_FPGA = 10;

View File

@ -13,7 +13,6 @@
#include "sls/logger.h"
#include "sls/sls_detector_exceptions.h"
// #include "stdlib.h"
#include <cstdlib>
#include <cerrno> // errno
#include <cstring> // strerror
@ -23,16 +22,15 @@
#include <sys/mman.h> // shared memory
#include <sys/stat.h> // fstat
#include <unistd.h>
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
#define SHM_MODULE_PREFIX "_module_"
#define SHM_ENV_NAME "SLSDETNAME"
#include <iostream>
#include <string>
namespace sls {
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
#define SHM_MODULE_PREFIX "_module_"
#define SHM_ENV_NAME "SLSDETNAME"
template <typename T> class SharedMemory {
static constexpr int NAME_MAX_LENGTH = 255;
std::string name;