Merge pull request #115 from slsdetectorgroup/mythen3

Mythen3
This commit is contained in:
Dhanya Thattil 2020-07-17 19:24:34 +02:00 committed by GitHub
commit c4374e623e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 301 additions and 196 deletions

View File

@ -15,19 +15,31 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() {
// enabling according to det type
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::MYTHEN3:
slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
if (detType == slsDetectorDefs::MYTHEN3) {
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
break;
case slsDetectorDefs::EIGER:
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
// disable dr
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboDynamicRange->model());
if (model) {
QModelIndex index;
QStandardItem *item;
index =
model->index(DYNAMICRANGE_4, comboDynamicRange->modelColumn(),
comboDynamicRange->rootModelIndex());
item = model->itemFromIndex(index);
item->setEnabled(false);
}
} else if (detType == slsDetectorDefs::EIGER) {
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
break;
default:
break;
}
// default settings for the disabled

View File

@ -1614,7 +1614,6 @@ int enableTenGigabitEthernet(int val) {
} else {
bus_w(addr, bus_r(addr) & (~CONFIG_GB10_SND_UDP_MSK));
}
// configuremac called from client
}
return ((bus_r(addr) & CONFIG_GB10_SND_UDP_MSK) >>
CONFIG_GB10_SND_UDP_OFST);

View File

@ -1528,7 +1528,6 @@ int enableTenGigabitEthernet(int val) {
send_to_ten_gig = 1;
else
send_to_ten_gig = 0;
// configuremac called from client
}
return send_to_ten_gig;
}

View File

@ -112,7 +112,7 @@
#define CONFIG_DYNAMIC_RANGE_OFST (4)
#define CONFIG_DYNAMIC_RANGE_MSK (0x00000003 << CONFIG_DYNAMIC_RANGE_OFST)
#define CONFIG_DYNAMIC_RANGE_1_VAL ((0x0 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_4_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_8_VAL ((0x1 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_16_VAL ((0x2 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
#define CONFIG_DYNAMIC_RANGE_24_VAL ((0x3 << CONFIG_DYNAMIC_RANGE_OFST) & CONFIG_DYNAMIC_RANGE_MSK)
@ -149,6 +149,8 @@
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
#define PKT_CONFIG_1G_INTERFACE_OFST (16)
#define PKT_CONFIG_1G_INTERFACE_MSK (0x00000001 << PKT_CONFIG_1G_INTERFACE_OFST)
/* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)

View File

@ -21,6 +21,7 @@
// Global variable from slsDetectorServer_funcs
extern int debugflag;
extern int checkModuleFlag;
extern udpStruct udpDetails;
extern const enum detectorType myDetectorType;
@ -426,6 +427,42 @@ void setupDetector() {
setGateDelay(i, DEFAULT_GATE_DELAY);
}
setInitialExtSignals();
// 10G UDP
enableTenGigabitEthernet(1);
// check module type attached if not in debug mode
{
int ret = checkDetectorType();
if (checkModuleFlag) {
switch (ret) {
case -1:
sprintf(initErrorMessage,
"Could not get the module type attached.\n");
initError = FAIL;
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage));
return;
case -2:
sprintf(initErrorMessage,
"No Module attached! Run server with -nomodule.\n");
initError = FAIL;
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage));
return;
case FAIL:
sprintf(initErrorMessage,
"Wrong Module (Not Mythen3) attached!\n");
initError = FAIL;
LOG(logERROR, ("Aborting startup!\n\n", initErrorMessage));
return;
default:
break;
}
} else {
LOG(logINFOBLUE,
("In No-Module mode: Ignoring module type. Continuing.\n"));
}
}
powerChip(1);
loadDefaultPattern(DEFAULT_PATTERN_FILE);
}
@ -496,16 +533,15 @@ int setDynamicRange(int dr) {
if (dr > 0) {
uint32_t regval = 0;
switch (dr) {
case 1:
/*case 1: TODO:Not implemented in firmware yet
regval = CONFIG_DYNAMIC_RANGE_1_VAL;
break;
case 4:
regval = CONFIG_DYNAMIC_RANGE_4_VAL;
break;*/
case 8:
regval = CONFIG_DYNAMIC_RANGE_8_VAL;
break;
case 16:
regval = CONFIG_DYNAMIC_RANGE_16_VAL;
break;
case 24:
case 32:
regval = CONFIG_DYNAMIC_RANGE_24_VAL;
break;
@ -520,10 +556,10 @@ int setDynamicRange(int dr) {
uint32_t regval = bus_r(CONFIG_REG) & CONFIG_DYNAMIC_RANGE_MSK;
switch (regval) {
case CONFIG_DYNAMIC_RANGE_1_VAL:
return 1;
case CONFIG_DYNAMIC_RANGE_4_VAL:
return 4;
/*case CONFIG_DYNAMIC_RANGE_1_VAL: TODO:Not implemented in firmware yet
return 1;*/
case CONFIG_DYNAMIC_RANGE_8_VAL:
return 8;
case CONFIG_DYNAMIC_RANGE_16_VAL:
return 16;
case CONFIG_DYNAMIC_RANGE_24_VAL:
@ -1459,6 +1495,26 @@ int setDetectorPosition(int pos[]) {
int *getDetectorPosition() { return detPos; }
int enableTenGigabitEthernet(int val) {
uint32_t addr = PKT_CONFIG_REG;
// set
if (val != -1) {
LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
// 1g
if (val == 0) {
bus_w(addr, bus_r(addr) | PKT_CONFIG_1G_INTERFACE_MSK);
}
// 10g
else {
bus_w(addr, bus_r(addr) & (~PKT_CONFIG_1G_INTERFACE_MSK));
}
}
int oneG = ((bus_r(addr) & PKT_CONFIG_1G_INTERFACE_MSK) >>
PKT_CONFIG_1G_INTERFACE_OFST);
return oneG ? 0 : 1;
}
/* pattern */
void startPattern() {
@ -2003,7 +2059,6 @@ void *start_timer(void *arg) {
int numFrames = (getNumFrames() * getNumTriggers());
int64_t expUs = getGatePeriod() / 1000;
// int dr = setDynamicRange(-1);
int imagesize = calculateDataBytes();
int dataSize = imagesize / PACKETS_PER_FRAME;
int packetSize = dataSize + sizeof(sls_detector_header);
@ -2011,8 +2066,33 @@ void *start_timer(void *arg) {
// Generate data
char imageData[imagesize];
memset(imageData, 0, imagesize);
for (int i = 0; i < imagesize; i += sizeof(uint8_t)) {
*((uint8_t *)(imageData + i)) = i;
{
int dr = setDynamicRange(-1);
int numCounters = __builtin_popcount(getCounterMask());
int nchannels = NCHAN_1_COUNTER * NCHIP * numCounters;
switch (dr) {
/*case 1: // TODO: Not implemented in firmware yet
break;*/
case 8:
for (int i = 0; i < nchannels; ++i) {
*((uint8_t *)(imageData + i)) = (uint8_t)i;
}
break;
case 16:
for (int i = 0; i < nchannels; ++i) {
*((uint16_t *)(imageData + i * sizeof(uint16_t))) = (uint16_t)i;
}
break;
case 32:
for (int i = 0; i < nchannels; ++i) {
*((uint32_t *)(imageData + i * sizeof(uint32_t))) =
((uint32_t)i & 0xFFFFFF); // 24 bit
}
break;
default:
break;
}
}
// Send data
@ -2247,13 +2327,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
int calculateDataBytes() {
int numCounters = __builtin_popcount(getCounterMask());
int dr = setDynamicRange(-1);
int databytes = NCHAN_1_COUNTER * NCHIP * numCounters *
((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 0.5 : // 4 bit
0.125))); // 1 bit
return databytes;
return (NCHAN_1_COUNTER * NCHIP * numCounters * ((double)dr / 8.00));
}
int getTotalNumberOfChannels() {

View File

@ -27,7 +27,7 @@
#define DEFAULT_PATTERN_FILE ("DefaultPattern.txt")
#define DEFAULT_INTERNAL_GATES (1)
#define DEFAULT_EXTERNAL_GATES (1)
#define DEFAULT_DYNAMIC_RANGE (24)
#define DEFAULT_DYNAMIC_RANGE (32)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_GATE_WIDTH (100 * 1000 * 1000) // ns

View File

@ -377,7 +377,8 @@ int getInterruptSubframe();
int setReadNLines(int value);
int getReadNLines();
#endif
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD)
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(EIGERD) || \
defined(MYTHEN3D)
int enableTenGigabitEthernet(int val);
#endif

View File

@ -2684,10 +2684,13 @@ int set_dynamic_range(int file_des) {
// check dr
switch (dr) {
case GET_FLAG:
#ifdef MYTHEN3D
case 32:
#elif EIGERD
/*#ifdef MYTHEN3D TODO:Not implemented in firmware yet
case 1:
#endif*/
#ifdef EIGERD
case 4:
#endif
#if defined(EIGERD) || defined(MYTHEN3D)
case 8:
case 16:
case 32:
@ -2698,6 +2701,11 @@ int set_dynamic_range(int file_des) {
#endif
retval = setDynamicRange(dr);
LOG(logDEBUG1, ("Dynamic range: %d\n", retval));
if (retval == -1) {
ret = FAIL;
sprintf(mess, "Could not get dynamic range.\n");
LOG(logERROR, (mess));
}
validate(dr, retval, "set dynamic range", DEC);
break;
default:
@ -2847,14 +2855,14 @@ int enable_ten_giga(int file_des) {
return printSocketReadError();
LOG(logINFOBLUE, ("Setting 10GbE: %d\n", arg));
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(MYTHEN3D) || \
defined(GOTTHARD2D)
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(GOTTHARD2D)
functionNotImplemented();
#else
// set & get
if ((arg == GET_FLAG) || (Server_VerifyLock() == OK)) {
if (arg >= 0 && enableTenGigabitEthernet(GET_FLAG) != arg) {
enableTenGigabitEthernet(arg);
#ifdef EIGERD
uint64_t hardwaremac = getDetectorMAC();
if (udpDetails.srcmac != hardwaremac) {
LOG(logINFOBLUE, ("Updating udp source mac\n"));
@ -2865,6 +2873,7 @@ int enable_ten_giga(int file_des) {
LOG(logINFOBLUE, ("Updating udp source ip\n"));
udpDetails.srcip = hardwareip;
}
#endif
configure_mac();
}
retval = enableTenGigabitEthernet(GET_FLAG);

View File

@ -203,6 +203,16 @@ class Detector {
* [Gotthard2] only in continuous mode */
Result<ns> getDelayAfterTriggerLeft(Positions pos = {}) const;
Result<int> getDynamicRange(Positions pos = {}) const;
/**
* [Eiger] Options: 4, 8, 16, 32
* [Mythen3] Options: 8, 16, 32
* [Eiger] If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to
* 1
*/
void setDynamicRange(int value);
Result<defs::timingMode> getTimingMode(Positions pos = {}) const;
/**
@ -501,10 +511,10 @@ class Detector {
Result<std::string> printRxConfiguration(Positions pos = {}) const;
/** [Eiger][CTB][Moench] */
/** [Eiger][CTB][Moench][Mythen3] */
Result<bool> getTenGiga(Positions pos = {}) const;
/** [Eiger][CTB][Moench] */
/** [Eiger][CTB][Moench][Mythen3] */
void setTenGiga(bool value, Positions pos = {});
/** [Eiger, Jungfrau] */
@ -698,8 +708,8 @@ class Detector {
Result<int> getRxZmqStartingFrame(Positions pos = {}) const;
/**
* The starting frame index to stream out. 0 by default, which streams
* the first frame in an acquisition, and then depending on the rx zmq
* The starting frame index to stream out. 0 by default, which streams
* the first frame in an acquisition, and then depending on the rx zmq
* frequency/ timer.
*/
void setRxZmqStartingFrame(int fnum, Positions pos = {});
@ -736,15 +746,6 @@ class Detector {
* *
* ************************************************/
Result<int> getDynamicRange(Positions pos = {}) const;
/**
* [Eiger]
* Options: 4, 8, 16, 32
* If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to 1
*/
void setDynamicRange(int value);
/** [Eiger] in 32 bit mode */
Result<ns> getSubExptime(Positions pos = {}) const;

View File

@ -487,6 +487,37 @@ std::string CmdProxy::Exptime(int action) {
return os.str();
}
std::string CmdProxy::DynamicRange(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[value]\n\tDynamic Range or number of bits per "
"pixel in detector.\n\t"
"[Eiger] Options: 4, 8, 16, 32\n\t"
"[Mythen3] Options: 8, 16, 32"
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getDynamicRange({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError(
"Cannot execute dynamic range at module level");
}
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setDynamicRange(StringTo<int>(args[0]));
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Speed(int action) {
std::ostringstream os;
os << cmd << ' ';
@ -1196,35 +1227,6 @@ std::string CmdProxy::ReceiveHostname(int action) {
/* ZMQ Streaming Parameters (Receiver<->Client) */
/* Eiger Specific */
std::string CmdProxy::DynamicRange(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[4|8|16|32]\n\t[Eiger] Dynamic Range or number of bits per "
"pixel in detector."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getDynamicRange({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError(
"Cannot execute dynamic range at module level");
}
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setDynamicRange(StringTo<int>(args[0]));
os << args.front() << '\n';
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Threshold(int action) {
std::ostringstream os;
os << cmd << ' ';

View File

@ -643,6 +643,7 @@ class CmdProxy {
{"triggersl", &CmdProxy::triggersl},
{"delayl", &CmdProxy::delayl},
{"periodl", &CmdProxy::periodl},
{"dr", &CmdProxy::DynamicRange},
{"timing", &CmdProxy::timing},
{"speed", &CmdProxy::Speed},
{"adcphase", &CmdProxy::Adcphase},
@ -814,7 +815,6 @@ class CmdProxy {
{"zmqip", &CmdProxy::zmqip},
/* Eiger Specific */
{"dr", &CmdProxy::DynamicRange},
{"subexptime", &CmdProxy::subexptime},
{"subdeadtime", &CmdProxy::subdeadtime},
{"threshold", &CmdProxy::Threshold},
@ -996,6 +996,7 @@ class CmdProxy {
/* acquisition parameters */
std::string Acquire(int action);
std::string Exptime(int action);
std::string DynamicRange(int action);
std::string Speed(int action);
std::string Adcphase(int action);
std::string Dbitphase(int action);
@ -1021,7 +1022,6 @@ class CmdProxy {
/* File */
/* ZMQ Streaming Parameters (Receiver<->Client) */
/* Eiger Specific */
std::string DynamicRange(int action);
std::string Threshold(int action);
std::string ThresholdNoTb(int action);
std::string TrimEnergies(int action);
@ -1648,7 +1648,7 @@ class CmdProxy {
"\n\tPrints the receiver configuration.");
INTEGER_COMMAND(tengiga, getTenGiga, setTenGiga, StringTo<int>,
"[0, 1]\n\t[Eiger][Ctb][Moench] 10GbE Enable.");
"[0, 1]\n\t[Eiger][Ctb][Moench][Mythen3] 10GbE Enable.");
INTEGER_COMMAND(flowcontrol10g, getTenGigaFlowControl,
setTenGigaFlowControl, StringTo<int>,
@ -1785,9 +1785,11 @@ class CmdProxy {
"[nth frame]\n\tStream out every nth frame. Default is 1. 0 means "
"streaming every 200 ms and discarding frames in this interval.");
INTEGER_COMMAND(
rx_zmqstartfnum, getRxZmqStartingFrame, setRxZmqStartingFrame, StringTo<int>,
"[fnum]\n\tThe starting frame index to stream out. 0 by default, which streams the first frame in an acquisition, and then depending on the rx zmq frequency/ timer");
INTEGER_COMMAND(rx_zmqstartfnum, getRxZmqStartingFrame,
setRxZmqStartingFrame, StringTo<int>,
"[fnum]\n\tThe starting frame index to stream out. 0 by "
"default, which streams the first frame in an acquisition, "
"and then depending on the rx zmq frequency/ timer");
INTEGER_COMMAND(
rx_zmqport, getRxZmqPort, setRxZmqPort, StringTo<int>,

View File

@ -273,6 +273,14 @@ Result<ns> Detector::getPeriodLeft(Positions pos) const {
return pimpl->Parallel(&Module::getPeriodLeft, pos);
}
Result<int> Detector::getDynamicRange(Positions pos) const {
return pimpl->Parallel(&Module::getDynamicRange, pos);
}
void Detector::setDynamicRange(int value) {
pimpl->Parallel(&Module::setDynamicRange, {}, value);
}
Result<defs::timingMode> Detector::getTimingMode(Positions pos) const {
return pimpl->Parallel(&Module::getTimingMode, pos);
}
@ -1022,14 +1030,6 @@ void Detector::setClientZmqIp(const IpAddr ip, Positions pos) {
// Eiger Specific
Result<int> Detector::getDynamicRange(Positions pos) const {
return pimpl->Parallel(&Module::getDynamicRange, pos);
}
void Detector::setDynamicRange(int value) {
pimpl->Parallel(&Module::setDynamicRange, {}, value);
}
Result<ns> Detector::getSubExptime(Positions pos) const {
return pimpl->Parallel(&Module::getSubExptime, pos);
}

View File

@ -259,6 +259,38 @@ int64_t Module::getPeriodLeft() const {
return sendToDetectorStop<int64_t>(F_GET_PERIOD_LEFT);
}
int Module::getDynamicRange() {
return sendToDetector<int>(F_SET_DYNAMIC_RANGE, GET_FLAG);
}
void Module::setDynamicRange(int n) {
int prev_val = n;
if (shm()->myDetectorType == EIGER) {
prev_val = getDynamicRange();
}
auto retval = sendToDetector<int>(F_SET_DYNAMIC_RANGE, n);
if (shm()->useReceiverFlag) {
int arg = retval;
sendToReceiver<int>(F_SET_RECEIVER_DYNAMIC_RANGE, arg);
}
// changes in dr
if (n != prev_val) {
// update speed for usability
if (n == 32) {
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
"Dynamic Range of 32";
setClockDivider(RUN_CLOCK, 2);
} else if (prev_val == 32) {
LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of "
<< n;
setClockDivider(RUN_CLOCK, 0);
}
updateRateCorrection();
}
}
slsDetectorDefs::timingMode Module::getTimingMode() {
return sendToDetector<timingMode>(F_SET_TIMING_MODE, GET_FLAG);
}
@ -1017,38 +1049,6 @@ void Module::setClientStreamingIP(const sls::IpAddr ip) {
// Eiger Specific
int Module::getDynamicRange() {
return sendToDetector<int>(F_SET_DYNAMIC_RANGE, GET_FLAG);
}
void Module::setDynamicRange(int n) {
int prev_val = n;
if (shm()->myDetectorType == EIGER) {
prev_val = getDynamicRange();
}
auto retval = sendToDetector<int>(F_SET_DYNAMIC_RANGE, n);
if (shm()->useReceiverFlag) {
int arg = retval;
sendToReceiver<int>(F_SET_RECEIVER_DYNAMIC_RANGE, arg);
}
// changes in dr
if (n != prev_val) {
// update speed for usability
if (n == 32) {
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
"Dynamic Range of 32";
setClockDivider(RUN_CLOCK, 2);
} else if (prev_val == 32) {
LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of "
<< n;
setClockDivider(RUN_CLOCK, 0);
}
updateRateCorrection();
}
}
int64_t Module::getSubExptime() {
return sendToDetector<int64_t>(F_GET_SUB_EXPTIME);
}

View File

@ -125,6 +125,8 @@ class Module : public virtual slsDetectorDefs {
int64_t getNumberOfTriggersLeft() const;
int64_t getDelayAfterTriggerLeft() const;
int64_t getPeriodLeft() const;
int getDynamicRange();
void setDynamicRange(int n);
timingMode getTimingMode();
void setTimingMode(timingMode value);
int getClockDivider(int clkIndex);
@ -290,8 +292,6 @@ class Module : public virtual slsDetectorDefs {
* Eiger Specific *
* *
* ************************************************/
int getDynamicRange();
void setDynamicRange(int n);
int64_t getSubExptime();
void setSubExptime(int64_t value);
int64_t getSubDeadTime();

View File

@ -315,47 +315,6 @@ TEST_CASE("txndelay_right", "[.cmd][.new]") {
/* Eiger Specific */
TEST_CASE("dr", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto dr = det.getDynamicRange().squash();
std::array<int, 4> vals{4, 8, 16, 32};
for (const auto val : vals) {
std::ostringstream oss1, oss2;
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
proxy.Call("dr", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
}
det.setDynamicRange(dr);
} else if (det_type == defs::MYTHEN3) {
// not updated in firmware to support anything other than 32 at the
// moment
std::ostringstream oss1, oss2;
proxy.Call("dr", {"32"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr 32\n");
proxy.Call("dr", {"32"}, -1, PUT, oss2);
REQUIRE(oss2.str() == "dr 32\n");
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"16"}, -1, PUT));
} else {
// For the other detectors we should get an error message
// except for dr 16
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT));
std::ostringstream oss1, oss2;
proxy.Call("dr", {"16"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr 16\n");
proxy.Call("dr", {"16"}, -1, PUT, oss2);
REQUIRE(oss2.str() == "dr 16\n");
}
}
TEST_CASE("subexptime", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -451,6 +451,48 @@ TEST_CASE("periodl", "[.cmd][.new]") {
}
}
TEST_CASE("dr", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto dr = det.getDynamicRange().squash();
std::array<int, 4> vals{4, 8, 16, 32};
for (const auto val : vals) {
std::ostringstream oss1, oss2;
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
proxy.Call("dr", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
}
det.setDynamicRange(dr);
} else if (det_type == defs::MYTHEN3) {
auto dr = det.getDynamicRange().squash();
// not updated in firmware to support dr 1
std::array<int, 3> vals{8, 16, 32};
for (const auto val : vals) {
std::ostringstream oss1, oss2;
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
proxy.Call("dr", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
}
det.setDynamicRange(dr);
} else {
// For the other detectors we should get an error message
// except for dr 16
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT));
std::ostringstream oss1, oss2;
proxy.Call("dr", {"16"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "dr 16\n");
proxy.Call("dr", {"16"}, -1, PUT, oss2);
REQUIRE(oss2.str() == "dr 16\n");
}
}
TEST_CASE("timing", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
@ -1523,7 +1565,7 @@ TEST_CASE("tengiga", "[.cmd][.new]") {
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD ||
det_type == defs::MOENCH) {
det_type == defs::MOENCH || det_type == defs::MYTHEN3) {
auto tengiga = det.getTenGiga();
det.setTenGiga(false);

View File

@ -430,7 +430,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
}
impl()->setTimingMode(arg.timMode);
if (myDetectorType == EIGER || myDetectorType == MOENCH ||
myDetectorType == CHIPTESTBOARD) {
myDetectorType == CHIPTESTBOARD || myDetectorType == MYTHEN3) {
try {
impl()->setTenGigaEnable(arg.tenGiga);
} catch (const RuntimeError &e) {
@ -727,21 +727,28 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting dynamic range: " << dr;
bool exists = false;
switch (myDetectorType) {
case EIGER:
if (dr == 4 || dr == 8 || dr == 16 || dr == 32) {
switch (dr) {
case 16:
exists = true;
break;
/*case 1: //TODO: Not yet implemented in firmware
if (myDetectorType == MYTHEN3) {
exists = true;
}
break;
case MYTHEN3:
if (dr == 1 || dr == 4 || dr == 16 || dr == 32) {
*/
case 4:
if (myDetectorType == EIGER) {
exists = true;
}
break;
case 8:
case 32:
if (myDetectorType == EIGER || myDetectorType == MYTHEN3) {
exists = true;
}
break;
default:
if (dr == 16) {
exists = true;
}
break;
}
if (!exists) {
@ -980,7 +987,7 @@ int ClientInterface::get_overwrite(Interface &socket) {
int ClientInterface::enable_tengiga(Interface &socket) {
auto val = socket.Receive<int>();
if (myDetectorType != EIGER && myDetectorType != CHIPTESTBOARD &&
myDetectorType != MOENCH)
myDetectorType != MOENCH && myDetectorType != MYTHEN3)
functionNotImplemented();
if (val >= 0) {
@ -1718,7 +1725,7 @@ int ClientInterface::get_streaming_start_fnum(Interface &socket) {
}
int ClientInterface::set_streaming_start_fnum(Interface &socket) {
auto index = socket.Receive<int>();
auto index = socket.Receive<int>();
if (index < 0) {
throw RuntimeError("Invalid streaming start frame number: " +
std::to_string(index));

View File

@ -449,11 +449,7 @@ class Mythen3Data : public GeneralData {
ncounters = n;
nPixelsX = NCHAN * ncounters;
LOG(logINFO) << "nPixelsX: " << nPixelsX;
imageSize = nPixelsX * nPixelsY *
((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 0.5 : // 4 bit
0.125))); // 1 bit
imageSize = nPixelsX * nPixelsY * ((double)dr / 8.00);
dataSize = imageSize / packetsPerFrame;
packetSize = headerSizeinPacket + dataSize;
LOG(logINFO) << "PacketSize: " << packetSize;
@ -465,11 +461,7 @@ class Mythen3Data : public GeneralData {
* @param tgEnable (discarded, of no value to mythen3)
*/
void SetDynamicRange(int dr, bool tgEnable) {
imageSize = nPixelsX * nPixelsY *
((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 0.5 : // 4 bit
0.125))); // 1 bit
imageSize = nPixelsX * nPixelsY * ((double)dr / 8.00);
dataSize = imageSize / packetsPerFrame;
packetSize = headerSizeinPacket + dataSize;
LOG(logINFO) << "PacketSize: " << packetSize;

View File

@ -293,9 +293,10 @@ void Implementation::setDetectorType(const detectorType d) {
dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable,
&masterFileWriteEnable, &dataStreamEnable, &dynamicRange,
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &framePadding,
&activated, &deactivatedPaddingEnable, &silentMode, &quadEnable,
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
&framePadding, &activated, &deactivatedPaddingEnable,
&silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset,
&ctbAnalogDataBytes));
} catch (...) {
listener.clear();
dataProcessor.clear();
@ -1018,10 +1019,10 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType,
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable,
&dynamicRange, &streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
&framePadding, &activated, &deactivatedPaddingEnable,
&silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset,
&ctbAnalogDataBytes));
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
&streamingStartFnum, &framePadding, &activated,
&deactivatedPaddingEnable, &silentMode, &quadEnable,
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
dataProcessor[i]->SetGeneralData(generalData);
} catch (...) {
listener.clear();
@ -1661,6 +1662,9 @@ void Implementation::setTenGigaEnable(const bool b) {
case EIGER:
generalData->SetTenGigaEnable(b, dynamicRange);
break;
case MYTHEN3:
generalData->SetDynamicRange(dynamicRange, b);
break;
case MOENCH:
case CHIPTESTBOARD:
ctbAnalogDataBytes = generalData->setImageSize(