help should doesn't create detector object (#508)

* help should doesn't create detector object instead passing nullptr to the Proxy
This commit is contained in:
Dhanya Thattil
2022-08-10 12:27:17 +02:00
committed by GitHub
parent 6bf9dbf6d3
commit 07ff28e9e5
2 changed files with 18 additions and 11 deletions

View File

@ -85,6 +85,8 @@ This document describes the differences between v7.0.0 and v6.x.x
- number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status - number of storage cells is not updated in teh receiver. done. and also allowing it to be modified in running status
- refactored memory structure in receiver and listener code (maybe resolves stuck issue, need to check) - refactored memory structure in receiver and listener code (maybe resolves stuck issue, need to check)
- callback modified to have rx header and not rx header pointer - callback modified to have rx header and not rx header pointer
-help should not create a new object
2. Resolved Issues 2. Resolved Issues
================== ==================

View File

@ -53,17 +53,19 @@ int main(int argc, char *argv[]) {
if (parser.isHelp()) if (parser.isHelp())
action = slsDetectorDefs::HELP_ACTION; action = slsDetectorDefs::HELP_ACTION;
else {
// Free shared memory should work also without a detector // Free shared memory should work also without a detector
// if we have an option for verify in the detector constructor // if we have an option for verify in the detector constructor
// we could avoid this but clutter the code // we could avoid this but clutter the code
if (parser.command() == "free" && action != slsDetectorDefs::HELP_ACTION) { if (parser.command() == "free") {
if (parser.detector_id() != -1) if (parser.detector_id() != -1)
std::cout << "Cannot free shared memory of sub-detector\n"; std::cout << "Cannot free shared memory of sub-detector\n";
else else
sls::freeSharedMemory(parser.multi_id()); sls::freeSharedMemory(parser.multi_id());
return 0; return 0;
} }
}
// prevent mem size check // prevent mem size check
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) { if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
@ -71,8 +73,11 @@ int main(int argc, char *argv[]) {
} }
try { try {
sls::Detector det(parser.multi_id()); std::unique_ptr<sls::Detector> det{nullptr};
sls::CmdProxy proxy(&det); if (action != slsDetectorDefs::HELP_ACTION) {
det = sls::make_unique<sls::Detector>(parser.multi_id());
}
sls::CmdProxy proxy(det.get());
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(), proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
action, std::cout, parser.receiver_id()); action, std::cout, parser.receiver_id());
} catch (const sls::RuntimeError &e) { } catch (const sls::RuntimeError &e) {