From e172df79f3e96093095130bb0951d2112e41fed9 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 3 Feb 2023 11:23:19 +0100 Subject: [PATCH] format --- .../src/slsDetectorServer_funcs.c | 74 +++++++++---------- slsDetectorSoftware/src/DetectorImpl.h | 4 +- slsSupportLib/tests/test-container_utils.cpp | 15 ++-- 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 948a2e950..28318ecdb 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -1916,57 +1916,55 @@ int acquire(int blocking, int file_des) { #ifdef EIGERD // check for hardware mac and hardware ip if (udpDetails[0].srcmac != getDetectorMAC()) { - ret = FAIL; - uint64_t sourcemac = getDetectorMAC(); - char src_mac[MAC_ADDRESS_SIZE]; - getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); - sprintf( - mess, + ret = FAIL; + uint64_t sourcemac = getDetectorMAC(); + char src_mac[MAC_ADDRESS_SIZE]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); + sprintf(mess, "Invalid udp source mac address for this detector. Must be " "same as hardware detector mac address %s\n", src_mac); - LOG(logERROR, (mess)); - } else if (!enableTenGigabitEthernet(GET_FLAG) && - (udpDetails[0].srcip != getDetectorIP())) { - ret = FAIL; - uint32_t sourceip = getDetectorIP(); - char src_ip[INET_ADDRSTRLEN]; - getIpAddressinString(src_ip, sourceip); - sprintf( - mess, + LOG(logERROR, (mess)); + } else if (!enableTenGigabitEthernet(GET_FLAG) && + (udpDetails[0].srcip != getDetectorIP())) { + ret = FAIL; + uint32_t sourceip = getDetectorIP(); + char src_ip[INET_ADDRSTRLEN]; + getIpAddressinString(src_ip, sourceip); + sprintf(mess, "Invalid udp source ip address for this detector. Must be " "same as hardware detector ip address %s in 1G readout " "mode \n", src_ip); - LOG(logERROR, (mess)); - } else + LOG(logERROR, (mess)); + } else #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; - 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"); + strcpy(mess, "Could not start acquisition thread!\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; - strcpy(mess, "Could not start acquisition thread!\n"); - LOG(logERROR, (mess)); - } else { - // only does not wait for non blocking and scan - if (blocking || !scan) { - pthread_join(pthread_tid, NULL); - } + // only does not wait for non blocking and scan + if (blocking || !scan) { + pthread_join(pthread_tid, NULL); } } + } } return Server_SendResult(file_des, INT32, NULL, 0); } diff --git a/slsDetectorSoftware/src/DetectorImpl.h b/slsDetectorSoftware/src/DetectorImpl.h index 7de70b753..1f70ec0ec 100644 --- a/slsDetectorSoftware/src/DetectorImpl.h +++ b/slsDetectorSoftware/src/DetectorImpl.h @@ -84,9 +84,7 @@ class DetectorImpl : public virtual slsDetectorDefs { */ virtual ~DetectorImpl(); - template struct NonDeduced { - using type = CT; - }; + template struct NonDeduced { using type = CT; }; template Result Parallel(RT (Module::*somefunc)(CT...), std::vector positions, diff --git a/slsSupportLib/tests/test-container_utils.cpp b/slsSupportLib/tests/test-container_utils.cpp index 061ee6e4e..b70c8b476 100644 --- a/slsSupportLib/tests/test-container_utils.cpp +++ b/slsSupportLib/tests/test-container_utils.cpp @@ -136,19 +136,18 @@ TEST_CASE("compare a vector of arrays", "[support]") { CHECK(minusOneIfDifferent(vec1) == arr); } -TEST_CASE("remove duplicates from vector"){ - std::vector v{5,6,5,3}; +TEST_CASE("remove duplicates from vector") { + std::vector v{5, 6, 5, 3}; auto r = removeDuplicates(v); - CHECK(r == true); //did indeed remove elements - CHECK( v == std::vector{3,5,6}); + CHECK(r == true); // did indeed remove elements + CHECK(v == std::vector{3, 5, 6}); } -TEST_CASE("remove duplicated empty vector"){ +TEST_CASE("remove duplicated empty vector") { std::vector v; auto r = removeDuplicates(v); - CHECK(r == false); //no elements to remove - CHECK( v == std::vector{}); + CHECK(r == false); // no elements to remove + CHECK(v == std::vector{}); } - } // namespace sls