Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
maliakal_d 2019-04-24 13:31:06 +02:00
commit 92310f845c
11 changed files with 402 additions and 114 deletions

View File

@ -10,6 +10,7 @@
target_sources(tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test-integrationMulti.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-integrationDectector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test-eigerIntegration.cpp
)
# if(SLS_USE_TESTS)

View File

@ -36,9 +36,10 @@ std::ostream &operator<<(std::ostream &out, const ROI &r) {
int main() {
int ret[]{0,0,0};
for (auto i: ret)
std::cout << i << "\n";
std::cout << "nullptr: " << sizeof(nullptr) << "\n";
// int ret[]{0,0,0};
// for (auto i: ret)
// std::cout << i << "\n";
// uint32_t imageSize = 101;
// uint32_t packetSize = 100;
// std::cout << "a: " << std::ceil((double)imageSize / (double)packetSize) <<'\n';

View File

@ -0,0 +1,107 @@
#include "catch.hpp"
#include "multiSlsDetector.h"
#include "string_utils.h"
#include "tests/globals.h"
#include <iostream>
TEST_CASE("Set and get dacs", "[.eigerintegration][cli]") {
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
auto th = 1000;
// set and read back each individual dac of EIGER
d.setDAC(0, di::E_SvP, 0);
CHECK(d.setDAC(-1, di::E_SvP, 0) == 0);
d.setDAC(4000, di::E_SvN, 0);
CHECK(d.setDAC(-1, di::E_SvN, 0) == 4000);
d.setDAC(2000, di::E_Vtr, 0);
CHECK(d.setDAC(-1, di::E_Vtr, 0) == 2000);
d.setDAC(3500, di::E_Vrf, 0);
CHECK(d.setDAC(-1, di::E_Vrf, 0) == 3500);
d.setDAC(1400, di::E_Vrs, 0);
CHECK(d.setDAC(-1, di::E_Vrs, 0) == 1400);
d.setDAC(2556, di::E_Vtgstv, 0);
CHECK(d.setDAC(-1, di::E_Vtgstv, 0) == 2556);
d.setDAC(1500, di::E_Vcmp_ll, 0);
CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == 1500);
d.setDAC(1400, di::E_Vcmp_lr, 0);
CHECK(d.setDAC(-1, di::E_Vcmp_lr, 0) == 1400);
d.setDAC(4000, di::E_cal, 0);
CHECK(d.setDAC(-1, di::E_cal, 0) == 4000);
d.setDAC(1300, di::E_Vcmp_rl, 0);
CHECK(d.setDAC(-1, di::E_Vcmp_rl, 0) == 1300);
d.setDAC(1200, di::E_Vcmp_rr, 0);
CHECK(d.setDAC(-1, di::E_Vcmp_rr, 0) == 1200);
d.setDAC(1100, di::E_rxb_rb, 0);
CHECK(d.setDAC(-1, di::E_rxb_rb, 0) == 1100);
d.setDAC(1100, di::E_rxb_lb, 0);
CHECK(d.setDAC(-1, di::E_rxb_lb, 0) == 1100);
d.setDAC(1500, di::E_Vcp, 0);
CHECK(d.setDAC(-1, di::E_Vcp, 0) == 1500);
d.setDAC(2000, di::E_Vcn, 0);
CHECK(d.setDAC(-1, di::E_Vcn, 0) == 2000);
d.setDAC(1550, di::E_Vis, 0);
CHECK(d.setDAC(-1, di::E_Vis, 0) == 1550);
d.setDAC(660, di::IO_DELAY, 0);
CHECK(d.setDAC(-1, di::IO_DELAY, 0) == 660);
// setting threshold sets all individual vcmp
d.setDAC(th, di::THRESHOLD, 0);
CHECK(d.setDAC(-1, di::THRESHOLD, 0) == th);
CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == th);
CHECK(d.setDAC(-1, di::E_Vcmp_lr, 0) == th);
CHECK(d.setDAC(-1, di::E_Vcmp_rl, 0) == th);
CHECK(d.setDAC(-1, di::E_Vcmp_rr, 0) == th);
// different values gives -1
if (d.getNumberOfDetectors() > 1) {
d.setDAC(1600, di::E_Vcmp_ll, 0, 0);
d.setDAC(1700, di::E_Vcmp_ll, 0, 1);
CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0, 0) == 1600);
CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0, 1) == 1700);
CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == -1);
CHECK(d.setDAC(-1, di::THRESHOLD, 0) == -1);
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 0) == -1);
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 1) == -1);
}
d.freeSharedMemory();
}
TEST_CASE("Read temperatures", "[.eigerintegration][cli]") {
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
std::vector<di> tempindex{di::TEMPERATURE_FPGA, di::TEMPERATURE_FPGA2,
di::TEMPERATURE_FPGA3};
for (auto index : tempindex) {
for (int i = 0; i != d.getNumberOfDetectors(); ++i) {
double temp = static_cast<double>(d.getADC(index, 0)) / 1000;
CHECK(temp > 20);
CHECK(temp < 60);
}
}
}
int to_time(uint32_t reg){
uint32_t clocks = reg >> 3;
uint32_t exponent = (reg & 0b111)+1;
return clocks*pow(10, exponent);
// clocks = register >> 3
// exponent = register & 0b111
// return clocks*10**exponent / 100e6
}
TEST_CASE("Read/write register", "[.eigerintegration][cli]"){
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
d.setNumberOfFrames(1);
d.setExposureTime(10000);
d.acquire();
CHECK(to_time(d.readRegister(0x4, 0)) == 10000);
d.writeRegister(0x4, 500);
CHECK(d.readRegister(0x4) == 500);
}

View File

@ -14,9 +14,32 @@
#define VERBOSE
// Header holding all configurations for different detectors
#include "config.h"
#include "tests/config.h"
TEST_CASE("single EIGER detector no receiver basic set and get", "[.integration]") {
using dt = slsDetectorDefs::detectorType;
extern std::string hostname;
extern std::string detector_type;
extern dt type;
TEST_CASE("Single detector no receiver", "[.integration][cli]") {
auto t = slsDetector::getTypeFromDetector(hostname);
CHECK(t == type);
slsDetector d(t);
CHECK(d.getDetectorTypeAsEnum() == t);
CHECK(d.getDetectorTypeAsString() == detector_type);
d.setHostname(hostname);
CHECK(d.getHostname() == hostname);
d.setOnline(true);
CHECK(d.getOnlineFlag() == true);
d.freeSharedMemory();
}
TEST_CASE("single EIGER detector no receiver basic set and get",
"[.integration][eiger]") {
// TODO! this test should take command line arguments for config
SingleDetectorConfig c;
@ -48,9 +71,12 @@ TEST_CASE("single EIGER detector no receiver basic set and get", "[.integration]
CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::X) == 1024);
CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Y) == 256);
// CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Z) == 1);
CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::X) == 1024);
CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Y) == 256);
// CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z) == 1);
CHECK(d.getTotalNumberOfChannelsInclGapPixels(
slsDetectorDefs::dimension::X) == 1024);
CHECK(d.getTotalNumberOfChannelsInclGapPixels(
slsDetectorDefs::dimension::Y) == 256);
// CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z)
// == 1);
CHECK(d.getNChans() == 256 * 256);
CHECK(d.getNChans(slsDetectorDefs::dimension::X) == 256);
@ -142,15 +168,17 @@ TEST_CASE("Locking mechanism and last ip", "[.integration]") {
d.freeSharedMemory();
}
TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
// FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */
// ACQUISITION_TIME, /**< exposure time */
// FRAME_PERIOD, /**< period between exposures */
// DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */
// GATES_NUMBER, /**< number of gates per frame (in gated mode) */
// CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */
TEST_CASE("Timer functions", "[.integration][cli]") {
// FRAME_NUMBER, /**< number of real time frames: total number of
// acquisitions is number or frames*number of cycles */ ACQUISITION_TIME,
// /**< exposure time */ FRAME_PERIOD, /**< period between exposures */
// DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or
// readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per
// frame (in gated mode) */ CYCLES_NUMBER, /**< number of cycles: total
// number of acquisitions is number or frames*number of cycles */
// ACTUAL_TIME, /**< Actual time of the detector's internal timer */
// MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */
// MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo)
// */
// PROGRESS, /**< fraction of measurement elapsed - only get! */
// MEASUREMENTS_NUMBER,
@ -163,43 +191,56 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
// MEASURED_PERIOD, /**< measured period */
// MEASURED_SUBPERIOD, /**< measured subperiod */
// MAX_TIMERS
SingleDetectorConfig c;
auto type = slsDetector::getTypeFromDetector(c.hostname);
slsDetector d(type);
d.setHostname(c.hostname);
d.setHostname(hostname);
d.setOnline(true);
// Number of frames
auto frames = 10;
auto frames = 5;
d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, frames);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER) == frames);
auto t = 10000000;
d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t);
auto exptime = 2000000000;
d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, exptime);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == exptime);
auto period = 1000000000;
auto period = 2000000000;
d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD) == period);
// not implemented for EIGER
// auto delay = 10000;
// d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay);
// CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) == delay);
if (type != dt::EIGER) {
auto delay = 10000;
d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) ==
delay);
}
// auto gates = 1;
// d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates);
// CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates);
if (type != dt::EIGER) {
auto gates = 1;
d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates);
}
auto cycles = 2;
d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER, cycles);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER) == cycles);
if (type == dt::EIGER) {
auto subtime = 200;
d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME, subtime);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) == subtime);
d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME,
subtime);
CHECK(d.setTimer(
slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) ==
subtime);
}
// for (int i =0; i!=frames; ++i)
d.startAndReadAll();
d.freeSharedMemory();
// If we add a timer we should add tests for the timer
CHECK(slsDetectorDefs::MAX_TIMERS == 19);
}
// TEST_CASE("Aquire", "[.integration][eiger]"){
@ -216,15 +257,16 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
// d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
// d.startAndReadAll();
// auto rperiod = d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD);
// auto rperiod =
// d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD);
// CHECK(rperiod == 0.1);
// d.freeSharedMemory();
// }
TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider", "[.eigerintegration]") {
TEST_CASE(
"Eiger Dynamic Range with effect on rate correction and clock divider",
"[.eigerintegration]") {
SingleDetectorConfig c;
int ratecorr = 125;
@ -277,7 +319,6 @@ TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider"
CHECK(m.getRateCorrection() == 0);
}
TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
SingleDetectorConfig c;
@ -315,24 +356,29 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
CHECK(m.setPatternWord(addr, -1) == word);
addr = MAX_ADDR;
CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError);
CHECK_THROWS_WITH(m.setPatternWord(addr, word), Catch::Matchers::Contains( "be between 0 and" ));
CHECK_THROWS_WITH(m.setPatternWord(addr, word),
Catch::Matchers::Contains("be between 0 and"));
addr = -1;
CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError);
CHECK_THROWS_WITH(m.setPatternWord(addr, word), Catch::Matchers::Contains( "be between 0 and" ));
CHECK_THROWS_WITH(m.setPatternWord(addr, word),
Catch::Matchers::Contains("be between 0 and"));
addr = 0x2FF;
for (level = 0; level < 3; ++level) {
CHECK(m.setPatternWaitAddr(level, addr) == addr);
CHECK(m.setPatternWaitAddr(level, -1) == addr);
}
CHECK_THROWS_WITH(m.setPatternWaitAddr(-1, addr), Catch::Matchers::Contains( "be between 0 and" ));
CHECK_THROWS_WITH(m.setPatternWaitAddr(0, MAX_ADDR), Catch::Matchers::Contains( "be between 0 and" ));
CHECK_THROWS_WITH(m.setPatternWaitAddr(-1, addr),
Catch::Matchers::Contains("be between 0 and"));
CHECK_THROWS_WITH(m.setPatternWaitAddr(0, MAX_ADDR),
Catch::Matchers::Contains("be between 0 and"));
for (level = 0; level < 3; ++level) {
CHECK(m.setPatternWaitTime(level, word) == word);
CHECK(m.setPatternWaitTime(level, -1) == word);
}
CHECK_THROWS_WITH(m.setPatternWaitTime(-1, word), Catch::Matchers::Contains( "be between 0 and" ));
CHECK_THROWS_WITH(m.setPatternWaitTime(-1, word),
Catch::Matchers::Contains("be between 0 and"));
{
int startaddr = addr;

View File

@ -1,11 +1,110 @@
// #include "catch.hpp"
// #include "multiSlsDetector.h"
#include "catch.hpp"
#include "multiSlsDetector.h"
#include "string_utils.h"
#include "tests/globals.h"
#include <iostream>
// #include <iostream>
// TEST_CASE("Initialize a detector") {
// multiSlsDetector det(0, true, true);
// std::cout << "Size: " << det.getNumberOfDetectors() << std::endl;
// std::cout << "Hostname: " << det.getHostname() << std::endl;
// REQUIRE(false);
using namespace Catch::literals;
// }
TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
auto hostnames = sls::split(hostname, '+');
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
REQUIRE(d.setOnline() == true); // get!
CHECK(d.getHostname() == hostname);
for (size_t i = 0; i != hostnames.size(); ++i) {
CHECK(d.getHostname(i) == hostnames[i]);
}
CHECK(d.getDetectorTypeAsEnum() == type);
CHECK(d.getDetectorTypeAsString() == detector_type);
CHECK(d.getNumberOfDetectors() == hostnames.size());
d.freeSharedMemory();
}
TEST_CASE("Set and read timers", "[.integration][.multi]") {
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
// FRAME_NUMBER
int n_frames = 3;
d.setNumberOfFrames(n_frames);
CHECK(d.setNumberOfFrames() == n_frames);
// ACQUISITION_TIME
double exptime = 0.3;
d.setExposureTime(exptime, true);
CHECK(d.setExposureTime(-1, true) == Approx(exptime));
CHECK(d.setExposureTime(-1) == Approx(exptime * 1E9));
// FRAME_PERIOD,
double period = 0.5;
d.setExposurePeriod(period, true);
CHECK(d.setExposurePeriod(-1, true) == Approx(period));
CHECK(d.setExposurePeriod(-1) == Approx(period * 1E9));
// DELAY_AFTER_TRIGGER,
// GATES_NUMBER,
// CYCLES_NUMBER,
// ACTUAL_TIME
// MEASUREMENT_TIME
// PROGRESS, /**< fraction of measurement elapsed - only get! */
// MEASUREMENTS_NUMBER,
int measurements = 2;
d.setTimer(ti::MEASUREMENTS_NUMBER, measurements);
CHECK(d.setTimer(ti::MEASUREMENTS_NUMBER, -1) == measurements);
// FRAMES_FROM_START,
// FRAMES_FROM_START_PG,
// SAMPLES,
// SUBFRAME_ACQUISITION_TIME, /**< subframe exposure time */
double subframe_exposure = 2000000; // ns
if (type == dt::EIGER) {
d.setSubFrameExposureTime(subframe_exposure);
CHECK(d.setSubFrameExposureTime(-1) == Approx(subframe_exposure));
}
// STORAGE_CELL_NUMBER, /**<number of storage cells */
// SUBFRAME_DEADTIME, /**< subframe deadtime */
double subframe_deadtime = 4000; // ns
if (type == dt::EIGER) {
d.setSubFrameExposureDeadTime(subframe_deadtime);
CHECK(d.setSubFrameExposureDeadTime(-1) == Approx(subframe_deadtime));
}
if (type == dt::EIGER) {
// 32bit is needed for subframe exposure
d.setDynamicRange(32);
CHECK(d.setDynamicRange(-1) == 32);
d.setReadOutFlags(ro::PARALLEL);
// Needed to have measured values
d.acquire();
// MEASURED_PERIOD, /**< measured period */
for (int i = 0; i != d.getNumberOfDetectors(); ++i) {
CHECK(d.getMeasuredPeriod(true, i) == Approx(period));
}
// MEASURED_SUBPERIOD, /**< measured subperiod */
for (int i = 0; i != d.getNumberOfDetectors(); ++i) {
CHECK(d.getMeasuredSubFramePeriod(false, i) ==
Approx(subframe_deadtime + subframe_exposure));
}
}
// MAX_TIMERS
d.freeSharedMemory();
}

View File

@ -292,6 +292,8 @@ class slsDetector : public virtual slsDetectorDefs{
int64_t getId(idMode mode);
int sendToDetector(int fnum, void* args, size_t args_size, void* retval, size_t retval_size);
int64_t getReceiverSoftwareVersion() const;
/**

View File

@ -1825,24 +1825,30 @@ int slsDetector::getDataBytesInclGapPixels() {
int slsDetector::setDAC(int val, dacIndex index, int mV) {
int fnum = F_SET_DAC;
int ret = FAIL;
int args[3]{static_cast<int>(index), mV, val};
int args[]{static_cast<int>(index), mV, val};
int retval = -1;
FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val
<< (mV != 0 ? "mV" : "dac units");
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
sizeof(retval));
sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
FILE_LOG(logDEBUG1) << "Dac index " << index << ": " << retval
<< (mV != 0 ? "mV" : "dac units");
}
return retval;
}
int slsDetector::sendToDetector(int fnum, void* args, size_t args_size, void* retval, size_t retval_size)
{
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
auto ret = client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
client.close();
if (ret == FORCE_UPDATE) {
updateDetector();
}
return retval;
return ret;
}
int slsDetector::getADC(dacIndex index) {
@ -1852,10 +1858,7 @@ int slsDetector::getADC(dacIndex index) {
FILE_LOG(logDEBUG1) << "Getting ADC " << index;
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
sizeof(retval));
sendToDetector(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
FILE_LOG(logDEBUG1) << "ADC (" << index << "): " << retval;
}
return retval;
@ -1870,10 +1873,7 @@ slsDetector::setExternalCommunicationMode(externalCommunicationMode pol) {
FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol;
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
sizeof(retval));
ret = sendToDetector(fnum, &arg, sizeof(arg), &retval,sizeof(retval));
FILE_LOG(logDEBUG1) << "Timing Mode: " << retval;
}
if (ret == FORCE_UPDATE) {
@ -1952,45 +1952,30 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) {
int fnum = F_WRITE_REGISTER;
int ret = FAIL;
uint32_t args[]{addr, val};
uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Writing to register 0x" << std::hex << addr
<< "data: 0x" << std::hex << val << std::dec;
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
sizeof(retval));
sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
FILE_LOG(logDEBUG1) << "Register 0x" << std::hex << addr << ": 0x"
<< std::hex << retval << std::dec;
}
if (ret == FORCE_UPDATE) {
updateDetector();
}
return retval;
}
uint32_t slsDetector::readRegister(uint32_t addr) {
int fnum = F_READ_REGISTER;
int ret = FAIL;
uint32_t arg = addr;
uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Reading register 0x" << std::hex << addr
<< std::dec;
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname,
detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
sizeof(retval));
sendToDetector(fnum, &addr, sizeof(addr), &retval, sizeof(retval));
FILE_LOG(logDEBUG1) << "Register 0x" << std::hex << addr << ": 0x"
<< std::hex << retval << std::dec;
}
if (ret == FORCE_UPDATE) {
updateDetector();
}
return retval;
}

View File

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

View File

@ -1,5 +1,8 @@
#pragma once
#include <string>
#include "sls_detector_defs.h"
struct SingleDetectorConfig {
slsDetectorDefs::detectorType type_enum =
slsDetectorDefs::detectorType::CHIPTESTBOARD;

View File

@ -0,0 +1,8 @@
#include "sls_detector_defs.h"
using dt = slsDetectorDefs::detectorType;
using di = slsDetectorDefs::dacIndex;
using ti = slsDetectorDefs::timerIndex;
using ro = slsDetectorDefs::readOutFlags;
extern std::string hostname;
extern std::string detector_type;
extern dt type;

View File

@ -1,3 +1,38 @@
// tests-main.cpp
#define CATCH_CONFIG_MAIN
// #define CATCH_CONFIG_MAIN
// #include "catch.hpp"
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
#include "sls_detector_defs.h"
#include "tests/config.h"
#include <string>
// using namespace Catch::clara;
using Opt = Catch::clara::Opt;
using dt = slsDetectorDefs::detectorType;
std::string hostname;
std::string detector_type;
dt type;
int main(int argc, char *argv[]) {
Catch::Session session;
auto cli = session.cli() |
Opt(hostname, "hostname")["-hn"]["--hostname"](
"Detector hostname for integration tests") |
Opt(detector_type, "detector_type")["-dt"]["--detector_type"](
"Detector type for integration tests");
session.cli(cli);
auto ret = session.applyCommandLine(argc, argv);
if (ret) {
return ret;
}
type = slsDetectorDefs::detectorTypeToEnum(detector_type);
return session.run();
}