mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-01 10:20:04 +02:00
WIP
This commit is contained in:
parent
bc7ebd45df
commit
8c279695de
@ -761,6 +761,11 @@ class CmdProxy {
|
||||
{"stopport", &CmdProxy::stopport},
|
||||
{"lock", &CmdProxy::lock},
|
||||
{"lastclient", &CmdProxy::lastclient},
|
||||
{"execcommand", &CmdProxy::ExecuteCommand},
|
||||
{"nframes", &CmdProxy::nframes},
|
||||
{"now", &CmdProxy::now},
|
||||
{"timestamp", &CmdProxy::timestamp},
|
||||
{"user", &CmdProxy::UserDetails},
|
||||
|
||||
|
||||
|
||||
@ -838,8 +843,8 @@ class CmdProxy {
|
||||
std::string AdcRegister(int action);
|
||||
std::string BitOperations(int action);
|
||||
/* Insignificant */
|
||||
|
||||
|
||||
std::string ExecuteCommand(int action);
|
||||
std::string UserDetails(int action);
|
||||
|
||||
|
||||
/* configuration */
|
||||
@ -1347,6 +1352,15 @@ class CmdProxy {
|
||||
GET_COMMAND(lastclient, getLastClientIP,
|
||||
"\n\tClient IP Address that last communicated with the detector.");
|
||||
|
||||
GET_COMMAND(nframes, getNumberOfFramesFromStart,
|
||||
"\n\t[Gotthard][Jungfrau][CTB] Number of frames from start run control.");
|
||||
|
||||
TIME_GET_COMMAND(now, getActualTime,
|
||||
"[(optional unit) ns|us|ms|s]\n\t[Jungfrau][CTB] Time from detector start up.");
|
||||
|
||||
TIME_GET_COMMAND(timestamp, getMeasurementTime,
|
||||
"[(optional unit) ns|us|ms|s]\n\t[Jungfrau][CTB] Timestamp at a frame start.");
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -44,14 +44,12 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
static std::string helpData(int action);
|
||||
static std::string helpFree(int action);
|
||||
static std::string helpHostname(int action);
|
||||
static std::string helpUser(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);
|
||||
static std::string helpTimeLeft(int action);
|
||||
static std::string helpConfiguration(int action);
|
||||
static std::string helpReceiver(int action);
|
||||
|
||||
@ -64,14 +62,12 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
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 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 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);
|
||||
std::string cmdTimeLeft(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdReceiver(int narg, const char * const args[], int action, int detPos = -1);
|
||||
|
||||
|
@ -1467,6 +1467,45 @@ std::string CmdProxy::BitOperations(int action) {
|
||||
|
||||
/* Insignificant */
|
||||
|
||||
std::string CmdProxy::ExecuteCommand(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[command]\n\tExecutes command on detector server." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
throw sls::RuntimeError("Cannot get.");
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
if (args.size() != 1) {
|
||||
WrongNumberOfParameters(1);
|
||||
}
|
||||
det->executeCommand(args[0], {det_id});
|
||||
os << "successful" << '\n';
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string CmdProxy::UserDetails(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tUser details from shared memory." << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (det_id != -1) {
|
||||
throw sls::RuntimeError("Cannot execute this at module level");
|
||||
}
|
||||
if (args.size() != 0) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto t = det->getUserDetails();
|
||||
os << t << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put.");
|
||||
} else {
|
||||
throw sls::RuntimeError("Unknown action");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
} // namespace sls
|
@ -108,13 +108,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdExitServer;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>execcommand</b> Executes a command on the detector server. Don't use it!!!!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "execcommand";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdExitServer;
|
||||
++i;
|
||||
|
||||
/*! \page test
|
||||
- <b>rx_execcommand</b> Executes a command on the receiver server. Don't use it!!!!
|
||||
*/
|
||||
@ -180,13 +173,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
++i;
|
||||
|
||||
|
||||
/*! \page config
|
||||
- <b>user</b> \c Returns user details from shared memory. Only allowed at multi detector level. Cannot put. \c (string)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "user";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdUser;
|
||||
++i;
|
||||
|
||||
/*! \page config
|
||||
\section configstatus Status
|
||||
commands to configure detector status
|
||||
@ -239,26 +225,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
|
||||
/* read only timers */
|
||||
|
||||
/*! \page timing
|
||||
- <b>now</b> Getting actual time of the detector from start. For Jungfrau only. Only get!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "now";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimeLeft;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>timestamp</b> Getting timestamp. For Jungfrau only. Only get!
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "timestamp";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimeLeft;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>nframes</b> Frames from start run control. Only Jungfrau. Only get! \c Returns \c (long long int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "nframes";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimeLeft;
|
||||
++i;
|
||||
|
||||
|
||||
/* speed */
|
||||
@ -1040,35 +1006,6 @@ std::string slsDetectorCommand::helpHostname(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdUser(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) {
|
||||
return std::string("cannot put");
|
||||
}
|
||||
if (detPos >= 0) {
|
||||
return std::string("Wrong usage - getting user details only from "
|
||||
"multiDetector level");
|
||||
}
|
||||
return myDet->getUserDetails();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpUser(int action) {
|
||||
std::ostringstream os;
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << std::string("user \t returns user details from shared memory without updating shared memory. "
|
||||
"Only allowed at multi detector level.\n");
|
||||
}
|
||||
if (action == PUT_ACTION || action == HELP_ACTION) {
|
||||
os << std::string("user \t cannot put\n");
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdHelp(int narg, const char * const args[], int action, int detPos) {
|
||||
#ifdef VERBOSE
|
||||
@ -1099,9 +1036,6 @@ std::string slsDetectorCommand::cmdExitServer(int narg, const char * const args[
|
||||
|
||||
myDet->exitReceiver(detPos);
|
||||
return std::string("Receiver shut down\n");
|
||||
} else if (cmd == "execcommand") {
|
||||
myDet->execCommand(std::string(args[1]), detPos);
|
||||
return std::string("Command executed successfully\n");
|
||||
} else if (cmd == "rx_execcommand") {
|
||||
|
||||
myDet->execReceiverCommand(std::string(args[1]), detPos);
|
||||
@ -1116,7 +1050,6 @@ std::string slsDetectorCommand::helpExitServer(int action) {
|
||||
std::ostringstream os;
|
||||
os << std::string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n");
|
||||
os << std::string("rx_exit \t shuts down all the receiver servers.\n");
|
||||
os << std::string("execcommand \t executes command in detector server. Don't use it if you do not know what you are doing.\n");
|
||||
os << std::string("rx_execcommand \t executes command in receiver server. Don't use it if you do not know what you are doing.\n");
|
||||
return os.str();
|
||||
}
|
||||
@ -1607,51 +1540,6 @@ std::string slsDetectorCommand::helpDAC(int action) {
|
||||
|
||||
|
||||
|
||||
std::string slsDetectorCommand::cmdTimeLeft(int narg, const char * const args[], int action, int detPos) {
|
||||
timerIndex index;
|
||||
int64_t ret;
|
||||
double rval;
|
||||
|
||||
char answer[1000];
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpTimeLeft(action);
|
||||
|
||||
if (cmd == "now")
|
||||
index = ACTUAL_TIME;
|
||||
else if (cmd == "timestamp")
|
||||
index = MEASUREMENT_TIME;
|
||||
else if (cmd == "nframes")
|
||||
index = FRAMES_FROM_START;
|
||||
else
|
||||
return std::string("could not decode timer ") + cmd;
|
||||
|
||||
if (action == PUT_ACTION) {
|
||||
return std::string("cannot set ") + std::string(args[1]);
|
||||
}
|
||||
|
||||
|
||||
ret = myDet->getTimeLeft(index, detPos);
|
||||
|
||||
if ((ret != -1) && (index == ACTUAL_TIME || index == MEASUREMENT_TIME)) {
|
||||
rval = (double)ret * 1E-9;
|
||||
sprintf(answer,"%0.9f",rval);
|
||||
} else {
|
||||
sprintf(answer,"%lld",(long long int)ret);
|
||||
}
|
||||
|
||||
return std::string(answer);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpTimeLeft(int action) {
|
||||
|
||||
std::ostringstream os;
|
||||
if (action == GET_ACTION || action == HELP_ACTION) {
|
||||
os << std::endl;
|
||||
}
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
std::string slsDetectorCommand::cmdConfiguration(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
|
@ -9,6 +9,41 @@
|
||||
auto GET = slsDetectorDefs::GET_ACTION;
|
||||
auto PUT = slsDetectorDefs::PUT_ACTION;
|
||||
|
||||
|
||||
TEST_CASE("user", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("user", GET));
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("user bla", PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("now", "[.cmd]") {
|
||||
if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("now", GET));
|
||||
} else {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("now", GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("timestamp", "[.cmd]") {
|
||||
if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD) {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("timestamp", GET));
|
||||
} else {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("timestamp", GET));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("nframes", "[.cmd]") {
|
||||
if (test::type == slsDetectorDefs::JUNGFRAU || test::type == slsDetectorDefs::CHIPTESTBOARD || test::type == slsDetectorDefs::GOTTHARD) {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("nframes", GET));
|
||||
} else {
|
||||
REQUIRE_THROWS(multiSlsDetectorClient("nframes", GET));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("execcommand", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("execcommand ls", PUT));
|
||||
}
|
||||
|
||||
TEST_CASE("port", "[.cmd]") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
Loading…
x
Reference in New Issue
Block a user