mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
fix
This commit is contained in:
parent
692ade6c17
commit
4240ea57d4
@ -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<patternParameters>();
|
||||
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<uint64_t>(args[2]);
|
||||
pat->word[addr] = StringTo<uint64_t>(args[2]);
|
||||
} else if (cmd == "patioctrl") {
|
||||
if (nargs != 1) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
}
|
||||
pat.patioctrl = StringTo<uint64_t>(args[1]);
|
||||
pat->patioctrl = StringTo<uint64_t>(args[1]);
|
||||
} else if (cmd == "patlimits") {
|
||||
if (nargs != 2) {
|
||||
throw RuntimeError("Invalid arguments for " +
|
||||
ToString(args));
|
||||
}
|
||||
pat.patlimits[0] = StringTo<uint32_t>(args[1]);
|
||||
pat.patlimits[1] = StringTo<uint32_t>(args[2]);
|
||||
if (pat.patlimits[0] >= MAX_PATTERN_LENGTH ||
|
||||
pat.patlimits[1] >= MAX_PATTERN_LENGTH) {
|
||||
pat->patlimits[0] = StringTo<uint32_t>(args[1]);
|
||||
pat->patlimits[1] = StringTo<uint32_t>(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<uint32_t>(args[1]);
|
||||
int patloop2 = StringTo<uint32_t>(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<uint32_t>(args[1]);
|
||||
pat->patnloop[level] = StringTo<uint32_t>(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<uint32_t>(args[1]);
|
||||
if (pat.patwait[level] >= MAX_PATTERN_LENGTH) {
|
||||
pat->patwait[level] = StringTo<uint32_t>(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<uint64_t>(args[1]);
|
||||
pat->patwaittime[level] = StringTo<uint64_t>(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() {
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user