mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
more of sendToDetector
This commit is contained in:
parent
834b1e58ea
commit
dbf927901f
@ -4,9 +4,19 @@
|
|||||||
#include "tests/globals.h"
|
#include "tests/globals.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
TEST_CASE("Set and get dacs", "[.eigerintegration][cli]") {
|
class MultiDetectorFixture {
|
||||||
multiSlsDetector d(0, true, true);
|
protected:
|
||||||
d.setHostname(hostname.c_str());
|
multiSlsDetector d;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MultiDetectorFixture() : d(0, true, true) {
|
||||||
|
d.setHostname(hostname.c_str());
|
||||||
|
}
|
||||||
|
~MultiDetectorFixture() { d.freeSharedMemory(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Set and get dacs",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
auto th = 1000;
|
auto th = 1000;
|
||||||
|
|
||||||
// set and read back each individual dac of EIGER
|
// set and read back each individual dac of EIGER
|
||||||
@ -64,14 +74,10 @@ TEST_CASE("Set and get dacs", "[.eigerintegration][cli]") {
|
|||||||
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 0) == -1);
|
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 0) == -1);
|
||||||
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 1) == -1);
|
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 1) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
d.freeSharedMemory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Read temperatures", "[.eigerintegration][cli]") {
|
TEST_CASE_METHOD(MultiDetectorFixture, "Read temperatures",
|
||||||
multiSlsDetector d(0, true, true);
|
"[.eigerintegration][cli]") {
|
||||||
d.setHostname(hostname.c_str());
|
|
||||||
|
|
||||||
std::vector<di> tempindex{di::TEMPERATURE_FPGA, di::TEMPERATURE_FPGA2,
|
std::vector<di> tempindex{di::TEMPERATURE_FPGA, di::TEMPERATURE_FPGA2,
|
||||||
di::TEMPERATURE_FPGA3};
|
di::TEMPERATURE_FPGA3};
|
||||||
for (auto index : tempindex) {
|
for (auto index : tempindex) {
|
||||||
@ -83,19 +89,15 @@ TEST_CASE("Read temperatures", "[.eigerintegration][cli]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int to_time(uint32_t reg){
|
int to_time(uint32_t reg) {
|
||||||
uint32_t clocks = reg >> 3;
|
uint32_t clocks = reg >> 3;
|
||||||
uint32_t exponent = (reg & 0b111)+1;
|
uint32_t exponent = (reg & 0b111) + 1;
|
||||||
return clocks*pow(10, exponent);
|
return clocks * pow(10, exponent);
|
||||||
// clocks = register >> 3
|
|
||||||
// exponent = register & 0b111
|
|
||||||
// return clocks*10**exponent / 100e6
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Read/write register", "[.eigerintegration][cli]"){
|
TEST_CASE_METHOD(MultiDetectorFixture, "Read/write register",
|
||||||
multiSlsDetector d(0, true, true);
|
"[.eigerintegration][cli]") {
|
||||||
d.setHostname(hostname.c_str());
|
d.setTimer(ti::MEASUREMENTS_NUMBER, 1);
|
||||||
|
|
||||||
d.setNumberOfFrames(1);
|
d.setNumberOfFrames(1);
|
||||||
d.setExposureTime(10000);
|
d.setExposureTime(10000);
|
||||||
d.acquire();
|
d.acquire();
|
||||||
@ -103,5 +105,83 @@ TEST_CASE("Read/write register", "[.eigerintegration][cli]"){
|
|||||||
|
|
||||||
d.writeRegister(0x4, 500);
|
d.writeRegister(0x4, 500);
|
||||||
CHECK(d.readRegister(0x4) == 500);
|
CHECK(d.readRegister(0x4) == 500);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Set dynamic range",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
|
std::vector<int> dynamic_range{4, 8, 16, 32};
|
||||||
|
for (auto dr : dynamic_range) {
|
||||||
|
d.setDynamicRange(dr);
|
||||||
|
CHECK(d.setDynamicRange() == dr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Set clock divider",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
|
for (int i = 0; i != 3; ++i) {
|
||||||
|
d.setSpeed(sv::CLOCK_DIVIDER, i);
|
||||||
|
CHECK(d.setSpeed(sv::CLOCK_DIVIDER) == i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Get time left",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
|
CHECK_THROWS(d.getTimeLeft(ti::PROGRESS));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Get ID", "[.eigerintegration][cli]") {
|
||||||
|
std::string hn = hostname;
|
||||||
|
hn.erase(std::remove(begin(hn), end(hn), 'b'), end(hn));
|
||||||
|
hn.erase(std::remove(begin(hn), end(hn), 'e'), end(hn));
|
||||||
|
auto hostnames = sls::split(hn, '+');
|
||||||
|
CHECK(hostnames.size() == d.getNumberOfDetectors());
|
||||||
|
for (int i = 0; i != d.getNumberOfDetectors(); ++i) {
|
||||||
|
CHECK(d.getId(defs::DETECTOR_SERIAL_NUMBER, 0) ==
|
||||||
|
std::stoi(hostnames[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Lock server",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
|
|
||||||
|
d.lockServer(1);
|
||||||
|
CHECK(d.lockServer() == 1);
|
||||||
|
d.lockServer(0);
|
||||||
|
CHECK(d.lockServer() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Settings", "[.eigerintegration][cli]") {
|
||||||
|
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Set readout flags",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
|
d.setReadOutFlags(defs::PARALLEL);
|
||||||
|
CHECK((d.setReadOutFlags() & defs::PARALLEL));
|
||||||
|
|
||||||
|
d.setReadOutFlags(defs::NONPARALLEL);
|
||||||
|
CHECK_FALSE((d.setReadOutFlags() & defs::PARALLEL));
|
||||||
|
CHECK((d.setReadOutFlags() & defs::NONPARALLEL));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "Flow control 10gbe",
|
||||||
|
"[.eigerintegration][cli]") {
|
||||||
|
d.setFlowControl10G(1);
|
||||||
|
CHECK(d.setFlowControl10G() == 1);
|
||||||
|
d.setFlowControl10G(0);
|
||||||
|
CHECK(d.setFlowControl10G() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "activate", "[.eigerintegration][cli]") {
|
||||||
|
d.activate(0);
|
||||||
|
CHECK(d.activate() == 0);
|
||||||
|
d.activate(1);
|
||||||
|
CHECK(d.activate() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CASE_METHOD(MultiDetectorFixture, "all trimbits", "[.eigerintegration][cli]") {
|
||||||
|
d.setAllTrimbits(32);
|
||||||
|
CHECK(d.setAllTrimbits(-1) == 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,14 @@
|
|||||||
|
|
||||||
// Header holding all configurations for different detectors
|
// Header holding all configurations for different detectors
|
||||||
#include "tests/config.h"
|
#include "tests/config.h"
|
||||||
|
#include "tests/globals.h"
|
||||||
|
|
||||||
using dt = slsDetectorDefs::detectorType;
|
// using dt = slsDetectorDefs::detectorType;
|
||||||
extern std::string hostname;
|
// extern std::string hostname;
|
||||||
extern std::string detector_type;
|
// extern std::string detector_type;
|
||||||
extern dt type;
|
// extern dt type;
|
||||||
|
|
||||||
TEST_CASE("Single detector no receiver", "[.integration][cli]") {
|
TEST_CASE("Single detector no receiver", "[.integration][.single]") {
|
||||||
auto t = slsDetector::getTypeFromDetector(hostname);
|
auto t = slsDetector::getTypeFromDetector(hostname);
|
||||||
CHECK(t == type);
|
CHECK(t == type);
|
||||||
|
|
||||||
@ -35,9 +36,57 @@ TEST_CASE("Single detector no receiver", "[.integration][cli]") {
|
|||||||
d.setOnline(true);
|
d.setOnline(true);
|
||||||
CHECK(d.getOnlineFlag() == true);
|
CHECK(d.getOnlineFlag() == true);
|
||||||
|
|
||||||
|
CHECK(d.setDetectorType() == type);
|
||||||
|
|
||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Set control port then create a new object with this control port",
|
||||||
|
"[.integration][.single]") {
|
||||||
|
/*
|
||||||
|
TODO!
|
||||||
|
Standard port but should not be hardcoded
|
||||||
|
Is this the best way to initialize the detectors
|
||||||
|
Using braces to make the object go out of scope
|
||||||
|
*/
|
||||||
|
int old_cport = DEFAULT_PORTNO;
|
||||||
|
int old_sport = DEFAULT_PORTNO + 1;
|
||||||
|
int new_cport = 1993;
|
||||||
|
int new_sport = 2000;
|
||||||
|
{
|
||||||
|
slsDetector d(type);
|
||||||
|
d.setHostname(hostname);
|
||||||
|
d.setOnline(true);
|
||||||
|
CHECK(d.getControlPort() == old_cport);
|
||||||
|
d.setControlPort(new_cport);
|
||||||
|
CHECK(d.getStopPort() == old_sport);
|
||||||
|
d.setStopPort(new_sport);
|
||||||
|
d.freeSharedMemory();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
slsDetector d(type);
|
||||||
|
d.setHostname(hostname);
|
||||||
|
d.setControlPort(new_cport);
|
||||||
|
d.setStopPort(new_sport);
|
||||||
|
CHECK(d.getControlPort() == new_cport);
|
||||||
|
CHECK(d.getStopPort() == new_sport);
|
||||||
|
|
||||||
|
d.setOnline(true);
|
||||||
|
|
||||||
|
// Reset standard ports
|
||||||
|
d.setControlPort(old_cport);
|
||||||
|
d.setStopPort(old_sport);
|
||||||
|
d.freeSharedMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
slsDetector d(type);
|
||||||
|
d.setHostname(hostname);
|
||||||
|
d.setOnline(true);
|
||||||
|
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
|
||||||
|
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
|
||||||
@ -91,63 +140,11 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
|
|||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Set control port then create a new object with this control port",
|
|
||||||
"[.integration]") {
|
|
||||||
/*
|
|
||||||
TODO!
|
|
||||||
Standard port but should not be hardcoded
|
|
||||||
Is this the best way to initialize the detectors
|
|
||||||
Using braces to make the object go out of scope
|
|
||||||
*/
|
|
||||||
int old_cport = DEFAULT_PORTNO;
|
|
||||||
int old_sport = DEFAULT_PORTNO + 1;
|
|
||||||
int new_cport = 1993;
|
|
||||||
int new_sport = 2000;
|
|
||||||
SingleDetectorConfig c;
|
|
||||||
{
|
|
||||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
|
||||||
CHECK(type == c.type_enum);
|
|
||||||
slsDetector d(type);
|
|
||||||
d.setHostname(c.hostname);
|
|
||||||
d.setOnline(true);
|
|
||||||
CHECK(d.getControlPort() == old_cport);
|
|
||||||
d.setControlPort(new_cport);
|
|
||||||
CHECK(d.getStopPort() == old_sport);
|
|
||||||
d.setStopPort(new_sport);
|
|
||||||
d.freeSharedMemory();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
auto type = slsDetector::getTypeFromDetector(c.hostname, new_cport);
|
|
||||||
CHECK(type == c.type_enum);
|
|
||||||
slsDetector d(type);
|
|
||||||
d.setHostname(c.hostname);
|
|
||||||
d.setControlPort(new_cport);
|
|
||||||
d.setStopPort(new_sport);
|
|
||||||
CHECK(d.getControlPort() == new_cport);
|
|
||||||
CHECK(d.getStopPort() == new_sport);
|
|
||||||
|
|
||||||
d.setOnline(true);
|
|
||||||
|
|
||||||
// Reset standard ports
|
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
||||||
d.setControlPort(old_cport);
|
|
||||||
d.setStopPort(old_sport);
|
|
||||||
d.freeSharedMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
|
||||||
CHECK(type == c.type_enum);
|
|
||||||
slsDetector d(type);
|
slsDetector d(type);
|
||||||
d.setHostname(c.hostname);
|
d.setHostname(hostname);
|
||||||
d.setOnline(true);
|
|
||||||
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
|
|
||||||
d.freeSharedMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("Locking mechanism and last ip", "[.integration]") {
|
|
||||||
SingleDetectorConfig c;
|
|
||||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
|
||||||
slsDetector d(type);
|
|
||||||
d.setHostname(c.hostname);
|
|
||||||
d.setOnline(true);
|
d.setOnline(true);
|
||||||
|
|
||||||
// Check that detector server is unlocked then lock
|
// Check that detector server is unlocked then lock
|
||||||
@ -164,10 +161,18 @@ TEST_CASE("Locking mechanism and last ip", "[.integration]") {
|
|||||||
d.lockServer(0);
|
d.lockServer(0);
|
||||||
CHECK(d.lockServer() == 0);
|
CHECK(d.lockServer() == 0);
|
||||||
|
|
||||||
CHECK(d.getLastClientIP() == c.my_ip);
|
CHECK(d.getLastClientIP() == my_ip);
|
||||||
d.freeSharedMemory();
|
d.freeSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Set settings", "[.integration][.single]"){
|
||||||
|
slsDetector d(type);
|
||||||
|
d.setHostname(hostname);
|
||||||
|
d.setOnline(true);
|
||||||
|
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 cycles */ ACQUISITION_TIME,
|
// acquisitions is number or frames*number of cycles */ ACQUISITION_TIME,
|
||||||
|
@ -139,10 +139,6 @@ int slsDetector::checkReceiverVersionCompatibility() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int64_t slsDetector::getId(idMode mode) {
|
int64_t slsDetector::getId(idMode mode) {
|
||||||
int arg = static_cast<int>(mode);
|
|
||||||
int64_t retval = -1;
|
|
||||||
FILE_LOG(logDEBUG1) << "Getting id type " << mode;
|
|
||||||
|
|
||||||
// These should not go to detector...
|
// These should not go to detector...
|
||||||
assert(mode != THIS_SOFTWARE_VERSION);
|
assert(mode != THIS_SOFTWARE_VERSION);
|
||||||
assert(mode != RECEIVER_VERSION);
|
assert(mode != RECEIVER_VERSION);
|
||||||
@ -150,17 +146,13 @@ int64_t slsDetector::getId(idMode mode) {
|
|||||||
assert(mode != CLIENT_RECEIVER_API_VERSION);
|
assert(mode != CLIENT_RECEIVER_API_VERSION);
|
||||||
|
|
||||||
int fnum = F_GET_ID;
|
int fnum = F_GET_ID;
|
||||||
int ret = FAIL;
|
int arg = static_cast<int>(mode);
|
||||||
|
int64_t retval = -1;
|
||||||
|
FILE_LOG(logDEBUG1) << "Getting id type " << mode;
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
FILE_LOG(logDEBUG1)
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
<< "Id (" << mode << "): 0x" << std::hex << retval << std::dec;
|
||||||
sizeof(retval));
|
|
||||||
}
|
|
||||||
FILE_LOG(logDEBUG1) << "Id (" << mode << "): 0x" << std::hex << retval
|
|
||||||
<< std::dec;
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -497,16 +489,10 @@ int slsDetector::setDetectorType(detectorType const type) {
|
|||||||
// if unspecified, then get from detector
|
// if unspecified, then get from detector
|
||||||
if (type == GET_DETECTOR_TYPE) {
|
if (type == GET_DETECTOR_TYPE) {
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
detector_shm()->myDetectorType = static_cast<detectorType>(retval);
|
detector_shm()->myDetectorType = static_cast<detectorType>(retval);
|
||||||
FILE_LOG(logDEBUG1) << "Detector Type: " << retval;
|
FILE_LOG(logDEBUG1) << "Detector Type: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
@ -619,7 +605,6 @@ int slsDetector::setOnline(int value) {
|
|||||||
detector_shm()->onlineFlag = OFFLINE_FLAG;
|
detector_shm()->onlineFlag = OFFLINE_FLAG;
|
||||||
|
|
||||||
if (value == ONLINE_FLAG) {
|
if (value == ONLINE_FLAG) {
|
||||||
|
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
auto client = DetectorSocket(detector_shm()->hostname,
|
||||||
detector_shm()->controlPort);
|
detector_shm()->controlPort);
|
||||||
client.close();
|
client.close();
|
||||||
@ -661,26 +646,18 @@ std::string slsDetector::checkOnline() {
|
|||||||
|
|
||||||
int slsDetector::setControlPort(int port_number) {
|
int slsDetector::setControlPort(int port_number) {
|
||||||
int fnum = F_SET_PORT;
|
int fnum = F_SET_PORT;
|
||||||
int ret = FAIL;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting control port to " << port_number;
|
FILE_LOG(logDEBUG1) << "Setting control port to " << port_number;
|
||||||
|
|
||||||
if (port_number >= 0 && port_number != detector_shm()->controlPort) {
|
if (port_number >= 0 && port_number != detector_shm()->controlPort) {
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &port_number, sizeof(port_number), &retval,
|
||||||
detector_shm()->controlPort);
|
sizeof(retval));
|
||||||
ret = client.sendCommandThenRead(fnum, &port_number,
|
|
||||||
sizeof(port_number), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
detector_shm()->controlPort = retval;
|
detector_shm()->controlPort = retval;
|
||||||
FILE_LOG(logDEBUG1) << "Control port: " << retval;
|
FILE_LOG(logDEBUG1) << "Control port: " << retval;
|
||||||
} else {
|
} else {
|
||||||
detector_shm()->controlPort = port_number;
|
detector_shm()->controlPort = port_number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return detector_shm()->controlPort;
|
return detector_shm()->controlPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,39 +724,24 @@ int slsDetector::getStopPort() const { return detector_shm()->stopPort; }
|
|||||||
|
|
||||||
int slsDetector::lockServer(int lock) {
|
int slsDetector::lockServer(int lock) {
|
||||||
int fnum = F_LOCK_SERVER;
|
int fnum = F_LOCK_SERVER;
|
||||||
int ret = FAIL;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting detector server lock to " << lock;
|
FILE_LOG(logDEBUG1) << "Setting detector server lock to " << lock;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &lock, sizeof(lock), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &lock, sizeof(lock), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Lock: " << retval;
|
FILE_LOG(logDEBUG1) << "Lock: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string slsDetector::getLastClientIP() {
|
std::string slsDetector::getLastClientIP() {
|
||||||
int fnum = F_GET_LAST_CLIENT_IP;
|
int fnum = F_GET_LAST_CLIENT_IP;
|
||||||
int ret = FAIL;
|
|
||||||
char retval[INET_ADDRSTRLEN]{};
|
char retval[INET_ADDRSTRLEN]{};
|
||||||
FILE_LOG(logDEBUG1) << "Getting last client ip to detector server";
|
FILE_LOG(logDEBUG1) << "Getting last client ip to detector server";
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Last client IP to detector: " << retval;
|
FILE_LOG(logDEBUG1) << "Last client IP to detector: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,16 +762,12 @@ int slsDetector::exitServer() {
|
|||||||
int slsDetector::execCommand(const std::string &cmd) {
|
int slsDetector::execCommand(const std::string &cmd) {
|
||||||
int fnum = F_EXEC_COMMAND;
|
int fnum = F_EXEC_COMMAND;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char arg[MAX_STR_LENGTH] = {};
|
char arg[MAX_STR_LENGTH]{};
|
||||||
char retval[MAX_STR_LENGTH] = {};
|
char retval[MAX_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(arg, cmd.c_str());
|
sls::strcpy_safe(arg, cmd.c_str());
|
||||||
FILE_LOG(logDEBUG1) << "Sending command to detector " << arg;
|
FILE_LOG(logDEBUG1) << "Sending command to detector " << arg;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, arg, sizeof(arg), retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, arg, sizeof(arg), retval,
|
|
||||||
sizeof(retval));
|
|
||||||
if (strlen(retval) != 0u) {
|
if (strlen(retval) != 0u) {
|
||||||
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n"
|
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n"
|
||||||
<< retval;
|
<< retval;
|
||||||
@ -1115,22 +1073,15 @@ slsDetector::setSettings(detectorSettings isettings) {
|
|||||||
slsDetectorDefs::detectorSettings
|
slsDetectorDefs::detectorSettings
|
||||||
slsDetector::sendSettingsOnly(detectorSettings isettings) {
|
slsDetector::sendSettingsOnly(detectorSettings isettings) {
|
||||||
int fnum = F_SET_SETTINGS;
|
int fnum = F_SET_SETTINGS;
|
||||||
int ret = FAIL;
|
|
||||||
int arg = static_cast<int>(isettings);
|
int arg = static_cast<int>(isettings);
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting settings to " << arg;
|
FILE_LOG(logDEBUG1) << "Setting settings to " << arg;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Settings: " << retval;
|
FILE_LOG(logDEBUG1) << "Settings: " << retval;
|
||||||
detector_shm()->currentSettings = static_cast<detectorSettings>(retval);
|
detector_shm()->currentSettings = static_cast<detectorSettings>(retval);
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return detector_shm()->currentSettings;
|
return detector_shm()->currentSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1153,22 +1104,14 @@ int slsDetector::getThresholdEnergy() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int fnum = F_GET_THRESHOLD_ENERGY;
|
|
||||||
int ret = FAIL;
|
|
||||||
int retval = -1;
|
|
||||||
FILE_LOG(logDEBUG1) << "Getting threshold energy";
|
FILE_LOG(logDEBUG1) << "Getting threshold energy";
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
int fnum = F_GET_THRESHOLD_ENERGY;
|
||||||
detector_shm()->controlPort);
|
int retval = -1;
|
||||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, &retval,
|
sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Threshold: " << retval;
|
FILE_LOG(logDEBUG1) << "Threshold: " << retval;
|
||||||
detector_shm()->currentThresholdEV = retval;
|
detector_shm()->currentThresholdEV = retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return detector_shm()->currentThresholdEV;
|
return detector_shm()->currentThresholdEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1630,10 +1573,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
|||||||
// send to detector
|
// send to detector
|
||||||
int64_t oldtimer = detector_shm()->timerValue[index];
|
int64_t oldtimer = detector_shm()->timerValue[index];
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval;
|
FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval;
|
||||||
detector_shm()->timerValue[index] = retval;
|
detector_shm()->timerValue[index] = retval;
|
||||||
// update #nchans and databytes, as it depends on #samples, roi,
|
// update #nchans and databytes, as it depends on #samples, roi,
|
||||||
@ -1643,10 +1583,6 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
|||||||
detector_shm()->myDetectorType == MOENCH)) {
|
detector_shm()->myDetectorType == MOENCH)) {
|
||||||
updateTotalNumberOfChannels();
|
updateTotalNumberOfChannels();
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
client.close();
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setting timers consequences (eiger (ratecorr) )
|
// setting timers consequences (eiger (ratecorr) )
|
||||||
@ -1666,7 +1602,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send to reciever
|
// send to reciever
|
||||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG && ret == OK) {
|
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG && ret != FAIL) {
|
||||||
auto receiver = ReceiverSocket(detector_shm()->receiver_hostname,
|
auto receiver = ReceiverSocket(detector_shm()->receiver_hostname,
|
||||||
detector_shm()->receiverTCPPort);
|
detector_shm()->receiverTCPPort);
|
||||||
// char mess[MAX_STR_LENGTH]{};
|
// char mess[MAX_STR_LENGTH]{};
|
||||||
@ -1739,22 +1675,15 @@ int64_t slsDetector::getTimeLeft(timerIndex index) {
|
|||||||
|
|
||||||
int slsDetector::setSpeed(speedVariable sp, int value, int mode) {
|
int slsDetector::setSpeed(speedVariable sp, int value, int mode) {
|
||||||
int fnum = F_SET_SPEED;
|
int fnum = F_SET_SPEED;
|
||||||
int ret = FAIL;
|
|
||||||
int args[]{static_cast<int>(sp), value, mode};
|
int args[]{static_cast<int>(sp), value, mode};
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting speed index " << sp << " to " << value
|
FILE_LOG(logDEBUG1) << "Setting speed index " << sp << " to " << value
|
||||||
<< " mode: " << mode;
|
<< " mode: " << mode;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Speed index " << sp << ": " << retval;
|
FILE_LOG(logDEBUG1) << "Speed index " << sp << ": " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1765,20 +1694,12 @@ int slsDetector::setDynamicRange(int n) {
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n;
|
FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n;
|
||||||
|
|
||||||
// send to detector
|
|
||||||
int olddr = detector_shm()->dynamicRange;
|
int olddr = detector_shm()->dynamicRange;
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
// char mess[MAX_STR_LENGTH] = {};
|
sendToDetector(fnum, &n, sizeof(n), &retval, sizeof(retval));
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &n, sizeof(n), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Dynamic Range: " << retval;
|
FILE_LOG(logDEBUG1) << "Dynamic Range: " << retval;
|
||||||
detector_shm()->dynamicRange = retval;
|
detector_shm()->dynamicRange = retval;
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
client.close();
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// only for eiger
|
// only for eiger
|
||||||
@ -1838,15 +1759,15 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int slsDetector::sendToDetector(int fnum, void *args, size_t args_size,
|
||||||
int slsDetector::sendToDetector(int fnum, void* args, size_t args_size, void* retval, size_t retval_size)
|
void *retval, size_t retval_size) {
|
||||||
{
|
auto client =
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
|
||||||
detector_shm()->controlPort);
|
auto ret =
|
||||||
auto ret = client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
client.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||||
client.close();
|
client.close();
|
||||||
if (ret == FORCE_UPDATE) {
|
if (ret == FORCE_UPDATE) {
|
||||||
updateDetector();
|
ret = updateDetector();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1912,10 +1833,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
|
|||||||
FILE_LOG(logDEBUG1) << "Setting readout flags to " << flag;
|
FILE_LOG(logDEBUG1) << "Setting readout flags to " << flag;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Readout flag: " << retval;
|
FILE_LOG(logDEBUG1) << "Readout flag: " << retval;
|
||||||
detector_shm()->roFlags = retval;
|
detector_shm()->roFlags = retval;
|
||||||
// update #nchans and databytes, as it depends on #samples, roi,
|
// update #nchans and databytes, as it depends on #samples, roi,
|
||||||
@ -1924,9 +1842,6 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
|
|||||||
updateTotalNumberOfChannels();
|
updateTotalNumberOfChannels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
|
||||||
|
|
||||||
// sending to receiver
|
// sending to receiver
|
||||||
if (ret != FAIL) {
|
if (ret != FAIL) {
|
||||||
@ -2448,23 +2363,16 @@ std::string slsDetector::getReceiverStreamingIP() {
|
|||||||
int slsDetector::setDetectorNetworkParameter(networkParameter index,
|
int slsDetector::setDetectorNetworkParameter(networkParameter index,
|
||||||
int delay) {
|
int delay) {
|
||||||
int fnum = F_SET_NETWORK_PARAMETER;
|
int fnum = F_SET_NETWORK_PARAMETER;
|
||||||
int ret = FAIL;
|
|
||||||
int args[2]{static_cast<int>(index), delay};
|
int args[2]{static_cast<int>(index), delay};
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to "
|
FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to "
|
||||||
<< delay;
|
<< delay;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
<< "Network Parameter (" << index << "): " << retval;
|
<< "Network Parameter (" << index << "): " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2728,22 +2636,15 @@ int slsDetector::setUDPConnection() {
|
|||||||
|
|
||||||
int slsDetector::digitalTest(digitalTestMode mode, int ival) {
|
int slsDetector::digitalTest(digitalTestMode mode, int ival) {
|
||||||
int fnum = F_DIGITAL_TEST;
|
int fnum = F_DIGITAL_TEST;
|
||||||
int ret = FAIL;
|
int args[]{static_cast<int>(mode), ival};
|
||||||
int args[2]{static_cast<int>(mode), ival};
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Sending digital test of mode " << mode << ", ival "
|
FILE_LOG(logDEBUG1) << "Sending digital test of mode " << mode << ", ival "
|
||||||
<< ival;
|
<< ival;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Digital Test returned: " << retval;
|
FILE_LOG(logDEBUG1) << "Digital Test returned: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2810,17 +2711,12 @@ int slsDetector::getCounterBlock(int16_t image[], int startACQ) {
|
|||||||
int fnum = F_READ_COUNTER_BLOCK;
|
int fnum = F_READ_COUNTER_BLOCK;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int nChan = getTotalNumberOfChannels();
|
int nChan = getTotalNumberOfChannels();
|
||||||
int args[2] = {startACQ, nChan};
|
int args[] = {startACQ, nChan};
|
||||||
FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ;
|
FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, args, sizeof(args), image,
|
||||||
detector_shm()->controlPort);
|
nChan * sizeof(int16_t));
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), image,
|
|
||||||
nChan * sizeof(int16_t));
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2830,35 +2726,20 @@ int slsDetector::resetCounterBlock(int startACQ) {
|
|||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int arg = startACQ;
|
int arg = startACQ;
|
||||||
FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ;
|
FILE_LOG(logDEBUG1) << "Resetting Counter with startacq: " << startACQ;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, &arg, sizeof(arg), nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::setCounterBit(int i) {
|
int slsDetector::setCounterBit(int i) {
|
||||||
int fnum = F_SET_COUNTER_BIT;
|
int fnum = F_SET_COUNTER_BIT;
|
||||||
int ret = FAIL;
|
|
||||||
int arg = i;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Sending counter bit " << arg;
|
FILE_LOG(logDEBUG1) << "Sending counter bit " << i;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &i, sizeof(i), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Counter bit: " << retval;
|
FILE_LOG(logDEBUG1) << "Counter bit: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3022,12 +2903,7 @@ int slsDetector::writeAdcRegister(uint32_t addr, uint32_t val) {
|
|||||||
<< "data: 0x" << std::hex << val << std::dec;
|
<< "data: 0x" << std::hex << val << std::dec;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, args, sizeof(args), nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3041,16 +2917,10 @@ int slsDetector::activate(int enable) {
|
|||||||
|
|
||||||
// detector
|
// detector
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, &arg, sizeof(arg), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Activate: " << retval;
|
FILE_LOG(logDEBUG1) << "Activate: " << retval;
|
||||||
detector_shm()->activated = static_cast<bool>(retval);
|
detector_shm()->activated = static_cast<bool>(retval);
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
|
||||||
|
|
||||||
// receiver
|
// receiver
|
||||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG && ret == OK) {
|
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG && ret == OK) {
|
||||||
@ -3131,21 +3001,12 @@ int slsDetector::setFlippedData(dimension d, int value) {
|
|||||||
|
|
||||||
int slsDetector::setAllTrimbits(int val) {
|
int slsDetector::setAllTrimbits(int val) {
|
||||||
int fnum = F_SET_ALL_TRIMBITS;
|
int fnum = F_SET_ALL_TRIMBITS;
|
||||||
int ret = FAIL;
|
|
||||||
int arg = val;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting all trimbits to " << val;
|
FILE_LOG(logDEBUG1) << "Setting all trimbits to " << val;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &val, sizeof(val), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "All trimbit value: " << retval;
|
FILE_LOG(logDEBUG1) << "All trimbit value: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3213,17 +3074,11 @@ std::vector<int> slsDetector::getTrimEn() {
|
|||||||
int slsDetector::pulsePixel(int n, int x, int y) {
|
int slsDetector::pulsePixel(int n, int x, int y) {
|
||||||
int fnum = F_PULSE_PIXEL;
|
int fnum = F_PULSE_PIXEL;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int args[3] = {n, x, y};
|
int args[]{n, x, y};
|
||||||
FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times at (" << x
|
FILE_LOG(logDEBUG1) << "Pulsing pixel " << n << " number of times at (" << x
|
||||||
<< "," << y << ")";
|
<< "," << y << ")";
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, args, sizeof(args), nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3231,18 +3086,12 @@ int slsDetector::pulsePixel(int n, int x, int y) {
|
|||||||
int slsDetector::pulsePixelNMove(int n, int x, int y) {
|
int slsDetector::pulsePixelNMove(int n, int x, int y) {
|
||||||
int fnum = F_PULSE_PIXEL_AND_MOVE;
|
int fnum = F_PULSE_PIXEL_AND_MOVE;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int args[3] = {n, x, y};
|
int args[]{n, x, y};
|
||||||
FILE_LOG(logDEBUG1) << "Pulsing pixel " << n
|
FILE_LOG(logDEBUG1) << "Pulsing pixel " << n
|
||||||
<< " number of times and move by delta (" << x << ","
|
<< " number of times and move by delta (" << x << ","
|
||||||
<< y << ")";
|
<< y << ")";
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, args, sizeof(args), nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3250,16 +3099,9 @@ int slsDetector::pulsePixelNMove(int n, int x, int y) {
|
|||||||
int slsDetector::pulseChip(int n) {
|
int slsDetector::pulseChip(int n) {
|
||||||
int fnum = F_PULSE_CHIP;
|
int fnum = F_PULSE_CHIP;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int arg = n;
|
|
||||||
FILE_LOG(logDEBUG1) << "Pulsing chip " << n << " number of times";
|
FILE_LOG(logDEBUG1) << "Pulsing chip " << n << " number of times";
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, &n, sizeof(n), nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), nullptr, 0);
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3317,21 +3159,12 @@ int slsDetector::setTemperatureEvent(int val) {
|
|||||||
|
|
||||||
int slsDetector::setStoragecellStart(int pos) {
|
int slsDetector::setStoragecellStart(int pos) {
|
||||||
int fnum = F_STORAGE_CELL_START;
|
int fnum = F_STORAGE_CELL_START;
|
||||||
int ret = FAIL;
|
|
||||||
int arg = pos;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting storage cell start to " << pos;
|
FILE_LOG(logDEBUG1) << "Setting storage cell start to " << pos;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &pos, sizeof(pos), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Storage cell start: " << retval;
|
FILE_LOG(logDEBUG1) << "Storage cell start: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3445,12 +3278,7 @@ int slsDetector::resetFPGA() {
|
|||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
FILE_LOG(logDEBUG1) << "Sending reset FPGA";
|
FILE_LOG(logDEBUG1) << "Sending reset FPGA";
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, nullptr, 0, nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
|
||||||
}
|
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
ret = updateDetector();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3459,15 +3287,13 @@ int slsDetector::copyDetectorServer(const std::string &fname,
|
|||||||
const std::string &hostname) {
|
const std::string &hostname) {
|
||||||
int fnum = F_COPY_DET_SERVER;
|
int fnum = F_COPY_DET_SERVER;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
char args[2][MAX_STR_LENGTH] = {};
|
char args[][MAX_STR_LENGTH]{};
|
||||||
sls::strcpy_safe(args[0], fname.c_str());
|
sls::strcpy_safe(args[0], fname.c_str());
|
||||||
sls::strcpy_safe(args[1], hostname.c_str());
|
sls::strcpy_safe(args[1], hostname.c_str());
|
||||||
FILE_LOG(logINFO) << "Sending detector server " << args[0] << " from host "
|
FILE_LOG(logINFO) << "Sending detector server " << args[0] << " from host "
|
||||||
<< args[1];
|
<< args[1];
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
ret = sendToDetector(fnum, args, sizeof(args), nullptr, 0);
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3493,45 +3319,26 @@ int slsDetector::rebootController() {
|
|||||||
|
|
||||||
int slsDetector::powerChip(int ival) {
|
int slsDetector::powerChip(int ival) {
|
||||||
int fnum = F_POWER_CHIP;
|
int fnum = F_POWER_CHIP;
|
||||||
int ret = FAIL;
|
|
||||||
int arg = ival;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting power chip to " << ival;
|
FILE_LOG(logDEBUG1) << "Setting power chip to " << ival;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &ival, sizeof(ival), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Power chip: " << retval;
|
FILE_LOG(logDEBUG1) << "Power chip: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::setAutoComparatorDisableMode(int ival) {
|
int slsDetector::setAutoComparatorDisableMode(int ival) {
|
||||||
int fnum = F_AUTO_COMP_DISABLE;
|
int fnum = F_AUTO_COMP_DISABLE;
|
||||||
int ret = FAIL;
|
|
||||||
int arg = ival;
|
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting auto comp disable mode to " << ival;
|
FILE_LOG(logDEBUG1) << "Setting auto comp disable mode to " << ival;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
sendToDetector(fnum, &ival, sizeof(ival), &retval, sizeof(retval));
|
||||||
detector_shm()->controlPort);
|
|
||||||
ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,
|
|
||||||
sizeof(retval));
|
|
||||||
FILE_LOG(logDEBUG1) << "Auto comp disable: " << retval;
|
FILE_LOG(logDEBUG1) << "Auto comp disable: " << retval;
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
|
||||||
updateDetector();
|
|
||||||
}
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::setModule(sls_detector_module& module, int tb) {
|
int slsDetector::setModule(sls_detector_module& module, int tb) {
|
||||||
int fnum = F_SET_MODULE;
|
int fnum = F_SET_MODULE;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
|
@ -3,6 +3,9 @@ using dt = slsDetectorDefs::detectorType;
|
|||||||
using di = slsDetectorDefs::dacIndex;
|
using di = slsDetectorDefs::dacIndex;
|
||||||
using ti = slsDetectorDefs::timerIndex;
|
using ti = slsDetectorDefs::timerIndex;
|
||||||
using ro = slsDetectorDefs::readOutFlags;
|
using ro = slsDetectorDefs::readOutFlags;
|
||||||
|
using sv = slsDetectorDefs::speedVariable;
|
||||||
|
using defs = slsDetectorDefs;
|
||||||
extern std::string hostname;
|
extern std::string hostname;
|
||||||
extern std::string detector_type;
|
extern std::string detector_type;
|
||||||
extern dt type;
|
extern dt type;
|
||||||
|
extern std::string my_ip;
|
@ -14,16 +14,20 @@ using dt = slsDetectorDefs::detectorType;
|
|||||||
|
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
std::string detector_type;
|
std::string detector_type;
|
||||||
|
std::string my_ip;
|
||||||
dt type;
|
dt type;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
Catch::Session session;
|
my_ip = "undefined";
|
||||||
|
|
||||||
|
Catch::Session session;
|
||||||
auto cli = session.cli() |
|
auto cli = session.cli() |
|
||||||
Opt(hostname, "hostname")["-hn"]["--hostname"](
|
Opt(hostname, "hostname")["-hn"]["--hostname"](
|
||||||
"Detector hostname for integration tests") |
|
"Detector hostname for integration tests") |
|
||||||
Opt(detector_type, "detector_type")["-dt"]["--detector_type"](
|
Opt(detector_type, "detector_type")["-dt"]["--detector_type"](
|
||||||
"Detector type for integration tests");
|
"Detector type for integration tests") |
|
||||||
|
Opt(my_ip, "my_ip")["-hip"]["--host_ip"](
|
||||||
|
"Host ip address");
|
||||||
|
|
||||||
session.cli(cli);
|
session.cli(cli);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user