From 4240ea57d425c59ba41ea1cc5562ba5312e8be43 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 23 Jun 2020 14:26:54 +0200 Subject: [PATCH] fix --- slsDetectorSoftware/src/Module.cpp | 31 +++++++++++++---------- slsSupportLib/include/sls_detector_defs.h | 12 ++++----- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 57c53a688..92b3ed460 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2,6 +2,7 @@ #include "ClientSocket.h" #include "SharedMemory.h" #include "ToString.h" +#include "container_utils.h" #include "file_utils.h" #include "network_utils.h" #include "sls_detector_exceptions.h" @@ -1747,7 +1748,7 @@ void Module::setLEDEnable(bool enable) { // Pattern void Module::setPattern(const std::string &fname) { - patternParameters pat; + auto pat = sls::make_unique(); std::ifstream input_file(fname); if (!input_file.is_open()) { throw RuntimeError("Could not open pattern file " + fname + @@ -1778,22 +1779,22 @@ void Module::setPattern(const std::string &fname) { if (addr >= MAX_PATTERN_LENGTH) { throw RuntimeError("Invalid address for " + ToString(args)); } - pat.word[addr] = StringTo(args[2]); + pat->word[addr] = StringTo(args[2]); } else if (cmd == "patioctrl") { if (nargs != 1) { throw RuntimeError("Invalid arguments for " + ToString(args)); } - pat.patioctrl = StringTo(args[1]); + pat->patioctrl = StringTo(args[1]); } else if (cmd == "patlimits") { if (nargs != 2) { throw RuntimeError("Invalid arguments for " + ToString(args)); } - pat.patlimits[0] = StringTo(args[1]); - pat.patlimits[1] = StringTo(args[2]); - if (pat.patlimits[0] >= MAX_PATTERN_LENGTH || - pat.patlimits[1] >= MAX_PATTERN_LENGTH) { + pat->patlimits[0] = StringTo(args[1]); + pat->patlimits[1] = StringTo(args[2]); + if (pat->patlimits[0] >= MAX_PATTERN_LENGTH || + pat->patlimits[1] >= MAX_PATTERN_LENGTH) { throw RuntimeError("Invalid address for " + ToString(args)); } } else if (cmd == "patloop0" || cmd == "patloop1" || @@ -1805,8 +1806,8 @@ void Module::setPattern(const std::string &fname) { int level = cmd[cmd.find_first_of("012")] - '0'; int patloop1 = StringTo(args[1]); int patloop2 = StringTo(args[2]); - pat.patloop[level * 2 + 0] = patloop1; - pat.patloop[level * 2 + 1] = patloop2; + pat->patloop[level * 2 + 0] = patloop1; + pat->patloop[level * 2 + 1] = patloop2; if (patloop1 >= MAX_PATTERN_LENGTH || patloop2 >= MAX_PATTERN_LENGTH) { throw RuntimeError("Invalid address for " + ToString(args)); @@ -1818,7 +1819,7 @@ void Module::setPattern(const std::string &fname) { ToString(args)); } int level = cmd[cmd.find_first_of("012")] - '0'; - pat.patnloop[level] = StringTo(args[1]); + pat->patnloop[level] = StringTo(args[1]); } else if (cmd == "patwait0" || cmd == "patwait1" || cmd == "patwait2") { if (nargs != 1) { @@ -1826,8 +1827,8 @@ void Module::setPattern(const std::string &fname) { ToString(args)); } int level = cmd[cmd.find_first_of("012")] - '0'; - pat.patwait[level] = StringTo(args[1]); - if (pat.patwait[level] >= MAX_PATTERN_LENGTH) { + pat->patwait[level] = StringTo(args[1]); + if (pat->patwait[level] >= MAX_PATTERN_LENGTH) { throw RuntimeError("Invalid address for " + ToString(args)); } } else if (cmd == "patwaittime0" || cmd == "patwaittime1" || @@ -1837,13 +1838,15 @@ void Module::setPattern(const std::string &fname) { ToString(args)); } int level = cmd[cmd.find_first_of("012")] - '0'; - pat.patwaittime[level] = StringTo(args[1]); + pat->patwaittime[level] = StringTo(args[1]); } else { throw RuntimeError("Unknown command in pattern file " + cmd); } } } - sendToDetector(F_SET_PATTERN, pat, nullptr); + LOG(logDEBUG1) << "Sending pattern from file to detector:" << *pat; + sendToDetector(F_SET_PATTERN, pat.get(), sizeof(patternParameters), nullptr, + 0); } uint64_t Module::getPatternIOControl() { diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 651e23da6..9f60c9f15 100644 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -442,13 +442,13 @@ typedef struct { /** pattern structure */ struct patternParameters { - uint64_t word[MAX_PATTERN_LENGTH] = {}; + uint64_t word[MAX_PATTERN_LENGTH]{}; uint64_t patioctrl{0}; - uint32_t patlimits[2] = {}; - uint32_t patloop[6] = {}; - uint32_t patnloop[3] = {}; - uint32_t patwait[3] = {}; - uint64_t patwaittime[3] = {}; + uint32_t patlimits[2]{}; + uint32_t patloop[6]{}; + uint32_t patnloop[3]{}; + uint32_t patwait[3]{}; + uint64_t patwaittime[3]{}; } __attribute__((packed)); #endif