mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
format
This commit is contained in:
@ -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
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
int getAbsPath(char *buf, size_t bufSize, char *fname);
|
@ -2,8 +2,8 @@
|
||||
#include "clogger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <libgen.h> // dirname
|
||||
#include <string.h>
|
||||
#include <unistd.h> // 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);
|
||||
|
@ -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 <string.h>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
|
||||
namespace sls {
|
||||
|
@ -14,13 +14,13 @@
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
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<int>(F_GET_RECEIVER_FILE_WRITE);
|
||||
@ -1391,7 +1389,7 @@ void Module::setBurstPeriod(int64_t value) {
|
||||
}
|
||||
|
||||
std::array<int, 2> Module::getInjectChannel() {
|
||||
return sendToDetector<std::array<int, 2> >(F_GET_INJECT_CHANNEL);
|
||||
return sendToDetector<std::array<int, 2>>(F_GET_INJECT_CHANNEL);
|
||||
}
|
||||
|
||||
void Module::setInjectChannel(const int offsetChannel,
|
||||
|
@ -9,28 +9,28 @@ 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
|
||||
// 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<sls::sharedSlsDetector> shm(0,0);
|
||||
REQUIRE(shm.IsExisting()== true);
|
||||
sls::SharedMemory<sls::sharedSlsDetector> shm(0, 0);
|
||||
REQUIRE(shm.IsExisting() == true);
|
||||
shm.OpenSharedMemory();
|
||||
shm()->shmversion = 0;
|
||||
|
||||
@ -40,19 +40,19 @@ TEST_CASE("Is shm fixed pattern shm compatible"){
|
||||
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();
|
||||
|
@ -9,14 +9,14 @@
|
||||
#include "file_utils.h"
|
||||
|
||||
#include <cerrno> //eperm
|
||||
#include <chrono>
|
||||
#include <cstdlib> //system
|
||||
#include <cstring>
|
||||
#include <cstring> //strcpy
|
||||
#include <fstream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
#include <sys/stat.h> // stat
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
/** cosntructor & destructor */
|
||||
|
@ -1,20 +1,19 @@
|
||||
#include "ZmqSocket.h"
|
||||
#include "logger.h"
|
||||
#include "network_utils.h" //ip
|
||||
#include <chrono>
|
||||
#include <errno.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <zmq.h>
|
||||
#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();
|
||||
std::ostringstream oss;
|
||||
@ -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)
|
||||
@ -125,10 +123,10 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) {
|
||||
"\"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,
|
||||
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());
|
||||
|
@ -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);
|
||||
|
||||
}
|
Reference in New Issue
Block a user