flippeddatax for jungfrau server

This commit is contained in:
2021-08-05 12:39:04 +02:00
parent acd12bf2fa
commit c5d6dd0dd4
15 changed files with 174 additions and 60 deletions

View File

@ -63,6 +63,7 @@ This document describes the differences between 5.2.0 and 5.1.0 releases.
getAutoCompDisable->getAutoComparatorDisable
setBottom->setFlippedDataAcrossXAxis
3. Firmware Requirements
========================

View File

@ -848,12 +848,13 @@ void init_det(py::module &m) {
(void (Detector::*)(bool, sls::Positions)) &
Detector::setOverFlowMode,
py::arg(), py::arg() = Positions{})
.def("getBottom",
.def("getFlippedDataAcrossXAxis",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getBottom,
Detector::getFlippedDataAcrossXAxis,
py::arg() = Positions{})
.def("setBottom",
(void (Detector::*)(bool, sls::Positions)) & Detector::setBottom,
.def("setFlippedDataAcrossXAxis",
(void (Detector::*)(bool, sls::Positions)) &
Detector::setFlippedDataAcrossXAxis,
py::arg(), py::arg() = Positions{})
.def("getRateCorrection",
(Result<sls::ns>(Detector::*)(sls::Positions) const) &

View File

@ -190,7 +190,7 @@
#define CONFIG_TDMA_TIMESLOT_OFST (25) // 1ms
#define CONFIG_TDMA_TIMESLOT_MSK (0x0000001F << CONFIG_TDMA_TIMESLOT_OFST)
#define CONFIG_BOTTOM_INVERT_STREAM_OFST (30)
#define CONFIG_BOTTOM_INVERT_STREAM_MSK (0x0000001F << CONFIG_BOTTOM_INVERT_STREAM_OFST)
#define CONFIG_BOTTOM_INVERT_STREAM_MSK (0x00000001 << CONFIG_BOTTOM_INVERT_STREAM_OFST)
#define CONFIG_ETHRNT_FLW_CNTRL_OFST (31)
#define CONFIG_ETHRNT_FLW_CNTRL_MSK (0x00000001 << CONFIG_ETHRNT_FLW_CNTRL_OFST)

View File

@ -474,6 +474,7 @@ void setupDetector() {
// temp threshold and reset event
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
setTemperatureEvent(0);
setFlippedDataAcrossXAxis(0);
}
int resetToDefaultDacs(int hardReset) {
@ -2002,6 +2003,25 @@ void alignDeserializer() {
bus_r(ADC_DSRLZR_3_REG) & (~(ADC_DSRLZR_3_RFRSH_ALGNMNT_MSK)));
}
int getFlippedDataAcrossXAxis() {
return ((bus_r(CONFIG_REG) & CONFIG_BOTTOM_INVERT_STREAM_MSK) >>
CONFIG_BOTTOM_INVERT_STREAM_OFST);
}
void setFlippedDataAcrossXAxis(int arg) {
if (arg >= 0) {
if (arg == 0) {
LOG(logINFO, ("Switching off bottom flipping\n"));
bus_w(CONFIG_REG,
bus_r(CONFIG_REG) & ~CONFIG_BOTTOM_INVERT_STREAM_MSK);
} else {
LOG(logINFO, ("Switching on bottom flipping\n"));
bus_w(CONFIG_REG,
bus_r(CONFIG_REG) | CONFIG_BOTTOM_INVERT_STREAM_MSK);
}
}
}
int getTenGigaFlowControl() {
return ((bus_r(CONFIG_REG) & CONFIG_ETHRNT_FLW_CNTRL_MSK) >>
CONFIG_ETHRNT_FLW_CNTRL_OFST);

View File

@ -460,6 +460,8 @@ int setThresholdTemperature(int val);
int setTemperatureControl(int val);
int setTemperatureEvent(int val);
void alignDeserializer();
int getFlippedDataAcrossXAxis();
void setFlippedDataAcrossXAxis(int arg);
// eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter
#elif EIGERD

View File

@ -260,4 +260,6 @@ int set_default_dac(int);
int get_gain_mode(int);
int set_gain_mode(int);
int get_comp_disable_time(int);
int set_comp_disable_time(int);
int set_comp_disable_time(int);
int get_flipped_data_x(int);
int set_flipped_data_x(int);

View File

@ -386,6 +386,8 @@ void function_table() {
flist[F_SET_GAIN_MODE] = &set_gain_mode;
flist[F_GET_COMP_DISABLE_TIME] = &get_comp_disable_time;
flist[F_SET_COMP_DISABLE_TIME] = &set_comp_disable_time;
flist[F_GET_FLIPPED_DATA_X] = &get_flipped_data_x;
flist[F_SET_FLIPPED_DATA_X] = &set_flipped_data_x;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -8675,4 +8677,65 @@ int set_comp_disable_time(int file_des) {
}
#endif
return Server_SendResult(file_des, INT64, NULL, 0);
}
}
int get_flipped_data_x(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int retval = -1;
LOG(logDEBUG1, ("Getting flipped data x\n"));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// get only
retval = getFlippedDataAcrossXAxis();
LOG(logDEBUG1, ("flippeddatax retval: %u\n", retval));
#endif
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
}
int set_flipped_data_x(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logINFO, ("Setting flipped data x: %u\n", (int)arg));
#ifndef JUNGFRAUD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
if (arg != 0 && arg != 1) {
ret = FAIL;
sprintf(mess,
"Could not set flipped data x. Invalid argument %d.\n",
arg);
LOG(logERROR, (mess));
}
// only for HW 2.0 (version = 3)
else if (isHardwareVersion2()) {
ret = FAIL;
strcpy(mess, "Could not set flipped data x. Only available for "
"Hardware Board version 2.0.\n");
LOG(logERROR, (mess));
} else if (getNumberofUDPInterfaces() == 1) {
ret = FAIL;
strcpy(mess, "Could not set flipped data x. Number of udp "
"interfaces is still 1.\n");
LOG(logERROR, (mess));
} else {
setFlippedDataAcrossXAxis(arg);
int retval = getFlippedDataAcrossXAxis();
LOG(logDEBUG1, ("flippeddatax retval: %u\n", retval));
validate(&ret, mess, arg, retval, "set flipped data x", DEC);
}
}
#endif
return Server_SendResult(file_des, INT32, NULL, 0);
}

View File

@ -172,6 +172,15 @@ class Detector {
*/
void setGapPixelsinCallback(const bool enable);
/** [Eiger][Jungfrau] */
Result<bool> getFlippedDataAcrossXAxis(Positions pos = {}) const;
/** [Eiger] flips across x Axis paramater sent to slsreceiver to send to gui
* (via zmq) to flip bottom [Jungfrau] flips data across x Axis in the
* detector itself. slsReceiver and slsDetectorGui does not handle.
*/
void setFlippedDataAcrossXAxis(bool value, Positions pos = {});
Result<bool> isVirtualDetectorServer(Positions pos = {}) const;
///@{
@ -995,12 +1004,6 @@ class Detector {
/** [Eiger] Overflow in 32 bit mode. Default is disabled.*/
void setOverFlowMode(bool value, Positions pos = {});
/** [Eiger] */
Result<bool> getBottom(Positions pos = {}) const;
/** [Eiger] for client call back (gui) purposes to flip bottom image */
void setBottom(bool value, Positions pos = {});
/** [Eiger] deadtime in ns, 0 = disabled */
Result<ns> getRateCorrection(Positions pos = {}) const;

View File

@ -769,6 +769,7 @@ class CmdProxy {
{"trimval", &CmdProxy::trimval},
{"trimen", &CmdProxy::TrimEnergies},
{"gappixels", &CmdProxy::GapPixels},
{"flippeddatax", &CmdProxy::flippeddatax},
/* acquisition parameters */
{"acquire", &CmdProxy::Acquire},
@ -906,7 +907,6 @@ class CmdProxy {
{"subexptime", &CmdProxy::subexptime},
{"subdeadtime", &CmdProxy::subdeadtime},
{"overflow", &CmdProxy::overflow},
{"flippeddatax", &CmdProxy::flippeddatax},
{"ratecorr", &CmdProxy::RateCorrection},
{"readnlines", &CmdProxy::readnlines},
{"interruptsubframe", &CmdProxy::interruptsubframe},
@ -1233,6 +1233,16 @@ class CmdProxy {
"[n_trimval]\n\t[Eiger][Mythen3] All trimbits set to this "
"value. Returns -1 if all trimbits are different values.");
INTEGER_COMMAND_VEC_ID(
flippeddatax, getFlippedDataAcrossXAxis, setFlippedDataAcrossXAxis,
StringTo<int>,
"[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 "
"is top. Used to let Gui (via zmq from receiver) know to flip the "
"bottom image over the x axis. Files are not written without the flip "
"however.\n\t[Jungfrau] If enabled, the bottom is flipped across the x "
"axis from the detector. The slsReceiver nor the Gui handles this "
"parameter.");
/* acquisition parameters */
INTEGER_COMMAND_SET_NOID_GET_ID(
@ -1778,13 +1788,6 @@ class CmdProxy {
"[0, 1]\n\t[Eiger] Enable or disable show overflow flag in "
"32 bit mode. Default is disabled.");
INTEGER_COMMAND_VEC_ID(
flippeddatax, getBottom, setBottom, StringTo<int>,
"[0, 1]\n\t[Eiger] Top or Bottom Half of Eiger module. 1 is bottom, 0 "
"is top. Used to let Gui (via zmq from receiver) know to flip the "
"bottom image over the x axis. Files are not written without the flip "
"however.");
INTEGER_COMMAND_VEC_ID(
readnlines, getPartialReadout, setPartialReadout, StringTo<int>,
"[1 - 256]\n\t[Eiger] Number of rows to readout per half module "

View File

@ -279,6 +279,14 @@ void Detector::setGapPixelsinCallback(bool enable) {
pimpl->setGapPixelsinCallback(enable);
}
Result<bool> Detector::getFlippedDataAcrossXAxis(Positions pos) const {
return pimpl->Parallel(&Module::getFlippedDataAcrossXAxis, pos);
}
void Detector::setFlippedDataAcrossXAxis(bool value, Positions pos) {
pimpl->Parallel(&Module::setFlippedDataAcrossXAxis, pos, value);
}
Result<bool> Detector::isVirtualDetectorServer(Positions pos) const {
return pimpl->Parallel(&Module::isVirtualDetectorServer, pos);
}
@ -1304,14 +1312,6 @@ void Detector::setOverFlowMode(bool value, Positions pos) {
pimpl->Parallel(&Module::setOverFlowMode, pos, value);
}
Result<bool> Detector::getBottom(Positions pos) const {
return pimpl->Parallel(&Module::getFlippedDataX, pos);
}
void Detector::setBottom(bool value, Positions pos) {
pimpl->Parallel(&Module::setFlippedDataX, pos, value);
}
Result<ns> Detector::getRateCorrection(Positions pos) const {
return pimpl->Parallel(&Module::getRateCorrection, pos);
}

View File

@ -458,6 +458,22 @@ int Module::setTrimEn(const std::vector<int> &energies) {
return shm()->trimEnergies.size();
}
bool Module::getFlippedDataAcrossXAxis() const {
if (shm()->myDetectorType == EIGER) {
return sendToReceiver<int>(F_SET_FLIPPED_DATA_RECEIVER, GET_FLAG);
}
return sendToDetector<int>(F_GET_FLIPPED_DATA_X);
}
void Module::setFlippedDataAcrossXAxis(bool value) {
if (shm()->myDetectorType == EIGER) {
sendToReceiver<int>(F_SET_FLIPPED_DATA_RECEIVER,
static_cast<int>(value));
} else {
sendToDetector(F_SET_FLIPPED_DATA_X, static_cast<int>(value), nullptr);
}
}
bool Module::isVirtualDetectorServer() const {
return sendToDetector<int>(F_IS_VIRTUAL);
}
@ -1398,14 +1414,6 @@ void Module::setOverFlowMode(const bool enable) {
sendToDetector(F_SET_OVERFLOW_MODE, static_cast<int>(enable), nullptr);
}
bool Module::getFlippedDataX() const {
return sendToReceiver<int>(F_SET_FLIPPED_DATA_RECEIVER, GET_FLAG);
}
void Module::setFlippedDataX(bool value) {
sendToReceiver<int>(F_SET_FLIPPED_DATA_RECEIVER, static_cast<int>(value));
}
int64_t Module::getRateCorrection() const {
return sendToDetector<int64_t>(F_GET_RATE_CORRECT);
}

View File

@ -114,6 +114,8 @@ class Module : public virtual slsDetectorDefs {
void setAllTrimbits(int val);
std::vector<int> getTrimEn() const;
int setTrimEn(const std::vector<int> &energies = {});
bool getFlippedDataAcrossXAxis() const;
void setFlippedDataAcrossXAxis(bool value);
bool isVirtualDetectorServer() const;
/**************************************************
@ -323,8 +325,6 @@ class Module : public virtual slsDetectorDefs {
void setSubDeadTime(int64_t value);
bool getOverFlowMode() const;
void setOverFlowMode(const bool enable);
bool getFlippedDataX() const;
void setFlippedDataX(bool value);
int64_t getRateCorrection() const;
void setDefaultRateCorrection();
void setRateCorrection(int64_t t = 0);

View File

@ -340,27 +340,6 @@ TEST_CASE("overflow", "[.cmd]") {
}
}
TEST_CASE("flippeddatax", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) {
auto previous = det.getBottom();
std::ostringstream oss1, oss2, oss3;
proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "flippeddatax 1\n");
proxy.Call("flippeddatax", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "flippeddatax 1\n");
proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "flippeddatax 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setBottom(previous[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET));
}
}
TEST_CASE("ratecorr", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -510,6 +510,34 @@ TEST_CASE("gappixels", "[.cmd]") {
}
}
TEST_CASE("flippeddatax", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::JUNGFRAU) {
auto previous = det.getFlippedDataAcrossXAxis();
auto previous_numudp = det.getNumberofUDPInterfaces();
if (det_type == defs::JUNGFRAU) {
det.setNumberofUDPInterfaces(2);
}
std::ostringstream oss1, oss2, oss3;
proxy.Call("flippeddatax", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "flippeddatax 1\n");
proxy.Call("flippeddatax", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "flippeddatax 1\n");
proxy.Call("flippeddatax", {"0"}, -1, PUT, oss3);
REQUIRE(oss3.str() == "flippeddatax 0\n");
for (int i = 0; i != det.size(); ++i) {
det.setFlippedDataAcrossXAxis(previous[i], {i});
if (det_type == defs::JUNGFRAU) {
det.setNumberofUDPInterfaces(previous_numudp[i], {i});
}
}
} else {
REQUIRE_THROWS(proxy.Call("flippeddatax", {}, -1, GET));
}
}
/* acquisition parameters */
// acquire: not testing

View File

@ -237,6 +237,8 @@ enum detFuncs {
F_SET_GAIN_MODE,
F_GET_COMP_DISABLE_TIME,
F_SET_COMP_DISABLE_TIME,
F_GET_FLIPPED_DATA_X,
F_SET_FLIPPED_DATA_X,
NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
@ -580,6 +582,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SET_GAIN_MODE: return "F_SET_GAIN_MODE";
case F_GET_COMP_DISABLE_TIME: return "F_GET_COMP_DISABLE_TIME";
case F_SET_COMP_DISABLE_TIME: return "F_SET_COMP_DISABLE_TIME";
case F_GET_FLIPPED_DATA_X: return "F_GET_FLIPPED_DATA_X";
case F_SET_FLIPPED_DATA_X: return "F_SET_FLIPPED_DATA_X";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";