This commit is contained in:
Erik Frojdh
2020-07-23 14:01:59 +02:00
parent 3ddb264875
commit 5faf3c7336
12 changed files with 49 additions and 58 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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,7 +42,6 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
return OK;
}
int getAbsPath(char *buf, size_t bufSize, char *fname) {
// get path of current binary
char path[bufSize];

View File

@@ -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>

View File

@@ -9,8 +9,8 @@
#include "sls_detector_defs.h"
#include "versionAPI.h"
#include <fstream>
#include <chrono>
#include <fstream>
#include <thread>
namespace sls {

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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)
@@ -126,9 +124,9 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) {
; //"}\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,
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());

View File

@@ -59,7 +59,6 @@ TEST_CASE("default construct scanParameters"){
CHECK(p.startOffset == 0);
CHECK(p.stopOffset == 0);
CHECK(p.stepSize == 0);
}
TEST_CASE("compare two scanParameters") {
@@ -70,5 +69,4 @@ TEST_CASE("compare two scanParameters"){
p0.enable = 1;
CHECK_FALSE(p0 == p1);
}