adding config for tests

This commit is contained in:
Erik Frojdh 2019-04-23 17:37:02 +02:00
parent 72091f47d9
commit 02fd4b356e
9 changed files with 258 additions and 91 deletions

View File

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

View File

@ -13,18 +13,41 @@
#include <vector> #include <vector>
#define VERBOSE #define VERBOSE
//Header holding all configurations for different detectors // 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;
//TODO! this test should take command line arguments for config 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; SingleDetectorConfig c;
//Read type by connecting to the detector // Read type by connecting to the detector
auto type = slsDetector::getTypeFromDetector(c.hostname); auto type = slsDetector::getTypeFromDetector(c.hostname);
CHECK(type == c.type_enum); CHECK(type == c.type_enum);
//Create slsDetector of said type and set hostname and detector online // Create slsDetector of said type and set hostname and detector online
slsDetector d(type); slsDetector d(type);
CHECK(d.getDetectorTypeAsEnum() == type); CHECK(d.getDetectorTypeAsEnum() == type);
CHECK(d.getDetectorTypeAsString() == c.type_string); CHECK(d.getDetectorTypeAsString() == c.type_string);
@ -38,19 +61,22 @@ TEST_CASE("single EIGER detector no receiver basic set and get", "[.integration]
CHECK(d.getReceiverOnline() == false); CHECK(d.getReceiverOnline() == false);
CHECK(d.checkDetectorVersionCompatibility() == slsDetectorDefs::OK); CHECK(d.checkDetectorVersionCompatibility() == slsDetectorDefs::OK);
//Setting and reading exposure time // Setting and reading exposure time
auto t = 1000000000; auto t = 1000000000;
d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t); d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t);
//size of an eiger half module with and without gap pixels // size of an eiger half module with and without gap pixels
CHECK(d.getTotalNumberOfChannels() == 256 * 256 * 4); CHECK(d.getTotalNumberOfChannels() == 256 * 256 * 4);
CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::X) == 1024); CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::X) == 1024);
CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Y) == 256); CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Y) == 256);
// CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Z) == 1); // CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Z) == 1);
CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::X) == 1024); CHECK(d.getTotalNumberOfChannelsInclGapPixels(
CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Y) == 256); slsDetectorDefs::dimension::X) == 1024);
// CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z) == 1); CHECK(d.getTotalNumberOfChannelsInclGapPixels(
slsDetectorDefs::dimension::Y) == 256);
// CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z)
// == 1);
CHECK(d.getNChans() == 256 * 256); CHECK(d.getNChans() == 256 * 256);
CHECK(d.getNChans(slsDetectorDefs::dimension::X) == 256); CHECK(d.getNChans(slsDetectorDefs::dimension::X) == 256);
@ -102,7 +128,7 @@ TEST_CASE("Set control port then create a new object with this control port",
d.setOnline(true); d.setOnline(true);
//Reset standard ports // Reset standard ports
d.setControlPort(old_cport); d.setControlPort(old_cport);
d.setStopPort(old_sport); d.setStopPort(old_sport);
d.freeSharedMemory(); d.freeSharedMemory();
@ -124,17 +150,17 @@ TEST_CASE("Locking mechanism and last ip", "[.integration]") {
d.setHostname(c.hostname); d.setHostname(c.hostname);
d.setOnline(true); d.setOnline(true);
//Check that detector server is unlocked then lock // Check that detector server is unlocked then lock
CHECK(d.lockServer() == 0); CHECK(d.lockServer() == 0);
d.lockServer(1); d.lockServer(1);
CHECK(d.lockServer() == 1); CHECK(d.lockServer() == 1);
//Can we still access the detector while it's locked // Can we still access the detector while it's locked
auto t = 1300000000; auto t = 1300000000;
d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t); d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t);
//unlock again and free // unlock again and free
d.lockServer(0); d.lockServer(0);
CHECK(d.lockServer() == 0); CHECK(d.lockServer() == 0);
@ -142,15 +168,17 @@ TEST_CASE("Locking mechanism and last ip", "[.integration]") {
d.freeSharedMemory(); d.freeSharedMemory();
} }
TEST_CASE("Excersise all possible set timer functions", "[.integration]") { TEST_CASE("Timer functions", "[.integration][cli]") {
// FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */ // FRAME_NUMBER, /**< number of real time frames: total number of
// ACQUISITION_TIME, /**< exposure time */ // acquisitions is number or frames*number of cycles */ ACQUISITION_TIME,
// FRAME_PERIOD, /**< period between exposures */ // /**< exposure time */ FRAME_PERIOD, /**< period between exposures */
// DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */ // DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or
// GATES_NUMBER, /**< number of gates per frame (in gated mode) */ // readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per
// CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */ // 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 */ // 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! */ // PROGRESS, /**< fraction of measurement elapsed - only get! */
// MEASUREMENTS_NUMBER, // MEASUREMENTS_NUMBER,
@ -163,43 +191,56 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
// MEASURED_PERIOD, /**< measured period */ // MEASURED_PERIOD, /**< measured period */
// MEASURED_SUBPERIOD, /**< measured subperiod */ // MEASURED_SUBPERIOD, /**< measured subperiod */
// MAX_TIMERS // MAX_TIMERS
SingleDetectorConfig c;
auto type = slsDetector::getTypeFromDetector(c.hostname);
slsDetector d(type); slsDetector d(type);
d.setHostname(c.hostname); d.setHostname(hostname);
d.setOnline(true); d.setOnline(true);
//Number of frames // Number of frames
auto frames = 10; auto frames = 5;
d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, frames); d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, frames);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER) == frames); CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER) == frames);
auto t = 10000000; auto exptime = 2000000000;
d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t); d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, exptime);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == exptime);
auto period = 1000000000; auto period = 2000000000;
d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period); d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD) == period); CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD) == period);
// not implemented for EIGER if (type != dt::EIGER) {
// auto delay = 10000; auto delay = 10000;
// d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay); d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay);
// CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) == delay); CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) ==
delay);
}
// auto gates = 1; if (type != dt::EIGER) {
// d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates); auto gates = 1;
// CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates); d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates);
}
auto cycles = 2; auto cycles = 2;
d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER, cycles); d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER, cycles);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER) == cycles); CHECK(d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER) == cycles);
auto subtime = 200; if (type == dt::EIGER) {
d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME, subtime); auto subtime = 200;
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(); d.freeSharedMemory();
// If we add a timer we should add tests for the timer
CHECK(slsDetectorDefs::MAX_TIMERS == 19);
} }
// TEST_CASE("Aquire", "[.integration][eiger]"){ // 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.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
// d.startAndReadAll(); // d.startAndReadAll();
// auto rperiod =
// d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD);
// auto rperiod = d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD);
// CHECK(rperiod == 0.1); // CHECK(rperiod == 0.1);
// d.freeSharedMemory(); // 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; SingleDetectorConfig c;
int ratecorr = 125; int ratecorr = 125;
@ -233,9 +275,9 @@ TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider"
multiSlsDetector m(0); multiSlsDetector m(0);
// ensure eiger detector type, hostname and online // ensure eiger detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum()==c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
REQUIRE(m.getHostname()==c.hostname); REQUIRE(m.getHostname() == c.hostname);
REQUIRE(m.setOnline(true)==slsDetectorDefs::ONLINE_FLAG); REQUIRE(m.setOnline(true) == slsDetectorDefs::ONLINE_FLAG);
// starting state with rate correction off // starting state with rate correction off
CHECK(m.setRateCorrection(0) == 0); CHECK(m.setRateCorrection(0) == 0);
@ -267,27 +309,26 @@ TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider"
// ratecorr fail with dr 4 or 8 // ratecorr fail with dr 4 or 8
CHECK_THROWS_AS(m.setDynamicRange(8), sls::NonCriticalError); CHECK_THROWS_AS(m.setDynamicRange(8), sls::NonCriticalError);
CHECK(m.getRateCorrection()==0); CHECK(m.getRateCorrection() == 0);
m.setDynamicRange(16); m.setDynamicRange(16);
m.setDynamicRange(16); m.setDynamicRange(16);
m.setRateCorrection(ratecorr); m.setRateCorrection(ratecorr);
m.setDynamicRange(16); m.setDynamicRange(16);
m.setRateCorrection(ratecorr); m.setRateCorrection(ratecorr);
CHECK_THROWS_AS(m.setDynamicRange(4), sls::NonCriticalError); CHECK_THROWS_AS(m.setDynamicRange(4), sls::NonCriticalError);
CHECK(m.getRateCorrection()==0); CHECK(m.getRateCorrection() == 0);
} }
TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") { TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); multiSlsDetector m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum()==c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
REQUIRE(m.getHostname()==c.hostname); REQUIRE(m.getHostname() == c.hostname);
REQUIRE(m.setOnline(true)==slsDetectorDefs::ONLINE_FLAG); REQUIRE(m.setOnline(true) == slsDetectorDefs::ONLINE_FLAG);
uint64_t word = 0; uint64_t word = 0;
int addr = 0; int addr = 0;
@ -314,25 +355,30 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
m.setPatternWord(addr, word); m.setPatternWord(addr, word);
CHECK(m.setPatternWord(addr, -1) == word); CHECK(m.setPatternWord(addr, -1) == word);
addr = MAX_ADDR; addr = MAX_ADDR;
CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError); 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; addr = -1;
CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError); 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; addr = 0x2FF;
for (level = 0; level < 3; ++level) { for (level = 0; level < 3; ++level) {
CHECK(m.setPatternWaitAddr(level, addr) == addr); CHECK(m.setPatternWaitAddr(level, addr) == addr);
CHECK(m.setPatternWaitAddr(level, -1) == 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(-1, addr),
CHECK_THROWS_WITH(m.setPatternWaitAddr(0, MAX_ADDR), Catch::Matchers::Contains( "be between 0 and" )); 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) { for (level = 0; level < 3; ++level) {
CHECK(m.setPatternWaitTime(level, word) == word); CHECK(m.setPatternWaitTime(level, word) == word);
CHECK(m.setPatternWaitTime(level, -1) == 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; int startaddr = addr;
@ -354,6 +400,6 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
CHECK_THROWS_WITH(m.setPatternLoops(-1, startaddr, MAX_ADDR, nloops), CHECK_THROWS_WITH(m.setPatternLoops(-1, startaddr, MAX_ADDR, nloops),
Catch::Matchers::Contains("be less than")); Catch::Matchers::Contains("be less than"));
CHECK_THROWS_WITH(m.setPatternLoops(-1, MAX_ADDR, stopaddr, nloops), CHECK_THROWS_WITH(m.setPatternLoops(-1, MAX_ADDR, stopaddr, nloops),
Catch::Matchers::Contains("be less than")); Catch::Matchers::Contains("be less than"));
} }
} }

View File

@ -1,11 +1,78 @@
// #include "catch.hpp" #include "catch.hpp"
// #include "multiSlsDetector.h"
// #include <iostream> #include "multiSlsDetector.h"
// TEST_CASE("Initialize a detector") { #include "string_utils.h"
// multiSlsDetector det(0, true, true);
// std::cout << "Size: " << det.getNumberOfDetectors() << std::endl;
// std::cout << "Hostname: " << det.getHostname() << std::endl;
// REQUIRE(false);
// } #include "tests/globals.h"
#include <iostream>
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 get dacs", "[.integration][.multi]"){
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
switch(type){
case dt::EIGER:
d.setDAC(3500, di::E_Vrf, 0);
CHECK(d.setDAC(-1, di::E_Vrf, 0) == 3500);
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(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);
auto th = 1000;
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);
break;
}
d.freeSharedMemory();
}
TEST_CASE("Timers", "[.integration][.multi]") {
multiSlsDetector d(0, true, true);
d.setHostname(hostname.c_str());
int n_frames = 3;
d.setNumberOfFrames(n_frames);
CHECK(d.setNumberOfFrames() == n_frames);
double exptime = 1;
d.setExposureTime(exptime, true);
CHECK(d.setExposureTime(-1, true) == exptime);
d.freeSharedMemory();
}

View File

@ -292,6 +292,8 @@ class slsDetector : public virtual slsDetectorDefs{
int64_t getId(idMode mode); 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; int64_t getReceiverSoftwareVersion() const;
/** /**

View File

@ -1826,16 +1826,13 @@ int slsDetector::getDataBytesInclGapPixels() {
int slsDetector::setDAC(int val, dacIndex index, int mV) { int slsDetector::setDAC(int val, dacIndex index, int mV) {
int fnum = F_SET_DAC; int fnum = F_SET_DAC;
int ret = FAIL; int ret = FAIL;
int args[3]{static_cast<int>(index), mV, val}; int args[]{static_cast<int>(index), mV, val};
int retval = -1; int retval = -1;
FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val
<< (mV != 0 ? "mV" : "dac units"); << (mV != 0 ? "mV" : "dac units");
if (detector_shm()->onlineFlag == ONLINE_FLAG) { if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname, ret = sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
sizeof(retval));
FILE_LOG(logDEBUG1) << "Dac index " << index << ": " << retval FILE_LOG(logDEBUG1) << "Dac index " << index << ": " << retval
<< (mV != 0 ? "mV" : "dac units"); << (mV != 0 ? "mV" : "dac units");
} }
@ -1845,6 +1842,15 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) {
return retval; 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);
return client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
}
int slsDetector::getADC(dacIndex index) { int slsDetector::getADC(dacIndex index) {
int fnum = F_GET_ADC; int fnum = F_GET_ADC;
int arg = static_cast<int>(index); int arg = static_cast<int>(index);
@ -1870,10 +1876,10 @@ slsDetector::setExternalCommunicationMode(externalCommunicationMode pol) {
FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol; FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol;
if (detector_shm()->onlineFlag == ONLINE_FLAG) { if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname, ret = sendToDetector(fnum, &arg, sizeof(arg), &retval,sizeof(retval));
detector_shm()->controlPort); // auto client = DetectorSocket(detector_shm()->hostname,
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval, // detector_shm()->controlPort);
sizeof(retval)); // ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,sizeof(retval));
FILE_LOG(logDEBUG1) << "Timing Mode: " << retval; FILE_LOG(logDEBUG1) << "Timing Mode: " << retval;
} }
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {

View File

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

View File

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

View File

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

View File

@ -1,3 +1,38 @@
// tests-main.cpp // tests-main.cpp
#define CATCH_CONFIG_MAIN // #define CATCH_CONFIG_MAIN
// #include "catch.hpp"
#define CATCH_CONFIG_RUNNER
#include "catch.hpp" #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();
}