mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +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:
@ -37,9 +37,7 @@ int main(int argc, char *argv[]) {
|
||||
// Check for --version in the arguments
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!(strcmp(argv[i], "--version")) || !(strcmp(argv[i], "-v"))) {
|
||||
int64_t tempval = APILIB;
|
||||
std::cout << argv[0] << " " << GITBRANCH << " (0x" << std::hex
|
||||
<< tempval << ")" << std::endl;
|
||||
std::cout << argv[0] << " " << APILIB << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -277,21 +277,20 @@ std::string CmdProxy::Versions(int action) {
|
||||
auto t = det->getFirmwareVersion(std::vector<int>{det_id});
|
||||
os << "\nDetector Type: " << OutString(det->getDetectorType())
|
||||
<< "\nPackage Version: " << det->getPackageVersion() << std::hex
|
||||
<< "\nClient Version: 0x" << det->getClientVersion();
|
||||
<< "\nClient Version: " << det->getClientVersion();
|
||||
if (det->getDetectorType().squash() == defs::EIGER) {
|
||||
os << "\nFirmware Version: " << OutString(t);
|
||||
} else {
|
||||
os << "\nFirmware Version: " << OutStringHex(t);
|
||||
}
|
||||
os << "\nDetector Server Version: "
|
||||
<< OutStringHex(
|
||||
<< OutString(
|
||||
det->getDetectorServerVersion(std::vector<int>{det_id}));
|
||||
os << "\nDetector Server Version: "
|
||||
os << "\nDetector Kernel Version: "
|
||||
<< OutString(det->getKernelVersion({std::vector<int>{det_id}}));
|
||||
if (det->getUseReceiverFlag().squash(true)) {
|
||||
os << "\nReceiver Version: "
|
||||
<< OutStringHex(
|
||||
det->getReceiverVersion(std::vector<int>{det_id}));
|
||||
<< OutString(det->getReceiverVersion(std::vector<int>{det_id}));
|
||||
}
|
||||
os << std::dec << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
@ -324,12 +323,12 @@ std::string CmdProxy::ClientVersion(int action) {
|
||||
std::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "\n\tClient software version in format [0xYYMMDD]." << '\n';
|
||||
os << "\n\tClient software version" << '\n';
|
||||
} else if (action == defs::GET_ACTION) {
|
||||
if (!args.empty()) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
os << ToStringHex(det->getClientVersion()) << '\n';
|
||||
os << det->getClientVersion() << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw RuntimeError("cannot put");
|
||||
} else {
|
||||
@ -2563,8 +2562,7 @@ std::string CmdProxy::AdcVpp(int action) {
|
||||
if (action == defs::HELP_ACTION) {
|
||||
os << "[dac or mV value][(optional unit) mV] \n\t[Ctb][Moench] Vpp of "
|
||||
"ADC.\n\t 0 -> 1V ; 1 -> 1.14V ; 2 -> 1.33V ; 3 -> 1.6V ; 4 -> "
|
||||
"2V. "
|
||||
"\n\tAdvanced User function!\n"
|
||||
"2V. \n\tAdvanced User function!\n"
|
||||
<< '\n';
|
||||
return os.str();
|
||||
}
|
||||
|
@ -1232,16 +1232,14 @@ class CmdProxy {
|
||||
"[fname]\n\tSets detector measurement parameters to those contained in "
|
||||
"fname. Set up per measurement.");
|
||||
|
||||
GET_COMMAND_HEX(
|
||||
detectorserverversion, getDetectorServerVersion,
|
||||
"\n\tOn-board detector server software version in format [0xYYMMDD].");
|
||||
GET_COMMAND(detectorserverversion, getDetectorServerVersion,
|
||||
"\n\tOn-board detector server software version");
|
||||
|
||||
GET_COMMAND(
|
||||
kernelversion, getKernelVersion,
|
||||
"\n\tGet kernel version on the detector including time and date.");
|
||||
|
||||
GET_COMMAND_HEX(rx_version, getReceiverVersion,
|
||||
"\n\tReceiver version in format [0xYYMMDD].");
|
||||
GET_COMMAND(rx_version, getReceiverVersion, "\n\tReceiver version");
|
||||
|
||||
GET_COMMAND_HEX(serialnumber, getSerialNumber,
|
||||
"\n\t[Jungfrau][Gotthard][Mythen3][Gotthard2][CTB][Moench]"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "DetectorImpl.h"
|
||||
#include "Module.h"
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/Version.h"
|
||||
#include "sls/container_utils.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/logger.h"
|
||||
@ -112,15 +113,18 @@ void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
|
||||
|
||||
int Detector::getShmId() const { return pimpl->getDetectorIndex(); }
|
||||
|
||||
std::string Detector::getPackageVersion() const { return GITBRANCH; }
|
||||
std::string Detector::getPackageVersion() const { return RELEASE; }
|
||||
|
||||
int64_t Detector::getClientVersion() const { return APILIB; }
|
||||
std::string Detector::getClientVersion() const {
|
||||
Version v(APILIB);
|
||||
return v.concise();
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFirmwareVersion, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getDetectorServerVersion(Positions pos) const {
|
||||
Result<std::string> Detector::getDetectorServerVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getDetectorServerVersion, pos);
|
||||
}
|
||||
|
||||
@ -136,7 +140,7 @@ Result<int> Detector::getModuleId(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getModuleId, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getReceiverVersion(Positions pos) const {
|
||||
Result<std::string> Detector::getReceiverVersion(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverSoftwareVersion, pos);
|
||||
}
|
||||
|
||||
@ -1123,14 +1127,16 @@ Result<std::string> Detector::getRxHostname(Positions pos) const {
|
||||
}
|
||||
|
||||
void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver,
|
||||
pimpl->getInitialChecks());
|
||||
updateRxRateCorrections();
|
||||
}
|
||||
|
||||
void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
// set all to same rx_hostname
|
||||
if (name.size() == 1) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0],
|
||||
pimpl->getInitialChecks());
|
||||
} else {
|
||||
if ((int)name.size() != size()) {
|
||||
throw RuntimeError(
|
||||
@ -1139,7 +1145,8 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
}
|
||||
// set each rx_hostname
|
||||
for (int idet = 0; idet < size(); ++idet) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet],
|
||||
pimpl->getInitialChecks());
|
||||
}
|
||||
}
|
||||
updateRxRateCorrections();
|
||||
|
@ -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) {
|
||||
|
@ -90,11 +90,13 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setHostname(const std::string &hostname, const bool initialChecks);
|
||||
|
||||
int64_t getFirmwareVersion() const;
|
||||
int64_t getDetectorServerVersion() const;
|
||||
std::string getControlServerLongVersion() const;
|
||||
std::string getStopServerLongVersion() const;
|
||||
std::string getDetectorServerVersion() const;
|
||||
std::string getKernelVersion() const;
|
||||
int64_t getSerialNumber() const;
|
||||
int getModuleId() const;
|
||||
int64_t getReceiverSoftwareVersion() const;
|
||||
std::string getReceiverSoftwareVersion() const;
|
||||
static detectorType
|
||||
getTypeFromDetector(const std::string &hostname,
|
||||
int cport = DEFAULT_TCP_CNTRL_PORTNO);
|
||||
@ -276,7 +278,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
* ************************************************/
|
||||
bool getUseReceiverFlag() const;
|
||||
std::string getReceiverHostname() const;
|
||||
void setReceiverHostname(const std::string &receiver);
|
||||
void setReceiverHostname(const std::string &receiver,
|
||||
const bool initialChecks);
|
||||
int getReceiverPort() const;
|
||||
int setReceiverPort(int port_number);
|
||||
int getReceiverFifoDepth() const;
|
||||
@ -600,6 +603,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getMeasurementTime() const;
|
||||
|
||||
private:
|
||||
std::string getReceiverLongVersion() const;
|
||||
|
||||
void checkArgs(const void *args, size_t args_size, void *retval,
|
||||
size_t retval_size) const;
|
||||
|
||||
@ -737,6 +742,8 @@ class Module : public virtual slsDetectorDefs {
|
||||
Called when new shared memory is created */
|
||||
void initializeModuleStructure(detectorType type);
|
||||
|
||||
void initialDetectorServerChecks();
|
||||
const std::string getDetectorAPI() const;
|
||||
void checkDetectorVersionCompatibility();
|
||||
void checkReceiverVersionCompatibility();
|
||||
void setModule(sls_detector_module &module, bool trimbits = true);
|
||||
|
Reference in New Issue
Block a user