mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 07:20:01 +02:00
clang-format
This commit is contained in:
parent
0f869e1215
commit
d935e78763
@ -5,10 +5,10 @@
|
|||||||
#include "CmdLineParser.h"
|
#include "CmdLineParser.h"
|
||||||
#include "CmdProxy.h"
|
#include "CmdProxy.h"
|
||||||
#include "container_utils.h"
|
#include "container_utils.h"
|
||||||
#include "string_utils.h"
|
|
||||||
#include "multiSlsDetector.h"
|
#include "multiSlsDetector.h"
|
||||||
#include "slsDetectorCommand.h"
|
#include "slsDetectorCommand.h"
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -22,59 +22,69 @@ inline int dummyCallback(detectorData *d, int p, void *) {
|
|||||||
|
|
||||||
class multiSlsDetectorClient {
|
class multiSlsDetectorClient {
|
||||||
public:
|
public:
|
||||||
multiSlsDetectorClient(int argc, char *argv[], int action, multiSlsDetector *myDetector = nullptr):
|
multiSlsDetectorClient(int argc, char *argv[], int action,
|
||||||
action_(action),
|
multiSlsDetector *myDetector = nullptr)
|
||||||
detPtr(myDetector){
|
: action_(action), detPtr(myDetector) {
|
||||||
parser.Parse(argc, argv);
|
parser.Parse(argc, argv);
|
||||||
runCommand();
|
runCommand();
|
||||||
|
|
||||||
}
|
}
|
||||||
multiSlsDetectorClient(const std::string& args, int action, multiSlsDetector *myDetector = nullptr):
|
multiSlsDetectorClient(const std::string &args, int action,
|
||||||
action_(action),
|
multiSlsDetector *myDetector = nullptr)
|
||||||
detPtr(myDetector){
|
: action_(action), detPtr(myDetector) {
|
||||||
parser.Parse(args);
|
parser.Parse(args);
|
||||||
runCommand();
|
runCommand();
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
int action_;
|
|
||||||
CmdLineParser parser;
|
|
||||||
multiSlsDetector* detPtr = nullptr;
|
|
||||||
|
|
||||||
void runCommand(){
|
private:
|
||||||
|
int action_;
|
||||||
|
CmdLineParser parser;
|
||||||
|
multiSlsDetector *detPtr = nullptr;
|
||||||
|
|
||||||
|
void runCommand() {
|
||||||
bool verify = true;
|
bool verify = true;
|
||||||
bool update = true;
|
bool update = true;
|
||||||
if (action_ == slsDetectorDefs::PUT_ACTION && parser.n_arguments() == 0) {
|
if (action_ == slsDetectorDefs::PUT_ACTION &&
|
||||||
std::cout << "Wrong usage - should be: " << parser.executable() << "[id-][pos:]channel arg" << std::endl;
|
parser.n_arguments() == 0) {
|
||||||
|
std::cout << "Wrong usage - should be: " << parser.executable()
|
||||||
|
<< "[id-][pos:]channel arg" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if (action_ == slsDetectorDefs::GET_ACTION && parser.command().empty()) {
|
if (action_ == slsDetectorDefs::GET_ACTION &&
|
||||||
std::cout << "Wrong usage - should be: " << parser.executable() << "[id-][pos:]channel arg" << std::endl;
|
parser.command().empty()) {
|
||||||
|
std::cout << "Wrong usage - should be: " << parser.executable()
|
||||||
|
<< "[id-][pos:]channel arg" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (action_ == slsDetectorDefs::READOUT_ACTION && parser.detector_id() != -1) {
|
if (action_ == slsDetectorDefs::READOUT_ACTION &&
|
||||||
std::cout << "detector_id: " << parser.detector_id() << " ,readout of individual detectors is not allowed!" << std::endl;
|
parser.detector_id() != -1) {
|
||||||
|
std::cout << "detector_id: " << parser.detector_id()
|
||||||
|
<< " ,readout of individual detectors is not allowed!"
|
||||||
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// special commands
|
// special commands
|
||||||
if (parser.command() == "free") {
|
if (parser.command() == "free") {
|
||||||
multiSlsDetector::freeSharedMemory(parser.multi_id(), parser.detector_id());
|
multiSlsDetector::freeSharedMemory(parser.multi_id(),
|
||||||
|
parser.detector_id());
|
||||||
return;
|
return;
|
||||||
} // get user details without verify sharedMultiSlsDetector version
|
} // get user details without verify sharedMultiSlsDetector version
|
||||||
else if ((parser.command() == "user") && (action_ == slsDetectorDefs::GET_ACTION)) {
|
else if ((parser.command() == "user") &&
|
||||||
|
(action_ == slsDetectorDefs::GET_ACTION)) {
|
||||||
verify = false;
|
verify = false;
|
||||||
update = false;
|
update = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::cout<<"id:"<<id<<" pos:"<<pos<<std::endl;
|
// std::cout<<"id:"<<id<<" pos:"<<pos<<std::endl;
|
||||||
// create multiSlsDetector class if required
|
// create multiSlsDetector class if required
|
||||||
std::unique_ptr<multiSlsDetector> localDet;
|
std::unique_ptr<multiSlsDetector> localDet;
|
||||||
if (detPtr == nullptr) {
|
if (detPtr == nullptr) {
|
||||||
try {
|
try {
|
||||||
localDet = sls::make_unique<multiSlsDetector>(parser.multi_id(), verify, update);
|
localDet = sls::make_unique<multiSlsDetector>(parser.multi_id(),
|
||||||
|
verify, update);
|
||||||
detPtr = localDet.get();
|
detPtr = localDet.get();
|
||||||
} catch (const RuntimeError &e) {
|
} catch (const RuntimeError &e) {
|
||||||
/*std::cout << e.GetMessage() << std::endl;*/
|
/*std::cout << e.GetMessage() << std::endl;*/
|
||||||
@ -89,28 +99,27 @@ class multiSlsDetectorClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call CmdProxy which execute the command if it exists, on success
|
||||||
//Call CmdProxy which execute the command if it exists, on success returns an empty string
|
// returns an empty string If the command is not in CmdProxy but
|
||||||
//If the command is not in CmdProxy but deprecated the new command is returned
|
// deprecated the new command is returned
|
||||||
if(action_ != slsDetectorDefs::READOUT_ACTION){
|
if (action_ != slsDetectorDefs::READOUT_ACTION) {
|
||||||
sls::CmdProxy<multiSlsDetector> proxy(detPtr);
|
sls::CmdProxy<multiSlsDetector> proxy(detPtr);
|
||||||
auto cmd = proxy.Call(parser.command(), parser.arguments(), parser.detector_id());
|
auto cmd = proxy.Call(parser.command(), parser.arguments(),
|
||||||
if (cmd.empty()){
|
parser.detector_id());
|
||||||
|
if (cmd.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
parser.setCommand(cmd);
|
parser.setCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// call multi detector command line
|
// call multi detector command line
|
||||||
slsDetectorCommand myCmd(detPtr);
|
slsDetectorCommand myCmd(detPtr);
|
||||||
std::string answer = myCmd.executeLine(parser.n_arguments()+1, parser.argv().data(), action_, parser.detector_id());
|
std::string answer =
|
||||||
|
myCmd.executeLine(parser.n_arguments() + 1, parser.argv().data(),
|
||||||
|
action_, parser.detector_id());
|
||||||
|
|
||||||
if (parser.multi_id()!=0)
|
if (parser.multi_id() != 0)
|
||||||
std::cout << parser.multi_id() << '-';
|
std::cout << parser.multi_id() << '-';
|
||||||
if (parser.detector_id() != -1)
|
if (parser.detector_id() != -1)
|
||||||
std::cout << parser.detector_id() << ':';
|
std::cout << parser.detector_id() << ':';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user