formatting

This commit is contained in:
maliakal_d 2023-10-25 09:36:51 +02:00
parent 4023ed0775
commit 35ed926047
9 changed files with 71 additions and 74 deletions

View File

@ -2928,7 +2928,8 @@ int softwareTrigger(int block) {
usleep(100); usleep(100);
#ifndef VIRTUAL #ifndef VIRTUAL
// block till frame sent out & back to wait for trigger (or not busy anymore) // block till frame sent out & back to wait for trigger (or not busy
// anymore)
if (block) { if (block) {
uint32_t retval = bus_r(STATUS_REG); uint32_t retval = bus_r(STATUS_REG);
while ((retval & RUN_BUSY_MSK) && !(retval & WAITING_FOR_TRIGGER_MSK)) { while ((retval & RUN_BUSY_MSK) && !(retval & WAITING_FOR_TRIGGER_MSK)) {
@ -2971,11 +2972,10 @@ enum runStatus getRunStatus() {
LOG(logINFOBLUE, ("Status: ERROR\n")); LOG(logINFOBLUE, ("Status: ERROR\n"));
s = ERROR; s = ERROR;
} }
// running // running
else if (retval & RUN_BUSY_MSK) { else if (retval & RUN_BUSY_MSK) {
if ((retval & if ((retval & WAITING_FOR_TRIGGER_MSK) ||
WAITING_FOR_TRIGGER_MSK) ||
(retval & WAITING_FOR_START_FRAME_MSK)) { (retval & WAITING_FOR_START_FRAME_MSK)) {
LOG(logINFOBLUE, ("Status: WAITING\n")); LOG(logINFOBLUE, ("Status: WAITING\n"));
s = WAITING; s = WAITING;

View File

@ -88,7 +88,7 @@ u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
// if electron mode bit touched // if electron mode bit touched
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
int electronCollectionModeChange = 0; int electronCollectionModeChange = 0;
if ((offset << MEM_MAP_SHIFT) == DAQ_REG) { if ((offset << MEM_MAP_SHIFT) == DAQ_REG) {
if ((readRegister(offset) ^ data) & DAQ_ELCTRN_CLLCTN_MDE_MSK) { if ((readRegister(offset) ^ data) & DAQ_ELCTRN_CLLCTN_MDE_MSK) {
electronCollectionModeChange = 1; electronCollectionModeChange = 1;
} }

View File

@ -1948,59 +1948,57 @@ int acquire(int blocking, int file_des) {
#ifdef EIGERD #ifdef EIGERD
// check for hardware mac and hardware ip // check for hardware mac and hardware ip
if (udpDetails[0].srcmac != getDetectorMAC()) { if (udpDetails[0].srcmac != getDetectorMAC()) {
ret = FAIL; ret = FAIL;
uint64_t sourcemac = getDetectorMAC(); uint64_t sourcemac = getDetectorMAC();
char src_mac[MAC_ADDRESS_SIZE]; char src_mac[MAC_ADDRESS_SIZE];
getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac);
sprintf( sprintf(mess,
mess,
"Invalid udp source mac address for this detector. Must be " "Invalid udp source mac address for this detector. Must be "
"same as hardware detector mac address %s\n", "same as hardware detector mac address %s\n",
src_mac); src_mac);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else if (!enableTenGigabitEthernet(GET_FLAG) && } else if (!enableTenGigabitEthernet(GET_FLAG) &&
(udpDetails[0].srcip != getDetectorIP())) { (udpDetails[0].srcip != getDetectorIP())) {
ret = FAIL; ret = FAIL;
uint32_t sourceip = getDetectorIP(); uint32_t sourceip = getDetectorIP();
char src_ip[INET_ADDRSTRLEN]; char src_ip[INET_ADDRSTRLEN];
getIpAddressinString(src_ip, sourceip); getIpAddressinString(src_ip, sourceip);
sprintf( sprintf(mess,
mess,
"Invalid udp source ip address for this detector. Must be " "Invalid udp source ip address for this detector. Must be "
"same as hardware detector ip address %s in 1G readout " "same as hardware detector ip address %s in 1G readout "
"mode \n", "mode \n",
src_ip); src_ip);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else } else
#endif #endif
if (configured == FAIL) { if (configured == FAIL) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because ");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess));
} else {
memset(scanErrMessage, 0, MAX_STR_LENGTH);
sharedMemory_setScanStop(0);
sharedMemory_setScanStatus(IDLE); // if it was error
if (pthread_create(&pthread_tid, NULL, &start_state_machine,
&blocking)) {
ret = FAIL; ret = FAIL;
strcpy(mess, "Could not start acquisition because "); strcpy(mess, "Could not start acquisition thread!\n");
strcat(mess, configureMessage);
LOG(logERROR, (mess));
} else if (sharedMemory_getScanStatus() == RUNNING) {
ret = FAIL;
strcpy(mess, "Could not start acquisition because a scan is "
"already running!\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
} else { } else {
memset(scanErrMessage, 0, MAX_STR_LENGTH); // wait for blocking always (scan or not)
sharedMemory_setScanStop(0); // non blocking-no scan also wait (for error message)
sharedMemory_setScanStatus(IDLE); // if it was error // non blcoking-scan dont wait (there is scanErrorMessage)
if (pthread_create(&pthread_tid, NULL, &start_state_machine, if (blocking || !scan) {
&blocking)) { pthread_join(pthread_tid, NULL);
ret = FAIL;
strcpy(mess, "Could not start acquisition thread!\n");
LOG(logERROR, (mess));
} else {
// wait for blocking always (scan or not)
// non blocking-no scan also wait (for error message)
// non blcoking-scan dont wait (there is scanErrorMessage)
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
}
} }
} }
}
} }
return Server_SendResult(file_des, INT32, NULL, 0); return Server_SendResult(file_des, INT32, NULL, 0);
} }

View File

@ -886,7 +886,8 @@ void Detector::stopDetector(Positions pos) {
// idle before stopping will return running (after async start script) when // idle before stopping will return running (after async start script) when
// getting status after, which will then be stopped again. // getting status after, which will then be stopped again.
while (!status.contains_only(defs::runStatus::IDLE, defs::runStatus::STOPPED)){ while (!status.contains_only(defs::runStatus::IDLE,
defs::runStatus::STOPPED)) {
if (status.any(defs::runStatus::ERROR)) { if (status.any(defs::runStatus::ERROR)) {
throw RuntimeError("Could not stop detector. At least one module " throw RuntimeError("Could not stop detector. At least one module "
"returned error status."); "returned error status.");

View File

@ -84,9 +84,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
*/ */
virtual ~DetectorImpl(); virtual ~DetectorImpl();
template <class CT> struct NonDeduced { template <class CT> struct NonDeduced { using type = CT; };
using type = CT;
};
template <typename RT, typename... CT> template <typename RT, typename... CT>
Result<RT> Parallel(RT (Module::*somefunc)(CT...), Result<RT> Parallel(RT (Module::*somefunc)(CT...),
std::vector<int> positions, std::vector<int> positions,

View File

@ -692,7 +692,8 @@ TEST_CASE("confadc", "[.cmd]") {
const int ndet = det.size(); const int ndet = det.size();
const int nchip = 10; const int nchip = 10;
const int nadc = 32; const int nadc = 32;
std::vector<std::vector<std::vector<int>>> prev_val(ndet, std::vector<std::vector<int>>(nchip, std::vector<int>(nadc))); std::vector<std::vector<std::vector<int>>> prev_val(
ndet, std::vector<std::vector<int>>(nchip, std::vector<int>(nadc)));
for (int i = 0; i != ndet; ++i) { for (int i = 0; i != ndet; ++i) {
for (int j = 0; j != nchip; ++j) { for (int j = 0; j != nchip; ++j) {
for (int k = 0; k != nadc; ++k) { for (int k = 0; k != nadc; ++k) {

View File

@ -196,24 +196,24 @@ TEST_CASE("String conversions") {
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]"); "[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
} }
TEST_CASE("Any element is equal"){ TEST_CASE("Any element is equal") {
Result<int> r{1,2,3,4,5}; Result<int> r{1, 2, 3, 4, 5};
REQUIRE(r.any(3)); REQUIRE(r.any(3));
REQUIRE_FALSE(r.any(9)); REQUIRE_FALSE(r.any(9));
} }
TEST_CASE("Result contains only the specified elements"){ TEST_CASE("Result contains only the specified elements") {
Result<int> r{1,1,1}; Result<int> r{1, 1, 1};
REQUIRE(r.contains_only(1)); REQUIRE(r.contains_only(1));
REQUIRE(r.contains_only(1,1)); REQUIRE(r.contains_only(1, 1));
} }
TEST_CASE("Only with multiple values"){ TEST_CASE("Only with multiple values") {
Result<int> r{1,1,2,1,2,1,1}; Result<int> r{1, 1, 2, 1, 2, 1, 1};
REQUIRE_FALSE(r.contains_only(1)); REQUIRE_FALSE(r.contains_only(1));
REQUIRE_FALSE(r.contains_only(2)); REQUIRE_FALSE(r.contains_only(2));
REQUIRE(r.contains_only(1,2)); REQUIRE(r.contains_only(1, 2));
REQUIRE(r.contains_only(2,1)); REQUIRE(r.contains_only(2, 1));
} }
} // namespace sls } // namespace sls

View File

@ -103,14 +103,13 @@ template <typename T> struct is_vector : public std::false_type {};
template <typename T> template <typename T>
struct is_vector<std::vector<T>> : public std::true_type {}; struct is_vector<std::vector<T>> : public std::true_type {};
template <class...> struct Conjunction : std::true_type {};
template <class B1> struct Conjunction<B1> : B1 {};
template<class...> struct Conjunction : std::true_type {}; template <class B1, class... Bn>
template<class B1> struct Conjunction<B1> : B1 {};
template<class B1, class... Bn>
struct Conjunction<B1, Bn...> struct Conjunction<B1, Bn...>
: std::conditional<bool(B1::value), Conjunction<Bn...>, B1>::type {}; : std::conditional<bool(B1::value), Conjunction<Bn...>, B1>::type {};
template<typename T, typename... Ts> template <typename T, typename... Ts>
using AllSame = typename std::enable_if<Conjunction<std::is_same<T, Ts>...>::value>::type; using AllSame =
typename std::enable_if<Conjunction<std::is_same<T, Ts>...>::value>::type;
} // namespace sls } // namespace sls

View File

@ -2,12 +2,12 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */ /** API versions */
#define RELEASE "8.0.0" #define RELEASE "8.0.0"
#define APILIB "8.0.0 0x231025" #define APILIB "8.0.0 0x231025"
#define APIRECEIVER "8.0.0 0x231025" #define APIRECEIVER "8.0.0 0x231025"
#define APICTB "8.0.0 0x231025" #define APICTB "8.0.0 0x231025"
#define APIGOTTHARD "8.0.0 0x231025" #define APIGOTTHARD "8.0.0 0x231025"
#define APIGOTTHARD2 "8.0.0 0x231025" #define APIGOTTHARD2 "8.0.0 0x231025"
#define APIJUNGFRAU "8.0.0 0x231025" #define APIJUNGFRAU "8.0.0 0x231025"
#define APIMYTHEN3 "8.0.0 0x231025" #define APIMYTHEN3 "8.0.0 0x231025"
#define APIMOENCH "8.0.0 0x231025" #define APIMOENCH "8.0.0 0x231025"
#define APIEIGER "8.0.0 0x231025" #define APIEIGER "8.0.0 0x231025"