mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 01:50:40 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
0cc0c2715b
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@ bin/
|
||||
build
|
||||
docs/
|
||||
RELEASE.txt
|
||||
Testing/
|
||||
|
||||
|
||||
*.pyc
|
||||
|
34
cmk.sh
34
cmk.sh
@ -7,6 +7,7 @@ TEXTCLIENT=0
|
||||
RECEIVER=0
|
||||
GUI=0
|
||||
DEBUG=0
|
||||
PYTHON=0
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@ -15,10 +16,11 @@ CMAKE_PRE=""
|
||||
CMAKE_POST=""
|
||||
|
||||
usage() { echo -e "
|
||||
Usage: $0 [-c] [-b] [-h] [-d <HDF5 directory>] [-j]
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [-h] [-d <HDF5 directory>] [-j]
|
||||
-[no option]: only make
|
||||
-c: Clean
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
-p: Builds/Rebuilds Python API
|
||||
-h: Builds/Rebuilds Cmake files with HDF5 package
|
||||
-d: HDF5 Custom Directory
|
||||
-t: Build/Rebuilds only text client
|
||||
@ -26,6 +28,12 @@ Usage: $0 [-c] [-b] [-h] [-d <HDF5 directory>] [-j]
|
||||
-g: Build/Rebuilds only gui
|
||||
-j: Number of threads to compile through
|
||||
-e: Debug mode
|
||||
|
||||
Rebuild when you switch to a new build and compile in parallel:
|
||||
./cmk.sh -bj5
|
||||
|
||||
Rebuild python
|
||||
./cmk.sh -p
|
||||
|
||||
For only make:
|
||||
./cmk.sh
|
||||
@ -55,12 +63,17 @@ For rebuilding only certain sections
|
||||
|
||||
" ; exit 1; }
|
||||
|
||||
while getopts ":bchd:j:trge" opt ; do
|
||||
while getopts ":bpchd:j:trge" opt ; do
|
||||
case $opt in
|
||||
b)
|
||||
echo "Building of CMake files Required"
|
||||
REBUILD=1
|
||||
;;
|
||||
p)
|
||||
echo "Compiling Options: Python"
|
||||
PYTHON=1
|
||||
REBUILD=1
|
||||
;;
|
||||
c)
|
||||
echo "Clean Required"
|
||||
CLEAN=1
|
||||
@ -111,27 +124,28 @@ while getopts ":bchd:j:trge" opt ; do
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
if [ $PYTHON -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_PYTHON=ON "
|
||||
echo "Enabling Compile Option: Python"
|
||||
fi
|
||||
|
||||
|
||||
if [ $TEXTCLIENT -eq 0 ] && [ $RECEIVER -eq 0 ] && [ $GUI -eq 0 ]; then
|
||||
#CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON -DSLS_USE_GUI=ON "
|
||||
CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=ON -DSLS_USE_GUI=OFF "
|
||||
echo "Compile Option: TextClient, Receiver and GUI"
|
||||
echo "Enabling Compile Option: TextClient, Receiver and GUI"
|
||||
else
|
||||
if [ $TEXTCLIENT -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON "
|
||||
echo "Compile Option: TextClient"
|
||||
echo "Enabling Compile Option: TextClient"
|
||||
fi
|
||||
if [ $RECEIVER -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_RECEIVER=ON "
|
||||
echo "Compile Option: Receiver"
|
||||
fi
|
||||
|
||||
echo "Enabling Compile Option: Receiver"
|
||||
fi
|
||||
if [ $GUI -eq 1 ]; then
|
||||
CMAKE_POST+=" -DSLS_USE_GUI=ON "
|
||||
echo "Compile Option: GUI"
|
||||
echo "Enabling Compile Option: GUI"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
struct SingleDetectorConfig {
|
||||
slsDetectorDefs::detectorType type_enum =
|
||||
slsDetectorDefs::detectorType::EIGER;
|
||||
const std::string hostname = "beb083";
|
||||
const std::string hostname = "beb031+beb032+";
|
||||
const std::string type_string = "Eiger";
|
||||
const std::string my_ip = "129.129.205.242";
|
||||
const std::string my_ip = "129.129.205.171";
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "ClientSocket.h"
|
||||
#include "logger.h"
|
||||
#include "multiSlsDetector.h"
|
||||
#include "slsDetector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
@ -221,4 +222,57 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
|
||||
// CHECK(rperiod == 0.1);
|
||||
|
||||
// d.freeSharedMemory();
|
||||
// }
|
||||
// }
|
||||
|
||||
TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider", "[.integration]") {
|
||||
SingleDetectorConfig c;
|
||||
|
||||
int ratecorr = 125;
|
||||
|
||||
// pick up multi detector from shm id 0
|
||||
multiSlsDetector m(0);
|
||||
|
||||
// ensure eiger detector type, hostname and online
|
||||
REQUIRE(m.getDetectorTypeAsEnum()==c.type_enum);
|
||||
REQUIRE(m.getHostname()==c.hostname);
|
||||
REQUIRE(m.setOnline(true)==slsDetectorDefs::ONLINE_FLAG);
|
||||
|
||||
// starting state with rate correction off
|
||||
CHECK(m.setRateCorrection(0) == 0);
|
||||
|
||||
// dr 16: clk divider, no change for ratecorr
|
||||
CHECK(m.setDynamicRange(16) == 16);
|
||||
CHECK(m.setSpeed(slsDetectorDefs::CLOCK_DIVIDER) == 1);
|
||||
CHECK(m.getRateCorrection() == 0);
|
||||
|
||||
// dr 32: clk divider, no change for ratecorr
|
||||
CHECK(m.setDynamicRange(32) == 32);
|
||||
CHECK(m.setSpeed(slsDetectorDefs::CLOCK_DIVIDER) == 2);
|
||||
CHECK(m.getRateCorrection() == 0);
|
||||
|
||||
// other drs: no change for clk divider, no change for ratecorr
|
||||
CHECK(m.setDynamicRange(8) == 8);
|
||||
CHECK(m.setSpeed(slsDetectorDefs::CLOCK_DIVIDER) == 2);
|
||||
CHECK(m.getRateCorrection() == 0);
|
||||
CHECK(m.setDynamicRange(4) == 4);
|
||||
CHECK(m.setSpeed(slsDetectorDefs::CLOCK_DIVIDER) == 2);
|
||||
CHECK(m.getRateCorrection() == 0);
|
||||
|
||||
// switching on rate correction with dr 16, 32
|
||||
m.setDynamicRange(16);
|
||||
m.setRateCorrection(ratecorr);
|
||||
CHECK(m.getRateCorrection() == ratecorr);
|
||||
m.setDynamicRange(32);
|
||||
CHECK(m.getRateCorrection() == ratecorr);
|
||||
|
||||
// ratecorr fail with dr 4 or 8
|
||||
CHECK_THROWS_AS(m.setDynamicRange(8), sls::NonCriticalError);
|
||||
CHECK(m.getRateCorrection()==0);
|
||||
m.setDynamicRange(16);
|
||||
m.setDynamicRange(16);
|
||||
m.setRateCorrection(ratecorr);
|
||||
m.setDynamicRange(16);
|
||||
m.setRateCorrection(ratecorr);
|
||||
CHECK_THROWS_AS(m.setDynamicRange(4), sls::NonCriticalError);
|
||||
CHECK(m.getRateCorrection()==0);
|
||||
}
|
||||
|
Binary file not shown.
@ -1766,10 +1766,6 @@ int set_dynamic_range(int file_des) {
|
||||
|
||||
// set & get
|
||||
if ((dr == -1) || (Server_VerifyLock() == OK)) {
|
||||
|
||||
#ifdef EIGERD
|
||||
int old_dr = setDynamicRange(-1);
|
||||
#endif
|
||||
// check dr
|
||||
switch(dr) {
|
||||
case -1:
|
||||
@ -1785,29 +1781,6 @@ int set_dynamic_range(int file_des) {
|
||||
modeNotImplemented("Dynamic range", dr);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef EIGERD
|
||||
if (dr != -1 && getRateCorrectionEnable()) {
|
||||
// 4 or 8 bit, switch off rate corr (only if dr worked)
|
||||
if ((dr != 32) && (dr != 16) && (ret == OK)) {
|
||||
setRateCorrection(0);
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Switching off Rate Correction. Must be in 32 or 16 bit mode\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
|
||||
// 16, 32 (diff from old value), set new tau in rate table(-1), if it didnt work, give error
|
||||
else if ((dr == 16 || dr == 32) && (old_dr != dr)) {
|
||||
setRateCorrection(-1); //tau_ns will not be -1 here
|
||||
// it didnt work
|
||||
if (!getRateCorrectionEnable()) {
|
||||
ret = FAIL;
|
||||
strcpy(mess,"Deactivating Rate Correction. Could not set it.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class multiSlsDetector;
|
||||
class ServerInterface;
|
||||
class MySocketTCP;
|
||||
|
||||
#define SLS_SHMVERSION 0x181005
|
||||
#define SLS_SHMVERSION 0x190412
|
||||
#define NCHIPSMAX 10
|
||||
#define NCHANSMAX 65536
|
||||
#define NDACSMAX 16
|
||||
@ -120,6 +120,9 @@ struct sharedSlsDetector {
|
||||
/** timer values */
|
||||
int64_t timerValue[slsDetectorDefs::timerIndex::MAX_TIMERS];
|
||||
|
||||
/** rate correction in ns */
|
||||
int64_t deadTime;
|
||||
|
||||
/** ip address/hostname of the receiver for client control via TCP */
|
||||
char receiver_hostname[MAX_STR_LENGTH];
|
||||
|
||||
@ -1339,7 +1342,7 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
sls_detector_module *getModule();
|
||||
|
||||
/**
|
||||
* Set Rate correction (Mythen, Eiger)
|
||||
* Set Rate correction (Eiger)
|
||||
* @param t dead time in ns - if 0 disable correction,
|
||||
* if >0 set dead time to t, if < 0 set deadtime to default dead time
|
||||
* for current settings
|
||||
@ -1348,11 +1351,18 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
int setRateCorrection(int64_t t = 0);
|
||||
|
||||
/**
|
||||
* Get rate correction Eiger)
|
||||
* Get rate correction (Eiger)
|
||||
* @returns 0 if rate correction disabled, > 0 otherwise
|
||||
*/
|
||||
int64_t getRateCorrection();
|
||||
|
||||
/**
|
||||
* Update rate correction according to dynamic range (Eiger)
|
||||
* If rate correction enabled and dr is 8 or 16, it will throw
|
||||
* Otherwise update ratecorrection if enabled
|
||||
*/
|
||||
void updateRateCorrection();
|
||||
|
||||
/**
|
||||
* Prints receiver configuration
|
||||
* @param level print level
|
||||
|
@ -1264,36 +1264,46 @@ int multiSlsDetector::setDynamicRange(int dr, int detPos) {
|
||||
int prevGValue = multi_shm()->dataBytesInclGapPixels;
|
||||
multi_shm()->dataBytes = 0;
|
||||
multi_shm()->dataBytesInclGapPixels = 0;
|
||||
multi_shm()->numberOfChannels = 0;
|
||||
for (auto &d : detectors) {
|
||||
multi_shm()->dataBytes += d->getDataBytes();
|
||||
multi_shm()->dataBytesInclGapPixels += d->getDataBytesInclGapPixels();
|
||||
multi_shm()->numberOfChannels += d->getTotalNumberOfChannels();
|
||||
}
|
||||
|
||||
// for usability
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
switch (dr) {
|
||||
case 32:
|
||||
FILE_LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setSpeed(CLOCK_DIVIDER, 2);
|
||||
break;
|
||||
case 16:
|
||||
FILE_LOG(logINFO) << "Setting Clock to Half Speed for Dynamic Range of 16";
|
||||
setSpeed(CLOCK_DIVIDER, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// if there was a change FIXME:add dr to sls shm and check that instead
|
||||
if ((prevValue != multi_shm()->dataBytes) ||
|
||||
(prevGValue != multi_shm()->dataBytesInclGapPixels)) {
|
||||
|
||||
updateOffsets();
|
||||
|
||||
// update speed, check ratecorrection
|
||||
if (getDetectorTypeAsEnum() == EIGER) {
|
||||
|
||||
// rate correction before speed for consistency
|
||||
// (else exception at speed makes ratecorr inconsistent)
|
||||
parallelCall(&slsDetector::updateRateCorrection);
|
||||
|
||||
// speed(usability)
|
||||
switch (dr) {
|
||||
case 32:
|
||||
FILE_LOG(logINFO)
|
||||
<< "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setSpeed(CLOCK_DIVIDER, 2);
|
||||
break;
|
||||
case 16:
|
||||
FILE_LOG(logINFO)
|
||||
<< "Setting Clock to Half Speed for Dynamic Range of 16";
|
||||
setSpeed(CLOCK_DIVIDER, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update offsets if there was a change FIXME:add dr to sls shm and check
|
||||
// that instead
|
||||
if ((prevValue != multi_shm()->dataBytes) ||
|
||||
(prevGValue != multi_shm()->dataBytesInclGapPixels)) {
|
||||
updateOffsets();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -322,6 +322,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
detector_shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = 0;
|
||||
detector_shm()->timerValue[STORAGE_CELL_NUMBER] = 0;
|
||||
detector_shm()->timerValue[SUBFRAME_DEADTIME] = 0;
|
||||
detector_shm()->deadTime = 0;
|
||||
sls::strcpy_safe(detector_shm()->receiver_hostname, "none");
|
||||
detector_shm()->receiverTCPPort = DEFAULT_PORTNO + 2;
|
||||
detector_shm()->receiverUDPPort = DEFAULT_UDP_PORTNO;
|
||||
@ -1951,7 +1952,7 @@ int slsDetector::setDynamicRange(int n) {
|
||||
client.close();
|
||||
ret = updateDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// only for eiger
|
||||
// setting dr consequences on databytes shm
|
||||
@ -3810,6 +3811,7 @@ int slsDetector::setRateCorrection(int64_t t) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname,
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
|
||||
detector_shm()->deadTime = t;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateDetector();
|
||||
@ -3828,6 +3830,7 @@ int64_t slsDetector::getRateCorrection() {
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval,
|
||||
sizeof(retval));
|
||||
detector_shm()->deadTime = retval;
|
||||
FILE_LOG(logDEBUG1) << "Rate correction: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
@ -3836,6 +3839,24 @@ int64_t slsDetector::getRateCorrection() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::updateRateCorrection() {
|
||||
// rate correction is enabled
|
||||
if (detector_shm()->deadTime != 0) {
|
||||
switch (detector_shm()->dynamicRange) {
|
||||
// rate correction is allowed
|
||||
case 16:
|
||||
case 32:
|
||||
setRateCorrection(detector_shm()->deadTime);
|
||||
break;
|
||||
// not allowed
|
||||
default:
|
||||
setRateCorrection(0);
|
||||
throw sls::NonCriticalError(
|
||||
"Rate correction Deactivated, must be in 32 or 16 bit mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void slsDetector::printReceiverConfiguration(TLogLevel level) {
|
||||
FILE_LOG(level) << "#Detector " << detId << ":\n Receiver Hostname:\t"
|
||||
<< getReceiverHostname()
|
||||
@ -4824,7 +4845,7 @@ int slsDetector::setLEDEnable(int enable) {
|
||||
int arg = enable;
|
||||
int retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Sending LED Enable: " << arg;
|
||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname,
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
||||
@ -4845,7 +4866,7 @@ int slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) {
|
||||
<< args[0] << ", delay: " << std::dec << args[1]
|
||||
<< " ps";
|
||||
|
||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname,
|
||||
detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define GITBRANCH "refgui"
|
||||
#define APIGOTTHARD 0x190108
|
||||
#define APIMOENCH 0x181108
|
||||
#define APIEIGER 0x190405
|
||||
#define APIJUNGFRAU 0x190405
|
||||
#define APILIB 0x190405
|
||||
#define APIRECEIVER 0x190405
|
||||
#define APIGUI 0x190405
|
||||
#define APICTB 0x190405
|
||||
#define APICTB 0x190412
|
||||
#define APIEIGER 0x190412
|
||||
|
Loading…
x
Reference in New Issue
Block a user