Merge branch 'developer' into dev/servers-opt
Build on RHEL9 docker image / build (push) Successful in 4m0s
Build on RHEL8 docker image / build (push) Successful in 5m13s
Run Simulator Tests on local RHEL9 / build (push) Successful in 20m42s
Run Simulator Tests on local RHEL8 / build (push) Successful in 24m8s

This commit is contained in:
Erik Fröjdh authored and GitHub committed 2026-10-23 14:23:32 +02:00
commit e25b4e5f00
11 files changed
+312 -82

No files matched your search

@@ -304,8 +304,6 @@ patternParameters *setChannelRegisterChip(int ichip, char *mask,
chanReg |= (0x1 << (3 + icounter));
}
}
chanReg /= 2;
// deserialize
if (chanReg & CHAN_REG_BAD_CHANNEL_MSK) {
LOG(logINFOBLUE,
("badchannel [chanReg:0x%x modCounter:%d, modChan:%d, "
@@ -313,6 +311,8 @@ patternParameters *setChannelRegisterChip(int ichip, char *mask,
chanReg, ichip * NCHAN + ich * NCOUNTERS,
ichip * NCHAN_1_COUNTER + ich, ichip, ich));
}
chanReg /= 2;
// deserialize
for (int i = 0; i < 23; i++) {
patword = clearBit(SIGNAL_clk, patword);
pat->word[iaddr++] = patword;
@@ -149,10 +149,12 @@ int validate_writePatternWord(char *message, int addr, uint64_t word) {
uint64_t retval = readPatternWord(addr);
LOG(logDEBUG1, ("Pattern word (addr:0x%x) retval: 0x%llx\n", addr,
(long long int)retval));
char mode[128];
memset(mode, 0, sizeof(mode));
sprintf(mode, "set pattern word for addr 0x%x", addr);
validate64(&ret, message, word, retval, "set pattern word", HEX);
// runs for every pattern word: only build the message on a mismatch
if (retval != word) {
char mode[64];
sprintf(mode, "set pattern word for addr 0x%x", addr);
validate64(&ret, message, word, retval, mode, HEX);
}
#endif
return ret;
}
@@ -700,7 +702,7 @@ int loadPattern(char *message, enum TLogLevel printLevel,
int ret = OK;
memset(clientPatternfile, 0, MAX_STR_LENGTH);
memcpy(clientPatternfile, patfname, MAX_STR_LENGTH);
printf("Client Pattern File:%s\n", clientPatternfile);
LOG(logDEBUG1, ("Client Pattern File:%s\n", clientPatternfile));
#ifdef MYTHEN3D
trimmingPrint = printLevel;
#endif
@@ -542,30 +542,30 @@ int main(int argc, char *argv[]) {
for (int i = 0; i != f.numReceivers; ++i) {
uint16_t port = f.port + i;
sem_t *semaphore = &semaphores[i];
threads.emplace_back(
[i, semaphore, port, user_data, &threadException]() {
LOG(sls::logINFOBLUE) << "Thread " << i << " [ Tid: "
<< sls::getThreadId() << ']';
try {
sls::Receiver receiver(port);
receiver.registerCallBackStartAcquisition(
StartAcquisitionCallback, user_data);
receiver.registerCallBackAcquisitionFinished(
AcquisitionFinishedCallback, user_data);
receiver.registerCallBackRawDataReady(GetDataCallback,
user_data);
threads.emplace_back([i, semaphore, port, user_data,
&threadException]() {
LOG(sls::logINFOBLUE)
<< "Thread " << i << " [ Tid: " << sls::getThreadId() << ']';
try {
sls::Receiver receiver(port);
receiver.registerCallBackStartAcquisition(
StartAcquisitionCallback, user_data);
receiver.registerCallBackAcquisitionFinished(
AcquisitionFinishedCallback, user_data);
receiver.registerCallBackRawDataReady(GetDataCallback,
user_data);
/** - as long as no Ctrl+C */
// each child shares the common semaphore
sem_wait(semaphore);
} catch (...) {
// capture exception and raise SIGINT to exit gracefully
threadException = std::current_exception();
raise(SIGINT);
}
LOG(sls::logINFOBLUE) << "Exiting Thread " << i << " [ Tid: "
<< sls::getThreadId() << " ]";
});
/** - as long as no Ctrl+C */
// each child shares the common semaphore
sem_wait(semaphore);
} catch (...) {
// capture exception and raise SIGINT to exit gracefully
threadException = std::current_exception();
raise(SIGINT);
}
LOG(sls::logINFOBLUE) << "Exiting Thread " << i
<< " [ Tid: " << sls::getThreadId() << " ]";
});
}
for (auto &t : threads) {
+8 -7
View File
@@ -177,9 +177,8 @@ int main(int argc, char *argv[]) {
/** - if child process */
else if (pid == 0) {
LOG(sls::logINFOBLUE)
<< "Child process " << i << " [ Tid: " << sls::getThreadId()
<< ']';
LOG(sls::logINFOBLUE) << "Child process " << i
<< " [ Tid: " << sls::getThreadId() << ']';
try {
uint16_t port = m.port + i;
@@ -210,13 +209,15 @@ int main(int argc, char *argv[]) {
// each child process gets a copy of the semaphore
sem_wait(&semaphore);
sem_destroy(&semaphore);
LOG(sls::logINFOBLUE) << "Exiting Child Process [ Tid: "
<< sls::getThreadId() << ']';
LOG(sls::logINFOBLUE)
<< "Exiting Child Process [ Tid: " << sls::getThreadId()
<< ']';
exit(EXIT_SUCCESS);
} catch (...) {
sem_destroy(&semaphore);
LOG(sls::logINFOBLUE) << "Exiting Child Process [ Tid: "
<< sls::getThreadId() << " ]";
LOG(sls::logINFOBLUE)
<< "Exiting Child Process [ Tid: " << sls::getThreadId()
<< " ]";
exit(EXIT_FAILURE);
}
}
+1 -2
View File
@@ -352,8 +352,7 @@ T StringTo(const std::string &f, const std::string &unit) {
}
}
template <typename T,
std::enable_if_t<!is_container<T>::value, int> = 0>
template <typename T, std::enable_if_t<!is_container<T>::value, int> = 0>
T StringTo(const std::string &t) {
std::string tmp{t};
auto unit = RemoveUnit(tmp);
+25 -5
View File
@@ -2,32 +2,52 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include <iosfwd>
#include <stdint.h>
#include <string>
namespace sls {
struct SemanticVersion {
int major{0};
int minor{0};
int patch{0};
std::string prerelease{};
std::string toString() const;
bool operator==(const SemanticVersion &other) const;
bool operator<=(const SemanticVersion &other) const;
};
class Version {
private:
std::string version_;
/** Note: "0.0.0" is considered not semantic versioning here */
bool hasSemanticVersioning_{false};
SemanticVersion version_{};
std::string date_;
inline static const std::string defaultVersion_[] = {"developer", "0.0.0"};
SemanticVersion parseSemanticVersion(const std::string &version);
public:
explicit Version(const std::string &s);
std::string toString() const;
bool hasSemanticVersioning() const;
std::string getVersion() const;
std::string getDate() const;
std::string concise() const;
int getMajorVersion() const;
// expects semantic versioning
// throws if not semantic versioning
SemanticVersion getSemanticVersion() const;
int getMajorVersion() const;
int getMinorVersion() const;
int getPatchVersion() const;
std::string getPrereleaseVersion() const;
bool isBackwardCompatible(const Version &other) const;
bool operator!=(const Version &other) const;
bool operator==(const Version &other) const;
bool operator<=(const Version &other) const;
};
std::ostream &operator<<(std::ostream &out, const SemanticVersion &v);
std::ostream &operator<<(std::ostream &out, const Version &v);
} // namespace sls
+1 -1
View File
@@ -9,5 +9,5 @@
#define APIEIGER "0.0.0 0x260807"
#define APIXILINXCTB "0.0.0 0x260813"
#define APIJUNGFRAU "0.0.0 0x261002"
#define APIMYTHEN3 "0.0.0 0x260506"
#define APIMYTHEN3 "0.0.0 0x261022"
#define APIMATTERHORN "0.0.0 0x260529"
+124 -34
View File
@@ -1,84 +1,174 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "sls/Version.h"
#include "sls/logger.h"
#include "sls/sls_detector_exceptions.h"
#include "sls/string_utils.h"
#include <cstdio>
#include <sstream>
namespace sls {
std::string SemanticVersion::toString() const {
std::ostringstream oss;
oss << major << "." << minor << "." << patch;
if (!prerelease.empty()) {
oss << prerelease;
}
return oss.str();
}
bool SemanticVersion::operator==(const SemanticVersion &other) const {
return major == other.major && minor == other.minor &&
patch == other.patch && prerelease == other.prerelease;
}
bool SemanticVersion::operator<=(const SemanticVersion &other) const {
if (major != other.major)
return major < other.major;
if (minor != other.minor)
return minor < other.minor;
if (patch != other.patch)
return patch < other.patch;
// A release version is greater than its prerelease
if (prerelease.empty() && !other.prerelease.empty())
return false;
if (!prerelease.empty() && other.prerelease.empty())
return true;
return prerelease <= other.prerelease;
}
SemanticVersion Version::parseSemanticVersion(const std::string &version) {
SemanticVersion ver;
// assuming only released versions have semantic versioning
if (version == "developer" || version == "0.0.0") {
return ver;
}
char prereleaseBuffer[256] = {'\0'};
// Parse major.minor.patch and capture any optional trailing suffix.
const int scanned = sscanf(version.c_str(), "%d.%d.%d%255s", &ver.major,
&ver.minor, &ver.patch, prereleaseBuffer);
if (scanned == 3 || scanned == 4) {
hasSemanticVersioning_ = true;
if (scanned == 4)
ver.prerelease = prereleaseBuffer;
else
ver.prerelease.clear();
}
return ver;
}
Version::Version(const std::string &s) {
auto list = split(s, ' ');
// only date from previous releases
if (list.size() == 1) {
date_ = list[0];
}
// semantic versioning + date
else {
version_ = list[0];
auto version = list[0];
date_ = list[1];
version_ = parseSemanticVersion(version);
}
}
bool Version::hasSemanticVersioning() const {
return (version_ != defaultVersion_[0]) && (version_ != defaultVersion_[1]);
std::string Version::toString() const {
std::ostringstream oss;
oss << version_ << " " << getDate();
return oss.str();
}
std::string Version::getVersion() const { return version_; }
bool Version::hasSemanticVersioning() const { return hasSemanticVersioning_; }
std::string Version::getVersion() const { return version_.toString(); }
std::string Version::getDate() const { return date_; }
std::string Version::concise() const {
if (hasSemanticVersioning())
return version_;
if (hasSemanticVersioning_)
return version_.toString();
return date_;
}
int Version::getMajorVersion() const {
int major = 0, minor = 0, patch = 0;
if (sscanf(version_.c_str(), "%d.%d.%d", &major, &minor, &patch) == 3) {
return major;
SemanticVersion Version::getSemanticVersion() const {
if (!hasSemanticVersioning_) {
throw sls::RuntimeError("No semantic versioning available for " +
toString());
}
throw sls::RuntimeError("Could not get major version from " + version_);
return version_;
}
int Version::getMajorVersion() const {
if (!hasSemanticVersioning_) {
throw sls::RuntimeError("Could not get major version from " +
toString());
}
return version_.major;
}
int Version::getMinorVersion() const {
if (!hasSemanticVersioning_) {
throw sls::RuntimeError("Could not get minor version from " +
toString());
}
return version_.minor;
}
int Version::getPatchVersion() const {
if (!hasSemanticVersioning_) {
throw sls::RuntimeError("Could not get patch version from " +
toString());
}
return version_.patch;
}
std::string Version::getPrereleaseVersion() const {
if (!hasSemanticVersioning_) {
throw sls::RuntimeError("Could not get prerelease version from " +
toString());
}
return version_.prerelease;
}
bool Version::isBackwardCompatible(const Version &other) const {
if (!hasSemanticVersioning_ || !other.hasSemanticVersioning()) {
throw sls::RuntimeError("Cannot check backward compatibility without "
"semantic versioning for " +
toString() + " and " + other.toString());
}
return getMajorVersion() == other.getMajorVersion();
}
bool Version::operator==(const Version &other) const {
if (hasSemanticVersioning() && other.hasSemanticVersioning()) {
return version_ == other.getSemanticVersion();
}
return date_ == other.getDate();
}
bool Version::operator!=(const Version &other) const {
return !(*this == other);
}
bool Version::operator==(const Version &other) const {
// both have semantic versioning
if (hasSemanticVersioning() && other.hasSemanticVersioning()) {
return version_ == other.getVersion();
}
// compare dates
return date_ == other.getDate();
}
bool Version::operator<=(const Version &other) const {
// both have semantic versioning
if (hasSemanticVersioning() && other.hasSemanticVersioning()) {
// release version
std::string otherVersion = other.getVersion();
if (version_ == otherVersion)
return true;
// less than
return (std::lexicographical_compare(version_.begin(), version_.end(),
otherVersion.begin(),
otherVersion.end()));
return version_ <= other.getSemanticVersion();
}
// compare dates
return date_ <= other.getDate();
}
std::ostream &operator<<(std::ostream &out, const SemanticVersion &v) {
return out << v.toString();
}
std::ostream &operator<<(std::ostream &out, const Version &v) {
std::ostringstream oss;
oss << v.getVersion() << " " << v.getDate();
return out << oss.str();
return out << v.toString();
}
} // namespace sls
+2 -2
View File
@@ -415,10 +415,10 @@ TEST_CASE("string to timingInfoDecoder") {
defs::timingInfoDecoder::SHINE);
}
TEST_CASE("Convert string to vector of ints") {
REQUIRE(StringTo<std::vector<int>>("1, 2, 3") == std::vector<int>{1, 2, 3});
REQUIRE(StringTo<std::vector<int>>(" 4 ,5,6 ") == std::vector<int>{4, 5, 6});
REQUIRE(StringTo<std::vector<int>>(" 4 ,5,6 ") ==
std::vector<int>{4, 5, 6});
REQUIRE(StringTo<std::vector<int>>("[8]") == std::vector<int>{8});
REQUIRE(StringTo<std::vector<int>>("9, ") == std::vector<int>{9});
REQUIRE(StringTo<std::vector<int>>("") == std::vector<int>{});
+119 -1
View File
@@ -9,11 +9,129 @@ TEST_CASE("check if version is semantic", "[version]") {
auto [version_string, has_semantic_version] =
GENERATE(std::make_tuple("developer 0x250512", false),
std::make_tuple("0.0.0 0x250512", false));
std::make_tuple("0.0.0 0x250512", false),
std::make_tuple("10.1.1 0x250512", true),
std::make_tuple("0x250512", false));
Version version(version_string);
CHECK(version.hasSemanticVersioning() == has_semantic_version);
}
TEST_CASE("semantic version ordering compares numerically", "[version]") {
Version v9("9.1.1 0x250512");
Version v10("10.0.1 0x250512");
CHECK(v9 <= v10);
CHECK_FALSE(v10 <= v9);
}
TEST_CASE("semantic version compares prerelease lexicographically",
"[version]") {
Version rc("10.1.1.rc 0x250512");
Version zz("10.1.1.zz 0x250512");
CHECK(rc <= zz);
CHECK_FALSE(zz <= rc);
}
TEST_CASE("semantic version compares prerelease with no prerelease",
"[version]") {
Version prerelease("10.1.1.rc 0x250512");
Version release("10.1.1 0x250512");
CHECK(prerelease <= release);
CHECK_FALSE(release <= prerelease);
}
TEST_CASE(
"semantic comparison falls back to date on malformed semantic version",
"[version]") {
Version malformed("10.1 0x250512");
Version valid("10.1.1 0x250513");
CHECK(malformed <= valid);
CHECK_FALSE(valid <= malformed);
}
TEST_CASE("semantic version compares prerelease and without", "[version]") {
Version v1011rc("10.1.1.rc 0x250512");
Version v1010("10.1.0 0x250512");
CHECK_FALSE(v1011rc <= v1010);
CHECK(v1010 <= v1011rc);
}
TEST_CASE("semantic version", "[version]") {
auto version = Version("10.1.1.rc 0x250512");
CHECK(version.hasSemanticVersioning());
CHECK(version.getDate() == "0x250512");
CHECK(version.toString() == "10.1.1.rc 0x250512");
auto semver = version.getSemanticVersion();
CHECK(semver.toString() == "10.1.1.rc");
CHECK(semver.major == 10);
CHECK(semver.minor == 1);
CHECK(semver.patch == 1);
CHECK(semver.prerelease == ".rc");
auto version2 = Version("9.2.1 0x250512");
CHECK(version2.hasSemanticVersioning());
CHECK(version2.getDate() == "0x250512");
CHECK(version2.toString() == "9.2.1 0x250512");
auto semver2 = version2.getSemanticVersion();
CHECK(semver2.toString() == "9.2.1");
CHECK(semver2.major == 9);
CHECK(semver2.minor == 2);
CHECK(semver2.patch == 1);
CHECK(semver2.prerelease == "");
CHECK(version != version2);
CHECK(version2 <= version);
CHECK_FALSE(version <= version2);
auto version3 = Version("10.1.1.rc2 0x250512");
CHECK(version <= version3);
auto version4 = Version("10.1.1.rc3 0x250512");
CHECK(version3 <= version4);
auto release = Version("10.1.1 0x250512");
CHECK(version <= release);
auto dev_version = Version("developer 0x250512");
CHECK_FALSE(dev_version.hasSemanticVersioning());
CHECK(dev_version.getDate() == "0x250512");
CHECK(dev_version.toString() == "0.0.0 0x250512");
REQUIRE_THROWS(dev_version.getSemanticVersion());
REQUIRE_THROWS(dev_version.getMajorVersion());
REQUIRE_THROWS(dev_version.getMinorVersion());
REQUIRE_THROWS(dev_version.getPatchVersion());
REQUIRE_THROWS(dev_version.getPrereleaseVersion());
REQUIRE_THROWS(dev_version.isBackwardCompatible(version));
CHECK(dev_version == version);
auto zero_version = Version("0.0.0 0x250512");
CHECK_FALSE(zero_version.hasSemanticVersioning());
CHECK(zero_version.getDate() == "0x250512");
CHECK(zero_version.toString() == "0.0.0 0x250512");
REQUIRE_THROWS(zero_version.getSemanticVersion());
REQUIRE_THROWS(zero_version.getMajorVersion());
REQUIRE_THROWS(zero_version.getMinorVersion());
REQUIRE_THROWS(zero_version.getPatchVersion());
REQUIRE_THROWS(zero_version.getPrereleaseVersion());
REQUIRE_THROWS(zero_version.isBackwardCompatible(version));
CHECK(zero_version == dev_version);
auto date_only_version = Version("0x250512");
CHECK_FALSE(date_only_version.hasSemanticVersioning());
CHECK(date_only_version.getDate() == "0x250512");
CHECK(date_only_version.toString() == "0.0.0 0x250512");
REQUIRE_THROWS(date_only_version.getSemanticVersion());
REQUIRE_THROWS(date_only_version.getMajorVersion());
REQUIRE_THROWS(date_only_version.getMinorVersion());
REQUIRE_THROWS(date_only_version.getPatchVersion());
REQUIRE_THROWS(date_only_version.getPrereleaseVersion());
REQUIRE_THROWS(date_only_version.isBackwardCompatible(version));
CHECK(date_only_version == zero_version);
}
} // namespace sls