Merge pull request #121 from slsdetectorgroup/checkargs

Check args for sending to detector/receiver
This commit is contained in:
Dhanya Thattil
2020-07-27 15:49:19 +02:00
committed by GitHub
2 changed files with 443 additions and 370 deletions

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,7 @@ class Module : public virtual slsDetectorDefs {
Safe to call only if detector shm also deleted or its numberOfDetectors is
updated */
void freeSharedMemory();
bool isFixedPatternSharedMemoryCompatible();
bool isFixedPatternSharedMemoryCompatible() const;
std::string getHostname() const;
/** initialChecks is enable or disable initial compatibility checks and
@ -86,9 +86,9 @@ class Module : public virtual slsDetectorDefs {
users! */
void setHostname(const std::string &hostname, const bool initialChecks);
int64_t getFirmwareVersion();
int64_t getDetectorServerVersion();
int64_t getSerialNumber();
int64_t getFirmwareVersion() const;
int64_t getDetectorServerVersion() const;
int64_t getSerialNumber() const;
int64_t getReceiverSoftwareVersion() const;
static detectorType getTypeFromDetector(const std::string &hostname,
int cport = DEFAULT_PORTNO);
@ -98,10 +98,10 @@ class Module : public virtual slsDetectorDefs {
void updateNumberOfChannels();
slsDetectorDefs::xy getNumberOfChannels() const;
void updateNumberOfDetector(slsDetectorDefs::xy det);
detectorSettings getSettings();
detectorSettings getSettings() const;
void setSettings(detectorSettings isettings);
void loadSettingsFile(const std::string &fname);
int getAllTrimbits();
int getAllTrimbits() const;
void setAllTrimbits(int val);
/**************************************************
@ -109,45 +109,45 @@ class Module : public virtual slsDetectorDefs {
* Acquisition Parameters *
* *
* ************************************************/
int64_t getNumberOfFrames();
int64_t getNumberOfFrames() const;
void setNumberOfFrames(int64_t value);
int64_t getNumberOfTriggers();
int64_t getNumberOfTriggers() const;
void setNumberOfTriggers(int64_t value);
/** [Mythen3] gatIndex: 0-2, [Others]: -1 always */
int64_t getExptime(int gateIndex);
int64_t getExptime(int gateIndex) const;
/** [Mythen3] gatIndex: -1 for all, 0-2, [Others]: -1 always */
void setExptime(int gateIndex, int64_t value);
int64_t getPeriod();
int64_t getPeriod() const;
void setPeriod(int64_t value);
int64_t getDelayAfterTrigger();
int64_t getDelayAfterTrigger() const;
void setDelayAfterTrigger(int64_t value);
int64_t getNumberOfFramesLeft() const;
int64_t getNumberOfTriggersLeft() const;
int64_t getDelayAfterTriggerLeft() const;
int64_t getPeriodLeft() const;
int getDynamicRange();
int getDynamicRange() const;
void setDynamicRange(int n);
timingMode getTimingMode();
timingMode getTimingMode() const;
void setTimingMode(timingMode value);
int getClockDivider(int clkIndex);
int getClockDivider(int clkIndex) const;
void setClockDivider(int clkIndex, int value);
int getClockPhase(int clkIndex, bool inDegrees);
int getClockPhase(int clkIndex, bool inDegrees) const;
void setClockPhase(int clkIndex, int value, bool inDegrees);
int getMaxClockPhaseShift(int clkIndex);
int getClockFrequency(int clkIndex);
int getMaxClockPhaseShift(int clkIndex) const;
int getClockFrequency(int clkIndex) const;
void setClockFrequency(int clkIndex, int value);
int getDAC(dacIndex index, bool mV);
int getDAC(dacIndex index, bool mV) const;
void setDAC(int val, dacIndex index, bool mV);
bool getPowerChip();
bool getPowerChip() const;
void setPowerChip(bool on);
int getImageTestMode();
int getImageTestMode() const;
void setImageTestMode(const int value);
/* temperature in millidegrees */
int getADC(dacIndex index);
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex);
int getADC(dacIndex index) const;
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex) const;
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex,
int value);
externalSignalFlag getExternalSignalFlags(int signalIndex);
externalSignalFlag getExternalSignalFlags(int signalIndex) const;
void setExternalSignalFlags(int signalIndex, externalSignalFlag type);
/**************************************************
@ -165,53 +165,53 @@ class Module : public virtual slsDetectorDefs {
int getReceiverProgress() const;
int64_t getFramesCaughtByReceiver() const;
std::vector<uint64_t> getNumMissingPackets() const;
uint64_t getStartingFrameNumber();
uint64_t getStartingFrameNumber() const;
void setStartingFrameNumber(uint64_t value);
void sendSoftwareTrigger();
defs::scanParameters getScan();
defs::scanParameters getScan() const;
void setScan(const defs::scanParameters t);
std::string getScanErrorMessage();
std::string getScanErrorMessage() const;
/**************************************************
* *
* Network Configuration (Detector<->Receiver) *
* *
* ************************************************/
int getNumberofUDPInterfacesFromShm();
int getNumberofUDPInterfaces();
int getNumberofUDPInterfacesFromShm() const;
int getNumberofUDPInterfaces() const;
void setNumberofUDPInterfaces(int n);
int getSelectedUDPInterface();
int getSelectedUDPInterface() const;
void selectUDPInterface(int n);
sls::IpAddr getSourceUDPIP();
sls::IpAddr getSourceUDPIP() const;
void setSourceUDPIP(const sls::IpAddr ip);
sls::IpAddr getSourceUDPIP2();
sls::IpAddr getSourceUDPIP2() const;
void setSourceUDPIP2(const sls::IpAddr ip);
sls::MacAddr getSourceUDPMAC();
sls::MacAddr getSourceUDPMAC() const;
void setSourceUDPMAC(const sls::MacAddr mac);
sls::MacAddr getSourceUDPMAC2();
sls::MacAddr getSourceUDPMAC2() const;
void setSourceUDPMAC2(const sls::MacAddr mac);
sls::IpAddr getDestinationUDPIP();
sls::IpAddr getDestinationUDPIP() const;
void setDestinationUDPIP(const sls::IpAddr ip);
sls::IpAddr getDestinationUDPIP2();
sls::IpAddr getDestinationUDPIP2() const;
void setDestinationUDPIP2(const sls::IpAddr ip);
sls::MacAddr getDestinationUDPMAC();
sls::MacAddr getDestinationUDPMAC() const;
void setDestinationUDPMAC(const sls::MacAddr mac);
sls::MacAddr getDestinationUDPMAC2();
sls::MacAddr getDestinationUDPMAC2() const;
void setDestinationUDPMAC2(const sls::MacAddr mac);
int getDestinationUDPPort();
int getDestinationUDPPort() const;
void setDestinationUDPPort(int udpport);
int getDestinationUDPPort2();
int getDestinationUDPPort2() const;
void setDestinationUDPPort2(int udpport);
std::string printReceiverConfiguration();
bool getTenGiga();
bool getTenGiga() const;
void setTenGiga(bool value);
bool getTenGigaFlowControl();
bool getTenGigaFlowControl() const;
void setTenGigaFlowControl(bool enable);
int getTransmissionDelayFrame();
int getTransmissionDelayFrame() const;
void setTransmissionDelayFrame(int value);
int getTransmissionDelayLeft();
int getTransmissionDelayLeft() const;
void setTransmissionDelayLeft(int value);
int getTransmissionDelayRight();
int getTransmissionDelayRight() const;
void setTransmissionDelayRight(int value);
/**************************************************
@ -224,18 +224,18 @@ class Module : public virtual slsDetectorDefs {
void setReceiverHostname(const std::string &receiver);
int getReceiverPort() const;
int setReceiverPort(int port_number);
int getReceiverFifoDepth();
int getReceiverFifoDepth() const;
void setReceiverFifoDepth(int n_frames);
bool getReceiverSilentMode();
bool getReceiverSilentMode() const;
void setReceiverSilentMode(bool enable);
frameDiscardPolicy getReceiverFramesDiscardPolicy();
frameDiscardPolicy getReceiverFramesDiscardPolicy() const;
void setReceiverFramesDiscardPolicy(frameDiscardPolicy f);
bool getPartialFramesPadding();
bool getPartialFramesPadding() const;
void setPartialFramesPadding(bool padding);
int64_t getReceiverUDPSocketBufferSize() const;
int64_t getReceiverRealUDPSocketBufferSize() const;
void setReceiverUDPSocketBufferSize(int64_t udpsockbufsize);
bool getReceiverLock();
bool getReceiverLock() const;
void setReceiverLock(bool lock);
sls::IpAddr getReceiverLastClientIP() const;
std::array<pid_t, NUM_RX_THREAD_IDS> getReceiverThreadIds() const;
@ -245,22 +245,22 @@ class Module : public virtual slsDetectorDefs {
* File *
* *
* ************************************************/
fileFormat getFileFormat();
fileFormat getFileFormat() const;
void setFileFormat(fileFormat f);
std::string getFilePath();
std::string getFilePath() const;
void setFilePath(const std::string &path);
std::string getFileName();
std::string getFileName() const;
void setFileName(const std::string &fname);
int64_t getFileIndex();
int64_t getFileIndex() const;
void setFileIndex(int64_t file_index);
void incrementFileIndex();
bool getFileWrite();
bool getFileWrite() const;
void setFileWrite(bool value);
bool getMasterFileWrite();
bool getMasterFileWrite() const;
void setMasterFileWrite(bool value);
bool getFileOverWrite();
bool getFileOverWrite() const;
void setFileOverWrite(bool value);
int getFramesPerFile();
int getFramesPerFile() const;
/** 0 will set frames per file to unlimited */
void setFramesPerFile(int n_frames);
@ -269,22 +269,22 @@ class Module : public virtual slsDetectorDefs {
* ZMQ Streaming Parameters (Receiver<->Client)*
* *
* ************************************************/
bool getReceiverStreaming();
bool getReceiverStreaming() const;
void setReceiverStreaming(bool enable);
int getReceiverStreamingFrequency();
int getReceiverStreamingFrequency() const;
/** Option: nth frame streamed out, if 0, streamed out at a timer of 200 */
void setReceiverStreamingFrequency(int freq);
int getReceiverStreamingTimer();
int getReceiverStreamingTimer() const;
void setReceiverStreamingTimer(int time_in_ms = 200);
int getReceiverStreamingStartingFrame();
int getReceiverStreamingStartingFrame() const;
void setReceiverStreamingStartingFrame(int fnum);
int getReceiverStreamingPort();
int getReceiverStreamingPort() const;
void setReceiverStreamingPort(int port);
sls::IpAddr getReceiverStreamingIP();
sls::IpAddr getReceiverStreamingIP() const;
void setReceiverStreamingIP(const sls::IpAddr ip);
int getClientStreamingPort();
int getClientStreamingPort() const;
void setClientStreamingPort(int port);
sls::IpAddr getClientStreamingIP();
sls::IpAddr getClientStreamingIP() const;
void setClientStreamingIP(const sls::IpAddr ip);
/**************************************************
@ -292,42 +292,42 @@ class Module : public virtual slsDetectorDefs {
* Eiger Specific *
* *
* ************************************************/
int64_t getSubExptime();
int64_t getSubExptime() const;
void setSubExptime(int64_t value);
int64_t getSubDeadTime();
int64_t getSubDeadTime() const;
void setSubDeadTime(int64_t value);
int getThresholdEnergy();
int getThresholdEnergy() const;
void setThresholdEnergy(int e_eV, detectorSettings isettings,
bool trimbits);
std::string getSettingsDir();
std::string getSettingsDir() const;
std::string setSettingsDir(const std::string &dir);
bool getParallelMode();
bool getParallelMode() const;
void setParallelMode(const bool enable);
bool getOverFlowMode();
bool getOverFlowMode() const;
void setOverFlowMode(const bool enable);
bool getFlippedDataX();
bool getFlippedDataX() const;
void setFlippedDataX(bool value);
std::vector<int> getTrimEn();
std::vector<int> getTrimEn() const;
int setTrimEn(const std::vector<int> &energies = {});
int64_t getRateCorrection();
int64_t getRateCorrection() const;
void setDefaultRateCorrection();
void setRateCorrection(int64_t t = 0);
int getReadNLines();
int getReadNLines() const;
void setReadNLines(const int value);
bool getInterruptSubframe();
bool getInterruptSubframe() const;
void setInterruptSubframe(const bool enable);
int64_t getMeasuredPeriod() const;
int64_t getMeasuredSubFramePeriod() const;
bool getActivate();
bool getActivate() const;
void setActivate(const bool enable);
bool getDeactivatedRxrPaddingMode();
bool getDeactivatedRxrPaddingMode() const;
void setDeactivatedRxrPaddingMode(bool padding);
bool getCounterBit();
bool getCounterBit() const;
void setCounterBit(bool cb);
void pulsePixel(int n = 0, int x = 0, int y = 0);
void pulsePixelNMove(int n = 0, int x = 0, int y = 0);
void pulseChip(int n_pulses = 0);
bool getQuad();
bool getQuad() const;
void setQuad(const bool enable);
/**************************************************
@ -335,19 +335,19 @@ class Module : public virtual slsDetectorDefs {
* Jungfrau Specific *
* *
* ************************************************/
int getThresholdTemperature();
int getThresholdTemperature() const;
void setThresholdTemperature(int val);
bool getTemperatureControl();
bool getTemperatureControl() const;
void setTemperatureControl(bool val);
int getTemperatureEvent();
int getTemperatureEvent() const;
void resetTemperatureEvent();
bool getAutoComparatorDisableMode();
bool getAutoComparatorDisableMode() const;
void setAutoComparatorDisableMode(bool val);
int getNumberOfAdditionalStorageCells();
int getNumberOfAdditionalStorageCells() const;
void setNumberOfAdditionalStorageCells(int value);
int getStorageCellStart();
int getStorageCellStart() const;
void setStorageCellStart(int pos);
int64_t getStorageCellDelay();
int64_t getStorageCellDelay() const;
void setStorageCellDelay(int64_t value);
/**************************************************
@ -355,7 +355,7 @@ class Module : public virtual slsDetectorDefs {
* Gotthard Specific *
* *
* ************************************************/
slsDetectorDefs::ROI getROI();
slsDetectorDefs::ROI getROI() const;
void setROI(slsDetectorDefs::ROI arg);
void clearROI();
int64_t getExptimeLeft() const;
@ -365,33 +365,33 @@ class Module : public virtual slsDetectorDefs {
* Gotthard2 Specific *
* *
* ************************************************/
int64_t getNumberOfBursts();
int64_t getNumberOfBursts() const;
void setNumberOfBursts(int64_t value);
int64_t getBurstPeriod();
int64_t getBurstPeriod() const;
void setBurstPeriod(int64_t value);
std::array<int, 2> getInjectChannel();
std::array<int, 2> getInjectChannel() const;
void setInjectChannel(const int offsetChannel, const int incrementChannel);
std::vector<int> getVetoPhoton(const int chipIndex);
std::vector<int> getVetoPhoton(const int chipIndex) const;
void setVetoPhoton(const int chipIndex, const int numPhotons,
const int energy, const std::string &fname);
void setVetoReference(const int gainIndex, const int value);
void setVetoFile(const int chipIndex, const std::string &fname);
burstMode getBurstMode();
burstMode getBurstMode() const;
void setBurstMode(burstMode value);
bool getCDSGain();
bool getCDSGain() const;
void setCDSGain(bool value);
int getFilter();
int getFilter() const;
void setFilter(int value);
bool getCurrentSource();
bool getCurrentSource() const;
void setCurrentSource(bool value);
slsDetectorDefs::timingSourceType getTimingSource();
slsDetectorDefs::timingSourceType getTimingSource() const;
void setTimingSource(slsDetectorDefs::timingSourceType value);
bool getVeto();
bool getVeto() const;
void setVeto(bool enable);
int getADCConfiguration(const int chipIndex, const int adcIndex);
int getADCConfiguration(const int chipIndex, const int adcIndex) const;
void setADCConfiguration(const int chipIndex, const int adcIndex,
int value);
void getBadChannels(const std::string &fname);
void getBadChannels(const std::string &fname) const;
void setBadChannels(const std::string &fname);
/**************************************************
@ -399,27 +399,27 @@ class Module : public virtual slsDetectorDefs {
* Mythen3 Specific *
* *
* ************************************************/
uint32_t getCounterMask();
uint32_t getCounterMask() const;
void setCounterMask(uint32_t countermask);
int getNumberOfGates();
int getNumberOfGates() const;
void setNumberOfGates(int value);
std::array<time::ns, 3> getExptimeForAllGates();
int64_t getGateDelay(int gateIndex);
std::array<time::ns, 3> getExptimeForAllGates() const;
int64_t getGateDelay(int gateIndex) const;
void setGateDelay(int gateIndex, int64_t value);
std::array<time::ns, 3> getGateDelayForAllGates();
std::array<time::ns, 3> getGateDelayForAllGates() const;
/**************************************************
* *
* CTB / Moench Specific *
* *
* ************************************************/
int getNumberOfAnalogSamples();
int getNumberOfAnalogSamples() const;
void setNumberOfAnalogSamples(int value);
int getPipeline(int clkIndex);
int getPipeline(int clkIndex) const;
void setPipeline(int clkIndex, int value);
uint32_t getADCEnableMask();
uint32_t getADCEnableMask() const;
void setADCEnableMask(uint32_t mask);
uint32_t getTenGigaADCEnableMask();
uint32_t getTenGigaADCEnableMask() const;
void setTenGigaADCEnableMask(uint32_t mask);
/**************************************************
@ -427,20 +427,20 @@ class Module : public virtual slsDetectorDefs {
* CTB Specific *
* *
* ************************************************/
int getNumberOfDigitalSamples();
int getNumberOfDigitalSamples() const;
void setNumberOfDigitalSamples(int value);
readoutMode getReadoutMode();
readoutMode getReadoutMode() const;
void setReadoutMode(const readoutMode mode);
int getExternalSamplingSource();
int setExternalSamplingSource(int value);
bool getExternalSampling();
bool getExternalSampling() const;
void setExternalSampling(bool value);
std::vector<int> getReceiverDbitList() const;
void setReceiverDbitList(const std::vector<int> &list);
int getReceiverDbitOffset();
int getReceiverDbitOffset() const;
void setReceiverDbitOffset(int value);
void setDigitalIODelay(uint64_t pinMask, int delay);
bool getLEDEnable();
bool getLEDEnable() const;
void setLEDEnable(bool enable);
/**************************************************
@ -449,21 +449,21 @@ class Module : public virtual slsDetectorDefs {
* *
* ************************************************/
void setPattern(const std::string &fname);
uint64_t getPatternIOControl();
uint64_t getPatternIOControl() const;
void setPatternIOControl(uint64_t word);
uint64_t getPatternWord(int addr);
uint64_t getPatternWord(int addr) const;
void setPatternWord(int addr, uint64_t word);
std::array<int, 2> getPatternLoopAddresses(int level);
std::array<int, 2> getPatternLoopAddresses(int level) const;
void setPatternLoopAddresses(int level, int start, int stop);
int getPatternLoopCycles(int level);
int getPatternLoopCycles(int level) const;
void setPatternLoopCycles(int level, int n);
int getPatternWaitAddr(int level);
int getPatternWaitAddr(int level) const;
void setPatternWaitAddr(int level, int addr);
uint64_t getPatternWaitTime(int level);
uint64_t getPatternWaitTime(int level) const;
void setPatternWaitTime(int level, uint64_t t);
uint64_t getPatternMask();
uint64_t getPatternMask() const;
void setPatternMask(uint64_t mask);
uint64_t getPatternBitMask();
uint64_t getPatternBitMask() const;
void setPatternBitMask(uint64_t mask);
void startPattern();
@ -472,10 +472,10 @@ class Module : public virtual slsDetectorDefs {
* Moench *
* *
* ************************************************/
std::map<std::string, std::string> getAdditionalJsonHeader();
std::map<std::string, std::string> getAdditionalJsonHeader() const;
void setAdditionalJsonHeader(
const std::map<std::string, std::string> &jsonHeader);
std::string getAdditionalJsonParameter(const std::string &key);
std::string getAdditionalJsonParameter(const std::string &key) const;
void setAdditionalJsonParameter(const std::string &key,
const std::string &value);
@ -489,14 +489,14 @@ class Module : public virtual slsDetectorDefs {
void copyDetectorServer(const std::string &fname,
const std::string &hostname);
void rebootController();
uint32_t readRegister(uint32_t addr);
uint32_t readRegister(uint32_t addr) const;
uint32_t writeRegister(uint32_t addr, uint32_t val);
uint32_t setBit(uint32_t addr, int n);
uint32_t clearBit(uint32_t addr, int n);
void executeFirmwareTest();
void executeBusTest();
void writeAdcRegister(uint32_t addr, uint32_t val);
uint32_t getADCInvert();
uint32_t getADCInvert() const;
void setADCInvert(uint32_t value);
/**************************************************
@ -508,9 +508,9 @@ class Module : public virtual slsDetectorDefs {
int setControlPort(int port_number);
int getStopPort() const;
int setStopPort(int port_number);
bool getLockDetector();
bool getLockDetector() const;
void setLockDetector(bool lock);
sls::IpAddr getLastClientIP();
sls::IpAddr getLastClientIP() const;
std::string execCommand(const std::string &cmd);
int64_t getNumberOfFramesFromStart() const;
int64_t getActualTime() const;
@ -518,6 +518,9 @@ class Module : public virtual slsDetectorDefs {
uint64_t getReceiverCurrentFrameIndex() const;
private:
void checkArgs(const void *args, size_t args_size, void *retval,
size_t retval_size) const;
/**
* Send function parameters to detector (control server)
* @param fnum function enum
@ -529,19 +532,39 @@ class Module : public virtual slsDetectorDefs {
void sendToDetector(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
void sendToDetector(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size) const;
template <typename Arg, typename Ret>
void sendToDetector(int fnum, const Arg &args, Ret &retval);
template <typename Arg, typename Ret>
void sendToDetector(int fnum, const Arg &args, Ret &retval) const;
template <typename Arg>
void sendToDetector(int fnum, const Arg &args, std::nullptr_t);
template <typename Arg>
void sendToDetector(int fnum, const Arg &args, std::nullptr_t) const;
template <typename Ret>
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
template <typename Ret>
void sendToDetector(int fnum, std::nullptr_t, Ret &retval) const;
void sendToDetector(int fnum);
void sendToDetector(int fnum) const;
template <typename Ret> Ret sendToDetector(int fnum);
template <typename Ret> Ret sendToDetector(int fnum) const;
template <typename Ret, typename Arg>
Ret sendToDetector(int fnum, const Arg &args);
template <typename Ret, typename Arg>
Ret sendToDetector(int fnum, const Arg &args) const;
/** Send function parameters to detector (stop server) */
void sendToDetectorStop(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);
@ -578,6 +601,9 @@ class Module : public virtual slsDetectorDefs {
template <typename Ret, typename Arg>
Ret sendToDetectorStop(int fnum, const Arg &args);
template <typename Ret, typename Arg>
Ret sendToDetectorStop(int fnum, const Arg &args) const;
/** Send function parameters to receiver */
void sendToReceiver(int fnum, const void *args, size_t args_size,
void *retval, size_t retval_size);