Merge branch 'developer' into gui

This commit is contained in:
Erik Frojdh 2019-07-02 10:54:29 +02:00
commit 547ab8a749
49 changed files with 54 additions and 20 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "python/pybind11"] [submodule "python/pybind11"]
path = python/pybind11 path = libs/pybind11
url = https://github.com/pybind/pybind11.git url = https://github.com/pybind/pybind11.git

View File

@ -109,9 +109,14 @@ if(SLS_USE_SANITIZER)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif() endif()
#rapidjson
add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libs/rapidjson>
)
# Install fake the libraries # Install fake the libraries
install(TARGETS slsProjectOptions slsProjectWarnings install(TARGETS slsProjectOptions slsProjectWarnings rapidjson
EXPORT "${TARGETS_EXPORT_NAME}" EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@ -132,6 +137,9 @@ if (SLS_USE_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
endif(SLS_USE_TESTS) endif(SLS_USE_TESTS)
# Common functionallity to detector and receiver # Common functionallity to detector and receiver
add_subdirectory(slsSupportLib) add_subdirectory(slsSupportLib)
@ -165,6 +173,7 @@ if (SLS_USE_INTEGRATION_TESTS)
endif (SLS_USE_INTEGRATION_TESTS) endif (SLS_USE_INTEGRATION_TESTS)
if (SLS_USE_PYTHON) if (SLS_USE_PYTHON)
add_subdirectory(libs/pybind11)
add_subdirectory(python) add_subdirectory(python)
endif(SLS_USE_PYTHON) endif(SLS_USE_PYTHON)

View File

@ -1,4 +1,4 @@
add_subdirectory(pybind11)
pybind11_add_module(_sls_detector src/main.cpp) pybind11_add_module(_sls_detector src/main.cpp)

View File

@ -439,8 +439,8 @@
#define POWER_ENBL_VLTG_RGLTR_OFST (16) #define POWER_ENBL_VLTG_RGLTR_OFST (16)
#define POWER_ENBL_VLTG_RGLTR_MSK (0x0000001F << POWER_ENBL_VLTG_RGLTR_OFST) #define POWER_ENBL_VLTG_RGLTR_MSK (0x0000001F << POWER_ENBL_VLTG_RGLTR_OFST)
#define POWER_HV_SLCT_OFST (31) #define POWER_HV_INTERNAL_SLCT_OFST (31)
#define POWER_HV_SLCT_MSK (0x00000001 << POWER_HV_SLCT_OFST) #define POWER_HV_INTERNAL_SLCT_MSK (0x00000001 << POWER_HV_INTERNAL_SLCT_OFST)
/* Number of Words RW register TODO */ /* Number of Words RW register TODO */
#define NUMBER_OF_WORDS_REG (0x5F << MEM_MAP_SHIFT) #define NUMBER_OF_WORDS_REG (0x5F << MEM_MAP_SHIFT)

View File

@ -1422,14 +1422,14 @@ int setHighVoltage(int val){
FILE_LOG(logINFO, ("Setting High voltage: %d V\n", val)); FILE_LOG(logINFO, ("Setting High voltage: %d V\n", val));
uint32_t addr = POWER_REG; uint32_t addr = POWER_REG;
// switch off high voltage // switch to external high voltage
bus_w(addr, bus_r(addr) & (~POWER_HV_SLCT_MSK)); bus_w(addr, bus_r(addr) & (~POWER_HV_INTERNAL_SLCT_OFST));
MAX1932_Set(val); MAX1932_Set(val);
// switch on high voltage if val > 0 // switch on internal high voltage, if set
if (val > 0) if (val > 0)
bus_w(addr, bus_r(addr) | POWER_HV_SLCT_MSK); bus_w(addr, bus_r(addr) | POWER_HV_INTERNAL_SLCT_OFST);
highvoltage = val; highvoltage = val;
} }

View File

@ -13,6 +13,7 @@
#include "GeneralData.h" #include "GeneralData.h"
#include "Listener.h" #include "Listener.h"
#include "ZmqSocket.h" //just for the zmq port define #include "ZmqSocket.h" //just for the zmq port define
#include "file_utils.h"
#include <cerrno> //eperm #include <cerrno> //eperm
#include <cstdlib> //system #include <cstdlib> //system
@ -553,12 +554,8 @@ void slsReceiverImplementation::setFilePath(const char c[]) {
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called"; FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if (strlen(c)) { if (strlen(c)) {
// check if filepath exists mkdir_p(c); //throws if it can't create
struct stat st; strcpy(filePath, c);
if (stat(c, &st) == 0)
strcpy(filePath, c);
else
FILE_LOG(logERROR) << "FilePath does not exist: " << c;
} }
FILE_LOG(logINFO) << "File path: " << filePath; FILE_LOG(logINFO) << "File path: " << filePath;
} }

View File

@ -808,6 +808,8 @@ int slsReceiverTCPIPInterface::set_file_dir(Interface &socket) {
if (strlen(fPath) != 0) { if (strlen(fPath) != 0) {
FILE_LOG(logDEBUG1) << "Setting file path: " << fPath; FILE_LOG(logDEBUG1) << "Setting file path: " << fPath;
if(fPath[0] != '/')
throw RuntimeError("Receiver path needs to be absolute path");
impl()->setFilePath(fPath); impl()->setFilePath(fPath);
} }
std::string s = impl()->getFilePath(); std::string s = impl()->getFilePath();

View File

@ -53,7 +53,10 @@ set_target_properties(slsSupportLib PROPERTIES
PUBLIC_HEADER "${PUBLICHEADERS}" PUBLIC_HEADER "${PUBLICHEADERS}"
) )
target_link_libraries(slsSupportLib slsProjectOptions slsProjectWarnings) target_link_libraries(slsSupportLib
slsProjectOptions
slsProjectWarnings
rapidjson)
if (SLS_USE_TESTS) if (SLS_USE_TESTS)
add_subdirectory(tests) add_subdirectory(tests)

View File

@ -52,5 +52,5 @@ int writeDataFile(std::string fname,int nch, short int *data);
// mkdir -p path implemented by recursive calls
void mkdir_p(const std::string& path, std::string dir="");

View File

@ -1,9 +1,12 @@
#include "file_utils.h" #include "file_utils.h"
#include "logger.h" #include "logger.h"
#include "sls_detector_exceptions.h"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) { int readDataFile(std::ifstream &infile, short int *data, int nch, int offset) {
int ichan, iline=0; int ichan, iline=0;
@ -77,5 +80,25 @@ int writeDataFile(std::string fname,int nch, short int *data) {
void mkdir_p(const std::string& path, std::string dir) {
if (path.length() == 0)
return;
size_t i = 0;
for (; i < path.length(); i++) {
dir += path[i];
if (path[i] == '/')
break;
}
if(mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0){
if (errno != EEXIST)
throw sls::RuntimeError("Could not create: " + dir);
}
if (i + 1 < path.length())
mkdir_p(path.substr(i + 1), dir);
}

View File

@ -1,5 +1,5 @@
include_directories( include_directories(
${PROJECT_SOURCE_DIR}/catch ${PROJECT_SOURCE_DIR}/libs/catch
include include
) )