mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-08 19:10:42 +02:00
wip to change to enum for portposition
This commit is contained in:
parent
c6aaf2f8b1
commit
ec7ba7c508
@ -451,19 +451,15 @@ int Beb_GetActivate(int *retval) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_SetDataStream(int left, int enable) {
|
||||
int Beb_SetDataStream(enum portPositiion port, int enable) {
|
||||
if (!Beb_activated) {
|
||||
if (left) {
|
||||
if (port == LEFT) {
|
||||
Beb_deactivated_left_datastream = enable;
|
||||
} else {
|
||||
Beb_deactivated_right_datastream = enable;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (left < 0) {
|
||||
LOG(logERROR, ("Invalid left value\n"));
|
||||
return 0;
|
||||
}
|
||||
if (enable < 0) {
|
||||
LOG(logERROR, ("Invalid enable value\n"));
|
||||
return 0;
|
||||
@ -475,8 +471,8 @@ int Beb_SetDataStream(int left, int enable) {
|
||||
return 0;
|
||||
} else {
|
||||
u_int32_t reg = XPAR_GPIO_P15_STREAMING_REG;
|
||||
u_int32_t mask =
|
||||
(left ? XPAR_GPIO_LFT_STRM_DSBL_MSK : XPAR_GPIO_RGHT_STRM_DSBL_MSK);
|
||||
u_int32_t mask = (port == LEFT ? XPAR_GPIO_LFT_STRM_DSBL_MSK
|
||||
: XPAR_GPIO_RGHT_STRM_DSBL_MSK);
|
||||
|
||||
u_int32_t value = Beb_Read32(csp0base, reg);
|
||||
// disabling in firmware
|
||||
@ -488,8 +484,8 @@ int Beb_SetDataStream(int left, int enable) {
|
||||
if (retval != value) {
|
||||
LOG(logERROR,
|
||||
("Could not %s %s fpga datastream. Wrote 0x%x, read 0x%x\n",
|
||||
(enable ? "enable" : "disable"), (left ? "left" : "right"),
|
||||
value, retval));
|
||||
(enable ? "enable" : "disable"),
|
||||
(port == LEFT ? "left" : "right"), value, retval));
|
||||
Beb_close(fd, csp0base);
|
||||
}
|
||||
}
|
||||
@ -497,9 +493,9 @@ int Beb_SetDataStream(int left, int enable) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Beb_GetDataStream(int left, int *retval) {
|
||||
int Beb_GetDataStream(enum portPositiion port, int *retval) {
|
||||
if (!Beb_activated) {
|
||||
if (left) {
|
||||
if (port == LEFT) {
|
||||
return Beb_deactivated_left_datastream;
|
||||
} else {
|
||||
return Beb_deactivated_right_datastream;
|
||||
@ -512,8 +508,8 @@ int Beb_GetDataStream(int left, int *retval) {
|
||||
return 0;
|
||||
} else {
|
||||
u_int32_t reg = XPAR_GPIO_P15_STREAMING_REG;
|
||||
u_int32_t mask =
|
||||
(left ? XPAR_GPIO_LFT_STRM_DSBL_MSK : XPAR_GPIO_RGHT_STRM_DSBL_MSK);
|
||||
u_int32_t mask = (port == LEFT ? XPAR_GPIO_LFT_STRM_DSBL_MSK
|
||||
: XPAR_GPIO_RGHT_STRM_DSBL_MSK);
|
||||
|
||||
u_int32_t value = Beb_Read32(csp0base, reg);
|
||||
// disabling in firmware
|
||||
|
@ -41,8 +41,8 @@ int Beb_SetTop(enum TOPINDEX ind);
|
||||
int Beb_SetMaster(enum MASTERINDEX ind);
|
||||
int Beb_SetActivate(int enable);
|
||||
int Beb_GetActivate(int *retval);
|
||||
int Beb_SetDataStream(int left, int enable);
|
||||
int Beb_GetDataStream(int left, int *retval);
|
||||
int Beb_SetDataStream(enum portPositiion port, int enable);
|
||||
int Beb_GetDataStream(ienum portPositiion port, int *retval);
|
||||
int Beb_Set32bitOverflow(int val);
|
||||
|
||||
int Beb_GetTenGigaFlowControl();
|
||||
|
@ -2051,38 +2051,38 @@ int getActivate(int *retval) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int setDataStream(int left, int enable) {
|
||||
int setDataStream(enum portPositiion port, int enable) {
|
||||
if (enable < 0) {
|
||||
LOG(logERROR, ("Invalid setDataStream enable argument: %d\n", enable));
|
||||
return FAIL;
|
||||
}
|
||||
if (left < 0) {
|
||||
LOG(logERROR, ("Invalid setDataStream left argument: %d\n", left));
|
||||
LOG(logERROR, ("Invalid setDataStream port argument: %d\n", port));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (left) {
|
||||
if (port == LEFT) {
|
||||
eiger_virtual_left_datastream = enable;
|
||||
} else {
|
||||
eiger_virtual_right_datastream = enable;
|
||||
}
|
||||
#else
|
||||
if (!Beb_SetDataStream(left, enable)) {
|
||||
if (!Beb_SetDataStream(port, enable)) {
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getDataStream(int left, int *retval) {
|
||||
int getDataStream(enum portPositiion port, int *retval) {
|
||||
#ifdef VIRTUAL
|
||||
if (left) {
|
||||
if (port == LEFT) {
|
||||
*retval = eiger_virtual_left_datastream;
|
||||
} else {
|
||||
*retval = eiger_virtual_right_datastream;
|
||||
}
|
||||
#else
|
||||
if (!Beb_GetDataStream(left, retval)) {
|
||||
if (!Beb_GetDataStream(port, retval)) {
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
|
@ -474,8 +474,8 @@ int getAllTrimbits();
|
||||
int getBebFPGATemp();
|
||||
int setActivate(int enable);
|
||||
int getActivate(int *retval);
|
||||
int getDataStream(int left, int *retval);
|
||||
int setDataStream(int left, int enable);
|
||||
int getDataStream(enum portPositiion port, int *retval);
|
||||
int setDataStream(enum portPositiion port, int enable);
|
||||
|
||||
// gotthard specific - adc phase
|
||||
#elif GOTTHARDD
|
||||
|
@ -7058,7 +7058,7 @@ int get_receiver_parameters(int file_des) {
|
||||
// data stream left
|
||||
#ifdef EIGERD
|
||||
i32 = 0;
|
||||
getDataStream(1, &i32);
|
||||
getDataStream(LEFT, &i32);
|
||||
#else
|
||||
i32 = 0;
|
||||
#endif
|
||||
@ -7069,7 +7069,7 @@ int get_receiver_parameters(int file_des) {
|
||||
// data stream right
|
||||
#ifdef EIGERD
|
||||
i32 = 0;
|
||||
getDataStream(0, &i32);
|
||||
getDataStream(RIGHT, &i32);
|
||||
#else
|
||||
i32 = 0;
|
||||
#endif
|
||||
@ -8251,33 +8251,31 @@ int get_gain_caps(int file_des) {
|
||||
int get_datastream(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
enum portPosition arg = LEFT;
|
||||
int retval = -1;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
|
||||
return printSocketReadError();
|
||||
LOG(logDEBUG1, ("Getting data stream enable [left:%d]\n", arg));
|
||||
LOG(logDEBUG1, ("Getting data stream enable [port:%d]\n", arg));
|
||||
|
||||
#ifndef EIGERD
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get only
|
||||
int leftFpga = arg;
|
||||
if (leftFpga != 0 && leftFpga != 1) {
|
||||
if (arg != LEFT && arg != RIGHT) {
|
||||
ret = FAIL;
|
||||
sprintf(
|
||||
mess,
|
||||
"Could not get data stream enable. Invalid side %d. Left argument"
|
||||
"should be 0 or 1.\n",
|
||||
leftFpga);
|
||||
"Could not get data stream enable. Invalid port position %d. Only left and right allowed\n",
|
||||
arg);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = getDataStream(leftFpga, &retval);
|
||||
ret = getDataStream(arg, &retval);
|
||||
LOG(logDEBUG1, ("datastream (%s) retval: %u\n",
|
||||
(leftFpga ? "left" : "right"), retval));
|
||||
(arg == LEFT? "left" : "right"), retval));
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not get %s data stream enable.\n",
|
||||
(leftFpga ? "left" : "right"));
|
||||
(arg == LEFT ? "left" : "right"));
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
@ -8300,39 +8298,38 @@ int set_datastream(int file_des) {
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
int leftFpga = args[0];
|
||||
enum portPosition port = static_cast<portPosition>(args[0]);
|
||||
int enable = args[1];
|
||||
char msg[256];
|
||||
memset(msg, 0, sizeof(msg));
|
||||
sprintf(msg, "%s %s fpga datastream", (enable ? "enable" : "disable"),
|
||||
(leftFpga ? "left" : "right"));
|
||||
if (leftFpga != 0 && leftFpga != 1) {
|
||||
(port == LEFT ? "left" : "right"));
|
||||
if (port != LEFT && port != RIGHT) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,
|
||||
"Could not %s. Invalid side %d. Left argument should be 0 "
|
||||
"or 1.\n",
|
||||
msg, leftFpga);
|
||||
"Could not %s. Invalid port position %d. Only left and right allowed\n",
|
||||
msg, port);
|
||||
LOG(logERROR, (mess));
|
||||
} else if (enable != 0 && enable != 1) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not %s. Invalid enable %d. \n", msg, enable);
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
ret = setDataStream(leftFpga, enable);
|
||||
ret = setDataStream(port, enable);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not %s\n", msg);
|
||||
LOG(logERROR, (mess));
|
||||
} /*else {
|
||||
} else {
|
||||
int retval = -1;
|
||||
ret = getDataStream(leftFpga, &retval);
|
||||
ret = getDataStream(port, &retval);
|
||||
LOG(logDEBUG1, ("%s retval: %u\n", msg, retval));
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not get %s data stream enable.\n",
|
||||
(leftFpga ? "left" : "right"));
|
||||
(port == LEFT ? "left" : "right"));
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
validate(&ret, mess, enable, retval, msg, DEC);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1062,11 +1062,13 @@ class Detector {
|
||||
void setQuad(const bool enable);
|
||||
|
||||
/** [Eiger] */
|
||||
Result<bool> getDataStream(const bool left, Positions pos = {}) const;
|
||||
Result<bool> getDataStream(const portPosition port,
|
||||
Positions pos = {}) const;
|
||||
|
||||
/** [Eiger] enable or disable data streaming from left or right of detector
|
||||
*/
|
||||
void setDataStream(const bool left, const bool enable, Positions pos = {});
|
||||
void setDataStream(const portPosition port, const bool enable,
|
||||
Positions pos = {});
|
||||
|
||||
///@{
|
||||
|
||||
|
@ -1603,29 +1603,15 @@ std::string CmdProxy::DataStream(int action) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
// TODO, enum for "left and right?"
|
||||
if (args[0] == "left") {
|
||||
left = true;
|
||||
} else if (args[0] == "right") {
|
||||
left = false;
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown data argument " + args[0]);
|
||||
}
|
||||
auto t = det->getDataStream(left, std::vector<int>{det_id});
|
||||
auto t = det->getDataStream(StringTo<defs::portPosition>(args[0]),
|
||||
std::vector<int>{det_id});
|
||||
os << OutString(t) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 2) {
|
||||
WrongNumberOfParameters(2);
|
||||
}
|
||||
if (args[0] == "left") {
|
||||
left = true;
|
||||
} else if (args[0] == "right") {
|
||||
left = false;
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown data argument " + args[0]);
|
||||
}
|
||||
det->setDataStream(left, StringTo<bool>(args[1]),
|
||||
std::vector<int>{det_id});
|
||||
det->setDataStream(StringTo<defs::portPosition>(args[0]),
|
||||
StringTo<bool>(args[1]), std::vector<int>{det_id});
|
||||
os << args << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
|
@ -1369,13 +1369,14 @@ void Detector::setQuad(const bool enable) {
|
||||
pimpl->Parallel(&Module::setQuad, {}, enable);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getDataStream(const bool left, Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDataStream, pos, left);
|
||||
Result<bool> Detector::getDataStream(const portPosition port,
|
||||
Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDataStream, pos, port);
|
||||
}
|
||||
|
||||
void Detector::setDataStream(const bool left, const bool enable,
|
||||
void Detector::setDataStream(const portPosition port, const bool enable,
|
||||
Positions pos) {
|
||||
pimpl->Parallel(&Module::setDataStream, pos, left, enable);
|
||||
pimpl->Parallel(&Module::setDataStream, pos, port, enable);
|
||||
}
|
||||
|
||||
// Jungfrau Specific
|
||||
|
@ -1509,12 +1509,12 @@ void Module::setQuad(const bool enable) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Module::getDataStream(const bool left) const {
|
||||
return sendToDetector<int>(F_GET_DATASTREAM, static_cast<int>(left));
|
||||
bool Module::getDataStream(const portPosition port) const {
|
||||
return sendToDetector<int>(F_GET_DATASTREAM, static_cast<int>(port));
|
||||
}
|
||||
|
||||
void Module::setDataStream(const bool left, const bool enable) {
|
||||
int args[]{static_cast<int>(left), static_cast<int>(enable)};
|
||||
void Module::setDataStream(const portPosition port, const bool enable) {
|
||||
int args[]{static_cast<int>(port), static_cast<int>(enable)};
|
||||
sendToDetector(F_SET_DATASTREAM, args, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_RECEIVER_SET_DATASTREAM, args, nullptr);
|
||||
|
@ -343,8 +343,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
void pulseChip(int n_pulses = 0);
|
||||
bool getQuad() const;
|
||||
void setQuad(const bool enable);
|
||||
bool getDataStream(const bool left) const;
|
||||
void setDataStream(const bool left, const bool enable);
|
||||
bool getDataStream(const portPosition port) const;
|
||||
void setDataStream(const portPosition port, const bool enable);
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
|
@ -1703,14 +1703,21 @@ int ClientInterface::set_all_threshold(Interface &socket) {
|
||||
int ClientInterface::set_detector_datastream(Interface &socket) {
|
||||
int args[2]{-1, -1};
|
||||
socket.Receive(args);
|
||||
bool left = static_cast<int>(args[0]);
|
||||
portPosition port = static_cast<portPosition>(args[0]);
|
||||
switch (port) {
|
||||
case LEFT:
|
||||
case RIGHT:
|
||||
break;
|
||||
default:
|
||||
throw RuntimeError("Invalid port type");
|
||||
}
|
||||
bool enable = static_cast<int>(args[1]);
|
||||
LOG(logDEBUG1) << "Setting datstream " << (left ? "left" : "right")
|
||||
<< ") to " << sls::ToString(enable);
|
||||
LOG(logDEBUG1) << "Setting datastream (" << sls::ToString(port) << ") to "
|
||||
<< sls::ToString(enable);
|
||||
if (myDetectorType != EIGER)
|
||||
functionNotImplemented();
|
||||
verifyIdle(socket);
|
||||
impl()->setDetectorDataStream(left, enable);
|
||||
impl()->setDetectorDataStream(port, enable);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
|
@ -1508,15 +1508,17 @@ void Implementation::setActivate(bool enable) {
|
||||
LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
bool Implementation::getDetectorDataStream(const bool leftPort) const {
|
||||
int index = (leftPort ? 0 : 1);
|
||||
bool Implementation::getDetectorDataStream(const portPosition port) const {
|
||||
int index = (port == LEFT ? 0 : 1);
|
||||
return detectorDataStream[index];
|
||||
}
|
||||
|
||||
void Implementation::setDetectorDataStream(const bool leftPort, const bool enable) {
|
||||
int index = (leftPort ? 0 : 1);
|
||||
void Implementation::setDetectorDataStream(const portPosition port,
|
||||
const bool enable) {
|
||||
int index = (port == LEFT ? 0 : 1);
|
||||
detectorDataStream[index] = enable;
|
||||
LOG(logINFO) << "Detector datastream (" << (leftPort ? "Left" : "Right") << " Port): " << sls::ToString(detectorDataStream[index]);
|
||||
LOG(logINFO) << "Detector datastream (" << sls::ToString(port)
|
||||
<< " Port): " << sls::ToString(detectorDataStream[index]);
|
||||
}
|
||||
|
||||
bool Implementation::getDeactivatedPadding() const {
|
||||
|
@ -211,10 +211,10 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
/** [Eiger] If deactivated, receiver will create dummy data if deactivated
|
||||
* padding is enabled (as it will receive nothing from detector) */
|
||||
void setActivate(const bool enable);
|
||||
bool getDetectorDataStream(const bool leftPort) const;
|
||||
bool getDetectorDataStream(const portPosition port) const;
|
||||
/** [Eiger] If datastream is disabled, receiver will create dummy data if deactivated
|
||||
* padding for that port is enabled (as it will receive nothing from detector) */
|
||||
void setDetectorDataStream(const bool leftPort, const bool enable);
|
||||
void setDetectorDataStream(const portPosition port, const bool enable);
|
||||
bool getDeactivatedPadding() const;
|
||||
/* [Eiger] */
|
||||
void setDeactivatedPadding(const bool enable);
|
||||
|
@ -37,6 +37,7 @@ std::string ToString(const std::vector<defs::dacIndex> &vec);
|
||||
std::string ToString(const defs::burstMode s);
|
||||
std::string ToString(const defs::timingSourceType s);
|
||||
std::string ToString(const defs::M3_GainCaps s);
|
||||
std::string ToString(const defs::portPosition s);
|
||||
|
||||
std::string ToString(const slsDetectorDefs::xy &coord);
|
||||
std::ostream &operator<<(std::ostream &os, const slsDetectorDefs::xy &coord);
|
||||
@ -299,6 +300,7 @@ template <> defs::dacIndex StringTo(const std::string &s);
|
||||
template <> defs::burstMode StringTo(const std::string &s);
|
||||
template <> defs::timingSourceType StringTo(const std::string &s);
|
||||
template <> defs::M3_GainCaps StringTo(const std::string &s);
|
||||
template <> defs::portPosition StringTo(const std::string &s);
|
||||
|
||||
template <> uint32_t StringTo(const std::string &s);
|
||||
template <> uint64_t StringTo(const std::string &s);
|
||||
|
@ -401,6 +401,8 @@ typedef struct {
|
||||
M3_C15pre = 1 << 14,
|
||||
};
|
||||
|
||||
enum portPosition { LEFT, RIGHT, TOP, BOTTOM };
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/** scan structure */
|
||||
|
@ -521,6 +521,21 @@ std::string ToString(const defs::timingSourceType s) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ToString(const defs::portPosition s) {
|
||||
switch (s) {
|
||||
case defs::LEFT:
|
||||
return std::string("left");
|
||||
case defs::RIGHT:
|
||||
return std::string("right");
|
||||
case defs::TOP:
|
||||
return std::string("top");
|
||||
case defs::BOTTOM:
|
||||
return std::string("bottom");
|
||||
default:
|
||||
return std::string("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &ToString(const std::string &s) { return s; }
|
||||
|
||||
template <> defs::detectorType StringTo(const std::string &s) {
|
||||
@ -861,23 +876,25 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
|
||||
throw sls::RuntimeError("Unknown timing source type " + s);
|
||||
}
|
||||
|
||||
template <> defs::M3_GainCaps StringTo(const std::string &s){
|
||||
if (s == "C10pre")
|
||||
return defs::M3_C10pre;
|
||||
if (s == "C15sh")
|
||||
return defs::M3_C15sh;
|
||||
if (s == "C30sh")
|
||||
return defs::M3_C30sh;
|
||||
if (s == "C50sh")
|
||||
return defs::M3_C50sh;
|
||||
if (s == "C225ACsh")
|
||||
return defs::M3_C225ACsh;
|
||||
if (s == "C15pre")
|
||||
return defs::M3_C15pre;
|
||||
throw sls::RuntimeError("Unknown gain cap " + s);
|
||||
|
||||
template <> defs::portPosition StringTo(const std::string &s) {
|
||||
if (s == "left")
|
||||
return defs::LEFT;
|
||||
if (s == "right")
|
||||
return defs::RIGHT;
|
||||
if (s == "top")
|
||||
return defs::TOP;
|
||||
if (s == "bottom")
|
||||
return defs::BOTTOM;
|
||||
throw sls::RuntimeError("Unknown port position " + s);
|
||||
}
|
||||
|
||||
template <> defs::timingSourceType StringTo(const std::string &s) {
|
||||
if (s == "internal")
|
||||
return defs::TIMING_INTERNAL;
|
||||
if (s == "external")
|
||||
return defs::TIMING_EXTERNAL;
|
||||
throw sls::RuntimeError("Unknown timing source type " + s);
|
||||
}
|
||||
|
||||
std::string ToString(defs::M3_GainCaps s){
|
||||
std::ostringstream os;
|
||||
|
Loading…
x
Reference in New Issue
Block a user