mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-15 06:17:12 +02:00
Versioning (#568)
- removed getClientServerAPIVersion in server (not used) - removed rxr side (clientversion compatibility check), removed enum as well as it is now done on the client side. - versionAPI.h - GITBRANCH changed to RELEASE - dates for all API changed to "sem_version date". Scripts to compile servers modified for this. Empty "branch" name will end up with developer for sem_version. - Version class with constructor taking in the long version (APILIB date). Other member functions including concise(to get sem_version for new releases and date for old releases), - bypassing initial tests, also now bypasses the client-rxr compatibility check (at rx_hostname command) - previously, compatibility between client-det was ensuring both had the same detector API (eg. same APIJUNGFRAU) - Now, compatibility only checks APILIB (client side) and detector API(eg. APIJUNGFRAU) (detector side) have same major version. It only does backward compatibility test. Rest is upto user to ensure. - If server is from an older release, it will compare dates like previous implementation (APIJUNGFRAU from both client and det) - - previously, compatibility between client-rxr was ensuring both had the same APIRECEIVER - Now, compatibility only checks APILIB (client side) and APIRECEIVER (rxr side) have same major version. It only does backward compatibility test. Rest is upto user to ensure. - If rxr is from an older release, it will compare dates like previous implementation (APIRECEIVER from both client and rxr) - removed APIGUI, evalVersionVariables.sh, genVersionHeader.sh (not needed or not used) - clientVersion, rxrversion and detectorserverversion all return strings and not integers (in hex) anymore. Depending if it has semantic versioning, it will print that or the date if it is too old. - fixed in python (strings for versions) - check_version function in detector server changed to "initial checks" as it only checks server-firmware compatibility and initial server checks. Client compatibilities are moved to client side. - --version gives sem_version and date? Is date needed as well. The clientversion, detserverversion and rxrversion API gives only sem_version (no date) - - formatting
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include "SharedMemory.h"
|
||||
#include "sls/ClientSocket.h"
|
||||
#include "sls/ToString.h"
|
||||
#include "sls/Version.h"
|
||||
#include "sls/bit_utils.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
@ -72,6 +73,7 @@ void Module::setHostname(const std::string &hostname,
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.close();
|
||||
try {
|
||||
initialDetectorServerChecks();
|
||||
checkDetectorVersionCompatibility();
|
||||
LOG(logINFO) << "Module Version Compatibility - Success";
|
||||
} catch (const DetectorError &e) {
|
||||
@ -90,8 +92,21 @@ int64_t Module::getFirmwareVersion() const {
|
||||
return sendToDetector<int64_t>(F_GET_FIRMWARE_VERSION);
|
||||
}
|
||||
|
||||
int64_t Module::getDetectorServerVersion() const {
|
||||
return sendToDetector<int64_t>(F_GET_SERVER_VERSION);
|
||||
std::string Module::getControlServerLongVersion() const {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToDetector(F_GET_SERVER_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string Module::getStopServerLongVersion() const {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToDetectorStop(F_GET_SERVER_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string Module::getDetectorServerVersion() const {
|
||||
Version v(getControlServerLongVersion());
|
||||
return v.concise();
|
||||
}
|
||||
|
||||
std::string Module::getKernelVersion() const {
|
||||
@ -106,11 +121,15 @@ int64_t Module::getSerialNumber() const {
|
||||
|
||||
int Module::getModuleId() const { return sendToDetector<int>(F_GET_MODULE_ID); }
|
||||
|
||||
int64_t Module::getReceiverSoftwareVersion() const {
|
||||
if (shm()->useReceiverFlag) {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_VERSION);
|
||||
}
|
||||
return -1;
|
||||
std::string Module::getReceiverLongVersion() const {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sendToReceiver(F_GET_RECEIVER_VERSION, nullptr, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::string Module::getReceiverSoftwareVersion() const {
|
||||
Version v(getReceiverLongVersion());
|
||||
return v.concise();
|
||||
}
|
||||
|
||||
// static function
|
||||
@ -1279,7 +1298,8 @@ std::string Module::getReceiverHostname() const {
|
||||
return std::string(shm()->rxHostname);
|
||||
}
|
||||
|
||||
void Module::setReceiverHostname(const std::string &receiverIP) {
|
||||
void Module::setReceiverHostname(const std::string &receiverIP,
|
||||
const bool initialChecks) {
|
||||
LOG(logDEBUG1) << "Setting up Receiver hostname with " << receiverIP;
|
||||
|
||||
if (getRunStatus() == RUNNING) {
|
||||
@ -1303,8 +1323,17 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
||||
}
|
||||
strcpy_safe(shm()->rxHostname, host.c_str());
|
||||
shm()->useReceiverFlag = true;
|
||||
checkReceiverVersionCompatibility();
|
||||
|
||||
try {
|
||||
checkReceiverVersionCompatibility();
|
||||
LOG(logINFO) << "Receiver Version Compatibility - Success";
|
||||
} catch (const RuntimeError &e) {
|
||||
if (!initialChecks) {
|
||||
LOG(logWARNING) << "Bypassing Initial Checks at your own risk!";
|
||||
} else {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
// populate parameters from detector
|
||||
rxParameters retval;
|
||||
sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval);
|
||||
@ -3216,41 +3245,95 @@ void Module::initializeModuleStructure(detectorType type) {
|
||||
shm()->nDacs = parameters.nDacs;
|
||||
}
|
||||
|
||||
void Module::initialDetectorServerChecks() {
|
||||
sendToDetector(F_INITIAL_CHECKS);
|
||||
sendToDetectorStop(F_INITIAL_CHECKS);
|
||||
}
|
||||
|
||||
void Module::checkDetectorVersionCompatibility() {
|
||||
int64_t arg = 0;
|
||||
std::string detServers[2] = {getControlServerLongVersion(),
|
||||
getStopServerLongVersion()};
|
||||
for (int i = 0; i != 2; ++i) {
|
||||
// det and client (sem. versioning)
|
||||
Version det(detServers[i]);
|
||||
Version client(APILIB);
|
||||
if (det.hasSemanticVersioning() && client.hasSemanticVersioning()) {
|
||||
if (!det.isBackwardCompatible(client)) {
|
||||
std::ostringstream oss;
|
||||
oss << "Detector (" << (i == 0 ? "Control" : "Stop")
|
||||
<< ") version (" << det.concise()
|
||||
<< ") is incompatible with client version ("
|
||||
<< client.concise() << "). Please update "
|
||||
<< (det <= client ? "detector" : "client");
|
||||
throw sls::RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
// comparing dates(exact match to expected)
|
||||
else {
|
||||
Version expectedDetector(getDetectorAPI());
|
||||
if (det != expectedDetector) {
|
||||
std::ostringstream oss;
|
||||
oss << "Detector (" << (i == 0 ? "Control" : "Stop")
|
||||
<< ") version (" << det.getDate()
|
||||
<< ") is incompatible with client-detector API version ("
|
||||
<< expectedDetector.getDate() << "). Please update "
|
||||
<< (det <= expectedDetector ? "detector" : "client");
|
||||
throw sls::RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG) << "Detector compatible";
|
||||
}
|
||||
}
|
||||
|
||||
const std::string Module::getDetectorAPI() const {
|
||||
switch (shm()->detType) {
|
||||
case EIGER:
|
||||
arg = APIEIGER;
|
||||
break;
|
||||
return APIEIGER;
|
||||
case JUNGFRAU:
|
||||
arg = APIJUNGFRAU;
|
||||
break;
|
||||
return APIJUNGFRAU;
|
||||
case GOTTHARD:
|
||||
arg = APIGOTTHARD;
|
||||
break;
|
||||
return APIGOTTHARD;
|
||||
case CHIPTESTBOARD:
|
||||
arg = APICTB;
|
||||
break;
|
||||
return APICTB;
|
||||
case MOENCH:
|
||||
arg = APIMOENCH;
|
||||
break;
|
||||
return APIMOENCH;
|
||||
case MYTHEN3:
|
||||
arg = APIMYTHEN3;
|
||||
break;
|
||||
return APIMYTHEN3;
|
||||
case GOTTHARD2:
|
||||
arg = APIGOTTHARD2;
|
||||
break;
|
||||
return APIGOTTHARD2;
|
||||
default:
|
||||
throw NotImplementedError(
|
||||
"Check version compatibility is not implemented for this detector");
|
||||
"Detector type not implemented to get Detector API");
|
||||
}
|
||||
sendToDetector(F_CHECK_VERSION, arg, nullptr);
|
||||
sendToDetectorStop(F_CHECK_VERSION, arg, nullptr);
|
||||
}
|
||||
|
||||
void Module::checkReceiverVersionCompatibility() {
|
||||
// TODO! Verify that this works as intended when version don't match
|
||||
sendToReceiver(F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr);
|
||||
// rxr and client (sem. versioning)
|
||||
Version rxr(getReceiverLongVersion());
|
||||
Version client(APILIB);
|
||||
if (rxr.hasSemanticVersioning() && client.hasSemanticVersioning()) {
|
||||
if (!rxr.isBackwardCompatible(client)) {
|
||||
std::ostringstream oss;
|
||||
oss << "Receiver version (" << rxr.concise()
|
||||
<< ") is incompatible with client version (" << client.concise()
|
||||
<< "). Please update "
|
||||
<< (rxr <= client ? "receiver" : "client");
|
||||
throw sls::RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
// comparing dates(exact match to expected)
|
||||
else {
|
||||
Version expectedReceiver(APIRECEIVER);
|
||||
if (rxr != expectedReceiver) {
|
||||
std::ostringstream oss;
|
||||
oss << "Receiver version (" << rxr.getDate()
|
||||
<< ") is incompatible with client-receiver API version ("
|
||||
<< expectedReceiver.getDate() << "). Please update "
|
||||
<< (rxr <= expectedReceiver ? "receiver" : "client");
|
||||
throw sls::RuntimeError(oss.str());
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG) << "Receiver compatible";
|
||||
}
|
||||
|
||||
void Module::setModule(sls_detector_module &module, bool trimbits) {
|
||||
|
Reference in New Issue
Block a user