mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-16 23:07:13 +02:00
connected command to execute command in receiver pc
This commit is contained in:
@ -2724,6 +2724,18 @@ int multiSlsDetector::exitReceiver(int detPos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int multiSlsDetector::execReceiverCommand(std::string cmd, int detPos) {
|
||||||
|
// single
|
||||||
|
if (detPos >= 0) {
|
||||||
|
return detectors[detPos]->execReceiverCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// multi
|
||||||
|
auto r = parallelCall(&slsDetector::execReceiverCommand, cmd);
|
||||||
|
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string multiSlsDetector::getFilePath(int detPos) {
|
std::string multiSlsDetector::getFilePath(int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
|
@ -1229,6 +1229,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
int exitReceiver(int detPos = -1);
|
int exitReceiver(int detPos = -1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a system command on the receiver server
|
||||||
|
* e.g. mount an nfs disk, reboot and returns answer etc.
|
||||||
|
* @param cmd command to be executed
|
||||||
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int execReceiverCommand(std::string cmd, int detPos = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns output file directory
|
* Returns output file directory
|
||||||
* @param detPos -1 for all detectors in list or specific detector position
|
* @param detPos -1 for all detectors in list or specific detector position
|
||||||
|
@ -5990,6 +5990,30 @@ int slsDetector::exitReceiver() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int slsDetector::execReceiverCommand(std::string cmd) {
|
||||||
|
|
||||||
|
int fnum=F_EXEC_RECEIVER_COMMAND;
|
||||||
|
int ret=FAIL;
|
||||||
|
char arg[MAX_STR_LENGTH];
|
||||||
|
memset(arg,0,sizeof(arg));
|
||||||
|
char retval[MAX_STR_LENGTH];
|
||||||
|
memset(retval,0, sizeof(retval));
|
||||||
|
|
||||||
|
strcpy(arg,cmd.c_str());
|
||||||
|
|
||||||
|
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) {
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "Sending to receiver the command: " << arg << std::endl;
|
||||||
|
#endif
|
||||||
|
if (connectData() == OK){
|
||||||
|
ret=thisReceiver->SendString(fnum,retval,arg);
|
||||||
|
disconnectData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::updateReceiverNoWait() {
|
int slsDetector::updateReceiverNoWait() {
|
||||||
|
|
||||||
@ -7506,3 +7530,5 @@ int slsDetector::writeSettingsFile(std::string fname, sls_detector_module mod,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1377,6 +1377,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
int exitReceiver();
|
int exitReceiver();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a system command on the receiver server
|
||||||
|
* e.g. mount an nfs disk, reboot and returns answer etc.
|
||||||
|
* @param cmd command to be executed
|
||||||
|
* @returns OK or FAIL
|
||||||
|
*/
|
||||||
|
int execReceiverCommand(std::string cmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
updates the shared memory receiving the data from the detector (without asking and closing the connection
|
updates the shared memory receiving the data from the detector (without asking and closing the connection
|
||||||
/returns OK
|
/returns OK
|
||||||
|
@ -112,6 +112,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
|
/*! \page test
|
||||||
|
- <b>rx_execcommand</b> Executes a command on the receiver server. Don't use it!!!!
|
||||||
|
*/
|
||||||
|
descrToFuncMap[i].m_pFuncName="rx_execcommand";//OK
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer;
|
||||||
|
++i;
|
||||||
|
|
||||||
/*! \page test
|
/*! \page test
|
||||||
- <b>flippeddatay [i]</b> enables/disables data being flipped across y axis. 1 enables, 0 disables. Not implemented.
|
- <b>flippeddatay [i]</b> enables/disables data being flipped across y axis. 1 enables, 0 disables. Not implemented.
|
||||||
*/
|
*/
|
||||||
@ -2437,7 +2444,13 @@ string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action, int
|
|||||||
if(myDet->execCommand(std::string(args[1]), detPos)==OK)
|
if(myDet->execCommand(std::string(args[1]), detPos)==OK)
|
||||||
return string("Command executed successfully\n");
|
return string("Command executed successfully\n");
|
||||||
else
|
else
|
||||||
|
return string("Command failed\n");
|
||||||
|
}
|
||||||
|
else if (cmd=="rx_execcommand"){
|
||||||
|
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
|
||||||
|
if(myDet->execReceiverCommand(std::string(args[1]), detPos)==OK)
|
||||||
|
return string("Command executed successfully\n");
|
||||||
|
else
|
||||||
return string("Command failed\n");
|
return string("Command failed\n");
|
||||||
}
|
}
|
||||||
else return("cannot decode command\n");
|
else return("cannot decode command\n");
|
||||||
@ -2451,6 +2464,7 @@ string slsDetectorCommand::helpExitServer(int action){
|
|||||||
os << string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n");
|
os << string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n");
|
||||||
os << string("exitreceiver \t shuts down all the receiver servers.\n");
|
os << string("exitreceiver \t shuts down all the receiver servers.\n");
|
||||||
os << string("execcommand \t executes command in detector server. Don't use it if you do not know what you are doing.\n");
|
os << string("execcommand \t executes command in detector server. Don't use it if you do not know what you are doing.\n");
|
||||||
|
os << 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();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ int slsReceiverTCPIPInterface::exec_command() {
|
|||||||
sysret=system(cmd);
|
sysret=system(cmd);
|
||||||
//should be replaced by popen
|
//should be replaced by popen
|
||||||
if (sysret == 0) {
|
if (sysret == 0) {
|
||||||
sprintf(mess,"Succeeded\n");
|
ret = OK;
|
||||||
} else {
|
} else {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,"Executing Command failed\n");
|
sprintf(mess,"Executing Command failed\n");
|
||||||
@ -436,7 +436,8 @@ int slsReceiverTCPIPInterface::exec_command() {
|
|||||||
|
|
||||||
// send answer
|
// send answer
|
||||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||||
mySock->SendDataOnly(mess,MAX_STR_LENGTH);
|
if (ret == FAIL)
|
||||||
|
mySock->SendDataOnly(mess,MAX_STR_LENGTH);
|
||||||
|
|
||||||
// return ok/fail
|
// return ok/fail
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user