diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 262c7eef8..6380fd9d4 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -1,9 +1,9 @@ #include "slsDetectorFunctionList.h" #include "RegisterDefs.h" #include "clogger.h" +#include "common.h" #include "sharedMemory.h" #include "versionAPI.h" -#include "common.h" #include "LTC2620.h" // dacs #ifdef VIRTUAL diff --git a/slsDetectorServers/slsDetectorServer/include/common.h b/slsDetectorServers/slsDetectorServer/include/common.h index e4f009c48..fed3cbbf2 100644 --- a/slsDetectorServers/slsDetectorServer/include/common.h +++ b/slsDetectorServers/slsDetectorServer/include/common.h @@ -2,7 +2,6 @@ #include - /** * Convert a value from a range to a different range (eg voltage to dac or vice * versa) @@ -17,6 +16,4 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outputMax, int inputValue, int *outputValue); - - -int getAbsPath(char* buf, size_t bufSize, char* fname); \ No newline at end of file +int getAbsPath(char *buf, size_t bufSize, char *fname); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index 621fc40af..04af3bb11 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -2,8 +2,8 @@ #include "clogger.h" #include "sls_detector_defs.h" -#include #include // dirname +#include #include // readlink int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, @@ -42,8 +42,7 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, return OK; } - -int getAbsPath(char* buf, size_t bufSize, char* fname) { +int getAbsPath(char *buf, size_t bufSize, char *fname) { // get path of current binary char path[bufSize]; memset(path, 0, bufSize); @@ -58,6 +57,6 @@ int getAbsPath(char* buf, size_t bufSize, char* fname) { char *dir = dirname(path); memset(buf, 0, bufSize); sprintf(buf, "%s/%s", dir, fname); - LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf)); + LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf)); return OK; } \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c index 25f6a5744..538ea24fb 100644 --- a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c +++ b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c @@ -1,9 +1,9 @@ #include "readDefaultPattern.h" #include "ansi.h" #include "clogger.h" +#include "common.h" #include "slsDetectorServer_defs.h" #include "sls_detector_defs.h" -#include "common.h" #include diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 6890c5644..b160b9f8b 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -992,7 +992,7 @@ enum DACINDEX getDACIndex(enum dacIndex ind) { default: #ifdef CHIPTESTBOARDD if (ind < NDAC_ONLY) { - //For CTB use the index directly, no conversion + // For CTB use the index directly, no conversion serverDacIndex = (enum DACINDEX)ind; break; } diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index d8c520911..21deb7394 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -9,8 +9,8 @@ #include "sls_detector_defs.h" #include "versionAPI.h" -#include #include +#include #include namespace sls { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 9339cd108..61409375c 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -14,13 +14,13 @@ #include #include #include -#include #include -#include +#include #include #include #include #include +#include namespace sls { @@ -933,9 +933,7 @@ void Module::setFileIndex(int64_t file_index) { sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr); } -void Module::incrementFileIndex() { - sendToReceiver(F_INCREMENT_FILE_INDEX); -} +void Module::incrementFileIndex() { sendToReceiver(F_INCREMENT_FILE_INDEX); } bool Module::getFileWrite() { return sendToReceiver(F_GET_RECEIVER_FILE_WRITE); @@ -1391,7 +1389,7 @@ void Module::setBurstPeriod(int64_t value) { } std::array Module::getInjectChannel() { - return sendToDetector >(F_GET_INJECT_CHANNEL); + return sendToDetector>(F_GET_INJECT_CHANNEL); } void Module::setInjectChannel(const int offsetChannel, diff --git a/slsDetectorSoftware/tests/test-Module.cpp b/slsDetectorSoftware/tests/test-Module.cpp index 747bf90e8..560d2b814 100644 --- a/slsDetectorSoftware/tests/test-Module.cpp +++ b/slsDetectorSoftware/tests/test-Module.cpp @@ -9,50 +9,50 @@ TEST_CASE("Construction with a defined detector type") { m.freeSharedMemory(); // clean up } -TEST_CASE("Read back detector type from shm"){ +TEST_CASE("Read back detector type from shm") { // Create specific detector in order to create shm sls::Module m(dt::JUNGFRAU); // New detector that reads type from shm sls::Module m2; - REQUIRE(m2.getDetectorType()== dt::JUNGFRAU); + REQUIRE(m2.getDetectorType() == dt::JUNGFRAU); - // Now both objects point to the same shm so we can only + // Now both objects point to the same shm so we can only // free one! m2.freeSharedMemory(); } -TEST_CASE("Is shm fixed pattern shm compatible"){ +TEST_CASE("Is shm fixed pattern shm compatible") { sls::Module m(dt::JUNGFRAU); // Should be true since we just created the shm REQUIRE(m.isFixedPatternSharedMemoryCompatible() == true); - // Set shm version to 0 - sls::SharedMemory shm(0,0); - REQUIRE(shm.IsExisting()== true); + // Set shm version to 0 + sls::SharedMemory shm(0, 0); + REQUIRE(shm.IsExisting() == true); shm.OpenSharedMemory(); shm()->shmversion = 0; - + // Should fail since version is set to 0 REQUIRE(m.isFixedPatternSharedMemoryCompatible() == false); m.freeSharedMemory(); } -TEST_CASE("Get default control port"){ +TEST_CASE("Get default control port") { sls::Module m(dt::MYTHEN3); REQUIRE(m.getControlPort() == 1952); m.freeSharedMemory(); } -TEST_CASE("Get default stop port"){ +TEST_CASE("Get default stop port") { sls::Module m(dt::GOTTHARD2); REQUIRE(m.getStopPort() == 1953); m.freeSharedMemory(); } -TEST_CASE("Get default receiver TCP port"){ +TEST_CASE("Get default receiver TCP port") { sls::Module m(dt::MYTHEN3); REQUIRE(m.getReceiverPort() == 1954); m.freeSharedMemory(); diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index fde293d00..0bb059f82 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -8,15 +8,15 @@ #include "ZmqSocket.h" //just for the zmq port define #include "file_utils.h" -#include //eperm +#include //eperm +#include #include //system #include #include //strcpy #include -#include -#include #include #include // stat +#include #include /** cosntructor & destructor */ diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 357d3fd69..a0b5d2152 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -3,10 +3,10 @@ #define APILIB 0x200409 #define APIRECEIVER 0x200409 #define APIGUI 0x200409 -#define APICTB 0x200723 -#define APIGOTTHARD 0x200723 +#define APICTB 0x200723 +#define APIGOTTHARD 0x200723 #define APIGOTTHARD2 0x200723 -#define APIJUNGFRAU 0x200723 -#define APIMYTHEN3 0x200723 -#define APIMOENCH 0x200722 -#define APIEIGER 0x200723 +#define APIJUNGFRAU 0x200723 +#define APIMYTHEN3 0x200723 +#define APIMOENCH 0x200722 +#define APIEIGER 0x200723 diff --git a/slsSupportLib/src/ZmqSocket.cpp b/slsSupportLib/src/ZmqSocket.cpp index d937b8462..02a64724c 100644 --- a/slsSupportLib/src/ZmqSocket.cpp +++ b/slsSupportLib/src/ZmqSocket.cpp @@ -1,22 +1,21 @@ #include "ZmqSocket.h" #include "logger.h" +#include "network_utils.h" //ip +#include #include #include +#include #include -#include #include #include -#include #include -#include "network_utils.h" //ip using namespace rapidjson; ZmqSocket::ZmqSocket(const char *const hostname_or_ip, const uint32_t portnumber) - : portno(portnumber), sockfd(false) -{ + : portno(portnumber), sockfd(false) { // Extra check that throws if conversion fails, could be removed - auto ipstr = sls::HostnameToIp(hostname_or_ip).str(); + auto ipstr = sls::HostnameToIp(hostname_or_ip).str(); std::ostringstream oss; oss << "tcp://" << ipstr << ":" << portno; sockfd.serverAddress = oss.str(); @@ -52,8 +51,7 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip, } ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip) - :portno(portnumber), sockfd(true) -{ + : portno(portnumber), sockfd(true) { // create context sockfd.contextDescriptor = zmq_ctx_new(); if (sockfd.contextDescriptor == nullptr) @@ -124,11 +122,11 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) { "\"flippedDataX\":%u, " "\"quad\":%u" - ; //"}\n"; - memset(header_buffer.get(),'\0',MAX_STR_LENGTH); //TODO! Do we need this - sprintf(header_buffer.get(), jsonHeaderFormat, header.jsonversion, header.dynamicRange, - header.fileIndex, header.ndetx, header.ndety, header.npixelsx, - header.npixelsy, header.imageSize, header.acqIndex, + ; //"}\n"; + memset(header_buffer.get(), '\0', MAX_STR_LENGTH); // TODO! Do we need this + sprintf(header_buffer.get(), jsonHeaderFormat, header.jsonversion, + header.dynamicRange, header.fileIndex, header.ndetx, header.ndety, + header.npixelsx, header.npixelsy, header.imageSize, header.acqIndex, header.frameIndex, header.progress, header.fname.c_str(), header.data ? 1 : 0, header.completeImage ? 1 : 0, @@ -186,14 +184,15 @@ int ZmqSocket::SendData(char *buf, int length) { int ZmqSocket::ReceiveHeader(const int index, zmqHeader &zHeader, uint32_t version) { - const int bytes_received = - zmq_recv(sockfd.socketDescriptor, header_buffer.get(), MAX_STR_LENGTH, 0); + const int bytes_received = zmq_recv(sockfd.socketDescriptor, + header_buffer.get(), MAX_STR_LENGTH, 0); if (bytes_received > 0) { #ifdef ZMQ_DETAIL cprintf(BLUE, "Header %d [%d] Length: %d Header:%s \n", index, portno, bytes_received, buffer.data()); #endif - if (ParseHeader(index, bytes_received, header_buffer.get(), zHeader, version)) { + if (ParseHeader(index, bytes_received, header_buffer.get(), zHeader, + version)) { #ifdef ZMQ_DETAIL cprintf(RED, "Parsed Header %d [%d] Length: %d Header:%s \n", index, portno, bytes_received, buffer.data()); diff --git a/slsSupportLib/tests/test-sls_detector_defs.cpp b/slsSupportLib/tests/test-sls_detector_defs.cpp index d0c28e43c..ffd2971f8 100644 --- a/slsSupportLib/tests/test-sls_detector_defs.cpp +++ b/slsSupportLib/tests/test-sls_detector_defs.cpp @@ -51,7 +51,7 @@ TEST_CASE("assign module", "[support]") { CHECK(m3.nchan == 256 * 256 * 4); } -TEST_CASE("default construct scanParameters"){ +TEST_CASE("default construct scanParameters") { slsDetectorDefs::scanParameters p; CHECK(p.dacSettleTime_ns == 0); CHECK(p.dacInd == slsDetectorDefs::DAC_0); @@ -59,10 +59,9 @@ TEST_CASE("default construct scanParameters"){ CHECK(p.startOffset == 0); CHECK(p.stopOffset == 0); CHECK(p.stepSize == 0); - } -TEST_CASE("compare two scanParameters"){ +TEST_CASE("compare two scanParameters") { slsDetectorDefs::scanParameters p0; slsDetectorDefs::scanParameters p1; @@ -70,5 +69,4 @@ TEST_CASE("compare two scanParameters"){ p0.enable = 1; CHECK_FALSE(p0 == p1); - } \ No newline at end of file