mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
added top
This commit is contained in:
parent
b6d63a8381
commit
34588356e8
@ -1474,6 +1474,19 @@ class Detector(CppDetectorApi):
|
|||||||
def trimval(self, value):
|
def trimval(self, value):
|
||||||
ut.set_using_dict(self.setAllTrimbits, value)
|
ut.set_using_dict(self.setAllTrimbits, value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def master(self):
|
||||||
|
"""
|
||||||
|
[Eiger] Sets half module to master and others to slaves.\n
|
||||||
|
[Gotthard][Gotthard2][Mythen3][Eiger] Gets if the current module/ half module is master.
|
||||||
|
"""
|
||||||
|
return self.getMaster()
|
||||||
|
|
||||||
|
@master.setter
|
||||||
|
def master(self, value):
|
||||||
|
ut.set_using_dict(self.setMaster, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@element
|
@element
|
||||||
def lock(self):
|
def lock(self):
|
||||||
@ -2126,6 +2139,21 @@ class Detector(CppDetectorApi):
|
|||||||
"""
|
"""
|
||||||
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
return ut.reduce_time(self.getMeasuredSubFramePeriod())
|
||||||
|
|
||||||
|
@property
|
||||||
|
@element
|
||||||
|
def top(self):
|
||||||
|
"""[Eiger] Sets half module to top (1), else bottom.
|
||||||
|
|
||||||
|
Note
|
||||||
|
-----
|
||||||
|
Advanced Function!
|
||||||
|
"""
|
||||||
|
return self.getTop()
|
||||||
|
|
||||||
|
@top.setter
|
||||||
|
def top(self, value):
|
||||||
|
ut.set_using_dict(self.setTop, value)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
------------------<<<Jungfrau specific>>>-------------------------
|
------------------<<<Jungfrau specific>>>-------------------------
|
||||||
"""
|
"""
|
||||||
|
@ -1011,6 +1011,14 @@ void init_det(py::module &m) {
|
|||||||
sls::Positions)) &
|
sls::Positions)) &
|
||||||
Detector::setDataStream,
|
Detector::setDataStream,
|
||||||
py::arg(), py::arg(), py::arg() = Positions{})
|
py::arg(), py::arg(), py::arg() = Positions{})
|
||||||
|
.def("getTop",
|
||||||
|
(Result<bool>(Detector::*)(sls::Positions) const) &
|
||||||
|
Detector::getTop,
|
||||||
|
py::arg() = Positions{})
|
||||||
|
.def("setTop",
|
||||||
|
(void (Detector::*)(bool, sls::Positions)) &
|
||||||
|
Detector::setTop,
|
||||||
|
py::arg(), py::arg() = Positions{})
|
||||||
.def("getChipVersion",
|
.def("getChipVersion",
|
||||||
(Result<double>(Detector::*)(sls::Positions) const) &
|
(Result<double>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getChipVersion,
|
Detector::getChipVersion,
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -291,3 +291,5 @@ void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
|||||||
char *checksum, char *serverName);
|
char *checksum, char *serverName);
|
||||||
int get_update_mode(int);
|
int get_update_mode(int);
|
||||||
int set_update_mode(int);
|
int set_update_mode(int);
|
||||||
|
int get_top(int);
|
||||||
|
int set_top(int);
|
@ -470,6 +470,8 @@ void function_table() {
|
|||||||
flist[F_GET_UPDATE_MODE] = &get_update_mode;
|
flist[F_GET_UPDATE_MODE] = &get_update_mode;
|
||||||
flist[F_SET_UPDATE_MODE] = &set_update_mode;
|
flist[F_SET_UPDATE_MODE] = &set_update_mode;
|
||||||
flist[F_SET_MASTER] = &set_master;
|
flist[F_SET_MASTER] = &set_master;
|
||||||
|
flist[F_GET_TOP] = &get_top;
|
||||||
|
flist[F_SET_TOP] = &set_top;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||||
@ -9720,3 +9722,65 @@ int set_update_mode(int file_des) {
|
|||||||
|
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_top(int file_des) {
|
||||||
|
ret = OK;
|
||||||
|
memset(mess, 0, sizeof(mess));
|
||||||
|
int retval = -1;
|
||||||
|
LOG(logDEBUG1, ("Getting top\n"));
|
||||||
|
|
||||||
|
#ifndef EIGERD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
// get only
|
||||||
|
ret = isTop(&retval);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
strcpy(mess, "Could not get Top\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
LOG(logDEBUG1, ("retval top: %d\n", retval));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
|
}
|
||||||
|
|
||||||
|
int set_top(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(logDEBUG1, ("Setting top : %u\n", arg));
|
||||||
|
|
||||||
|
#ifndef EIGERD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
|
||||||
|
// only set
|
||||||
|
if (Server_VerifyLock() == OK) {
|
||||||
|
if (arg != 0 && arg != 1) {
|
||||||
|
ret = FAIL;
|
||||||
|
sprintf(mess, "Could not set top mode. Invalid value: %d. Must be 0 or 1\n", arg);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
ret = setTop(arg == 1 ? OW_TOP : OW_BOTTOM);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
sprintf(mess, "Could not set %s\n", (arg == 1 ? "Top" : "Bottom"));
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
int retval = -1;
|
||||||
|
ret = isTop(&retval);
|
||||||
|
if (ret == FAIL) {
|
||||||
|
strcpy(mess, "Could not get Top mode\n");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
} else {
|
||||||
|
LOG(logDEBUG1, ("retval top: %d\n", retval));
|
||||||
|
validate(&ret, mess, arg, retval, "set top mode", DEC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
}
|
@ -1157,6 +1157,12 @@ class Detector {
|
|||||||
void setDataStream(const defs::portPosition port, const bool enable,
|
void setDataStream(const defs::portPosition port, const bool enable,
|
||||||
Positions pos = {});
|
Positions pos = {});
|
||||||
|
|
||||||
|
/** [Eiger] Advanced */
|
||||||
|
Result<bool> getTop(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** [Eiger] Advanced. Default is hardware default */
|
||||||
|
void setTop(bool value, Positions pos = {});
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
/** @name Jungfrau Specific */
|
/** @name Jungfrau Specific */
|
||||||
|
@ -943,6 +943,7 @@ class CmdProxy {
|
|||||||
{"pulsechip", &CmdProxy::PulseChip},
|
{"pulsechip", &CmdProxy::PulseChip},
|
||||||
{"quad", &CmdProxy::Quad},
|
{"quad", &CmdProxy::Quad},
|
||||||
{"datastream", &CmdProxy::DataStream},
|
{"datastream", &CmdProxy::DataStream},
|
||||||
|
{"top", &CmdProxy::top},
|
||||||
|
|
||||||
/* Jungfrau Specific */
|
/* Jungfrau Specific */
|
||||||
{"chipversion", &CmdProxy::chipversion},
|
{"chipversion", &CmdProxy::chipversion},
|
||||||
@ -1908,6 +1909,11 @@ class CmdProxy {
|
|||||||
"start of acquisition. 0 complete reset, 1 partial reset. Default is "
|
"start of acquisition. 0 complete reset, 1 partial reset. Default is "
|
||||||
"complete reset. Advanced function!");
|
"complete reset. Advanced function!");
|
||||||
|
|
||||||
|
INTEGER_COMMAND_VEC_ID(
|
||||||
|
top, getTop, setTop, StringTo<int>,
|
||||||
|
"[0, 1]\n\t[Eiger] Sets half module to top (1), else bottom.");
|
||||||
|
|
||||||
|
|
||||||
/* Jungfrau Specific */
|
/* Jungfrau Specific */
|
||||||
|
|
||||||
GET_COMMAND(chipversion, getChipVersion,
|
GET_COMMAND(chipversion, getChipVersion,
|
||||||
|
@ -1505,6 +1505,14 @@ void Detector::setDataStream(const defs::portPosition port, const bool enable,
|
|||||||
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
|
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<bool> Detector::getTop(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getTop, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setTop(bool value, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setTop, pos, value);
|
||||||
|
}
|
||||||
|
|
||||||
// Jungfrau Specific
|
// Jungfrau Specific
|
||||||
Result<double> Detector::getChipVersion(Positions pos) const {
|
Result<double> Detector::getChipVersion(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getChipVersion, pos);
|
return pimpl->Parallel(&Module::getChipVersion, pos);
|
||||||
|
@ -1679,6 +1679,15 @@ void Module::setDataStream(const portPosition port, const bool enable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Module::getTop() const {
|
||||||
|
return (
|
||||||
|
!static_cast<bool>(sendToDetector<int>(F_GET_TOP)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setTop(bool value) {
|
||||||
|
sendToDetector<int>(F_SET_TOP, static_cast<int>(value));
|
||||||
|
}
|
||||||
|
|
||||||
// Jungfrau Specific
|
// Jungfrau Specific
|
||||||
double Module::getChipVersion() const {
|
double Module::getChipVersion() const {
|
||||||
return (sendToDetector<int>(F_GET_CHIP_VERSION)) / 10.00;
|
return (sendToDetector<int>(F_GET_CHIP_VERSION)) / 10.00;
|
||||||
|
@ -369,6 +369,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setQuad(const bool enable);
|
void setQuad(const bool enable);
|
||||||
bool getDataStream(const portPosition port) const;
|
bool getDataStream(const portPosition port) const;
|
||||||
void setDataStream(const portPosition port, const bool enable);
|
void setDataStream(const portPosition port, const bool enable);
|
||||||
|
bool getTop() const;
|
||||||
|
void setTop(bool value);
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -630,3 +630,31 @@ TEST_CASE("datastream", "[.cmd]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("datastream", {"left", "1"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("datastream", {"left", "1"}, -1, PUT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("top", "[.cmd]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
if (det_type == defs::EIGER) {
|
||||||
|
auto prev_val = det.getTop();
|
||||||
|
int numModulesTested = 1;
|
||||||
|
if (det.size() > 1) {
|
||||||
|
numModulesTested = 2;
|
||||||
|
}
|
||||||
|
for (int i = 0; i != numModulesTested; ++i) {
|
||||||
|
std::ostringstream oss1, oss2, oss3;
|
||||||
|
proxy.Call("top", {"1"}, i, PUT, oss1);
|
||||||
|
REQUIRE(oss1.str() == "top 1\n");
|
||||||
|
proxy.Call("top", {}, i, GET, oss2);
|
||||||
|
REQUIRE(oss2.str() == "top 1\n");
|
||||||
|
proxy.Call("top", {"0"}, i, PUT, oss3);
|
||||||
|
REQUIRE(oss3.str() == "top 0\n");
|
||||||
|
}
|
||||||
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
det.setTop(prev_val[i], {i});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REQUIRE_THROWS(proxy.Call("top", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("top", {"1"}, -1, PUT));
|
||||||
|
}
|
||||||
|
}
|
@ -259,6 +259,8 @@ enum detFuncs {
|
|||||||
F_GET_UPDATE_MODE,
|
F_GET_UPDATE_MODE,
|
||||||
F_SET_UPDATE_MODE,
|
F_SET_UPDATE_MODE,
|
||||||
F_SET_MASTER,
|
F_SET_MASTER,
|
||||||
|
F_GET_TOP,
|
||||||
|
F_SET_TOP,
|
||||||
|
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||||
@ -621,6 +623,8 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_GET_UPDATE_MODE: return "F_GET_UPDATE_MODE";
|
case F_GET_UPDATE_MODE: return "F_GET_UPDATE_MODE";
|
||||||
case F_SET_UPDATE_MODE: return "F_SET_UPDATE_MODE";
|
case F_SET_UPDATE_MODE: return "F_SET_UPDATE_MODE";
|
||||||
case F_SET_MASTER: return "F_SET_MASTER";
|
case F_SET_MASTER: return "F_SET_MASTER";
|
||||||
|
case F_GET_TOP: return "F_GET_TOP";
|
||||||
|
case F_SET_TOP: return "F_SET_TOP";
|
||||||
|
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user