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 "slsDetectorFunctionList.h"
#include "RegisterDefs.h" #include "RegisterDefs.h"
#include "clogger.h" #include "clogger.h"
#include "common.h"
#include "sharedMemory.h" #include "sharedMemory.h"
#include "versionAPI.h" #include "versionAPI.h"
#include "common.h"
#include "LTC2620.h" // dacs #include "LTC2620.h" // dacs
#ifdef VIRTUAL #ifdef VIRTUAL

View File

@ -2,7 +2,6 @@
#include <stdio.h> #include <stdio.h>
/** /**
* Convert a value from a range to a different range (eg voltage to dac or vice * Convert a value from a range to a different range (eg voltage to dac or vice
* versa) * versa)
@ -17,6 +16,4 @@
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
int outputMax, int inputValue, int *outputValue); int outputMax, int inputValue, int *outputValue);
int getAbsPath(char *buf, size_t bufSize, char *fname); int getAbsPath(char *buf, size_t bufSize, char *fname);

View File

@ -2,8 +2,8 @@
#include "clogger.h" #include "clogger.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <string.h>
#include <libgen.h> // dirname #include <libgen.h> // dirname
#include <string.h>
#include <unistd.h> // readlink #include <unistd.h> // readlink
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
@ -42,7 +42,6 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin,
return OK; 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 // get path of current binary
char path[bufSize]; char path[bufSize];

View File

@ -1,9 +1,9 @@
#include "readDefaultPattern.h" #include "readDefaultPattern.h"
#include "ansi.h" #include "ansi.h"
#include "clogger.h" #include "clogger.h"
#include "common.h"
#include "slsDetectorServer_defs.h" #include "slsDetectorServer_defs.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "common.h"
#include <string.h> #include <string.h>

View File

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

View File

@ -14,13 +14,13 @@
#include <array> #include <array>
#include <bitset> #include <bitset>
#include <cassert> #include <cassert>
#include <cmath>
#include <chrono> #include <chrono>
#include <thread> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include <iomanip> #include <iomanip>
#include <iterator> #include <iterator>
#include <sstream> #include <sstream>
#include <thread>
namespace sls { namespace sls {
@ -933,9 +933,7 @@ void Module::setFileIndex(int64_t file_index) {
sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr); sendToReceiver(F_SET_RECEIVER_FILE_INDEX, file_index, nullptr);
} }
void Module::incrementFileIndex() { void Module::incrementFileIndex() { sendToReceiver(F_INCREMENT_FILE_INDEX); }
sendToReceiver(F_INCREMENT_FILE_INDEX);
}
bool Module::getFileWrite() { bool Module::getFileWrite() {
return sendToReceiver<int>(F_GET_RECEIVER_FILE_WRITE); return sendToReceiver<int>(F_GET_RECEIVER_FILE_WRITE);

View File

@ -9,14 +9,14 @@
#include "file_utils.h" #include "file_utils.h"
#include <cerrno> //eperm #include <cerrno> //eperm
#include <chrono>
#include <cstdlib> //system #include <cstdlib> //system
#include <cstring> #include <cstring>
#include <cstring> //strcpy #include <cstring> //strcpy
#include <fstream> #include <fstream>
#include <chrono>
#include <thread>
#include <iostream> #include <iostream>
#include <sys/stat.h> // stat #include <sys/stat.h> // stat
#include <thread>
#include <unistd.h> #include <unistd.h>
/** cosntructor & destructor */ /** cosntructor & destructor */

View File

@ -1,20 +1,19 @@
#include "ZmqSocket.h" #include "ZmqSocket.h"
#include "logger.h" #include "logger.h"
#include "network_utils.h" //ip
#include <chrono>
#include <errno.h> #include <errno.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <string.h> #include <string.h>
#include <chrono>
#include <thread> #include <thread>
#include <vector> #include <vector>
#include <sstream>
#include <zmq.h> #include <zmq.h>
#include "network_utils.h" //ip
using namespace rapidjson; using namespace rapidjson;
ZmqSocket::ZmqSocket(const char *const hostname_or_ip, ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
const uint32_t portnumber) const uint32_t portnumber)
: portno(portnumber), sockfd(false) : portno(portnumber), sockfd(false) {
{
// Extra check that throws if conversion fails, could be removed // 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; std::ostringstream oss;
@ -52,8 +51,7 @@ ZmqSocket::ZmqSocket(const char *const hostname_or_ip,
} }
ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip) ZmqSocket::ZmqSocket(const uint32_t portnumber, const char *ethip)
:portno(portnumber), sockfd(true) : portno(portnumber), sockfd(true) {
{
// create context // create context
sockfd.contextDescriptor = zmq_ctx_new(); sockfd.contextDescriptor = zmq_ctx_new();
if (sockfd.contextDescriptor == nullptr) if (sockfd.contextDescriptor == nullptr)
@ -126,9 +124,9 @@ int ZmqSocket::SendHeader(int index, zmqHeader header) {
; //"}\n"; ; //"}\n";
memset(header_buffer.get(), '\0', MAX_STR_LENGTH); // TODO! Do we need this memset(header_buffer.get(), '\0', MAX_STR_LENGTH); // TODO! Do we need this
sprintf(header_buffer.get(), jsonHeaderFormat, header.jsonversion, header.dynamicRange, sprintf(header_buffer.get(), jsonHeaderFormat, header.jsonversion,
header.fileIndex, header.ndetx, header.ndety, header.npixelsx, header.dynamicRange, header.fileIndex, header.ndetx, header.ndety,
header.npixelsy, header.imageSize, header.acqIndex, header.npixelsx, header.npixelsy, header.imageSize, header.acqIndex,
header.frameIndex, header.progress, header.fname.c_str(), header.frameIndex, header.progress, header.fname.c_str(),
header.data ? 1 : 0, header.completeImage ? 1 : 0, 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, int ZmqSocket::ReceiveHeader(const int index, zmqHeader &zHeader,
uint32_t version) { uint32_t version) {
const int bytes_received = const int bytes_received = zmq_recv(sockfd.socketDescriptor,
zmq_recv(sockfd.socketDescriptor, header_buffer.get(), MAX_STR_LENGTH, 0); header_buffer.get(), MAX_STR_LENGTH, 0);
if (bytes_received > 0) { if (bytes_received > 0) {
#ifdef ZMQ_DETAIL #ifdef ZMQ_DETAIL
cprintf(BLUE, "Header %d [%d] Length: %d Header:%s \n", index, portno, cprintf(BLUE, "Header %d [%d] Length: %d Header:%s \n", index, portno,
bytes_received, buffer.data()); bytes_received, buffer.data());
#endif #endif
if (ParseHeader(index, bytes_received, header_buffer.get(), zHeader, version)) { if (ParseHeader(index, bytes_received, header_buffer.get(), zHeader,
version)) {
#ifdef ZMQ_DETAIL #ifdef ZMQ_DETAIL
cprintf(RED, "Parsed Header %d [%d] Length: %d Header:%s \n", index, cprintf(RED, "Parsed Header %d [%d] Length: %d Header:%s \n", index,
portno, bytes_received, buffer.data()); portno, bytes_received, buffer.data());

View File

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