* WIP

* WIP

* WIP

* cleaned up multi

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* split up python module

* WIP

* WIP

* WIP

* WIP

* WIP

* ok

* fixed bugs from rebase

* WIP

* fixed broken test

* WIP

* fixed python

* WIP

* sphinx help

* including new commands

* docs

* WIP

* WIP

* more tests

* added missing public header

* WIP
This commit is contained in:
Dhanya Thattil
2019-08-07 11:21:07 +02:00
committed by GitHub
parent 98ddf154b2
commit 4ceee97c03
58 changed files with 2317 additions and 571 deletions

View File

@ -0,0 +1,127 @@
#pragma once
#include "Result.h"
#include "sls_detector_defs.h"
#include <chrono>
#include <memory>
#include <vector>
class multiSlsDetector;
namespace sls {
using ns = std::chrono::nanoseconds;
using Positions = const std::vector<int> &;
using defs = slsDetectorDefs;
/**
* \class Detector
*/
class Detector {
std::unique_ptr<multiSlsDetector> pimpl;
public:
/**
* @param multi_id multi detector shared memory id
*/
Detector(int multi_id = 0);
~Detector();
// Acquisition
/**
* Blocking call, starts the receiver and detector. Acquired
* the number of frames set.
*/
void acquire();
void startReceiver(Positions pos = {});
void stopReceiver(Positions pos = {});
/**
* Get the acquiring flag. When true the detector blocks
* any attempt to start a new acquisition.
*/
bool getAcquiringFlag() const;
/**
* Set the acquiring flag. This might have to done manually
* after an acquisition was aborted.
*/
void setAcquiringFlag(bool value);
/** Read back the run status of the receiver */
Result<defs::runStatus> getReceiverStatus(Positions pos = {});
// Configuration
/**
* Frees the shared memory of this detector and all modules
* belonging to it.
*/
void freeSharedMemory();
void setConfig(const std::string &fname);
Result<std::string> getHostname(Positions pos = {}) const;
// void setHostname(Positions pos = {});
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
void setStartingFrameNumber(uint64_t value, Positions pos);
// Bits and registers
/**
* Clears (sets to 0) bit number bitnr in register at addr.
* @param addr address of the register
* @param bitnr bit number to clear
* @param pos detector position
*/
void clearBit(uint32_t addr, int bitnr, Positions pos = {});
/**
* Sets bit number bitnr in register at addr to 1
* @param addr address of the register
* @param bitnr bit number to clear
* @param pos detector position
*/
void setBit(uint32_t addr, int bitnr, Positions pos = {});
/**
* Reads 32 bit register from detector
* @param addr address of the register
* @returns value read from register
*/
Result<uint32_t> getRegister(uint32_t addr, Positions pos = {});
/**************************************************
* *
* FILE, anything concerning file writing or *
* reading goes here *
* *
* ************************************************/
/**
* Returns receiver file name prefix. The actual file name
* contains module id and file index as well.
* @param pos detector positions
* @returns file name prefix
*/
Result<std::string> getFileName() const;
/**
* Sets the receiver file name prefix
* @param fname file name prefix
*/
void setFileName(const std::string &fname);
Result<std::string> getFilePath() const;
void setFilePath(const std::string &fname);
Result<bool> getFileWrite(Positions pos = {}) const;
void setFileWrite(bool value, Positions pos = {});
Result<bool> getFileOverWrite(Positions pos = {}) const;
void setFileOverWrite(bool value, Positions pos = {});
// Time
Result<ns> getExptime(Positions pos = {}) const;
void setExptime(ns t, Positions pos = {});
Result<ns> getSubExptime(Positions pos = {}) const;
void setSubExptime(ns t, Positions pos = {});
Result<ns> getPeriod(Positions pos = {}) const;
void setPeriod(ns t, Positions pos = {});
};
} // namespace sls

View File

@ -0,0 +1,99 @@
#pragma once
/**
* \file Result.h
* Result is a thin wrapper around std::vector and used for returning values
* from the detector. Since every module could have a different value, we need
* to return a vector instead of just a single value.
*
* Easy conversions to single values are provided using the squash method.
*/
#include <algorithm>
#include <iostream>
#include <vector>
#include "ToString.h"
#include "container_utils.h"
namespace sls {
/**
* @tparam T type to store in the result
* @tparam Allocator for the underlying vector, default
*/
template <class T, class Allocator = std::allocator<T>> class Result {
/** wrapped vector */
std::vector<T, Allocator> vec;
public:
Result() = default;
Result(std::initializer_list<T> list) : vec(list){};
/**
* Forward arguments to the constructor of std::vector
* @tparam Args template paramter pack to forward
*/
template <typename... Args>
Result(Args &&... args) : vec(std::forward<Args>(args)...) {}
using value_type = typename std::vector<T>::value_type;
using iterator = typename std::vector<T>::iterator;
using const_iterator = typename std::vector<T>::const_iterator;
using size_type = typename std::vector<T>::size_type;
using reference = typename std::vector<T>::reference;
using const_reference = typename std::vector<T>::const_reference;
auto begin() noexcept -> decltype(vec.begin()) { return vec.begin(); }
auto begin() const noexcept -> decltype(vec.begin()) { return vec.begin(); }
auto cbegin() const noexcept -> decltype(vec.cbegin()) {
return vec.cbegin();
}
auto end() noexcept -> decltype(vec.end()) { return vec.end(); }
auto end() const noexcept -> decltype(vec.end()) { return vec.end(); }
auto cend() const noexcept -> decltype(vec.cend()) { return vec.cend(); }
auto size() const noexcept -> decltype(vec.size()) { return vec.size(); }
auto empty() const noexcept -> decltype(vec.empty()) { return vec.empty(); }
auto front() -> decltype(vec.front()) { return vec.front(); }
auto front() const -> decltype(vec.front()) { return vec.front(); }
template <typename V>
auto push_back(V value) -> decltype(vec.push_back(value)) {
vec.push_back(std::forward<V>(value));
}
auto operator[](size_type pos) -> decltype(vec[pos]) { return vec[pos]; }
const_reference operator[](size_type pos) const { return vec[pos]; }
/**
* If all elements are equal it returns the front value
* otherwise a default constructed T
*/
T squash() const { return Squash(vec); }
/**
* If all elements are equal return the front value, otherwise
* return the supplied default value
*/
T squash(T default_value) const { return Squash(vec, default_value); }
/** Test whether all elements of the result are equal */
bool equal() const noexcept { return allEqual(vec); }
/** Convert Result<T> to std::vector<T> */
operator std::vector<T>() { return vec; }
/** Convert Result<T> to T using squash() */
operator T() { return squash(); }
};
/**
* operator << overload to print Result, uses ToString for the conversion
* @tparam T type stored in the Result
*/
template <typename T>
std::ostream &operator<<(std::ostream &os, const Result<T> &res) {
return os << ToString(res);
}
} // namespace sls

View File

@ -4,7 +4,6 @@
#include "logger.h"
#include "sls_detector_defs.h"
class slsDetector;
class ZmqSocket;
class detectorData;
@ -20,14 +19,17 @@ class detectorData;
#define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30
#include <future>
#include <numeric>
/**
* @short structure allocated in shared memory to store detector settings
* for IPC and cache
*/
* @short structure allocated in shared memory to store detector settings
* for IPC and cache
*/
struct sharedMultiSlsDetector {
/* FIXED PATTERN FOR STATIC FUNCTIONS. DO NOT CHANGE, ONLY APPEND
* ------*/
* ------*/
/** shared memory version */
int shmversion;
@ -45,7 +47,7 @@ struct sharedMultiSlsDetector {
int numberOfDetectors;
/** END OF FIXED PATTERN
* -----------------------------------------------*/
* -----------------------------------------------*/
/** Number of detectors operated at once */
int numberOfDetector[2];
@ -72,11 +74,11 @@ struct sharedMultiSlsDetector {
int maxNumberOfChannel[2];
/** max number of channels including gap pixels for all detectors in
* one dimension*/
* one dimension*/
int maxNumberOfChannelInclGapPixels[2];
/** max number of channels allowed for the complete set of detectors in
* one dimension */
* one dimension */
int maxNumberOfChannelsPerDetector[2];
/** timer values */
@ -98,8 +100,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* one
* @param update true to update last user pid, date etc
*/
explicit multiSlsDetector(int multi_id = 0,
bool verify = true,
explicit multiSlsDetector(int multi_id = 0, bool verify = true,
bool update = true);
/**
@ -107,6 +108,101 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
virtual ~multiSlsDetector();
template <class CT> struct NonDeduced { using type = CT; };
template <typename RT, typename... CT>
std::vector<RT> Parallel(RT (slsDetector::*somefunc)(CT...),
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) {
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
std::vector<std::future<RT>> futures;
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= detectors.size())
throw sls::RuntimeError("Detector out of range");
futures.push_back(std::async(std::launch::async, somefunc,
detectors[i].get(), Args...));
}
std::vector<RT> result;
result.reserve(positions.size());
for (auto &i : futures) {
result.push_back(i.get());
}
return result;
}
template <typename RT, typename... CT>
std::vector<RT> Parallel(RT (slsDetector::*somefunc)(CT...) const,
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const{
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
std::vector<std::future<RT>> futures;
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= detectors.size())
throw sls::RuntimeError("Detector out of range");
futures.push_back(std::async(std::launch::async, somefunc,
detectors[i].get(), Args...));
}
std::vector<RT> result;
result.reserve(positions.size());
for (auto &i : futures) {
result.push_back(i.get());
}
return result;
}
template <typename... CT>
void Parallel(void (slsDetector::*somefunc)(CT...),
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) {
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
std::vector<std::future<void>> futures;
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= detectors.size())
throw sls::RuntimeError("Detector out of range");
futures.push_back(std::async(std::launch::async, somefunc,
detectors[i].get(), Args...));
}
for (auto &i : futures) {
i.get();
}
}
template <typename... CT>
void Parallel(void (slsDetector::*somefunc)(CT...) const,
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const{
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
std::vector<std::future<void>> futures;
futures.reserve(positions.size());
for (size_t i : positions) {
if (i >= detectors.size())
throw sls::RuntimeError("Detector out of range");
futures.push_back(std::async(std::launch::async, somefunc,
detectors[i].get(), Args...));
}
for (auto &i : futures) {
i.get();
}
}
/**
* Creates/open shared memory, initializes detector structure and members
* Called by constructor/ set hostname / read config file
@ -114,14 +210,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* one
* @param update true to update last user pid, date etc
*/
void setupMultiDetector(bool verify = true,
bool update = true);
void setupMultiDetector(bool verify = true, bool update = true);
/**
* Loop through the detectors serially and return the result as a vector
*/
template <class CT>
struct NonDeduced { using type = CT; };
template <typename RT, typename... CT>
std::vector<RT> serialCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args);
@ -149,13 +243,13 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::vector<RT> parallelCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const;
template <typename... CT>
void parallelCall(void (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args);
template <typename... CT>
void parallelCall(void (slsDetector::*somefunc)(CT...), typename NonDeduced<CT>::type... Args);
template <typename... CT>
void parallelCall(void (slsDetector::*somefunc)(CT...) const, typename NonDeduced<CT>::type... Args) const;
void parallelCall(void (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const;
/**
* Decodes which detector and the corresponding channel numbers for it
@ -210,22 +304,24 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int64_t getId(idMode mode, int detPos = -1);
/**
* Get Client Software version
* @returns client software version
*/
int getMultiId()const{return multiId;}
/**
* Get Client Software version
* @returns client software version
*/
int64_t getClientSoftwareVersion() const;
/**
* Get Receiver software version
* @return receiver software version
*/
/**
* Get Receiver software version
* @return receiver software version
*/
int64_t getReceiverSoftwareVersion(int detPos = -1);
/**
* Get Detector Number
* @returns vector of detector number
*/
/**
* Get Detector Number
* @returns vector of detector number
*/
std::vector<int64_t> getDetectorNumber();
/**
* Free shared memory from the command line
@ -621,7 +717,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
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
@ -761,7 +857,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns value of speed set
*/
int setSpeed(speedVariable index, int value = -1, int mode = 0, int detPos = -1);
int setSpeed(speedVariable index, int value = -1, int mode = 0,
int detPos = -1);
/**
* Set/get dynamic range and updates the number of dataBytes
@ -780,9 +877,9 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int getDataBytes(int detPos = -1);
/**
/**
* Returns the number of detectors in the multi structure*/
size_t size() const{ return detectors.size();}
size_t size() const { return detectors.size(); }
/**
* Set/get dacs value
@ -898,12 +995,14 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::string getDetectorMAC(int detPos = -1);
/**
* Validates the format of the detector MAC address (bottom half) and sets it (Jungfrau only)
* Validates the format of the detector MAC address (bottom half) and sets
* it (Jungfrau only)
* @param detectorMAC detector MAC address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector MAC address (bottom half)
*/
std::string setDetectorMAC2(const std::string &detectorMAC, int detPos = -1);
std::string setDetectorMAC2(const std::string &detectorMAC,
int detPos = -1);
/**
* Returns the detector MAC address (bottom half) Jungfrau only
@ -928,7 +1027,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::string getDetectorIP(int detPos = -1) const;
/**
* Validates the format of the detector IP address (bottom half) and sets it (Jungfrau only)
* Validates the format of the detector IP address (bottom half) and sets it
* (Jungfrau only)
* @param detectorIP detector IP address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the detector IP address (bottom half)
@ -944,13 +1044,15 @@ class multiSlsDetector : public virtual slsDetectorDefs {
/**
* Validates and sets the receiver.
* Also updates the receiver with all the shared memory parameters significant for the receiver
* Also configures the detector to the receiver as UDP destination
* Also updates the receiver with all the shared memory parameters
* significant for the receiver Also configures the detector to the receiver
* as UDP destination
* @param receiver receiver hostname or IP address
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver IP address from shared memory
*/
std::string setReceiverHostname(const std::string &receiver, int detPos = -1);
std::string setReceiverHostname(const std::string &receiver,
int detPos = -1);
/**
* Returns the receiver IP address
@ -975,7 +1077,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::string getReceiverUDPIP(int detPos = -1) const;
/**
* Validates the format of the receiver UDP IP address (bottom half) and sets it(Jungfrau only)
* Validates the format of the receiver UDP IP address (bottom half) and
* sets it(Jungfrau only)
* @param udpip receiver UDP IP address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP IP address (bottom half)
@ -1005,7 +1108,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::string getReceiverUDPMAC(int detPos = -1) const;
/**
* Validates the format of the receiver UDP MAC address (bottom half) and sets it (Jungfrau only)
* Validates the format of the receiver UDP MAC address (bottom half) and
* sets it (Jungfrau only)
* @param udpmac receiver UDP MAC address (bottom half)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP MAC address (bottom half)
@ -1043,14 +1147,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int setReceiverUDPPort2(int udpport, int detPos = -1);
/**
* Returns the receiver UDP port 2 of same interface (Eiger and Jungfrau only)
* Returns the receiver UDP port 2 of same interface (Eiger and Jungfrau
* only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver UDP port 2 of same interface
*/
int getReceiverUDPPort2(int detPos = -1) const;
/**
* Sets the number of UDP interfaces to stream data from detector (Jungfrau only)
* Sets the number of UDP interfaces to stream data from detector (Jungfrau
* only)
* @param n number of interfaces. Options 1 or 2.
* @param detPos -1 for all detectors in list or specific detector position
* @returns the number of interfaces
@ -1058,14 +1164,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int setNumberofUDPInterfaces(int n, int detPos = -1);
/**
* Returns the number of UDP interfaces to stream data from detector (Jungfrau only)
* Returns the number of UDP interfaces to stream data from detector
* (Jungfrau only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the number of interfaces
*/
int getNumberofUDPInterfaces(int detPos = -1) const;
/**
* Selects the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only)
* Selects the UDP interfaces to stream data from detector. Effective only
* when number of interfaces is 1. (Jungfrau only)
* @param n selected interface. Options 1 or 2.
* @param detPos -1 for all detectors in list or specific detector position
* @returns the interface selected
@ -1073,7 +1181,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int selectUDPInterface(int n, int detPos = -1);
/**
* Returns the UDP interfaces to stream data from detector. Effective only when number of interfaces is 1. (Jungfrau only)
* Returns the UDP interfaces to stream data from detector. Effective only
* when number of interfaces is 1. (Jungfrau only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the interface selected
*/
@ -1090,11 +1199,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void setClientDataStreamingInPort(int i = -1, int detPos = -1);
/**
* Returns the client zmq port
* If detPos is -1(multi module), port returns client streaming port of first module
* Returns the client zmq port
* If detPos is -1(multi module), port returns client streaming port of
* first module
* @param detPos -1 for all detectors in list or specific detector position
* @returns the client zmq port
*/
* @returns the client zmq port
*/
int getClientStreamingPort(int detPos = -1);
/**
@ -1108,11 +1218,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void setReceiverDataStreamingOutPort(int i = -1, int detPos = -1);
/**
* Returns the receiver zmq port
* If detPos is -1(multi module), port returns receiver streaming port of first module
* Returns the receiver zmq port
* If detPos is -1(multi module), port returns receiver streaming port of
* first module
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver zmq port
*/
* @returns the receiver zmq port
*/
int getReceiverStreamingPort(int detPos = -1);
/**
@ -1126,11 +1237,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int detPos = -1);
/**
* Returns the client zmq ip
* If detPos is -1(multi module), ip returns concatenation of all client streaming ip
* Returns the client zmq ip
* If detPos is -1(multi module), ip returns concatenation of all client
* streaming ip
* @param detPos -1 for all detectors in list or specific detector position
* @returns the client zmq ip
*/
* @returns the client zmq ip
*/
std::string getClientStreamingIP(int detPos = -1);
/**
@ -1144,11 +1256,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int detPos = -1);
/**
* Returns the receiver zmq ip
* If detPos is -1(multi module), ip returns concatenation of all receiver streaming ip
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver zmq ip
*/
* Returns the receiver zmq ip
* If detPos is -1(multi module), ip returns concatenation of all receiver
* streaming ip
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver zmq ip
*/
std::string getReceiverStreamingIP(int detPos = -1);
/**
@ -1159,7 +1272,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns transmission delay
*/
int setDetectorNetworkParameter(networkParameter index, int delay, int detPos = -1);
int setDetectorNetworkParameter(networkParameter index, int delay,
int detPos = -1);
/**
* Sets the additional json header
@ -1167,7 +1281,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns additional json header, default is empty
*/
std::string setAdditionalJsonHeader(const std::string &jsonheader, int detPos = -1);
std::string setAdditionalJsonHeader(const std::string &jsonheader,
int detPos = -1);
/**
* Returns the additional json header
@ -1177,14 +1292,17 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::string getAdditionalJsonHeader(int detPos = -1);
/**
* Sets the value for the additional json header parameter if found, else append it
* Sets the value for the additional json header parameter if found, else
* append it
* @param key additional json header parameter
* @param value additional json header parameter value (cannot be empty)
* @param detPos -1 for all detectors in list or specific detector position
* @returns the additional json header parameter value,
* empty if no parameter found in additional json header
*/
std::string setAdditionalJsonParameter(const std::string &key, const std::string &value, int detPos = -1);
std::string setAdditionalJsonParameter(const std::string &key,
const std::string &value,
int detPos = -1);
/**
* Returns the additional json header parameter value
@ -1193,21 +1311,26 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @returns the additional json header parameter value,
* empty if no parameter found in additional json header
*/
std::string getAdditionalJsonParameter(const std::string &key, int detPos = -1);
std::string getAdditionalJsonParameter(const std::string &key,
int detPos = -1);
/**
* Sets the detector minimum/maximum energy threshold in processor (for Moench only)
* Sets the detector minimum/maximum energy threshold in processor (for
* Moench only)
* @param index 0 for emin, antyhing else for emax
* @param v value to set (-1 gets)
* @returns detector minimum/maximum energy threshold (-1 for not found or error in computing json parameter value)
* @returns detector minimum/maximum energy threshold (-1 for not found or
* error in computing json parameter value)
*/
int setDetectorMinMaxEnergyThreshold(const int index, int value, int detPos = -1);
int setDetectorMinMaxEnergyThreshold(const int index, int value,
int detPos = -1);
/**
* Sets the frame mode in processor (Moench only)
* @param value frameModeType (-1 gets)
* @param detPos -1 for all detectors in list or specific detector position
* @returns frame mode (-1 for not found or error in computing json parameter value)
* @returns frame mode (-1 for not found or error in computing json
* parameter value)
*/
int setFrameMode(frameModeType value, int detPos = -1);
@ -1215,7 +1338,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* Sets the detector mode in processor (Moench only)
* @param value detectorModetype (-1 gets)
* @param detPos -1 for all detectors in list or specific detector position
* @returns detector mode (-1 for not found or error in computing json parameter value)
* @returns detector mode (-1 for not found or error in computing json
* parameter value)
*/
int setDetectorMode(detectorModeType value, int detPos = -1);
@ -1225,7 +1349,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns receiver udp socket buffer size
*/
int64_t setReceiverUDPSocketBufferSize(int64_t udpsockbufsize = -1, int detPos = -1);
int64_t setReceiverUDPSocketBufferSize(int64_t udpsockbufsize = -1,
int detPos = -1);
/**
* Returns the receiver UDP socket buffer size
@ -1324,77 +1449,77 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
void setADCEnableMask(uint32_t mask, int detPos = -1);
/**
/**
* Get ADC Enable Mask (CTB, Moench)
* @param detPos -1 for all detectors in list or specific detector position
* @returns ADC Enable mask
*/
uint32_t getADCEnableMask(int detPos = -1);
/**
/**
* Set ADC invert register (CTB, Moench)
* @param value ADC invert value
* @param detPos -1 for all detectors in list or specific detector position
*/
void setADCInvert(uint32_t value, int detPos = -1);
/**
/**
* Get ADC invert register (CTB, Moench)
* @param detPos -1 for all detectors in list or specific detector position
* @returns ADC invert value
*/
uint32_t getADCInvert(int detPos = -1);
/**
/**
* Set external sampling source (CTB only)
* @param value external sampling source (Option: 0-63)
* @param detPos -1 for all detectors in list or specific detector position
*/
void setExternalSamplingSource(int value, int detPos = -1);
/**
/**
* Get external sampling source (CTB only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling source
*/
int getExternalSamplingSource(int detPos = -1);
/**
/**
* Set external sampling enable (CTB only)
* @param value external sampling source (Option: 0-63)
* @param detPos -1 for all detectors in list or specific detector position
*/
void setExternalSampling(bool value, int detPos = -1);
/**
/**
* Get external sampling source (CTB only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling enable
*/
int getExternalSampling(int detPos = -1);
/**
/**
* Set external sampling enable (CTB only)
* @param list external sampling source (Option: 0-63)
* @param detPos -1 for all detectors in list or specific detector position
*/
void setReceiverDbitList(std::vector<int> list, int detPos = -1);
/**
/**
* Get external sampling source (CTB only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns external sampling enable
*/
std::vector<int> getReceiverDbitList(int detPos = -1);
/**
/**
* Set digital data offset in bytes (CTB only)
* @param value digital data offset in bytes
* @param detPos -1 for all detectors in list or specific detector position
*/
void setReceiverDbitOffset(int value, int detPos = -1);
/**
/**
* Get digital data offset in bytes (CTB only)
* @param detPos -1 for all detectors in list or specific detector position
* @returns digital data offset in bytes
@ -1565,7 +1690,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void rebootController(int detPos = -1);
/**
* Updates the firmware, detector server and then reboots detector controller blackfin. (Not Eiger)
* Updates the firmware, detector server and then reboots detector
* controller blackfin. (Not Eiger)
* @param sname name of detector server binary
* @param hostname name of pc to tftp from
* @param fname programming file name
@ -1589,7 +1715,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int setAutoComparatorDisableMode(int ival = -1, int detPos = -1);
/**
* Set Rate correction ( Eiger)
* @param t dead time in ns - if 0 disable correction,
@ -1600,17 +1725,17 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void setRateCorrection(int64_t t = 0, int detPos = -1);
/**
* Get rate correction ( Eiger)
* @param detPos -1 for all detectors in list or specific detector position
* @returns 0 if rate correction disabled, > 0 otherwise (ns)
*/
* Get rate correction ( Eiger)
* @param detPos -1 for all detectors in list or specific detector position
* @returns 0 if rate correction disabled, > 0 otherwise (ns)
*/
int64_t getRateCorrection(int detPos = -1);
/**
* Prints receiver configuration
* @param level print level
* @param detPos -1 for all detectors in list or specific detector position
*/
* Prints receiver configuration
* @param level print level
* @param detPos -1 for all detectors in list or specific detector position
*/
void printReceiverConfiguration(TLogLevel level = logINFO, int detPos = -1);
/**
@ -1824,8 +1949,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @returns file write enable
*/
int getFileWrite(int detPos = -1) const;
/**
/**
* Sets/Gets receiver master file write enable
* @param value 1 or 0 to set/reset master file write enable
* @param detPos -1 for all detectors in list or specific detector position
@ -1923,26 +2048,27 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
int setPattern(const std::string &fname, int detPos = -1);
/**
* Sets pattern IO control (CTB/ Moench)
* @param word 64bit word to be written, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setPatternIOControl(uint64_t word = -1, int detPos = -1);
/**
* Sets pattern IO control (CTB/ Moench)
* @param word 64bit word to be written, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setPatternIOControl(uint64_t word = -1, int detPos = -1);
/**
* Sets pattern clock control (CTB/ Moench)
* @param word 64bit word to be written, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setPatternClockControl(uint64_t word = -1, int detPos = -1);
/**
* Sets pattern clock control (CTB/ Moench)
* @param word 64bit word to be written, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setPatternClockControl(uint64_t word = -1, int detPos = -1);
/**
* Writes a pattern word (CTB/ Moench)
* @param addr address of the word
* @param word 64bit word to be written, -1 reads the addr (same as executing the pattern)
* @param word 64bit word to be written, -1 reads the addr (same as
* executing the pattern)
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
@ -1956,15 +2082,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param n number of loops for level 0-2, -1 gets
* @param detPos -1 for all detectors in list or specific detector position
*/
void setPatternLoops(int level, int start = -1, int stop = -1, int n = -1, int detPos = -1);
void setPatternLoops(int level, int start = -1, int stop = -1, int n = -1,
int detPos = -1);
/**
* Gets the pattern loop limits (CTB/ Moench)
* @param level -1 complete pattern, 0,1,2, loop level
* @param detPos -1 for all detectors in list or specific detector position
* @returns array of start address, stop address and number of loops
*/
std::array<int, 3> getPatternLoops(int level, int detPos = -1);
/**
* Gets the pattern loop limits (CTB/ Moench)
* @param level -1 complete pattern, 0,1,2, loop level
* @param detPos -1 for all detectors in list or specific detector position
* @returns array of start address, stop address and number of loops
*/
std::array<int, 3> getPatternLoops(int level, int detPos = -1);
/**
* Sets the wait address (CTB/ Moench)
@ -1999,14 +2126,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
uint64_t getPatternMask(int detPos = -1);
/**
* Selects the bits that the mask will be applied to for every pattern (CTB/ Moench)
* Selects the bits that the mask will be applied to for every pattern (CTB/
* Moench)
* @param mask mask to select bits
* @param detPos -1 for all detectors in list or specific detector position
*/
void setPatternBitMask(uint64_t mask, int detPos = -1);
/**
* Gets the bits that the mask will be applied to for every pattern (CTB/ Moench)
* Gets the bits that the mask will be applied to for every pattern (CTB/
* Moench)
* @param detPos -1 for all detectors in list or specific detector position
* @returns mask of bits selected
*/
@ -2132,16 +2261,14 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
void addSlsDetector(const std::string &hostname);
/**
* 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)
@ -2197,14 +2324,13 @@ 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);
/**
* 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};
@ -2260,4 +2386,3 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void (*dataReady)(detectorData *, uint64_t, uint32_t, void *){nullptr};
void *pCallbackArg{nullptr};
};

View File

@ -4,6 +4,7 @@
#include "CmdLineParser.h"
#include "CmdProxy.h"
#include "Detector.h"
#include "container_utils.h"
#include "multiSlsDetector.h"
#include "slsDetectorCommand.h"
@ -109,7 +110,12 @@ class multiSlsDetectorClient {
// 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);
int multi_id = 0;
if (detPtr != nullptr)
multi_id = detPtr->getMultiId();
sls::Detector d(multi_id);
sls::CmdProxy<sls::Detector> proxy(&d);
// sls::CmdProxy<multiSlsDetector> proxy(detPtr);
auto cmd = proxy.Call(parser.command(), parser.arguments(),
parser.detector_id(), action_);
if (cmd.empty()) {

View File

@ -629,7 +629,7 @@ class slsDetector : public virtual slsDetectorDefs {
* Set starting frame number for the next acquisition
* @param val starting frame number
*/
void setStartingFrameNumber(const uint64_t value);
void setStartingFrameNumber(uint64_t value);
/**
* Get starting frame number for the next acquisition