added enum left right top bottom

This commit is contained in:
maliakal_d 2021-07-21 09:25:27 +02:00
parent ec7ba7c508
commit 8ba37e99a7
9 changed files with 50 additions and 48 deletions

View File

@ -2051,15 +2051,11 @@ int getActivate(int *retval) {
return OK; return OK;
} }
int setDataStream(enum portPositiion port, int enable) { int setDataStream(enum portPosition port, int enable) {
if (enable < 0) { if (enable < 0) {
LOG(logERROR, ("Invalid setDataStream enable argument: %d\n", enable)); LOG(logERROR, ("Invalid setDataStream enable argument: %d\n", enable));
return FAIL; return FAIL;
} }
if (left < 0) {
LOG(logERROR, ("Invalid setDataStream port argument: %d\n", port));
return FAIL;
}
#ifdef VIRTUAL #ifdef VIRTUAL
if (port == LEFT) { if (port == LEFT) {
eiger_virtual_left_datastream = enable; eiger_virtual_left_datastream = enable;
@ -2074,7 +2070,7 @@ int setDataStream(enum portPositiion port, int enable) {
return OK; return OK;
} }
int getDataStream(enum portPositiion port, int *retval) { int getDataStream(enum portPosition port, int *retval) {
#ifdef VIRTUAL #ifdef VIRTUAL
if (port == LEFT) { if (port == LEFT) {
*retval = eiger_virtual_left_datastream; *retval = eiger_virtual_left_datastream;

View File

@ -474,8 +474,8 @@ int getAllTrimbits();
int getBebFPGATemp(); int getBebFPGATemp();
int setActivate(int enable); int setActivate(int enable);
int getActivate(int *retval); int getActivate(int *retval);
int getDataStream(enum portPositiion port, int *retval); int getDataStream(enum portPosition port, int *retval);
int setDataStream(enum portPositiion port, int enable); int setDataStream(enum portPosition port, int enable);
// gotthard specific - adc phase // gotthard specific - adc phase
#elif GOTTHARDD #elif GOTTHARDD

View File

@ -8298,7 +8298,7 @@ int set_datastream(int file_des) {
#else #else
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
enum portPosition port = static_cast<portPosition>(args[0]); enum portPosition port = args[0];
int enable = args[1]; int enable = args[1];
char msg[256]; char msg[256];
memset(msg, 0, sizeof(msg)); memset(msg, 0, sizeof(msg));

View File

@ -1062,12 +1062,12 @@ class Detector {
void setQuad(const bool enable); void setQuad(const bool enable);
/** [Eiger] */ /** [Eiger] */
Result<bool> getDataStream(const portPosition port, Result<bool> getDataStream(const defs::portPosition port,
Positions pos = {}) const; Positions pos = {}) const;
/** [Eiger] enable or disable data streaming from left or right of detector /** [Eiger] enable or disable data streaming from left or right of detector
*/ */
void setDataStream(const portPosition port, const bool enable, void setDataStream(const defs::portPosition port, const bool enable,
Positions pos = {}); Positions pos = {});
///@{ ///@{

View File

@ -1593,7 +1593,6 @@ std::string CmdProxy::Quad(int action) {
std::string CmdProxy::DataStream(int action) { std::string CmdProxy::DataStream(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
bool left = true;
if (action == defs::HELP_ACTION) { if (action == defs::HELP_ACTION) {
os << "[left|right] [0, 1]\n\t[Eiger] Enables or disables data " os << "[left|right] [0, 1]\n\t[Eiger] Enables or disables data "
"streaming from left or/and right side of detector. 1 (enabled) " "streaming from left or/and right side of detector. 1 (enabled) "

View File

@ -1369,12 +1369,12 @@ void Detector::setQuad(const bool enable) {
pimpl->Parallel(&Module::setQuad, {}, enable); pimpl->Parallel(&Module::setQuad, {}, enable);
} }
Result<bool> Detector::getDataStream(const portPosition port, Result<bool> Detector::getDataStream(const defs::portPosition port,
Positions pos) const { Positions pos) const {
return pimpl->Parallel(&Module::getDataStream, pos, port); return pimpl->Parallel(&Module::getDataStream, pos, port);
} }
void Detector::setDataStream(const portPosition port, const bool enable, void Detector::setDataStream(const defs::portPosition port, const bool enable,
Positions pos) { Positions pos) {
pimpl->Parallel(&Module::setDataStream, pos, port, enable); pimpl->Parallel(&Module::setDataStream, pos, port, enable);
} }

View File

@ -655,8 +655,8 @@ TEST_CASE("datastream", "[.cmd]") {
CmdProxy proxy(&det); CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash(); auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER) { if (det_type == defs::EIGER) {
auto prev_val_left = det.getDataStream(true); auto prev_val_left = det.getDataStream(defs::LEFT);
auto prev_val_right = det.getDataStream(false); auto prev_val_right = det.getDataStream(defs::RIGHT);
// no "left" or "right" // no "left" or "right"
REQUIRE_THROWS(proxy.Call("datastream", {"1"}, -1, PUT)); REQUIRE_THROWS(proxy.Call("datastream", {"1"}, -1, PUT));
{ {
@ -680,8 +680,8 @@ TEST_CASE("datastream", "[.cmd]") {
REQUIRE(oss.str() == "datastream right 1\n"); REQUIRE(oss.str() == "datastream right 1\n");
} }
for (int i = 0; i != det.size(); ++i) { for (int i = 0; i != det.size(); ++i) {
det.setDataStream(prev_val_left[i], {i}); det.setDataStream(defs::LEFT, prev_val_left[i], {i});
det.setDataStream(prev_val_right[i], {i}); det.setDataStream(defs::RIGHT, prev_val_right[i], {i});
} }
} else { } else {
REQUIRE_THROWS(proxy.Call("datastream", {}, -1, GET)); REQUIRE_THROWS(proxy.Call("datastream", {}, -1, GET));

View File

@ -403,8 +403,8 @@ int ClientInterface::setup_receiver(Interface &socket) {
impl()->setSubPeriod(std::chrono::nanoseconds(arg.subExpTimeNs) + impl()->setSubPeriod(std::chrono::nanoseconds(arg.subExpTimeNs) +
std::chrono::nanoseconds(arg.subDeadTimeNs)); std::chrono::nanoseconds(arg.subDeadTimeNs));
impl()->setActivate(static_cast<bool>(arg.activate)); impl()->setActivate(static_cast<bool>(arg.activate));
impl()->setDetectorDataStream(1, arg.dataStreamLeft); impl()->setDetectorDataStream(LEFT, arg.dataStreamLeft);
impl()->setDetectorDataStream(0, arg.dataStreamRight); impl()->setDetectorDataStream(RIGHT, arg.dataStreamRight);
try { try {
impl()->setQuad(arg.quad == 0 ? false : true); impl()->setQuad(arg.quad == 0 ? false : true);
} catch (const RuntimeError &e) { } catch (const RuntimeError &e) {

View File

@ -521,6 +521,25 @@ std::string ToString(const defs::timingSourceType s) {
} }
} }
std::string ToString(defs::M3_GainCaps s) {
std::ostringstream os;
if (s & defs::M3_C10pre)
os << "C10pre, ";
if (s & defs::M3_C15sh)
os << "C15sh, ";
if (s & defs::M3_C30sh)
os << "C30sh, ";
if (s & defs::M3_C50sh)
os << "C50sh, ";
if (s & defs::M3_C225ACsh)
os << "C225ACsh, ";
if (s & defs::M3_C15pre)
os << "C15pre, ";
auto rs = os.str();
rs.erase(rs.end() - 2);
return rs;
}
std::string ToString(const defs::portPosition s) { std::string ToString(const defs::portPosition s) {
switch (s) { switch (s) {
case defs::LEFT: case defs::LEFT:
@ -876,6 +895,22 @@ template <> defs::timingSourceType StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown timing source type " + 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) { template <> defs::portPosition StringTo(const std::string &s) {
if (s == "left") if (s == "left")
return defs::LEFT; return defs::LEFT;
@ -888,34 +923,6 @@ template <> defs::portPosition StringTo(const std::string &s) {
throw sls::RuntimeError("Unknown port position " + s); 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;
if (s & defs::M3_C10pre)
os << "C10pre, ";
if (s & defs::M3_C15sh)
os << "C15sh, ";
if (s & defs::M3_C30sh)
os << "C30sh, ";
if (s & defs::M3_C50sh)
os << "C50sh, ";
if (s & defs::M3_C225ACsh)
os << "C225ACsh, ";
if (s & defs::M3_C15pre)
os << "C15pre, ";
auto rs = os.str();
rs.erase(rs.end()-2);
return rs;
}
template <> uint32_t StringTo(const std::string &s) { template <> uint32_t StringTo(const std::string &s) {
int base = s.find("0x") != std::string::npos ? 16 : 10; int base = s.find("0x") != std::string::npos ? 16 : 10;
return std::stoul(s, nullptr, base); return std::stoul(s, nullptr, base);