Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
maliakal_d 2020-02-04 10:50:14 +01:00
commit 64214f22f9
15 changed files with 188 additions and 322 deletions

View File

@ -45,9 +45,7 @@ void CmdParser::Parse(const std::string &s) {
auto old_size = arguments_.size(); auto old_size = arguments_.size();
arguments_.erase(std::remove_if(begin(arguments_), end(arguments_), arguments_.erase(std::remove_if(begin(arguments_), end(arguments_),
[](const std::string &item) { [](const std::string &item) {
if (item == "-h" || item == "--help") return (item == "-h" || item == "--help");
return true;
return false;
}), }),
end(arguments_)); end(arguments_));
if (old_size - arguments_.size() > 0) if (old_size - arguments_.size() > 0)

View File

@ -1288,7 +1288,7 @@ std::string CmdProxy::Counters(int action) {
std::vector <int> result; std::vector <int> result;
for (size_t i = 0; i < 32; ++i) { for (size_t i = 0; i < 32; ++i) {
if (mask & (1 << i)) { if (mask & (1 << i)) {
result.push_back((int)i); result.push_back(static_cast<int>(i));
} }
} }
os << sls::ToString(result) << '\n'; os << sls::ToString(result) << '\n';

View File

@ -148,7 +148,7 @@ Result<defs::detectorSettings> Detector::getSettings(Positions pos) const {
return pimpl->Parallel(&slsDetector::getSettings, pos); return pimpl->Parallel(&slsDetector::getSettings, pos);
} }
void Detector::setSettings(defs::detectorSettings value, Positions pos) { void Detector::setSettings(const defs::detectorSettings value, Positions pos) {
pimpl->Parallel(&slsDetector::setSettings, pos, value); pimpl->Parallel(&slsDetector::setSettings, pos, value);
} }

View File

@ -43,93 +43,6 @@ void DetectorImpl::setupMultiDetector(bool verify, bool update) {
} }
} }
template <typename RT, typename... CT>
std::vector<RT>
DetectorImpl::serialCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
std::vector<RT> result;
result.reserve(detectors.size());
for (auto &d : detectors) {
result.push_back((d.get()->*somefunc)(Args...));
}
return result;
}
template <typename RT, typename... CT>
std::vector<RT>
DetectorImpl::serialCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const {
std::vector<RT> result;
result.reserve(detectors.size());
for (auto &d : detectors) {
result.push_back((d.get()->*somefunc)(Args...));
}
return result;
}
template <typename RT, typename... CT>
std::vector<RT>
DetectorImpl::parallelCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
std::vector<std::future<RT>> futures;
for (auto &d : detectors) {
futures.push_back(
std::async(std::launch::async, somefunc, d.get(), Args...));
}
std::vector<RT> result;
result.reserve(detectors.size());
for (auto &i : futures) {
result.push_back(i.get());
}
return result;
}
template <typename RT, typename... CT>
std::vector<RT>
DetectorImpl::parallelCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const {
std::vector<std::future<RT>> futures;
for (auto &d : detectors) {
futures.push_back(
std::async(std::launch::async, somefunc, d.get(), Args...));
}
std::vector<RT> result;
result.reserve(detectors.size());
for (auto &i : futures) {
result.push_back(i.get());
}
return result;
}
template <typename... CT>
void DetectorImpl::parallelCall(void (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
std::vector<std::future<void>> futures;
for (auto &d : detectors) {
futures.push_back(
std::async(std::launch::async, somefunc, d.get(), Args...));
}
for (auto &i : futures) {
i.get();
}
return;
}
template <typename... CT>
void DetectorImpl::parallelCall(
void (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const {
std::vector<std::future<void>> futures;
for (auto &d : detectors) {
futures.push_back(
std::async(std::launch::async, somefunc, d.get(), Args...));
}
for (auto &i : futures) {
i.get();
}
return;
}
void DetectorImpl::setAcquiringFlag(bool flag) { void DetectorImpl::setAcquiringFlag(bool flag) {
multi_shm()->acquiringFlag = flag; multi_shm()->acquiringFlag = flag;
} }
@ -212,7 +125,6 @@ std::string DetectorImpl::getUserDetails() {
return sstream.str(); return sstream.str();
} }
bool DetectorImpl::getInitialChecks() const { bool DetectorImpl::getInitialChecks() const {
return multi_shm()->initialChecks; return multi_shm()->initialChecks;
} }
@ -270,8 +182,8 @@ void DetectorImpl::initializeMembers(bool verify) {
void DetectorImpl::updateUserdetails() { void DetectorImpl::updateUserdetails() {
multi_shm()->lastPID = getpid(); multi_shm()->lastPID = getpid();
memset(multi_shm()->lastUser, 0, SHORT_STRING_LENGTH); memset(multi_shm()->lastUser, 0, sizeof(multi_shm()->lastUser));
memset(multi_shm()->lastDate, 0, SHORT_STRING_LENGTH); memset(multi_shm()->lastDate, 0, sizeof(multi_shm()->lastDate));
try { try {
sls::strcpy_safe(multi_shm()->lastUser, exec("whoami").c_str()); sls::strcpy_safe(multi_shm()->lastUser, exec("whoami").c_str());
sls::strcpy_safe(multi_shm()->lastDate, exec("date").c_str()); sls::strcpy_safe(multi_shm()->lastDate, exec("date").c_str());
@ -316,8 +228,7 @@ std::string DetectorImpl::exec(const char *cmd) {
return result; return result;
} }
void DetectorImpl::setVirtualDetectorServers(const int numdet, void DetectorImpl::setVirtualDetectorServers(const int numdet, const int port) {
const int port) {
std::vector<std::string> hostnames; std::vector<std::string> hostnames;
for (int i = 0; i < numdet; ++i) { for (int i = 0; i < numdet; ++i) {
// * 2 is for control and stop port // * 2 is for control and stop port
@ -369,15 +280,17 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
// get type by connecting // get type by connecting
detectorType type = slsDetector::getTypeFromDetector(host, port); detectorType type = slsDetector::getTypeFromDetector(host, port);
int pos = (int)detectors.size(); auto pos = detectors.size();
detectors.push_back( detectors.emplace_back(
sls::make_unique<slsDetector>(type, multiId, pos, false)); sls::make_unique<slsDetector>(type, multiId, pos, false));
multi_shm()->numberOfDetectors = detectors.size(); multi_shm()->numberOfDetectors = detectors.size();
detectors[pos]->setControlPort(port); detectors[pos]->setControlPort(port);
detectors[pos]->setStopPort(port + 1); detectors[pos]->setStopPort(port + 1);
detectors[pos]->setHostname(host, multi_shm()->initialChecks); detectors[pos]->setHostname(host, multi_shm()->initialChecks);
// detector type updated by now // detector type updated by now
multi_shm()->multiDetectorType = Parallel(&slsDetector::getDetectorType, {}).tsquash("Inconsistent detector types."); multi_shm()->multiDetectorType =
Parallel(&slsDetector::getDetectorType, {})
.tsquash("Inconsistent detector types.");
} }
void DetectorImpl::updateDetectorSize() { void DetectorImpl::updateDetectorSize() {
@ -464,7 +377,8 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
if (multi_shm()->multiDetectorType == EIGER) { if (multi_shm()->multiDetectorType == EIGER) {
numSocketsPerDetector = 2; numSocketsPerDetector = 2;
} }
if (Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {}).squash() == 2) { if (Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {}).squash() ==
2) {
numSocketsPerDetector = 2; numSocketsPerDetector = 2;
} }
numSockets *= numSocketsPerDetector; numSockets *= numSocketsPerDetector;
@ -476,7 +390,8 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
try { try {
zmqSocket.push_back(sls::make_unique<ZmqSocket>( zmqSocket.push_back(sls::make_unique<ZmqSocket>(
detectors[iSocket / numSocketsPerDetector] detectors[iSocket / numSocketsPerDetector]
->getClientStreamingIP().str() ->getClientStreamingIP()
.str()
.c_str(), .c_str(),
portnum)); portnum));
FILE_LOG(logINFO) << "Zmq Client[" << iSocket << "] at " FILE_LOG(logINFO) << "Zmq Client[" << iSocket << "] at "
@ -503,7 +418,9 @@ void DetectorImpl::readFrameFromReceiver() {
bool gappixelsenable = false; bool gappixelsenable = false;
bool quadEnable = false; bool quadEnable = false;
bool eiger = false; bool eiger = false;
bool numInterfaces = Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {}).squash(); // cannot pick up from zmq bool numInterfaces =
Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {})
.squash(); // cannot pick up from zmq
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()]; bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
int numRunning = 0; int numRunning = 0;
@ -530,7 +447,7 @@ void DetectorImpl::readFrameFromReceiver() {
uint32_t size = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0; uint32_t size = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
float bytesPerPixel = 0; float bytesPerPixel = 0;
// header info every header // header info every header
std::string currentFileName = ""; std::string currentFileName;
uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1,
currentFileIndex = -1; currentFileIndex = -1;
uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1,
@ -657,18 +574,18 @@ void DetectorImpl::readFrameFromReceiver() {
if (eiger && (flippedDataX != 0U)) { if (eiger && (flippedDataX != 0U)) {
for (uint32_t i = 0; i < nPixelsY; ++i) { for (uint32_t i = 0; i < nPixelsY; ++i) {
memcpy(((char *)multiframe) + memcpy((multiframe) +
((yoffset + (nPixelsY - 1 - i)) * ((yoffset + (nPixelsY - 1 - i)) *
rowoffset) + rowoffset) +
xoffset, xoffset,
(char *)image + (i * singledetrowoffset), image + (i * singledetrowoffset),
singledetrowoffset); singledetrowoffset);
} }
} else { } else {
for (uint32_t i = 0; i < nPixelsY; ++i) { for (uint32_t i = 0; i < nPixelsY; ++i) {
memcpy(((char *)multiframe) + memcpy((multiframe) + ((yoffset + i) * rowoffset) +
((yoffset + i) * rowoffset) + xoffset, xoffset,
(char *)image + (i * singledetrowoffset), image + (i * singledetrowoffset),
singledetrowoffset); singledetrowoffset);
} }
} }
@ -699,19 +616,20 @@ void DetectorImpl::readFrameFromReceiver() {
<< "\n\t nDetPixelsX: " << nDetPixelsX << "\n\t nDetPixelsX: " << nDetPixelsX
<< "\n\t nDetPixelsY: " << nDetPixelsY << "\n\t nDetPixelsY: " << nDetPixelsY
<< "\n\t databytes: " << n; << "\n\t databytes: " << n;
thisData = new detectorData( thisData =
getCurrentProgress(), currentFileName.c_str(), nDetPixelsX, new detectorData(getCurrentProgress(), currentFileName,
nDetPixelsY, multigappixels, n, dynamicRange, nDetPixelsX, nDetPixelsY, multigappixels,
currentFileIndex); n, dynamicRange, currentFileIndex);
} }
// normal pixels // normal pixels
else { else {
thisData = new detectorData( thisData =
getCurrentProgress(), currentFileName.c_str(), nDetPixelsX, new detectorData(getCurrentProgress(), currentFileName,
nDetPixelsY, multiframe, multisize, dynamicRange, nDetPixelsX, nDetPixelsY, multiframe,
currentFileIndex); multisize, dynamicRange, currentFileIndex);
} }
dataReady(thisData, currentFrameIndex, dataReady(
thisData, currentFrameIndex,
((dynamicRange == 32 && eiger) ? currentSubFrameIndex : -1), ((dynamicRange == 32 && eiger) ? currentSubFrameIndex : -1),
pCallbackArg); pCallbackArg);
delete thisData; delete thisData;
@ -904,7 +822,6 @@ bool DetectorImpl::enableDataStreamingToClient(int enable) {
return client_downstream; return client_downstream;
} }
void DetectorImpl::savePattern(const std::string &fname) { void DetectorImpl::savePattern(const std::string &fname) {
// std::ofstream outfile; // std::ofstream outfile;
// outfile.open(fname.c_str(), std::ios_base::out); // outfile.open(fname.c_str(), std::ios_base::out);
@ -945,16 +862,16 @@ void DetectorImpl::savePattern(const std::string &fname) {
// multiSlsDetectorClient(cmd, GET_ACTION, this, outfile); // multiSlsDetectorClient(cmd, GET_ACTION, this, outfile);
} }
void DetectorImpl::registerAcquisitionFinishedCallback(void (*func)(double, int,
void *),
void DetectorImpl::registerAcquisitionFinishedCallback( void *pArg) {
void (*func)(double, int, void *), void *pArg) {
acquisition_finished = func; acquisition_finished = func;
acqFinished_p = pArg; acqFinished_p = pArg;
} }
void DetectorImpl::registerDataCallback( void DetectorImpl::registerDataCallback(void (*userCallback)(detectorData *,
void (*userCallback)(detectorData *, uint64_t, uint32_t, void *), uint64_t, uint32_t,
void *),
void *pArg) { void *pArg) {
dataReady = userCallback; dataReady = userCallback;
pCallbackArg = pArg; pCallbackArg = pArg;
@ -972,7 +889,8 @@ double DetectorImpl::setTotalProgress() {
int ns = 1; int ns = 1;
if (multi_shm()->multiDetectorType == JUNGFRAU) { if (multi_shm()->multiDetectorType == JUNGFRAU) {
ns = Parallel(&slsDetector::getNumberOfAdditionalStorageCellsFromShm, {}) ns =
Parallel(&slsDetector::getNumberOfAdditionalStorageCellsFromShm, {})
.tsquash("Inconsistent number of additional storage cells"); .tsquash("Inconsistent number of additional storage cells");
++ns; ++ns;
} }
@ -992,8 +910,7 @@ void DetectorImpl::incrementProgress() {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
progressIndex += 1; progressIndex += 1;
std::cout << std::fixed << std::setprecision(2) << std::setw(6) std::cout << std::fixed << std::setprecision(2) << std::setw(6)
<< 100. * progressIndex / totalProgress << 100. * progressIndex / totalProgress << " \%";
<< " \%";
std::cout << '\r' << std::flush; std::cout << '\r' << std::flush;
} }
@ -1001,8 +918,7 @@ void DetectorImpl::setCurrentProgress(int64_t i) {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
progressIndex = (double)i; progressIndex = (double)i;
std::cout << std::fixed << std::setprecision(2) << std::setw(6) std::cout << std::fixed << std::setprecision(2) << std::setw(6)
<< 100. * progressIndex / totalProgress << 100. * progressIndex / totalProgress << " \%";
<< " \%";
std::cout << '\r' << std::flush; std::cout << '\r' << std::flush;
} }
@ -1016,21 +932,23 @@ int DetectorImpl::acquire() {
struct timespec begin, end; struct timespec begin, end;
clock_gettime(CLOCK_REALTIME, &begin); clock_gettime(CLOCK_REALTIME, &begin);
// in the real time acquisition loop, processing thread will wait for a post // in the real time acquisition loop, processing thread will wait for a
// each time // post each time
sem_init(&sem_newRTAcquisition, 1, 0); sem_init(&sem_newRTAcquisition, 1, 0);
// in the real time acquistion loop, main thread will wait for processing // in the real time acquistion loop, main thread will wait for
// thread to be done each time (which in turn waits for receiver/ext // processing thread to be done each time (which in turn waits for
// process) // receiver/ext process)
sem_init(&sem_endRTAcquisition, 1, 0); sem_init(&sem_endRTAcquisition, 1, 0);
bool receiver = Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false); bool receiver =
Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false);
progressIndex = 0; progressIndex = 0;
setJoinThreadFlag(false); setJoinThreadFlag(false);
// verify receiver is idle // verify receiver is idle
if (receiver) { if (receiver) {
if (Parallel(&slsDetector::getReceiverStatus, {}).squash(ERROR) != IDLE) { if (Parallel(&slsDetector::getReceiverStatus, {}).squash(ERROR) !=
IDLE) {
Parallel(&slsDetector::stopReceiver, {}); Parallel(&slsDetector::stopReceiver, {});
} }
} }
@ -1079,8 +997,7 @@ int DetectorImpl::acquire() {
auto t = Parallel(&slsDetector::getRunStatus, {}); auto t = Parallel(&slsDetector::getRunStatus, {});
if (t.equal()) if (t.equal())
status = t.front(); status = t.front();
acquisition_finished(getCurrentProgress(), status, acquisition_finished(getCurrentProgress(), status, acqFinished_p);
acqFinished_p);
} }
sem_destroy(&sem_newRTAcquisition); sem_destroy(&sem_newRTAcquisition);
@ -1122,7 +1039,8 @@ void DetectorImpl::processData() {
} }
} }
// get progress // get progress
caught = Parallel(&slsDetector::getFramesCaughtByReceiver, {0}).squash(); caught = Parallel(&slsDetector::getFramesCaughtByReceiver, {0})
.squash();
// updating progress // updating progress
if (caught != -1) { if (caught != -1) {
@ -1185,7 +1103,6 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
<< "Updating Firmware. This can take awhile. Please be patient..."; << "Updating Firmware. This can take awhile. Please be patient...";
FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname; FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
size_t filesize = 0; size_t filesize = 0;
// check if it exists // check if it exists
struct stat st; struct stat st;
@ -1215,9 +1132,8 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
// convert src to dst rawbin // convert src to dst rawbin
FILE_LOG(logDEBUG1) << "Converting " << fname << " to " << destfname; FILE_LOG(logDEBUG1) << "Converting " << fname << " to " << destfname;
{ {
const int pofNumHeaderBytes = 0x11C; constexpr int pofNumHeaderBytes = 0x11C;
const int pofNumPadding = 0x80; constexpr int pofFooterOfst = 0x1000000;
const int pofFooterOfst = 0x1000000;
int dstFilePos = 0; int dstFilePos = 0;
if (isPof) { if (isPof) {
// Read header and discard // Read header and discard
@ -1225,14 +1141,13 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
fgetc(src); fgetc(src);
} }
// Write 0xFF to destination 0x80 times (padding) // Write 0xFF to destination 0x80 times (padding)
{ constexpr int pofNumPadding{0x80};
char c = 0xFF; constexpr uint8_t c{0xFF};
while (dstFilePos < pofNumPadding) { while (dstFilePos < pofNumPadding) {
write(dst, &c, 1); write(dst, &c, sizeof(c));
++dstFilePos; ++dstFilePos;
} }
} }
}
// Swap bits from source and write to dest // Swap bits from source and write to dest
while (!feof(src)) { while (!feof(src)) {
// pof: exit early to discard footer // pof: exit early to discard footer
@ -1247,8 +1162,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
// swap bits // swap bits
int d = 0; int d = 0;
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
d = d | d = d | (((s & (1 << i)) >> i) << (7 - i));
(((s & (1 << i)) >> i) << (7 - i));
} }
write(dst, &d, 1); write(dst, &d, 1);
++dstFilePos; ++dstFilePos;
@ -1258,7 +1172,6 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
throw RuntimeError( throw RuntimeError(
"Could not convert programming file. EOF before end of flash"); "Could not convert programming file. EOF before end of flash");
} }
} }
if (fclose(src) != 0) { if (fclose(src) != 0) {
throw RuntimeError("Program FPGA: Could not close source file"); throw RuntimeError("Program FPGA: Could not close source file");

View File

@ -19,7 +19,6 @@ class detectorData;
#define MULTI_SHMAPIVERSION 0x190809 #define MULTI_SHMAPIVERSION 0x190809
#define MULTI_SHMVERSION 0x200131 #define MULTI_SHMVERSION 0x200131
#define SHORT_STRING_LENGTH 50 #define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30
#include <future> #include <future>
#include <numeric> #include <numeric>
@ -193,44 +192,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
} }
} }
/**
* Loop through the detectors serially and return the result as a vector
*/
template <typename RT, typename... CT>
std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args);
/**
* Loop through the detectors serially and return the result as a vector
* Const qualified version
*/
template <typename RT, typename... CT>
std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const;
/**
* Loop through the detectors in parallel and return the result as a vector
*/
template <typename RT, typename... CT>
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args);
/**
* Loop through the detectors in parallel and return the result as a vector
* Const qualified version
*/
template <typename RT, typename... CT>
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const;
template <typename... CT>
void parallelCall(void (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args);
template <typename... CT>
void parallelCall(void (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const;
/** set acquiring flag in shared memory */ /** set acquiring flag in shared memory */
void setAcquiringFlag(bool flag); void setAcquiringFlag(bool flag);

View File

@ -18,7 +18,7 @@
using sls::RuntimeError; using sls::RuntimeError;
using sls::SocketError; using sls::SocketError;
using Interface = sls::ServerInterface2; using Interface = sls::ServerInterface;
ClientInterface::~ClientInterface() { ClientInterface::~ClientInterface() {
killTcpThread = true; killTcpThread = true;
@ -217,7 +217,7 @@ void ClientInterface::modeNotImplemented(const std::string &modename,
} }
template <typename T> template <typename T>
void ClientInterface::validate(T arg, T retval, std::string modename, void ClientInterface::validate(T arg, T retval, const std::string& modename,
numberMode hex) { numberMode hex) {
if (ret == OK && arg != -1 && retval != arg) { if (ret == OK && arg != -1 && retval != arg) {
auto format = (hex == HEX) ? std::hex : std::dec; auto format = (hex == HEX) ? std::hex : std::dec;

View File

@ -41,85 +41,85 @@ class ClientInterface : private virtual slsDetectorDefs {
private: private:
void startTCPServer(); void startTCPServer();
int functionTable(); int functionTable();
int decodeFunction(sls::ServerInterface2 &socket); int decodeFunction(sls::ServerInterface &socket);
void functionNotImplemented(); void functionNotImplemented();
void modeNotImplemented(const std::string& modename, int mode); void modeNotImplemented(const std::string& modename, int mode);
template <typename T> template <typename T>
void validate(T arg, T retval, std::string modename, numberMode hex); void validate(T arg, T retval, const std::string& modename, numberMode hex);
void verifyLock(); void verifyLock();
void verifyIdle(sls::ServerInterface2 &socket); void verifyIdle(sls::ServerInterface &socket);
int exec_command(sls::ServerInterface2 &socket); int exec_command(sls::ServerInterface &socket);
int exit_server(sls::ServerInterface2 &socket); int exit_server(sls::ServerInterface &socket);
int lock_receiver(sls::ServerInterface2 &socket); int lock_receiver(sls::ServerInterface &socket);
int get_last_client_ip(sls::ServerInterface2 &socket); int get_last_client_ip(sls::ServerInterface &socket);
int set_port(sls::ServerInterface2 &socket); int set_port(sls::ServerInterface &socket);
int update_client(sls::ServerInterface2 &socket); int update_client(sls::ServerInterface &socket);
int send_update(sls::ServerInterface2 &socket); int send_update(sls::ServerInterface &socket);
int get_version(sls::ServerInterface2 &socket); int get_version(sls::ServerInterface &socket);
int set_detector_type(sls::ServerInterface2 &socket); int set_detector_type(sls::ServerInterface &socket);
int set_detector_hostname(sls::ServerInterface2 &socket); int set_detector_hostname(sls::ServerInterface &socket);
int set_roi(sls::ServerInterface2 &socket); int set_roi(sls::ServerInterface &socket);
int set_num_frames(sls::ServerInterface2 &socket); int set_num_frames(sls::ServerInterface &socket);
int set_num_analog_samples(sls::ServerInterface2 &socket); int set_num_analog_samples(sls::ServerInterface &socket);
int set_num_digital_samples(sls::ServerInterface2 &socket); int set_num_digital_samples(sls::ServerInterface &socket);
int set_exptime(sls::ServerInterface2 &socket); int set_exptime(sls::ServerInterface &socket);
int set_period(sls::ServerInterface2 &socket); int set_period(sls::ServerInterface &socket);
int set_subexptime(sls::ServerInterface2 &socket); int set_subexptime(sls::ServerInterface &socket);
int set_subdeadtime(sls::ServerInterface2 &socket); int set_subdeadtime(sls::ServerInterface &socket);
int set_dynamic_range(sls::ServerInterface2 &socket); int set_dynamic_range(sls::ServerInterface &socket);
int set_streaming_frequency(sls::ServerInterface2 &socket); int set_streaming_frequency(sls::ServerInterface &socket);
int get_status(sls::ServerInterface2 &socket); int get_status(sls::ServerInterface &socket);
int start_receiver(sls::ServerInterface2 &socket); int start_receiver(sls::ServerInterface &socket);
int stop_receiver(sls::ServerInterface2 &socket); int stop_receiver(sls::ServerInterface &socket);
int set_file_dir(sls::ServerInterface2 &socket); int set_file_dir(sls::ServerInterface &socket);
int set_file_name(sls::ServerInterface2 &socket); int set_file_name(sls::ServerInterface &socket);
int set_file_index(sls::ServerInterface2 &socket); int set_file_index(sls::ServerInterface &socket);
int get_frame_index(sls::ServerInterface2 &socket); int get_frame_index(sls::ServerInterface &socket);
int get_missing_packets(sls::ServerInterface2 &socket); int get_missing_packets(sls::ServerInterface &socket);
int get_frames_caught(sls::ServerInterface2 &socket); int get_frames_caught(sls::ServerInterface &socket);
int enable_file_write(sls::ServerInterface2 &socket); int enable_file_write(sls::ServerInterface &socket);
int enable_master_file_write(sls::ServerInterface2 &socket); int enable_master_file_write(sls::ServerInterface &socket);
int enable_compression(sls::ServerInterface2 &socket); int enable_compression(sls::ServerInterface &socket);
int enable_overwrite(sls::ServerInterface2 &socket); int enable_overwrite(sls::ServerInterface &socket);
int enable_tengiga(sls::ServerInterface2 &socket); int enable_tengiga(sls::ServerInterface &socket);
int set_fifo_depth(sls::ServerInterface2 &socket); int set_fifo_depth(sls::ServerInterface &socket);
int set_activate(sls::ServerInterface2 &socket); int set_activate(sls::ServerInterface &socket);
int set_data_stream_enable(sls::ServerInterface2 &socket); int set_data_stream_enable(sls::ServerInterface &socket);
int set_streaming_timer(sls::ServerInterface2 &socket); int set_streaming_timer(sls::ServerInterface &socket);
int set_flipped_data(sls::ServerInterface2 &socket); int set_flipped_data(sls::ServerInterface &socket);
int set_file_format(sls::ServerInterface2 &socket); int set_file_format(sls::ServerInterface &socket);
int set_detector_posid(sls::ServerInterface2 &socket); int set_detector_posid(sls::ServerInterface &socket);
int set_multi_detector_size(sls::ServerInterface2 &socket); int set_multi_detector_size(sls::ServerInterface &socket);
int set_streaming_port(sls::ServerInterface2 &socket); int set_streaming_port(sls::ServerInterface &socket);
int set_streaming_source_ip(sls::ServerInterface2 &socket); int set_streaming_source_ip(sls::ServerInterface &socket);
int set_silent_mode(sls::ServerInterface2 &socket); int set_silent_mode(sls::ServerInterface &socket);
int enable_gap_pixels(sls::ServerInterface2 &socket); int enable_gap_pixels(sls::ServerInterface &socket);
int restream_stop(sls::ServerInterface2 &socket); int restream_stop(sls::ServerInterface &socket);
int set_additional_json_header(sls::ServerInterface2 &socket); int set_additional_json_header(sls::ServerInterface &socket);
int get_additional_json_header(sls::ServerInterface2 &socket); int get_additional_json_header(sls::ServerInterface &socket);
int set_udp_socket_buffer_size(sls::ServerInterface2 &socket); int set_udp_socket_buffer_size(sls::ServerInterface &socket);
int get_real_udp_socket_buffer_size(sls::ServerInterface2 &socket); int get_real_udp_socket_buffer_size(sls::ServerInterface &socket);
int set_frames_per_file(sls::ServerInterface2 &socket); int set_frames_per_file(sls::ServerInterface &socket);
int check_version_compatibility(sls::ServerInterface2 &socket); int check_version_compatibility(sls::ServerInterface &socket);
int set_discard_policy(sls::ServerInterface2 &socket); int set_discard_policy(sls::ServerInterface &socket);
int set_padding_enable(sls::ServerInterface2 &socket); int set_padding_enable(sls::ServerInterface &socket);
int set_deactivated_padding_enable(sls::ServerInterface2 &socket); int set_deactivated_padding_enable(sls::ServerInterface &socket);
int set_readout_mode(sls::ServerInterface2 &socket); int set_readout_mode(sls::ServerInterface &socket);
int set_adc_mask(sls::ServerInterface2 &socket); int set_adc_mask(sls::ServerInterface &socket);
int set_dbit_list(sls::ServerInterface2 &socket); int set_dbit_list(sls::ServerInterface &socket);
int get_dbit_list(sls::ServerInterface2 &socket); int get_dbit_list(sls::ServerInterface &socket);
int set_dbit_offset(sls::ServerInterface2 &socket); int set_dbit_offset(sls::ServerInterface &socket);
int set_quad_type(sls::ServerInterface2 &socket); int set_quad_type(sls::ServerInterface &socket);
int set_read_n_lines(sls::ServerInterface2 &socket); int set_read_n_lines(sls::ServerInterface &socket);
int set_udp_ip(sls::ServerInterface2 &socket); int set_udp_ip(sls::ServerInterface &socket);
int set_udp_ip2(sls::ServerInterface2 &socket); int set_udp_ip2(sls::ServerInterface &socket);
int set_udp_port(sls::ServerInterface2 &socket); int set_udp_port(sls::ServerInterface &socket);
int set_udp_port2(sls::ServerInterface2 &socket); int set_udp_port2(sls::ServerInterface &socket);
int set_num_interfaces(sls::ServerInterface2 &socket); int set_num_interfaces(sls::ServerInterface &socket);
int set_adc_mask_10g(sls::ServerInterface2 &socket); int set_adc_mask_10g(sls::ServerInterface &socket);
int set_num_counters(sls::ServerInterface2 &socket); int set_num_counters(sls::ServerInterface &socket);
Implementation *impl() { Implementation *impl() {
if (receiver != nullptr) { if (receiver != nullptr) {
@ -133,7 +133,7 @@ class ClientInterface : private virtual slsDetectorDefs {
detectorType myDetectorType; detectorType myDetectorType;
std::unique_ptr<Implementation> receiver{nullptr}; std::unique_ptr<Implementation> receiver{nullptr};
int (ClientInterface::*flist[NUM_REC_FUNCTIONS])( int (ClientInterface::*flist[NUM_REC_FUNCTIONS])(
sls::ServerInterface2 &socket); sls::ServerInterface &socket);
int ret{OK}; int ret{OK};
int fnum{-1}; int fnum{-1};
int lockedByClient{0}; int lockedByClient{0};

View File

@ -76,19 +76,13 @@ void Fifo::DestroyFifos(){
free(memory); free(memory);
memory = nullptr; memory = nullptr;
} }
if (fifoBound) {
delete fifoBound; delete fifoBound;
fifoBound = nullptr; fifoBound = nullptr;
}
if (fifoFree) {
delete fifoFree; delete fifoFree;
fifoFree = nullptr; fifoFree = nullptr;
}
if (fifoStream) {
delete fifoStream; delete fifoStream;
fifoStream = nullptr; fifoStream = nullptr;
} }
}
void Fifo::FreeAddress(char*& address) { void Fifo::FreeAddress(char*& address) {

View File

@ -66,7 +66,7 @@ void ThreadObject::SetThreadPriority(int priority) {
struct sched_param param; struct sched_param param;
param.sched_priority = priority; param.sched_priority = priority;
if (pthread_setschedparam(threadObject->native_handle(), SCHED_FIFO, &param) == EPERM) { if (pthread_setschedparam(threadObject->native_handle(), SCHED_FIFO, &param) == EPERM) {
if (!index) { if (index == 0) {
FILE_LOG(logWARNING) << "Could not prioritize " << type << " thread. " FILE_LOG(logWARNING) << "Could not prioritize " << type << " thread. "
"(No Root Privileges?)"; "(No Root Privileges?)";
} }

View File

@ -4,7 +4,7 @@ set(SOURCES
src/ClientSocket.cpp src/ClientSocket.cpp
src/DataSocket.cpp src/DataSocket.cpp
src/ServerSocket.cpp src/ServerSocket.cpp
src/ServerInterface2.cpp src/ServerInterface.cpp
src/network_utils.cpp src/network_utils.cpp
) )
@ -25,7 +25,7 @@ set(PUBLICHEADERS
include/ClientSocket.h include/ClientSocket.h
include/DataSocket.h include/DataSocket.h
include/ServerSocket.h include/ServerSocket.h
include/ServerInterface2.h include/ServerInterface.h
include/network_utils.h include/network_utils.h
include/FixedCapacityContainer.h include/FixedCapacityContainer.h
include/ToString.h include/ToString.h

View File

@ -2,18 +2,18 @@
#include "DataSocket.h" #include "DataSocket.h"
namespace sls { namespace sls {
class ServerInterface2; class ServerInterface;
} }
#include "ServerSocket.h" #include "ServerSocket.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
namespace sls { namespace sls {
class ServerInterface2 : public DataSocket { class ServerInterface : public DataSocket {
using defs = slsDetectorDefs; using defs = slsDetectorDefs;
public: public:
ServerInterface2(int socketId) : DataSocket(socketId) {} ServerInterface(int socketId) : DataSocket(socketId) {}
int sendResult(int ret, void *retval, int retvalSize, char *mess = nullptr); int sendResult(int ret, void *retval, int retvalSize, char *mess = nullptr);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "DataSocket.h" #include "DataSocket.h"
#include "ServerInterface2.h" #include "ServerInterface.h"
#include "network_utils.h" #include "network_utils.h"
#include <cstdint> #include <cstdint>
#include <netdb.h> #include <netdb.h>
@ -14,7 +14,7 @@ namespace sls {
class ServerSocket : public DataSocket { class ServerSocket : public DataSocket {
public: public:
ServerSocket(int port); ServerSocket(int port);
ServerInterface2 accept(); ServerInterface accept();
IpAddr getLastClient() const noexcept { return lastClient; } IpAddr getLastClient() const noexcept { return lastClient; }
IpAddr getThisClient() const noexcept { return thisClient; } IpAddr getThisClient() const noexcept { return thisClient; }
IpAddr getLockedBy() const noexcept { return lockedBy; } IpAddr getLockedBy() const noexcept { return lockedBy; }

View File

@ -1,10 +1,10 @@
#include "ServerInterface2.h" #include "ServerInterface.h"
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <sstream> #include <sstream>
namespace sls { namespace sls {
int ServerInterface2::sendResult(int ret, void *retval, int retvalSize, int ServerInterface::sendResult(int ret, void *retval, int retvalSize,
char *mess) { char *mess) {
write(&ret, sizeof(ret)); write(&ret, sizeof(ret));

View File

@ -1,4 +1,4 @@
#include "ServerInterface2.h" #include "ServerInterface.h"
#include "ServerSocket.h" #include "ServerSocket.h"
#include "DataSocket.h" #include "DataSocket.h"
@ -37,7 +37,7 @@ ServerSocket::ServerSocket(int port)
} }
} }
ServerInterface2 ServerSocket::accept() { ServerInterface ServerSocket::accept() {
lastClient = thisClient; //update from previous connection lastClient = thisClient; //update from previous connection
struct sockaddr_in clientAddr; struct sockaddr_in clientAddr;
socklen_t addr_size = sizeof clientAddr; socklen_t addr_size = sizeof clientAddr;
@ -49,7 +49,7 @@ ServerInterface2 ServerSocket::accept() {
char tc[INET_ADDRSTRLEN]{}; char tc[INET_ADDRSTRLEN]{};
inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN); inet_ntop(AF_INET, &(clientAddr.sin_addr), tc, INET_ADDRSTRLEN);
thisClient = IpAddr{tc}; thisClient = IpAddr{tc};
return ServerInterface2(newSocket); return ServerInterface(newSocket);
} }
}; // namespace sls }; // namespace sls

View File

@ -3,7 +3,7 @@
#include "tests/testenum.h" #include "tests/testenum.h"
#include "ServerInterface2.h" #include "ServerInterface.h"
#include "container_utils.h" #include "container_utils.h"
#include <iostream> #include <iostream>
#include <unordered_map> #include <unordered_map>
@ -15,7 +15,7 @@ struct EnumClassHash {
} }
}; };
using Interface = sls::ServerInterface2; using Interface = sls::ServerInterface;
using func_ptr = void (*)(Interface &); using func_ptr = void (*)(Interface &);
/******************************************** /********************************************