added patfname command to save the file the last pttern was loaded from (#770)

* added patfname command to save the file the last pttern was loaded from
This commit is contained in:
2023-06-22 09:08:48 +02:00
committed by GitHub
parent e18c191247
commit 58cdb5bd20
19 changed files with 120 additions and 28 deletions

View File

@ -2478,9 +2478,23 @@ void Module::setLEDEnable(bool enable) {
}
// Pattern
std::string Module::getPatterFileName() const {
char retval[MAX_STR_LENGTH]{};
sendToDetector(F_GET_PATTERN_FILE_NAME, nullptr, retval);
return retval;
}
void Module::setPattern(const Pattern &pat) {
sendToDetector(F_SET_PATTERN, pat.data(), pat.size(), nullptr, 0);
void Module::setPattern(const Pattern &pat, const std::string &fname) {
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
client.Send(F_SET_PATTERN);
client.Send(pat.data(), pat.size());
char args[MAX_STR_LENGTH]{};
strcpy_safe(args, fname.c_str());
client.Send(args);
if (client.Receive<int>() == FAIL) {
throw DetectorError("Detector " + std::to_string(moduleIndex) +
" returned error: " + client.readErrorMessage());
}
}
Pattern Module::getPattern() {