This commit is contained in:
2019-10-28 15:59:18 +01:00
parent 3fdae431b0
commit bc7ebd45df
4 changed files with 50 additions and 69 deletions

View File

@ -757,16 +757,18 @@ class CmdProxy {
{"bustest", &CmdProxy::bustest},
/* Insignificant */
{"adcvpp", &CmdProxy::adcvpp},//dac
{"port", &CmdProxy::port},
{"stopport", &CmdProxy::stopport},
{"lock", &CmdProxy::lock},
{"lastclient", &CmdProxy::lastclient},
{"lock", &CmdProxy::lock}
{"adcvpp", &CmdProxy::adcvpp}//dac
};
@ -1333,17 +1335,27 @@ class CmdProxy {
/* Insignificant */
INTEGER_COMMAND(port, getControlPort, setControlPort, std::stoi,
"[n]\n\tPort number of the control server on detector for detector-client tcp interface. Default is 1952. Normally unchanged.");
INTEGER_COMMAND(stopport, getStopPort, setStopPort, std::stoi,
"[n]\n\tPort number of the stop server on detector for detector-client tcp interface. Default is 1953. Normally unchanged.");
INTEGER_COMMAND(lock, getDetectorLock, setDetectorLock, std::stoi,
"[0, 1]\n\tLock detector to one IP, 1: locks");
GET_COMMAND(lastclient, getLastClientIP,
"\n\tClient IP Address that last communicated with the detector.");
DAC_COMMAND(adcvpp, getDAC, setDAC, defs::ADC_VPP,
"[dac or mv value][(optional unit) mv] \n\t[Ctb] Vpp of ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> 2V.");
GET_COMMAND(lastclient, getLastClientIP,
"\n\tClient IP Address that last communicated with the detector.");
INTEGER_COMMAND(lock, getDetectorLock, setDetectorLock, std::stoi,
"[0, 1]\n\tLock detector to one IP, 1: locks");

View File

@ -47,7 +47,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
static std::string helpUser(int action);
static std::string helpExitServer(int action);
static std::string helpThreaded(int action);
static std::string helpPort(int action);
static std::string helpSettings(int action);
static std::string helpSN(int action);
static std::string helpDigiTest(int action);
@ -68,7 +67,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
std::string cmdUser(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 cmdPort(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);

View File

@ -810,21 +810,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/* communication configuration */
/*! \page network
- <b>port [port]</b> sets/gets the port of the client-detector control server TCP interface. Use single-detector command. Default value is 1952 for all detectors. Normally not changed. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "port";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPort;
++i;
/*! \page network
- <b>stopport [port]</b> sets/gets the port of the client-detector stop server TCP interface. Use single-detector command. Default value is 1953 for all detectors. Normally not changed. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "stopport";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPort;
++i;
/* receiver functions */
/*! \page receiver Receiver commands
@ -1167,48 +1152,6 @@ std::string slsDetectorCommand::helpThreaded(int action) {
std::string slsDetectorCommand::cmdPort(int narg, const char * const args[], int action, int detPos) {
if (action == HELP_ACTION)
return helpPort(action);
int val; //ret,
char ans[MAX_STR_LENGTH];
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &val))
;
else
return std::string("could not scan port number") + std::string(args[1]);
}
if (cmd == "port") {
if (action == PUT_ACTION)
myDet->setControlPort(val, detPos);
sprintf(ans, "%d", myDet->setControlPort(-1, detPos));
} else if (cmd == "stopport") {
if (action == PUT_ACTION)
myDet->setStopPort(val, detPos);
sprintf(ans, "%d", myDet->setStopPort(-1, detPos));
} else
return std::string("unknown port type ") + cmd;
return std::string(ans);
}
std::string slsDetectorCommand::helpPort(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "port i \n sets the communication control port" << std::endl;
os << "stopport i \n sets the communication stop port " << std::endl;
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "port \n gets the communication control port" << std::endl;
os << "stopport \n gets the communication stop port " << std::endl;
}
return os.str();
}
std::string slsDetectorCommand::cmdSettings(int narg, const char * const args[], int action, int detPos) {

View File

@ -9,6 +9,34 @@
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
TEST_CASE("port", "[.cmd]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("port 1942", PUT, nullptr, oss));
REQUIRE(oss.str() == "port 1942\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("port", GET, nullptr, oss));
REQUIRE(oss.str() == "port 1942\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("port 1952", PUT));
}
TEST_CASE("stopport", "[.cmd]") {
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("stopport 1942", PUT, nullptr, oss));
REQUIRE(oss.str() == "stopport 1942\n");
}
{
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient("stopport", GET, nullptr, oss));
REQUIRE(oss.str() == "stopport 1942\n");
}
REQUIRE_NOTHROW(multiSlsDetectorClient("stopport 1953", PUT));
}
TEST_CASE("adcreg", "[.cmd]") {
if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD || test::type == slsDetectorDefs::GOTTHARD) {
REQUIRE_THROWS(multiSlsDetectorClient("adcreg 0x34", PUT));