wip, setmaster

This commit is contained in:
maliakal_d 2022-02-23 12:26:37 +01:00
parent ef3df36e55
commit 89edf58f41
7 changed files with 36 additions and 14 deletions

View File

@ -173,6 +173,12 @@ void init_det(py::module &m) {
.def("setFlipRows",
(void (Detector::*)(bool, sls::Positions)) & Detector::setFlipRows,
py::arg(), py::arg() = Positions{})
.def("getMaster",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::getMaster,
py::arg() = Positions{})
.def("setMaster", (void (Detector::*)(bool, int)) & Detector::setMaster,
py::arg(), py::arg() = -1)
.def("isVirtualDetectorServer",
(Result<bool>(Detector::*)(sls::Positions) const) &
Detector::isVirtualDetectorServer,

View File

@ -400,6 +400,7 @@ void setVirtualDefaultModuleConfigurations() {
#else
normal = 1;
#endif
#endif
}
int updateModuleConfiguration() {
@ -420,7 +421,7 @@ int getModuleConfiguration(int *m, int *t, int *n) {
#ifdef VIRTUAL
*m = master;
*t = top;
*n = nomal;
*n = normal;
#else
if (Beb_GetModuleConfiguration(&m, &t, &n) == FAIL) {
initError = FAIL;
@ -553,13 +554,13 @@ int readConfigFile() {
line);
break;
}
if (m != 0 && m != 1)) {
sprintf(initErrorMessage,
"Invalid master argument from on-board server "
"config file. Line:[%s].\n",
line);
break;
}
if (m != 0 && m != 1) {
sprintf(initErrorMessage,
"Invalid master argument from on-board server "
"config file. Line:[%s].\n",
line);
break;
}
if (setMaster(m) == FAIL) {
sprintf(initErrorMessage,
"Could not set master from config file. Line:[%s].\n",

View File

@ -1554,7 +1554,9 @@ int isMaster(int *retval) {
void setTiming(enum timingMode arg) {
if (!isMaster() && arg == AUTO_TIMING)
int master = 0;
isMaster(&master);
if (master && arg == AUTO_TIMING)
arg = TRIGGER_EXPOSURE;
uint32_t addr = CONFIG_REG;

View File

@ -468,7 +468,7 @@ void function_table() {
flist[F_UPDATE_DETECTOR_SERVER] = &update_detector_server;
flist[F_GET_UPDATE_MODE] = &get_update_mode;
flist[F_SET_UPDATE_MODE] = &set_update_mode;
flist[F_SET_MASTER]] = &set_master;
flist[F_SET_MASTER] = &set_master;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -8228,9 +8228,10 @@ int set_master(int file_des) {
} else {
ret = setMaster(arg);
if (ret == FAIL) {
strcpy("Could not set master\n");
strcpy(mess, "Could not set master\n");
LOG(logERROR, (mess));
} else {
int retval = 0;
ret = isMaster(&retval);
if (ret == FAIL) {
strcpy(mess, "Could not get master\n");

View File

@ -196,7 +196,7 @@ class Detector {
/** [Eiger][Mythen3][Gotthard1] via stop server **/
Result<bool> getMaster(Positions pos = {}) const;
/** [Eiger] Set master */
/** [Eiger] Set half module to master and the others to slaves */
void setMaster(bool value, int pos);
Result<bool> isVirtualDetectorServer(Positions pos = {}) const;

View File

@ -1282,6 +1282,12 @@ class CmdProxy {
"interfaces must be set to 2. slsReceiver and slsDetectorGui "
"does not handle.");
INTEGER_COMMAND_VEC_ID_GET(
master, getMaster, setMaster, StringTo<int>,
"[0, 1]\n\t[Eiger] Sets half module to master and "
"others to slaves.\n\t\t [Gotthard][Mythen3][Eiger] "
"Gets if the current module/ half module is master.");
/* acquisition parameters */
INTEGER_COMMAND_SET_NOID_GET_ID(

View File

@ -303,10 +303,16 @@ Result<bool> Detector::getMaster(Positions pos) const {
}
void Detector::setMaster(bool master, int pos) {
if (pos == -1)) {
if (pos == -1 && size() > 1) {
throw RuntimeError("Master can be set only to a single module");
}
pimpl->Parallel(&Module::setMaster, {pos}, value);
// multi mod, set slaves first
if (master && size() > 1) {
pimpl->Parallel(&Module::setMaster, {}, false);
pimpl->Parallel(&Module::setMaster, {pos}, master);
} else {
pimpl->Parallel(&Module::setMaster, {pos}, master);
}
}
Result<bool> Detector::isVirtualDetectorServer(Positions pos) const {