merge resolved

This commit is contained in:
2019-08-08 14:55:36 +02:00
3 changed files with 355 additions and 119 deletions

View File

@ -254,38 +254,151 @@ class Detector {
// Erik
/** CTB only.Sets the mask applied to every pattern. */
Result<int> getFramesCaughtByReceiver(Positions pos = {}) const;
Result<uint64_t> getReceiverCurrentFrameIndex(Positions pos = {}) const;
void resetFramesCaught(Positions pos = {});
//TODO!
// int createReceivingDataSockets(const bool destroy = false);
// void readFrameFromReceiver();
void setMasterFileWrite(bool value, Positions pos = {});
Result<bool> getMasterFileWrite(Positions pos = {}) const;
void setReceiverStreamingFrequency(int freq = -1, int detPos = -1);
/**
* [All] If receiver streaming frequency is 0, then this timer between each
* data stream is set. Default is 500 ms.
*/
void setReceiverStreamingTimer(int time_in_ms = 500, Positions pos = {});
/** [All] */
Result<int> getReceiverStreamingTimer(Positions pos = {}) const;
// TODO!
// int enableDataStreamingToClient(int enable = -1);
// int enableDataStreamingFromReceiver(int enable = -1, int detPos = -1)
/** [TODO! All?] */
void setTenGigaEnabled(bool value, Positions pos = {});
/** [TODO! All?] */
Result<bool> getTenGigaEnabled(Positions pos = {}) const;
/** [All] */
void setReceiverFifoDepth(int nframes, Positions pos = {});
/** [All] */
Result<int> getReceiverFifoDepth(Positions pos = {}) const;
/** [All] */
void setReceiverSilentMode(bool value, Positions pos = {});
/** [All] */
Result<bool> getReceiverSilentMode(Positions pos = {}) const;
/** [CTB] */
void setPattern(const std::string &fname, Positions pos = {});
/** [CTB] */
void setPatternIOControl(uint64_t word, Positions pos = {});
/** [CTB] */
Result<uint64_t> getPatternIOControl(Positions pos = {}) const;
/** [CTB] */
void setPatternClockControl(uint64_t word, Positions pos = {});
/** [CTB] */
Result<uint64_t> getPatternClockControl(Positions pos = {}) const;
/**
* [CTB] Writes a pattern word
* @param addr address of the word
* @param word word to be written, -1 reads the addr (same as
* executing the pattern)
* @param pos detector position
* @returns actual value
*/
void setPatternWord(int addr, uint64_t word, Positions pos = {});
// TODO! Does this have side effects?
// uint64_t getPatternWord()...
/**
* [CTB] Sets the pattern or loop limits.
* @param level -1 complete pattern, 0,1,2, loop level
* @param start start address for level 0-2
* @param stop stop address for level 0-2
* @param n number of loops for level 0-2
* @param detPos -1 for all detectors in list or specific detector position
*/
void setPatternLoops(int level, int start, int stop, int n,
Positions pos = {});
/**
* [CTB] Gets the pattern loop limits
* @param level -1 complete pattern, 0,1,2, loop level
* @param pos detector positions
* @returns array of start address, stop address and number of loops
*/
Result<std::array<int, 3>> getPatternLoops(int level,
Positions pos = {}) const;
/**
* [CTB] Sets the wait address
* @param level 0,1,2, wait level
* @param addr wait address
* @param pos detector position
* @returns actual value
*/
void setPatternWaitAddr(int level, int addr, Positions pos = {});
/* [CTB] */
Result<int> getPatternWaitAddr(int level, Positions pos = {}) const;
/**
* [CTB] Sets the wait time
* @param level 0,1,2, wait level
* @param t wait time
* @param pos detector position
*/
void setPatternWaitTime(int level, uint64_t t, Positions pos = {});
/** [CTB] */
Result<uint64_t> getPatternWaitTime(int level, Positions pos = {}) const;
/** [CTB] Sets the mask applied to every pattern. */
void setPatternMask(uint64_t mask, Positions pos = {});
/** CTB only. Gets the mask applied to every pattern. */
/** [CTB] Gets the mask applied to every pattern. */
Result<uint64_t> getPatternMask(Positions pos = {});
/**
* CTB only. Sets the bitmask that the mask will be applied to for every
* [CTB] Sets the bitmask that the mask will be applied to for every
* pattern.
* @param mask mask to select bits
*/
void setPatternBitMask(uint64_t mask, Positions pos = {});
/**
* CTB only. Gets the bits that the mask will be applied to for every
* [CTB] Gets the bits that the mask will be applied to for every
* pattern
*/
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
/**
* CTB only. Enable or disable the LED
* @param enable true to switch on, false to switch off
*/
/** [CTB] Enable or disable the LED */
void setLEDEnable(bool enable, Positions pos = {});
/**
* CTB only. Get LED enable.
*/
/** [CTB] Get LED enable. */
Result<bool> getLEDEnable(Positions pos = {}) const;
/**
* CTB only. Set Digital IO Delay
* [CTB] Set Digital IO Delay
* @param digital IO mask to select the pins
* @param delay delay in ps(1 bit=25ps, max of 775 ps)
*/

View File

@ -20,7 +20,6 @@ class detectorData;
#define SHORT_STRING_LENGTH 50
#define DATE_LENGTH 30
#include <future>
#include <numeric>
/**
@ -118,7 +117,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) {
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
@ -143,7 +143,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const {
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
@ -168,7 +169,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) {
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
@ -190,7 +192,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::vector<int> positions,
typename NonDeduced<CT>::type... Args) const {
if (positions.empty() || (positions.size() == 1 && positions[0] == -1 )) {
if (positions.empty() ||
(positions.size() == 1 && positions[0] == -1)) {
positions.resize(detectors.size());
std::iota(begin(positions), end(positions), 0);
}
@ -280,7 +283,9 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns Id or version number of that type
*/
int64_t getId(idMode mode, int detPos = -1);//not needed anymore (later remove this_software_version from enum)
int64_t getId(idMode mode,
int detPos = -1); // not needed anymore (later remove
// this_software_version from enum)
int getMultiId() const { return multiId; } // part of multi also
@ -300,14 +305,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* Get Detector Number
* @returns vector of detector number
*/
std::vector<int64_t> getDetectorNumber(); // renamed to getDetectorSerialNumber
std::vector<int64_t>
getDetectorNumber(); // renamed to getDetectorSerialNumber
/**
* Free shared memory from the command line
* avoiding creating the constructor classes and mapping
* @param multiId multi detector Id
* @param detPos -1 for all detectors in list or specific detector position
*/
static void freeSharedMemory(int multiId, int detPos = -1);// private or not needed
static void freeSharedMemory(int multiId,
int detPos = -1); // private or not needed
/**
* Free shared memory and delete shared memory structure
@ -325,10 +332,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
std::string getUserDetails(); // part of multi
/**
* Sets the hostname of all sls detectors in shared memory and updates local cache
* Sets the hostname of all sls detectors in shared memory and updates local
* cache
* @param name hostname of all the sls detectors
*/
void setHostname(const std::vector<std::string> &name);//cannot set individually
void setHostname(
const std::vector<std::string> &name); // cannot set individually
/**
* Sets the hostname of all sls detectors in shared memory
@ -347,6 +356,14 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
std::string getHostname(int detPos = -1) const; //
/**
* Appends detectors to the end of the list in shared memory
* Connects to them
* @param name concatenated hostname of the sls detectors to be appended to
* the list
*/
void addMultipleDetectors(const char *name); // ????
/**
* Get Detector type as an enum
* @returns detector type
@ -863,7 +880,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* adcphase for Gotthard, others for CTB & Moench)
* @param value (clkdivider 0,1,2 for full, half and quarter speed). Other
* values check manual
* @param mode 0 for shift, 1 for degrees. relevant only for speed type adcphase and dbit phase
* @param mode 0 for shift, 1 for degrees. relevant only for speed type
* adcphase and dbit phase
* @param detPos -1 for all detectors in list or specific detector position
* @returns value of speed set
*/
@ -1691,7 +1709,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param hostname name of pc to tftp from
* @param detPos -1 for all detectors in list or specific detector position
*/
void copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos = -1);
void copyDetectorServer(const std::string &fname,
const std::string &hostname, int detPos = -1);
/**
* Reboot detector controller (Not Eiger)
@ -1707,7 +1726,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param fname programming file name
* @param detPos -1 for all detectors in list or specific detector position
*/
void update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos = -1);
void update(const std::string &sname, const std::string &hostname,
const std::string &fname, int detPos = -1);
/**
* Power on/off Chip (Jungfrau)
@ -1881,18 +1901,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
/**
* Get File index
* @param detPos -1 for all detectors in list or specific detector position
* @param detPos -1 for all detectors in list or specific detector
* position
* @returns file index
*/
int getFileIndex(int detPos = -1) const;
/**
* increments file index
* @param detPos -1 for all detectors in list or specific detector position
* @returns the file index
*/
int incrementFileIndex(int detPos = -1);
/**
* Receiver starts listening to packets
* @param detPos -1 for all detectors in list or specific detector position
@ -1917,21 +1931,21 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns number of frames caught by receiver
*/
int getFramesCaughtByReceiver(int detPos = -1);
int getFramesCaughtByReceiver(int detPos = -1); //
/**
* Gets the current frame index of receiver
* @param detPos -1 for all detectors in list or specific detector position
* @returns average of all current frame index of receiver
*/
uint64_t getReceiverCurrentFrameIndex(int detPos = -1);
uint64_t getReceiverCurrentFrameIndex(int detPos = -1); //
/**
* Resets framescaught in receiver
* Use this when using startAcquisition instead of acquire
* @param detPos -1 for all detectors in list or specific detector position
*/
void resetFramesCaught(int detPos = -1);
void resetFramesCaught(int detPos = -1); //
/**
* Create Receiving Data Sockets
@ -1966,14 +1980,14 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns master file write enable
*/
int setMasterFileWrite(bool value, int detPos = -1);
int setMasterFileWrite(bool value, int detPos = -1); //
/**
* Gets master file write enable
* @param detPos -1 for all detectors in list or specific detector position
* @returns master file write enable
*/
int getMasterFileWrite(int detPos = -1) const;
int getMasterFileWrite(int detPos = -1) const; //
/**
* Sets/Gets file overwrite enable
@ -2009,7 +2023,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns receiver streaming timer in ms
*/
int setReceiverStreamingTimer(int time_in_ms = 500, int detPos = -1);
int setReceiverStreamingTimer(int time_in_ms = 500, int detPos = -1); //
/**
* Enable data streaming to client
@ -2032,7 +2046,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns if 10Gbe is enabled
*/
int enableTenGigabitEthernet(int i = -1, int detPos = -1);
int enableTenGigabitEthernet(int i = -1, int detPos = -1); //
/**
* Set/get receiver fifo depth
@ -2040,7 +2054,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver fifo depth
*/
int setReceiverFifoDepth(int i = -1, int detPos = -1);
int setReceiverFifoDepth(int i = -1, int detPos = -1); //
/**
* Set/get receiver silent mode
@ -2048,7 +2062,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns the receiver silent mode enable
*/
int setReceiverSilentMode(int i = -1, int detPos = -1);
int setReceiverSilentMode(int i = -1, int detPos = -1); //
/**
* Opens pattern file and sends pattern (CTB/ Moench)
@ -2056,7 +2070,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK/FAIL
*/
int setPattern(const std::string &fname, int detPos = -1);
int setPattern(const std::string &fname, int detPos = -1); //
/**
* Sets pattern IO control (CTB/ Moench)
@ -2064,7 +2078,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @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);
uint64_t setPatternIOControl(uint64_t word = -1, int detPos = -1); //
/**
* Sets pattern clock control (CTB/ Moench)
@ -2072,7 +2086,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @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);
uint64_t setPatternClockControl(uint64_t word = -1, int detPos = -1); //
/**
* Writes a pattern word (CTB/ Moench)
@ -2082,7 +2096,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setPatternWord(int addr, uint64_t word, int detPos = -1);
uint64_t setPatternWord(int addr, uint64_t word, int detPos = -1); //
/**
* Sets the pattern or loop limits (CTB/ Moench)
@ -2093,7 +2107,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @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);
int detPos = -1); //
/**
* Gets the pattern loop limits (CTB/ Moench)
@ -2101,7 +2115,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @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);
std::array<int, 3> getPatternLoops(int level, int detPos = -1); //
/**
* Sets the wait address (CTB/ Moench)
@ -2110,7 +2124,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
int setPatternWaitAddr(int level, int addr = -1, int detPos = -1);
int setPatternWaitAddr(int level, int addr = -1, int detPos = -1); //
/**
* Sets the wait time (CTB/ Moench)
@ -2119,7 +2133,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* @param detPos -1 for all detectors in list or specific detector position
* @returns actual value
*/
uint64_t setPatternWaitTime(int level, uint64_t t = -1, int detPos = -1);
uint64_t setPatternWaitTime(int level, uint64_t t = -1, int detPos = -1); //
/**
* Sets the mask applied to every pattern (CTB/ Moench)
@ -2211,8 +2225,8 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* s is for subframe number for eiger for 32 bit mode
* @param pArg argument
*/
void registerDataCallback(void (*userCallback)(detectorData *, uint64_t, uint32_t,
void *),
void registerDataCallback(void (*userCallback)(detectorData *, uint64_t,
uint32_t, void *),
void *pArg);
/**
@ -2230,8 +2244,13 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/
void processData();
private:
/**
* increments file index
* @param detPos -1 for all detectors in list or specific detector position
* @returns the file index
*/
int incrementFileIndex(int detPos = -1);
/**
* Creates/open shared memory, initializes detector structure and members
* Called by constructor/ set hostname / read config file

View File

@ -203,6 +203,110 @@ void Detector::setMaxNumberOfChannels(const defs::coordinates value) {
pimpl->setMaxNumberOfChannels(value);
}
// Erik
Result<int> Detector::getFramesCaughtByReceiver(Positions pos) const{
return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos);
}
Result<uint64_t> Detector::getReceiverCurrentFrameIndex(Positions pos) const {
return pimpl->Parallel(&slsDetector::getReceiverCurrentFrameIndex, pos);
}
void Detector::resetFramesCaught(Positions pos) {
pimpl->Parallel(&slsDetector::resetFramesCaught, pos);
}
void Detector::setMasterFileWrite(bool value, Positions pos) {
pimpl->Parallel(&slsDetector::setMasterFileWrite, pos, value);
}
Result<bool> Detector::getMasterFileWrite(Positions pos) const {
return pimpl->Parallel(&slsDetector::getMasterFileWrite, pos);
}
void Detector::setReceiverStreamingTimer(int time_in_ms, Positions pos) {
pimpl->Parallel(&slsDetector::setReceiverStreamingTimer, pos, time_in_ms);
}
Result<int> Detector::getReceiverStreamingTimer(Positions pos) const {
return pimpl->Parallel(&slsDetector::setReceiverStreamingTimer, pos, -1);
}
void Detector::setTenGigaEnabled(bool value, Positions pos) {
pimpl->Parallel(&slsDetector::enableTenGigabitEthernet, pos,
static_cast<int>(value));
}
Result<bool> Detector::getTenGigaEnabled(Positions pos) const {
return pimpl->Parallel(&slsDetector::enableTenGigabitEthernet, pos, -1);
}
Result<int> Detector::getReceiverFifoDepth(Positions pos) const {
return pimpl->Parallel(&slsDetector::setReceiverFifoDepth, pos, -1);
}
void Detector::setReceiverFifoDepth(int nframes, Positions pos) {
pimpl->Parallel(&slsDetector::setReceiverFifoDepth, pos, nframes);
}
Result<bool> Detector::getReceiverSilentMode(Positions pos) const {
return pimpl->Parallel(&slsDetector::setReceiverSilentMode, pos, -1);
}
void Detector::setReceiverSilentMode(bool value, Positions pos) {
pimpl->Parallel(&slsDetector::setReceiverSilentMode, pos,
static_cast<int>(value));
}
void Detector::setPattern(const std::string &fname, Positions pos) {
pimpl->Parallel(&slsDetector::setPattern, pos, fname);
}
void Detector::setPatternIOControl(uint64_t word, Positions pos) {
pimpl->Parallel(&slsDetector::setPatternIOControl, pos, word);
}
Result<uint64_t> Detector::getPatternIOControl(Positions pos) const {
return pimpl->Parallel(&slsDetector::setPatternIOControl, pos, -1);
}
void Detector::setPatternClockControl(uint64_t word, Positions pos) {
pimpl->Parallel(&slsDetector::setPatternClockControl, pos, word);
}
Result<uint64_t> Detector::getPatternClockControl(Positions pos) const {
return pimpl->Parallel(&slsDetector::setPatternClockControl, pos, -1);
}
void Detector::setPatternWord(int addr, uint64_t word, Positions pos) {
pimpl->Parallel(&slsDetector::setPatternWord, pos, addr, word);
}
void Detector::setPatternLoops(int level, int start, int stop, int n,
Positions pos) {
pimpl->Parallel(&slsDetector::setPatternLoops, pos, level, start, stop, n);
}
Result<std::array<int, 3>> Detector::getPatternLoops(int level,
Positions pos) const {
return pimpl->Parallel(&slsDetector::setPatternLoops, pos, level, -1, -1,
-1);
}
void Detector::setPatternWaitAddr(int level, int addr, Positions pos) {
pimpl->Parallel(&slsDetector::setPatternWaitAddr, pos, level, addr);
}
Result<int> Detector::getPatternWaitAddr(int level, Positions pos) const {
return pimpl->Parallel(&slsDetector::setPatternWaitAddr, pos, level, -1);
}
void Detector::setPatternWaitTime(int level, uint64_t t, Positions pos) {
pimpl->Parallel(&slsDetector::setPatternWaitTime, pos, level, t);
}
Result<uint64_t> Detector::getPatternWaitTime(int level, Positions pos) const {
return pimpl->Parallel(&slsDetector::setPatternWaitTime, pos, level, -1);
}
Result<uint64_t> Detector::getPatternMask(Positions pos) {
return pimpl->Parallel(&slsDetector::getPatternMask, pos);