mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-29 23:51:18 +01:00
merge fix
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "Module.h"
|
||||
#include "SharedMemory.h"
|
||||
#include "sls/ClientSocket.h"
|
||||
@@ -475,7 +477,8 @@ bool Module::getFlipRows() const {
|
||||
void Module::setFlipRows(bool value) {
|
||||
if (shm()->detType == EIGER) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver<int>(rxIndex, F_SET_FLIP_ROWS_RECEIVER, static_cast<int>(value));
|
||||
sendToReceiver<int>(rxIndex, F_SET_FLIP_ROWS_RECEIVER,
|
||||
static_cast<int>(value));
|
||||
} else {
|
||||
sendToDetector(F_SET_FLIP_ROWS, static_cast<int>(value), nullptr);
|
||||
}
|
||||
@@ -505,7 +508,7 @@ void Module::setNumberOfTriggers(int64_t value) {
|
||||
sendToDetector(F_SET_NUM_TRIGGERS, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_TRIGGERS, value, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_TRIGGERS, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,7 +525,7 @@ void Module::setExptime(int gateIndex, int64_t value) {
|
||||
sendToDetector(F_SET_EXPTIME, args, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_EXPTIME, args, nullptr);
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_EXPTIME, args, nullptr);
|
||||
}
|
||||
if (prevVal != value) {
|
||||
updateRateCorrection();
|
||||
@@ -537,7 +540,7 @@ void Module::setPeriod(int64_t value) {
|
||||
sendToDetector(F_SET_PERIOD, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_PERIOD, value, nullptr);
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_PERIOD, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,11 +589,11 @@ void Module::setDynamicRange(int dr) {
|
||||
if (dr == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
setClockDivider(RUN_CLOCK, 2);
|
||||
setReadoutSpeed(defs::QUARTER_SPEED);
|
||||
} else {
|
||||
LOG(logINFO) << "Setting Clock to Full Speed for Dynamic Range of "
|
||||
<< dr;
|
||||
setClockDivider(RUN_CLOCK, 0);
|
||||
setReadoutSpeed(defs::FULL_SPEED);
|
||||
}
|
||||
// EIGER only, update speed and rate correction when dr changes
|
||||
if (dr != prev_val) {
|
||||
@@ -607,10 +610,18 @@ void Module::setTimingMode(timingMode value) {
|
||||
sendToDetector<int>(F_SET_TIMING_MODE, value);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_TIMING_MODE, value, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_TIMING_MODE, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
slsDetectorDefs::speedLevel Module::getReadoutSpeed() const {
|
||||
return sendToDetector<speedLevel>(F_GET_READOUT_SPEED);
|
||||
}
|
||||
|
||||
void Module::setReadoutSpeed(speedLevel value) {
|
||||
sendToDetector(F_SET_READOUT_SPEED, value, nullptr);
|
||||
}
|
||||
|
||||
int Module::getClockDivider(int clkIndex) const {
|
||||
return sendToDetector<int>(F_GET_CLOCK_DIVIDER, clkIndex);
|
||||
}
|
||||
@@ -758,14 +769,14 @@ void Module::setReadNRows(const int value) {
|
||||
|
||||
void Module::startReceiver() {
|
||||
shm()->stoppedFlag = false;
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_START_RECEIVER);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_START_RECEIVER);
|
||||
}
|
||||
|
||||
void Module::stopReceiver() {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_STOP_RECEIVER, static_cast<int>(shm()->stoppedFlag),
|
||||
nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_STOP_RECEIVER,
|
||||
static_cast<int>(shm()->stoppedFlag), nullptr);
|
||||
}
|
||||
|
||||
void Module::startAcquisition() {
|
||||
@@ -803,8 +814,8 @@ void Module::stopAcquisition() {
|
||||
}
|
||||
|
||||
void Module::restreamStopFromReceiver() {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RESTREAM_STOP_FROM_RECEIVER);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RESTREAM_STOP_FROM_RECEIVER);
|
||||
}
|
||||
|
||||
void Module::startAndReadAll() {
|
||||
@@ -817,17 +828,17 @@ slsDetectorDefs::runStatus Module::getRunStatus() const {
|
||||
}
|
||||
|
||||
slsDetectorDefs::runStatus Module::getReceiverStatus() const {
|
||||
const int rxIndex = -1;
|
||||
const int rxIndex = -1;
|
||||
return sendToReceiver<runStatus>(rxIndex, F_GET_RECEIVER_STATUS);
|
||||
}
|
||||
|
||||
double Module::getReceiverProgress() const {
|
||||
const int rxIndex = -1;
|
||||
const int rxIndex = -1;
|
||||
return sendToReceiver<double>(rxIndex, F_GET_RECEIVER_PROGRESS);
|
||||
}
|
||||
|
||||
int64_t Module::getFramesCaughtByReceiver() const {
|
||||
const int rxIndex = -1;
|
||||
const int rxIndex = -1;
|
||||
return sendToReceiver<int64_t>(rxIndex, F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
}
|
||||
|
||||
@@ -836,7 +847,8 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
|
||||
LOG(logDEBUG1) << "Getting num missing packets";
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = 0;
|
||||
auto client = ReceiverSocket(shm()->receivers[rxIndex].hostname, shm()->receivers[rxIndex].tcpPort);
|
||||
auto client = ReceiverSocket(shm()->receivers[rxIndex].hostname,
|
||||
shm()->receivers[rxIndex].tcpPort);
|
||||
client.Send(F_GET_NUM_MISSING_PACKETS);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError(
|
||||
@@ -847,7 +859,7 @@ std::vector<uint64_t> Module::getNumMissingPackets() const {
|
||||
std::vector<uint64_t> retval(nports);
|
||||
client.Receive(retval);
|
||||
LOG(logDEBUG1) << "Missing packets of Receiver" << moduleIndex
|
||||
<< ": " << sls::ToString(retval);
|
||||
<< ": " << sls::ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@@ -874,7 +886,7 @@ void Module::setScan(const defs::scanParameters t) {
|
||||
auto retval = sendToDetector<int64_t>(F_SET_SCAN, t);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_SCAN, t, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_SCAN, t, nullptr);
|
||||
}
|
||||
// if disabled, retval is 1, else its number of steps
|
||||
setNumberOfFrames(retval);
|
||||
@@ -902,7 +914,7 @@ void Module::setNumberofUDPInterfaces(int n) {
|
||||
shm()->numUDPInterfaces = n;
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_INTERFACES, n, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_INTERFACES, n, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,7 +1036,7 @@ void Module::setDestinationUDPIP(const IpAddr ip, const int rxIndex) {
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
sls::MacAddr retval(0LU);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_IP, ip, retval);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_IP, ip, retval);
|
||||
LOG(logINFO) << "Setting destination udp mac of Module [" << moduleIndex
|
||||
<< ", " << rxIndex << "] to " << retval;
|
||||
if (rxIndex == 0) {
|
||||
@@ -1061,7 +1073,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip, const int rxIndex) {
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
sls::MacAddr retval(0LU);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_IP2, ip, retval);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_IP2, ip, retval);
|
||||
LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex
|
||||
<< " to " << retval;
|
||||
if (rxIndex == 0) {
|
||||
@@ -1096,7 +1108,7 @@ void Module::setDestinationUDPMAC(const MacAddr mac, const int rxIndex) {
|
||||
}
|
||||
|
||||
sls::MacAddr Module::getDestinationUDPMAC2(const int rxIndex) const {
|
||||
if (rxIndex == 0) {
|
||||
if (rxIndex == 0) {
|
||||
return sendToDetector<sls::MacAddr>(F_GET_DEST_UDP_MAC2);
|
||||
}
|
||||
auto t = getDestinationUDPList(rxIndex);
|
||||
@@ -1117,7 +1129,7 @@ void Module::setDestinationUDPMAC2(const MacAddr mac, const int rxIndex) {
|
||||
}
|
||||
|
||||
int Module::getDestinationUDPPort(const int rxIndex) const {
|
||||
if (rxIndex == 0) {
|
||||
if (rxIndex == 0) {
|
||||
return sendToDetector<int>(F_GET_DEST_UDP_PORT);
|
||||
}
|
||||
auto t = getDestinationUDPList(rxIndex);
|
||||
@@ -1133,12 +1145,12 @@ void Module::setDestinationUDPPort(const int port, const int rxIndex) {
|
||||
setDestinationUDPList(t);
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_PORT, port, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_PORT, port, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int Module::getDestinationUDPPort2(const int rxIndex) const {
|
||||
if (rxIndex == 0) {
|
||||
if (rxIndex == 0) {
|
||||
return sendToDetector<int>(F_GET_DEST_UDP_PORT2);
|
||||
}
|
||||
auto t = getDestinationUDPList(rxIndex);
|
||||
@@ -1154,7 +1166,7 @@ void Module::setDestinationUDPPort2(const int port, const int rxIndex) {
|
||||
setDestinationUDPList(t);
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_PORT2, port, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_UDP_PORT2, port, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,15 +1178,15 @@ void Module::validateUDPConfiguration() {
|
||||
|
||||
std::string Module::printReceiverConfiguration(const int rxIndex) {
|
||||
std::ostringstream os;
|
||||
os << "\n\nModule " << moduleIndex << "\nReceiver [" << rxIndex << "] Hostname:\t"
|
||||
<< getReceiverHostname(rxIndex);
|
||||
os << "\n\nModule " << moduleIndex << "\nReceiver [" << rxIndex
|
||||
<< "] Hostname:\t" << getReceiverHostname(rxIndex);
|
||||
|
||||
if (shm()->detType == JUNGFRAU) {
|
||||
os << "\nNumber of Interfaces:\t" << getNumberofUDPInterfaces()
|
||||
<< "\nSelected Interface:\t" << getSelectedUDPInterface();
|
||||
}
|
||||
auto t = getDestinationUDPList(rxIndex);
|
||||
|
||||
|
||||
os << "\nSource UDP IP:\t" << getSourceUDPIP() << "\nSource UDP MAC:\t"
|
||||
<< getSourceUDPMAC() << "\nDestination UDP IP:\t" << t.ip
|
||||
<< "\nDestination UDP MAC:\t" << t.mac;
|
||||
@@ -1182,8 +1194,8 @@ std::string Module::printReceiverConfiguration(const int rxIndex) {
|
||||
if (shm()->detType == JUNGFRAU) {
|
||||
os << "\nSource UDP IP2:\t" << getSourceUDPIP2()
|
||||
<< "\nSource UDP MAC2:\t" << getSourceUDPMAC2()
|
||||
<< "\nDestination UDP IP2:\t" << t.ip2
|
||||
<< "\nDestination UDP MAC2:\t" << t.mac2;
|
||||
<< "\nDestination UDP IP2:\t" << t.ip2 << "\nDestination UDP MAC2:\t"
|
||||
<< t.mac2;
|
||||
}
|
||||
os << "\nDestination UDP Port:\t" << t.port;
|
||||
if (shm()->detType == JUNGFRAU || shm()->detType == EIGER) {
|
||||
@@ -1249,7 +1261,8 @@ std::string Module::getReceiverHostname(const int rxIndex) const {
|
||||
return std::string(shm()->receivers[rxIndex].hostname);
|
||||
}
|
||||
|
||||
void Module::setReceiverHostname(const std::string &receiverIP, const int rxIndex) {
|
||||
void Module::setReceiverHostname(const std::string &receiverIP,
|
||||
const int rxIndex) {
|
||||
LOG(logDEBUG1) << "Setting up Receiver with " << receiverIP;
|
||||
|
||||
if (receiverIP == "none") {
|
||||
@@ -1287,7 +1300,7 @@ void Module::setReceiverHostname(const std::string &receiverIP, const int rxInde
|
||||
strcpy_safe(retval.hostname, shm()->hostname);
|
||||
|
||||
sls::MacAddr retvals[2];
|
||||
sendToReceiver(rxIndex, F_SETUP_RECEIVER, retval, retvals);
|
||||
sendToReceiver(rxIndex, F_SETUP_RECEIVER, retval, retvals);
|
||||
// update Modules with dest mac
|
||||
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
||||
LOG(logINFO) << "Setting destination udp mac of "
|
||||
@@ -1308,7 +1321,9 @@ void Module::setReceiverHostname(const std::string &receiverIP, const int rxInde
|
||||
updateReceiverStreamingIP(rxIndex);
|
||||
}
|
||||
|
||||
int Module::getReceiverPort(const int rxIndex) const { return shm()->receivers[rxIndex].tcpPort; }
|
||||
int Module::getReceiverPort(const int rxIndex) const {
|
||||
return shm()->receivers[rxIndex].tcpPort;
|
||||
}
|
||||
|
||||
int Module::setReceiverPort(int port_number, const int rxIndex) {
|
||||
if (port_number >= 0 && port_number != shm()->receivers[rxIndex].tcpPort) {
|
||||
@@ -1334,19 +1349,21 @@ bool Module::getReceiverSilentMode() const {
|
||||
|
||||
void Module::setReceiverSilentMode(bool enable) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_SILENT_MODE, static_cast<int>(enable),
|
||||
nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_SILENT_MODE,
|
||||
static_cast<int>(enable), nullptr);
|
||||
}
|
||||
|
||||
slsDetectorDefs::frameDiscardPolicy
|
||||
Module::getReceiverFramesDiscardPolicy() const {
|
||||
const int rxIndex = 0;
|
||||
return sendToReceiver<frameDiscardPolicy>(rxIndex, F_GET_RECEIVER_DISCARD_POLICY);
|
||||
return sendToReceiver<frameDiscardPolicy>(rxIndex,
|
||||
F_GET_RECEIVER_DISCARD_POLICY);
|
||||
}
|
||||
|
||||
void Module::setReceiverFramesDiscardPolicy(frameDiscardPolicy f) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_DISCARD_POLICY, static_cast<int>(f), nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_DISCARD_POLICY, static_cast<int>(f),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
bool Module::getPartialFramesPadding() const {
|
||||
@@ -1356,7 +1373,8 @@ bool Module::getPartialFramesPadding() const {
|
||||
|
||||
void Module::setPartialFramesPadding(bool padding) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_PADDING, static_cast<int>(padding), nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_PADDING, static_cast<int>(padding),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
int Module::getReceiverUDPSocketBufferSize() const {
|
||||
@@ -1392,8 +1410,8 @@ sls::IpAddr Module::getReceiverLastClientIP() const {
|
||||
|
||||
std::array<pid_t, NUM_RX_THREAD_IDS> Module::getReceiverThreadIds() const {
|
||||
const int rxIndex = 0;
|
||||
return sendToReceiver<std::array<pid_t, NUM_RX_THREAD_IDS>>(rxIndex,
|
||||
F_GET_RECEIVER_THREAD_IDS);
|
||||
return sendToReceiver<std::array<pid_t, NUM_RX_THREAD_IDS>>(
|
||||
rxIndex, F_GET_RECEIVER_THREAD_IDS);
|
||||
}
|
||||
|
||||
// File
|
||||
@@ -1404,13 +1422,13 @@ slsDetectorDefs::fileFormat Module::getFileFormat() const {
|
||||
|
||||
void Module::setFileFormat(fileFormat f) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_FORMAT, f, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_FORMAT, f, nullptr);
|
||||
}
|
||||
|
||||
std::string Module::getFilePath() const {
|
||||
char ret[MAX_STR_LENGTH]{};
|
||||
const int rxIndex = 0;
|
||||
sendToReceiver(rxIndex, F_GET_RECEIVER_FILE_PATH, nullptr, ret);
|
||||
sendToReceiver(rxIndex, F_GET_RECEIVER_FILE_PATH, nullptr, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1421,13 +1439,13 @@ void Module::setFilePath(const std::string &path) {
|
||||
char args[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args, path.c_str());
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_PATH, args, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_PATH, args, nullptr);
|
||||
}
|
||||
|
||||
std::string Module::getFileName() const {
|
||||
char buff[MAX_STR_LENGTH]{};
|
||||
const int rxIndex = 0;
|
||||
sendToReceiver(rxIndex, F_GET_RECEIVER_FILE_NAME, nullptr, buff);
|
||||
sendToReceiver(rxIndex, F_GET_RECEIVER_FILE_NAME, nullptr, buff);
|
||||
return buff;
|
||||
}
|
||||
|
||||
@@ -1438,7 +1456,7 @@ void Module::setFileName(const std::string &fname) {
|
||||
char args[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(args, fname.c_str());
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_NAME, args, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_NAME, args, nullptr);
|
||||
}
|
||||
|
||||
int64_t Module::getFileIndex() const {
|
||||
@@ -1448,12 +1466,12 @@ int64_t Module::getFileIndex() const {
|
||||
|
||||
void Module::setFileIndex(int64_t file_index) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_INDEX, file_index, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_INDEX, file_index, nullptr);
|
||||
}
|
||||
|
||||
void Module::incrementFileIndex() {
|
||||
void Module::incrementFileIndex() {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_INCREMENT_FILE_INDEX);
|
||||
sendToReceiver(rxIndex, F_INCREMENT_FILE_INDEX);
|
||||
}
|
||||
|
||||
bool Module::getFileWrite() const {
|
||||
@@ -1463,7 +1481,8 @@ bool Module::getFileWrite() const {
|
||||
|
||||
void Module::setFileWrite(bool value) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_WRITE, static_cast<int>(value), nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FILE_WRITE, static_cast<int>(value),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
bool Module::getMasterFileWrite() const {
|
||||
@@ -1473,8 +1492,8 @@ bool Module::getMasterFileWrite() const {
|
||||
|
||||
void Module::setMasterFileWrite(bool value) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_MASTER_FILE_WRITE, static_cast<int>(value),
|
||||
nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_MASTER_FILE_WRITE,
|
||||
static_cast<int>(value), nullptr);
|
||||
}
|
||||
|
||||
bool Module::getFileOverWrite() const {
|
||||
@@ -1484,7 +1503,8 @@ bool Module::getFileOverWrite() const {
|
||||
|
||||
void Module::setFileOverWrite(bool value) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_OVERWRITE, static_cast<int>(value), nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_OVERWRITE, static_cast<int>(value),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
int Module::getFramesPerFile() const {
|
||||
@@ -1494,7 +1514,7 @@ int Module::getFramesPerFile() const {
|
||||
|
||||
void Module::setFramesPerFile(int n_frames) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, nullptr);
|
||||
}
|
||||
|
||||
// ZMQ Streaming Parameters (Receiver<->Client)
|
||||
@@ -1506,7 +1526,8 @@ bool Module::getReceiverStreaming() const {
|
||||
|
||||
void Module::setReceiverStreaming(bool enable) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING, static_cast<int>(enable), nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING, static_cast<int>(enable),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
int Module::getReceiverStreamingFrequency() const {
|
||||
@@ -1520,7 +1541,7 @@ void Module::setReceiverStreamingFrequency(int freq) {
|
||||
std::to_string(freq));
|
||||
}
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_FREQUENCY, freq, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_FREQUENCY, freq, nullptr);
|
||||
}
|
||||
|
||||
int Module::getReceiverStreamingTimer() const {
|
||||
@@ -1544,7 +1565,7 @@ void Module::setReceiverStreamingStartingFrame(int fnum) {
|
||||
std::to_string(fnum));
|
||||
}
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_START_FNUM, fnum, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_START_FNUM, fnum, nullptr);
|
||||
}
|
||||
|
||||
int Module::getReceiverStreamingPort() const {
|
||||
@@ -1554,12 +1575,13 @@ int Module::getReceiverStreamingPort() const {
|
||||
|
||||
void Module::setReceiverStreamingPort(int port) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_PORT, port, nullptr);
|
||||
}
|
||||
|
||||
sls::IpAddr Module::getReceiverStreamingIP() const {
|
||||
const int rxIndex = 0;
|
||||
return sendToReceiver<sls::IpAddr>(rxIndex, F_GET_RECEIVER_STREAMING_SRC_IP);
|
||||
return sendToReceiver<sls::IpAddr>(rxIndex,
|
||||
F_GET_RECEIVER_STREAMING_SRC_IP);
|
||||
}
|
||||
|
||||
void Module::setReceiverStreamingIP(const sls::IpAddr ip, const int rxIndex) {
|
||||
@@ -1593,7 +1615,7 @@ int Module::getReceiverStreamingHwm() const {
|
||||
|
||||
void Module::setReceiverStreamingHwm(const int limit) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_HWM, limit, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_STREAMING_HWM, limit, nullptr);
|
||||
}
|
||||
|
||||
// Eiger Specific
|
||||
@@ -1609,8 +1631,8 @@ void Module::setSubExptime(int64_t value) {
|
||||
}
|
||||
sendToDetector(F_SET_SUB_EXPTIME, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_SUB_EXPTIME, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_SUB_EXPTIME, value, nullptr);
|
||||
}
|
||||
if (prevVal != value) {
|
||||
updateRateCorrection();
|
||||
@@ -1624,8 +1646,8 @@ int64_t Module::getSubDeadTime() const {
|
||||
void Module::setSubDeadTime(int64_t value) {
|
||||
sendToDetector(F_SET_SUB_DEADTIME, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_SUB_DEADTIME, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_SUB_DEADTIME, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1654,7 +1676,8 @@ void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
|
||||
LOG(logDEBUG) << "Sending to receiver 0 [rate corrections: " << ToString(t)
|
||||
<< ']';
|
||||
// only to master receiver
|
||||
auto client = ReceiverSocket(shm()->receivers[0].hostname, shm()->receivers[0].tcpPort);
|
||||
auto client = ReceiverSocket(shm()->receivers[0].hostname,
|
||||
shm()->receivers[0].tcpPort);
|
||||
client.Send(F_SET_RECEIVER_RATE_CORRECT);
|
||||
client.Send(static_cast<int>(t.size()));
|
||||
client.Send(t);
|
||||
@@ -1697,8 +1720,8 @@ void Module::setActivate(const bool enable) {
|
||||
auto retval = sendToDetector<int>(F_ACTIVATE, arg);
|
||||
sendToDetectorStop<int>(F_ACTIVATE, arg);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_ACTIVATE, retval, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_ACTIVATE, retval, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1731,8 +1754,8 @@ void Module::setQuad(const bool enable) {
|
||||
int value = enable ? 1 : 0;
|
||||
sendToDetector(F_SET_QUAD, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_QUAD, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_QUAD, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1744,8 +1767,8 @@ void Module::setDataStream(const portPosition port, const bool enable) {
|
||||
int args[]{static_cast<int>(port), static_cast<int>(enable)};
|
||||
sendToDetector(F_SET_DATASTREAM, args, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_DATASTREAM, args, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_DATASTREAM, args, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1853,8 +1876,8 @@ void Module::setROI(slsDetectorDefs::ROI arg) {
|
||||
}
|
||||
sendToDetector(F_SET_ROI, arg, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_ROI, arg, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_ROI, arg, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1873,8 +1896,8 @@ int64_t Module::getNumberOfBursts() const {
|
||||
void Module::setNumberOfBursts(int64_t value) {
|
||||
sendToDetector(F_SET_NUM_BURSTS, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_BURSTS, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_BURSTS, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2106,8 +2129,8 @@ slsDetectorDefs::burstMode Module::getBurstMode() const {
|
||||
void Module::setBurstMode(slsDetectorDefs::burstMode value) {
|
||||
sendToDetector(F_SET_BURST_MODE, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_BURST_MODE, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_BURST_MODE, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2241,8 +2264,9 @@ void Module::setCounterMask(uint32_t countermask) {
|
||||
sendToDetector(F_SET_COUNTER_MASK, countermask, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
LOG(logDEBUG1) << "Sending Reciver counter mask: " << countermask;
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_COUNTER_MASK, countermask, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_COUNTER_MASK, countermask,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2253,8 +2277,8 @@ int Module::getNumberOfGates() const {
|
||||
void Module::setNumberOfGates(int value) {
|
||||
sendToDetector(F_SET_NUM_GATES, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_GATES, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_NUM_GATES, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2270,8 +2294,8 @@ void Module::setGateDelay(int gateIndex, int64_t value) {
|
||||
int64_t args[]{static_cast<int64_t>(gateIndex), value};
|
||||
sendToDetector(F_SET_GATE_DELAY, args, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_GATE_DELAY, args, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_GATE_DELAY, args, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2301,8 +2325,9 @@ void Module::setNumberOfAnalogSamples(int value) {
|
||||
// update #nchan, as it depends on #samples, adcmask
|
||||
updateNumberOfChannels();
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2324,7 +2349,7 @@ void Module::setADCEnableMask(uint32_t mask) {
|
||||
updateNumberOfChannels();
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver<int>(rxIndex, F_RECEIVER_SET_ADC_MASK, mask);
|
||||
}
|
||||
}
|
||||
@@ -2338,7 +2363,7 @@ void Module::setTenGigaADCEnableMask(uint32_t mask) {
|
||||
updateNumberOfChannels(); // depends on samples and adcmask
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver<int>(rxIndex, F_RECEIVER_SET_ADC_MASK_10G, mask);
|
||||
}
|
||||
}
|
||||
@@ -2356,8 +2381,9 @@ void Module::setNumberOfDigitalSamples(int value) {
|
||||
if (shm()->useReceiverFlag) {
|
||||
LOG(logDEBUG1) << "Sending number of digital samples to Receiver: "
|
||||
<< value;
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, value, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, value,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2373,8 +2399,8 @@ void Module::setReadoutMode(const slsDetectorDefs::readoutMode mode) {
|
||||
updateNumberOfChannels();
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_READOUT_MODE, mode, nullptr);
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_SET_READOUT_MODE, mode, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2396,8 +2422,8 @@ void Module::setExternalSampling(bool value) {
|
||||
|
||||
std::vector<int> Module::getReceiverDbitList() const {
|
||||
const int rxIndex = 0;
|
||||
return sendToReceiver<sls::StaticVector<int, MAX_RX_DBIT>>(rxIndex,
|
||||
F_GET_RECEIVER_DBIT_LIST);
|
||||
return sendToReceiver<sls::StaticVector<int, MAX_RX_DBIT>>(
|
||||
rxIndex, F_GET_RECEIVER_DBIT_LIST);
|
||||
}
|
||||
|
||||
void Module::setReceiverDbitList(std::vector<int> list) {
|
||||
@@ -2417,7 +2443,7 @@ void Module::setReceiverDbitList(std::vector<int> list) {
|
||||
|
||||
sls::StaticVector<int, MAX_RX_DBIT> arg = list;
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||
}
|
||||
|
||||
int Module::getReceiverDbitOffset() const {
|
||||
@@ -2427,7 +2453,7 @@ int Module::getReceiverDbitOffset() const {
|
||||
|
||||
void Module::setReceiverDbitOffset(int value) {
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_DBIT_OFFSET, value, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_RECEIVER_DBIT_OFFSET, value, nullptr);
|
||||
}
|
||||
|
||||
void Module::setDigitalIODelay(uint64_t pinMask, int delay) {
|
||||
@@ -2549,11 +2575,12 @@ std::map<std::string, std::string> Module::getAdditionalJsonHeader() const {
|
||||
"(zmq json header)");
|
||||
}
|
||||
const int rxIndex = 0;
|
||||
auto client = ReceiverSocket(shm()->receivers[rxIndex].hostname, shm()->receivers[rxIndex].tcpPort);
|
||||
auto client = ReceiverSocket(shm()->receivers[rxIndex].hostname,
|
||||
shm()->receivers[rxIndex].tcpPort);
|
||||
client.Send(F_GET_ADDITIONAL_JSON_HEADER);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto size = client.Receive<int>();
|
||||
std::string buff(size, '\0');
|
||||
@@ -2595,7 +2622,8 @@ void Module::setAdditionalJsonHeader(
|
||||
LOG(logDEBUG) << "Sending to receiver additional json header "
|
||||
<< ToString(jsonHeader);
|
||||
const int rxIndex = -1;
|
||||
auto client = ReceiverSocket(shm()->receivers[rxIndex].hostname, shm()->receivers[rxIndex].tcpPort);
|
||||
auto client = ReceiverSocket(shm()->receivers[rxIndex].hostname,
|
||||
shm()->receivers[rxIndex].tcpPort);
|
||||
client.Send(F_SET_ADDITIONAL_JSON_HEADER);
|
||||
client.Send(size);
|
||||
if (size > 0)
|
||||
@@ -2603,7 +2631,7 @@ void Module::setAdditionalJsonHeader(
|
||||
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
" returned error: " + client.readErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2612,7 +2640,7 @@ std::string Module::getAdditionalJsonParameter(const std::string &key) const {
|
||||
sls::strcpy_safe(arg, key.c_str());
|
||||
char retval[SHORT_STR_LENGTH]{};
|
||||
const int rxIndex = 0;
|
||||
sendToReceiver(rxIndex, F_GET_ADDITIONAL_JSON_PARAMETER, arg, retval);
|
||||
sendToReceiver(rxIndex, F_GET_ADDITIONAL_JSON_PARAMETER, arg, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -2629,7 +2657,7 @@ void Module::setAdditionalJsonParameter(const std::string &key,
|
||||
sls::strcpy_safe(args[0], key.c_str());
|
||||
sls::strcpy_safe(args[1], value.c_str());
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_SET_ADDITIONAL_JSON_PARAMETER, args, nullptr);
|
||||
sendToReceiver(rxIndex, F_SET_ADDITIONAL_JSON_PARAMETER, args, nullptr);
|
||||
}
|
||||
|
||||
// Advanced
|
||||
@@ -2658,7 +2686,18 @@ void Module::copyDetectorServer(const std::string &fname,
|
||||
sls::strcpy_safe(args[1], hostname.c_str());
|
||||
LOG(logINFO) << "Sending detector server " << args[0] << " from host "
|
||||
<< args[1];
|
||||
sendToDetector(F_COPY_DET_SERVER, args, nullptr);
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
client.Send(F_COPY_DET_SERVER);
|
||||
client.Send(args);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::cout << '\n';
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname
|
||||
<< "): detector server copied";
|
||||
}
|
||||
|
||||
void Module::rebootController() {
|
||||
@@ -2727,9 +2766,7 @@ void Module::setControlPort(int port_number) {
|
||||
|
||||
int Module::getStopPort() const { return shm()->stopPort; }
|
||||
|
||||
void Module::setStopPort(int port_number) {
|
||||
shm()->stopPort = port_number;
|
||||
}
|
||||
void Module::setStopPort(int port_number) { shm()->stopPort = port_number; }
|
||||
|
||||
bool Module::getLockDetector() const {
|
||||
return sendToDetector<int>(F_LOCK_SERVER, GET_FLAG);
|
||||
@@ -3023,8 +3060,9 @@ Ret Module::sendToDetectorStop(int fnum, const Arg &args) {
|
||||
|
||||
//-------------------------------------------------------------- sendToReceiver
|
||||
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size) const {
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const void *args,
|
||||
size_t args_size, void *retval,
|
||||
size_t retval_size) const {
|
||||
// This is the only function that actually sends data to the receiver
|
||||
// the other versions use templates to deduce sizes and create
|
||||
// the return type
|
||||
@@ -3036,7 +3074,8 @@ void Module::sendToReceiver(const int rxIndex, int fnum, const void *args, size_
|
||||
}
|
||||
checkArgs(args, args_size, retval, retval_size);
|
||||
if (rxIndex >= MAX_UDP_DESTINATION) {
|
||||
throw RuntimeError("Invalid destination index " + std::to_string(rxIndex));
|
||||
throw RuntimeError("Invalid destination index " +
|
||||
std::to_string(rxIndex));
|
||||
}
|
||||
int startReceiver = 0;
|
||||
int endReceiver = MAX_UDP_DESTINATION;
|
||||
@@ -3051,26 +3090,30 @@ void Module::sendToReceiver(const int rxIndex, int fnum, const void *args, size_
|
||||
LOG(logDEBUG1) << "Receiver [" << shm()->receivers[i].hostname << ", "
|
||||
<< shm()->receivers[i].tcpPort << ']';
|
||||
try {
|
||||
auto receiver = ReceiverSocket(shm()->receivers[i].hostname, shm()->receivers[i].tcpPort);
|
||||
auto receiver = ReceiverSocket(shm()->receivers[i].hostname,
|
||||
shm()->receivers[i].tcpPort);
|
||||
receiver.sendCommandThenRead(fnum, args, args_size, retval,
|
||||
retval_size);
|
||||
retval_size);
|
||||
receiver.close();
|
||||
} catch (ReceiverError& e) {
|
||||
} catch (ReceiverError &e) {
|
||||
std::ostringstream oss;
|
||||
oss << e.what() << '[' << shm()->receivers[i].hostname << ", " << shm()->receivers[i].tcpPort << ']';
|
||||
throw ReceiverError (oss.str());
|
||||
oss << e.what() << '[' << shm()->receivers[i].hostname << ", "
|
||||
<< shm()->receivers[i].tcpPort << ']';
|
||||
throw ReceiverError(oss.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const void *args, size_t args_size,
|
||||
void *retval, size_t retval_size) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, args, args_size,
|
||||
retval, retval_size);
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const void *args,
|
||||
size_t args_size, void *retval,
|
||||
size_t retval_size) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(
|
||||
rxIndex, fnum, args, args_size, retval, retval_size);
|
||||
}
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args, Ret &retval) const {
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args,
|
||||
Ret &retval) const {
|
||||
LOG(logDEBUG1) << "Sending to Receiver " << rxIndex << ": ["
|
||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||
<< ", " << args << ", " << sizeof(args) << ", "
|
||||
@@ -3082,12 +3125,15 @@ void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args, Ret &r
|
||||
}
|
||||
|
||||
template <typename Arg, typename Ret>
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args, Ret &retval) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, args, retval);
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args,
|
||||
Ret &retval) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, args,
|
||||
retval);
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args, std::nullptr_t) const {
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args,
|
||||
std::nullptr_t) const {
|
||||
LOG(logDEBUG1) << "Sending to Receiver " << rxIndex << ": ["
|
||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||
<< ", " << typeid(Arg).name() << ", " << sizeof(Arg)
|
||||
@@ -3097,12 +3143,15 @@ void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args, std::n
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args, std::nullptr_t) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, args, nullptr);
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args,
|
||||
std::nullptr_t) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, args,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, std::nullptr_t, Ret &retval) const {
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, std::nullptr_t,
|
||||
Ret &retval) const {
|
||||
LOG(logDEBUG1) << "Sending to Receiver " << rxIndex << ": ["
|
||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||
@@ -3113,11 +3162,14 @@ void Module::sendToReceiver(const int rxIndex, int fnum, std::nullptr_t, Ret &re
|
||||
}
|
||||
|
||||
template <typename Ret>
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, std::nullptr_t, Ret &retval) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, nullptr, retval);
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum, std::nullptr_t,
|
||||
Ret &retval) {
|
||||
static_cast<const Module &>(*this).sendToReceiver(rxIndex, fnum, nullptr,
|
||||
retval);
|
||||
}
|
||||
|
||||
template <typename Ret> Ret Module::sendToReceiver(const int rxIndex, int fnum) const {
|
||||
template <typename Ret>
|
||||
Ret Module::sendToReceiver(const int rxIndex, int fnum) const {
|
||||
LOG(logDEBUG1) << "Sending to Receiver " << rxIndex << ": ["
|
||||
<< getFunctionNameFromEnum(static_cast<detFuncs>(fnum))
|
||||
<< ", nullptr, 0, " << typeid(Ret).name() << ", "
|
||||
@@ -3129,8 +3181,10 @@ template <typename Ret> Ret Module::sendToReceiver(const int rxIndex, int fnum)
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <typename Ret> Ret Module::sendToReceiver(const int rxIndex, int fnum) {
|
||||
return static_cast<const Module &>(*this).sendToReceiver<Ret>(rxIndex, fnum);
|
||||
template <typename Ret>
|
||||
Ret Module::sendToReceiver(const int rxIndex, int fnum) {
|
||||
return static_cast<const Module &>(*this).sendToReceiver<Ret>(rxIndex,
|
||||
fnum);
|
||||
}
|
||||
|
||||
void Module::sendToReceiver(const int rxIndex, int fnum) const {
|
||||
@@ -3160,7 +3214,8 @@ Ret Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args) const {
|
||||
|
||||
template <typename Ret, typename Arg>
|
||||
Ret Module::sendToReceiver(const int rxIndex, int fnum, const Arg &args) {
|
||||
return static_cast<const Module &>(*this).sendToReceiver<Ret>(rxIndex, fnum, args);
|
||||
return static_cast<const Module &>(*this).sendToReceiver<Ret>(rxIndex, fnum,
|
||||
args);
|
||||
}
|
||||
|
||||
slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
|
||||
@@ -3267,7 +3322,8 @@ void Module::checkDetectorVersionCompatibility() {
|
||||
void Module::checkReceiverVersionCompatibility() {
|
||||
// TODO! Verify that this works as intended when version don't match
|
||||
const int rxIndex = -1;
|
||||
sendToReceiver(rxIndex, F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER), nullptr);
|
||||
sendToReceiver(rxIndex, F_RECEIVER_CHECK_VERSION, int64_t(APIRECEIVER),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
int Module::sendModule(sls_detector_module *myMod, sls::ClientSocket &client) {
|
||||
@@ -3337,7 +3393,7 @@ void Module::setModule(sls_detector_module &module, bool trimbits) {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Will need to update to each round robin entry
|
||||
// TODO Will need to update to each round robin entry
|
||||
void Module::updateReceiverStreamingIP(const int rxIndex) {
|
||||
auto ip = getReceiverStreamingIP();
|
||||
if (ip == 0) {
|
||||
@@ -3346,8 +3402,8 @@ void Module::updateReceiverStreamingIP(const int rxIndex) {
|
||||
if (ip == 0) {
|
||||
ip = HostnameToIp(shm()->receivers[rxIndex].hostname);
|
||||
}
|
||||
LOG(logINFO) << "Setting default receiver [" << moduleIndex
|
||||
<< " , " << rxIndex << "] streaming zmq ip to " << ip;
|
||||
LOG(logINFO) << "Setting default receiver [" << moduleIndex << " , "
|
||||
<< rxIndex << "] streaming zmq ip to " << ip;
|
||||
}
|
||||
setReceiverStreamingIP(ip, rxIndex);
|
||||
}
|
||||
@@ -3629,7 +3685,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
currentPointer += unitprogramsize;
|
||||
}
|
||||
|
||||
// checksum
|
||||
// checksum
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
@@ -3641,8 +3697,8 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
|
||||
// simulating erasing flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex
|
||||
<< " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// erasing takes 65 seconds, printing here (otherwise need threads
|
||||
@@ -3652,10 +3708,10 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
@@ -3663,7 +3719,8 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
|
||||
// simulating writing to flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module " << moduleIndex << " (" << shm()->hostname << ")";
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// writing takes 30 seconds, printing here (otherwise need threads
|
||||
@@ -3673,10 +3730,10 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
@@ -3719,8 +3776,8 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
|
||||
// simulating erasing flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex
|
||||
<< " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// erasing takes 10 seconds, printing here (otherwise need threads
|
||||
@@ -3730,10 +3787,10 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
@@ -3741,7 +3798,8 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
|
||||
// simulating writing to flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module " << moduleIndex << " (" << shm()->hostname << ")";
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// writing takes 45 seconds, printing here (otherwise need threads
|
||||
@@ -3751,10 +3809,10 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
printf("%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
|
||||
100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
Reference in New Issue
Block a user