Merge branch 'developer' into gui

This commit is contained in:
2019-06-03 11:13:03 +02:00
201 changed files with 25684 additions and 2843 deletions

View File

@ -81,7 +81,6 @@ LATEX_HIDE_INDICES = YES
PREDEFINED = __cplusplus
INPUT = ../slsSupportLib/include/communication_funcs.h \
../slsSupportLib/include/error_defs.h \
../slsSupportLib/include/sls_detector_defs.h \
../slsSupportLib/include/sls_detector_funcs.h \
../slsSupportLib/include/ansi.h \

View File

@ -25,7 +25,29 @@ class detectorData {
npoints(np), npy(ny), cvalues(cval), databytes(dbytes),
dynamicRange(dr), dgainvalues(NULL), fileIndex(file_ind) {
strcpy(fileName,fname);
};
};
int64_t getChannel(int i) {
int off=dynamicRange/8;
if (off==1) {
char val=*(cvalues+i);
return val;
}
if (off==2) {
int16_t val=*((int16_t*)(cvalues+i*off));
return val;
}
if (off==4) {
int32_t val=*((int32_t*)(cvalues+i*off));
return val;
}
if (off==8) {
int64_t val=*((int64_t*)(cvalues+i*off));
return val;
}
return -1;
}
/**
@short The destructor

View File

@ -1,7 +1,6 @@
#pragma once
#include "SharedMemory.h"
#include "error_defs.h"
#include "logger.h"
#include "sls_detector_defs.h"
@ -630,6 +629,20 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @returns OK or FAIL
*/
int configureMAC(int detPos = -1);
/**
* Set starting frame number for the next acquisition
* @param val starting frame number
* @param detPos -1 for all detectors in list or specific detector position
*/
void setStartingFrameNumber(const uint64_t value, int detPos = -1);
/**
* Get starting frame number for the next acquisition
* @param detPos -1 for all detectors in list or specific detector position
* @returns starting frame number
*/
uint64_t getStartingFrameNumber(int detPos = -1);
/**
* Set/get timer value (not all implemented for all detectors)
@ -1799,9 +1812,9 @@ class multiSlsDetector : public virtual slsDetectorDefs {
/**
* Gets the current frame index of receiver
* @param detPos -1 for all detectors in list or specific detector position
* @returns current frame index of receiver
* @returns average of all current frame index of receiver
*/
int getReceiverCurrentFrameIndex(int detPos = -1);
uint64_t getReceiverCurrentFrameIndex(int detPos = -1);
/**
* Resets framescaught in receiver
@ -2160,14 +2173,14 @@ class multiSlsDetector : public virtual slsDetectorDefs {
/**
* add gap pixels to the image (only for Eiger in 4 bit mode)
* @param image pointer to image without gap pixels
* @param gpImage poiner to image with gap pixels, if NULL, allocated
* inside function
* @returns number of data bytes of image with gap pixels
*/
int processImageWithGapPixels(char *image, char *&gpImage);
/**
* add gap pixels to the image (only for Eiger in 4 bit mode)
* @param image pointer to image without gap pixels
* @param gpImage poiner to image with gap pixels, if NULL, allocated
* inside function
* @returns number of data bytes of image with gap pixels
*/
int processImageWithGapPixels(char *image, char *&gpImage);
/**
* Set total progress (total number of frames/images in an acquisition)
@ -2223,6 +2236,14 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
std::vector<char> readPofFile(const std::string &fname);
/**
* Convert a double holding time in seconds to an int64_t with nano seconds
* Used for conversion when sending time to detector
* @param t time in seconds
* @returns time in nano seconds
*/
int64_t secondsToNanoSeconds(double t);
/** Multi detector Id */
const int multiId{0};

View File

@ -3,6 +3,7 @@
#include <string>
#include "CmdLineParser.h"
#include "CmdProxy.h"
#include "container_utils.h"
#include "string_utils.h"
#include "multiSlsDetector.h"
@ -21,85 +22,114 @@ inline int dummyCallback(detectorData *d, int p, void *) {
class multiSlsDetectorClient {
public:
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector = nullptr):
action_(action),
detPtr(myDetector){
multiSlsDetectorClient(int argc, char *argv[], int action,
multiSlsDetector *myDetector = nullptr,
std::ostream &output = std::cout)
: action_(action), detPtr(myDetector), os(output) {
parser.Parse(argc, argv);
runCommand();
}
multiSlsDetectorClient(const std::string& args, int action, multiSlsDetector *myDetector = nullptr):
action_(action),
detPtr(myDetector){
multiSlsDetectorClient(const std::string &args, int action,
multiSlsDetector *myDetector = nullptr,
std::ostream &output = std::cout)
: action_(action), detPtr(myDetector), os(output) {
parser.Parse(args);
runCommand();
}
private:
int action_;
CmdLineParser parser;
multiSlsDetector* detPtr = nullptr;
void runCommand(){
private:
int action_;
CmdLineParser parser;
multiSlsDetector *detPtr = nullptr;
std::ostream &os;
void runCommand() {
bool verify = true;
bool update = true;
if (action_ == slsDetectorDefs::PUT_ACTION && parser.n_arguments() == 0) {
std::cout << "Wrong usage - should be: " << parser.executable() << "[id-][pos:]channel arg" << std::endl;
std::cout << std::endl;
if (action_ == slsDetectorDefs::PUT_ACTION &&
parser.n_arguments() == 0) {
os << "Wrong usage - should be: " << parser.executable()
<< "[id-][pos:]channel arg" << std::endl;
os << std::endl;
return;
};
if (action_ == slsDetectorDefs::GET_ACTION && parser.command().empty()) {
std::cout << "Wrong usage - should be: " << parser.executable() << "[id-][pos:]channel arg" << std::endl;
std::cout << std::endl;
if (action_ == slsDetectorDefs::GET_ACTION &&
parser.command().empty()) {
os << "Wrong usage - should be: " << parser.executable()
<< "[id-][pos:]channel arg" << std::endl;
os << std::endl;
return;
};
if (action_ == slsDetectorDefs::READOUT_ACTION && parser.detector_id() != -1) {
std::cout << "detector_id: " << parser.detector_id() << " ,readout of individual detectors is not allowed!" << std::endl;
if (action_ == slsDetectorDefs::READOUT_ACTION &&
parser.detector_id() != -1) {
os << "detector_id: " << parser.detector_id()
<< " ,readout of individual detectors is not allowed!"
<< std::endl;
return;
}
// special commands
if (parser.command() == "free") {
multiSlsDetector::freeSharedMemory(parser.multi_id(), parser.detector_id());
multiSlsDetector::freeSharedMemory(parser.multi_id(),
parser.detector_id());
return;
} // get user details without verify sharedMultiSlsDetector version
else if ((parser.command() == "user") && (action_ == slsDetectorDefs::GET_ACTION)) {
else if ((parser.command() == "user") &&
(action_ == slsDetectorDefs::GET_ACTION)) {
verify = false;
update = false;
}
//std::cout<<"id:"<<id<<" pos:"<<pos<<std::endl;
// create multiSlsDetector class if required
std::unique_ptr<multiSlsDetector> localDet;
if (detPtr == nullptr) {
try {
localDet = sls::make_unique<multiSlsDetector>(parser.multi_id(), verify, update);
localDet = sls::make_unique<multiSlsDetector>(parser.multi_id(),
verify, update);
detPtr = localDet.get();
} catch (const RuntimeError &e) {
/*std::cout << e.GetMessage() << std::endl;*/
/*os << e.GetMessage() << std::endl;*/
return;
} catch (...) {
std::cout << " caught exception\n";
os << " caught exception\n";
return;
}
}
if (parser.detector_id() >= detPtr->getNumberOfDetectors()) {
std::cout << "position is out of bounds.\n";
os << "position is out of bounds.\n";
return;
}
// call multi detector command line
slsDetectorCommand myCmd(detPtr);
std::string answer = myCmd.executeLine(parser.n_arguments()+1, parser.argv().data(), action_, parser.detector_id());
// Call CmdProxy which execute the command if it exists, on success
// returns an empty string If the command is not in CmdProxy but
// deprecated the new command is returned
if (action_ != slsDetectorDefs::READOUT_ACTION) {
sls::CmdProxy<multiSlsDetector> proxy(detPtr);
auto cmd = proxy.Call(parser.command(), parser.arguments(),
parser.detector_id());
if (cmd.empty()) {
return;
} else {
parser.setCommand(cmd);
}
}
if (parser.multi_id()!=0)
std::cout << parser.multi_id() << '-';
// call multi detector command line
slsDetectorCommand myCmd(detPtr);
std::string answer =
myCmd.executeLine(parser.n_arguments() + 1, parser.argv().data(),
action_, parser.detector_id());
if (parser.multi_id() != 0)
os << parser.multi_id() << '-';
if (parser.detector_id() != -1)
std::cout << parser.detector_id() << ':';
os << parser.detector_id() << ':';
if (action_ != slsDetectorDefs::READOUT_ACTION) {
std::cout << parser.command() << " ";
os << parser.command() << " ";
}
std::cout << answer << std::endl;
os << answer << std::endl;
}
};

View File

@ -2,12 +2,11 @@
#include "ClientSocket.h"
#include "SharedMemory.h"
#include "error_defs.h"
#include "logger.h"
#include "sls_detector_defs.h"
#include "network_utils.h"
#include "FixedCapacityContainer.h"
class ClientInterface;
#include <cmath>
#include <vector>
@ -16,10 +15,9 @@ class ClientInterface;
class multiSlsDetector;
class ServerInterface;
class MySocketTCP;
#define SLS_SHMVERSION 0x190503
#define MAX_RX_DBIT 64
#define SLS_SHMVERSION 0x190515
/**
@ -243,11 +241,7 @@ struct sharedSlsDetector {
/** overwrite enable */
bool rxFileOverWrite;
/** receiver dbit size */
int rxDbitListSize;
/** receiver dbit list */
int rxDbitList[MAX_RX_DBIT];
sls::FixedCapacityContainer<int, MAX_RX_DBIT> rxDbitList;
/** reciever dbit offset */
int rxDbitOffset;
@ -736,6 +730,18 @@ class slsDetector : public virtual slsDetectorDefs{
*/
int configureMAC();
/**
* Set starting frame number for the next acquisition
* @param val starting frame number
*/
void setStartingFrameNumber(const uint64_t value);
/**
* Get starting frame number for the next acquisition
* @returns starting frame number
*/
uint64_t getStartingFrameNumber();
/**
* Set/get timer value (not all implemented for all detectors)
* @param index timer index
@ -1701,7 +1707,7 @@ class slsDetector : public virtual slsDetectorDefs{
* Gets the current frame index of receiver
* @returns current frame index of receiver
*/
int getReceiverCurrentFrameIndex();
uint64_t getReceiverCurrentFrameIndex();
/**
* Resets framescaught in receiver

View File

@ -29,14 +29,14 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
* @param action can be PUT_ACTION or GET_ACTION(from text client even READOUT_ACTION for acquisition)
* @param detPos -1 for all detectors in multi detector list or position of a specific detector in list
*/
std::string executeLine(int narg, char *args[], int action, int detPos = -1);
std::string executeLine(int narg, const char * const args[], int action, int detPos = -1);
/* /\** */
/* returns the help for the executeLine command */
/* \param os output stream to return the help to */
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* *\/ */
std::string helpLine(int narg, char *args[], int action=HELP_ACTION, int detPos = -1);
std::string helpLine(int narg, const char * const args[], int action=HELP_ACTION, int detPos = -1);
static std::string helpAcquire(int action);
static std::string helpData(int action);
static std::string helpStatus(int action);
@ -96,56 +96,56 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
multiSlsDetector *myDet;
std::string cmdUnderDevelopment(int narg, char *args[], int action, int detPos = -1);
std::string cmdUnknown(int narg, char *args[], int action, int detPos = -1);
std::string cmdAcquire(int narg, char *args[], int action, int detPos = -1);
std::string cmdData(int narg, char *args[], int action, int detPos = -1);
std::string cmdStatus(int narg, char *args[], int action, int detPos = -1);
std::string cmdDataStream(int narg, char *args[], int action, int detPos = -1);
std::string cmdFree(int narg, char *args[], int action, int detPos = -1);
std::string cmdHostname(int narg, char *args[], int action, int detPos = -1);
std::string cmdUser(int narg, char *args[], int action, int detPos = -1);
std::string cmdHelp(int narg, char *args[], int action, int detPos = -1);
std::string cmdExitServer(int narg, char *args[], int action, int detPos = -1);
std::string cmdSettingsDir(int narg, char *args[], int action, int detPos = -1);
std::string cmdTrimEn(int narg, char *args[], int action, int detPos = -1);
std::string cmdOutDir(int narg, char *args[], int action, int detPos = -1);
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
std::string cmdLastClient(int narg, char *args[], int action, int detPos = -1);
std::string cmdOnline(int narg, char *args[], int action, int detPos = -1);
std::string cmdConfigureMac(int narg, char *args[], int action, int detPos = -1);
std::string cmdDetectorSize(int narg, char *args[], int action, int detPos = -1);
std::string cmdSettings(int narg, char *args[], int action, int detPos = -1);
std::string cmdSN(int narg, char *args[], int action, int detPos = -1);
std::string cmdDigiTest(int narg, char *args[], int action, int detPos = -1);
std::string cmdRegister(int narg, char *args[], int action, int detPos = -1);
std::string cmdDAC(int narg, char *args[], int action, int detPos = -1);
std::string cmdTiming(int narg, char *args[], int action, int detPos = -1);
std::string cmdTimer(int narg, char *args[], int action, int detPos = -1);
std::string cmdTimeLeft(int narg, char *args[], int action, int detPos = -1);
std::string cmdSpeed(int narg, char *args[], int action, int detPos = -1);
std::string cmdAdvanced(int narg, char *args[], int action, int detPos = -1);
std::string cmdConfiguration(int narg, char *args[], int action, int detPos = -1);
std::string cmdImage(int narg, char *args[], int action, int detPos = -1);
std::string cmdCounter(int narg, char *args[], int action, int detPos = -1);
std::string cmdADC(int narg, char *args[], int action, int detPos = -1);
std::string cmdTempControl(int narg, char *args[], int action, int detPos = -1);
std::string cmdEnablefwrite(int narg, char *args[], int action, int detPos = -1);
std::string cmdOverwrite(int narg, char *args[], int action, int detPos = -1);
std::string cmdReceiver(int narg, char *args[], int action, int detPos = -1);
std::string cmdPattern(int narg, char *args[], int action, int detPos = -1);
std::string cmdPulse(int narg, char *args[], int action, int detPos = -1);
std::string cmdProcessor(int narg, char *args[], int action, int detPos = -1);
std::string cmdUnderDevelopment(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdUnknown(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdAcquire(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdData(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdStatus(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdDataStream(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdFree(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdHostname(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdUser(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdHelp(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdExitServer(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdSettingsDir(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdTrimEn(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdOutDir(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdFileName(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdFileIndex(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdRateCorr(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdNetworkParameter(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdPort(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdLock(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdLastClient(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdOnline(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdConfigureMac(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdDetectorSize(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdSettings(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdSN(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdDigiTest(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdRegister(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdDAC(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdTiming(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdTimer(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdTimeLeft(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdSpeed(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdAdvanced(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdImage(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdCounter(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdADC(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdTempControl(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdEnablefwrite(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdOverwrite(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdReceiver(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdPattern(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdPulse(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdProcessor(int narg, const char * const args[], int action, int detPos = -1);
int numberOfCommands;
std::string cmd;
typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action, int detPos);
typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, const char * const args[], int action, int detPos);
struct FuncTable

View File

@ -521,7 +521,7 @@ public:
int setHighVoltage(int i = -1, int detPos = -1);
/**
* Set 10GbE Flow Control (Eiger)
* Set 10GbE Flow Control (Eiger and Jungfrau)
* @param enable 1 to set, 0 to unset, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
* @returns 10GbE flow Control

View File

@ -12,8 +12,8 @@
#include "container_utils.h"
#include "string_utils.h"
#include "network_utils.h"
#include "string_utils.h"
#include <cstring>
#include <iomanip>
@ -421,7 +421,7 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) {
}
// get type by connecting
detectorType type = slsDetector::getTypeFromDetector(hostname.c_str(), DEFAULT_PORTNO);
detectorType type = slsDetector::getTypeFromDetector(hostname, DEFAULT_PORTNO);
int pos = (int)detectors.size();
detectors.push_back(sls::make_unique<slsDetector>(type, multiId, pos, false));
multi_shm()->numberOfDetectors = detectors.size();
@ -1071,6 +1071,34 @@ int multiSlsDetector::configureMAC(int detPos) {
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
void multiSlsDetector::setStartingFrameNumber(const uint64_t value, int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->setStartingFrameNumber(value);
}
// multi
parallelCall(&slsDetector::setStartingFrameNumber, value);
}
uint64_t multiSlsDetector::getStartingFrameNumber(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getStartingFrameNumber();
}
// multi
auto r = parallelCall(&slsDetector::getStartingFrameNumber);
if (sls::allEqual(r)) {
return r.front();
}
// can't have different values for next acquisition
std::ostringstream ss;
ss << "Error: Different Values for starting frame number";
throw RuntimeError(ss.str());
}
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
// single
if (detPos >= 0) {
@ -1113,89 +1141,50 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
return ret;
}
int64_t multiSlsDetector::secondsToNanoSeconds(double t){
int64_t ns = lround(t * 1E9);
return (ns < 0) ? -1: ns;
}
double multiSlsDetector::setExposureTime(double t, bool inseconds, int detPos) {
if (!inseconds) {
return setTimer(ACQUISITION_TIME, (int64_t)t, detPos);
}
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) {
tms = -1;
}
tms = setTimer(ACQUISITION_TIME, tms, detPos);
if (tms < 0) {
return -1;
}
return ((1E-9) * (double)tms);
auto t_ns = setTimer(ACQUISITION_TIME, secondsToNanoSeconds(t), detPos);
return (t_ns < 0) ? -1 : 1E-9 * t_ns;
}
double multiSlsDetector::setExposurePeriod(double t, bool inseconds, int detPos) {
if (!inseconds) {
return setTimer(FRAME_PERIOD, (int64_t)t, detPos);
}
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) {
tms = -1;
}
tms = setTimer(FRAME_PERIOD, tms, detPos);
if (tms < 0) {
return -1;
}
return ((1E-9) * (double)tms);
auto t_ns = setTimer(FRAME_PERIOD, secondsToNanoSeconds(t), detPos);
return (t_ns < 0) ? -1 : 1E-9 * t_ns;
}
double multiSlsDetector::setDelayAfterTrigger(double t, bool inseconds, int detPos) {
if (!inseconds) {
return setTimer(DELAY_AFTER_TRIGGER, (int64_t)t, detPos);
}
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) {
tms = -1;
}
tms = setTimer(DELAY_AFTER_TRIGGER, tms, detPos);
if (tms < 0) {
return -1;
}
return ((1E-9) * (double)tms);
auto t_ns = setTimer(DELAY_AFTER_TRIGGER, secondsToNanoSeconds(t), detPos);
return (t_ns < 0) ? -1 : 1E-9 * t_ns;
}
double multiSlsDetector::setSubFrameExposureTime(double t, bool inseconds, int detPos) {
if (!inseconds) {
return setTimer(SUBFRAME_ACQUISITION_TIME, (int64_t)t, detPos);
} else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) {
tms = -1;
}
tms = setTimer(SUBFRAME_ACQUISITION_TIME, tms, detPos);
if (tms < 0) {
return -1;
}
return ((1E-9) * (double)tms);
}
auto t_ns = setTimer(SUBFRAME_ACQUISITION_TIME, secondsToNanoSeconds(t), detPos);
return (t_ns < 0) ? -1 : 1E-9 * t_ns;
}
double multiSlsDetector::setSubFrameExposureDeadTime(double t, bool inseconds, int detPos) {
if (!inseconds) {
return setTimer(SUBFRAME_DEADTIME, (int64_t)t, detPos);
} else {
// + 0.5 to round for precision lost from converting double to int64_t
int64_t tms = (int64_t)(t * (1E+9) + 0.5);
if (t < 0) {
tms = -1;
}
tms = setTimer(SUBFRAME_DEADTIME, tms, detPos);
if (tms < 0) {
return -1;
}
return ((1E-9) * (double)tms);
}
auto t_ns = setTimer(SUBFRAME_DEADTIME, secondsToNanoSeconds(t), detPos);
return (t_ns < 0) ? -1 : 1E-9 * t_ns;
}
int64_t multiSlsDetector::setNumberOfFrames(int64_t t, int detPos) {
@ -3185,7 +3174,7 @@ int multiSlsDetector::getFramesCaughtByReceiver(int detPos) {
return ((sls::sum(r)) / (int)detectors.size());
}
int multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
uint64_t multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->getReceiverCurrentFrameIndex();
@ -3195,7 +3184,7 @@ int multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
auto r = parallelCall(&slsDetector::getReceiverCurrentFrameIndex);
// prevent divide by all or do not take avg when -1 for "did not connect"
if ((detectors.empty()) || (sls::anyEqualTo(r, -1))) {
if ((detectors.empty()) || (sls::anyEqualTo(r, static_cast<uint64_t>(-1)))) {
return -1;
}
@ -3390,7 +3379,10 @@ void multiSlsDetector::readFrameFromReceiver() {
uint32_t xoffset = coordX * nPixelsX * bytesPerPixel;
uint32_t yoffset = coordY * nPixelsY;
uint32_t singledetrowoffset = nPixelsX * bytesPerPixel;
uint32_t rowoffset = nX * singledetrowoffset;
uint32_t rowoffset = nX * singledetrowoffset;
if (getDetectorTypeAsEnum() == CHIPTESTBOARD) {
singledetrowoffset=size;
}
FILE_LOG(logDEBUG1) << "Multi Image Info:"
"\n\txoffset: "
<< xoffset << "\n\tyoffset: " << yoffset

View File

@ -1,8 +1,5 @@
#include "slsDetector.h"
#include "ClientInterface.h"
#include "ClientSocket.h"
#include "MySocketTCP.h"
#include "ServerInterface.h"
#include "SharedMemory.h"
#include "file_utils.h"
#include "multiSlsDetector.h"
@ -340,7 +337,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->detectorIP2 = DEFAULT_DET_MAC2;
shm()->numUDPInterfaces = 1;
shm()->selectedUDPInterface = 1;
shm()->selectedUDPInterface = 0;
shm()->rxOnlineFlag = OFFLINE_FLAG;
shm()->tenGigaEnable = 0;
shm()->flippedData[X] = 0;
@ -389,8 +386,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->rxFileWrite = true;
shm()->rxMasterFileWrite = true;
shm()->rxFileOverWrite = true;
shm()->rxDbitListSize = 0;
memset(shm()->rxDbitList, 0, MAX_RX_DBIT * sizeof(int));
shm()->rxDbitOffset = 0;
// get the detector parameters based on type
@ -1442,7 +1437,7 @@ int slsDetector::configureMAC() {
// 2d positions to detector to put into udp header
{
int pos[2] = {0, 0};
int max = shm()->multiSize[1] * (shm()->numUDPInterfaces);
int max = shm()->multiSize[Y] * (shm()->numUDPInterfaces);
// row
pos[0] = (detId % max);
// col for horiz. udp ports
@ -1502,6 +1497,23 @@ int slsDetector::configureMAC() {
return ret;
}
void slsDetector::setStartingFrameNumber(const uint64_t value) {
FILE_LOG(logDEBUG1) << "Setting starting frame number to " << value;
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_SET_STARTING_FRAME_NUMBER, value, nullptr);
}
}
uint64_t slsDetector::getStartingFrameNumber() {
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting starting frame number";
if (shm()->onlineFlag == ONLINE_FLAG) {
sendToDetector(F_GET_STARTING_FRAME_NUMBER, nullptr, retval);
FILE_LOG(logDEBUG1) << "Starting frame number :" << retval;
}
return retval;
}
int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
int ret = FAIL;
int64_t args[]{static_cast<int64_t>(index), t};
@ -1559,6 +1571,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
DIGITAL_SAMPLES,
STORAGE_CELL_NUMBER};
// if in list (lambda)
if (std::any_of(std::begin(rt), std::end(rt),
[index](timerIndex t) { return t == index; })) {
args[1] = shm()->timerValue[index];
@ -1907,7 +1920,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
<< "\nrx streaming source ip:" << shm()->rxZmqip
<< "\nrx additional json header:" << shm()->rxAdditionalJsonHeader
<< "\nrx_datastream:" << enableDataStreamingFromReceiver(-1)
<< "\nrx_dbitlistsize:" << shm()->rxDbitListSize
<< "\nrx_dbitlistsize:" << shm()->rxDbitList.size()
<< "\nrx_DbitOffset:" << shm()->rxDbitOffset
<< std::endl;
@ -1948,7 +1961,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
enableTenGigabitEthernet(shm()->tenGigaEnable);
setReadOutFlags(GET_READOUT_FLAGS);
break;
case CHIPTESTBOARD:
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
@ -1974,8 +1987,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
}
if (shm()->myDetectorType == CHIPTESTBOARD) {
std::vector<int> list(shm()->rxDbitList, shm()->rxDbitList + shm()->rxDbitListSize);
setReceiverDbitList(list);
setReceiverDbitList(shm()->rxDbitList);
}
setReceiverSilentMode(static_cast<int>(shm()->rxSilentMode));
@ -2097,7 +2109,7 @@ int slsDetector::selectUDPInterface(int n) {
if (shm()->myDetectorType != JUNGFRAU) {
throw RuntimeError("Cannot select an interface for this detector");
}
shm()->selectedUDPInterface = (n > 1 ? 2 : 1);
shm()->selectedUDPInterface = (n == 0 ? 0 : 1);
if (strcmp(shm()->rxHostname, "none") == 0) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) {
@ -2178,7 +2190,7 @@ void slsDetector::setReceiverStreamingIP(std::string sourceIP) {
memset(shm()->rxZmqip, 0, MAX_STR_LENGTH);
sls::strcpy_safe(shm()->rxZmqip, args);
// if zmqip is empty, update it
if (strlen(shm()->zmqip) != 0u) {
if (shm()->zmqip != 0u) {
sls::strcpy_safe(shm()->zmqip, args);
}
FILE_LOG(logDEBUG1) << "Sending receiver streaming IP to receiver: "
@ -2354,7 +2366,7 @@ int64_t slsDetector::getReceiverRealUDPSocketBufferSize() {
int slsDetector::setUDPConnection() {
int ret = FAIL;
char args[6][MAX_STR_LENGTH]{};
char args[5][MAX_STR_LENGTH]{};
char retvals[2][MAX_STR_LENGTH]{};
FILE_LOG(logDEBUG1) << "Setting UDP Connection";
@ -2371,9 +2383,8 @@ int slsDetector::setUDPConnection() {
shm()->rxUDPIP = HostnameToIp(shm()->rxHostname);
}
}
// jungfrau 2 interfaces or (1 interface and 2nd interface), copy udpip if
// udpip2 empty
if (shm()->numUDPInterfaces == 2 || shm()->selectedUDPInterface == 2) {
// jungfrau 2 interfaces, copy udpip if udpip2 empty
if (shm()->numUDPInterfaces == 2) {
if (shm()->rxUDPIP2 == 0) {
shm()->rxUDPIP2 = shm()->rxUDPIP;
}
@ -2381,15 +2392,12 @@ int slsDetector::setUDPConnection() {
// copy arguments to args[][]
snprintf(args[0], sizeof(args[0]), "%d", shm()->numUDPInterfaces);
snprintf(args[1], sizeof(args[1]), "%d", shm()->selectedUDPInterface);
sls::strcpy_safe(args[2], getReceiverUDPIP().str());
sls::strcpy_safe(args[3], getReceiverUDPIP2().str());
snprintf(args[4], sizeof(args[4]), "%d", shm()->rxUDPPort);
snprintf(args[5], sizeof(args[5]), "%d", shm()->rxUDPPort2);
sls::strcpy_safe(args[1], getReceiverUDPIP().str());
sls::strcpy_safe(args[2], getReceiverUDPIP2().str());
snprintf(args[3], sizeof(args[3]), "%d", shm()->rxUDPPort);
snprintf(args[4], sizeof(args[4]), "%d", shm()->rxUDPPort2);
FILE_LOG(logDEBUG1) << "Receiver Number of UDP Interfaces: "
<< shm()->numUDPInterfaces;
FILE_LOG(logDEBUG1) << "Receiver Selected Interface: "
<< shm()->selectedUDPInterface;
FILE_LOG(logDEBUG1) << "Receiver udp ip address: " << shm()->rxUDPIP;
FILE_LOG(logDEBUG1) << "Receiver udp ip address2: " << shm()->rxUDPIP2;
FILE_LOG(logDEBUG1) << "Receiver udp port: " << shm()->rxUDPPort;
@ -2731,51 +2739,20 @@ void slsDetector::setReceiverDbitList(std::vector<int> list) {
throw sls::RuntimeError("Dbit list value must be between 0 and 63\n");
}
}
// copy size and vector to shm
shm()->rxDbitListSize = list.size();
std::copy(list.begin(), list.end(), shm()->rxDbitList);
shm()->rxDbitList = list;
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
int args[list.size() + 1];
args[0] = list.size();
std::copy(std::begin(list), std::end(list), args + 1);
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, args, sizeof(args), nullptr, 0);
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, shm()->rxDbitList, nullptr);
}
}
std::vector<int> slsDetector::getReceiverDbitList() {
int fnum = F_GET_RECEIVER_DBIT_LIST;
int ret = FAIL;
std::vector <int> retval;
int retsize = 0;
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
FILE_LOG(logDEBUG1) << "Getting Receiver Dbit List";
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
auto receiver =
sls::ClientSocket("Receiver", shm()->rxHostname, shm()->rxTCPPort);
receiver.sendData(&fnum, sizeof(fnum));
receiver.receiveData(&ret, sizeof(ret));
if (ret == FAIL) {
char mess[MAX_STR_LENGTH]{};
receiver.receiveData(mess, MAX_STR_LENGTH);
throw ReceiverError("Receiver " + std::to_string(detId) +
" returned error: " + std::string(mess));
}
receiver.receiveData(&retsize, sizeof(retsize));
int list[retsize];
receiver.receiveData(list, sizeof(list));
// copy after no errors
shm()->rxDbitListSize = retsize;
std::copy(list, list + retsize, shm()->rxDbitList);
sendToReceiver(F_GET_RECEIVER_DBIT_LIST, nullptr, retval);
shm()->rxDbitList = retval;
}
if (shm()->rxDbitListSize) {
retval.resize(shm()->rxDbitListSize);
std::copy(shm()->rxDbitList, shm()->rxDbitList + shm()->rxDbitListSize, std::begin(retval));
}
return retval;
return shm()->rxDbitList;
}
int slsDetector::setReceiverDbitOffset(int value) {
@ -3256,10 +3233,10 @@ int slsDetector::setReceiverOnline(int value) {
} else {
shm()->rxOnlineFlag = OFFLINE_FLAG;
if (value == ONLINE_FLAG) {
// connect and set offline flag
auto receiver =
ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
receiver.close();
// Connect and ask for receiver id to verify that
// it's online and working
int64_t retval{0};
sendToReceiver(F_GET_RECEIVER_ID, nullptr, retval);
shm()->rxOnlineFlag = ONLINE_FLAG;
if (shm()->receiverAPIVersion == 0) {
checkReceiverVersionCompatibility();
@ -3422,15 +3399,11 @@ int slsDetector::updateCachedReceiverVariables() const {
n += receiver.receiveData(&i32, sizeof(i32));
shm()->rxSilentMode = static_cast<bool>(i32);
// dbit list size
// dbit list
{
int listsize = 0;
n += receiver.receiveData(&listsize, sizeof(listsize));
int list[listsize];
n += receiver.receiveData(list, sizeof(list));
// copy after no errors
shm()->rxDbitListSize = listsize;
std::copy(list, list + listsize, shm()->rxDbitList);
sls::FixedCapacityContainer<int, MAX_RX_DBIT> temp;
n += receiver.receiveData(&temp, sizeof(temp));
shm()->rxDbitList = temp;
}
// dbit offset
@ -3637,8 +3610,8 @@ int slsDetector::getFramesCaughtByReceiver() {
return retval;
}
int slsDetector::getReceiverCurrentFrameIndex() {
int retval = -1;
uint64_t slsDetector::getReceiverCurrentFrameIndex() {
uint64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
sendToReceiver(F_GET_RECEIVER_FRAME_INDEX, nullptr, retval);

View File

@ -3,6 +3,7 @@
#include "string_utils.h"
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <sstream>
@ -595,6 +596,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>startingfnum [i]</b> sets/gets starting frame number for the next acquisition. Only for Jungfrau and Eiger. \c Returns \c (long long int)
*/
descrToFuncMap[i].m_pFuncName = "startingfnum";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
++i;
/*! \page timing
- <b>cycles [i]</b> sets/gets number of triggers. Timing mode should be set appropriately. \c Returns \c (long long int)
*/
@ -675,19 +683,12 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page timing
- <b>delayl</b> gets delay left. Used in GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits)
- <b>delayl</b> gets delay left. Used in GOTTHARD, JUNGFRAU, MOENCH and CTB only. Only get! \c Returns \c (double with 9 decimal digits)
*/
descrToFuncMap[i].m_pFuncName = "delayl";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimeLeft;
++i;
/*! \page timing
- <b>gatesl</b> gets number of gates left. Used in GOTTHARD only. Only get! \c Returns \c (double with 9 decimal digits)
*/
descrToFuncMap[i].m_pFuncName = "gatesl";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimeLeft;
++i;
/*! \page config
- <b>framesl</b> gets number of frames left. Used in GOTTHARD and Jungfrau only. Only get! \c Returns \c (double with 9 decimal digits)
*/
@ -1587,7 +1588,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>rx_udpip2 [ip]</b> sets/gets the ip address of the second receiver UDP interface where the data from the bottom half module of the detector will be streamed to. Normally used for single detectors (Can be multi-detector). Used if different from eth0. JUNGFRAU only. \c Returns \c (string)
- <b>rx_udpip2 [ip]</b> sets/gets the ip address of the second receiver UDP interface where the data from the top half module of the detector will be streamed to. Normally used for single detectors (Can be multi-detector). Used if different from eth0. JUNGFRAU only. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "rx_udpip2";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -1601,7 +1602,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>rx_udpmac2 [mac]</b> sets/gets the mac address of the second receiver UDP interface where the data from the bottom half module of the detector will be streamed to. Normally used for single detectors (Can be multi-detector). JUNGFRAU only.\c Returns \c (string)
- <b>rx_udpmac2 [mac]</b> sets/gets the mac address of the second receiver UDP interface where the data from the top half module of the detector will be streamed to. Normally used for single detectors (Can be multi-detector). JUNGFRAU only.\c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "rx_udpmac2";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -1615,7 +1616,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>rx_udpport2 [port]</b> sets/gets the second port of the receiver UDP interface where the data from the second half of the detector will be streamed to. Use single-detector command. Used for EIGERand JUNGFRAU only. \c Returns \c (int)
- <b>rx_udpport2 [port]</b> sets/gets the second port of the receiver UDP interface where the data from the second half of the detector will be streamed to. Use single-detector command. For Eiger, it is the right half and for Jungfrau, it is the top half module. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "rx_udpport2";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -1643,35 +1644,35 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>detectormac2 [mac]</b> sets/gets the mac address of the second half of the detector UDP interface from where the bottom half module of the detector will stream data. Use single-detector command. Normally unused. JUNGFRAU only. \c Returns \c (string)
- <b>detectormac2 [mac]</b> sets/gets the mac address of the second half of the detector UDP interface from where the top half module of the detector will stream data. Use single-detector command. Normally unused. JUNGFRAU only. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "detectormac2";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>detectorip [ip]</b> sets/gets the ip address of the detector UDP interface from where the bottom half of the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip (if rx_udpip specified). \c Returns \c (string)
- <b>detectorip [ip]</b> sets/gets the ip address of the detector UDP interface from where the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip (if rx_udpip specified). \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "detectorip";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>detectorip2 [ip]</b> sets/gets the ip address of the second half of the detector UDP interface from where the bottom half of the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip2 (if rx_udpip2 specified). JUNGFRAU only. \c Returns \c (string)
- <b>detectorip2 [ip]</b> sets/gets the ip address of the top half of the detector UDP interface from where the top half of the detector will stream data. Use single-detector command. Keep in same subnet as rx_udpip2 (if rx_udpip2 specified). JUNGFRAU only. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "detectorip2";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>numinterfaces [n]</b> sets/gets the number of interfaces used to stream out from the detector. Options: 1, 2. JUNGFRAU only. \c Returns \c (int)
- <b>numinterfaces [n]</b> sets/gets the number of interfaces used to stream out from the detector. Options: 1(default), 2. JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "numinterfaces";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
++i;
/*! \page network
- <b>selinterface [n]</b> sets/gets the 1st or the 2nd interface to use to stream data out of the detector. Options: 1, 2. Effective only when \c numinterfaces is 1. JUNGFRAU only. \c Returns \c (int)
- <b>selinterface [n]</b> sets/gets interface to use to stream data out of the detector. Options: 0 (outer, default), 1(inner). Effective only when \c numinterfaces is 1. JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "selinterface";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -1699,7 +1700,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page network
- <b>flowcontrol_10g [delay]</b> Enables/disables 10 GbE flow control. 1 enables, 0 disables. Used for EIGER only. \c Returns \c (int)
- <b>flowcontrol_10g [delay]</b> Enables/disables 10 GbE flow control. 1 enables, 0 disables. Used for EIGER and JUNGFRAU only. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "flowcontrol_10g";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdNetworkParameter;
@ -2129,7 +2130,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
//-----------------------------------------------------------
std::string slsDetectorCommand::executeLine(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::executeLine(int narg, const char * const args[], int action, int detPos) {
if (action == READOUT_ACTION)
return cmdAcquire(narg, args, action, detPos);
@ -2160,14 +2161,14 @@ std::string slsDetectorCommand::executeLine(int narg, char *args[], int action,
return cmdUnknown(narg, args, action, detPos);
}
std::string slsDetectorCommand::cmdUnknown(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdUnknown(int narg, const char * const args[], int action, int detPos) {
return std::string("Unknown command ") + std::string(args[0]) + std::string("\n") + helpLine(0, args, action, detPos);
}
std::string slsDetectorCommand::cmdUnderDevelopment(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdUnderDevelopment(int narg, const char * const args[], int action, int detPos) {
return std::string("Must still develop ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
}
std::string slsDetectorCommand::helpLine(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::helpLine(int narg, const char * const args[], int action, int detPos) {
std::ostringstream os;
@ -2186,7 +2187,7 @@ std::string slsDetectorCommand::helpLine(int narg, char *args[], int action, int
return executeLine(narg, args, HELP_ACTION, detPos);
}
std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -2231,7 +2232,7 @@ std::string slsDetectorCommand::helpAcquire(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdData(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdData(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
@ -2263,7 +2264,7 @@ std::string slsDetectorCommand::helpData(int action) {
return std::string("data \t gets all data from the detector (if any) processes them and writes them to file according to the preferences already setup\n");
}
std::string slsDetectorCommand::cmdStatus(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdStatus(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
@ -2316,7 +2317,7 @@ std::string slsDetectorCommand::helpStatus(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdDataStream(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
@ -2350,7 +2351,7 @@ std::string slsDetectorCommand::helpDataStream(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdFree(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdFree(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
@ -2366,7 +2367,7 @@ std::string slsDetectorCommand::helpFree(int action) {
return std::string("free \t frees the shared memory\n");
}
std::string slsDetectorCommand::cmdHostname(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdHostname(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -2428,7 +2429,7 @@ std::string slsDetectorCommand::helpHostname(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdUser(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdUser(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -2458,7 +2459,7 @@ std::string slsDetectorCommand::helpUser(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdHelp(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdHelp(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -2471,7 +2472,7 @@ std::string slsDetectorCommand::cmdHelp(int narg, char *args[], int action, int
return helpLine(0, args, action, detPos);
}
std::string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdExitServer(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -2519,7 +2520,7 @@ std::string slsDetectorCommand::helpExitServer(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdSettingsDir(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdSettingsDir(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -2547,7 +2548,7 @@ std::string slsDetectorCommand::helpSettingsDir(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdTrimEn(int narg, const char * const args[], int action, int detPos) {
std::vector<int> energies;
if (action == HELP_ACTION)
return helpTrimEn(action);
@ -2578,7 +2579,7 @@ std::string slsDetectorCommand::helpTrimEn(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdOutDir(int narg, const char * const args[], int action, int detPos) {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == HELP_ACTION)
return helpOutDir(action);
@ -2598,7 +2599,7 @@ std::string slsDetectorCommand::helpOutDir(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdFileName(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdFileName(int narg, const char * const args[], int action, int detPos) {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == HELP_ACTION)
return helpFileName(action);
@ -2634,7 +2635,7 @@ std::string slsDetectorCommand::helpFileName(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdEnablefwrite(int narg, const char * const args[], int action, int detPos) {
int i;
char ans[100];
@ -2680,7 +2681,7 @@ std::string slsDetectorCommand::helpEnablefwrite(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdOverwrite(int narg, const char * const args[], int action, int detPos) {
int i;
char ans[100];
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
@ -2706,7 +2707,7 @@ std::string slsDetectorCommand::helpOverwrite(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdFileIndex(int narg, const char * const args[], int action, int detPos) {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == HELP_ACTION) {
return helpFileName(action);
@ -2726,7 +2727,7 @@ std::string slsDetectorCommand::helpFileIndex(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdRateCorr(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION) {
return helpRateCorr(action);
@ -2753,7 +2754,7 @@ std::string slsDetectorCommand::helpRateCorr(int action) {
return os.str();
}
// std::string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
// std::string slsDetectorCommand::cmdThreaded(int narg, const char * const args[], int action, int detPos){
// int ival;
// char answer[1000];
@ -2779,7 +2780,7 @@ std::string slsDetectorCommand::helpThreaded(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdImage(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdImage(int narg, const char * const args[], int action, int detPos) {
std::string sval;
int retval = FAIL;
if (action == HELP_ACTION)
@ -2814,7 +2815,7 @@ std::string slsDetectorCommand::helpImage(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdCounter(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdCounter(int narg, const char * const args[], int action, int detPos) {
int ival;
char answer[100];
std::string sval;
@ -2875,7 +2876,7 @@ std::string slsDetectorCommand::helpCounter(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdNetworkParameter(int narg, const char * const args[], int action, int detPos) {
char ans[100] = {0};
int i;
@ -2919,7 +2920,7 @@ std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int
if (action == PUT_ACTION) {
myDet->setReceiverUDPIP2(args[1], detPos);
}
return myDet->getReceiverUDPIP(detPos);
return myDet->getReceiverUDPIP2(detPos);
} else if (cmd == "rx_udpmac") {
if (action == PUT_ACTION) {
myDet->setReceiverUDPMAC(args[1], detPos);
@ -2929,7 +2930,7 @@ std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int
if (action == PUT_ACTION) {
myDet->setReceiverUDPMAC2(args[1], detPos);
}
return myDet->getReceiverUDPMAC(detPos);
return myDet->getReceiverUDPMAC2(detPos);
} else if (cmd == "rx_udpport") {
if (action == PUT_ACTION) {
if (!(sscanf(args[1], "%d", &i))) {
@ -3069,13 +3070,13 @@ std::string slsDetectorCommand::helpNetworkParameter(int action) {
os << "rx_udpmac mac \n sets receiver udp mac to mac" << std::endl;
os << "rx_udpmac2 mac \n sets receiver udp mac of 2nd udp interface to mac. Jungfrau only." << std::endl;
os << "rx_udpport port \n sets receiver udp port to port" << std::endl;
os << "rx_udpport2 port \n sets receiver udp port to port. For Eiger and Jungfrau, it is the second half module and for other detectors, same as rx_udpport" << std::endl;
os << "numinterfaces n \n sets the number of interfaces to n used to stream out from the detector. Options: 1, 2. JUNGFRAU only. " << std::endl;
os << "selinterface n \n sets the 1st or the 2nd interface to use to stream data out of the detector. Options: 1, 2. Effective only when numinterfaces is 1. JUNGFRAU only. " << std::endl;
os << "rx_udpport2 port \n sets receiver udp port to port. For Eiger, it is the right half and for Jungfrau, it is the top half module and for other detectors, same as rx_udpport" << std::endl;
os << "numinterfaces n \n sets the number of interfaces to n used to stream out from the detector. Options: 1 (default), 2. JUNGFRAU only. " << std::endl;
os << "selinterface n \n sets interface to use to stream data out of the detector. Options: 0 (outer, default), 1(inner). Effective only when numinterfaces is 1. JUNGFRAU only. " << std::endl;
os << "txndelay_left port \n sets detector transmission delay of the left port" << std::endl;
os << "txndelay_right port \n sets detector transmission delay of the right port" << std::endl;
os << "txndelay_frame port \n sets detector transmission delay of the entire frame" << std::endl;
os << "flowcontrol_10g port \n sets flow control for 10g for eiger" << std::endl;
os << "flowcontrol_10g port \n sets flow control for 10g for eiger and jungfrau" << std::endl;
os << "zmqport port \n sets the 0MQ (TCP) port of the client to where final data is streamed to (eg. for GUI). The default already connects with rx_zmqport for the GUI. "
"Use single-detector command to set individually or multi-detector command to calculate based on port for the rest."
"Must restart streaming in client with new port from gui/external gui"
@ -3109,13 +3110,13 @@ std::string slsDetectorCommand::helpNetworkParameter(int action) {
os << "rx_udpip \n gets receiver udp mac " << std::endl;
os << "rx_udpip2 \n gets receiver udp mac of 2nd udp interface. Jungfrau only" << std::endl;
os << "rx_udpport \n gets receiver udp port " << std::endl;
os << "rx_udpport2 \n gets receiver udp port of 2nd udp interface. For Eiger and Jungfrau, it is the second half module and for other detectors, same as rx_udpport" << std::endl;
os << "numinterfaces \n gets the number of interfaces to n used to stream out from the detector. Options: 1, 2. JUNGFRAU only. " << std::endl;
os << "selinterface \n gets the interface selected to use to stream data out of the detector. Options: 1, 2. Effective only when numinterfaces is 1. JUNGFRAU only. " << std::endl;
os << "rx_udpport2 \n gets receiver udp port of 2nd udp interface. For Eiger, it is the right half and for Jungfrau, it is the top half module and for other detectors, same as rx_udpport" << std::endl;
os << "numinterfaces \n gets the number of interfaces to n used to stream out from the detector. Options: 1 (default), 2. JUNGFRAU only. " << std::endl;
os << "selinterface \n gets interface to use to stream data out of the detector. Options: 0 (outer, default), 1(inner). Effective only when numinterfaces is 1. JUNGFRAU only. " << std::endl;
os << "txndelay_left \n gets detector transmission delay of the left port" << std::endl;
os << "txndelay_right \n gets detector transmission delay of the right port" << std::endl;
os << "txndelay_frame \n gets detector transmission delay of the entire frame" << std::endl;
os << "flowcontrol_10g \n gets flow control for 10g for eiger" << std::endl;
os << "flowcontrol_10g \n gets flow control for 10g for eiger and jungfrau" << std::endl;
os << "zmqport \n gets the 0MQ (TCP) port of the client to where final data is streamed to" << std::endl;
os << "rx_zmqport \n gets the 0MQ (TCP) port of the receiver from where data is streamed from" << std::endl;
os << "zmqip \n gets the 0MQ (TCP) ip of the client to where final data is streamed to.If no custom ip, empty until first time connect to receiver" << std::endl;
@ -3126,7 +3127,7 @@ std::string slsDetectorCommand::helpNetworkParameter(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdPort(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdPort(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpPort(action);
@ -3174,7 +3175,7 @@ std::string slsDetectorCommand::helpPort(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdLock(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdLock(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpLock(action);
@ -3225,7 +3226,7 @@ std::string slsDetectorCommand::helpLock(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdLastClient(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpLastClient(action);
@ -3256,7 +3257,7 @@ std::string slsDetectorCommand::helpLastClient(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdOnline(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION) {
return helpOnline(action);
@ -3340,7 +3341,7 @@ std::string slsDetectorCommand::helpOnline(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdConfigureMac(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION) {
return helpConfigureMac(action);
@ -3371,7 +3372,7 @@ std::string slsDetectorCommand::helpConfigureMac(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpDetectorSize(action);
@ -3439,7 +3440,7 @@ std::string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int acti
ret = myDet->setDynamicRange(val, detPos);
} else if (cmd == "roi") {
const ROI* r = myDet->getROI(ret, detPos);
if (r != NULL)
delete [] r;
} else if (cmd == "detsizechan") {
sprintf(ans, "%d %d", myDet->getMaxNumberOfChannelsPerDetector(X), myDet->getMaxNumberOfChannelsPerDetector(Y));
@ -3488,7 +3489,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdSettings(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpSettings(action);
@ -3606,7 +3607,7 @@ std::string slsDetectorCommand::helpSettings(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdSN(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int action, int detPos) {
char answer[1000];
@ -3699,7 +3700,7 @@ std::string slsDetectorCommand::helpSN(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdDigiTest(int narg, const char * const args[], int action, int detPos) {
char answer[1000];
@ -3750,7 +3751,7 @@ std::string slsDetectorCommand::helpDigiTest(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdRegister(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdRegister(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpRegister(action);
@ -3868,7 +3869,7 @@ std::string slsDetectorCommand::helpRegister(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdDAC(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdDAC(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpDAC(action);
@ -4214,7 +4215,7 @@ std::string slsDetectorCommand::helpDAC(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdADC(int narg, const char * const args[], int action, int detPos) {
dacIndex adc;
int idac;
@ -4341,7 +4342,7 @@ std::string slsDetectorCommand::helpADC(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdTempControl(int narg, const char * const args[], int action, int detPos) {
char answer[1000] = "";
int val = -1;
@ -4408,7 +4409,7 @@ std::string slsDetectorCommand::helpTempControl(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdTiming(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdTiming(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
@ -4434,7 +4435,7 @@ std::string slsDetectorCommand::helpTiming(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdTimer(int narg, const char * const args[], int action, int detPos) {
timerIndex index;
int64_t t = -1, ret;
double val, rval;
@ -4483,6 +4484,16 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int
}
sprintf(answer, "%d", myDet->setStoragecellStart(-1, detPos));
return std::string(answer);
} else if (cmd == "startingfnum") {
myDet->setOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) {
uint64_t ival = -1;
if (!sscanf(args[1], "%lu", &ival))
return std::string("cannot scan starting frame number value ") + std::string(args[1]);
myDet->setStartingFrameNumber(ival, detPos);
return std::string(args[1]);
}
return std::to_string(myDet->getStartingFrameNumber(detPos));
} else
return std::string("could not decode timer ") + cmd;
@ -4496,10 +4507,9 @@ std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int
if (index == ACQUISITION_TIME || index == SUBFRAME_ACQUISITION_TIME ||
index == FRAME_PERIOD || index == DELAY_AFTER_TRIGGER ||
index == SUBFRAME_DEADTIME || index == STORAGE_CELL_DELAY) {
// +0.5 for precision of eg.0.0000325
t = (val * 1E9 + 0.5);
t = lround(val * 1E9);
} else
t = (int64_t)val;
t = static_cast<int64_t>(val);
}
myDet->setOnline(ONLINE_FLAG, detPos);
@ -4535,6 +4545,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
os << "period t \t sets the frame period in s" << std::endl;
os << "delay t \t sets the delay after trigger in s" << std::endl;
os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "startingfnum t \t sets starting frame number for the next acquisition. Only for Jungfrau and Eiger." << std::endl;
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
os << "samples t \t sets the number of samples (both analog and digital) expected from the ctb" << std::endl;
os << "asamples t \t sets the number of analog samples expected from the ctb" << std::endl;
@ -4552,6 +4563,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
os << "period \t gets the frame period in s" << std::endl;
os << "delay \t gets the delay after trigger in s" << std::endl;
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "startingfnum \t gets starting frame number for the next acquisition. Only for Jungfrau and Eiger." << std::endl;
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
os << "samples \t gets the number of samples (both analog and digital) expected from the ctb" << std::endl;
os << "asamples \t gets the number of analog samples expected from the ctb" << std::endl;
@ -4565,7 +4577,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdTimeLeft(int narg, const char * const args[], int action, int detPos) {
timerIndex index;
int64_t ret;
double rval;
@ -4581,8 +4593,6 @@ std::string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action,
index = FRAME_PERIOD;
else if (cmd == "delayl")
index = DELAY_AFTER_TRIGGER;
else if (cmd == "gatesl")
index = GATES_NUMBER;
else if (cmd == "framesl")
index = FRAME_NUMBER;
else if (cmd == "cyclesl")
@ -4635,7 +4645,7 @@ std::string slsDetectorCommand::helpTimeLeft(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdSpeed(int narg, const char * const args[], int action, int detPos) {
speedVariable index;
int t = -1, ret = 0, mode = 0;
@ -4732,7 +4742,7 @@ std::string slsDetectorCommand::helpSpeed(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], int action, int detPos) {
char answer[1000] = "";
@ -4970,7 +4980,7 @@ std::string slsDetectorCommand::helpAdvanced(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdConfiguration(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpConfiguration(action);
@ -5040,7 +5050,7 @@ std::string slsDetectorCommand::helpConfiguration(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[], int action, int detPos) {
char answer[100];
int ival = -1;
@ -5087,7 +5097,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action,
if (action == PUT_ACTION)
return std::string("cannot put");
else {
sprintf(answer, "%d", myDet->getReceiverCurrentFrameIndex(detPos));
sprintf(answer, "%lu", myDet->getReceiverCurrentFrameIndex(detPos));
return std::string(answer);
}
} else if (cmd == "r_readfreq") {
@ -5288,7 +5298,7 @@ std::string slsDetectorCommand::helpPattern(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpPattern(action);
@ -5758,7 +5768,7 @@ std::string slsDetectorCommand::helpPulse(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdPulse(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdPulse(int narg, const char * const args[], int action, int detPos) {
int retval = FAIL;
if (action == HELP_ACTION)
@ -5820,7 +5830,7 @@ std::string slsDetectorCommand::helpProcessor(int action) {
return os.str();
}
std::string slsDetectorCommand::cmdProcessor(int narg, char *args[], int action, int detPos) {
std::string slsDetectorCommand::cmdProcessor(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpProcessor(action);

View File

@ -27,7 +27,5 @@ int main(int argc, char *argv[]) {
int action = slsDetectorDefs::HELP_ACTION;
#endif
// if (argc > 1)
// argv++;
multiSlsDetectorClient(argc, argv, action);
}

View File

@ -2,4 +2,5 @@ target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-SharedMemory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-multiSlsDetector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-multiSlsDetectorClient.cpp
)

View File

@ -0,0 +1,40 @@
#include "catch.hpp"
#include "multiSlsDetectorClient.h"
#include "sls_detector_defs.h"
#include <sstream>
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("rx_fifodepth", "[.cmd]") {
auto oss = std::ostringstream{};
multiSlsDetectorClient("rx_fifodepth 10", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_fifodepth 10\n");
oss = std::ostringstream{};
multiSlsDetectorClient("rx_fifodepth 100", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_fifodepth 100\n");
oss = std::ostringstream{};
multiSlsDetectorClient("rx_fifodepth", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_fifodepth 100\n");
oss = std::ostringstream{};
multiSlsDetectorClient("0:rx_fifodepth", GET, nullptr, oss);
REQUIRE(oss.str() == "0:rx_fifodepth 100\n");
}
TEST_CASE("frames", "[.cmd]"){
auto oss = std::ostringstream{};
multiSlsDetectorClient("frames 1000", PUT, nullptr, oss);
REQUIRE(oss.str() == "frames 1000\n");
oss = std::ostringstream{};
multiSlsDetectorClient("frames", GET, nullptr, oss);
REQUIRE(oss.str() == "frames 1000\n");
oss = std::ostringstream{};
multiSlsDetectorClient("frames 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "frames 1\n");
}