mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
clang-format
This commit is contained in:
parent
32662baef8
commit
959fd562d3
@ -9,7 +9,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include "CmdProxy.h"
|
#include "CmdProxy.h"
|
||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
@ -52,5 +51,4 @@ int main() {
|
|||||||
auto help = replace_all(tmp, "\n\t", "\n\t\t");
|
auto help = replace_all(tmp, "\n\t", "\n\t\t");
|
||||||
fs << '\t' << cmd << usage << help << "\n";
|
fs << '\t' << cmd << usage << help << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#include "catch.hpp"
|
|
||||||
#include "DetectorImpl.h"
|
#include "DetectorImpl.h"
|
||||||
|
#include "catch.hpp"
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
#include "tests/globals.h"
|
#include "tests/globals.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
40
integrationTests/test-integrationDectector.cpp
Executable file → Normal file
40
integrationTests/test-integrationDectector.cpp
Executable file → Normal file
@ -2,9 +2,9 @@
|
|||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
#include "ClientSocket.h"
|
#include "ClientSocket.h"
|
||||||
#include "logger.h"
|
|
||||||
#include "DetectorImpl.h"
|
#include "DetectorImpl.h"
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
#include "logger.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
@ -79,7 +79,6 @@ TEST_CASE("Set control port then create a new object with this control port",
|
|||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("single EIGER detector no receiver basic set and get",
|
TEST_CASE("single EIGER detector no receiver basic set and get",
|
||||||
"[.integration][eiger]") {
|
"[.integration][eiger]") {
|
||||||
// TODO! this test should take command line arguments for config
|
// TODO! this test should take command line arguments for config
|
||||||
@ -130,8 +129,6 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
|
|||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
||||||
Module d(test::type);
|
Module d(test::type);
|
||||||
d.setHostname(test::hostname);
|
d.setHostname(test::hostname);
|
||||||
@ -154,13 +151,12 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
|||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Set settings", "[.integration][.single]"){
|
TEST_CASE("Set settings", "[.integration][.single]") {
|
||||||
Module d(test::type);
|
Module d(test::type);
|
||||||
d.setHostname(test::hostname);
|
d.setHostname(test::hostname);
|
||||||
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
|
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Timer functions", "[.integration][cli]") {
|
TEST_CASE("Timer functions", "[.integration][cli]") {
|
||||||
// FRAME_NUMBER, /**< number of real time frames: total number of
|
// FRAME_NUMBER, /**< number of real time frames: total number of
|
||||||
// acquisitions is number or frames*number of triggers */ ACQUISITION_TIME,
|
// acquisitions is number or frames*number of triggers */ ACQUISITION_TIME,
|
||||||
@ -204,8 +200,7 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
|
|||||||
if (test::type != dt::EIGER) {
|
if (test::type != dt::EIGER) {
|
||||||
auto delay = 10000;
|
auto delay = 10000;
|
||||||
d.setDelayAfterTrigger(delay);
|
d.setDelayAfterTrigger(delay);
|
||||||
CHECK(d.getDelayAfterTrigger() ==
|
CHECK(d.getDelayAfterTrigger() == delay);
|
||||||
delay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto triggers = 2;
|
auto triggers = 2;
|
||||||
@ -218,10 +213,9 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
|
|||||||
CHECK(d.getSubExptime() == subtime);
|
CHECK(d.getSubExptime() == subtime);
|
||||||
}
|
}
|
||||||
// for (int i =0; i!=frames; ++i)
|
// for (int i =0; i!=frames; ++i)
|
||||||
d.startAndReadAll();
|
d.startAndReadAll();
|
||||||
|
|
||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEST_CASE("Aquire", "[.integration][eiger]"){
|
// TEST_CASE("Aquire", "[.integration][eiger]"){
|
||||||
@ -382,8 +376,8 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert",
|
||||||
TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegration][dbit]") {
|
"[.ctbintegration][dbit]") {
|
||||||
SingleDetectorConfig c;
|
SingleDetectorConfig c;
|
||||||
|
|
||||||
// pick up multi detector from shm id 0
|
// pick up multi detector from shm id 0
|
||||||
@ -403,7 +397,7 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
|
|||||||
|
|
||||||
// dbit list
|
// dbit list
|
||||||
|
|
||||||
std::vector <int> list = m.getReceiverDbitList();
|
std::vector<int> list = m.getReceiverDbitList();
|
||||||
list.clear();
|
list.clear();
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
list.push_back(i);
|
list.push_back(i);
|
||||||
@ -414,14 +408,14 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
|
|||||||
list.push_back(64);
|
list.push_back(64);
|
||||||
CHECK_THROWS_AS(m.setReceiverDbitList(list), sls::RuntimeError);
|
CHECK_THROWS_AS(m.setReceiverDbitList(list), sls::RuntimeError);
|
||||||
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
|
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
|
||||||
Catch::Matchers::Contains("be between 0 and 63"));
|
Catch::Matchers::Contains("be between 0 and 63"));
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
for (int i = 0; i < 65; ++i)
|
for (int i = 0; i < 65; ++i)
|
||||||
list.push_back(i);
|
list.push_back(i);
|
||||||
CHECK(list.size() == 65);
|
CHECK(list.size() == 65);
|
||||||
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
|
CHECK_THROWS_WITH(m.setReceiverDbitList(list),
|
||||||
Catch::Matchers::Contains("be greater than 64"));
|
Catch::Matchers::Contains("be greater than 64"));
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
m.setReceiverDbitList(list);
|
m.setReceiverDbitList(list);
|
||||||
@ -441,7 +435,7 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
|
|||||||
m.setExternalSamplingSource(62);
|
m.setExternalSamplingSource(62);
|
||||||
CHECK(m.getExternalSamplingSource() == 62);
|
CHECK(m.getExternalSamplingSource() == 62);
|
||||||
CHECK_THROWS_WITH(m.setExternalSamplingSource(64),
|
CHECK_THROWS_WITH(m.setExternalSamplingSource(64),
|
||||||
Catch::Matchers::Contains("be 0-63"));
|
Catch::Matchers::Contains("be 0-63"));
|
||||||
CHECK(m.getExternalSamplingSource() == 62);
|
CHECK(m.getExternalSamplingSource() == 62);
|
||||||
m.setExternalSampling(1);
|
m.setExternalSampling(1);
|
||||||
CHECK(m.getExternalSampling() == 1);
|
CHECK(m.getExternalSampling() == 1);
|
||||||
@ -450,20 +444,23 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
|
|||||||
m.setExternalSampling(1);
|
m.setExternalSampling(1);
|
||||||
CHECK(m.getExternalSampling() == 1);
|
CHECK(m.getExternalSampling() == 1);
|
||||||
CHECK(m.readRegister(0x7b) == 0x1003E);
|
CHECK(m.readRegister(0x7b) == 0x1003E);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegration][startingfnum]") {
|
TEST_CASE("Eiger or Jungfrau startingfnum",
|
||||||
|
"[.eigerintegration][.jungfrauintegration][startingfnum]") {
|
||||||
SingleDetectorConfig c;
|
SingleDetectorConfig c;
|
||||||
|
|
||||||
// pick up multi detector from shm id 0
|
// pick up multi detector from shm id 0
|
||||||
DetectorImpl m(0);
|
DetectorImpl m(0);
|
||||||
|
|
||||||
// ensure ctb detector type, hostname and online
|
// ensure ctb detector type, hostname and online
|
||||||
REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU)));
|
REQUIRE(
|
||||||
|
((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) ||
|
||||||
|
(m.getDetectorTypeAsEnum() ==
|
||||||
|
slsDetectorDefs::detectorType::JUNGFRAU)));
|
||||||
REQUIRE(m.getHostname() == c.hostname);
|
REQUIRE(m.getHostname() == c.hostname);
|
||||||
|
|
||||||
CHECK(m.setNumberOfFrames(1) == 1);
|
CHECK(m.setNumberOfFrames(1) == 1);
|
||||||
|
|
||||||
// starting fnum
|
// starting fnum
|
||||||
uint64_t val = 8;
|
uint64_t val = 8;
|
||||||
@ -498,7 +495,8 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
|
|||||||
DetectorImpl m(0);
|
DetectorImpl m(0);
|
||||||
|
|
||||||
// ensure detector type, hostname
|
// ensure detector type, hostname
|
||||||
REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));
|
REQUIRE(
|
||||||
|
(m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));
|
||||||
REQUIRE(m.getHostname() == c.hostname);
|
REQUIRE(m.getHostname() == c.hostname);
|
||||||
|
|
||||||
m.setDynamicRange(16);
|
m.setDynamicRange(16);
|
||||||
|
6
integrationTests/test-integrationMulti.cpp
Executable file → Normal file
6
integrationTests/test-integrationMulti.cpp
Executable file → Normal file
@ -1,5 +1,5 @@
|
|||||||
#include "catch.hpp"
|
|
||||||
#include "DetectorImpl.h"
|
#include "DetectorImpl.h"
|
||||||
|
#include "catch.hpp"
|
||||||
#include "string_utils.h"
|
#include "string_utils.h"
|
||||||
#include "tests/globals.h"
|
#include "tests/globals.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -24,8 +24,6 @@ TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
|
|||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
||||||
|
|
||||||
DetectorImpl d(0, true, true);
|
DetectorImpl d(0, true, true);
|
||||||
@ -57,7 +55,6 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
|||||||
// PROGRESS, /**< fraction of measurement elapsed - only get! */
|
// PROGRESS, /**< fraction of measurement elapsed - only get! */
|
||||||
// MEASUREMENTS_NUMBER,
|
// MEASUREMENTS_NUMBER,
|
||||||
|
|
||||||
|
|
||||||
// FRAMES_FROM_START,
|
// FRAMES_FROM_START,
|
||||||
// FRAMES_FROM_START_PG,
|
// FRAMES_FROM_START_PG,
|
||||||
// SAMPLES,
|
// SAMPLES,
|
||||||
@ -78,7 +75,6 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
|||||||
CHECK(d.setSubFrameExposureDeadTime(-1) == Approx(subframe_deadtime));
|
CHECK(d.setSubFrameExposureDeadTime(-1) == Approx(subframe_deadtime));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (test::type == dt::EIGER) {
|
if (test::type == dt::EIGER) {
|
||||||
// 32bit is needed for subframe exposure
|
// 32bit is needed for subframe exposure
|
||||||
d.setDynamicRange(32);
|
d.setDynamicRange(32);
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
#include "network_utils.h"
|
#include "network_utils.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
|
|
||||||
class detectorData;
|
class detectorData;
|
||||||
|
|
||||||
@ -16,12 +15,11 @@ class DetectorImpl;
|
|||||||
class MacAddr;
|
class MacAddr;
|
||||||
class IpAddr;
|
class IpAddr;
|
||||||
|
|
||||||
//Free function to avoid dependence on class
|
// Free function to avoid dependence on class
|
||||||
//and avoid the option to free another objects
|
// and avoid the option to free another objects
|
||||||
//shm by mistake
|
// shm by mistake
|
||||||
void freeSharedMemory(int multiId, int detPos = -1);
|
void freeSharedMemory(int multiId, int detPos = -1);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class Detector
|
* \class Detector
|
||||||
*/
|
*/
|
||||||
@ -101,11 +99,12 @@ class Detector {
|
|||||||
/** [Jungfrau][Gotthard][Gotthard2] */
|
/** [Jungfrau][Gotthard][Gotthard2] */
|
||||||
Result<defs::detectorSettings> getSettings(Positions pos = {}) const;
|
Result<defs::detectorSettings> getSettings(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2
|
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2,
|
||||||
* [Gotthard] Options: DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN
|
* FORCESWITCHG1, FORCESWITCHG2 [Gotthard] Options: DYNAMICGAIN, HIGHGAIN,
|
||||||
* [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2
|
* LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN [Gotthard2] Options: DYNAMICGAIN,
|
||||||
* [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN,
|
* FIXGAIN1, FIXGAIN2 [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN,
|
||||||
* G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
|
* G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN,
|
||||||
|
* G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
|
||||||
*/
|
*/
|
||||||
void setSettings(defs::detectorSettings value, Positions pos = {});
|
void setSettings(defs::detectorSettings value, Positions pos = {});
|
||||||
|
|
||||||
@ -304,10 +303,12 @@ class Detector {
|
|||||||
void setDAC(defs::dacIndex index, int value, bool mV, Positions pos = {});
|
void setDAC(defs::dacIndex index, int value, bool mV, Positions pos = {});
|
||||||
|
|
||||||
/* [Gotthard2] */
|
/* [Gotthard2] */
|
||||||
Result<int> getOnChipDAC(defs::dacIndex index, int chipIndex, Positions pos = {}) const;
|
Result<int> getOnChipDAC(defs::dacIndex index, int chipIndex,
|
||||||
|
Positions pos = {}) const;
|
||||||
|
|
||||||
/* [Gotthard2] */
|
/* [Gotthard2] */
|
||||||
void setOnChipDAC(defs::dacIndex index, int chipIndex, int value, Positions pos = {});
|
void setOnChipDAC(defs::dacIndex index, int chipIndex, int value,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
@ -326,7 +327,8 @@ class Detector {
|
|||||||
*/
|
*/
|
||||||
void acquire();
|
void acquire();
|
||||||
|
|
||||||
/** If acquisition aborted, use this to clear before starting next acquisition */
|
/** If acquisition aborted, use this to clear before starting next
|
||||||
|
* acquisition */
|
||||||
void clearAcquiringFlag();
|
void clearAcquiringFlag();
|
||||||
|
|
||||||
/** Non Blocking: Start receiver listener*/
|
/** Non Blocking: Start receiver listener*/
|
||||||
@ -348,7 +350,8 @@ class Detector {
|
|||||||
|
|
||||||
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
||||||
|
|
||||||
Result<std::vector<uint64_t>> getNumMissingPackets(Positions pos = {}) const;
|
Result<std::vector<uint64_t>>
|
||||||
|
getNumMissingPackets(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Eiger][Jungfrau] */
|
/** [Eiger][Jungfrau] */
|
||||||
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
|
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
|
||||||
@ -512,7 +515,8 @@ class Detector {
|
|||||||
* Validates and sets the receiver.
|
* Validates and sets the receiver.
|
||||||
* Updates local receiver cache parameters
|
* Updates local receiver cache parameters
|
||||||
* Configures the detector to the receiver as UDP destination
|
* Configures the detector to the receiver as UDP destination
|
||||||
* @param receiver receiver hostname or IP address, can include tcp port eg. hostname:port
|
* @param receiver receiver hostname or IP address, can include tcp port eg.
|
||||||
|
* hostname:port
|
||||||
*/
|
*/
|
||||||
void setRxHostname(const std::string &receiver, Positions pos = {});
|
void setRxHostname(const std::string &receiver, Positions pos = {});
|
||||||
|
|
||||||
@ -659,10 +663,10 @@ class Detector {
|
|||||||
Result<int> getClientZmqPort(Positions pos = {}) const;
|
Result<int> getClientZmqPort(Positions pos = {}) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified only when using an intermediate process between receiver and gui/client.
|
* Modified only when using an intermediate process between receiver and
|
||||||
* Module_id is -1 for all detectors, ports for each
|
* gui/client. Module_id is -1 for all detectors, ports for each module is
|
||||||
* module is calculated (increments) Restarts client zmq sockets only if it
|
* calculated (increments) Restarts client zmq sockets only if it was
|
||||||
* was already enabled
|
* already enabled
|
||||||
*/
|
*/
|
||||||
void setClientZmqPort(int port, int module_id = -1);
|
void setClientZmqPort(int port, int module_id = -1);
|
||||||
|
|
||||||
@ -915,7 +919,6 @@ class Detector {
|
|||||||
void setExternalSignalFlags(defs::externalSignalFlag value,
|
void setExternalSignalFlags(defs::externalSignalFlag value,
|
||||||
Positions pos = {});
|
Positions pos = {});
|
||||||
|
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
* Gotthard2 Specific *
|
* Gotthard2 Specific *
|
||||||
@ -940,16 +943,21 @@ class Detector {
|
|||||||
/** [Gotthard2]
|
/** [Gotthard2]
|
||||||
* @param offsetChannel starting channel to be injected
|
* @param offsetChannel starting channel to be injected
|
||||||
* @param incrementChannel determines succeeding channels to be injected */
|
* @param incrementChannel determines succeeding channels to be injected */
|
||||||
void setInjectChannel(const int offsetChannel, const int incrementChannel, Positions pos = {});
|
void setInjectChannel(const int offsetChannel, const int incrementChannel,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/** [Gotthard2] adu values for each channel */
|
/** [Gotthard2] adu values for each channel */
|
||||||
Result<std::vector<int>> getVetoPhoton(const int chipIndex, Positions pos = {});
|
Result<std::vector<int>> getVetoPhoton(const int chipIndex,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/** [Gotthard2] energy in keV */
|
/** [Gotthard2] energy in keV */
|
||||||
void setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname, Positions pos = {});
|
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||||
|
const int energy, const std::string &fname,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/** [Gotthard2] */
|
/** [Gotthard2] */
|
||||||
void setVetoReference(const int gainIndex, const int value, Positions pos = {});
|
void setVetoReference(const int gainIndex, const int value,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/** [Gotthard2] */
|
/** [Gotthard2] */
|
||||||
Result<defs::burstMode> getBurstMode(Positions pos = {});
|
Result<defs::burstMode> getBurstMode(Positions pos = {});
|
||||||
@ -1096,7 +1104,7 @@ class Detector {
|
|||||||
Result<std::vector<int>> getRxDbitList(Positions pos = {}) const;
|
Result<std::vector<int>> getRxDbitList(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [CTB] list contains the set of bits (0-63) to save */
|
/** [CTB] list contains the set of bits (0-63) to save */
|
||||||
void setRxDbitList(const std::vector<int>& list, Positions pos = {});
|
void setRxDbitList(const std::vector<int> &list, Positions pos = {});
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
Result<int> getRxDbitOffset(Positions pos = {}) const;
|
Result<int> getRxDbitOffset(Positions pos = {}) const;
|
||||||
@ -1150,21 +1158,26 @@ class Detector {
|
|||||||
* [Mythen3][Moench] */
|
* [Mythen3][Moench] */
|
||||||
void setPatternWord(int addr, uint64_t word, Positions pos = {});
|
void setPatternWord(int addr, uint64_t word, Positions pos = {});
|
||||||
|
|
||||||
/**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
|
/**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
|
||||||
|
* levels
|
||||||
* @returns array of start address and stop address
|
* @returns array of start address and stop address
|
||||||
*/
|
*/
|
||||||
Result<std::array<int, 2>> getPatternLoopAddresses(int level,
|
Result<std::array<int, 2>>
|
||||||
Positions pos = {}) const;
|
getPatternLoopAddresses(int level, Positions pos = {}) const;
|
||||||
|
|
||||||
/** [CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels */
|
/** [CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
|
||||||
void setPatternLoopAddresses(int level, int start, int stop, Positions pos = {});
|
* levels */
|
||||||
|
void setPatternLoopAddresses(int level, int start, int stop,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2 levels
|
/**[CTB][Moench][Mythen3] Options: level: -1 (complete pattern) and 0-2
|
||||||
|
* levels
|
||||||
* @returns number of loops
|
* @returns number of loops
|
||||||
*/
|
*/
|
||||||
Result<int> getPatternLoopCycles(int level, Positions pos = {}) const;
|
Result<int> getPatternLoopCycles(int level, Positions pos = {}) const;
|
||||||
|
|
||||||
/** [CTB][Moench][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2 levels */
|
/** [CTB][Moench][Mythen3] n: 0-2, level: -1 (complete pattern) and 0-2
|
||||||
|
* levels */
|
||||||
void setPatternLoopCycles(int level, int n, Positions pos = {});
|
void setPatternLoopCycles(int level, int n, Positions pos = {});
|
||||||
|
|
||||||
/* [CTB][Moench][Mythen3] */
|
/* [CTB][Moench][Mythen3] */
|
||||||
@ -1182,14 +1195,15 @@ class Detector {
|
|||||||
/** [CTB][Moench][Mythen3] */
|
/** [CTB][Moench][Mythen3] */
|
||||||
Result<uint64_t> getPatternMask(Positions pos = {});
|
Result<uint64_t> getPatternMask(Positions pos = {});
|
||||||
|
|
||||||
/** [CTB][Moench][Mythen3] Sets the mask applied to every pattern to the selected bit mask */
|
/** [CTB][Moench][Mythen3] Sets the mask applied to every pattern to the
|
||||||
|
* selected bit mask */
|
||||||
void setPatternMask(uint64_t mask, Positions pos = {});
|
void setPatternMask(uint64_t mask, Positions pos = {});
|
||||||
|
|
||||||
/** [CTB][Moench][Mythen3] */
|
/** [CTB][Moench][Mythen3] */
|
||||||
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
|
Result<uint64_t> getPatternBitMask(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [CTB][Moench][Mythen3] Sets the bitmask that the mask will be applied to for every
|
/** [CTB][Moench][Mythen3] Sets the bitmask that the mask will be applied to
|
||||||
* pattern
|
* for every pattern
|
||||||
*/
|
*/
|
||||||
void setPatternBitMask(uint64_t mask, Positions pos = {});
|
void setPatternBitMask(uint64_t mask, Positions pos = {});
|
||||||
|
|
||||||
@ -1200,11 +1214,14 @@ class Detector {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
|
|
||||||
/** [Moench] */
|
/** [Moench] */
|
||||||
Result<std::map<std::string, std::string>> getAdditionalJsonHeader(Positions pos = {}) const;
|
Result<std::map<std::string, std::string>>
|
||||||
|
getAdditionalJsonHeader(Positions pos = {}) const;
|
||||||
|
|
||||||
/** [Moench] If empty, reset additional json header. Max 20 characters for each key/value */
|
/** [Moench] If empty, reset additional json header. Max 20 characters for
|
||||||
void setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader,
|
* each key/value */
|
||||||
Positions pos = {});
|
void setAdditionalJsonHeader(
|
||||||
|
const std::map<std::string, std::string> &jsonHeader,
|
||||||
|
Positions pos = {});
|
||||||
|
|
||||||
/** [Moench] */
|
/** [Moench] */
|
||||||
Result<std::string> getAdditionalJsonParameter(const std::string &key,
|
Result<std::string> getAdditionalJsonParameter(const std::string &key,
|
||||||
@ -1215,7 +1232,8 @@ class Detector {
|
|||||||
* else appends the parameter key and value
|
* else appends the parameter key and value
|
||||||
* If empty, deletes parameter. Max 20 characters for each key/value
|
* If empty, deletes parameter. Max 20 characters for each key/value
|
||||||
*/
|
*/
|
||||||
void setAdditionalJsonParameter(const std::string &key, const std::string &value,
|
void setAdditionalJsonParameter(const std::string &key,
|
||||||
|
const std::string &value,
|
||||||
Positions pos = {});
|
Positions pos = {});
|
||||||
|
|
||||||
/** [Moench] TODO! How do we do this best??? Can be refactored to something
|
/** [Moench] TODO! How do we do this best??? Can be refactored to something
|
||||||
|
92
slsDetectorSoftware/include/detectorData.h
Executable file → Normal file
92
slsDetectorSoftware/include/detectorData.h
Executable file → Normal file
@ -5,56 +5,60 @@
|
|||||||
@short data structure to hold the detector data after postprocessing
|
@short data structure to hold the detector data after postprocessing
|
||||||
*/
|
*/
|
||||||
class detectorData {
|
class detectorData {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param progress progress index
|
* @param progress progress index
|
||||||
* @param fname file name prefix
|
* @param fname file name prefix
|
||||||
* @param nx number of detector channels (1D detector) or dimension in x (2D detector)
|
* @param nx number of detector channels (1D detector) or dimension in x (2D
|
||||||
* @param ny dimension in y (2D detector)
|
* detector)
|
||||||
* @param d pointer to data in char* format
|
* @param ny dimension in y (2D detector)
|
||||||
* @param dbytes number of bytes of image pointed to by cval pointer
|
* @param d pointer to data in char* format
|
||||||
* @param dr dynamic range or bits per pixel
|
* @param dbytes number of bytes of image pointed to by cval pointer
|
||||||
* @param fIndex file index
|
* @param dr dynamic range or bits per pixel
|
||||||
* @param complete true if complete image, else missing packets
|
* @param fIndex file index
|
||||||
*/
|
* @param complete true if complete image, else missing packets
|
||||||
detectorData(double progress, std::string fname, int x, int y, char *d, int dbytes, int dr, uint64_t fIndex, bool complete) :
|
*/
|
||||||
progressIndex(progress), fileName(fname), fileIndex(fIndex), nx(x), ny(y), data(d), databytes(dbytes), dynamicRange(dr), completeImage(complete) {};
|
detectorData(double progress, std::string fname, int x, int y, char *d,
|
||||||
|
int dbytes, int dr, uint64_t fIndex, bool complete)
|
||||||
|
: progressIndex(progress), fileName(fname), fileIndex(fIndex), nx(x),
|
||||||
|
ny(y), data(d), databytes(dbytes), dynamicRange(dr),
|
||||||
|
completeImage(complete){};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
* data has to be deleted by caller
|
* data has to be deleted by caller
|
||||||
*/
|
*/
|
||||||
~detectorData() {};
|
~detectorData(){};
|
||||||
|
|
||||||
int64_t getChannel(int i) {
|
int64_t getChannel(int i) {
|
||||||
int off=dynamicRange/8;
|
int off = dynamicRange / 8;
|
||||||
if (off==1) {
|
if (off == 1) {
|
||||||
char val=*(data+i);
|
char val = *(data + i);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (off==2) {
|
if (off == 2) {
|
||||||
int16_t val=*((int16_t*)(data+i*off));
|
int16_t val = *((int16_t *)(data + i * off));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (off==4) {
|
if (off == 4) {
|
||||||
int32_t val=*((int32_t*)(data+i*off));
|
int32_t val = *((int32_t *)(data + i * off));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
if (off==8) {
|
if (off == 8) {
|
||||||
int64_t val=*((int64_t*)(data+i*off));
|
int64_t val = *((int64_t *)(data + i * off));
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//private:
|
// private:
|
||||||
double progressIndex;
|
double progressIndex;
|
||||||
std::string fileName;
|
std::string fileName;
|
||||||
uint64_t fileIndex;
|
uint64_t fileIndex;
|
||||||
int nx;
|
int nx;
|
||||||
int ny;
|
int ny;
|
||||||
char* data;
|
char *data;
|
||||||
int databytes;
|
int databytes;
|
||||||
int dynamicRange;
|
int dynamicRange;
|
||||||
bool completeImage;
|
bool completeImage;
|
||||||
};
|
};
|
||||||
|
1428
slsDetectorSoftware/include/slsDetectorUsers.h
Executable file → Normal file
1428
slsDetectorSoftware/include/slsDetectorUsers.h
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
10
slsDetectorSoftware/src/CmdParser.cpp
Executable file → Normal file
10
slsDetectorSoftware/src/CmdParser.cpp
Executable file → Normal file
@ -45,7 +45,8 @@ void CmdParser::Parse(const std::string &s) {
|
|||||||
auto old_size = arguments_.size();
|
auto old_size = arguments_.size();
|
||||||
arguments_.erase(std::remove_if(begin(arguments_), end(arguments_),
|
arguments_.erase(std::remove_if(begin(arguments_), end(arguments_),
|
||||||
[](const std::string &item) {
|
[](const std::string &item) {
|
||||||
return (item == "-h" || item == "--help");
|
return (item == "-h" ||
|
||||||
|
item == "--help");
|
||||||
}),
|
}),
|
||||||
end(arguments_));
|
end(arguments_));
|
||||||
if (old_size - arguments_.size() > 0)
|
if (old_size - arguments_.size() > 0)
|
||||||
@ -100,16 +101,15 @@ std::vector<const char *> CmdParser::argv() const {
|
|||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CmdParser::cli_line() const {
|
||||||
std::string CmdParser::cli_line() const{
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << command_;
|
os << command_;
|
||||||
for (const auto & arg : arguments_)
|
for (const auto &arg : arguments_)
|
||||||
os << " " << arg;
|
os << " " << arg;
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdParser::Reset(){
|
void CmdParser::Reset() {
|
||||||
multi_id_ = 0;
|
multi_id_ = 0;
|
||||||
detector_id_ = -1;
|
detector_id_ = -1;
|
||||||
help_ = false;
|
help_ = false;
|
||||||
|
8
slsDetectorSoftware/src/CmdParser.h
Executable file → Normal file
8
slsDetectorSoftware/src/CmdParser.h
Executable file → Normal file
@ -28,12 +28,14 @@ class CmdParser {
|
|||||||
int multi_id() const noexcept { return multi_id_; };
|
int multi_id() const noexcept { return multi_id_; };
|
||||||
int detector_id() const noexcept { return detector_id_; };
|
int detector_id() const noexcept { return detector_id_; };
|
||||||
int n_arguments() const noexcept { return arguments_.size(); }
|
int n_arguments() const noexcept { return arguments_.size(); }
|
||||||
const std::string &command() const noexcept{ return command_; }
|
const std::string &command() const noexcept { return command_; }
|
||||||
void setCommand(std::string cmd) { command_ = cmd; }
|
void setCommand(std::string cmd) { command_ = cmd; }
|
||||||
bool isHelp() const noexcept { return help_; }
|
bool isHelp() const noexcept { return help_; }
|
||||||
|
|
||||||
const std::string &executable() const noexcept{ return executable_; }
|
const std::string &executable() const noexcept { return executable_; }
|
||||||
const std::vector<std::string> &arguments() const noexcept{ return arguments_; };
|
const std::vector<std::string> &arguments() const noexcept {
|
||||||
|
return arguments_;
|
||||||
|
};
|
||||||
std::vector<const char *> argv() const;
|
std::vector<const char *> argv() const;
|
||||||
std::string cli_line() const;
|
std::string cli_line() const;
|
||||||
|
|
||||||
|
@ -169,7 +169,8 @@ std::string CmdProxy::VirtualServer(int action) {
|
|||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw sls::RuntimeError("Cannot execute this at module level");
|
throw sls::RuntimeError("Cannot execute this at module level");
|
||||||
}
|
}
|
||||||
det->setVirtualDetectorServers(StringTo<int>(args[0]), StringTo<int>(args[1]));
|
det->setVirtualDetectorServers(StringTo<int>(args[0]),
|
||||||
|
StringTo<int>(args[1]));
|
||||||
os << sls::ToString(args);
|
os << sls::ToString(args);
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -394,21 +395,24 @@ std::string CmdProxy::Adcphase(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[n_value] [(optional)deg]\n\t[Jungfrau][Ctb][Moench][Moench][Gotthard] Phase "
|
os << "[n_value] "
|
||||||
|
"[(optional)deg]\n\t[Jungfrau][Ctb][Moench][Moench][Gotthard] "
|
||||||
|
"Phase "
|
||||||
"shift of ADC clock. \n\t[Jungfrau] Absolute phase shift. If deg "
|
"shift of ADC clock. \n\t[Jungfrau] Absolute phase shift. If deg "
|
||||||
"used, then shift in degrees. Changing Speed also resets "
|
"used, then shift in degrees. Changing Speed also resets "
|
||||||
"adcphase to recommended defaults.\n\t[Ctb][Moench] Absolute phase "
|
"adcphase to recommended defaults.\n\t[Ctb][Moench] Absolute "
|
||||||
|
"phase "
|
||||||
"shift. If deg used, then shift in degrees. Changing adcclk also "
|
"shift. If deg used, then shift in degrees. Changing adcclk also "
|
||||||
"resets adcphase and sets it to previous values.\n\t[Gotthard] "
|
"resets adcphase and sets it to previous values.\n\t[Gotthard] "
|
||||||
"Relative phase shift"
|
"Relative phase shift"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (det_type == defs::EIGER ||
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||||
det_type == defs::MYTHEN3 ||
|
|
||||||
det_type == defs::GOTTHARD2) {
|
det_type == defs::GOTTHARD2) {
|
||||||
throw sls::RuntimeError("adcphase not implemented for this detector");
|
throw sls::RuntimeError(
|
||||||
}
|
"adcphase not implemented for this detector");
|
||||||
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
Result<int> t;
|
Result<int> t;
|
||||||
if (args.empty()) {
|
if (args.empty()) {
|
||||||
@ -416,7 +420,8 @@ std::string CmdProxy::Adcphase(int action) {
|
|||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
if (args[0] != "deg") {
|
if (args[0] != "deg") {
|
||||||
throw sls::RuntimeError("Unknown adcphase argument " + args[0] +
|
throw sls::RuntimeError("Unknown adcphase argument " +
|
||||||
|
args[0] +
|
||||||
". Did you mean deg? ");
|
". Did you mean deg? ");
|
||||||
}
|
}
|
||||||
t = det->getADCPhaseInDegrees({det_id});
|
t = det->getADCPhaseInDegrees({det_id});
|
||||||
@ -426,14 +431,14 @@ std::string CmdProxy::Adcphase(int action) {
|
|||||||
}
|
}
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
det->setADCPhase(StringTo<int>(args[0]), {det_id} );
|
det->setADCPhase(StringTo<int>(args[0]), {det_id});
|
||||||
os << args.front() << '\n';
|
os << args.front() << '\n';
|
||||||
} else if (args.size() == 2) {
|
} else if (args.size() == 2) {
|
||||||
if (args[1] != "deg") {
|
if (args[1] != "deg") {
|
||||||
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
|
throw sls::RuntimeError("Unknown adcphase 2nd argument " +
|
||||||
args[1] + ". Did you mean deg?");
|
args[1] + ". Did you mean deg?");
|
||||||
}
|
}
|
||||||
det->setADCPhaseInDegrees(StringTo<int>(args[0]) , {det_id});
|
det->setADCPhaseInDegrees(StringTo<int>(args[0]), {det_id});
|
||||||
os << args[0] << " " << args[1] << '\n';
|
os << args[0] << " " << args[1] << '\n';
|
||||||
} else {
|
} else {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
@ -449,17 +454,19 @@ std::string CmdProxy::Dbitphase(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau] Phase shift of clock to "
|
os << "[n_value] [(optional)deg]\n\t[Ctb][Jungfrau] Phase shift of "
|
||||||
|
"clock to "
|
||||||
"latch digital bits. Absolute phase shift. If deg used, then "
|
"latch digital bits. Absolute phase shift. If deg used, then "
|
||||||
"shift in degrees. \n\t[Ctb]Changing dbitclk also resets dbitphase and "
|
"shift in degrees. \n\t[Ctb]Changing dbitclk also resets "
|
||||||
|
"dbitphase and "
|
||||||
"sets to previous values."
|
"sets to previous values."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
auto det_type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (det_type == defs::EIGER ||
|
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
|
||||||
det_type == defs::MYTHEN3 ||
|
|
||||||
det_type == defs::GOTTHARD2) {
|
det_type == defs::GOTTHARD2) {
|
||||||
throw sls::RuntimeError("dbitphase not implemented for this detector");
|
throw sls::RuntimeError(
|
||||||
|
"dbitphase not implemented for this detector");
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
Result<int> t;
|
Result<int> t;
|
||||||
@ -485,7 +492,7 @@ std::string CmdProxy::Dbitphase(int action) {
|
|||||||
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
|
throw sls::RuntimeError("Unknown dbitphase 2nd argument " +
|
||||||
args[1] + ". Did you mean deg? ");
|
args[1] + ". Did you mean deg? ");
|
||||||
}
|
}
|
||||||
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id} );
|
det->setDBITPhaseInDegrees(StringTo<int>(args[0]), {det_id});
|
||||||
os << args[0] << " " << args[1] << '\n';
|
os << args[0] << " " << args[1] << '\n';
|
||||||
} else {
|
} else {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
@ -507,7 +514,8 @@ std::string CmdProxy::ClockFrequency(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw sls::RuntimeError("clkfreq not implemented for this detector.");
|
throw sls::RuntimeError(
|
||||||
|
"clkfreq not implemented for this detector.");
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
@ -519,8 +527,8 @@ std::string CmdProxy::ClockFrequency(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setClockFrequency(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
det->setClockFrequency(StringTo<int>(args[0]),
|
||||||
{det_id});
|
StringTo<int>(args[1]), {det_id});
|
||||||
os << StringTo<int>(args[1]) << '\n';
|
os << StringTo<int>(args[1]) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -541,7 +549,8 @@ std::string CmdProxy::ClockPhase(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw sls::RuntimeError("clkphase not implemented for this detector.");
|
throw sls::RuntimeError(
|
||||||
|
"clkphase not implemented for this detector.");
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
@ -552,16 +561,16 @@ std::string CmdProxy::ClockPhase(int action) {
|
|||||||
throw sls::RuntimeError("Cannot scan argument" + args[1] +
|
throw sls::RuntimeError("Cannot scan argument" + args[1] +
|
||||||
". Did you mean deg?");
|
". Did you mean deg?");
|
||||||
}
|
}
|
||||||
auto t =
|
auto t = det->getClockPhaseinDegrees(StringTo<int>(args[0]),
|
||||||
det->getClockPhaseinDegrees(StringTo<int>(args[0]), {det_id});
|
{det_id});
|
||||||
os << OutString(t) << " deg\n";
|
os << OutString(t) << " deg\n";
|
||||||
} else {
|
} else {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
det->setClockPhase(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
det->setClockPhase(StringTo<int>(args[0]),
|
||||||
{det_id});
|
StringTo<int>(args[1]), {det_id});
|
||||||
os << args[1] << '\n';
|
os << args[1] << '\n';
|
||||||
} else if (args.size() == 3) {
|
} else if (args.size() == 3) {
|
||||||
if (args[2] != "deg") {
|
if (args[2] != "deg") {
|
||||||
@ -591,13 +600,15 @@ std::string CmdProxy::MaxClockPhaseShift(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw sls::RuntimeError("maxclkphaseshift not implemented for this detector.");
|
throw sls::RuntimeError(
|
||||||
|
"maxclkphaseshift not implemented for this detector.");
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
auto t = det->getMaxClockPhaseShift(StringTo<int>(args[0]), {det_id});
|
auto t =
|
||||||
|
det->getMaxClockPhaseShift(StringTo<int>(args[0]), {det_id});
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
throw sls::RuntimeError("Cannot put");
|
throw sls::RuntimeError("Cannot put");
|
||||||
@ -618,7 +629,8 @@ std::string CmdProxy::ClockDivider(int action) {
|
|||||||
} else {
|
} else {
|
||||||
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
defs::detectorType type = det->getDetectorType().squash(defs::GENERIC);
|
||||||
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
if (type != defs::GOTTHARD2 && type != defs::MYTHEN3) {
|
||||||
throw sls::RuntimeError("clkdiv not implemented for this detector.");
|
throw sls::RuntimeError(
|
||||||
|
"clkdiv not implemented for this detector.");
|
||||||
}
|
}
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
@ -649,8 +661,11 @@ std::string CmdProxy::Dac(int action) {
|
|||||||
os << "[dac index] [dac or mv value] [(optional unit) mv] "
|
os << "[dac index] [dac or mv value] [(optional unit) mv] "
|
||||||
"\n\t[Ctb] Dac."
|
"\n\t[Ctb] Dac."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (det->getDetectorType().squash(defs::GENERIC) != defs::CHIPTESTBOARD) {
|
} else if (det->getDetectorType().squash(defs::GENERIC) !=
|
||||||
throw sls::RuntimeError("Dac command can only be used for chip test board. Use daclist to get list of dac commands for current detector.");
|
defs::CHIPTESTBOARD) {
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Dac command can only be used for chip test board. Use daclist to "
|
||||||
|
"get list of dac commands for current detector.");
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
bool mv = false;
|
bool mv = false;
|
||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
@ -662,8 +677,8 @@ std::string CmdProxy::Dac(int action) {
|
|||||||
} else if (args.size() > 2) {
|
} else if (args.size() > 2) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
auto t = det->getDAC(static_cast<defs::dacIndex>(StringTo<int>(args[0])),
|
auto t = det->getDAC(
|
||||||
mv, {det_id});
|
static_cast<defs::dacIndex>(StringTo<int>(args[0])), mv, {det_id});
|
||||||
os << args[0] << ' ' << OutString(t)
|
os << args[0] << ' ' << OutString(t)
|
||||||
<< (args.size() > 1 ? " mv\n" : "\n");
|
<< (args.size() > 1 ? " mv\n" : "\n");
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
@ -757,10 +772,10 @@ std::vector<std::string> CmdProxy::DacCommands() {
|
|||||||
break;
|
break;
|
||||||
case defs::GOTTHARD2:
|
case defs::GOTTHARD2:
|
||||||
return std::vector<std::string>{
|
return std::vector<std::string>{
|
||||||
"vref_h_adc", "vb_comp_fe", "vb_comp_adc", "vcom_cds",
|
"vref_h_adc", "vb_comp_fe", "vb_comp_adc", "vcom_cds",
|
||||||
"vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
|
"vref_rstore", "vb_opa_1st", "vref_comp_fe", "vcom_adc1",
|
||||||
"vref_prech", "vref_l_adc", "vref_cds", "vb_cs",
|
"vref_prech", "vref_l_adc", "vref_cds", "vb_cs",
|
||||||
"vb_opa_fd", "vcom_adc2"};
|
"vb_opa_fd", "vcom_adc2"};
|
||||||
break;
|
break;
|
||||||
case defs::MYTHEN3:
|
case defs::MYTHEN3:
|
||||||
return std::vector<std::string>{
|
return std::vector<std::string>{
|
||||||
@ -769,9 +784,9 @@ std::vector<std::string> CmdProxy::DacCommands() {
|
|||||||
"viinsh", "vph", "vtrim", "vdcsh"};
|
"viinsh", "vph", "vtrim", "vdcsh"};
|
||||||
break;
|
break;
|
||||||
case defs::MOENCH:
|
case defs::MOENCH:
|
||||||
return std::vector<std::string>{"vbp_colbuf", "vipre", "vin_cm",
|
return std::vector<std::string>{"vbp_colbuf", "vipre", "vin_cm",
|
||||||
"vb_sda", "vcasc_sfp", "vout_cm",
|
"vb_sda", "vcasc_sfp", "vout_cm",
|
||||||
"vipre_cds", "ibias_sfp"};
|
"vipre_cds", "ibias_sfp"};
|
||||||
break;
|
break;
|
||||||
case defs::CHIPTESTBOARD:
|
case defs::CHIPTESTBOARD:
|
||||||
return std::vector<std::string>{
|
return std::vector<std::string>{
|
||||||
@ -790,8 +805,7 @@ std::string CmdProxy::ReceiverStatus(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "running, idle]\n\tReceiver listener status."
|
os << "running, idle]\n\tReceiver listener status." << '\n';
|
||||||
<< '\n';
|
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
@ -799,7 +813,8 @@ std::string CmdProxy::ReceiverStatus(int action) {
|
|||||||
auto t = det->getReceiverStatus({det_id});
|
auto t = det->getReceiverStatus({det_id});
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
throw sls::RuntimeError("Cannot put. Did you mean to use command 'rx_start' or 'rx_stop'?");
|
throw sls::RuntimeError(
|
||||||
|
"Cannot put. Did you mean to use command 'rx_start' or 'rx_stop'?");
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
@ -810,8 +825,9 @@ std::string CmdProxy::DetectorStatus(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[running, error, transmitting, finished, waiting, idle]\n\tDetector status."
|
os << "[running, error, transmitting, finished, waiting, "
|
||||||
<< '\n';
|
"idle]\n\tDetector status."
|
||||||
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
@ -819,7 +835,8 @@ std::string CmdProxy::DetectorStatus(int action) {
|
|||||||
auto t = det->getDetectorStatus({det_id});
|
auto t = det->getDetectorStatus({det_id});
|
||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
throw sls::RuntimeError("Cannot put. Did you mean to use command 'start' or 'stop'?");
|
throw sls::RuntimeError(
|
||||||
|
"Cannot put. Did you mean to use command 'start' or 'stop'?");
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
}
|
}
|
||||||
@ -832,8 +849,10 @@ std::string CmdProxy::UDPDestinationIP(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[x.x.x.x] or auto\n\tIp address of the receiver (destination) udp interface. If 'auto' used, then ip is set to ip of rx_hostname."
|
os << "[x.x.x.x] or auto\n\tIp address of the receiver (destination) "
|
||||||
<< '\n';
|
"udp interface. If 'auto' used, then ip is set to ip of "
|
||||||
|
"rx_hostname."
|
||||||
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getDestinationUDPIP({det_id});
|
auto t = det->getDestinationUDPIP({det_id});
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) {
|
||||||
@ -845,14 +864,15 @@ std::string CmdProxy::UDPDestinationIP(int action) {
|
|||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
if (args[0] == "auto") {
|
if (args[0] == "auto") {
|
||||||
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
|
std::string rxHostname =
|
||||||
|
det->getRxHostname({det_id}).squash("none");
|
||||||
// Hostname could be ip try to decode otherwise look up the hostname
|
// Hostname could be ip try to decode otherwise look up the hostname
|
||||||
auto val = sls::IpAddr{rxHostname};
|
auto val = sls::IpAddr{rxHostname};
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
val = HostnameToIp(rxHostname.c_str());
|
val = HostnameToIp(rxHostname.c_str());
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Setting udp_dstip of detector " <<
|
LOG(logINFO) << "Setting udp_dstip of detector " << det_id << " to "
|
||||||
det_id << " to " << val;
|
<< val;
|
||||||
det->setDestinationUDPIP(val, {det_id});
|
det->setDestinationUDPIP(val, {det_id});
|
||||||
os << val << '\n';
|
os << val << '\n';
|
||||||
} else {
|
} else {
|
||||||
@ -870,8 +890,11 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[x.x.x.x] or auto\n\t[Jungfrau] Ip address of the receiver (destination) udp interface where the second half of detector data is sent to. If 'auto' used, then ip is set to ip of rx_hostname."
|
os << "[x.x.x.x] or auto\n\t[Jungfrau] Ip address of the receiver "
|
||||||
<< '\n';
|
"(destination) udp interface where the second half of detector "
|
||||||
|
"data is sent to. If 'auto' used, then ip is set to ip of "
|
||||||
|
"rx_hostname."
|
||||||
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
auto t = det->getDestinationUDPIP2({det_id});
|
auto t = det->getDestinationUDPIP2({det_id});
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) {
|
||||||
@ -883,14 +906,15 @@ std::string CmdProxy::UDPDestinationIP2(int action) {
|
|||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
if (args[0] == "auto") {
|
if (args[0] == "auto") {
|
||||||
std::string rxHostname = det->getRxHostname({det_id}).squash("none");
|
std::string rxHostname =
|
||||||
|
det->getRxHostname({det_id}).squash("none");
|
||||||
// Hostname could be ip try to decode otherwise look up the hostname
|
// Hostname could be ip try to decode otherwise look up the hostname
|
||||||
auto val = sls::IpAddr{rxHostname};
|
auto val = sls::IpAddr{rxHostname};
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
val = HostnameToIp(rxHostname.c_str());
|
val = HostnameToIp(rxHostname.c_str());
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "Setting udp_dstip2 of detector " <<
|
LOG(logINFO) << "Setting udp_dstip2 of detector " << det_id
|
||||||
det_id << " to " << val;
|
<< " to " << val;
|
||||||
det->setDestinationUDPIP2(val, {det_id});
|
det->setDestinationUDPIP2(val, {det_id});
|
||||||
os << val << '\n';
|
os << val << '\n';
|
||||||
} else {
|
} else {
|
||||||
@ -910,11 +934,13 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[hostname or ip address]\n\t"
|
os << "[hostname or ip address]\n\t"
|
||||||
"[hostname or ip address]:[tcp port]\n\t"
|
"[hostname or ip address]:[tcp port]\n\t"
|
||||||
"[hostname1]:[tcp_port1]+[hostname2]:[tcp_port2]+\n\t"
|
"[hostname1]:[tcp_port1]+[hostname2]:[tcp_port2]+\n\t"
|
||||||
"Receiver hostname or IP. If port included, then the receiver tcp port.\n\t"
|
"Receiver hostname or IP. If port included, then the receiver "
|
||||||
"Used for TCP control communication between client and receiver "
|
"tcp port.\n\t"
|
||||||
"to configure receiver. Also updates receiver with detector parameters."
|
"Used for TCP control communication between client and receiver "
|
||||||
|
"to configure receiver. Also updates receiver with detector "
|
||||||
|
"parameters."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
@ -930,10 +956,12 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
|||||||
if (args.size() > 1) {
|
if (args.size() > 1) {
|
||||||
// multiple in mulitple
|
// multiple in mulitple
|
||||||
if (args[0].find('+') != std::string::npos) {
|
if (args[0].find('+') != std::string::npos) {
|
||||||
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
throw sls::RuntimeError(
|
||||||
|
"Cannot add multiple receivers at module level");
|
||||||
}
|
}
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
throw sls::RuntimeError(
|
||||||
|
"Cannot add multiple receivers at module level");
|
||||||
}
|
}
|
||||||
det->setRxHostname(args);
|
det->setRxHostname(args);
|
||||||
os << ToString(args) << '\n';
|
os << ToString(args) << '\n';
|
||||||
@ -943,7 +971,8 @@ std::string CmdProxy::ReceiveHostname(int action) {
|
|||||||
// multiple receivers concatenated with +
|
// multiple receivers concatenated with +
|
||||||
if (args[0].find('+') != std::string::npos) {
|
if (args[0].find('+') != std::string::npos) {
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw sls::RuntimeError("Cannot add multiple receivers at module level");
|
throw sls::RuntimeError(
|
||||||
|
"Cannot add multiple receivers at module level");
|
||||||
}
|
}
|
||||||
auto t = sls::split(args[0], '+');
|
auto t = sls::split(args[0], '+');
|
||||||
det->setRxHostname(t);
|
det->setRxHostname(t);
|
||||||
@ -997,8 +1026,10 @@ std::string CmdProxy::Threshold(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[eV] [(optinal settings) standard, lowgain, veryhighgain, verylowgain]"
|
os << "[eV] [(optinal settings) standard, lowgain, veryhighgain, "
|
||||||
"\n\t[Eiger] Threshold in eV" << '\n';
|
"verylowgain]"
|
||||||
|
"\n\t[Eiger] Threshold in eV"
|
||||||
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
@ -1029,8 +1060,9 @@ std::string CmdProxy::ThresholdNoTb(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[eV] [(optional settings) standard, lowgain, veryhighgain, verylowgain]"
|
os << "[eV] [(optional settings) standard, lowgain, veryhighgain, "
|
||||||
"\n\t[Eiger] Threshold in eV set without setting trimbits"
|
"verylowgain]"
|
||||||
|
"\n\t[Eiger] Threshold in eV set without setting trimbits"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
throw sls::RuntimeError("cannot get");
|
throw sls::RuntimeError("cannot get");
|
||||||
@ -1058,12 +1090,12 @@ std::string CmdProxy::GapPixels(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data call back."
|
os << "[0, 1]\n\t[Eiger][Jungfrau] Include Gap pixels only in data "
|
||||||
|
"call back."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError("Cannot get gap pixels at module level");
|
||||||
"Cannot get gap pixels at module level");
|
|
||||||
}
|
}
|
||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
WrongNumberOfParameters(0);
|
WrongNumberOfParameters(0);
|
||||||
@ -1072,8 +1104,7 @@ std::string CmdProxy::GapPixels(int action) {
|
|||||||
os << t << '\n';
|
os << t << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError("Cannot add gap pixels at module level");
|
||||||
"Cannot add gap pixels at module level");
|
|
||||||
}
|
}
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
@ -1283,8 +1314,7 @@ std::string CmdProxy::Quad(int action) {
|
|||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError("Cannot execute quad at module level");
|
||||||
"Cannot execute quad at module level");
|
|
||||||
}
|
}
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
@ -1410,7 +1440,8 @@ std::string CmdProxy::InjectChannel(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setInjectChannel(StringTo<int>(args[0]), StringTo<int>(args[1]), {det_id});
|
det->setInjectChannel(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||||
|
{det_id});
|
||||||
os << sls::ToString(args) << '\n';
|
os << sls::ToString(args) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -1459,7 +1490,8 @@ std::string CmdProxy::VetoReference(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setVetoReference(StringTo<int>(args[0]), StringTo<int>(args[1]), {det_id});
|
det->setVetoReference(StringTo<int>(args[0]), StringTo<int>(args[1]),
|
||||||
|
{det_id});
|
||||||
os << sls::ToString(args) << '\n';
|
os << sls::ToString(args) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -1471,7 +1503,8 @@ std::string CmdProxy::BurstMode(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[off or 0, internal or 1, external or 2]\n\t[Gotthard2] Default is burst internal type"
|
os << "[off or 0, internal or 1, external or 2]\n\t[Gotthard2] Default "
|
||||||
|
"is burst internal type"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
if (action == defs::GET_ACTION) {
|
if (action == defs::GET_ACTION) {
|
||||||
@ -1527,7 +1560,7 @@ std::string CmdProxy::Counters(int action) {
|
|||||||
}
|
}
|
||||||
auto mask = det->getCounterMask({det_id}).squash(-1);
|
auto mask = det->getCounterMask({det_id}).squash(-1);
|
||||||
// scan counter enable mask to get vector
|
// scan counter enable mask to get vector
|
||||||
std::vector <int> result;
|
std::vector<int> result;
|
||||||
for (size_t i = 0; i < 32; ++i) {
|
for (size_t i = 0; i < 32; ++i) {
|
||||||
if (mask & (1 << i)) {
|
if (mask & (1 << i)) {
|
||||||
result.push_back(static_cast<int>(i));
|
result.push_back(static_cast<int>(i));
|
||||||
@ -1579,7 +1612,7 @@ std::string CmdProxy::Samples(int action) {
|
|||||||
int ds = d.squash(-1);
|
int ds = d.squash(-1);
|
||||||
if (as == -1 || ds == -1 || as != ds) { // check if a == d?
|
if (as == -1 || ds == -1 || as != ds) { // check if a == d?
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
"Different samples. Use asamples or dsamples.");
|
"Different samples. Use asamples or dsamples.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << OutString(a) << '\n';
|
os << OutString(a) << '\n';
|
||||||
@ -1691,7 +1724,8 @@ std::string CmdProxy::DigitalIODelay(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setDigitalIODelay(StringTo<uint64_t>(args[0]), StringTo<int>(args[1]), {det_id});
|
det->setDigitalIODelay(StringTo<uint64_t>(args[0]),
|
||||||
|
StringTo<int>(args[1]), {det_id});
|
||||||
os << sls::ToString(args) << '\n';
|
os << sls::ToString(args) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -1705,7 +1739,8 @@ std::string CmdProxy::Pattern(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern file with only pattern "
|
os << "[fname]\n\t[Mythen3][Moench][Ctb][Moench] Loads binary pattern "
|
||||||
|
"file with only pattern "
|
||||||
"words"
|
"words"
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
@ -1726,7 +1761,8 @@ std::string CmdProxy::PatternWord(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit pattern at "
|
os << "[step or address] [64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 "
|
||||||
|
"bit pattern at "
|
||||||
"address of pattern memory."
|
"address of pattern memory."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
@ -1739,7 +1775,8 @@ std::string CmdProxy::PatternWord(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->setPatternWord(StringTo<int>(args[0]), StringTo<uint64_t>(args[1]), {det_id});
|
det->setPatternWord(StringTo<int>(args[0]), StringTo<uint64_t>(args[1]),
|
||||||
|
{det_id});
|
||||||
os << sls::ToString(args) << '\n';
|
os << sls::ToString(args) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -1752,17 +1789,21 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
if (cmd == "patlimits") {
|
if (cmd == "patlimits") {
|
||||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of complete "
|
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||||
|
"of complete "
|
||||||
"pattern."
|
"pattern."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (cmd == "patloop0") {
|
} else if (cmd == "patloop0") {
|
||||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 0."
|
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||||
|
"of loop 0."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (cmd == "patloop1") {
|
} else if (cmd == "patloop1") {
|
||||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 1."
|
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||||
|
"of loop 1."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (cmd == "patloop2") {
|
} else if (cmd == "patloop2") {
|
||||||
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of loop 2."
|
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
|
||||||
|
"of loop 2."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
@ -1807,11 +1848,17 @@ std::string CmdProxy::PatternLoopCycles(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
if (cmd == "patnloop0") {
|
if (cmd == "patnloop0") {
|
||||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 0." << '\n';
|
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
||||||
|
"loop 0."
|
||||||
|
<< '\n';
|
||||||
} else if (cmd == "patnloop1") {
|
} else if (cmd == "patnloop1") {
|
||||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 1." << '\n';
|
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
||||||
|
"loop 1."
|
||||||
|
<< '\n';
|
||||||
} else if (cmd == "patnloop2") {
|
} else if (cmd == "patnloop2") {
|
||||||
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of loop 2." << '\n';
|
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
|
||||||
|
"loop 2."
|
||||||
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
"Unknown command, use list to list all commands");
|
"Unknown command, use list to list all commands");
|
||||||
@ -1897,11 +1944,17 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
if (cmd == "patwaittime0") {
|
if (cmd == "patwaittime0") {
|
||||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock cycles." << '\n';
|
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock "
|
||||||
|
"cycles."
|
||||||
|
<< '\n';
|
||||||
} else if (cmd == "patwaittime1") {
|
} else if (cmd == "patwaittime1") {
|
||||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock cycles." << '\n';
|
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock "
|
||||||
|
"cycles."
|
||||||
|
<< '\n';
|
||||||
} else if (cmd == "patwaittime2") {
|
} else if (cmd == "patwaittime2") {
|
||||||
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock cycles." << '\n';
|
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock "
|
||||||
|
"cycles."
|
||||||
|
<< '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
"Unknown command, use list to list all commands");
|
"Unknown command, use list to list all commands");
|
||||||
@ -1928,7 +1981,8 @@ std::string CmdProxy::PatternWaitTime(int action) {
|
|||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]), {det_id});
|
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]),
|
||||||
|
{det_id});
|
||||||
os << args.front() << '\n';
|
os << args.front() << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -1944,9 +1998,11 @@ std::string CmdProxy::AdditionalJsonHeader(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]"
|
os << "[key1] [value1] [key2] [value2]...[keyn] [valuen]"
|
||||||
"\n\tAdditional json header to be streamed out from receiver via zmq. "
|
"\n\tAdditional json header to be streamed out from receiver via "
|
||||||
"Default is empty. Use only if to be processed by an intermediate user process "
|
"zmq. "
|
||||||
"listening to receiver zmq packets. Empty value deletes header. "
|
"Default is empty. Use only if to be processed by an "
|
||||||
|
"intermediate user process "
|
||||||
|
"listening to receiver zmq packets. Empty value deletes header. "
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) {
|
||||||
@ -1978,7 +2034,8 @@ std::string CmdProxy::JsonParameter(int action) {
|
|||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[key1] [value1]\n\tAdditional json header parameter streamed "
|
os << "[key1] [value1]\n\tAdditional json header parameter streamed "
|
||||||
"out from receiver. If not found in header, the pair is appended. "
|
"out from receiver. If not found in header, the pair is "
|
||||||
|
"appended. "
|
||||||
"An empty values deletes parameter."
|
"An empty values deletes parameter."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
@ -1989,14 +2046,14 @@ std::string CmdProxy::JsonParameter(int action) {
|
|||||||
os << OutString(t) << '\n';
|
os << OutString(t) << '\n';
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
switch (args.size()) {
|
switch (args.size()) {
|
||||||
case 1:
|
case 1:
|
||||||
det->setAdditionalJsonParameter(args[0], "", {det_id});
|
det->setAdditionalJsonParameter(args[0], "", {det_id});
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
|
det->setAdditionalJsonParameter(args[0], args[1], {det_id});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WrongNumberOfParameters(1);
|
WrongNumberOfParameters(1);
|
||||||
}
|
}
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
os << args[0] << " deleted" << '\n';
|
os << args[0] << " deleted" << '\n';
|
||||||
@ -2061,9 +2118,9 @@ std::string CmdProxy::ProgramFpga(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs FPGA from pof file."
|
os << "[fname.pof | fname.rbf]\n\t[Jungfrau][Ctb][Moench] Programs "
|
||||||
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file."
|
"FPGA from pof file."
|
||||||
<< '\n';
|
<< "\n\t[Mythen3][Gotthard2] Programs FPGA from rbf file." << '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
throw sls::RuntimeError("Cannot get");
|
throw sls::RuntimeError("Cannot get");
|
||||||
} else if (action == defs::PUT_ACTION) {
|
} else if (action == defs::PUT_ACTION) {
|
||||||
@ -2082,7 +2139,8 @@ std::string CmdProxy::CopyDetectorServer(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies detector "
|
os << "[server_name] [pc_host_name]\n\t[Jungfrau][Ctb][Moench] Copies "
|
||||||
|
"detector "
|
||||||
"server via tftp from pc and changes respawn server name in "
|
"server via tftp from pc and changes respawn server name in "
|
||||||
"/etc/inittab of detector."
|
"/etc/inittab of detector."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
@ -2104,7 +2162,8 @@ std::string CmdProxy::UpdateFirmwareAndDetectorServer(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[server_name] [pc_host_name] [fname.pof]\n\t[Jungfrau][Ctb][Moench] "
|
os << "[server_name] [pc_host_name] "
|
||||||
|
"[fname.pof]\n\t[Jungfrau][Ctb][Moench] "
|
||||||
"Updates detector server via tftp from pc, updates firmware to "
|
"Updates detector server via tftp from pc, updates firmware to "
|
||||||
"pof file and then reboots controller (blackfin)."
|
"pof file and then reboots controller (blackfin)."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
@ -2142,7 +2201,8 @@ std::string CmdProxy::Register(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->writeRegister(StringTo<uint32_t>(args[0]), StringTo<uint32_t>(args[1]), {det_id});
|
det->writeRegister(StringTo<uint32_t>(args[0]),
|
||||||
|
StringTo<uint32_t>(args[1]), {det_id});
|
||||||
os << sls::ToString(args) << '\n';
|
os << sls::ToString(args) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -2154,7 +2214,8 @@ std::string CmdProxy::AdcRegister(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[address] [value]\n\t[Jungfrau][Ctb][Moench][Gotthard] Writes to an adc "
|
os << "[address] [value]\n\t[Jungfrau][Ctb][Moench][Gotthard] Writes "
|
||||||
|
"to an adc "
|
||||||
"register in hex."
|
"register in hex."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
@ -2163,7 +2224,8 @@ std::string CmdProxy::AdcRegister(int action) {
|
|||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
WrongNumberOfParameters(2);
|
WrongNumberOfParameters(2);
|
||||||
}
|
}
|
||||||
det->writeAdcRegister(StringTo<uint32_t>(args[0]), StringTo<uint32_t>(args[1]), {det_id});
|
det->writeAdcRegister(StringTo<uint32_t>(args[0]),
|
||||||
|
StringTo<uint32_t>(args[1]), {det_id});
|
||||||
os << sls::ToString(args) << '\n';
|
os << sls::ToString(args) << '\n';
|
||||||
} else {
|
} else {
|
||||||
throw sls::RuntimeError("Unknown action");
|
throw sls::RuntimeError("Unknown action");
|
||||||
@ -2236,7 +2298,10 @@ std::string CmdProxy::InitialChecks(int action) {
|
|||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << cmd << ' ';
|
os << cmd << ' ';
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << "[0, 1]\n\tEnable or disable intial compatibility and other checks at detector start up. It is enabled by default. Must come before 'hostname' command to take effect. Can be used to reprogram fpga when current firmware is incompatible."
|
os << "[0, 1]\n\tEnable or disable intial compatibility and other "
|
||||||
|
"checks at detector start up. It is enabled by default. Must "
|
||||||
|
"come before 'hostname' command to take effect. Can be used to "
|
||||||
|
"reprogram fpga when current firmware is incompatible."
|
||||||
<< '\n';
|
<< '\n';
|
||||||
} else if (action == defs::GET_ACTION) {
|
} else if (action == defs::GET_ACTION) {
|
||||||
if (det_id != -1) {
|
if (det_id != -1) {
|
||||||
@ -2264,7 +2329,6 @@ std::string CmdProxy::InitialChecks(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Insignificant */
|
/* Insignificant */
|
||||||
|
|
||||||
std::string CmdProxy::ExecuteCommand(int action) {
|
std::string CmdProxy::ExecuteCommand(int action) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
|||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
#include "CmdParser.h"
|
#include "CmdParser.h"
|
||||||
#include "CmdProxy.h"
|
#include "CmdProxy.h"
|
||||||
|
#include "DetectorImpl.h"
|
||||||
|
#include "Module.h"
|
||||||
#include "container_utils.h"
|
#include "container_utils.h"
|
||||||
#include "detectorData.h"
|
#include "detectorData.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "DetectorImpl.h"
|
|
||||||
#include "Module.h"
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ void Detector::loadParameters(const std::string &fname) {
|
|||||||
if (current_line.find('#') != std::string::npos) {
|
if (current_line.find('#') != std::string::npos) {
|
||||||
current_line.erase(current_line.find('#'));
|
current_line.erase(current_line.find('#'));
|
||||||
}
|
}
|
||||||
LOG(logDEBUG1)
|
LOG(logDEBUG1) << "current_line after removing comments:\n\t"
|
||||||
<< "current_line after removing comments:\n\t" << current_line;
|
<< current_line;
|
||||||
if (current_line.length() > 1) {
|
if (current_line.length() > 1) {
|
||||||
parser.Parse(current_line);
|
parser.Parse(current_line);
|
||||||
proxy.Call(parser.command(), parser.arguments(),
|
proxy.Call(parser.command(), parser.arguments(),
|
||||||
@ -97,13 +97,9 @@ void Detector::setVirtualDetectorServers(int numServers, int startingPort) {
|
|||||||
|
|
||||||
int Detector::getShmId() const { return pimpl->getMultiId(); }
|
int Detector::getShmId() const { return pimpl->getMultiId(); }
|
||||||
|
|
||||||
std::string Detector::getPackageVersion() const {
|
std::string Detector::getPackageVersion() const { return GITBRANCH; }
|
||||||
return GITBRANCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t Detector::getClientVersion() const {
|
int64_t Detector::getClientVersion() const { return APILIB; }
|
||||||
return APILIB;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {
|
Result<int64_t> Detector::getFirmwareVersion(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getFirmwareVersion, pos);
|
return pimpl->Parallel(&Module::getFirmwareVersion, pos);
|
||||||
@ -242,8 +238,7 @@ void Detector::setTimingMode(defs::timingMode value, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
|
Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
|
||||||
auto res =
|
auto res = pimpl->Parallel(&Module::getClockDivider, pos, defs::RUN_CLOCK);
|
||||||
pimpl->Parallel(&Module::getClockDivider, pos, defs::RUN_CLOCK);
|
|
||||||
Result<defs::speedLevel> speedResult(res.size());
|
Result<defs::speedLevel> speedResult(res.size());
|
||||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||||
speedResult[i] = static_cast<defs::speedLevel>(res[i]);
|
speedResult[i] = static_cast<defs::speedLevel>(res[i]);
|
||||||
@ -257,13 +252,11 @@ void Detector::setSpeed(defs::speedLevel value, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getADCPhase(Positions pos) const {
|
Result<int> Detector::getADCPhase(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK,
|
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setADCPhase(int value, Positions pos) {
|
void Detector::setADCPhase(int value, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value,
|
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getMaxADCPhaseShift(Positions pos) const {
|
Result<int> Detector::getMaxADCPhaseShift(Positions pos) const {
|
||||||
@ -272,13 +265,11 @@ Result<int> Detector::getMaxADCPhaseShift(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getADCPhaseInDegrees(Positions pos) const {
|
Result<int> Detector::getADCPhaseInDegrees(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK,
|
return pimpl->Parallel(&Module::getClockPhase, pos, defs::ADC_CLOCK, true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setADCPhaseInDegrees(int value, Positions pos) {
|
void Detector::setADCPhaseInDegrees(int value, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value,
|
pimpl->Parallel(&Module::setClockPhase, pos, defs::ADC_CLOCK, value, true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getDBITPhase(Positions pos) const {
|
Result<int> Detector::getDBITPhase(Positions pos) const {
|
||||||
@ -297,13 +288,11 @@ Result<int> Detector::getMaxDBITPhaseShift(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getDBITPhaseInDegrees(Positions pos) const {
|
Result<int> Detector::getDBITPhaseInDegrees(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockPhase, pos, defs::DBIT_CLOCK,
|
return pimpl->Parallel(&Module::getClockPhase, pos, defs::DBIT_CLOCK, true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setDBITPhaseInDegrees(int value, Positions pos) {
|
void Detector::setDBITPhaseInDegrees(int value, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setClockPhase, pos, defs::DBIT_CLOCK, value,
|
pimpl->Parallel(&Module::setClockPhase, pos, defs::DBIT_CLOCK, value, true);
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
|
Result<int> Detector::getClockFrequency(int clkIndex, Positions pos) {
|
||||||
@ -343,8 +332,7 @@ void Detector::setClockDivider(int clkIndex, int value, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getHighVoltage(Positions pos) const {
|
Result<int> Detector::getHighVoltage(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::setDAC, pos, -1, defs::HIGH_VOLTAGE,
|
return pimpl->Parallel(&Module::setDAC, pos, -1, defs::HIGH_VOLTAGE, 0);
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setHighVoltage(int value, Positions pos) {
|
void Detector::setHighVoltage(int value, Positions pos) {
|
||||||
@ -430,13 +418,9 @@ void Detector::acquire() { pimpl->acquire(); }
|
|||||||
|
|
||||||
void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); }
|
void Detector::clearAcquiringFlag() { pimpl->setAcquiringFlag(0); }
|
||||||
|
|
||||||
void Detector::startReceiver() {
|
void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
|
||||||
pimpl->Parallel(&Module::startReceiver, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::stopReceiver() {
|
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
||||||
pimpl->Parallel(&Module::stopReceiver, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::startDetector() {
|
void Detector::startDetector() {
|
||||||
if (getDetectorType().squash() == defs::EIGER) {
|
if (getDetectorType().squash() == defs::EIGER) {
|
||||||
@ -445,9 +429,7 @@ void Detector::startDetector() {
|
|||||||
pimpl->Parallel(&Module::startAcquisition, {});
|
pimpl->Parallel(&Module::startAcquisition, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::stopDetector() {
|
void Detector::stopDetector() { pimpl->Parallel(&Module::stopAcquisition, {}); }
|
||||||
pimpl->Parallel(&Module::stopAcquisition, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
Result<defs::runStatus> Detector::getDetectorStatus(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getRunStatus, pos);
|
return pimpl->Parallel(&Module::getRunStatus, pos);
|
||||||
@ -461,7 +443,8 @@ Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
|||||||
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
|
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<std::vector<uint64_t>> Detector::getNumMissingPackets(Positions pos) const {
|
Result<std::vector<uint64_t>>
|
||||||
|
Detector::getNumMissingPackets(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
|
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,8 +590,7 @@ void Detector::setDestinationUDPPort2(int port, int module_id) {
|
|||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id},
|
pimpl->Parallel(&Module::setDestinationUDPPort2, {module_id}, port);
|
||||||
port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,9 +659,9 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
|
|||||||
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
pimpl->Parallel(&Module::setReceiverHostname, {}, name[0]);
|
||||||
} else {
|
} else {
|
||||||
if ((int)name.size() != size()) {
|
if ((int)name.size() != size()) {
|
||||||
throw RuntimeError("Receiver hostnames size " +
|
throw RuntimeError(
|
||||||
std::to_string(name.size()) + " does not match detector size " +
|
"Receiver hostnames size " + std::to_string(name.size()) +
|
||||||
std::to_string(size()));
|
" does not match detector size " + std::to_string(size()));
|
||||||
}
|
}
|
||||||
// set each rx_hostname
|
// set each rx_hostname
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
@ -699,8 +681,7 @@ void Detector::setRxPort(int port, int module_id) {
|
|||||||
it = port++;
|
it = port++;
|
||||||
}
|
}
|
||||||
for (int idet = 0; idet < size(); ++idet) {
|
for (int idet = 0; idet < size(); ++idet) {
|
||||||
pimpl->Parallel(&Module::setReceiverPort, {idet},
|
pimpl->Parallel(&Module::setReceiverPort, {idet}, port_list[idet]);
|
||||||
port_list[idet]);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
pimpl->Parallel(&Module::setReceiverPort, {module_id}, port);
|
||||||
@ -751,8 +732,7 @@ void Detector::setRxUDPSocketBufferSize(int64_t udpsockbufsize, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int64_t> Detector::getRxRealUDPSocketBufferSize(Positions pos) const {
|
Result<int64_t> Detector::getRxRealUDPSocketBufferSize(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getReceiverRealUDPSocketBufferSize,
|
return pimpl->Parallel(&Module::getReceiverRealUDPSocketBufferSize, pos);
|
||||||
pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<bool> Detector::getRxLock(Positions pos) {
|
Result<bool> Detector::getRxLock(Positions pos) {
|
||||||
@ -871,8 +851,7 @@ void Detector::setRxZmqPort(int port, int module_id) {
|
|||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id},
|
pimpl->Parallel(&Module::setReceiverStreamingPort, {module_id}, port);
|
||||||
port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,8 +880,7 @@ void Detector::setClientZmqPort(int port, int module_id) {
|
|||||||
port_list[idet]);
|
port_list[idet]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pimpl->Parallel(&Module::setClientStreamingPort, {module_id},
|
pimpl->Parallel(&Module::setClientStreamingPort, {module_id}, port);
|
||||||
port);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,8 +930,8 @@ Result<int> Detector::getThresholdEnergy(Positions pos) const {
|
|||||||
void Detector::setThresholdEnergy(int threshold_ev,
|
void Detector::setThresholdEnergy(int threshold_ev,
|
||||||
defs::detectorSettings settings,
|
defs::detectorSettings settings,
|
||||||
bool trimbits, Positions pos) {
|
bool trimbits, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setThresholdEnergy, pos, threshold_ev,
|
pimpl->Parallel(&Module::setThresholdEnergy, pos, threshold_ev, settings,
|
||||||
settings, static_cast<int>(trimbits));
|
static_cast<int>(trimbits));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<std::string> Detector::getSettingsPath(Positions pos) const {
|
Result<std::string> Detector::getSettingsPath(Positions pos) const {
|
||||||
@ -1146,8 +1124,7 @@ void Detector::setAutoCompDisable(bool value, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getNumberOfAdditionalStorageCells(Positions pos) const {
|
Result<int> Detector::getNumberOfAdditionalStorageCells(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getNumberOfAdditionalStorageCells,
|
return pimpl->Parallel(&Module::getNumberOfAdditionalStorageCells, pos);
|
||||||
pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setNumberOfAdditionalStorageCells(int value) {
|
void Detector::setNumberOfAdditionalStorageCells(int value) {
|
||||||
@ -1224,19 +1201,26 @@ Result<std::array<int, 2>> Detector::getInjectChannel(Positions pos) {
|
|||||||
return pimpl->Parallel(&Module::getInjectChannel, pos);
|
return pimpl->Parallel(&Module::getInjectChannel, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setInjectChannel(const int offsetChannel, const int incrementChannel, Positions pos) {
|
void Detector::setInjectChannel(const int offsetChannel,
|
||||||
pimpl->Parallel(&Module::setInjectChannel, pos, offsetChannel, incrementChannel);
|
const int incrementChannel, Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setInjectChannel, pos, offsetChannel,
|
||||||
|
incrementChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<std::vector<int>> Detector::getVetoPhoton(const int chipIndex, Positions pos) {
|
Result<std::vector<int>> Detector::getVetoPhoton(const int chipIndex,
|
||||||
|
Positions pos) {
|
||||||
return pimpl->Parallel(&Module::getVetoPhoton, pos, chipIndex);
|
return pimpl->Parallel(&Module::getVetoPhoton, pos, chipIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname, Positions pos) {
|
void Detector::setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||||
pimpl->Parallel(&Module::setVetoPhoton, pos, chipIndex, numPhotons, energy, fname);
|
const int energy, const std::string &fname,
|
||||||
|
Positions pos) {
|
||||||
|
pimpl->Parallel(&Module::setVetoPhoton, pos, chipIndex, numPhotons, energy,
|
||||||
|
fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setVetoReference(const int gainIndex, const int value, Positions pos) {
|
void Detector::setVetoReference(const int gainIndex, const int value,
|
||||||
|
Positions pos) {
|
||||||
pimpl->Parallel(&Module::setVetoReference, pos, gainIndex, value);
|
pimpl->Parallel(&Module::setVetoReference, pos, gainIndex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1284,10 +1268,8 @@ void Detector::setNumberOfAnalogSamples(int value, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::setNumberOfAnalogSamples, pos, value);
|
pimpl->Parallel(&Module::setNumberOfAnalogSamples, pos, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Result<int> Detector::getADCClock(Positions pos) const {
|
Result<int> Detector::getADCClock(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::ADC_CLOCK);
|
||||||
defs::ADC_CLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setADCClock(int value_in_MHz, Positions pos) {
|
void Detector::setADCClock(int value_in_MHz, Positions pos) {
|
||||||
@ -1296,8 +1278,7 @@ void Detector::setADCClock(int value_in_MHz, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getRUNClock(Positions pos) const {
|
Result<int> Detector::getRUNClock(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::RUN_CLOCK);
|
||||||
defs::RUN_CLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRUNClock(int value_in_MHz, Positions pos) {
|
void Detector::setRUNClock(int value_in_MHz, Positions pos) {
|
||||||
@ -1306,8 +1287,7 @@ void Detector::setRUNClock(int value_in_MHz, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getSYNCClock(Positions pos) const {
|
Result<int> Detector::getSYNCClock(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::SYNC_CLOCK);
|
||||||
defs::SYNC_CLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getADCPipeline(Positions pos) const {
|
Result<int> Detector::getADCPipeline(Positions pos) const {
|
||||||
@ -1372,7 +1352,6 @@ void Detector::setTenGigaADCEnableMask(uint32_t mask, Positions pos) {
|
|||||||
|
|
||||||
// CTB Specific
|
// CTB Specific
|
||||||
|
|
||||||
|
|
||||||
Result<int> Detector::getNumberOfDigitalSamples(Positions pos) const {
|
Result<int> Detector::getNumberOfDigitalSamples(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getNumberOfDigitalSamples, pos);
|
return pimpl->Parallel(&Module::getNumberOfDigitalSamples, pos);
|
||||||
}
|
}
|
||||||
@ -1390,8 +1369,7 @@ void Detector::setReadoutMode(defs::readoutMode value, Positions pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getDBITClock(Positions pos) const {
|
Result<int> Detector::getDBITClock(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getClockFrequency, pos,
|
return pimpl->Parallel(&Module::getClockFrequency, pos, defs::DBIT_CLOCK);
|
||||||
defs::DBIT_CLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setDBITClock(int value_in_MHz, Positions pos) {
|
void Detector::setDBITClock(int value_in_MHz, Positions pos) {
|
||||||
@ -1461,7 +1439,7 @@ Result<std::vector<int>> Detector::getRxDbitList(Positions pos) const {
|
|||||||
return pimpl->Parallel(&Module::getReceiverDbitList, pos);
|
return pimpl->Parallel(&Module::getReceiverDbitList, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxDbitList(const std::vector<int>& list, Positions pos) {
|
void Detector::setRxDbitList(const std::vector<int> &list, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setReceiverDbitList, pos, list);
|
pimpl->Parallel(&Module::setReceiverDbitList, pos, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1507,22 +1485,10 @@ void Detector::savePattern(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
// rest of pattern file
|
// rest of pattern file
|
||||||
const std::vector<std::string> commands{
|
const std::vector<std::string> commands{
|
||||||
"patioctrl",
|
"patioctrl", "patclkctrl", "patlimits", "patloop0",
|
||||||
"patclkctrl",
|
"patnloop0", "patloop1", "patnloop1", "patloop2",
|
||||||
"patlimits",
|
"patnloop2", "patwait0", "patwaittime0", "patwait1",
|
||||||
"patloop0",
|
"patwaittime1", "patwait2", "patwaittime2", "patmask",
|
||||||
"patnloop0",
|
|
||||||
"patloop1",
|
|
||||||
"patnloop1",
|
|
||||||
"patloop2",
|
|
||||||
"patnloop2",
|
|
||||||
"patwait0",
|
|
||||||
"patwaittime0",
|
|
||||||
"patwait1",
|
|
||||||
"patwaittime1",
|
|
||||||
"patwait2",
|
|
||||||
"patwaittime2",
|
|
||||||
"patmask",
|
|
||||||
"patsetbit",
|
"patsetbit",
|
||||||
};
|
};
|
||||||
for (const auto &cmd : commands)
|
for (const auto &cmd : commands)
|
||||||
@ -1559,14 +1525,13 @@ void Detector::setPatternWord(int addr, uint64_t word, Positions pos) {
|
|||||||
|
|
||||||
Result<std::array<int, 2>>
|
Result<std::array<int, 2>>
|
||||||
Detector::getPatternLoopAddresses(int level, Positions pos) const {
|
Detector::getPatternLoopAddresses(int level, Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level,
|
return pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, -1,
|
||||||
-1, -1);
|
-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setPatternLoopAddresses(int level, int start, int stop,
|
void Detector::setPatternLoopAddresses(int level, int start, int stop,
|
||||||
Positions pos) {
|
Positions pos) {
|
||||||
pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, start,
|
pimpl->Parallel(&Module::setPatternLoopAddresses, pos, level, start, stop);
|
||||||
stop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getPatternLoopCycles(int level, Positions pos) const {
|
Result<int> Detector::getPatternLoopCycles(int level, Positions pos) const {
|
||||||
@ -1611,12 +1576,13 @@ void Detector::setPatternBitMask(uint64_t mask, Positions pos) {
|
|||||||
|
|
||||||
// Moench
|
// Moench
|
||||||
|
|
||||||
Result<std::map<std::string, std::string>> Detector::getAdditionalJsonHeader(Positions pos) const {
|
Result<std::map<std::string, std::string>>
|
||||||
|
Detector::getAdditionalJsonHeader(Positions pos) const {
|
||||||
return pimpl->Parallel(&Module::getAdditionalJsonHeader, pos);
|
return pimpl->Parallel(&Module::getAdditionalJsonHeader, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader,
|
void Detector::setAdditionalJsonHeader(
|
||||||
Positions pos) {
|
const std::map<std::string, std::string> &jsonHeader, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setAdditionalJsonHeader, pos, jsonHeader);
|
pimpl->Parallel(&Module::setAdditionalJsonHeader, pos, jsonHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1625,7 +1591,8 @@ Result<std::string> Detector::getAdditionalJsonParameter(const std::string &key,
|
|||||||
return pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, key);
|
return pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setAdditionalJsonParameter(const std::string &key, const std::string &value,
|
void Detector::setAdditionalJsonParameter(const std::string &key,
|
||||||
|
const std::string &value,
|
||||||
Positions pos) {
|
Positions pos) {
|
||||||
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, key, value);
|
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, key, value);
|
||||||
}
|
}
|
||||||
@ -1654,8 +1621,8 @@ void Detector::setDetectorMinMaxEnergyThreshold(const bool isEmax,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result<defs::frameModeType> Detector::getFrameMode(Positions pos) const {
|
Result<defs::frameModeType> Detector::getFrameMode(Positions pos) const {
|
||||||
auto res = pimpl->Parallel(&Module::getAdditionalJsonParameter, pos,
|
auto res =
|
||||||
"frameMode");
|
pimpl->Parallel(&Module::getAdditionalJsonParameter, pos, "frameMode");
|
||||||
Result<defs::frameModeType> intResult(res.size());
|
Result<defs::frameModeType> intResult(res.size());
|
||||||
try {
|
try {
|
||||||
for (unsigned int i = 0; i < res.size(); ++i) {
|
for (unsigned int i = 0; i < res.size(); ++i) {
|
||||||
@ -1691,8 +1658,8 @@ Result<defs::detectorModeType> Detector::getDetectorMode(Positions pos) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setDetectorMode(defs::detectorModeType value, Positions pos) {
|
void Detector::setDetectorMode(defs::detectorModeType value, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos,
|
pimpl->Parallel(&Module::setAdditionalJsonParameter, pos, "detectorMode",
|
||||||
"detectorMode", sls::ToString(value));
|
sls::ToString(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advanced
|
// Advanced
|
||||||
@ -1753,9 +1720,7 @@ void Detector::writeAdcRegister(uint32_t addr, uint32_t value, Positions pos) {
|
|||||||
pimpl->Parallel(&Module::writeAdcRegister, pos, addr, value);
|
pimpl->Parallel(&Module::writeAdcRegister, pos, addr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Detector::getInitialChecks() const {
|
bool Detector::getInitialChecks() const { return pimpl->getInitialChecks(); }
|
||||||
return pimpl->getInitialChecks();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Detector::setInitialChecks(const bool value) {
|
void Detector::setInitialChecks(const bool value) {
|
||||||
pimpl->setInitialChecks(value);
|
pimpl->setInitialChecks(value);
|
||||||
|
269
slsDetectorSoftware/src/DetectorImpl.cpp
Executable file → Normal file
269
slsDetectorSoftware/src/DetectorImpl.cpp
Executable file → Normal file
@ -1,10 +1,10 @@
|
|||||||
#include "DetectorImpl.h"
|
#include "DetectorImpl.h"
|
||||||
|
#include "Module.h"
|
||||||
#include "SharedMemory.h"
|
#include "SharedMemory.h"
|
||||||
#include "ZmqSocket.h"
|
#include "ZmqSocket.h"
|
||||||
#include "detectorData.h"
|
#include "detectorData.h"
|
||||||
#include "file_utils.h"
|
#include "file_utils.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "Module.h"
|
|
||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace sls{
|
namespace sls {
|
||||||
|
|
||||||
DetectorImpl::DetectorImpl(int multi_id, bool verify, bool update)
|
DetectorImpl::DetectorImpl(int multi_id, bool verify, bool update)
|
||||||
: multiId(multi_id), multi_shm(multi_id, -1) {
|
: multiId(multi_id), multi_shm(multi_id, -1) {
|
||||||
@ -137,11 +137,11 @@ void DetectorImpl::initSharedMemory(bool verify) {
|
|||||||
multi_shm.OpenSharedMemory();
|
multi_shm.OpenSharedMemory();
|
||||||
if (verify && multi_shm()->shmversion != MULTI_SHMVERSION) {
|
if (verify && multi_shm()->shmversion != MULTI_SHMVERSION) {
|
||||||
LOG(logERROR) << "Multi shared memory (" << multiId
|
LOG(logERROR) << "Multi shared memory (" << multiId
|
||||||
<< ") version mismatch "
|
<< ") version mismatch "
|
||||||
"(expected 0x"
|
"(expected 0x"
|
||||||
<< std::hex << MULTI_SHMVERSION << " but got 0x"
|
<< std::hex << MULTI_SHMVERSION << " but got 0x"
|
||||||
<< multi_shm()->shmversion << std::dec
|
<< multi_shm()->shmversion << std::dec
|
||||||
<< ". Clear Shared memory to continue.";
|
<< ". Clear Shared memory to continue.";
|
||||||
throw SharedMemoryError("Shared memory version mismatch!");
|
throw SharedMemoryError("Shared memory version mismatch!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,8 +167,7 @@ void DetectorImpl::initializeMembers(bool verify) {
|
|||||||
// get objects from single det shared memory (open)
|
// get objects from single det shared memory (open)
|
||||||
for (int i = 0; i < multi_shm()->numberOfDetectors; i++) {
|
for (int i = 0; i < multi_shm()->numberOfDetectors; i++) {
|
||||||
try {
|
try {
|
||||||
detectors.push_back(
|
detectors.push_back(sls::make_unique<Module>(multiId, i, verify));
|
||||||
sls::make_unique<Module>(multiId, i, verify));
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
detectors.clear();
|
detectors.clear();
|
||||||
throw;
|
throw;
|
||||||
@ -233,9 +232,8 @@ void DetectorImpl::setVirtualDetectorServers(const int numdet, const int port) {
|
|||||||
void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
void DetectorImpl::setHostname(const std::vector<std::string> &name) {
|
||||||
// this check is there only to allow the previous detsizechan command
|
// this check is there only to allow the previous detsizechan command
|
||||||
if (multi_shm()->numberOfDetectors != 0) {
|
if (multi_shm()->numberOfDetectors != 0) {
|
||||||
LOG(logWARNING)
|
LOG(logWARNING) << "There are already detector(s) in shared memory."
|
||||||
<< "There are already detector(s) in shared memory."
|
"Freeing Shared memory now.";
|
||||||
"Freeing Shared memory now.";
|
|
||||||
bool initialChecks = multi_shm()->initialChecks;
|
bool initialChecks = multi_shm()->initialChecks;
|
||||||
freeSharedMemory();
|
freeSharedMemory();
|
||||||
setupMultiDetector();
|
setupMultiDetector();
|
||||||
@ -273,8 +271,7 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
|
|||||||
// get type by connecting
|
// get type by connecting
|
||||||
detectorType type = Module::getTypeFromDetector(host, port);
|
detectorType type = Module::getTypeFromDetector(host, port);
|
||||||
auto pos = detectors.size();
|
auto pos = detectors.size();
|
||||||
detectors.emplace_back(
|
detectors.emplace_back(sls::make_unique<Module>(type, multiId, pos, false));
|
||||||
sls::make_unique<Module>(type, multiId, pos, false));
|
|
||||||
multi_shm()->numberOfDetectors = detectors.size();
|
multi_shm()->numberOfDetectors = detectors.size();
|
||||||
detectors[pos]->setControlPort(port);
|
detectors[pos]->setControlPort(port);
|
||||||
detectors[pos]->setStopPort(port + 1);
|
detectors[pos]->setStopPort(port + 1);
|
||||||
@ -309,13 +306,13 @@ void DetectorImpl::updateDetectorSize() {
|
|||||||
multi_shm()->numberOfChannels.y = det_size.y * ndety;
|
multi_shm()->numberOfChannels.y = det_size.y * ndety;
|
||||||
|
|
||||||
LOG(logDEBUG) << "\n\tNumber of Detectors in X direction:"
|
LOG(logDEBUG) << "\n\tNumber of Detectors in X direction:"
|
||||||
<< multi_shm()->numberOfDetector.x
|
<< multi_shm()->numberOfDetector.x
|
||||||
<< "\n\tNumber of Detectors in Y direction:"
|
<< "\n\tNumber of Detectors in Y direction:"
|
||||||
<< multi_shm()->numberOfDetector.y
|
<< multi_shm()->numberOfDetector.y
|
||||||
<< "\n\tNumber of Channels in X direction:"
|
<< "\n\tNumber of Channels in X direction:"
|
||||||
<< multi_shm()->numberOfChannels.x
|
<< multi_shm()->numberOfChannels.x
|
||||||
<< "\n\tNumber of Channels in Y direction:"
|
<< "\n\tNumber of Channels in Y direction:"
|
||||||
<< multi_shm()->numberOfChannels.y;
|
<< multi_shm()->numberOfChannels.y;
|
||||||
|
|
||||||
for (auto &d : detectors) {
|
for (auto &d : detectors) {
|
||||||
d->updateMultiSize(multi_shm()->numberOfDetector);
|
d->updateMultiSize(multi_shm()->numberOfDetector);
|
||||||
@ -347,20 +344,20 @@ bool DetectorImpl::getGapPixelsinCallback() const {
|
|||||||
void DetectorImpl::setGapPixelsinCallback(const bool enable) {
|
void DetectorImpl::setGapPixelsinCallback(const bool enable) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
switch (multi_shm()->multiDetectorType) {
|
switch (multi_shm()->multiDetectorType) {
|
||||||
case JUNGFRAU:
|
case JUNGFRAU:
|
||||||
|
break;
|
||||||
|
case EIGER:
|
||||||
|
if (size() && detectors[0]->getQuad()) {
|
||||||
break;
|
break;
|
||||||
case EIGER:
|
}
|
||||||
if (size() && detectors[0]->getQuad()) {
|
if (multi_shm()->numberOfDetector.y % 2 != 0) {
|
||||||
break;
|
throw RuntimeError("Gap pixels can only be used "
|
||||||
}
|
"for full modules.");
|
||||||
if (multi_shm()->numberOfDetector.y % 2 != 0) {
|
}
|
||||||
throw RuntimeError("Gap pixels can only be used "
|
break;
|
||||||
"for full modules.");
|
default:
|
||||||
}
|
throw RuntimeError("Gap Pixels is not implemented for " +
|
||||||
break;
|
multi_shm()->multiDetectorType);
|
||||||
default:
|
|
||||||
throw RuntimeError("Gap Pixels is not implemented for "
|
|
||||||
+ multi_shm()->multiDetectorType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
multi_shm()->gapPixels = enable;
|
multi_shm()->gapPixels = enable;
|
||||||
@ -386,8 +383,7 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
|
|||||||
if (multi_shm()->multiDetectorType == EIGER) {
|
if (multi_shm()->multiDetectorType == EIGER) {
|
||||||
numSocketsPerDetector = 2;
|
numSocketsPerDetector = 2;
|
||||||
}
|
}
|
||||||
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() ==
|
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() == 2) {
|
||||||
2) {
|
|
||||||
numSocketsPerDetector = 2;
|
numSocketsPerDetector = 2;
|
||||||
}
|
}
|
||||||
numSockets *= numSocketsPerDetector;
|
numSockets *= numSocketsPerDetector;
|
||||||
@ -404,10 +400,9 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
|
|||||||
.c_str(),
|
.c_str(),
|
||||||
portnum));
|
portnum));
|
||||||
LOG(logINFO) << "Zmq Client[" << iSocket << "] at "
|
LOG(logINFO) << "Zmq Client[" << iSocket << "] at "
|
||||||
<< zmqSocket.back()->GetZmqServerAddress();
|
<< zmqSocket.back()->GetZmqServerAddress();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG(logERROR)
|
LOG(logERROR) << "Could not create Zmq socket on port " << portnum;
|
||||||
<< "Could not create Zmq socket on port " << portnum;
|
|
||||||
createReceivingDataSockets(true);
|
createReceivingDataSockets(true);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -429,9 +424,8 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
int nDetPixelsY = 0;
|
int nDetPixelsY = 0;
|
||||||
bool quadEnable = false;
|
bool quadEnable = false;
|
||||||
bool eiger = false;
|
bool eiger = false;
|
||||||
bool numInterfaces =
|
bool numInterfaces = Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
.squash(); // cannot pick up from zmq
|
||||||
.squash(); // cannot pick up from zmq
|
|
||||||
|
|
||||||
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
|
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
|
||||||
int numRunning = 0;
|
int numRunning = 0;
|
||||||
@ -444,7 +438,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
// to remember the list it connected to, to disconnect later
|
// to remember the list it connected to, to disconnect later
|
||||||
connectList[i] = false;
|
connectList[i] = false;
|
||||||
LOG(logERROR) << "Could not connect to socket "
|
LOG(logERROR) << "Could not connect to socket "
|
||||||
<< zmqSocket[i]->GetZmqServerAddress();
|
<< zmqSocket[i]->GetZmqServerAddress();
|
||||||
runningList[i] = false;
|
runningList[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,8 +485,8 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
{
|
{
|
||||||
zmqHeader zHeader;
|
zmqHeader zHeader;
|
||||||
if (zmqSocket[isocket]->ReceiveHeader(
|
if (zmqSocket[isocket]->ReceiveHeader(
|
||||||
isocket, zHeader, SLS_DETECTOR_JSON_HEADER_VERSION) ==
|
isocket, zHeader,
|
||||||
0) {
|
SLS_DETECTOR_JSON_HEADER_VERSION) == 0) {
|
||||||
// parse error, version error or end of acquisition for
|
// parse error, version error or end of acquisition for
|
||||||
// socket
|
// socket
|
||||||
runningList[isocket] = false;
|
runningList[isocket] = false;
|
||||||
@ -509,7 +503,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
multiframe = new char[multisize];
|
multiframe = new char[multisize];
|
||||||
memset(multiframe, 0xFF, multisize);
|
memset(multiframe, 0xFF, multisize);
|
||||||
// dynamic range
|
// dynamic range
|
||||||
dynamicRange = zHeader.dynamicRange;
|
dynamicRange = zHeader.dynamicRange;
|
||||||
bytesPerPixel = (float)dynamicRange / 8;
|
bytesPerPixel = (float)dynamicRange / 8;
|
||||||
// shape
|
// shape
|
||||||
nPixelsX = zHeader.npixelsx;
|
nPixelsX = zHeader.npixelsx;
|
||||||
@ -522,13 +516,13 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
nDetPixelsY = nY * nPixelsY;
|
nDetPixelsY = nY * nPixelsY;
|
||||||
// det type
|
// det type
|
||||||
eiger = (zHeader.detType == static_cast<int>(3))
|
eiger = (zHeader.detType == static_cast<int>(3))
|
||||||
? true
|
? true
|
||||||
: false; // to be changed to EIGER when firmware
|
: false; // to be changed to EIGER when
|
||||||
// updates its header data
|
// firmware updates its header data
|
||||||
quadEnable = (zHeader.quad == 0) ? false : true;
|
quadEnable = (zHeader.quad == 0) ? false : true;
|
||||||
LOG(logDEBUG1)
|
LOG(logDEBUG1)
|
||||||
<< "One Time Header Info:"
|
<< "One Time Header Info:"
|
||||||
"\n\tsize: "
|
"\n\tsize: "
|
||||||
<< size << "\n\tmultisize: " << multisize
|
<< size << "\n\tmultisize: " << multisize
|
||||||
<< "\n\tdynamicRange: " << dynamicRange
|
<< "\n\tdynamicRange: " << dynamicRange
|
||||||
<< "\n\tbytesPerPixel: " << bytesPerPixel
|
<< "\n\tbytesPerPixel: " << bytesPerPixel
|
||||||
@ -553,9 +547,9 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
if (zHeader.completeImage == 0) {
|
if (zHeader.completeImage == 0) {
|
||||||
completeImage = false;
|
completeImage = false;
|
||||||
}
|
}
|
||||||
LOG(logDEBUG1)
|
LOG(logDEBUG1)
|
||||||
<< "Header Info:"
|
<< "Header Info:"
|
||||||
"\n\tcurrentFileName: "
|
"\n\tcurrentFileName: "
|
||||||
<< currentFileName << "\n\tcurrentAcquisitionIndex: "
|
<< currentFileName << "\n\tcurrentAcquisitionIndex: "
|
||||||
<< currentAcquisitionIndex
|
<< currentAcquisitionIndex
|
||||||
<< "\n\tcurrentFrameIndex: " << currentFrameIndex
|
<< "\n\tcurrentFrameIndex: " << currentFrameIndex
|
||||||
@ -579,10 +573,10 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
uint32_t rowoffset = nX * singledetrowoffset;
|
uint32_t rowoffset = nX * singledetrowoffset;
|
||||||
if (multi_shm()->multiDetectorType == CHIPTESTBOARD) {
|
if (multi_shm()->multiDetectorType == CHIPTESTBOARD) {
|
||||||
singledetrowoffset = size;
|
singledetrowoffset = size;
|
||||||
}
|
}
|
||||||
LOG(logDEBUG1)
|
LOG(logDEBUG1)
|
||||||
<< "Multi Image Info:"
|
<< "Multi Image Info:"
|
||||||
"\n\txoffset: "
|
"\n\txoffset: "
|
||||||
<< xoffset << "\n\tyoffset: " << yoffset
|
<< xoffset << "\n\tyoffset: " << yoffset
|
||||||
<< "\n\tsingledetrowoffset: " << singledetrowoffset
|
<< "\n\tsingledetrowoffset: " << singledetrowoffset
|
||||||
<< "\n\trowoffset: " << rowoffset;
|
<< "\n\trowoffset: " << rowoffset;
|
||||||
@ -608,33 +602,33 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(logDEBUG)<< "Call Back Info:"
|
LOG(logDEBUG) << "Call Back Info:"
|
||||||
<< "\n\t nDetPixelsX: " << nDetPixelsX
|
<< "\n\t nDetPixelsX: " << nDetPixelsX
|
||||||
<< "\n\t nDetPixelsY: " << nDetPixelsY
|
<< "\n\t nDetPixelsY: " << nDetPixelsY
|
||||||
<< "\n\t databytes: " << multisize
|
<< "\n\t databytes: " << multisize
|
||||||
<< "\n\t dynamicRange: " << dynamicRange;
|
<< "\n\t dynamicRange: " << dynamicRange;
|
||||||
|
|
||||||
// send data to callback
|
// send data to callback
|
||||||
if (data) {
|
if (data) {
|
||||||
char* image = multiframe;
|
char *image = multiframe;
|
||||||
int imagesize = multisize;
|
int imagesize = multisize;
|
||||||
|
|
||||||
if (gapPixels) {
|
if (gapPixels) {
|
||||||
int n = InsertGapPixels(multiframe, multigappixels,
|
int n = InsertGapPixels(multiframe, multigappixels, quadEnable,
|
||||||
quadEnable, dynamicRange, nDetPixelsX, nDetPixelsY);
|
dynamicRange, nDetPixelsX, nDetPixelsY);
|
||||||
image = multigappixels;
|
image = multigappixels;
|
||||||
imagesize = n;
|
imagesize = n;
|
||||||
}
|
}
|
||||||
LOG(logDEBUG)
|
LOG(logDEBUG) << "Image Info:"
|
||||||
<< "Image Info:"
|
<< "\n\tnDetPixelsX: " << nDetPixelsX
|
||||||
<< "\n\tnDetPixelsX: " << nDetPixelsX
|
<< "\n\tnDetPixelsY: " << nDetPixelsY
|
||||||
<< "\n\tnDetPixelsY: " << nDetPixelsY
|
<< "\n\timagesize: " << imagesize
|
||||||
<< "\n\timagesize: " << imagesize
|
<< "\n\tdynamicRange: " << dynamicRange;
|
||||||
<< "\n\tdynamicRange: " << dynamicRange;
|
|
||||||
|
|
||||||
thisData = new detectorData(currentProgress,
|
thisData =
|
||||||
currentFileName, nDetPixelsX, nDetPixelsY, image,
|
new detectorData(currentProgress, currentFileName, nDetPixelsX,
|
||||||
imagesize, dynamicRange, currentFileIndex, completeImage);
|
nDetPixelsY, image, imagesize, dynamicRange,
|
||||||
|
currentFileIndex, completeImage);
|
||||||
|
|
||||||
dataReady(
|
dataReady(
|
||||||
thisData, currentFrameIndex,
|
thisData, currentFrameIndex,
|
||||||
@ -680,14 +674,13 @@ void DetectorImpl::readFrameFromReceiver() {
|
|||||||
delete[] multigappixels;
|
delete[] multigappixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
int DetectorImpl::InsertGapPixels(char *image, char *&gpImage, bool quadEnable,
|
||||||
bool quadEnable, int dr, int &nPixelsx, int &nPixelsy) {
|
int dr, int &nPixelsx, int &nPixelsy) {
|
||||||
|
|
||||||
LOG(logDEBUG)<< "Insert Gap pixels:"
|
LOG(logDEBUG) << "Insert Gap pixels:"
|
||||||
<< "\n\t nPixelsx: " << nPixelsx
|
<< "\n\t nPixelsx: " << nPixelsx
|
||||||
<< "\n\t nPixelsy: " << nPixelsy
|
<< "\n\t nPixelsy: " << nPixelsy
|
||||||
<< "\n\t quadEnable: " << quadEnable
|
<< "\n\t quadEnable: " << quadEnable << "\n\t dr: " << dr;
|
||||||
<< "\n\t dr: " << dr;
|
|
||||||
|
|
||||||
// inter module gap pixels
|
// inter module gap pixels
|
||||||
int modGapPixelsx = 8;
|
int modGapPixelsx = 8;
|
||||||
@ -719,7 +712,7 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
// (setting gap pixels and then adding half module or disabling quad)
|
// (setting gap pixels and then adding half module or disabling quad)
|
||||||
if (nPixelsy / nMod1Pixelsy == 0) {
|
if (nPixelsy / nMod1Pixelsy == 0) {
|
||||||
LOG(logERROR) << "Gap pixels can only be enabled with full modules. "
|
LOG(logERROR) << "Gap pixels can only be enabled with full modules. "
|
||||||
"Sending dummy data without gap pixels.\n";
|
"Sending dummy data without gap pixels.\n";
|
||||||
double bytesPerPixel = (double)dr / 8.00;
|
double bytesPerPixel = (double)dr / 8.00;
|
||||||
int imagesize = nPixelsy * nPixelsx * bytesPerPixel;
|
int imagesize = nPixelsy * nPixelsx * bytesPerPixel;
|
||||||
if (gpImage == NULL) {
|
if (gpImage == NULL) {
|
||||||
@ -730,8 +723,10 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// total number of pixels
|
// total number of pixels
|
||||||
int nTotx = nPixelsx + (nMod1GapPixelsx * nModx) + (modGapPixelsx * (nModx - 1));
|
int nTotx =
|
||||||
int nToty = nPixelsy + (nMod1GapPixelsy * nMody) + (modGapPixelsy * (nMody - 1));
|
nPixelsx + (nMod1GapPixelsx * nModx) + (modGapPixelsx * (nModx - 1));
|
||||||
|
int nToty =
|
||||||
|
nPixelsy + (nMod1GapPixelsy * nMody) + (modGapPixelsy * (nMody - 1));
|
||||||
// total number of chips
|
// total number of chips
|
||||||
int nChipx = nPixelsx / nChipPixelsx;
|
int nChipx = nPixelsx / nChipPixelsx;
|
||||||
int nChipy = nPixelsy / nChipPixelsy;
|
int nChipy = nPixelsy / nChipPixelsy;
|
||||||
@ -739,13 +734,15 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
double bytesPerPixel = (double)dr / 8.00;
|
double bytesPerPixel = (double)dr / 8.00;
|
||||||
int imagesize = nTotx * nToty * bytesPerPixel;
|
int imagesize = nTotx * nToty * bytesPerPixel;
|
||||||
|
|
||||||
int nChipBytesx = nChipPixelsx * bytesPerPixel; // 1 chip bytes in x
|
int nChipBytesx = nChipPixelsx * bytesPerPixel; // 1 chip bytes in x
|
||||||
int nChipGapBytesx = chipGapPixelsx * bytesPerPixel; // 2 pixel bytes
|
int nChipGapBytesx = chipGapPixelsx * bytesPerPixel; // 2 pixel bytes
|
||||||
int nModGapBytesx = modGapPixelsx * bytesPerPixel; // 8 pixel bytes
|
int nModGapBytesx = modGapPixelsx * bytesPerPixel; // 8 pixel bytes
|
||||||
int nChipBytesy = nChipPixelsy * nTotx * bytesPerPixel; // 1 chip bytes in y
|
int nChipBytesy = nChipPixelsy * nTotx * bytesPerPixel; // 1 chip bytes in y
|
||||||
int nChipGapBytesy = chipGapPixelsy * nTotx * bytesPerPixel; // 2 lines
|
int nChipGapBytesy = chipGapPixelsy * nTotx * bytesPerPixel; // 2 lines
|
||||||
int nModGapBytesy = modGapPixelsy * nTotx * bytesPerPixel; // 36 lines
|
int nModGapBytesy = modGapPixelsy * nTotx *
|
||||||
// 4 bit mode, its 1 byte (because for 4 bit mode, we handle 1 byte at a time)
|
bytesPerPixel; // 36 lines
|
||||||
|
// 4 bit mode, its 1 byte (because for 4
|
||||||
|
// bit mode, we handle 1 byte at a time)
|
||||||
int pixel1 = (int)(ceil(bytesPerPixel));
|
int pixel1 = (int)(ceil(bytesPerPixel));
|
||||||
int row1Bytes = nTotx * bytesPerPixel;
|
int row1Bytes = nTotx * bytesPerPixel;
|
||||||
int nMod1TotPixelsx = nMod1Pixelsx + nMod1GapPixelsx;
|
int nMod1TotPixelsx = nMod1Pixelsx + nMod1GapPixelsx;
|
||||||
@ -759,38 +756,37 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
if (detType == JUNGFRAU) {
|
if (detType == JUNGFRAU) {
|
||||||
divisionValue = 1;
|
divisionValue = 1;
|
||||||
}
|
}
|
||||||
LOG(logDEBUG)
|
LOG(logDEBUG) << "Insert Gap pixels Calculations:\n\t"
|
||||||
<< "Insert Gap pixels Calculations:\n\t"
|
<< "nPixelsx: " << nPixelsx << "\n\t"
|
||||||
<< "nPixelsx: " << nPixelsx << "\n\t"
|
<< "nPixelsy: " << nPixelsy << "\n\t"
|
||||||
<< "nPixelsy: " << nPixelsy << "\n\t"
|
<< "nMod1Pixelsx: " << nMod1Pixelsx << "\n\t"
|
||||||
<< "nMod1Pixelsx: " << nMod1Pixelsx << "\n\t"
|
<< "nMod1Pixelsy: " << nMod1Pixelsy << "\n\t"
|
||||||
<< "nMod1Pixelsy: " << nMod1Pixelsy << "\n\t"
|
<< "nMod1GapPixelsx: " << nMod1GapPixelsx << "\n\t"
|
||||||
<< "nMod1GapPixelsx: " << nMod1GapPixelsx << "\n\t"
|
<< "nMod1GapPixelsy: " << nMod1GapPixelsy << "\n\t"
|
||||||
<< "nMod1GapPixelsy: " << nMod1GapPixelsy << "\n\t"
|
<< "nChipy: " << nChipy << "\n\t"
|
||||||
<< "nChipy: " << nChipy << "\n\t"
|
<< "nChipx: " << nChipx << "\n\t"
|
||||||
<< "nChipx: " << nChipx << "\n\t"
|
<< "nModx: " << nModx << "\n\t"
|
||||||
<< "nModx: " << nModx << "\n\t"
|
<< "nMody: " << nMody << "\n\t"
|
||||||
<< "nMody: " << nMody << "\n\t"
|
<< "nTotx: " << nTotx << "\n\t"
|
||||||
<< "nTotx: " << nTotx << "\n\t"
|
<< "nToty: " << nToty << "\n\t"
|
||||||
<< "nToty: " << nToty << "\n\t"
|
<< "bytesPerPixel: " << bytesPerPixel << "\n\t"
|
||||||
<< "bytesPerPixel: " << bytesPerPixel << "\n\t"
|
<< "imagesize: " << imagesize << "\n\t"
|
||||||
<< "imagesize: " << imagesize << "\n\t"
|
<< "nChipBytesx: " << nChipBytesx << "\n\t"
|
||||||
<< "nChipBytesx: " << nChipBytesx << "\n\t"
|
<< "nChipGapBytesx: " << nChipGapBytesx << "\n\t"
|
||||||
<< "nChipGapBytesx: " << nChipGapBytesx << "\n\t"
|
<< "nModGapBytesx: " << nModGapBytesx << "\n\t"
|
||||||
<< "nModGapBytesx: " << nModGapBytesx << "\n\t"
|
<< "nChipBytesy: " << nChipBytesy << "\n\t"
|
||||||
<< "nChipBytesy: " << nChipBytesy << "\n\t"
|
<< "nChipGapBytesy: " << nChipGapBytesy << "\n\t"
|
||||||
<< "nChipGapBytesy: " << nChipGapBytesy << "\n\t"
|
<< "nModGapBytesy: " << nModGapBytesy << "\n\t"
|
||||||
<< "nModGapBytesy: " << nModGapBytesy << "\n\t"
|
<< "pixel1: " << pixel1 << "\n\t"
|
||||||
<< "pixel1: " << pixel1 << "\n\t"
|
<< "row1Bytes: " << row1Bytes << "\n\t"
|
||||||
<< "row1Bytes: " << row1Bytes << "\n\t"
|
<< "nMod1TotPixelsx: " << nMod1TotPixelsx << "\n\t"
|
||||||
<< "nMod1TotPixelsx: " << nMod1TotPixelsx << "\n\t"
|
<< "divisionValue: " << divisionValue << "\n\n";
|
||||||
<< "divisionValue: " << divisionValue << "\n\n";
|
|
||||||
|
|
||||||
if (gpImage == NULL) {
|
if (gpImage == NULL) {
|
||||||
gpImage = new char[imagesize];
|
gpImage = new char[imagesize];
|
||||||
}
|
}
|
||||||
memset(gpImage, 0xFF, imagesize);
|
memset(gpImage, 0xFF, imagesize);
|
||||||
//memcpy(gpImage, image, imagesize);
|
// memcpy(gpImage, image, imagesize);
|
||||||
char *src = nullptr;
|
char *src = nullptr;
|
||||||
char *dst = nullptr;
|
char *dst = nullptr;
|
||||||
|
|
||||||
@ -872,11 +868,13 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
// neighbouring gap pixels to left
|
// neighbouring gap pixels to left
|
||||||
temp16 = (*((uint16_t *)(dst - pixel1))) / divisionValue;
|
temp16 =
|
||||||
|
(*((uint16_t *)(dst - pixel1))) / divisionValue;
|
||||||
(*((uint16_t *)dst)) = temp16;
|
(*((uint16_t *)dst)) = temp16;
|
||||||
(*((uint16_t *)(dst - pixel1))) = temp16;
|
(*((uint16_t *)(dst - pixel1))) = temp16;
|
||||||
// neighbouring gap pixels to right
|
// neighbouring gap pixels to right
|
||||||
temp16 = (*((uint16_t *)(dst + 2 * pixel1))) / divisionValue;
|
temp16 =
|
||||||
|
(*((uint16_t *)(dst + 2 * pixel1))) / divisionValue;
|
||||||
(*((uint16_t *)(dst + pixel1))) = temp16;
|
(*((uint16_t *)(dst + pixel1))) = temp16;
|
||||||
(*((uint16_t *)(dst + 2 * pixel1))) = temp16;
|
(*((uint16_t *)(dst + 2 * pixel1))) = temp16;
|
||||||
break;
|
break;
|
||||||
@ -890,7 +888,7 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
(*((uint32_t *)(dst + pixel1))) = temp32;
|
(*((uint32_t *)(dst + pixel1))) = temp32;
|
||||||
(*((uint32_t *)(dst + 2 * pixel1))) = temp32;
|
(*((uint32_t *)(dst + 2 * pixel1))) = temp32;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dst += nChipGapBytesx;
|
dst += nChipGapBytesx;
|
||||||
}
|
}
|
||||||
// skip inter module gap pixels in x
|
// skip inter module gap pixels in x
|
||||||
@ -973,8 +971,6 @@ int DetectorImpl::InsertGapPixels(char *image, char *&gpImage,
|
|||||||
return imagesize;
|
return imagesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool DetectorImpl::enableDataStreamingToClient(int enable) {
|
bool DetectorImpl::enableDataStreamingToClient(int enable) {
|
||||||
if (enable >= 0) {
|
if (enable >= 0) {
|
||||||
// destroy data threads
|
// destroy data threads
|
||||||
@ -1024,8 +1020,7 @@ int DetectorImpl::acquire() {
|
|||||||
// receiver/ext process)
|
// receiver/ext process)
|
||||||
sem_init(&sem_endRTAcquisition, 1, 0);
|
sem_init(&sem_endRTAcquisition, 1, 0);
|
||||||
|
|
||||||
bool receiver =
|
bool receiver = Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
||||||
Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
|
||||||
|
|
||||||
setJoinThreadFlag(false);
|
setJoinThreadFlag(false);
|
||||||
|
|
||||||
@ -1077,7 +1072,7 @@ int DetectorImpl::acquire() {
|
|||||||
if (acquisition_finished != nullptr) {
|
if (acquisition_finished != nullptr) {
|
||||||
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
||||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||||
int progress = (*std::min_element (a.begin(), a.end()));
|
int progress = (*std::min_element(a.begin(), a.end()));
|
||||||
acquisition_finished((double)progress, status, acqFinished_p);
|
acquisition_finished((double)progress, status, acqFinished_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,9 +1081,9 @@ int DetectorImpl::acquire() {
|
|||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
LOG(logDEBUG1) << "Elapsed time for acquisition:"
|
LOG(logDEBUG1) << "Elapsed time for acquisition:"
|
||||||
<< ((end.tv_sec - begin.tv_sec) +
|
<< ((end.tv_sec - begin.tv_sec) +
|
||||||
(end.tv_nsec - begin.tv_nsec) / 1000000000.0)
|
(end.tv_nsec - begin.tv_nsec) / 1000000000.0)
|
||||||
<< " seconds";
|
<< " seconds";
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
setAcquiringFlag(false);
|
setAcquiringFlag(false);
|
||||||
throw;
|
throw;
|
||||||
@ -1098,12 +1093,11 @@ int DetectorImpl::acquire() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DetectorImpl::printProgress(double progress) {
|
void DetectorImpl::printProgress(double progress) {
|
||||||
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
|
std::cout << std::fixed << std::setprecision(2) << std::setw(6) << progress
|
||||||
<< progress << " \%";
|
<< " \%";
|
||||||
std::cout << '\r' << std::flush;
|
std::cout << '\r' << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DetectorImpl::startProcessingThread() {
|
void DetectorImpl::startProcessingThread() {
|
||||||
dataProcessingThread = std::thread(&DetectorImpl::processData, this);
|
dataProcessingThread = std::thread(&DetectorImpl::processData, this);
|
||||||
}
|
}
|
||||||
@ -1128,7 +1122,9 @@ void DetectorImpl::processData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get and print progress
|
// get and print progress
|
||||||
double temp = (double)Parallel(&Module::getReceiverProgress, {0}).squash();
|
double temp =
|
||||||
|
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||||
|
.squash();
|
||||||
if (temp != progress) {
|
if (temp != progress) {
|
||||||
printProgress(progress);
|
printProgress(progress);
|
||||||
progress = temp;
|
progress = temp;
|
||||||
@ -1137,7 +1133,9 @@ void DetectorImpl::processData() {
|
|||||||
// exiting loop
|
// exiting loop
|
||||||
if (getJoinThreadFlag()) {
|
if (getJoinThreadFlag()) {
|
||||||
// print progress one final time before exiting
|
// print progress one final time before exiting
|
||||||
progress = (double)Parallel(&Module::getReceiverProgress, {0}).squash();
|
progress =
|
||||||
|
(double)Parallel(&Module::getReceiverProgress, {0})
|
||||||
|
.squash();
|
||||||
printProgress(progress);
|
printProgress(progress);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1297,10 +1295,9 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
"Program FPGA: Could not close destination file after converting");
|
"Program FPGA: Could not close destination file after converting");
|
||||||
}
|
}
|
||||||
unlink(destfname); // delete temporary file
|
unlink(destfname); // delete temporary file
|
||||||
LOG(logDEBUG1)
|
LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory";
|
||||||
<< "Successfully loaded the rawbin file to program memory";
|
|
||||||
LOG(logINFO) << "Read file into memory";
|
LOG(logINFO) << "Read file into memory";
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace sls
|
} // namespace sls
|
18
slsDetectorSoftware/src/DetectorImpl.h
Executable file → Normal file
18
slsDetectorSoftware/src/DetectorImpl.h
Executable file → Normal file
@ -22,7 +22,7 @@ class detectorData;
|
|||||||
#include <future>
|
#include <future>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
namespace sls{
|
namespace sls {
|
||||||
|
|
||||||
class Module;
|
class Module;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
* @param update true to update last user pid, date etc
|
* @param update true to update last user pid, date etc
|
||||||
*/
|
*/
|
||||||
explicit DetectorImpl(int multi_id = 0, bool verify = true,
|
explicit DetectorImpl(int multi_id = 0, bool verify = true,
|
||||||
bool update = true);
|
bool update = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -188,17 +188,18 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** set acquiring flag in shared memory */
|
/** set acquiring flag in shared memory */
|
||||||
void setAcquiringFlag(bool flag);
|
void setAcquiringFlag(bool flag);
|
||||||
|
|
||||||
/** return multi detector shared memory ID */
|
/** return multi detector shared memory ID */
|
||||||
int getMultiId() const;
|
int getMultiId() const;
|
||||||
|
|
||||||
/** Free specific shared memory from the command line without creating object */
|
/** Free specific shared memory from the command line without creating
|
||||||
|
* object */
|
||||||
static void freeSharedMemory(int multiId, int detPos = -1);
|
static void freeSharedMemory(int multiId, int detPos = -1);
|
||||||
|
|
||||||
/** Free all modules from current multi Id shared memory and delete members */
|
/** Free all modules from current multi Id shared memory and delete members
|
||||||
|
*/
|
||||||
void freeSharedMemory();
|
void freeSharedMemory();
|
||||||
|
|
||||||
/** Get user details of shared memory */
|
/** Get user details of shared memory */
|
||||||
@ -217,7 +218,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
void setVirtualDetectorServers(const int numdet, const int port);
|
void setVirtualDetectorServers(const int numdet, const int port);
|
||||||
|
|
||||||
/** Sets the hostname of all sls detectors in shared memory and updates local cache */
|
/** Sets the hostname of all sls detectors in shared memory and updates
|
||||||
|
* local cache */
|
||||||
void setHostname(const std::vector<std::string> &name);
|
void setHostname(const std::vector<std::string> &name);
|
||||||
|
|
||||||
/** Gets the total number of detectors */
|
/** Gets the total number of detectors */
|
||||||
@ -352,7 +354,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
* @returns total data bytes for updated image
|
* @returns total data bytes for updated image
|
||||||
*/
|
*/
|
||||||
int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr,
|
int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr,
|
||||||
int &nPixelsx, int &nPixelsy);
|
int &nPixelsx, int &nPixelsy);
|
||||||
|
|
||||||
void printProgress(double progress);
|
void printProgress(double progress);
|
||||||
|
|
||||||
@ -418,4 +420,4 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
|||||||
void *pCallbackArg{nullptr};
|
void *pCallbackArg{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace sls
|
} // namespace sls
|
698
slsDetectorSoftware/src/Module.cpp
Executable file → Normal file
698
slsDetectorSoftware/src/Module.cpp
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
81
slsDetectorSoftware/src/Module.h
Executable file → Normal file
81
slsDetectorSoftware/src/Module.h
Executable file → Normal file
@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class ServerInterface;
|
class ServerInterface;
|
||||||
|
|
||||||
#define SLS_SHMAPIVERSION 0x190726
|
#define SLS_SHMAPIVERSION 0x190726
|
||||||
#define SLS_SHMVERSION 0x200402
|
#define SLS_SHMVERSION 0x200402
|
||||||
|
|
||||||
namespace sls{
|
namespace sls {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short structure allocated in shared memory to store detector settings for
|
* @short structure allocated in shared memory to store detector settings for
|
||||||
@ -96,7 +96,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* one
|
* one
|
||||||
*/
|
*/
|
||||||
explicit Module(detectorType type, int multi_id = 0, int det_id = 0,
|
explicit Module(detectorType type, int multi_id = 0, int det_id = 0,
|
||||||
bool verify = true);
|
bool verify = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor called when opening existing shared memory
|
* Constructor called when opening existing shared memory
|
||||||
@ -182,7 +182,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
void updateNumberOfChannels();
|
void updateNumberOfChannels();
|
||||||
|
|
||||||
|
|
||||||
slsDetectorDefs::xy getNumberOfChannels() const;
|
slsDetectorDefs::xy getNumberOfChannels() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -272,11 +271,12 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
|
|
||||||
detectorSettings getSettings();
|
detectorSettings getSettings();
|
||||||
|
|
||||||
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2
|
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2,
|
||||||
* [Gotthard] Options: DYNAMICGAIN, HIGHGAIN, LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN
|
* FORCESWITCHG1, FORCESWITCHG2 [Gotthard] Options: DYNAMICGAIN, HIGHGAIN,
|
||||||
* [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2
|
* LOWGAIN, MEDIUMGAIN, VERYHIGHGAIN [Gotthard2] Options: DYNAMICGAIN,
|
||||||
* [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN,
|
* FIXGAIN1, FIXGAIN2 [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN,
|
||||||
* G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
|
* G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, G2_LOWCAP_HIGHGAIN,
|
||||||
|
* G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
|
||||||
*/
|
*/
|
||||||
void setSettings(detectorSettings isettings);
|
void setSettings(detectorSettings isettings);
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* @param tb 1 to include trimbits, 0 to exclude
|
* @param tb 1 to include trimbits, 0 to exclude
|
||||||
*/
|
*/
|
||||||
void setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS,
|
void setThresholdEnergy(int e_eV, detectorSettings isettings = GET_SETTINGS,
|
||||||
int tb = 1);
|
int tb = 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set threshold energy and settings (Eiger only)
|
* Set threshold energy and settings (Eiger only)
|
||||||
@ -499,7 +499,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* [Gotthard2] only in continuous mode */
|
* [Gotthard2] only in continuous mode */
|
||||||
int64_t getMeasurementTime() const;
|
int64_t getMeasurementTime() const;
|
||||||
|
|
||||||
|
|
||||||
timingMode getTimingMode();
|
timingMode getTimingMode();
|
||||||
void setTimingMode(timingMode value);
|
void setTimingMode(timingMode value);
|
||||||
|
|
||||||
@ -524,7 +523,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex);
|
int getOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex);
|
||||||
|
|
||||||
/* [Gotthard2] */
|
/* [Gotthard2] */
|
||||||
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex, int value);
|
void setOnChipDAC(slsDetectorDefs::dacIndex index, int chipIndex,
|
||||||
|
int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get adc value
|
* Get adc value
|
||||||
@ -581,7 +581,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [Ctb]
|
* [Ctb]
|
||||||
* @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL
|
* @param mode readout mode Options: ANALOG_ONLY, DIGITAL_ONLY,
|
||||||
|
* ANALOG_AND_DIGITAL
|
||||||
*/
|
*/
|
||||||
void setReadoutMode(const readoutMode mode);
|
void setReadoutMode(const readoutMode mode);
|
||||||
|
|
||||||
@ -634,7 +635,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
uint32_t clearBit(uint32_t addr, int n);
|
uint32_t clearBit(uint32_t addr, int n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates and sets the receiver.
|
* Validates and sets the receiver.
|
||||||
* Also updates the receiver with all the shared memory parameters
|
* Also updates the receiver with all the shared memory parameters
|
||||||
* significant for the receiver Also configures the detector to the receiver
|
* significant for the receiver Also configures the detector to the receiver
|
||||||
@ -650,7 +651,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
std::string getReceiverHostname() const;
|
std::string getReceiverHostname() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the format of the detector MAC address and sets it
|
* Validates the format of the detector MAC address and sets it
|
||||||
* @param mac detector MAC address
|
* @param mac detector MAC address
|
||||||
*/
|
*/
|
||||||
@ -702,14 +703,16 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the format of the receiver UDP IP address and sets it
|
* Validates the format of the receiver UDP IP address and sets it
|
||||||
* If slsReceiver used, Gets receiver udp mac address and sends it to the detector
|
* If slsReceiver used, Gets receiver udp mac address and sends it to the
|
||||||
|
* detector
|
||||||
* @param ip receiver UDP IP address
|
* @param ip receiver UDP IP address
|
||||||
*/
|
*/
|
||||||
void setDestinationUDPIP(const sls::IpAddr ip);
|
void setDestinationUDPIP(const sls::IpAddr ip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the receiver UDP IP address
|
* Returns the receiver UDP IP address
|
||||||
* If slsReceiver used, Gets receiver udp mac address and sends it to the detector
|
* If slsReceiver used, Gets receiver udp mac address and sends it to the
|
||||||
|
* detector
|
||||||
* @returns the receiver UDP IP address
|
* @returns the receiver UDP IP address
|
||||||
*/
|
*/
|
||||||
sls::IpAddr getDestinationUDPIP();
|
sls::IpAddr getDestinationUDPIP();
|
||||||
@ -717,14 +720,16 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
/**
|
/**
|
||||||
* Validates the format of the receiver UDP IP address (bottom half) and
|
* Validates the format of the receiver UDP IP address (bottom half) and
|
||||||
* sets it(Jungfrau only)
|
* sets it(Jungfrau only)
|
||||||
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the detector
|
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the
|
||||||
|
* detector
|
||||||
* @param ip receiver UDP IP address (bottom half)
|
* @param ip receiver UDP IP address (bottom half)
|
||||||
*/
|
*/
|
||||||
void setDestinationUDPIP2(const sls::IpAddr ip);
|
void setDestinationUDPIP2(const sls::IpAddr ip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the receiver UDP IP address (bottom half) Jungfrau only
|
* Returns the receiver UDP IP address (bottom half) Jungfrau only
|
||||||
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the detector
|
* If slsReceiver used, Gets receiver udp mac address2 and sends it to the
|
||||||
|
* detector
|
||||||
* @returns the receiver UDP IP address (bottom half)
|
* @returns the receiver UDP IP address (bottom half)
|
||||||
*/
|
*/
|
||||||
sls::IpAddr getDestinationUDPIP2();
|
sls::IpAddr getDestinationUDPIP2();
|
||||||
@ -904,13 +909,15 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setTransmissionDelayRight(int value);
|
void setTransmissionDelayRight(int value);
|
||||||
|
|
||||||
/** empty vector deletes entire additional json header */
|
/** empty vector deletes entire additional json header */
|
||||||
void setAdditionalJsonHeader(const std::map<std::string, std::string> &jsonHeader);
|
void setAdditionalJsonHeader(
|
||||||
|
const std::map<std::string, std::string> &jsonHeader);
|
||||||
std::map<std::string, std::string> getAdditionalJsonHeader();
|
std::map<std::string, std::string> getAdditionalJsonHeader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value for the additional json header parameter key if found, else
|
* Sets the value for the additional json header parameter key if found,
|
||||||
* append it. If value empty, then deletes parameter */
|
* else append it. If value empty, then deletes parameter */
|
||||||
void setAdditionalJsonParameter(const std::string &key, const std::string &value);
|
void setAdditionalJsonParameter(const std::string &key,
|
||||||
|
const std::string &value);
|
||||||
std::string getAdditionalJsonParameter(const std::string &key);
|
std::string getAdditionalJsonParameter(const std::string &key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -947,7 +954,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* Only for virtual servers */
|
* Only for virtual servers */
|
||||||
void setImageTestMode(const int value);
|
void setImageTestMode(const int value);
|
||||||
|
|
||||||
|
|
||||||
/** [Gotthard2] */
|
/** [Gotthard2] */
|
||||||
std::array<int, 2> getInjectChannel();
|
std::array<int, 2> getInjectChannel();
|
||||||
|
|
||||||
@ -960,7 +966,8 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
std::vector<int> getVetoPhoton(const int chipIndex);
|
std::vector<int> getVetoPhoton(const int chipIndex);
|
||||||
|
|
||||||
/** [Gotthard2] energy in keV */
|
/** [Gotthard2] energy in keV */
|
||||||
void setVetoPhoton(const int chipIndex, const int numPhotons, const int energy, const std::string& fname);
|
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||||
|
const int energy, const std::string &fname);
|
||||||
|
|
||||||
void setVetoReference(const int gainIndex, const int value);
|
void setVetoReference(const int gainIndex, const int value);
|
||||||
|
|
||||||
@ -1021,7 +1028,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
uint32_t getADCEnableMask();
|
uint32_t getADCEnableMask();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set 10Gb ADC Enable Mask (CTB, Moench)
|
* Set 10Gb ADC Enable Mask (CTB, Moench)
|
||||||
* @param mask ADC Enable mask
|
* @param mask ADC Enable mask
|
||||||
*/
|
*/
|
||||||
@ -1078,7 +1085,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
int getExternalSampling();
|
int getExternalSampling();
|
||||||
|
|
||||||
/** digital data bits enable (CTB only) */
|
/** digital data bits enable (CTB only) */
|
||||||
void setReceiverDbitList(const std::vector<int>& list);
|
void setReceiverDbitList(const std::vector<int> &list);
|
||||||
std::vector<int> getReceiverDbitList() const;
|
std::vector<int> getReceiverDbitList() const;
|
||||||
|
|
||||||
/** Set digital data offset in bytes (CTB only) */
|
/** Set digital data offset in bytes (CTB only) */
|
||||||
@ -1134,7 +1141,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* @param vector os trimmed energies
|
* @param vector os trimmed energies
|
||||||
* @returns number of trim energies
|
* @returns number of trim energies
|
||||||
*/
|
*/
|
||||||
int setTrimEn(const std::vector<int>& energies = {});
|
int setTrimEn(const std::vector<int> &energies = {});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a vector with the trimmed energies (Eiger)
|
* Returns a vector with the trimmed energies (Eiger)
|
||||||
@ -1330,7 +1337,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
int64_t getFileIndex();
|
int64_t getFileIndex();
|
||||||
void setFileIndex(int64_t file_index);
|
void setFileIndex(int64_t file_index);
|
||||||
void incrementFileIndex();
|
void incrementFileIndex();
|
||||||
fileFormat getFileFormat() ;
|
fileFormat getFileFormat();
|
||||||
void setFileFormat(fileFormat f);
|
void setFileFormat(fileFormat f);
|
||||||
int getFramesPerFile();
|
int getFramesPerFile();
|
||||||
/** 0 will set frames per file to unlimited */
|
/** 0 will set frames per file to unlimited */
|
||||||
@ -1340,7 +1347,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
bool getPartialFramesPadding();
|
bool getPartialFramesPadding();
|
||||||
void setPartialFramesPadding(bool padding);
|
void setPartialFramesPadding(bool padding);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receiver starts listening to packets
|
* Receiver starts listening to packets
|
||||||
*/
|
*/
|
||||||
@ -1373,7 +1379,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
uint64_t getReceiverCurrentFrameIndex() const;
|
uint64_t getReceiverCurrentFrameIndex() const;
|
||||||
int getReceiverProgress() const;
|
int getReceiverProgress() const;
|
||||||
|
|
||||||
|
|
||||||
void setFileWrite(bool value);
|
void setFileWrite(bool value);
|
||||||
bool getFileWrite();
|
bool getFileWrite();
|
||||||
void setMasterFileWrite(bool value);
|
void setMasterFileWrite(bool value);
|
||||||
@ -1468,7 +1473,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* @returns array of start addr and stop addr
|
* @returns array of start addr and stop addr
|
||||||
*/
|
*/
|
||||||
std::array<int, 2> setPatternLoopAddresses(int level = -1, int start = -1,
|
std::array<int, 2> setPatternLoopAddresses(int level = -1, int start = -1,
|
||||||
int stop = -1);
|
int stop = -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the pattern or loop limits (CTB/ Moench/ Mythen3)
|
* Sets the pattern or loop limits (CTB/ Moench/ Mythen3)
|
||||||
@ -1478,7 +1483,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int setPatternLoopCycles(int level = -1, int n = -1);
|
int setPatternLoopCycles(int level = -1, int n = -1);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the wait address (CTB/ Moench/ Mythen3)
|
* Sets the wait address (CTB/ Moench/ Mythen3)
|
||||||
* @param level 0,1,2, wait level
|
* @param level 0,1,2, wait level
|
||||||
@ -1588,8 +1592,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
|
void sendToDetector(int fnum, std::nullptr_t, Ret &retval);
|
||||||
void sendToDetector(int fnum);
|
void sendToDetector(int fnum);
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret> Ret sendToDetector(int fnum);
|
||||||
Ret sendToDetector(int fnum);
|
|
||||||
|
|
||||||
template <typename Ret, typename Arg>
|
template <typename Ret, typename Arg>
|
||||||
Ret sendToDetector(int fnum, const Arg &args);
|
Ret sendToDetector(int fnum, const Arg &args);
|
||||||
@ -1662,11 +1665,9 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
|
void sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const;
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret> Ret sendToReceiver(int fnum);
|
||||||
Ret sendToReceiver(int fnum);
|
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret> Ret sendToReceiver(int fnum) const;
|
||||||
Ret sendToReceiver(int fnum) const;
|
|
||||||
|
|
||||||
template <typename Ret, typename Arg>
|
template <typename Ret, typename Arg>
|
||||||
Ret sendToReceiver(int fnum, const Arg &args);
|
Ret sendToReceiver(int fnum, const Arg &args);
|
||||||
@ -1779,4 +1780,4 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
|
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
|
||||||
};
|
};
|
||||||
|
|
||||||
}// sls
|
} // namespace sls
|
108
slsDetectorSoftware/src/SharedMemory.h
Executable file → Normal file
108
slsDetectorSoftware/src/SharedMemory.h
Executable file → Normal file
@ -31,16 +31,15 @@
|
|||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> class SharedMemory {
|
||||||
class SharedMemory {
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* creates the single/multi detector shared memory name
|
* creates the single/multi detector shared memory name
|
||||||
* @param multiId multi detector id
|
* @param multiId multi detector id
|
||||||
* @param slsId sls detector id, -1 if a multi detector shared memory
|
* @param slsId sls detector id, -1 if a multi detector shared memory
|
||||||
*/
|
*/
|
||||||
SharedMemory(int multiId, int slsId) {
|
SharedMemory(int multiId, int slsId) {
|
||||||
name = ConstructSharedMemoryName(multiId, slsId);
|
name = ConstructSharedMemoryName(multiId, slsId);
|
||||||
}
|
}
|
||||||
@ -52,18 +51,17 @@ class SharedMemory {
|
|||||||
SharedMemory(const SharedMemory &) = delete;
|
SharedMemory(const SharedMemory &) = delete;
|
||||||
SharedMemory &operator=(const SharedMemory &other) = delete;
|
SharedMemory &operator=(const SharedMemory &other) = delete;
|
||||||
|
|
||||||
//Move constructor
|
// Move constructor
|
||||||
SharedMemory(SharedMemory &&other) : name(other.name),
|
SharedMemory(SharedMemory &&other)
|
||||||
fd(other.fd),
|
: name(other.name), fd(other.fd), shmSize(other.shmSize),
|
||||||
shmSize(other.shmSize),
|
shared_struct(other.shared_struct) {
|
||||||
shared_struct(other.shared_struct) {
|
|
||||||
|
|
||||||
other.fd = -1;
|
other.fd = -1;
|
||||||
other.shared_struct = nullptr;
|
other.shared_struct = nullptr;
|
||||||
other.shmSize = 0;
|
other.shmSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Move assignment
|
// Move assignment
|
||||||
SharedMemory &operator=(SharedMemory &&other) {
|
SharedMemory &operator=(SharedMemory &&other) {
|
||||||
name = other.name;
|
name = other.name;
|
||||||
if (fd) {
|
if (fd) {
|
||||||
@ -108,31 +106,31 @@ class SharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get shared memory name
|
* Get shared memory name
|
||||||
*/
|
*/
|
||||||
std::string GetName() const {
|
std::string GetName() const { return name; }
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const {
|
size_t size() const { return shmSize; }
|
||||||
return shmSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Shared memory and call MapSharedMemory to map it to an address
|
* Create Shared memory and call MapSharedMemory to map it to an address
|
||||||
* throws a SharedMemoryError exception on failure to create, ftruncate or map
|
* throws a SharedMemoryError exception on failure to create, ftruncate or
|
||||||
|
* map
|
||||||
* @param sz of shared memory
|
* @param sz of shared memory
|
||||||
*/
|
*/
|
||||||
void CreateSharedMemory() {
|
void CreateSharedMemory() {
|
||||||
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR,
|
||||||
|
S_IRUSR | S_IWUSR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
std::string msg = "Create shared memory " + name + " failed: " + strerror(errno);
|
std::string msg =
|
||||||
|
"Create shared memory " + name + " failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ftruncate(fd, sizeof(T)) < 0) {
|
if (ftruncate(fd, sizeof(T)) < 0) {
|
||||||
std::string msg = "Create shared memory " + name + " failed at ftruncate: " + strerror(errno);
|
std::string msg = "Create shared memory " + name +
|
||||||
|
" failed at ftruncate: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
close(fd);
|
close(fd);
|
||||||
RemoveSharedMemory();
|
RemoveSharedMemory();
|
||||||
@ -144,14 +142,15 @@ class SharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open existing Shared memory and call MapSharedMemory to map it to an address
|
* Open existing Shared memory and call MapSharedMemory to map it to an
|
||||||
* throws a SharedMemoryError exception on failure to open or map
|
* address throws a SharedMemoryError exception on failure to open or map
|
||||||
* @param sz of shared memory
|
* @param sz of shared memory
|
||||||
*/
|
*/
|
||||||
void OpenSharedMemory() {
|
void OpenSharedMemory() {
|
||||||
fd = shm_open(name.c_str(), O_RDWR, 0);
|
fd = shm_open(name.c_str(), O_RDWR, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
std::string msg = "Open existing shared memory " + name + " failed: " + strerror(errno);
|
std::string msg = "Open existing shared memory " + name +
|
||||||
|
" failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@ -166,7 +165,8 @@ class SharedMemory {
|
|||||||
void UnmapSharedMemory() {
|
void UnmapSharedMemory() {
|
||||||
if (shared_struct != nullptr) {
|
if (shared_struct != nullptr) {
|
||||||
if (munmap(shared_struct, shmSize) < 0) {
|
if (munmap(shared_struct, shmSize) < 0) {
|
||||||
std::string msg = "Unmapping shared memory " + name + " failed: " + strerror(errno);
|
std::string msg = "Unmapping shared memory " + name +
|
||||||
|
" failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
close(fd);
|
close(fd);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
@ -176,15 +176,16 @@ class SharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove existing Shared memory
|
* Remove existing Shared memory
|
||||||
*/
|
*/
|
||||||
void RemoveSharedMemory() {
|
void RemoveSharedMemory() {
|
||||||
UnmapSharedMemory();
|
UnmapSharedMemory();
|
||||||
if (shm_unlink(name.c_str()) < 0) {
|
if (shm_unlink(name.c_str()) < 0) {
|
||||||
// silent exit if shm did not exist anyway
|
// silent exit if shm did not exist anyway
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return;
|
return;
|
||||||
std::string msg = "Free Shared Memory " + name + " Failed: " + strerror(errno);
|
std::string msg =
|
||||||
|
"Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@ -197,18 +198,14 @@ class SharedMemory {
|
|||||||
static const int NAME_MAX_LENGTH = 255;
|
static const int NAME_MAX_LENGTH = 255;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Using the call operator to access the pointer
|
*Using the call operator to access the pointer
|
||||||
*/
|
*/
|
||||||
T *operator()() {
|
T *operator()() { return shared_struct; }
|
||||||
return shared_struct;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Using the call operator to access the pointer, const overload
|
*Using the call operator to access the pointer, const overload
|
||||||
*/
|
*/
|
||||||
const T *operator()() const {
|
const T *operator()() const { return shared_struct; }
|
||||||
return shared_struct;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
@ -232,11 +229,16 @@ class SharedMemory {
|
|||||||
if (slsId < 0)
|
if (slsId < 0)
|
||||||
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
|
ss << SHM_MULTI_PREFIX << multiId << sEnvPath;
|
||||||
else
|
else
|
||||||
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId << sEnvPath;
|
ss << SHM_MULTI_PREFIX << multiId << SHM_SLS_PREFIX << slsId
|
||||||
|
<< sEnvPath;
|
||||||
|
|
||||||
std::string temp = ss.str();
|
std::string temp = ss.str();
|
||||||
if (temp.length() > NAME_MAX_LENGTH) {
|
if (temp.length() > NAME_MAX_LENGTH) {
|
||||||
std::string msg = "Shared memory initialization failed. " + temp + " has " + std::to_string(temp.length()) + " characters. \n" + "Maximum is " + std::to_string(NAME_MAX_LENGTH) + ". Change the environment variable " + SHM_ENV_NAME;
|
std::string msg =
|
||||||
|
"Shared memory initialization failed. " + temp + " has " +
|
||||||
|
std::to_string(temp.length()) + " characters. \n" +
|
||||||
|
"Maximum is " + std::to_string(NAME_MAX_LENGTH) +
|
||||||
|
". Change the environment variable " + SHM_ENV_NAME;
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
@ -250,9 +252,11 @@ class SharedMemory {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
T *MapSharedMemory() {
|
T *MapSharedMemory() {
|
||||||
void *addr = mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
void *addr =
|
||||||
|
mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
if (addr == MAP_FAILED) {
|
if (addr == MAP_FAILED) {
|
||||||
std::string msg = "Mapping shared memory " + name + " failed: " + strerror(errno);
|
std::string msg =
|
||||||
|
"Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
close(fd);
|
close(fd);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
@ -264,23 +268,29 @@ class SharedMemory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify if existing shared memory size matches expected size
|
* Verify if existing shared memory size matches expected size
|
||||||
* @param expectedSize expected size of shared memory, replaced with smaller size if size does not match
|
* @param expectedSize expected size of shared memory, replaced with smaller
|
||||||
|
* size if size does not match
|
||||||
* @return 0 for success, 1 for fail
|
* @return 0 for success, 1 for fail
|
||||||
*/
|
*/
|
||||||
int VerifySizeMatch(size_t expectedSize) {
|
int VerifySizeMatch(size_t expectedSize) {
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
// could not fstat
|
// could not fstat
|
||||||
if (fstat(fd, &sb) < 0) {
|
if (fstat(fd, &sb) < 0) {
|
||||||
std::string msg = "Could not verify existing shared memory " + name + " size match " + "(could not fstat): " + strerror(errno);
|
std::string msg = "Could not verify existing shared memory " +
|
||||||
|
name + " size match " +
|
||||||
|
"(could not fstat): " + strerror(errno);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
close(fd);
|
close(fd);
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//size does not match
|
// size does not match
|
||||||
auto sz = static_cast<size_t>(sb.st_size);
|
auto sz = static_cast<size_t>(sb.st_size);
|
||||||
if (sz != expectedSize) {
|
if (sz != expectedSize) {
|
||||||
std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz);
|
std::string msg = "Existing shared memory " + name +
|
||||||
|
" size does not match" + "Expected " +
|
||||||
|
std::to_string(expectedSize) + ", found " +
|
||||||
|
std::to_string(sz);
|
||||||
LOG(logERROR) << msg;
|
LOG(logERROR) << msg;
|
||||||
throw SharedMemoryError(msg);
|
throw SharedMemoryError(msg);
|
||||||
return 1;
|
return 1;
|
||||||
|
103
slsDetectorSoftware/src/slsDetectorUsers.cpp
Executable file → Normal file
103
slsDetectorSoftware/src/slsDetectorUsers.cpp
Executable file → Normal file
@ -1,18 +1,18 @@
|
|||||||
#include "slsDetectorUsers.h"
|
#include "slsDetectorUsers.h"
|
||||||
//#include "detectorData.h"
|
//#include "detectorData.h"
|
||||||
//#include "multiSlsDetectorClient.h" TODO: do we need this put and get in users api
|
//#include "multiSlsDetectorClient.h" TODO: do we need this put and get in users
|
||||||
|
// api
|
||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
|
|
||||||
slsDetectorUsers::slsDetectorUsers(int shm_id) : detector(sls::make_unique<sls::Detector>(shm_id)){}
|
slsDetectorUsers::slsDetectorUsers(int shm_id)
|
||||||
|
: detector(sls::make_unique<sls::Detector>(shm_id)) {}
|
||||||
slsDetectorUsers::~slsDetectorUsers() = default;
|
slsDetectorUsers::~slsDetectorUsers() = default;
|
||||||
|
|
||||||
void slsDetectorUsers::readConfigurationFile(const std::string& fname){
|
void slsDetectorUsers::readConfigurationFile(const std::string &fname) {
|
||||||
detector->loadConfig(fname);
|
detector->loadConfig(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetectorUsers::size() const {
|
int slsDetectorUsers::size() const { return detector->size(); }
|
||||||
return detector->size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// int slsDetectorUsers::getDetectorSize(int &nx, int &ny, int detPos){
|
// int slsDetectorUsers::getDetectorSize(int &nx, int &ny, int detPos){
|
||||||
// slsDetectorDefs::xy res = detector.getNumberOfChannels();
|
// slsDetectorDefs::xy res = detector.getNumberOfChannels();
|
||||||
@ -38,7 +38,8 @@ int slsDetectorUsers::size() const {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// int64_t slsDetectorUsers::getDetectorFirmwareVersion(int detPos){
|
// int64_t slsDetectorUsers::getDetectorFirmwareVersion(int detPos){
|
||||||
// return detector.getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION, detPos);
|
// return detector.getId(slsDetectorDefs::DETECTOR_FIRMWARE_VERSION,
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int64_t slsDetectorUsers::getDetectorSerialNumber(int detPos){
|
// int64_t slsDetectorUsers::getDetectorSerialNumber(int detPos){
|
||||||
@ -46,7 +47,8 @@ int slsDetectorUsers::size() const {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// int64_t slsDetectorUsers::getDetectorSoftwareVersion(int detPos){
|
// int64_t slsDetectorUsers::getDetectorSoftwareVersion(int detPos){
|
||||||
// return detector.getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION, detPos);
|
// return detector.getId(slsDetectorDefs::DETECTOR_SOFTWARE_VERSION,
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int64_t slsDetectorUsers::getClientSoftwareVersion(){
|
// int64_t slsDetectorUsers::getClientSoftwareVersion(){
|
||||||
@ -103,37 +105,40 @@ int slsDetectorUsers::size() const {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setSettings(int isettings, int detPos){
|
// int slsDetectorUsers::setSettings(int isettings, int detPos){
|
||||||
// return detector.setSettings((slsDetectorDefs::detectorSettings)isettings, detPos);
|
// return
|
||||||
|
// detector.setSettings((slsDetectorDefs::detectorSettings)isettings, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::getThresholdEnergy(int detPos){
|
// int slsDetectorUsers::getThresholdEnergy(int detPos){
|
||||||
// return detector.getThresholdEnergy(detPos);
|
// return detector.getThresholdEnergy(detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int detPos) {
|
// int slsDetectorUsers::setThresholdEnergy(int e_ev, int tb, int isettings, int
|
||||||
// return detector.setThresholdEnergy(e_ev,
|
// detPos) { return detector.setThresholdEnergy(e_ev,
|
||||||
// (isettings == -1) ? slsDetectorDefs::GET_SETTINGS : (slsDetectorDefs::detectorSettings)isettings,
|
// (isettings == -1) ? slsDetectorDefs::GET_SETTINGS :
|
||||||
// tb, detPos);
|
// (slsDetectorDefs::detectorSettings)isettings, tb, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// double slsDetectorUsers::setExposureTime(double t, bool inseconds, int detPos){
|
// double slsDetectorUsers::setExposureTime(double t, bool inseconds, int
|
||||||
// return detector.setExposureTime(t, inseconds, detPos);
|
// detPos){ return detector.setExposureTime(t, inseconds, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int detPos){
|
// double slsDetectorUsers::setExposurePeriod(double t, bool inseconds, int
|
||||||
// return detector.setExposurePeriod(t, inseconds, detPos);
|
// detPos){ return detector.setExposurePeriod(t, inseconds, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int detPos){
|
// double slsDetectorUsers::setDelayAfterTrigger(double t, bool inseconds, int
|
||||||
// return detector.setDelayAfterTrigger(t, inseconds, detPos);
|
// detPos){ return detector.setDelayAfterTrigger(t, inseconds, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds, int detPos){
|
// double slsDetectorUsers::setSubFrameExposureTime(double t, bool inseconds,
|
||||||
// return detector.setSubFrameExposureTime(t, inseconds, detPos);
|
// int detPos){ return detector.setSubFrameExposureTime(t, inseconds,
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool inseconds, int detPos){
|
// double slsDetectorUsers::setSubFrameExposureDeadTime(double t, bool
|
||||||
// return detector.setSubFrameExposureDeadTime(t, inseconds, detPos);
|
// inseconds, int detPos){ return detector.setSubFrameExposureDeadTime(t,
|
||||||
|
// inseconds, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int detPos){
|
// int64_t slsDetectorUsers::setNumberOfFrames(int64_t t, int detPos){
|
||||||
@ -152,8 +157,8 @@ int slsDetectorUsers::size() const {
|
|||||||
// return detector.getMeasuredPeriod(inseconds, detPos);
|
// return detector.getMeasuredPeriod(inseconds, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int detPos) {
|
// double slsDetectorUsers::getMeasuredSubFramePeriod(bool inseconds, int
|
||||||
// return detector.getMeasuredSubFramePeriod(inseconds, detPos);
|
// detPos) { return detector.getMeasuredSubFramePeriod(inseconds, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setTimingMode(int pol, int detPos){
|
// int slsDetectorUsers::setTimingMode(int pol, int detPos){
|
||||||
@ -187,7 +192,8 @@ int slsDetectorUsers::size() const {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setDAC(int val, int index , int detPos) {
|
// int slsDetectorUsers::setDAC(int val, int index , int detPos) {
|
||||||
// return detector.setDAC(val, slsDetectorDefs::dacIndex(index), 0, detPos);
|
// return detector.setDAC(val, slsDetectorDefs::dacIndex(index), 0,
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::getADC(int index, int detPos) {
|
// int slsDetectorUsers::getADC(int index, int detPos) {
|
||||||
@ -224,7 +230,6 @@ int slsDetectorUsers::size() const {
|
|||||||
|
|
||||||
// *********************************************************************/
|
// *********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
// void slsDetectorUsers::startReceiver(int detPos) {
|
// void slsDetectorUsers::startReceiver(int detPos) {
|
||||||
// detector.startReceiver(detPos);
|
// detector.startReceiver(detPos);
|
||||||
// }
|
// }
|
||||||
@ -314,16 +319,16 @@ int slsDetectorUsers::size() const {
|
|||||||
// return detector.getClientStreamingPort(detPos);
|
// return detector.getClientStreamingPort(detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// std::string slsDetectorUsers::setReceiverDataStreamingOutIP(const std::string& ip, int detPos){
|
// std::string slsDetectorUsers::setReceiverDataStreamingOutIP(const
|
||||||
// if (ip.length()) {
|
// std::string& ip, int detPos){ if (ip.length()) {
|
||||||
// detector.setReceiverDataStreamingOutIP(ip, detPos);
|
// detector.setReceiverDataStreamingOutIP(ip, detPos);
|
||||||
// }
|
// }
|
||||||
// return detector.getReceiverStreamingIP(detPos);
|
// return detector.getReceiverStreamingIP(detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// std::string slsDetectorUsers::setClientDataStreamingInIP(const std::string& ip, int detPos){
|
// std::string slsDetectorUsers::setClientDataStreamingInIP(const std::string&
|
||||||
// if (ip.length()) {
|
// ip, int detPos){ if (ip.length()) {
|
||||||
// detector.setClientDataStreamingInIP(ip, detPos);
|
// detector.setClientDataStreamingInIP(ip, detPos);
|
||||||
// }
|
// }
|
||||||
// return detector.getClientStreamingIP(detPos);
|
// return detector.getClientStreamingIP(detPos);
|
||||||
// }
|
// }
|
||||||
@ -333,7 +338,9 @@ int slsDetectorUsers::size() const {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setReceiverFramesDiscardPolicy(int f, int detPos) {
|
// int slsDetectorUsers::setReceiverFramesDiscardPolicy(int f, int detPos) {
|
||||||
// return detector.setReceiverFramesDiscardPolicy(slsDetectorDefs::frameDiscardPolicy(f), detPos);
|
// return
|
||||||
|
// detector.setReceiverFramesDiscardPolicy(slsDetectorDefs::frameDiscardPolicy(f),
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setReceiverPartialFramesPadding(int f, int detPos) {
|
// int slsDetectorUsers::setReceiverPartialFramesPadding(int f, int detPos) {
|
||||||
@ -352,45 +359,37 @@ int slsDetectorUsers::size() const {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setDetectorMinMaxEnergyThreshold(const int index, int v, int detPos) {
|
// int slsDetectorUsers::setDetectorMinMaxEnergyThreshold(const int index, int
|
||||||
|
// v, int detPos) {
|
||||||
// return detector.setDetectorMinMaxEnergyThreshold(index, v, detPos);
|
// return detector.setDetectorMinMaxEnergyThreshold(index, v, detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setFrameMode(int value, int detPos) {
|
// int slsDetectorUsers::setFrameMode(int value, int detPos) {
|
||||||
// return detector.setFrameMode(slsDetectorDefs::frameModeType(value), detPos);
|
// return detector.setFrameMode(slsDetectorDefs::frameModeType(value),
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// int slsDetectorUsers::setDetectorMode(int value, int detPos) {
|
// int slsDetectorUsers::setDetectorMode(int value, int detPos) {
|
||||||
// return detector.setDetectorMode(slsDetectorDefs::detectorModeType(value), detPos);
|
// return detector.setDetectorMode(slsDetectorDefs::detectorModeType(value),
|
||||||
|
// detPos);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// /************************************************************************
|
// /************************************************************************
|
||||||
|
|
||||||
// CALLBACKS & COMMAND LINE PARSING
|
// CALLBACKS & COMMAND LINE PARSING
|
||||||
|
|
||||||
// *********************************************************************/
|
// *********************************************************************/
|
||||||
|
|
||||||
// void slsDetectorUsers::registerDataCallback(void( *userCallback)(detectorData*, uint64_t, uint32_t, void*), void *pArg) {
|
// void slsDetectorUsers::registerDataCallback(void(
|
||||||
|
// *userCallback)(detectorData*, uint64_t, uint32_t, void*), void *pArg) {
|
||||||
// detector.registerDataCallback(userCallback,pArg);
|
// detector.registerDataCallback(userCallback,pArg);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// void slsDetectorUsers::registerAcquisitionFinishedCallback(void( *func)(double,int, void*), void *pArg) {
|
// void slsDetectorUsers::registerAcquisitionFinishedCallback(void(
|
||||||
|
// *func)(double,int, void*), void *pArg) {
|
||||||
// detector.registerAcquisitionFinishedCallback(func,pArg);
|
// detector.registerAcquisitionFinishedCallback(func,pArg);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// void slsDetectorUsers::putCommand(const std::string& command){
|
// void slsDetectorUsers::putCommand(const std::string& command){
|
||||||
// multiSlsDetectorClient(command, slsDetectorDefs::PUT_ACTION, &detector);
|
// multiSlsDetectorClient(command, slsDetectorDefs::PUT_ACTION, &detector);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
14
slsDetectorSoftware/tests/test-CmdParser.cpp
Executable file → Normal file
14
slsDetectorSoftware/tests/test-CmdParser.cpp
Executable file → Normal file
@ -3,7 +3,6 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
// tests to add
|
// tests to add
|
||||||
// help for all docs
|
// help for all docs
|
||||||
// command for all depreciated commands
|
// command for all depreciated commands
|
||||||
@ -135,9 +134,9 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
|||||||
REQUIRE(p.argv().size() == 1);
|
REQUIRE(p.argv().size() == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with -h at a different position"){
|
WHEN("Parsing a string with -h at a different position") {
|
||||||
std::string s = "list -h something";
|
std::string s = "list -h something";
|
||||||
THEN("its also done right"){
|
THEN("its also done right") {
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
REQUIRE(p.isHelp());
|
REQUIRE(p.isHelp());
|
||||||
REQUIRE(p.command() == "list");
|
REQUIRE(p.command() == "list");
|
||||||
@ -145,9 +144,9 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
|||||||
REQUIRE(p.arguments().front() == "something");
|
REQUIRE(p.arguments().front() == "something");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Parsing a string with -help at a different position"){
|
WHEN("Parsing a string with -help at a different position") {
|
||||||
std::string s = "list --help something";
|
std::string s = "list --help something";
|
||||||
THEN("its also done right"){
|
THEN("its also done right") {
|
||||||
p.Parse(s);
|
p.Parse(s);
|
||||||
REQUIRE(p.isHelp());
|
REQUIRE(p.isHelp());
|
||||||
REQUIRE(p.command() == "list");
|
REQUIRE(p.command() == "list");
|
||||||
@ -158,7 +157,7 @@ SCENARIO("Parsing strings with -h or --help", "[support]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Parsing consecutive strings resets not found det id"){
|
TEST_CASE("Parsing consecutive strings resets not found det id") {
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse("1:exptime 0.5");
|
p.Parse("1:exptime 0.5");
|
||||||
REQUIRE(p.detector_id() == 1);
|
REQUIRE(p.detector_id() == 1);
|
||||||
@ -166,10 +165,9 @@ TEST_CASE("Parsing consecutive strings resets not found det id"){
|
|||||||
REQUIRE(p.detector_id() == -1);
|
REQUIRE(p.detector_id() == -1);
|
||||||
p.Parse("3:exptime 0.5");
|
p.Parse("3:exptime 0.5");
|
||||||
REQUIRE(p.detector_id() == 3);
|
REQUIRE(p.detector_id() == 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Parsing consecutive strings resets not found multi id"){
|
TEST_CASE("Parsing consecutive strings resets not found multi id") {
|
||||||
CmdParser p;
|
CmdParser p;
|
||||||
p.Parse("1-1:exptime 0.5");
|
p.Parse("1-1:exptime 0.5");
|
||||||
REQUIRE(p.multi_id() == 1);
|
REQUIRE(p.multi_id() == 1);
|
||||||
|
@ -17,7 +17,8 @@ using test::PUT;
|
|||||||
|
|
||||||
/* dacs */
|
/* dacs */
|
||||||
|
|
||||||
TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs][.new]") {
|
TEST_CASE("Setting and reading back Chip test board dacs",
|
||||||
|
"[.cmd][.dacs][.new]") {
|
||||||
// dac 0 to dac 17
|
// dac 0 to dac 17
|
||||||
|
|
||||||
Detector det;
|
Detector det;
|
||||||
@ -25,12 +26,14 @@ TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs][.new]"
|
|||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::CHIPTESTBOARD) {
|
if (det_type == defs::CHIPTESTBOARD) {
|
||||||
for (int i = 0; i < 18; ++i) {
|
for (int i = 0; i < 18; ++i) {
|
||||||
SECTION("dac " + std::to_string(i)) { test_dac(static_cast<defs::dacIndex>(i), "dac", 0); }
|
SECTION("dac " + std::to_string(i)) {
|
||||||
|
test_dac(static_cast<defs::dacIndex>(i), "dac", 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// eiger
|
// eiger
|
||||||
//REQUIRE_THROWS(proxy.Call("vthreshold", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vthreshold", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vsvp", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vsvp", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vsvn", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vsvn", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vtr", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vtr", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vrf", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vrf", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vrs", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vrs", {}, -1, GET));
|
||||||
@ -53,30 +56,30 @@ TEST_CASE("Setting and reading back Chip test board dacs", "[.cmd][.dacs][.new]"
|
|||||||
REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vref_prech", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vb_pixbuf", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vb_ds", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||||
// gotthard
|
// gotthard
|
||||||
//REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
||||||
// mythen3
|
// mythen3
|
||||||
//REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vth2", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vth3", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vpl", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vph", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vtrim", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vcassh", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vcas", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vicin", {}, -1, GET));
|
||||||
|
@ -14,7 +14,6 @@ using sls::Detector;
|
|||||||
using test::GET;
|
using test::GET;
|
||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
|
|
||||||
/** temperature */
|
/** temperature */
|
||||||
|
|
||||||
TEST_CASE("temp_fpgaext", "[.cmd][.new]") {
|
TEST_CASE("temp_fpgaext", "[.cmd][.new]") {
|
||||||
@ -25,7 +24,7 @@ TEST_CASE("temp_fpgaext", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgaext", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpgaext", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgaext", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpgaext", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_fpgaext "));
|
std::string s = (oss.str()).erase(0, strlen("temp_fpgaext "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_fpgaext", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_fpgaext", {}, -1, GET));
|
||||||
@ -40,7 +39,7 @@ TEST_CASE("temp_10ge", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_10ge", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_10ge", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_10ge", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_10ge", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_10ge "));
|
std::string s = (oss.str()).erase(0, strlen("temp_10ge "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_10ge", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_10ge", {}, -1, GET));
|
||||||
@ -55,7 +54,7 @@ TEST_CASE("temp_dcdc", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_dcdc", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_dcdc", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_dcdc", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_dcdc", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_dcdc "));
|
std::string s = (oss.str()).erase(0, strlen("temp_dcdc "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_dcdc", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_dcdc", {}, -1, GET));
|
||||||
@ -70,7 +69,7 @@ TEST_CASE("temp_sodl", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_sodl", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_sodl", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_sodl", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_sodl", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_sodl "));
|
std::string s = (oss.str()).erase(0, strlen("temp_sodl "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_sodl", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_sodl", {}, -1, GET));
|
||||||
@ -85,7 +84,7 @@ TEST_CASE("temp_sodr", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_sodr", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_sodr", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_sodr", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_sodr", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_sodr "));
|
std::string s = (oss.str()).erase(0, strlen("temp_sodr "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_sodr", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_sodr", {}, -1, GET));
|
||||||
@ -100,7 +99,7 @@ TEST_CASE("temp_fpgafl", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafl", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpgafl", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafl", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpgafl", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_fpgafl "));
|
std::string s = (oss.str()).erase(0, strlen("temp_fpgafl "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_fpgafl", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_fpgafl", {}, -1, GET));
|
||||||
@ -115,7 +114,7 @@ TEST_CASE("temp_fpgafr", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafr", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpgafr", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpgafr", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpgafr", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_fpgafr "));
|
std::string s = (oss.str()).erase(0, strlen("temp_fpgafr "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_fpgafr", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_fpgafr", {}, -1, GET));
|
||||||
@ -229,30 +228,6 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd][.dacs][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("Eiger transmission delay", "[.cmd]") {
|
TEST_CASE("Eiger transmission delay", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -519,8 +494,6 @@ TEST_CASE("quad", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("trigger", "[.cmd]") {
|
// TEST_CASE("trigger", "[.cmd]") {
|
||||||
// Detector det;
|
// Detector det;
|
||||||
// CmdProxy proxy(&det);
|
// CmdProxy proxy(&det);
|
||||||
|
@ -9,7 +9,6 @@ using sls::Detector;
|
|||||||
using test::GET;
|
using test::GET;
|
||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
|
|
||||||
void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -20,9 +19,11 @@ void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
|||||||
if (dacname == "dac") {
|
if (dacname == "dac") {
|
||||||
auto dacIndexstr = std::to_string(static_cast<int>(index));
|
auto dacIndexstr = std::to_string(static_cast<int>(index));
|
||||||
proxy.Call(dacname, {dacIndexstr, dacstr}, -1, PUT, oss_set);
|
proxy.Call(dacname, {dacIndexstr, dacstr}, -1, PUT, oss_set);
|
||||||
REQUIRE(oss_set.str() == dacname + " " + dacIndexstr + " " + dacstr + "\n");
|
REQUIRE(oss_set.str() ==
|
||||||
|
dacname + " " + dacIndexstr + " " + dacstr + "\n");
|
||||||
proxy.Call(dacname, {dacIndexstr}, -1, GET, oss_get);
|
proxy.Call(dacname, {dacIndexstr}, -1, GET, oss_get);
|
||||||
REQUIRE(oss_get.str() == dacname + " " + dacIndexstr + " " + dacstr + "\n");
|
REQUIRE(oss_get.str() ==
|
||||||
|
dacname + " " + dacIndexstr + " " + dacstr + "\n");
|
||||||
}
|
}
|
||||||
// other detectors
|
// other detectors
|
||||||
else {
|
else {
|
||||||
@ -37,12 +38,15 @@ void test_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_onchip_dac(defs::dacIndex index, const std::string &dacname, int dacvalue) {
|
void test_onchip_dac(defs::dacIndex index, const std::string &dacname,
|
||||||
|
int dacvalue) {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
REQUIRE_THROWS(proxy.Call(dacname, {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call(dacname, {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call(dacname, {"10", "0x0"}, -1, PUT)); // chip index (-1 to 9)
|
REQUIRE_THROWS(
|
||||||
REQUIRE_THROWS(proxy.Call(dacname, {"-1", "0x400"}, -1, PUT)); // max val is 0x3ff
|
proxy.Call(dacname, {"10", "0x0"}, -1, PUT)); // chip index (-1 to 9)
|
||||||
|
REQUIRE_THROWS(
|
||||||
|
proxy.Call(dacname, {"-1", "0x400"}, -1, PUT)); // max val is 0x3ff
|
||||||
|
|
||||||
int chipIndex = -1; // for now, it is -1 only
|
int chipIndex = -1; // for now, it is -1 only
|
||||||
auto prev_val = det.getOnChipDAC(index, chipIndex);
|
auto prev_val = det.getOnChipDAC(index, chipIndex);
|
||||||
@ -50,9 +54,11 @@ void test_onchip_dac(defs::dacIndex index, const std::string &dacname, int dacva
|
|||||||
auto chipIndexStr = std::to_string(chipIndex);
|
auto chipIndexStr = std::to_string(chipIndex);
|
||||||
std::ostringstream oss_set, oss_get;
|
std::ostringstream oss_set, oss_get;
|
||||||
proxy.Call(dacname, {chipIndexStr, dacValueStr}, -1, PUT, oss_set);
|
proxy.Call(dacname, {chipIndexStr, dacValueStr}, -1, PUT, oss_set);
|
||||||
REQUIRE(oss_set.str() == dacname + " " + chipIndexStr + " " + dacValueStr + "\n");
|
REQUIRE(oss_set.str() ==
|
||||||
|
dacname + " " + chipIndexStr + " " + dacValueStr + "\n");
|
||||||
proxy.Call(dacname, {chipIndexStr}, -1, GET, oss_get);
|
proxy.Call(dacname, {chipIndexStr}, -1, GET, oss_get);
|
||||||
REQUIRE(oss_get.str() == dacname + " " + chipIndexStr + " " + dacValueStr + "\n");
|
REQUIRE(oss_get.str() ==
|
||||||
|
dacname + " " + chipIndexStr + " " + dacValueStr + "\n");
|
||||||
|
|
||||||
// Reset all dacs to previous value
|
// Reset all dacs to previous value
|
||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
|
||||||
void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname, int dacvalue);
|
void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
|
||||||
void test_onchip_dac(slsDetectorDefs::dacIndex index, const std::string &dacname, int dacvalue);
|
int dacvalue);
|
||||||
|
void test_onchip_dac(slsDetectorDefs::dacIndex index,
|
||||||
|
const std::string &dacname, int dacvalue);
|
||||||
|
@ -18,7 +18,8 @@ using test::PUT;
|
|||||||
/* dacs */
|
/* dacs */
|
||||||
|
|
||||||
TEST_CASE("Setting and reading back GOTTHARD dacs", "[.cmd][.dacs][.new]") {
|
TEST_CASE("Setting and reading back GOTTHARD dacs", "[.cmd][.dacs][.new]") {
|
||||||
// vref_ds, vcascn_pb, vcascp_pb, vout_cm, vcasc_out, vin_cm, vref_comp, ib_test_c
|
// vref_ds, vcascn_pb, vcascp_pb, vout_cm, vcasc_out, vin_cm, vref_comp,
|
||||||
|
// ib_test_c
|
||||||
|
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -22,9 +22,12 @@ TEST_CASE("bursts", "[.cmd][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
auto prev_burst = det.getNumberOfBursts().tsquash("#bursts should be same to test");
|
auto prev_burst =
|
||||||
auto prev_trigger = det.getNumberOfFrames().tsquash("#frames should be same to test");
|
det.getNumberOfBursts().tsquash("#bursts should be same to test");
|
||||||
auto prev_frames = det.getNumberOfTriggers().tsquash("#triggers should be same to test");
|
auto prev_trigger =
|
||||||
|
det.getNumberOfFrames().tsquash("#frames should be same to test");
|
||||||
|
auto prev_frames = det.getNumberOfTriggers().tsquash(
|
||||||
|
"#triggers should be same to test");
|
||||||
auto prev_timingMode = det.getTimingMode();
|
auto prev_timingMode = det.getTimingMode();
|
||||||
auto prev_burstMode = det.getBurstMode();
|
auto prev_burstMode = det.getBurstMode();
|
||||||
// changing continuous mode frames and bursts
|
// changing continuous mode frames and bursts
|
||||||
@ -100,15 +103,25 @@ TEST_CASE("Setting and reading back GOTTHARD2 dacs", "[.cmd][.dacs][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
SECTION("vref_h_adc") { test_dac(defs::VREF_H_ADC, "vref_h_adc", 2099); }
|
SECTION("vref_h_adc") {
|
||||||
|
test_dac(defs::VREF_H_ADC, "vref_h_adc", 2099);
|
||||||
|
}
|
||||||
SECTION("vb_comp_fe") { test_dac(defs::VB_COMP_FE, "vb_comp_fe", 0); }
|
SECTION("vb_comp_fe") { test_dac(defs::VB_COMP_FE, "vb_comp_fe", 0); }
|
||||||
SECTION("vb_comp_adc") { test_dac(defs::VB_COMP_ADC, "vb_comp_adc", 0); }
|
SECTION("vb_comp_adc") {
|
||||||
|
test_dac(defs::VB_COMP_ADC, "vb_comp_adc", 0);
|
||||||
|
}
|
||||||
SECTION("vcom_cds") { test_dac(defs::VCOM_CDS, "vcom_cds", 1400); }
|
SECTION("vcom_cds") { test_dac(defs::VCOM_CDS, "vcom_cds", 1400); }
|
||||||
SECTION("vref_rstore") { test_dac(defs::VREF_RSTORE, "vref_rstore", 640); }
|
SECTION("vref_rstore") {
|
||||||
|
test_dac(defs::VREF_RSTORE, "vref_rstore", 640);
|
||||||
|
}
|
||||||
SECTION("vb_opa_1st") { test_dac(defs::VB_OPA_1ST, "vb_opa_1st", 0); }
|
SECTION("vb_opa_1st") { test_dac(defs::VB_OPA_1ST, "vb_opa_1st", 0); }
|
||||||
SECTION("vref_comp_fe") { test_dac(defs::VREF_COMP_FE, "vref_comp_fe", 0); }
|
SECTION("vref_comp_fe") {
|
||||||
|
test_dac(defs::VREF_COMP_FE, "vref_comp_fe", 0);
|
||||||
|
}
|
||||||
SECTION("vcom_adc1") { test_dac(defs::VCOM_ADC1, "vcom_adc1", 1400); }
|
SECTION("vcom_adc1") { test_dac(defs::VCOM_ADC1, "vcom_adc1", 1400); }
|
||||||
SECTION("vref_prech") { test_dac(defs::VREF_PRECH, "vref_prech", 1720); }
|
SECTION("vref_prech") {
|
||||||
|
test_dac(defs::VREF_PRECH, "vref_prech", 1720);
|
||||||
|
}
|
||||||
SECTION("vref_l_adc") { test_dac(defs::VREF_L_ADC, "vref_l_adc", 700); }
|
SECTION("vref_l_adc") { test_dac(defs::VREF_L_ADC, "vref_l_adc", 700); }
|
||||||
SECTION("vref_cds") { test_dac(defs::VREF_CDS, "vref_cds", 1200); }
|
SECTION("vref_cds") { test_dac(defs::VREF_CDS, "vref_cds", 1200); }
|
||||||
SECTION("vb_cs") { test_dac(defs::VB_CS, "vb_cs", 2799); }
|
SECTION("vb_cs") { test_dac(defs::VB_CS, "vb_cs", 2799); }
|
||||||
@ -178,7 +191,9 @@ TEST_CASE("vchip_comp_fe", "[.cmd][.onchipdacs][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
SECTION("vchip_comp_fe") { test_onchip_dac(defs::VB_COMP_FE, "vchip_comp_fe", 0x137); }
|
SECTION("vchip_comp_fe") {
|
||||||
|
test_onchip_dac(defs::VB_COMP_FE, "vchip_comp_fe", 0x137);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vchip_comp_fe", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vchip_comp_fe", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -189,7 +204,9 @@ TEST_CASE("vchip_opa_1st", "[.cmd][.onchipdacs][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
SECTION("vchip_opa_1st") { test_onchip_dac(defs::VB_OPA_1ST, "vchip_opa_1st", 0x000); }
|
SECTION("vchip_opa_1st") {
|
||||||
|
test_onchip_dac(defs::VB_OPA_1ST, "vchip_opa_1st", 0x000);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vchip_opa_1st", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vchip_opa_1st", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -200,7 +217,9 @@ TEST_CASE("vchip_opa_fd", "[.cmd][.onchipdacs][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
SECTION("vchip_opa_fd") { test_onchip_dac(defs::VB_OPA_FD, "vchip_opa_fd", 0x134); }
|
SECTION("vchip_opa_fd") {
|
||||||
|
test_onchip_dac(defs::VB_OPA_FD, "vchip_opa_fd", 0x134);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vchip_opa_fd", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vchip_opa_fd", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -211,7 +230,9 @@ TEST_CASE("vchip_comp_adc", "[.cmd][.onchipdacs][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
SECTION("vchip_comp_adc") { test_onchip_dac(defs::VB_COMP_ADC, "vchip_comp_adc", 0x3FF); }
|
SECTION("vchip_comp_adc") {
|
||||||
|
test_onchip_dac(defs::VB_COMP_ADC, "vchip_comp_adc", 0x3FF);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vchip_comp_adc", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vchip_comp_adc", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -222,7 +243,9 @@ TEST_CASE("vchip_ref_comp_fe", "[.cmd][.onchipdacs][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
SECTION("vchip_ref_comp_fe") { test_onchip_dac(defs::VREF_COMP_FE, "vchip_ref_comp_fe", 0x100); }
|
SECTION("vchip_ref_comp_fe") {
|
||||||
|
test_onchip_dac(defs::VREF_COMP_FE, "vchip_ref_comp_fe", 0x100);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vchip_ref_comp_fe", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vchip_ref_comp_fe", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -239,22 +262,6 @@ TEST_CASE("vchip_cs", "[.cmd][.onchipdacs][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("burstmode", "[.cmd]") {
|
TEST_CASE("burstmode", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -286,7 +293,6 @@ TEST_CASE("burstmode", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("vetoref", "[.cmd]") {
|
TEST_CASE("vetoref", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -294,14 +300,14 @@ TEST_CASE("vetoref", "[.cmd]") {
|
|||||||
|
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vetoref", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1, PUT)); // invalid chip index
|
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x3ff"}, -1,
|
||||||
|
PUT)); // invalid chip index
|
||||||
REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT));
|
REQUIRE_NOTHROW(proxy.Call("vetoref", {"1", "0x010"}, -1, PUT));
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("vetoref", {"3", "0x0"}, -1, PUT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("vetophoton", "[.cmd]") {
|
TEST_CASE("vetophoton", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -310,16 +316,17 @@ TEST_CASE("vetophoton", "[.cmd]") {
|
|||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vetophoton", {}, -1, GET));
|
||||||
REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("vetophoton", {"-1"}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1, PUT));// invalid chip index
|
REQUIRE_THROWS(proxy.Call("vetophoton", {"12", "1", "39950"}, -1,
|
||||||
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1, PUT)); // invalid photon number
|
PUT)); // invalid chip index
|
||||||
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1, PUT)); // invald file
|
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "0"}, -1,
|
||||||
|
PUT)); // invalid photon number
|
||||||
|
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1", "1", "39950"}, -1,
|
||||||
|
PUT)); // invald file
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vetophoton", {"-1"}, -1, GET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("inj_ch", "[.cmd]") {
|
TEST_CASE("inj_ch", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -327,8 +334,10 @@ TEST_CASE("inj_ch", "[.cmd]") {
|
|||||||
|
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
auto inj = det.getInjectChannel();
|
auto inj = det.getInjectChannel();
|
||||||
REQUIRE_THROWS(proxy.Call("inj_ch", {"-1", "1"}, -1, PUT));// invalid offset
|
REQUIRE_THROWS(
|
||||||
REQUIRE_THROWS(proxy.Call("inj_ch", {"0", "0"}, -1, PUT));// invalid increment
|
proxy.Call("inj_ch", {"-1", "1"}, -1, PUT)); // invalid offset
|
||||||
|
REQUIRE_THROWS(
|
||||||
|
proxy.Call("inj_ch", {"0", "0"}, -1, PUT)); // invalid increment
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss);
|
proxy.Call("inj_ch", {"0", "1"}, -1, PUT, oss);
|
||||||
@ -347,9 +356,6 @@ TEST_CASE("inj_ch", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("burstperiod", "[.cmd]") {
|
TEST_CASE("burstperiod", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -372,7 +378,6 @@ TEST_CASE("burstperiod", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("currentsource", "[.cmd]") {
|
TEST_CASE("currentsource", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -410,11 +415,11 @@ TEST_CASE("timingsource", "[.cmd]") {
|
|||||||
|
|
||||||
if (det_type == defs::GOTTHARD2) {
|
if (det_type == defs::GOTTHARD2) {
|
||||||
auto prev_val = det.getTimingSource();
|
auto prev_val = det.getTimingSource();
|
||||||
/* { until its activated in fpga
|
/* { until its activated in fpga
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("timingsource", {"external"}, -1, PUT, oss);
|
proxy.Call("timingsource", {"external"}, -1, PUT, oss);
|
||||||
REQUIRE(oss.str() == "timingsource external\n");
|
REQUIRE(oss.str() == "timingsource external\n");
|
||||||
}*/
|
}*/
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("timingsource", {"internal"}, -1, PUT, oss);
|
proxy.Call("timingsource", {"internal"}, -1, PUT, oss);
|
||||||
|
@ -16,7 +16,8 @@ using test::PUT;
|
|||||||
/* dacs */
|
/* dacs */
|
||||||
|
|
||||||
TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs][.new]") {
|
TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs][.new]") {
|
||||||
// vb_comp, vdd_prot, vin_com, vref_prech, vb_pixbuf, vb_ds, vref_ds, vref_comp
|
// vb_comp, vdd_prot, vin_com, vref_prech, vb_pixbuf, vb_ds, vref_ds,
|
||||||
|
// vref_comp
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
@ -24,7 +25,9 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs][.new]") {
|
|||||||
SECTION("vb_comp") { test_dac(defs::VB_COMP, "vb_comp", 1220); }
|
SECTION("vb_comp") { test_dac(defs::VB_COMP, "vb_comp", 1220); }
|
||||||
SECTION("vdd_prot") { test_dac(defs::VDD_PROT, "vdd_prot", 3000); }
|
SECTION("vdd_prot") { test_dac(defs::VDD_PROT, "vdd_prot", 3000); }
|
||||||
SECTION("vin_com") { test_dac(defs::VIN_COM, "vin_com", 1053); }
|
SECTION("vin_com") { test_dac(defs::VIN_COM, "vin_com", 1053); }
|
||||||
SECTION("vref_prech") { test_dac(defs::VREF_PRECH, "vref_prech", 1450); }
|
SECTION("vref_prech") {
|
||||||
|
test_dac(defs::VREF_PRECH, "vref_prech", 1450);
|
||||||
|
}
|
||||||
SECTION("vb_pixbuf") { test_dac(defs::VB_PIXBUF, "vb_pixbuf", 750); }
|
SECTION("vb_pixbuf") { test_dac(defs::VB_PIXBUF, "vb_pixbuf", 750); }
|
||||||
SECTION("vb_ds") { test_dac(defs::VB_DS, "vb_ds", 1000); }
|
SECTION("vb_ds") { test_dac(defs::VB_DS, "vb_ds", 1000); }
|
||||||
SECTION("vref_ds") { test_dac(defs::VREF_DS, "vref_ds", 480); }
|
SECTION("vref_ds") { test_dac(defs::VREF_DS, "vref_ds", 480); }
|
||||||
@ -91,38 +94,6 @@ TEST_CASE("Setting and reading back Jungfrau dacs", "[.cmd][.dacs][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("nframes", "[.cmd]") {
|
TEST_CASE("nframes", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -171,7 +142,7 @@ TEST_CASE("timestamp", "[.cmd]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("adcreg", "[.cmd]") {
|
TEST_CASE("adcreg", "[.cmd]") {
|
||||||
//TODO! what is a safe value to use?
|
// TODO! what is a safe value to use?
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
@ -234,5 +205,3 @@ TEST_CASE("resetfpga", "[.cmd]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("resetfpga", {}, -1, PUT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,13 +18,16 @@ using test::PUT;
|
|||||||
/* dacs */
|
/* dacs */
|
||||||
|
|
||||||
TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs][.new]") {
|
TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs][.new]") {
|
||||||
// vbp_colbuf, vipre, vin_cm", vb_sda, vcasc_sfp, vout_cm, vipre_cds, ibias_sfp
|
// vbp_colbuf, vipre, vin_cm", vb_sda, vcasc_sfp, vout_cm, vipre_cds,
|
||||||
|
// ibias_sfp
|
||||||
|
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::MOENCH) {
|
if (det_type == defs::MOENCH) {
|
||||||
SECTION("vbp_colbuf") { test_dac(defs::VBP_COLBUF, "vbp_colbuf", 1300); }
|
SECTION("vbp_colbuf") {
|
||||||
|
test_dac(defs::VBP_COLBUF, "vbp_colbuf", 1300);
|
||||||
|
}
|
||||||
SECTION("vipre") { test_dac(defs::VIPRE, "vipre", 1000); }
|
SECTION("vipre") { test_dac(defs::VIPRE, "vipre", 1000); }
|
||||||
SECTION("vin_cm") { test_dac(defs::VIN_CM, "vin_cm", 1400); }
|
SECTION("vin_cm") { test_dac(defs::VIN_CM, "vin_cm", 1400); }
|
||||||
SECTION("vb_sda") { test_dac(defs::VB_SDA, "vb_sda", 680); }
|
SECTION("vb_sda") { test_dac(defs::VB_SDA, "vb_sda", 680); }
|
||||||
@ -65,16 +68,16 @@ TEST_CASE("Setting and reading back MOENCH dacs", "[.cmd][.dacs][.new]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vref_ds", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vcascn_pb", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vcascp_pb", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vout_cm", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vcasc_out", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vin_cm", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vref_comp", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("ib_test_c", {}, -1, GET));
|
||||||
// mythen3
|
// mythen3
|
||||||
REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vpreamp", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vshaper", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vshaperneg", {}, -1, GET));
|
||||||
//REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
// REQUIRE_THROWS(proxy.Call("vipre", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("viinsh", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vdcsh", {}, -1, GET));
|
||||||
REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("vth1", {}, -1, GET));
|
||||||
|
@ -89,22 +89,6 @@ TEST_CASE("Setting and reading back MYTHEN3 dacs", "[.cmd][.dacs][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("counters", "[.cmd]") {
|
TEST_CASE("counters", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -106,7 +106,6 @@ TEST_CASE("rx_framescaught", "[.cmd][.rx][.new]") {
|
|||||||
// proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
// proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||||
// REQUIRE(oss.str() == "rx_framescaught 1\n");
|
// REQUIRE(oss.str() == "rx_framescaught 1\n");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("rx_missingpackets", "[.cmd][.rx][.new]") {
|
TEST_CASE("rx_missingpackets", "[.cmd][.rx][.new]") {
|
||||||
@ -141,7 +140,6 @@ TEST_CASE("rx_printconfig", "[.cmd][.rx][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("rx_printconfig", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("rx_printconfig", {}, -1, GET));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Receiver Config */
|
/* Receiver Config */
|
||||||
|
|
||||||
TEST_CASE("rx_hostname", "[.cmd][.rx][.new]") {
|
TEST_CASE("rx_hostname", "[.cmd][.rx][.new]") {
|
||||||
@ -149,7 +147,8 @@ TEST_CASE("rx_hostname", "[.cmd][.rx][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto prev_val = det.getRxHostname();
|
auto prev_val = det.getRxHostname();
|
||||||
|
|
||||||
// Cannot set rx_hostname (will reset parameters in rxr and no shm variables to update)
|
// Cannot set rx_hostname (will reset parameters in rxr and no shm variables
|
||||||
|
// to update)
|
||||||
// {
|
// {
|
||||||
// // disable receiver
|
// // disable receiver
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
@ -304,7 +303,8 @@ TEST_CASE("rx_padding", "[.cmd][.rx][.new]") {
|
|||||||
TEST_CASE("rx_udpsocksize", "[.cmd][.rx][.new]") {
|
TEST_CASE("rx_udpsocksize", "[.cmd][.rx][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash("Need same udp socket buffer size to test");
|
int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash(
|
||||||
|
"Need same udp socket buffer size to test");
|
||||||
std::string s_new_val = std::to_string(prev_val - 1000);
|
std::string s_new_val = std::to_string(prev_val - 1000);
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -648,7 +648,7 @@ TEST_CASE("rx_zmqport", "[.cmd][.rx][.new]") {
|
|||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setRxZmqPort(prev_val_zmqport[i], i);
|
det.setRxZmqPort(prev_val_zmqport[i], i);
|
||||||
if (det_type == defs::JUNGFRAU) {
|
if (det_type == defs::JUNGFRAU) {
|
||||||
det.setNumberofUDPInterfaces(prev_val_numinterfaces[i], {i});
|
det.setNumberofUDPInterfaces(prev_val_numinterfaces[i], {i});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -683,7 +683,9 @@ TEST_CASE("rx_dbitlist", "[.cmd][.rx][.new]") {
|
|||||||
auto prev_val = det.getRxDbitList();
|
auto prev_val = det.getRxDbitList();
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("rx_dbitlist", {"0", "4", "5", "8", "9", "10", "52", "63"}, -1, PUT, oss);
|
proxy.Call("rx_dbitlist",
|
||||||
|
{"0", "4", "5", "8", "9", "10", "52", "63"}, -1, PUT,
|
||||||
|
oss);
|
||||||
REQUIRE(oss.str() == "rx_dbitlist [0, 4, 5, 8, 9, 10, 52, 63]\n");
|
REQUIRE(oss.str() == "rx_dbitlist [0, 4, 5, 8, 9, 10, 52, 63]\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -745,7 +747,8 @@ TEST_CASE("rx_jsonaddheader", "[.cmd][.rx][.new]") {
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("rx_jsonaddheader", {"key1", "value1", "key2", "value2"}, -1, PUT, oss);
|
proxy.Call("rx_jsonaddheader", {"key1", "value1", "key2", "value2"}, -1,
|
||||||
|
PUT, oss);
|
||||||
REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n");
|
REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
#include <chrono>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#include "tests/globals.h"
|
#include "tests/globals.h"
|
||||||
|
|
||||||
@ -36,24 +36,25 @@ TEST_CASE("parameters", "[.cmd][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
// put only
|
// put only
|
||||||
REQUIRE_THROWS(proxy.Call("parameters", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("parameters", {}, -1, GET));
|
||||||
/*
|
/*
|
||||||
auto prev_val = det.getNumberOfFrames().tsquash("Number of frames has to be same to test");
|
auto prev_val = det.getNumberOfFrames().tsquash("Number of frames has to
|
||||||
{
|
be same to test");
|
||||||
system("echo 'frames 2' > /tmp/tempsetup.det ");
|
{
|
||||||
std::ostringstream oss;
|
system("echo 'frames 2' > /tmp/tempsetup.det ");
|
||||||
proxy.Call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
std::ostringstream oss;
|
||||||
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
proxy.Call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
||||||
REQUIRE(det.getNumberOfFrames().tsquash("failed") == 2);
|
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
||||||
}
|
REQUIRE(det.getNumberOfFrames().tsquash("failed") == 2);
|
||||||
{
|
}
|
||||||
system("echo '0:frames 1' > /tmp/tempsetup.det ");
|
{
|
||||||
std::ostringstream oss;
|
system("echo '0:frames 1' > /tmp/tempsetup.det ");
|
||||||
proxy.Call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
std::ostringstream oss;
|
||||||
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
proxy.Call("parameters", {"/tmp/tempsetup.det"}, -1, PUT, oss);
|
||||||
REQUIRE(det.getNumberOfFrames({0}).tsquash("failed") == 1);
|
REQUIRE(oss.str() == "parameters /tmp/tempsetup.det\n");
|
||||||
}
|
REQUIRE(det.getNumberOfFrames({0}).tsquash("failed") == 1);
|
||||||
det.setNumberOfFrames(prev_val);
|
}
|
||||||
*/
|
det.setNumberOfFrames(prev_val);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("hostname", "[.cmd][.new]") {
|
TEST_CASE("hostname", "[.cmd][.new]") {
|
||||||
@ -106,7 +107,7 @@ TEST_CASE("detectornumber", "[.cmd][.new]") {
|
|||||||
REQUIRE_THROWS(proxy.Call("detectornumber", {"0"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("detectornumber", {"0"}, -1, PUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("type", "[.cmd][.new]"){
|
TEST_CASE("type", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto dt = det.getDetectorType().squash();
|
auto dt = det.getDetectorType().squash();
|
||||||
@ -130,46 +131,46 @@ TEST_CASE("settings", "[.cmd][.new]") {
|
|||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
std::vector<std::string> sett;
|
std::vector<std::string> sett;
|
||||||
switch (det_type) {
|
switch (det_type) {
|
||||||
case defs::EIGER:
|
case defs::EIGER:
|
||||||
//FIXME: need to remove when settings removed
|
// FIXME: need to remove when settings removed
|
||||||
break;
|
break;
|
||||||
case defs::JUNGFRAU:
|
case defs::JUNGFRAU:
|
||||||
sett.push_back("dynamicgain");
|
sett.push_back("dynamicgain");
|
||||||
sett.push_back("dynamichg0");
|
sett.push_back("dynamichg0");
|
||||||
sett.push_back("fixgain1");
|
sett.push_back("fixgain1");
|
||||||
sett.push_back("fixgain2");
|
sett.push_back("fixgain2");
|
||||||
sett.push_back("forceswitchg1");
|
sett.push_back("forceswitchg1");
|
||||||
sett.push_back("forceswitchg2");
|
sett.push_back("forceswitchg2");
|
||||||
break;
|
break;
|
||||||
case defs::GOTTHARD:
|
case defs::GOTTHARD:
|
||||||
sett.push_back("highgain");
|
sett.push_back("highgain");
|
||||||
sett.push_back("dynamicgain");
|
sett.push_back("dynamicgain");
|
||||||
sett.push_back("lowgain");
|
sett.push_back("lowgain");
|
||||||
sett.push_back("mediumgain");
|
sett.push_back("mediumgain");
|
||||||
sett.push_back("veryhighgain");
|
sett.push_back("veryhighgain");
|
||||||
break;
|
break;
|
||||||
case defs::GOTTHARD2:
|
case defs::GOTTHARD2:
|
||||||
sett.push_back("dynamicgain");
|
sett.push_back("dynamicgain");
|
||||||
sett.push_back("fixgain1");
|
sett.push_back("fixgain1");
|
||||||
sett.push_back("fixgain2");
|
sett.push_back("fixgain2");
|
||||||
break;
|
break;
|
||||||
case defs::MOENCH:
|
case defs::MOENCH:
|
||||||
sett.push_back("g1_hg");
|
sett.push_back("g1_hg");
|
||||||
sett.push_back("g1_lg");
|
sett.push_back("g1_lg");
|
||||||
sett.push_back("g2_hc_hg");
|
sett.push_back("g2_hc_hg");
|
||||||
sett.push_back("g2_hc_lg");
|
sett.push_back("g2_hc_lg");
|
||||||
sett.push_back("g2_lc_hg");
|
sett.push_back("g2_lc_hg");
|
||||||
sett.push_back("g2_lc_lg");
|
sett.push_back("g2_lc_lg");
|
||||||
sett.push_back("g4_hg");
|
sett.push_back("g4_hg");
|
||||||
sett.push_back("g4_lg");
|
sett.push_back("g4_lg");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
REQUIRE_THROWS(proxy.Call("settings", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("settings", {}, -1, GET));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto prev_val = det.getSettings();
|
auto prev_val = det.getSettings();
|
||||||
for (auto & it : sett) {
|
for (auto &it : sett) {
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("settings", {it}, -1, PUT, oss);
|
proxy.Call("settings", {it}, -1, PUT, oss);
|
||||||
@ -196,7 +197,8 @@ TEST_CASE("settings", "[.cmd][.new]") {
|
|||||||
TEST_CASE("frames", "[.cmd][.new]") {
|
TEST_CASE("frames", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto prev_val = det.getNumberOfFrames().tsquash("#frames must be same to test");
|
auto prev_val =
|
||||||
|
det.getNumberOfFrames().tsquash("#frames must be same to test");
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("frames", {"1000"}, -1, PUT, oss);
|
proxy.Call("frames", {"1000"}, -1, PUT, oss);
|
||||||
@ -219,7 +221,8 @@ TEST_CASE("frames", "[.cmd][.new]") {
|
|||||||
TEST_CASE("triggers", "[.cmd][.new]") {
|
TEST_CASE("triggers", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto prev_val = det.getNumberOfTriggers().tsquash("#triggers must be same to test");
|
auto prev_val =
|
||||||
|
det.getNumberOfTriggers().tsquash("#triggers must be same to test");
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("triggers", {"1000"}, -1, PUT, oss);
|
proxy.Call("triggers", {"1000"}, -1, PUT, oss);
|
||||||
@ -468,10 +471,8 @@ TEST_CASE("adcphase", "[.cmd][.new]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::GOTTHARD ||
|
if (det_type == defs::GOTTHARD || det_type == defs::JUNGFRAU ||
|
||||||
det_type == defs::JUNGFRAU ||
|
det_type == defs::CHIPTESTBOARD || det_type == defs::MOENCH) {
|
||||||
det_type == defs::CHIPTESTBOARD ||
|
|
||||||
det_type == defs::MOENCH) {
|
|
||||||
if (det_type == defs::GOTTHARD) {
|
if (det_type == defs::GOTTHARD) {
|
||||||
std::ostringstream oss1;
|
std::ostringstream oss1;
|
||||||
proxy.Call("adcphase", {"20"}, -1, PUT, oss1);
|
proxy.Call("adcphase", {"20"}, -1, PUT, oss1);
|
||||||
@ -509,10 +510,9 @@ TEST_CASE("maxadcphaseshift", "[.cmd][.new]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::JUNGFRAU ||
|
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::CHIPTESTBOARD ||
|
|
||||||
det_type == defs::MOENCH ||
|
det_type == defs::MOENCH ||
|
||||||
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
|
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
|
||||||
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
|
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
|
||||||
REQUIRE_NOTHROW(proxy.Call("maxadcphaseshift", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("maxadcphaseshift", {}, -1, GET));
|
||||||
} else {
|
} else {
|
||||||
@ -524,8 +524,7 @@ TEST_CASE("dbitphase", "[.cmd][.new]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::JUNGFRAU ||
|
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD) {
|
||||||
det_type == defs::CHIPTESTBOARD) {
|
|
||||||
auto prev_val = det.getDBITPhase();
|
auto prev_val = det.getDBITPhase();
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
@ -554,9 +553,8 @@ TEST_CASE("maxdbitphaseshift", "[.cmd][.new]") {
|
|||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::JUNGFRAU ||
|
if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::CHIPTESTBOARD ||
|
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
|
||||||
det_type == defs::MYTHEN3 || // only because clk index of 0 exists
|
|
||||||
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
|
det_type == defs::GOTTHARD2) { // only because clk index of 0 exists
|
||||||
REQUIRE_NOTHROW(proxy.Call("maxdbitphaseshift", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("maxdbitphaseshift", {}, -1, GET));
|
||||||
} else {
|
} else {
|
||||||
@ -654,7 +652,6 @@ TEST_CASE("maxclkphaseshift", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("vhighvoltage", "[.cmd][.new]") {
|
TEST_CASE("vhighvoltage", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -679,9 +676,8 @@ TEST_CASE("vhighvoltage", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// range 0, 60 - 200
|
// range 0, 60 - 200
|
||||||
else if (det_type == defs::JUNGFRAU ||
|
else if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD ||
|
||||||
det_type == defs::CHIPTESTBOARD ||
|
det_type == defs::MOENCH) {
|
||||||
det_type == defs::MOENCH) {
|
|
||||||
REQUIRE_THROWS(proxy.Call("vhighvoltage", {"50"}, -1, PUT));
|
REQUIRE_THROWS(proxy.Call("vhighvoltage", {"50"}, -1, PUT));
|
||||||
{
|
{
|
||||||
std::ostringstream oss1, oss2;
|
std::ostringstream oss1, oss2;
|
||||||
@ -761,10 +757,8 @@ TEST_CASE("powerchip", "[.cmd][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
|
||||||
if (det_type == defs::JUNGFRAU ||
|
if (det_type == defs::JUNGFRAU || det_type == defs::MYTHEN3 ||
|
||||||
det_type == defs::MYTHEN3 ||
|
det_type == defs::GOTTHARD2 || det_type == defs::MOENCH) {
|
||||||
det_type == defs::GOTTHARD2 ||
|
|
||||||
det_type == defs::MOENCH) {
|
|
||||||
auto prev_val = det.getPowerChip();
|
auto prev_val = det.getPowerChip();
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -812,8 +806,7 @@ TEST_CASE("imagetest", "[.cmd][.new]") {
|
|||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
det.setImageTestMode(prev_val[i], {i});
|
det.setImageTestMode(prev_val[i], {i});
|
||||||
}
|
}
|
||||||
} else if (det_type != defs::JUNGFRAU &&
|
} else if (det_type != defs::JUNGFRAU && det_type != defs::EIGER) {
|
||||||
det_type != defs::EIGER) {
|
|
||||||
// wont fail for eiger and jungfrau virtual servers
|
// wont fail for eiger and jungfrau virtual servers
|
||||||
REQUIRE_THROWS(proxy.Call("imagetest", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("imagetest", {}, -1, GET));
|
||||||
}
|
}
|
||||||
@ -829,7 +822,7 @@ TEST_CASE("temp_adc", "[.cmd][.new]") {
|
|||||||
REQUIRE_NOTHROW(proxy.Call("temp_adc", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_adc", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_adc", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_adc", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_adc "));
|
std::string s = (oss.str()).erase(0, strlen("temp_adc "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_adc", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_adc", {}, -1, GET));
|
||||||
@ -841,11 +834,11 @@ TEST_CASE("temp_fpga", "[.cmd][.new]") {
|
|||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
auto det_type = det.getDetectorType().squash();
|
auto det_type = det.getDetectorType().squash();
|
||||||
if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD ||
|
if (det_type == defs::JUNGFRAU || det_type == defs::GOTTHARD ||
|
||||||
det_type == defs::EIGER) {
|
det_type == defs::EIGER) {
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpga", {}, -1, GET));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpga", {}, -1, GET));
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
REQUIRE_NOTHROW(proxy.Call("temp_fpga", {}, 0, GET, oss));
|
REQUIRE_NOTHROW(proxy.Call("temp_fpga", {}, 0, GET, oss));
|
||||||
std::string s = (oss.str()).erase (0, strlen("temp_fpga "));
|
std::string s = (oss.str()).erase(0, strlen("temp_fpga "));
|
||||||
REQUIRE(std::stoi(s) != -1);
|
REQUIRE(std::stoi(s) != -1);
|
||||||
} else {
|
} else {
|
||||||
REQUIRE_THROWS(proxy.Call("temp_fpga", {}, -1, GET));
|
REQUIRE_THROWS(proxy.Call("temp_fpga", {}, -1, GET));
|
||||||
@ -965,44 +958,6 @@ TEST_CASE("startingfnum", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("initialchecks", "[.cmd]") {
|
TEST_CASE("initialchecks", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -1032,7 +987,6 @@ TEST_CASE("initialchecks", "[.cmd]") {
|
|||||||
det.setInitialChecks(check);
|
det.setInitialChecks(check);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("user", "[.cmd]") {
|
TEST_CASE("user", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -1313,7 +1267,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
|||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT));
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("patsetbit", "[.cmd][.ctb]") {
|
// TEST_CASE("patsetbit", "[.cmd][.ctb]") {
|
||||||
// if (test::type == defs::CHIPTESTBOARD) {
|
// if (test::type == defs::CHIPTESTBOARD) {
|
||||||
// uint64_t val = 0;
|
// uint64_t val = 0;
|
||||||
@ -1932,8 +1885,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("romode", "[.cmd][.ctb]") {
|
// TEST_CASE("romode", "[.cmd][.ctb]") {
|
||||||
// if (test::type == defs::CHIPTESTBOARD) {
|
// if (test::type == defs::CHIPTESTBOARD) {
|
||||||
// {
|
// {
|
||||||
@ -2415,8 +2366,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("trimval", "[.cmd][.eiger]") {
|
// TEST_CASE("trimval", "[.cmd][.eiger]") {
|
||||||
// if (test::type == defs::EIGER) {
|
// if (test::type == defs::EIGER) {
|
||||||
// {
|
// {
|
||||||
@ -2460,8 +2409,6 @@ TEST_CASE("stopport", "[.cmd]") {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("parallel", "[.cmd][.eiger]") {
|
// TEST_CASE("parallel", "[.cmd][.eiger]") {
|
||||||
// if (test::type == defs::EIGER) {
|
// if (test::type == defs::EIGER) {
|
||||||
// {
|
// {
|
||||||
@ -2556,7 +2503,9 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("zmqport", {}, i, GET, oss);
|
proxy.Call("zmqport", {}, i, GET, oss);
|
||||||
REQUIRE(oss.str() == "zmqport " + std::to_string(port + i * socketsperdetector) + '\n');
|
REQUIRE(oss.str() == "zmqport " +
|
||||||
|
std::to_string(port + i * socketsperdetector) +
|
||||||
|
'\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
port = 1954;
|
port = 1954;
|
||||||
@ -2569,18 +2518,15 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
for (int i = 0; i != det.size(); ++i) {
|
for (int i = 0; i != det.size(); ++i) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
proxy.Call("zmqport", {}, i, GET, oss);
|
proxy.Call("zmqport", {}, i, GET, oss);
|
||||||
REQUIRE(oss.str() == "zmqport " + std::to_string(port + i * socketsperdetector) + '\n');
|
REQUIRE(oss.str() == "zmqport " +
|
||||||
|
std::to_string(port + i * socketsperdetector) +
|
||||||
|
'\n');
|
||||||
}
|
}
|
||||||
if (det_type == defs::JUNGFRAU) {
|
if (det_type == defs::JUNGFRAU) {
|
||||||
det.setNumberofUDPInterfaces(prev);
|
det.setNumberofUDPInterfaces(prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("txndelay", "[.cmd][.eiger][.jungfrau]") {
|
// TEST_CASE("txndelay", "[.cmd][.eiger][.jungfrau]") {
|
||||||
// if (test::type == defs::EIGER) {
|
// if (test::type == defs::EIGER) {
|
||||||
// {
|
// {
|
||||||
@ -2823,8 +2769,6 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
// REQUIRE_THROWS(multiSlsDetectorClient("numinterfaces 0", PUT));
|
// REQUIRE_THROWS(multiSlsDetectorClient("numinterfaces 0", PUT));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("adc", "[.cmd][.ctb]") {
|
// TEST_CASE("adc", "[.cmd][.ctb]") {
|
||||||
// if (test::type != defs::CHIPTESTBOARD) {
|
// if (test::type != defs::CHIPTESTBOARD) {
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("adc 8", GET));
|
// REQUIRE_THROWS(multiSlsDetectorClient("adc 8", GET));
|
||||||
@ -2838,9 +2782,6 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("syncclk", "[.cmd][.ctb]") {
|
// TEST_CASE("syncclk", "[.cmd][.ctb]") {
|
||||||
// if(test::type != defs::CHIPTESTBOARD) {
|
// if(test::type != defs::CHIPTESTBOARD) {
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("syncclk", GET));
|
// REQUIRE_THROWS(multiSlsDetectorClient("syncclk", GET));
|
||||||
@ -2934,8 +2875,6 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("threshold", "[.cmd]") {
|
// TEST_CASE("threshold", "[.cmd]") {
|
||||||
// if (test::type == defs::EIGER) {
|
// if (test::type == defs::EIGER) {
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("threshold 6400 standard",
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("threshold 6400 standard",
|
||||||
@ -2964,7 +2903,6 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
// CHECK_NOTHROW(multiSlsDetectorClient("type", GET));
|
// CHECK_NOTHROW(multiSlsDetectorClient("type", GET));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("status", "[.cmd]") {
|
// TEST_CASE("status", "[.cmd]") {
|
||||||
// Detector det;
|
// Detector det;
|
||||||
// CmdProxy proxy(&det);
|
// CmdProxy proxy(&det);
|
||||||
@ -2999,11 +2937,6 @@ TEST_CASE("zmqport", "[.cmd]") {
|
|||||||
// proxy.Call("frames", {"1"}, -1, PUT);
|
// proxy.Call("frames", {"1"}, -1, PUT);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("lock", "[.cmd]") {
|
TEST_CASE("lock", "[.cmd]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
@ -3027,8 +2960,3 @@ TEST_CASE("lock", "[.cmd]") {
|
|||||||
// TEST_CASE("lastclient", "[.cmd]") {
|
// TEST_CASE("lastclient", "[.cmd]") {
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("lastclient", GET));
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("lastclient", GET));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "Result.h"
|
#include "Result.h"
|
||||||
|
#include "ToString.h"
|
||||||
#include "TypeTraits.h"
|
#include "TypeTraits.h"
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "ToString.h"
|
|
||||||
|
|
||||||
using sls::Result;
|
using sls::Result;
|
||||||
|
|
||||||
@ -35,13 +35,12 @@ TEST_CASE("Like vector it can be constructed from size and value") {
|
|||||||
REQUIRE(res[4] == 7);
|
REQUIRE(res[4] == 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Result can be iterated using modern syntax"){
|
TEST_CASE("Result can be iterated using modern syntax") {
|
||||||
Result<int> res{0,1,2,3,4,5};
|
Result<int> res{0, 1, 2, 3, 4, 5};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto& r:res)
|
for (const auto &r : res)
|
||||||
REQUIRE(r == i++);
|
REQUIRE(r == i++);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Calling squash on an empty Result produces default value") {
|
TEST_CASE("Calling squash on an empty Result produces default value") {
|
||||||
@ -136,21 +135,20 @@ TEST_CASE("Convert from Result<int> to Result<ns>") {
|
|||||||
REQUIRE(res2[2] == ns(236));
|
REQUIRE(res2[2] == ns(236));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Result of vectors") {
|
||||||
TEST_CASE("Result of vectors"){
|
|
||||||
using VecVec = std::vector<std::vector<int>>;
|
using VecVec = std::vector<std::vector<int>>;
|
||||||
VecVec vecvec{{1,2,3}, {4,5,6}};
|
VecVec vecvec{{1, 2, 3}, {4, 5, 6}};
|
||||||
Result<VecVec> res{vecvec};
|
Result<VecVec> res{vecvec};
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Free function begin end"){
|
TEST_CASE("Free function begin end") {
|
||||||
Result<std::string> res{"ett", "nio", "sjutton"};
|
Result<std::string> res{"ett", "nio", "sjutton"};
|
||||||
REQUIRE(begin(res) == res.begin());
|
REQUIRE(begin(res) == res.begin());
|
||||||
REQUIRE(end(res) == res.end());
|
REQUIRE(end(res) == res.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Sorting a Result"){
|
TEST_CASE("Sorting a Result") {
|
||||||
Result<int> res{4,5,1,3};
|
Result<int> res{4, 5, 1, 3};
|
||||||
std::sort(res.begin(), res.end());
|
std::sort(res.begin(), res.end());
|
||||||
REQUIRE(res[0] == 1);
|
REQUIRE(res[0] == 1);
|
||||||
REQUIRE(res[1] == 3);
|
REQUIRE(res[1] == 3);
|
||||||
@ -158,24 +156,22 @@ TEST_CASE("Sorting a Result"){
|
|||||||
REQUIRE(res[3] == 5);
|
REQUIRE(res[3] == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing Result<std::string>"){
|
TEST_CASE("Printing Result<std::string>") {
|
||||||
Result<std::string> res{"ein", "zwei", "drei"};
|
Result<std::string> res{"ein", "zwei", "drei"};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << res;
|
os << res;
|
||||||
REQUIRE(os.str() == "[ein, zwei, drei]");
|
REQUIRE(os.str() == "[ein, zwei, drei]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Printing Result<int>"){
|
TEST_CASE("Printing Result<int>") {
|
||||||
Result<int> res{1, 2, 3};
|
Result<int> res{1, 2, 3};
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << res;
|
os << res;
|
||||||
REQUIRE(os.str() == "[1, 2, 3]");
|
REQUIRE(os.str() == "[1, 2, 3]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("String conversions"){
|
TEST_CASE("String conversions") {
|
||||||
Result<int> res{1,2,3};
|
Result<int> res{1, 2, 3};
|
||||||
REQUIRE(ToString(res) == "[1, 2, 3]");
|
REQUIRE(ToString(res) == "[1, 2, 3]");
|
||||||
|
|
||||||
Result<std::string> res2{"one", "two", "three"};
|
Result<std::string> res2{"one", "two", "three"};
|
||||||
@ -185,7 +181,7 @@ TEST_CASE("String conversions"){
|
|||||||
Smap m;
|
Smap m;
|
||||||
m["one"] = "1";
|
m["one"] = "1";
|
||||||
Result<Smap> res3{m, m, m};
|
Result<Smap> res3{m, m, m};
|
||||||
REQUIRE(res3.size()== 3);
|
REQUIRE(res3.size() == 3);
|
||||||
REQUIRE(ToString(res3) == "[{one: 1}, {one: 1}, {one: 1}]");
|
REQUIRE(ToString(res3) == "[{one: 1}, {one: 1}, {one: 1}]");
|
||||||
|
|
||||||
Smap m2;
|
Smap m2;
|
||||||
@ -194,5 +190,6 @@ TEST_CASE("String conversions"){
|
|||||||
m2["three"] = "3";
|
m2["three"] = "3";
|
||||||
|
|
||||||
Result<Smap> res4{m, m2, m};
|
Result<Smap> res4{m, m2, m};
|
||||||
REQUIRE(ToString(res4) == "[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
REQUIRE(ToString(res4) ==
|
||||||
|
"[{one: 1}, {one: 1, three: 3, two: 2}, {one: 1}]");
|
||||||
}
|
}
|
||||||
|
23
slsDetectorSoftware/tests/test-SharedMemory.cpp
Executable file → Normal file
23
slsDetectorSoftware/tests/test-SharedMemory.cpp
Executable file → Normal file
@ -64,24 +64,24 @@ TEST_CASE("Creating a second shared memory with the same name throws",
|
|||||||
|
|
||||||
TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
TEST_CASE("Open two shared memories to the same place", "[detector]") {
|
||||||
|
|
||||||
//Create the first shared memory
|
// Create the first shared memory
|
||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
shm.CreateSharedMemory();
|
shm.CreateSharedMemory();
|
||||||
shm()->x = 5;
|
shm()->x = 5;
|
||||||
CHECK(shm()->x == 5);
|
CHECK(shm()->x == 5);
|
||||||
|
|
||||||
//Open the second shared memory with the same name
|
// Open the second shared memory with the same name
|
||||||
SharedMemory<Data> shm2(shm_id, -1);
|
SharedMemory<Data> shm2(shm_id, -1);
|
||||||
shm2.OpenSharedMemory();
|
shm2.OpenSharedMemory();
|
||||||
CHECK(shm2()->x == 5);
|
CHECK(shm2()->x == 5);
|
||||||
CHECK(shm.GetName() == shm2.GetName());
|
CHECK(shm.GetName() == shm2.GetName());
|
||||||
|
|
||||||
//Check that they still point to the same place
|
// Check that they still point to the same place
|
||||||
shm2()->x = 7;
|
shm2()->x = 7;
|
||||||
CHECK(shm()->x == 7);
|
CHECK(shm()->x == 7);
|
||||||
|
|
||||||
//Remove only needs to be done once since they refer
|
// Remove only needs to be done once since they refer
|
||||||
//to the same memory
|
// to the same memory
|
||||||
shm2.RemoveSharedMemory();
|
shm2.RemoveSharedMemory();
|
||||||
CHECK(shm.IsExisting() == false);
|
CHECK(shm.IsExisting() == false);
|
||||||
CHECK(shm2.IsExisting() == false);
|
CHECK(shm2.IsExisting() == false);
|
||||||
@ -95,19 +95,18 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
|||||||
shm.CreateSharedMemory();
|
shm.CreateSharedMemory();
|
||||||
shm()->x = 9;
|
shm()->x = 9;
|
||||||
|
|
||||||
CHECK(shm.size()== sizeof(Data));
|
CHECK(shm.size() == sizeof(Data));
|
||||||
|
|
||||||
SharedMemory<Data> shm2(shm_id+1, -1);
|
SharedMemory<Data> shm2(shm_id + 1, -1);
|
||||||
shm2 = std::move(shm); //shm is now a moved from object!
|
shm2 = std::move(shm); // shm is now a moved from object!
|
||||||
|
|
||||||
CHECK(shm2()->x == 9);
|
CHECK(shm2()->x == 9);
|
||||||
CHECK(shm() == nullptr);
|
CHECK(shm() == nullptr);
|
||||||
CHECK(shm.size() == 0);
|
CHECK(shm.size() == 0);
|
||||||
|
|
||||||
CHECK(shm2.GetName() == std::string("/slsDetectorPackage_multi_") +
|
CHECK(shm2.GetName() ==
|
||||||
std::to_string(shm_id));
|
std::string("/slsDetectorPackage_multi_") + std::to_string(shm_id));
|
||||||
shm2.RemoveSharedMemory();
|
shm2.RemoveSharedMemory();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Create several shared memories", "[detector]") {
|
TEST_CASE("Create several shared memories", "[detector]") {
|
||||||
@ -115,7 +114,7 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
|||||||
std::vector<SharedMemory<int>> v;
|
std::vector<SharedMemory<int>> v;
|
||||||
v.reserve(N);
|
v.reserve(N);
|
||||||
for (int i = 0; i != N; ++i) {
|
for (int i = 0; i != N; ++i) {
|
||||||
v.emplace_back(shm_id+i, -1);
|
v.emplace_back(shm_id + i, -1);
|
||||||
CHECK(v[i].IsExisting() == false);
|
CHECK(v[i].IsExisting() == false);
|
||||||
v[i].CreateSharedMemory();
|
v[i].CreateSharedMemory();
|
||||||
*v[i]() = i;
|
*v[i]() = i;
|
||||||
|
9
slsDetectorSoftware/tests/test-slsDetector.cpp
Executable file → Normal file
9
slsDetectorSoftware/tests/test-slsDetector.cpp
Executable file → Normal file
@ -7,8 +7,6 @@
|
|||||||
// #include <algorithm>
|
// #include <algorithm>
|
||||||
// #include <iostream>
|
// #include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("Set and get trimen", "[detector]") {
|
// TEST_CASE("Set and get trimen", "[detector]") {
|
||||||
// // Free shared memory to be sure that we start in a clean state
|
// // Free shared memory to be sure that we start in a clean state
|
||||||
// slsDetector::freeSharedMemory(20, 20);
|
// slsDetector::freeSharedMemory(20, 20);
|
||||||
@ -188,12 +186,10 @@
|
|||||||
// d.setPartialFramesPadding(true);
|
// d.setPartialFramesPadding(true);
|
||||||
// CHECK(d.getPartialFramesPadding() == true);
|
// CHECK(d.getPartialFramesPadding() == true);
|
||||||
|
|
||||||
|
|
||||||
// d.freeSharedMemory();
|
// d.freeSharedMemory();
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("create detParamets struct", "[detector][new]"){
|
// TEST_CASE("create detParamets struct", "[detector][new]"){
|
||||||
// detParameters par;
|
// detParameters par;
|
||||||
// CHECK(sizeof(par) == 32);
|
// CHECK(sizeof(par) == 32);
|
||||||
@ -206,7 +202,6 @@
|
|||||||
// CHECK(par.nGappixelsX == 0);
|
// CHECK(par.nGappixelsX == 0);
|
||||||
// CHECK(par.nGappixelsY == 0);
|
// CHECK(par.nGappixelsY == 0);
|
||||||
|
|
||||||
|
|
||||||
// detParameters par2{slsDetectorDefs::detectorType::EIGER};
|
// detParameters par2{slsDetectorDefs::detectorType::EIGER};
|
||||||
// CHECK(sizeof(par2) == 32);
|
// CHECK(sizeof(par2) == 32);
|
||||||
// CHECK(par2.nChanX == 256);
|
// CHECK(par2.nChanX == 256);
|
||||||
@ -219,7 +214,6 @@
|
|||||||
// CHECK(par2.nGappixelsY == 1);
|
// CHECK(par2.nGappixelsY == 1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// TEST_CASE("ctb digital offset and list", "[detector][ctb]"){
|
// TEST_CASE("ctb digital offset and list", "[detector][ctb]"){
|
||||||
// slsDetector::freeSharedMemory(20, 20);
|
// slsDetector::freeSharedMemory(20, 20);
|
||||||
// slsDetector d(slsDetectorDefs::detectorType::CHIPTESTBOARD, 20, 20);
|
// slsDetector d(slsDetectorDefs::detectorType::CHIPTESTBOARD, 20, 20);
|
||||||
@ -235,7 +229,6 @@
|
|||||||
// std::vector <int> list = d.getReceiverDbitList();
|
// std::vector <int> list = d.getReceiverDbitList();
|
||||||
// CHECK(list.empty());
|
// CHECK(list.empty());
|
||||||
|
|
||||||
|
|
||||||
// for (int i = 0; i < 10; ++i)
|
// for (int i = 0; i < 10; ++i)
|
||||||
// list.push_back(i);
|
// list.push_back(i);
|
||||||
// d.setReceiverDbitList(list);
|
// d.setReceiverDbitList(list);
|
||||||
@ -258,6 +251,4 @@
|
|||||||
// d.setReceiverDbitList(list);
|
// d.setReceiverDbitList(list);
|
||||||
// CHECK(d.getReceiverDbitList().empty());
|
// CHECK(d.getReceiverDbitList().empty());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
// }
|
@ -1,12 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct SingleDetectorConfig {
|
struct SingleDetectorConfig {
|
||||||
slsDetectorDefs::detectorType type_enum = slsDetectorDefs::detectorType::EIGER;
|
slsDetectorDefs::detectorType type_enum =
|
||||||
|
slsDetectorDefs::detectorType::EIGER;
|
||||||
const std::string hostname = "beb031+beb032+";
|
const std::string hostname = "beb031+beb032+";
|
||||||
const std::string type_string = "Eiger";
|
const std::string type_string = "Eiger";
|
||||||
const std::string my_ip = "129.129.205.171";
|
const std::string my_ip = "129.129.205.171";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -12,5 +12,4 @@ extern std::string my_ip;
|
|||||||
extern decltype(defs::GET_ACTION) GET;
|
extern decltype(defs::GET_ACTION) GET;
|
||||||
extern decltype(defs::PUT_ACTION) PUT;
|
extern decltype(defs::PUT_ACTION) PUT;
|
||||||
|
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
enum class func_id{read_data, read_int, read_half_data, combined};
|
enum class func_id { read_data, read_int, read_half_data, combined };
|
||||||
constexpr size_t MB = 1048576;
|
constexpr size_t MB = 1048576;
|
||||||
constexpr size_t DATA_SIZE = 50*MB;
|
constexpr size_t DATA_SIZE = 50 * MB;
|
@ -39,7 +39,7 @@ void read_int(Interface &socket) {
|
|||||||
std::cout << "Read <int>: " << i << "\n";
|
std::cout << "Read <int>: " << i << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_combined(Interface &socket){
|
void read_combined(Interface &socket) {
|
||||||
auto i = socket.Receive<int>();
|
auto i = socket.Receive<int>();
|
||||||
auto d = socket.Receive<double>();
|
auto d = socket.Receive<double>();
|
||||||
auto f = socket.Receive<float>();
|
auto f = socket.Receive<float>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user