mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
Merge branch 'developer' into jungfrauv0.8
This commit is contained in:
commit
7b817fa194
@ -29,14 +29,14 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
* @param action can be PUT_ACTION or GET_ACTION(from text client even READOUT_ACTION for acquisition)
|
||||
* @param detPos -1 for all detectors in multi detector list or position of a specific detector in list
|
||||
*/
|
||||
std::string executeLine(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string executeLine(int narg, const char * const args[], int action, int detPos = -1);
|
||||
|
||||
/* /\** */
|
||||
/* returns the help for the executeLine command */
|
||||
/* \param os output stream to return the help to */
|
||||
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
|
||||
/* *\/ */
|
||||
std::string helpLine(int narg, char *args[], int action=HELP_ACTION, int detPos = -1);
|
||||
std::string helpLine(int narg, const char * const args[], int action=HELP_ACTION, int detPos = -1);
|
||||
static std::string helpAcquire(int action);
|
||||
static std::string helpData(int action);
|
||||
static std::string helpStatus(int action);
|
||||
@ -96,56 +96,56 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
|
||||
std::string cmdUnderDevelopment(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdUnknown(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdAcquire(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdData(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdStatus(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdDataStream(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdFree(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdHostname(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdUser(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdHelp(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdExitServer(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdSettingsDir(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdTrimEn(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdOutDir(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdFileName(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdFileIndex(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdRateCorr(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdNetworkParameter(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPort(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdLock(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdLastClient(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdOnline(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdConfigureMac(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdDetectorSize(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdSettings(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdSN(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdDigiTest(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdRegister(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdDAC(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdTiming(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdTimer(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdTimeLeft(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdSpeed(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdAdvanced(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdConfiguration(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdImage(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdCounter(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdADC(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdTempControl(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdEnablefwrite(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdOverwrite(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdReceiver(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPattern(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdPulse(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdProcessor(int narg, char *args[], int action, int detPos = -1);
|
||||
std::string cmdUnderDevelopment(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdUnknown(int narg, const char * const args[], int action, int detPos = -1);
|
||||
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 cmdStatus(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdDataStream(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 cmdSettingsDir(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdTrimEn(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdOutDir(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdFileName(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdFileIndex(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdRateCorr(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdNetworkParameter(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 cmdLock(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdLastClient(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdOnline(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdConfigureMac(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdDetectorSize(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 cmdRegister(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 cmdTiming(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdTimer(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 cmdSpeed(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdAdvanced(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 cmdImage(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdCounter(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdADC(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdTempControl(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdEnablefwrite(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdOverwrite(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);
|
||||
std::string cmdPattern(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdPulse(int narg, const char * const args[], int action, int detPos = -1);
|
||||
std::string cmdProcessor(int narg, const char * const args[], int action, int detPos = -1);
|
||||
|
||||
int numberOfCommands;
|
||||
std::string cmd;
|
||||
|
||||
typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, char *args[], int action, int detPos);
|
||||
typedef std::string (slsDetectorCommand::*MemFuncGetter)(int narg, const char * const args[], int action, int detPos);
|
||||
|
||||
|
||||
struct FuncTable
|
||||
|
@ -2123,7 +2123,7 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
std::string slsDetectorCommand::executeLine(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::executeLine(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == READOUT_ACTION)
|
||||
return cmdAcquire(narg, args, action, detPos);
|
||||
@ -2154,14 +2154,14 @@ std::string slsDetectorCommand::executeLine(int narg, char *args[], int action,
|
||||
return cmdUnknown(narg, args, action, detPos);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdUnknown(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdUnknown(int narg, const char * const args[], int action, int detPos) {
|
||||
return std::string("Unknown command ") + std::string(args[0]) + std::string("\n") + helpLine(0, args, action, detPos);
|
||||
}
|
||||
std::string slsDetectorCommand::cmdUnderDevelopment(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdUnderDevelopment(int narg, const char * const args[], int action, int detPos) {
|
||||
return std::string("Must still develop ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::helpLine(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::helpLine(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
std::ostringstream os;
|
||||
|
||||
@ -2180,7 +2180,7 @@ std::string slsDetectorCommand::helpLine(int narg, char *args[], int action, int
|
||||
return executeLine(narg, args, HELP_ACTION, detPos);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdAcquire(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
|
||||
@ -2225,7 +2225,7 @@ std::string slsDetectorCommand::helpAcquire(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdData(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdData(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");
|
||||
@ -2257,7 +2257,7 @@ std::string slsDetectorCommand::helpData(int action) {
|
||||
return std::string("data \t gets all data from the detector (if any) processes them and writes them to file according to the preferences already setup\n");
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdStatus(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdStatus(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");
|
||||
@ -2310,7 +2310,7 @@ std::string slsDetectorCommand::helpStatus(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdDataStream(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdDataStream(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");
|
||||
@ -2344,7 +2344,7 @@ std::string slsDetectorCommand::helpDataStream(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdFree(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdFree(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");
|
||||
@ -2360,7 +2360,7 @@ std::string slsDetectorCommand::helpFree(int action) {
|
||||
return std::string("free \t frees the shared memory\n");
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdHostname(int narg, char *args[], int action, int detPos) {
|
||||
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
|
||||
@ -2422,7 +2422,7 @@ std::string slsDetectorCommand::helpHostname(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdUser(int narg, char *args[], int action, int detPos) {
|
||||
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
|
||||
@ -2452,7 +2452,7 @@ std::string slsDetectorCommand::helpUser(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdHelp(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdHelp(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
|
||||
@ -2465,7 +2465,7 @@ std::string slsDetectorCommand::cmdHelp(int narg, char *args[], int action, int
|
||||
return helpLine(0, args, action, detPos);
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdExitServer(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
|
||||
@ -2513,7 +2513,7 @@ std::string slsDetectorCommand::helpExitServer(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdSettingsDir(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdSettingsDir(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
|
||||
@ -2541,7 +2541,7 @@ std::string slsDetectorCommand::helpSettingsDir(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdTrimEn(int narg, const char * const args[], int action, int detPos) {
|
||||
std::vector<int> energies;
|
||||
if (action == HELP_ACTION)
|
||||
return helpTrimEn(action);
|
||||
@ -2572,7 +2572,7 @@ std::string slsDetectorCommand::helpTrimEn(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdOutDir(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdOutDir(int narg, const char * const args[], int action, int detPos) {
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
if (action == HELP_ACTION)
|
||||
return helpOutDir(action);
|
||||
@ -2592,7 +2592,7 @@ std::string slsDetectorCommand::helpOutDir(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdFileName(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdFileName(int narg, const char * const args[], int action, int detPos) {
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
if (action == HELP_ACTION)
|
||||
return helpFileName(action);
|
||||
@ -2628,7 +2628,7 @@ std::string slsDetectorCommand::helpFileName(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdEnablefwrite(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdEnablefwrite(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
int i;
|
||||
char ans[100];
|
||||
@ -2674,7 +2674,7 @@ std::string slsDetectorCommand::helpEnablefwrite(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdOverwrite(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdOverwrite(int narg, const char * const args[], int action, int detPos) {
|
||||
int i;
|
||||
char ans[100];
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
@ -2700,7 +2700,7 @@ std::string slsDetectorCommand::helpOverwrite(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdFileIndex(int narg, const char * const args[], int action, int detPos) {
|
||||
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||
if (action == HELP_ACTION) {
|
||||
return helpFileName(action);
|
||||
@ -2720,7 +2720,7 @@ std::string slsDetectorCommand::helpFileIndex(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdRateCorr(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdRateCorr(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION) {
|
||||
return helpRateCorr(action);
|
||||
@ -2747,7 +2747,7 @@ std::string slsDetectorCommand::helpRateCorr(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// std::string slsDetectorCommand::cmdThreaded(int narg, char *args[], int action, int detPos){
|
||||
// std::string slsDetectorCommand::cmdThreaded(int narg, const char * const args[], int action, int detPos){
|
||||
// int ival;
|
||||
// char answer[1000];
|
||||
|
||||
@ -2773,7 +2773,7 @@ std::string slsDetectorCommand::helpThreaded(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdImage(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdImage(int narg, const char * const args[], int action, int detPos) {
|
||||
std::string sval;
|
||||
int retval = FAIL;
|
||||
if (action == HELP_ACTION)
|
||||
@ -2808,7 +2808,7 @@ std::string slsDetectorCommand::helpImage(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdCounter(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdCounter(int narg, const char * const args[], int action, int detPos) {
|
||||
int ival;
|
||||
char answer[100];
|
||||
std::string sval;
|
||||
@ -2869,7 +2869,7 @@ std::string slsDetectorCommand::helpCounter(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdNetworkParameter(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
char ans[100] = {0};
|
||||
int i;
|
||||
@ -3120,7 +3120,7 @@ std::string slsDetectorCommand::helpNetworkParameter(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdPort(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdPort(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpPort(action);
|
||||
@ -3168,7 +3168,7 @@ std::string slsDetectorCommand::helpPort(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdLock(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdLock(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpLock(action);
|
||||
@ -3219,7 +3219,7 @@ std::string slsDetectorCommand::helpLock(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdLastClient(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdLastClient(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpLastClient(action);
|
||||
@ -3250,7 +3250,7 @@ std::string slsDetectorCommand::helpLastClient(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdOnline(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION) {
|
||||
return helpOnline(action);
|
||||
@ -3334,7 +3334,7 @@ std::string slsDetectorCommand::helpOnline(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdConfigureMac(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdConfigureMac(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION) {
|
||||
return helpConfigureMac(action);
|
||||
@ -3365,7 +3365,7 @@ std::string slsDetectorCommand::helpConfigureMac(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdDetectorSize(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpDetectorSize(action);
|
||||
@ -3482,7 +3482,7 @@ std::string slsDetectorCommand::helpDetectorSize(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdSettings(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdSettings(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpSettings(action);
|
||||
@ -3600,7 +3600,7 @@ std::string slsDetectorCommand::helpSettings(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdSN(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
char answer[1000];
|
||||
|
||||
@ -3693,7 +3693,7 @@ std::string slsDetectorCommand::helpSN(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdDigiTest(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
char answer[1000];
|
||||
|
||||
@ -3744,7 +3744,7 @@ std::string slsDetectorCommand::helpDigiTest(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdRegister(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdRegister(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpRegister(action);
|
||||
@ -3862,7 +3862,7 @@ std::string slsDetectorCommand::helpRegister(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdDAC(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdDAC(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpDAC(action);
|
||||
@ -4208,7 +4208,7 @@ std::string slsDetectorCommand::helpDAC(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdADC(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdADC(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
dacIndex adc;
|
||||
int idac;
|
||||
@ -4335,7 +4335,7 @@ std::string slsDetectorCommand::helpADC(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdTempControl(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdTempControl(int narg, const char * const args[], int action, int detPos) {
|
||||
char answer[1000] = "";
|
||||
int val = -1;
|
||||
|
||||
@ -4402,7 +4402,7 @@ std::string slsDetectorCommand::helpTempControl(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdTiming(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdTiming(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
|
||||
@ -4428,7 +4428,7 @@ std::string slsDetectorCommand::helpTiming(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdTimer(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdTimer(int narg, const char * const args[], int action, int detPos) {
|
||||
timerIndex index;
|
||||
int64_t t = -1, ret;
|
||||
double val, rval;
|
||||
@ -4558,7 +4558,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdTimeLeft(int narg, const char * const args[], int action, int detPos) {
|
||||
timerIndex index;
|
||||
int64_t ret;
|
||||
double rval;
|
||||
@ -4626,7 +4626,7 @@ std::string slsDetectorCommand::helpTimeLeft(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdSpeed(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
speedVariable index;
|
||||
int t = -1, ret = 0, mode = 0;
|
||||
@ -4723,7 +4723,7 @@ std::string slsDetectorCommand::helpSpeed(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdAdvanced(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
|
||||
char answer[1000] = "";
|
||||
@ -4961,7 +4961,7 @@ std::string slsDetectorCommand::helpAdvanced(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdConfiguration(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdConfiguration(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpConfiguration(action);
|
||||
@ -5031,7 +5031,7 @@ std::string slsDetectorCommand::helpConfiguration(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[], int action, int detPos) {
|
||||
char answer[100];
|
||||
int ival = -1;
|
||||
|
||||
@ -5279,7 +5279,7 @@ std::string slsDetectorCommand::helpPattern(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdPattern(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[], int action, int detPos) {
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
return helpPattern(action);
|
||||
@ -5749,7 +5749,7 @@ std::string slsDetectorCommand::helpPulse(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdPulse(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdPulse(int narg, const char * const args[], int action, int detPos) {
|
||||
int retval = FAIL;
|
||||
|
||||
if (action == HELP_ACTION)
|
||||
@ -5811,7 +5811,7 @@ std::string slsDetectorCommand::helpProcessor(int action) {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::string slsDetectorCommand::cmdProcessor(int narg, char *args[], int action, int detPos) {
|
||||
std::string slsDetectorCommand::cmdProcessor(int narg, const char * const args[], int action, int detPos) {
|
||||
if (action == HELP_ACTION)
|
||||
return helpProcessor(action);
|
||||
|
||||
|
@ -6,18 +6,17 @@
|
||||
|
||||
class CmdLineParser {
|
||||
public:
|
||||
void Parse(int argc, char *argv[]);
|
||||
void Parse(int argc, const char * const argv[]);
|
||||
void Parse(const std::string &s);
|
||||
void Print();
|
||||
|
||||
//getters
|
||||
int multi_id() const { return multi_id_; };
|
||||
int detector_id() const { return detector_id_; };
|
||||
int n_arguments() const { return arguments_.size(); }
|
||||
const std::string &command() const { return command_; }
|
||||
const std::string &executable() const { return executable_; }
|
||||
const std::vector<std::string> &arguments() const { return arguments_; };
|
||||
std::vector<char *> argv();
|
||||
std::vector<const char *> argv() const;
|
||||
|
||||
private:
|
||||
void DecodeIdAndPosition(const char *c);
|
||||
|
@ -5,10 +5,11 @@
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
//printing function for debugging
|
||||
|
||||
void CmdLineParser::Print() {
|
||||
std::cout << "\nCmdLineParser::Print()\n";
|
||||
std::cout << "\tmulti_id: " << multi_id_ << ", detector_id: " << detector_id_ << std::endl;
|
||||
std::cout << "\tmulti_id: " << multi_id_
|
||||
<< ", detector_id: " << detector_id_ << std::endl;
|
||||
std::cout << "\texecutable: " << executable_ << '\n';
|
||||
std::cout << "\tcommand: " << command_ << '\n';
|
||||
std::cout << "\tn_arguments: " << n_arguments() << '\n';
|
||||
@ -19,27 +20,22 @@ void CmdLineParser::Print() {
|
||||
std::cout << "\n\n";
|
||||
};
|
||||
|
||||
void CmdLineParser::Parse(int argc, char *argv[]) {
|
||||
//first element of argv is the command used to call the executable ->skipping
|
||||
//and if this is the only command skip all
|
||||
executable_ = argv[0];
|
||||
void CmdLineParser::Parse(int argc, const char * const argv[]) {
|
||||
executable_ = argv[0]; //first arg is calling binary
|
||||
if (argc > 1) {
|
||||
//second element is cmd string that needs to be decoded
|
||||
DecodeIdAndPosition(argv[1]);
|
||||
//The rest of the arguments goes into a vector for later processing
|
||||
for (int i = 2; i < argc; ++i) {
|
||||
arguments_.emplace_back(std::string(argv[i]));
|
||||
arguments_.emplace_back(argv[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void CmdLineParser::Parse(const std::string &s) {
|
||||
std::istringstream iss(s);
|
||||
auto it = std::istream_iterator<std::string>(iss);
|
||||
//read the first element and increment
|
||||
command_ = *it++;
|
||||
arguments_ = std::vector<std::string>(it, std::istream_iterator<std::string>());
|
||||
;
|
||||
arguments_ =
|
||||
std::vector<std::string>(it, std::istream_iterator<std::string>());
|
||||
DecodeIdAndPosition(command_.c_str());
|
||||
}
|
||||
|
||||
@ -51,19 +47,23 @@ void CmdLineParser::DecodeIdAndPosition(const char *c) {
|
||||
if (contains_id && contains_pos) {
|
||||
int r = sscanf(c, "%d-%d:%s", &multi_id_, &detector_id_, tmp);
|
||||
if (r != 3) {
|
||||
throw(std::invalid_argument("Cannot decode client or detector id from: \"" + std::string(c) + "\"\n"));
|
||||
throw(std::invalid_argument(
|
||||
"Cannot decode client or detector id from: \"" +
|
||||
std::string(c) + "\"\n"));
|
||||
}
|
||||
command_ = tmp;
|
||||
} else if (contains_id && !contains_pos) {
|
||||
int r = sscanf(c, "%d-%s", &multi_id_, tmp);
|
||||
if (r != 2) {
|
||||
throw(std::invalid_argument("Cannot decode client id from: \"" + std::string(c) + "\"\n"));
|
||||
throw(std::invalid_argument("Cannot decode client id from: \"" +
|
||||
std::string(c) + "\"\n"));
|
||||
}
|
||||
command_ = tmp;
|
||||
} else if (!contains_id && contains_pos) {
|
||||
int r = sscanf(c, "%d:%s", &detector_id_, tmp);
|
||||
if (r != 2) {
|
||||
throw(std::invalid_argument("Cannot decode detector id from: \"" + std::string(c) + "\"\n"));
|
||||
throw(std::invalid_argument("Cannot decode detector id from: \"" +
|
||||
std::string(c) + "\"\n"));
|
||||
}
|
||||
command_ = tmp;
|
||||
} else {
|
||||
@ -71,12 +71,11 @@ void CmdLineParser::DecodeIdAndPosition(const char *c) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<char *> CmdLineParser::argv() {
|
||||
std::vector<char *> vec;
|
||||
if (command_.empty()!=true){
|
||||
std::vector<const char *> CmdLineParser::argv() const {
|
||||
std::vector<const char *> vec;
|
||||
if (command_.empty() != true) {
|
||||
vec.push_back(&command_.front());
|
||||
}
|
||||
|
||||
for (auto &arg : arguments_) {
|
||||
vec.push_back(&arg.front());
|
||||
}
|
||||
|
@ -20,9 +20,7 @@ IpAddr::IpAddr(const std::string &address) {
|
||||
inet_pton(AF_INET, address.c_str(), &addr_);
|
||||
}
|
||||
|
||||
IpAddr::IpAddr(const char *address) {
|
||||
inet_pton(AF_INET, address, &addr_);
|
||||
}
|
||||
IpAddr::IpAddr(const char *address) { inet_pton(AF_INET, address, &addr_); }
|
||||
|
||||
std::string IpAddr::str() const {
|
||||
char ipstring[INET_ADDRSTRLEN]{};
|
||||
@ -31,9 +29,9 @@ std::string IpAddr::str() const {
|
||||
}
|
||||
std::string IpAddr::hex() const {
|
||||
std::ostringstream ss;
|
||||
ss << std::hex << std::setfill('0');
|
||||
for (int i = 0; i != 4; ++i) {
|
||||
ss << std::hex << std::setfill('0') << std::setw(2)
|
||||
<< ((addr_ >> i * 8) & 0xFF);
|
||||
ss << std::setw(2) << ((addr_ >> i * 8) & 0xFF);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
@ -56,18 +54,14 @@ std::string MacAddr::to_hex(const char delimiter) const {
|
||||
for (int i = 32; i >= 0; i -= 8) {
|
||||
if (delimiter)
|
||||
ss << delimiter;
|
||||
ss << ((addr_ >> i) & 0xFF);
|
||||
ss << std::setw(2) << ((addr_ >> i) & 0xFF);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string MacAddr::str() const {
|
||||
return to_hex(':');
|
||||
}
|
||||
std::string MacAddr::str() const { return to_hex(':'); }
|
||||
|
||||
std::string MacAddr::hex() const {
|
||||
return to_hex();
|
||||
}
|
||||
std::string MacAddr::hex() const { return to_hex(); }
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const IpAddr &addr) {
|
||||
return out << addr.str();
|
||||
|
@ -2,18 +2,126 @@
|
||||
#include "catch.hpp"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
//tests to add
|
||||
//help for all docs
|
||||
//command for all depreciated commands
|
||||
// tests to add
|
||||
// help for all docs
|
||||
// command for all depreciated commands
|
||||
|
||||
TEST_CASE("Parse with no arguments results in no command and default id") {
|
||||
//build up argc and argv
|
||||
//first argument is the command used to call the binary
|
||||
using vs = std::vector<std::string>;
|
||||
|
||||
SCENARIO("Construction", "[support]") {
|
||||
GIVEN("A default constructed CmdLineParser") {
|
||||
CmdLineParser p;
|
||||
THEN("The state of the object is valid") {
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command().empty());
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().empty());
|
||||
REQUIRE(p.argv().data() == nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SCENARIO("Parsing a string with the command line parser", "[support]") {
|
||||
GIVEN("A CmdLineParser") {
|
||||
CmdLineParser p;
|
||||
WHEN("Parsing an empty string") {
|
||||
std::string s;
|
||||
p.Parse(s);
|
||||
THEN("command and arguments are empty") {
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command().empty());
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().empty());
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with a single command") {
|
||||
std::string s = "vrf";
|
||||
p.Parse(s);
|
||||
THEN("command is assigned and id's remain default") {
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().size() == 1);
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with command and value") {
|
||||
std::string s = "vthreshold 1500";
|
||||
p.Parse(s);
|
||||
THEN("cmd and value are assigned and id's remain default") {
|
||||
REQUIRE(p.command() == "vthreshold");
|
||||
REQUIRE(p.arguments()[0] == "1500");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with detector id and command") {
|
||||
vs arg{"9:vcp", "53:vthreshold", "128:vtrim", "5:threshold"};
|
||||
std::vector<int> det_id{9, 53, 128, 5};
|
||||
vs res{"vcp", "vthreshold", "vtrim", "threshold"};
|
||||
|
||||
THEN("Values are correctly decoded") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
p.Parse(arg[i]);
|
||||
REQUIRE(p.detector_id() == det_id[i]);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == res[i]);
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().size() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
WHEN("Parsing a string with multi_id detector id and command") {
|
||||
vs arg{"8-12:vrf", "0-52:vcmp", "19-10:vtrim", "31-127:threshold"};
|
||||
std::vector<int> det_id{12, 52, 10, 127};
|
||||
std::vector<int> multi_id{8, 0, 19, 31};
|
||||
vs res{"vrf", "vcmp", "vtrim", "threshold"};
|
||||
|
||||
THEN("Values are correctly decoded") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
p.Parse(arg[i]);
|
||||
REQUIRE(p.detector_id() == det_id[i]);
|
||||
REQUIRE(p.multi_id() == multi_id[i]);
|
||||
REQUIRE(p.command() == res[i]);
|
||||
REQUIRE(p.arguments().empty());
|
||||
REQUIRE(p.argv().size() == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Parsing string with cmd and multiple arguments") {
|
||||
std::string s = "trimen 5000 6000 7000";
|
||||
p.Parse(s);
|
||||
THEN("cmd and args are correct") {
|
||||
REQUIRE(p.command() == "trimen");
|
||||
REQUIRE(p.arguments().size() == 3);
|
||||
REQUIRE(p.arguments()[0] == "5000");
|
||||
REQUIRE(p.arguments()[1] == "6000");
|
||||
REQUIRE(p.arguments()[2] == "7000");
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("Cliend id and or detector id cannot be decoded") {
|
||||
vs arg{"o:cmd", "-5:cmd", "aedpva:cmd",
|
||||
"5-svc:vrf", "asv-5:cmd", "savc-asa:cmd"};
|
||||
THEN("Parsing Throws") {
|
||||
for (size_t i = 0; i != arg.size(); ++i) {
|
||||
REQUIRE_THROWS(p.Parse(arg[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Parse with no arguments results in no command and default id",
|
||||
"[support]") {
|
||||
// build up argc and argv
|
||||
// first argument is the command used to call the binary
|
||||
int argc = 1;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
|
||||
const char* const argv[]{"call"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -23,25 +131,11 @@ TEST_CASE("Parse with no arguments results in no command and default id") {
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse empty string") {
|
||||
std::string s;
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command().empty());
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a command without client id and detector id results in default") {
|
||||
TEST_CASE(
|
||||
"Parse a command without client id and detector id results in default",
|
||||
"[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char*const argv[]{"caller", "vrf"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -51,27 +145,10 @@ TEST_CASE("Parse a command without client id and detector id results in default"
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a string without client id and detector id results in default") {
|
||||
std::string s = "vrf";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Parse a command with value but without client or detector id") {
|
||||
TEST_CASE("Parse a command with value but without client or detector id",
|
||||
"[support]") {
|
||||
int argc = 3;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "vrf";
|
||||
char a2[] = "3000";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
argv[2] = static_cast<char *>(a2);
|
||||
|
||||
const char* const argv[]{"caller", "vrf", "3000"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -81,26 +158,10 @@ TEST_CASE("Parse a command with value but without client or detector id") {
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "3000");
|
||||
}
|
||||
TEST_CASE("Parse a string with value but without client or detector id") {
|
||||
std::string s = "vrf 3000\n";
|
||||
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == -1);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().size() == 1);
|
||||
REQUIRE(p.arguments()[0] == "3000");
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes position") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "7:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
const char*const argv[]{"caller", "7:vrf"};
|
||||
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
@ -110,26 +171,10 @@ TEST_CASE("Decodes position") {
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
TEST_CASE("Decodes position from string") {
|
||||
std::string s = "7:vrf\n";
|
||||
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 7);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes double digit position") {
|
||||
TEST_CASE("Decodes double digit position", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "73:vcmp";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char* const argv[]{"caller", "73:vcmp"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -139,26 +184,9 @@ TEST_CASE("Decodes double digit position") {
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes double digit position from string") {
|
||||
|
||||
std::string s = "73:vcmp";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 73);
|
||||
REQUIRE(p.multi_id() == 0);
|
||||
REQUIRE(p.command() == "vcmp");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Decodes position and id") {
|
||||
TEST_CASE("Decodes position and id", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "5-8:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char* const argv[]{"caller", "5-8:vrf"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
@ -167,94 +195,34 @@ TEST_CASE("Decodes position and id") {
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
TEST_CASE("Decodes position and id from string") {
|
||||
std::string s = "5-8:vrf";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 5);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Double digit id") {
|
||||
TEST_CASE("Double digit id", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "56-8:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char *const argv[]{"caller", "56-8:vrf"};
|
||||
CmdLineParser p;
|
||||
p.Parse(argc, argv);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 56);
|
||||
REQUIRE(p.command() == "vrf");
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Double digit id from string") {
|
||||
std::string s = "56-8:vrf";
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE(p.detector_id() == 8);
|
||||
REQUIRE(p.multi_id() == 56);
|
||||
REQUIRE(p.command() == std::string("vrf"));
|
||||
REQUIRE(p.arguments().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Calling with wrong id throws invalid_argument") {
|
||||
|
||||
TEST_CASE("Calling with wrong id throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "asvldkn:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char *const argv[]{"caller", "asvldkn:vrf"};
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
TEST_CASE("Calling with string with wrong id throws invalid_argument") {
|
||||
std::string s = "asvldkn:vrf";
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(s));
|
||||
}
|
||||
|
||||
TEST_CASE("Calling with wrong client throws invalid_argument") {
|
||||
TEST_CASE("Calling with wrong client throws invalid_argument", "[support]") {
|
||||
int argc = 2;
|
||||
char *argv[argc];
|
||||
char a0[] = "call";
|
||||
char a1[] = "lki-3:vrf";
|
||||
argv[0] = static_cast<char *>(a0);
|
||||
argv[1] = static_cast<char *>(a1);
|
||||
|
||||
const char *const argv[]{"caller", "lki-3:vrf"};
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(argc, argv));
|
||||
}
|
||||
TEST_CASE("Calling with string with wrong client throws invalid_argument") {
|
||||
std::string s = "lki-3:vrf";
|
||||
CmdLineParser p;
|
||||
CHECK_THROWS(p.Parse(s));
|
||||
}
|
||||
|
||||
TEST_CASE("Parses string with two arguments") {
|
||||
std::string s = "trimen 3000 4000\n";
|
||||
TEST_CASE("Build up argv", "[support]") {
|
||||
CmdLineParser p;
|
||||
p.Parse(s);
|
||||
|
||||
REQUIRE("trimen" == p.command());
|
||||
REQUIRE("3000" == p.arguments()[0]);
|
||||
REQUIRE("4000" == p.arguments()[1]);
|
||||
REQUIRE(p.arguments().size() == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Build up argv"){
|
||||
CmdLineParser p;
|
||||
// p.argv();
|
||||
REQUIRE(p.argv().empty());
|
||||
REQUIRE(p.argv().data() == nullptr);
|
||||
|
||||
@ -262,5 +230,4 @@ TEST_CASE("Build up argv"){
|
||||
p.Parse(s);
|
||||
REQUIRE(p.argv().data() != nullptr);
|
||||
REQUIRE(p.argv().size() == 3);
|
||||
|
||||
}
|
@ -11,9 +11,9 @@ using namespace sls;
|
||||
|
||||
TEST_CASE("Convert mac address using classes", "[support]") {
|
||||
|
||||
std::vector<uint64_t> vec_addr{346856806822, 346856806852, 262027939863028};
|
||||
std::vector<uint64_t> vec_addr{346856806822, 346856806852, 262027939863028,0, 281474976710655};
|
||||
std::vector<std::string> vec_ans{"00:50:c2:46:d9:a6", "00:50:c2:46:d9:c4",
|
||||
"ee:50:22:46:d9:f4"};
|
||||
"ee:50:22:46:d9:f4", "00:00:00:00:00:00", "ff:ff:ff:ff:ff:ff"};
|
||||
for (size_t i = 0; i != vec_addr.size(); ++i) {
|
||||
auto mac0 = MacAddr(vec_addr[i]);
|
||||
auto mac1 = MacAddr(vec_ans[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user