diff --git a/slsDetectorSoftware/include/CmdProxy.h b/slsDetectorSoftware/include/CmdProxy.h index 56f001258..3f9c285a0 100644 --- a/slsDetectorSoftware/include/CmdProxy.h +++ b/slsDetectorSoftware/include/CmdProxy.h @@ -452,6 +452,8 @@ class CmdProxy { {"cycles", "triggers"}, {"cyclesl", "triggersl"}, {"clkdivider", "speed"}, + + /** dacs */ /* acquisition */ {"busy", "clearbusy"}, @@ -505,13 +507,13 @@ class CmdProxy { {"i_b", "im_b"}, {"i_c", "im_c"}, {"i_d", "im_d"}, - {"i_io", "im_io"} + {"i_io", "im_io"}, /* Pattern */ /* Moench */ /* Advanced */ /* Insignificant */ - + {"frameindex", "rx_frameindex"} }; @@ -523,6 +525,7 @@ class CmdProxy { //{"config", &CmdProxy::config}, {"parameters", &CmdProxy::parameters}, {"hostname", &CmdProxy::Hostname}, + {"virtual", &CmdProxy::VirtualServer}, {"versions", &CmdProxy::Versions}, {"packageversion", &CmdProxy::PackageVersion}, {"clientversion", &CmdProxy::ClientVersion}, @@ -561,9 +564,10 @@ class CmdProxy { {"temp_sodr", &CmdProxy::temp_sodr}, {"temp_fpgafl", &CmdProxy::temp_fpgafl}, {"temp_fpgafr", &CmdProxy::temp_fpgafr}, - // dacs {"timing", &CmdProxy::timing}, + /* dacs */ + /* acquisition */ {"clearbusy", &CmdProxy::clearbusy}, {"rx_start", &CmdProxy::rx_start}, @@ -766,6 +770,7 @@ class CmdProxy { {"now", &CmdProxy::now}, {"timestamp", &CmdProxy::timestamp}, {"user", &CmdProxy::UserDetails}, + {"rx_frameindex", &CmdProxy::rx_frameindex}, @@ -783,6 +788,7 @@ class CmdProxy { std::string ListCommands(int action); /* configuration */ std::string Hostname(int action); + std::string VirtualServer(int action); std::string FirmwareVersion(int action); std::string Versions(int action); std::string PackageVersion(int action); @@ -930,11 +936,12 @@ class CmdProxy { GET_IND_COMMAND(temp_fpgafr, getTemperature, slsDetectorDefs::TEMPERATURE_FPGA3, " °C", "[n_value]\n\t[Eiger]Temperature of the left front end board fpga"); - //dacs - INTEGER_COMMAND(timing, getTimingMode, setTimingMode, sls::StringTo, "[auto|trigger|gating|burst_trigger]\n\tTiming Mode of detector.\n\t[Jungfrau][Gotthard][Ctb] [auto|trigger]\n\t[Eiger] [auto|trigger|gating|burst_trigger]"); + /* dacs */ + + /* acquisition */ EXECUTE_SET_COMMAND_NOID(clearbusy, clearAcquiringFlag, @@ -1361,6 +1368,9 @@ class CmdProxy { TIME_GET_COMMAND(timestamp, getMeasurementTime, "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][CTB] Timestamp at a frame start."); + GET_COMMAND(rx_frameindex, getRxCurrentFrameIndex, + "\n\tCurrent frame index received in receiver."); + diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index cda942645..3b3d46159 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -49,6 +49,9 @@ class Detector { * and updates local detector cache */ void setHostname(const std::vector &hostname); + /** connects to n servers at local host starting at specific control port */ + void setVirtualDetectorServers(int numServers, int startingPort); + /** Gets shared memory ID */ int getShmId() const; @@ -178,6 +181,33 @@ class Detector { /** [Gotthard][Jungfrau][CTB] */ void setADCPhaseInDegrees(int value, Positions pos = {}); + /** [Gotthard2] Hz */ + Result getClockFrequency(int clkIndex, Positions pos = {}); + + /** [not implemented] Hz */ + void setClockFrequency(int clkIndex, int value, Positions pos = {}); + + /** [Gotthard2] */ + Result getClockPhase(int clkIndex, Positions pos = {}); + + /** [Gotthard2] */ + void setClockPhase(int clkIndex, int value, Positions pos = {}); + + /** [Gotthard2] */ + Result getMaxClockPhaseShift(int clkIndex, Positions pos = {}); + + /** [Gotthard2] */ + Result getClockPhaseinDegrees(int clkIndex, Positions pos = {}); + + /** [Gotthard2] */ + void setClockPhaseinDegrees(int clkIndex, int value, Positions pos = {}); + + /** [Gotthard2] */ + Result getClockDivider(int clkIndex, Positions pos = {}); + + /** [Gotthard2] */ + void setClockDivider(int clkIndex, int value, Positions pos = {}); + Result getHighVoltage(Positions pos = {}) const; /** @@ -1201,33 +1231,6 @@ class Detector { Result getRxCurrentFrameIndex(Positions pos = {}) const; - /** [Gotthard2] Hz */ - Result getClockFrequency(int clkIndex, Positions pos = {}); - - /** [unknown] Hz */ - void setClockFrequency(int clkIndex, int value, Positions pos = {}); - - /** [Gotthard2] */ - Result getClockPhase(int clkIndex, Positions pos = {}); - - /** [Gotthard2] */ - void setClockPhase(int clkIndex, int value, Positions pos = {}); - - /** [Gotthard2] */ - Result getMaxClockPhaseShift(int clkIndex, Positions pos = {}); - - /** [Gotthard2] */ - Result getClockPhaseinDegrees(int clkIndex, Positions pos = {}); - - /** [Gotthard2] */ - void setClockPhaseinDegrees(int clkIndex, int value, Positions pos = {}); - - /** [Gotthard2] */ - Result getClockDivider(int clkIndex, Positions pos = {}); - - /** [Gotthard2] */ - void setClockDivider(int clkIndex, int value, Positions pos = {}); - private: std::vector getPortNumbers(int start_port); }; diff --git a/slsDetectorSoftware/include/slsDetectorCommand.h b/slsDetectorSoftware/include/slsDetectorCommand.h index 11c3262ed..00a37724e 100755 --- a/slsDetectorSoftware/include/slsDetectorCommand.h +++ b/slsDetectorSoftware/include/slsDetectorCommand.h @@ -43,10 +43,8 @@ class slsDetectorCommand : public virtual slsDetectorDefs { static std::string helpAcquire(int action); static std::string helpData(int action); static std::string helpFree(int action); - static std::string helpHostname(int action); static std::string helpExitServer(int action); static std::string helpThreaded(int action); - static std::string helpSettings(int action); static std::string helpSN(int action); static std::string helpDigiTest(int action); static std::string helpDAC(int action); @@ -61,10 +59,8 @@ class slsDetectorCommand : public virtual slsDetectorDefs { std::string cmdAcquire(int narg, const char * const args[], int action, int detPos = -1); std::string cmdData(int narg, const char * const args[], int action, int detPos = -1); std::string cmdFree(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdHostname(int narg, const char * const args[], int action, int detPos = -1); std::string cmdHelp(int narg, const char * const args[], int action, int detPos = -1); std::string cmdExitServer(int narg, const char * const args[], int action, int detPos = -1); - std::string cmdSettings(int narg, const char * const args[], int action, int detPos = -1); std::string cmdSN(int narg, const char * const args[], int action, int detPos = -1); std::string cmdDigiTest(int narg, const char * const args[], int action, int detPos = -1); std::string cmdDAC(int narg, const char * const args[], int action, int detPos = -1); diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 76dc84280..9e53e10d8 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -169,6 +169,28 @@ std::string CmdProxy::Hostname(int action) { return os.str(); } +std::string CmdProxy::VirtualServer(int action) { + std::ostringstream os; + os << cmd << ' '; + if (action == defs::HELP_ACTION) { + os << "[n_servers] [starting_port_number]\n\tConnecs to n virtual server at local host starting at specific control port." << '\n'; + } else if (action == defs::GET_ACTION) { + throw sls::RuntimeError("cannot get"); + } else if (action == defs::PUT_ACTION) { + if (args.size() != 2) { + WrongNumberOfParameters(2); + } + if (det_id != -1) { + throw sls::RuntimeError("Cannot execute this at module level"); + } + det->setVirtualDetectorServers(std::stoi(args[0]), std::stoi(args[1])); + os << sls::ToString(args); + } else { + throw sls::RuntimeError("Unknown action"); + } + return os.str(); +} + std::string CmdProxy::FirmwareVersion(int action) { std::ostringstream os; os << cmd << ' '; @@ -482,6 +504,7 @@ std::string CmdProxy::ClockDivider(int action) { } +/* dacs */ /* acquisition */ /* Network Configuration (Detector<->Receiver) */ diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 5a6c1e3a9..74b957000 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -33,6 +33,10 @@ void Detector::setHostname(const std::vector &value) { pimpl->setHostname(value); } +void Detector::setVirtualDetectorServers(int numServers, int startingPort) { + pimpl->setVirtualDetectorServers(numServers, startingPort); +} + int Detector::getShmId() const { return pimpl->getMultiId(); } std::string Detector::getPackageVersion() const { @@ -201,6 +205,42 @@ void Detector::setADCPhaseInDegrees(int value, Positions pos) { pimpl->Parallel(&slsDetector::setSpeed, pos, defs::ADC_PHASE, value, 1); } +Result Detector::getClockFrequency(int clkIndex, Positions pos) { + return pimpl->Parallel(&slsDetector::getClockFrequency, pos, clkIndex); +} + +void Detector::setClockFrequency(int clkIndex, int value, Positions pos) { + pimpl->Parallel(&slsDetector::setClockFrequency, pos, clkIndex, value); +} + +Result Detector::getClockPhase(int clkIndex, Positions pos) { + return pimpl->Parallel(&slsDetector::getClockPhase, pos, clkIndex, false); +} + +void Detector::setClockPhase(int clkIndex, int value, Positions pos) { + pimpl->Parallel(&slsDetector::setClockPhase, pos, clkIndex, value, false); +} + +Result Detector::getMaxClockPhaseShift(int clkIndex, Positions pos) { + return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos, clkIndex); +} + +Result Detector::getClockPhaseinDegrees(int clkIndex, Positions pos) { + return pimpl->Parallel(&slsDetector::getClockPhase, pos, clkIndex, true); +} + +void Detector::setClockPhaseinDegrees(int clkIndex, int value, Positions pos) { + pimpl->Parallel(&slsDetector::setClockPhase, pos, clkIndex, value, true); +} + +Result Detector::getClockDivider(int clkIndex, Positions pos) { + return pimpl->Parallel(&slsDetector::getClockDivider, pos, clkIndex); +} + +void Detector::setClockDivider(int clkIndex, int value, Positions pos) { + pimpl->Parallel(&slsDetector::setClockDivider, pos, clkIndex, value); +} + Result Detector::getHighVoltage(Positions pos) const { return pimpl->Parallel(&slsDetector::setDAC, pos, -1, defs::HIGH_VOLTAGE, 0); @@ -1576,42 +1616,6 @@ Result Detector::getRxCurrentFrameIndex(Positions pos) const { return pimpl->Parallel(&slsDetector::getReceiverCurrentFrameIndex, pos); } -Result Detector::getClockFrequency(int clkIndex, Positions pos) { - return pimpl->Parallel(&slsDetector::getClockFrequency, pos, clkIndex); -} - -void Detector::setClockFrequency(int clkIndex, int value, Positions pos) { - pimpl->Parallel(&slsDetector::setClockFrequency, pos, clkIndex, value); -} - -Result Detector::getClockPhase(int clkIndex, Positions pos) { - return pimpl->Parallel(&slsDetector::getClockPhase, pos, clkIndex, false); -} - -void Detector::setClockPhase(int clkIndex, int value, Positions pos) { - pimpl->Parallel(&slsDetector::setClockPhase, pos, clkIndex, value, false); -} - -Result Detector::getMaxClockPhaseShift(int clkIndex, Positions pos) { - return pimpl->Parallel(&slsDetector::getMaxClockPhaseShift, pos, clkIndex); -} - -Result Detector::getClockPhaseinDegrees(int clkIndex, Positions pos) { - return pimpl->Parallel(&slsDetector::getClockPhase, pos, clkIndex, true); -} - -void Detector::setClockPhaseinDegrees(int clkIndex, int value, Positions pos) { - pimpl->Parallel(&slsDetector::setClockPhase, pos, clkIndex, value, true); -} - -Result Detector::getClockDivider(int clkIndex, Positions pos) { - return pimpl->Parallel(&slsDetector::getClockDivider, pos, clkIndex); -} - -void Detector::setClockDivider(int clkIndex, int value, Positions pos) { - pimpl->Parallel(&slsDetector::setClockDivider, pos, clkIndex, value); -} - std::vector Detector::getPortNumbers(int start_port) { int num_sockets_per_detector = 1; switch (getDetectorType({}).squash()) { diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index c8b6f1bed..09c64d2f2 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -165,13 +165,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFree; ++i; - /*! \page config - - virtual [n] [p] \c connects to n virtual detector servers at local host starting at port p \c Returns the list of the hostnames of the multi-detector structure. \c (string) - */ - descrToFuncMap[i].m_pFuncName = "virtual"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdHostname; - ++i; - /*! \page config \section configstatus Status @@ -284,20 +277,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { */ - /*! \page settings - - trimbits [fname] loads/stores the trimbits to/from the detector. If no extension is specified, the serial number of each module will be attached. \c Returns \c (string) fname - */ - descrToFuncMap[i].m_pFuncName = "trimbits"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSettings; - ++i; - - /*! \page settings - - trimval [i] sets all trimbits to i. Used in EIGER only. \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName = "trimval"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSettings; - ++i; - /* pots */ /*! \page settings \section settingsdacs DACs @@ -790,13 +769,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) { descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver; ++i; - /*! \page receiver - - frameindex [i] gets the current frame index of receiver. Average of all for multi-detector command. Only get! \c Returns \c (int) - */ - descrToFuncMap[i].m_pFuncName = "frameindex"; - descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver; - ++i; - /* pattern generator */ @@ -965,47 +937,6 @@ std::string slsDetectorCommand::helpFree(int action) { return std::string("free \t frees the shared memory\n"); } -std::string slsDetectorCommand::cmdHostname(int narg, const char * const args[], int action, int detPos) { -#ifdef VERBOSE - std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n"); -#endif - - if (action == HELP_ACTION) { - return helpHostname(HELP_ACTION); - } - - if (action == PUT_ACTION) { - if (detPos >= 0) { - return std::string("Wrong usage - setting hostname/virtual only from " - "multiDetector level"); - } - - if (cmd == "virtual") { - int port = -1; - int numDetectors = 0; - if (!sscanf(args[1], "%d", &numDetectors)) { - throw sls::RuntimeError("Cannot scan number of detector servers from virtual command\n"); - } - if (!sscanf(args[2], "%d", &port)) { - throw sls::RuntimeError("Cannot scan port from virtual command\n"); - } - myDet->setVirtualDetectorServers(numDetectors, port); - } else { - throw sls::RuntimeError("unknown command\n"); - } - } - return myDet->getHostname(detPos); -} - -std::string slsDetectorCommand::helpHostname(int action) { - std::ostringstream os; - - if (action == PUT_ACTION || action == HELP_ACTION) { - os << std::string("virtual [n] [p]\t connects to n virtual detector servers at local host starting at port p \n"); - } - return os.str(); -} - std::string slsDetectorCommand::cmdHelp(int narg, const char * const args[], int action, int detPos) { #ifdef VERBOSE @@ -1086,38 +1017,6 @@ std::string slsDetectorCommand::helpThreaded(int action) { -std::string slsDetectorCommand::cmdSettings(int narg, const char * const args[], int action, int detPos) { - - if (action == HELP_ACTION) - return helpSettings(action); - int val = -1; //ret, - char ans[1000]; - - - if (cmd == "trimval") { - if (action == PUT_ACTION) { - if (sscanf(args[1], "%d", &val)) - myDet->setAllTrimbits(val, detPos); - else - return std::string("invalid trimbit value ") + cmd; - } - sprintf(ans, "%d", myDet->setAllTrimbits(-1, detPos)); - return ans; - } - return std::string("unknown settings command ") + cmd; -} - -std::string slsDetectorCommand::helpSettings(int action) { - - std::ostringstream os; - if (action == PUT_ACTION || action == HELP_ACTION) { - os << "trimval i \n sets all the trimbits to i" << std::endl; - } - if (action == GET_ACTION || action == HELP_ACTION) { - os << "trimval \n returns the value all trimbits are set to. If they are different, returns -1." << std::endl; - } - return os.str(); -} std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int action, int detPos) { @@ -1576,14 +1475,6 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[], } } - else if (cmd == "frameindex") { - if (action == PUT_ACTION) - return std::string("cannot put"); - else { - sprintf(answer, "%lu", myDet->getReceiverCurrentFrameIndex(detPos)); - return std::string(answer); - } - } return std::string("could not decode command"); @@ -1595,10 +1486,6 @@ std::string slsDetectorCommand::helpReceiver(int action) { if (action == PUT_ACTION || action == HELP_ACTION) { os << "resetframescaught [any value] \t resets frames caught by receiver" << std::endl; - } - if (action == GET_ACTION || action == HELP_ACTION) { - os << "frameindex \t returns the current frame index of receiver(average for multi)" << std::endl; - } return os.str(); } diff --git a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp index b56c2a6a9..6718e5ca6 100644 --- a/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp +++ b/slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp @@ -9,6 +9,11 @@ auto GET = slsDetectorDefs::GET_ACTION; auto PUT = slsDetectorDefs::PUT_ACTION; +TEST_CASE("rx_frameindex", "[.cmd]") { + REQUIRE_NOTHROW(multiSlsDetectorClient("rx_frameindex", GET)); + REQUIRE_THROWS(multiSlsDetectorClient("rx_frameindex bla", PUT)); +} + TEST_CASE("user", "[.cmd]") { REQUIRE_NOTHROW(multiSlsDetectorClient("user", GET));