first draft of disabling data port at the receiver side. Todo: master file and stream for gui to use

This commit is contained in:
2026-05-07 17:15:50 +02:00
parent 111d10cfa7
commit 4ef8a625ab
39 changed files with 557 additions and 448 deletions
+41 -12
View File
@@ -207,7 +207,7 @@ int ClientInterface::functionTable(){
flist[F_GET_RECEIVER_STREAMING_HWM] = &ClientInterface::get_streaming_hwm;
flist[F_SET_RECEIVER_STREAMING_HWM] = &ClientInterface::set_streaming_hwm;
flist[F_RECEIVER_SET_ALL_THRESHOLD] = &ClientInterface::set_all_threshold;
flist[F_RECEIVER_SET_DATASTREAM] = &ClientInterface::set_detector_datastream;
flist[F_RECEIVER_SET_UDP_DATASTREAM] = &ClientInterface::set_port_udp_datastream;
flist[F_GET_RECEIVER_ARPING] = &ClientInterface::get_arping;
flist[F_SET_RECEIVER_ARPING] = &ClientInterface::set_arping;
flist[F_RECEIVER_GET_RECEIVER_ROI] = &ClientInterface::get_receiver_roi;
@@ -221,6 +221,7 @@ int ClientInterface::functionTable(){
flist[F_SET_RECEIVER_DBIT_REORDER] = &ClientInterface::set_dbit_reorder;
flist[F_RECEIVER_GET_ROI_METADATA] = &ClientInterface::get_roi_metadata;
flist[F_SET_RECEIVER_READOUT_SPEED] = &ClientInterface::set_readout_speed;
flist[F_RECEIVER_GET_UDP_DATASTREAM] = &ClientInterface::get_port_udp_datastream;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@@ -383,8 +384,8 @@ int ClientInterface::setup_receiver(Interface &socket) {
impl()->setSubPeriod(std::chrono::nanoseconds(arg.subExpTimeNs) +
std::chrono::nanoseconds(arg.subDeadTimeNs));
impl()->setActivate(static_cast<bool>(arg.activate));
impl()->setDetectorDataStream(LEFT, arg.dataStreamLeft);
impl()->setDetectorDataStream(RIGHT, arg.dataStreamRight);
impl()->setUDPDataStream(LEFT, arg.dataStreamLeft);
impl()->setUDPDataStream(RIGHT, arg.dataStreamRight);
impl()->setQuad(arg.quad == 0 ? false : true);
impl()->setThresholdEnergy(arg.thresholdEnergyeV[0]);
}
@@ -1653,27 +1654,55 @@ int ClientInterface::set_all_threshold(Interface &socket) {
return socket.Send(OK);
}
int ClientInterface::set_detector_datastream(Interface &socket) {
int args[2]{-1, -1};
socket.Receive(args);
portPosition port = static_cast<portPosition>(args[0]);
void ClientInterface::validate_port_position(const portPosition port) {
bool exists = false;
switch (port) {
case LEFT:
case RIGHT:
if (detType == EIGER) {
exists = true;
}
break;
case TOP:
case BOTTOM:
if (detType == JUNGFRAU || detType == MOENCH) {
exists = true;
}
break;
default:
throw RuntimeError("Invalid port type");
}
bool enable = static_cast<int>(args[1]);
LOG(logDEBUG1) << "Setting datastream (" << ToString(port) << ") to "
if (!exists) {
modeNotImplemented("Port type", port);
}
}
int ClientInterface::set_port_udp_datastream(Interface &socket) {
int args[2]{-1, -1};
socket.Receive(args);
portPosition port = static_cast<portPosition>(args[0]);
validate_port_position(port);
bool enable = static_cast<bool>(args[1]);
LOG(logDEBUG1) << "Setting udp datastream (" << ToString(port) << ") to "
<< ToString(enable);
if (detType != EIGER)
functionNotImplemented();
verifyIdle(socket);
impl()->setDetectorDataStream(port, enable);
if (detType != EIGER && detType != JUNGFRAU && detType != MOENCH)
functionNotImplemented();
impl()->setUDPDataStream(port, enable);
return socket.Send(OK);
}
int ClientInterface::get_port_udp_datastream(Interface &socket) {
auto arg = socket.Receive<int>();
portPosition port = static_cast<portPosition>(arg);
validate_port_position(port);
LOG(logDEBUG1) << "Getting udp datastream (" << ToString(port) << ")";
if (detType != EIGER && detType != JUNGFRAU && detType != MOENCH)
functionNotImplemented();
auto retval = static_cast<int>(impl()->getUDPDataStream(port));
return socket.sendResult(retval);
}
int ClientInterface::get_arping(Interface &socket) {
auto retval = static_cast<int>(impl()->getArping());
LOG(logDEBUG1) << "arping thread status:" << retval;
+3 -1
View File
@@ -154,7 +154,9 @@ class ClientInterface : private virtual slsDetectorDefs {
int get_streaming_hwm(ServerInterface &socket);
int set_streaming_hwm(ServerInterface &socket);
int set_all_threshold(ServerInterface &socket);
int set_detector_datastream(ServerInterface &socket);
void validate_port_position(const portPosition port);
int set_port_udp_datastream(ServerInterface &socket);
int get_port_udp_datastream(ServerInterface &socket);
int get_arping(ServerInterface &socket);
int set_arping(ServerInterface &socket);
int get_receiver_roi(ServerInterface &socket);
+2 -2
View File
@@ -153,14 +153,14 @@ void DataProcessor::CreateFirstFiles(const std::filesystem::path &filePath,
const uint64_t fileIndex,
const bool overWriteEnable,
const bool silentMode,
const bool detectorDataStream) {
const bool udpDataStream) {
if (dataFile == nullptr) {
throw RuntimeError("file object not contstructed");
}
CloseFiles();
// deactivated (half module/ single port or no roi), dont write file
if (!activated || !detectorDataStream || isOutsideRoi) {
if (!activated || !udpDataStream || isOutsideRoi) {
return;
}
+2 -2
View File
@@ -63,7 +63,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
void CreateFirstFiles(const std::filesystem::path &filePath,
const std::string &fileNamePrefix,
const uint64_t fileIndex, const bool overWriteEnable,
const bool silentMode, const bool detectorDataStream);
const bool silentMode, const bool udpDataStream);
#ifdef HDF5C
uint32_t GetFilesInAcquisition() const;
std::string CreateVirtualFile(const std::filesystem::path &filePath,
@@ -173,7 +173,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
uint32_t streamingTimerInMs;
uint32_t streamingStartFnum;
uint32_t currentFreqCount{0};
struct timespec timerbegin {};
struct timespec timerbegin{};
bool framePadding;
std::atomic<bool> startedFlag{false};
std::atomic<uint64_t> firstIndex{0};
+2 -2
View File
@@ -17,8 +17,8 @@ namespace sls {
class File : private virtual slsDetectorDefs {
public:
File(){};
virtual ~File(){};
File() {};
virtual ~File() {};
virtual fileFormat GetFileFormat() const = 0;
virtual void CloseFile() = 0;
+2 -2
View File
@@ -193,8 +193,8 @@ class GeneralData {
slsDetectorDefs::NO_DISCARD};
/* actual image size after ctboffset and ctbreorder */
uint32_t actualImageSize{0};
GeneralData(){};
virtual ~GeneralData(){};
GeneralData() {};
virtual ~GeneralData() {};
// Returns the pixel depth in byte, 4 bits being 0.5 byte
float GetPixelDepth() { return float(dynamicRange) / 8; }
+44 -29
View File
@@ -188,7 +188,7 @@ void Implementation::SetupListener(int i) {
listener[i]->SetEthernetInterface(eth[i]);
listener[i]->SetActivate(activated);
listener[i]->SetIsOutsideRoi(portRois[i].noRoi());
listener[i]->SetDetectorDatastream(detectorDataStream[i]);
listener[i]->SetUDPDatastream(udpDataStream[i]);
listener[i]->SetSilentMode(silentMode);
}
@@ -606,7 +606,7 @@ double Implementation::getProgress() const {
double progress = 0;
int index = 0;
for (const auto &it : listener) {
if (detectorDataStream[index] && it->GetStartedFlag()) {
if (udpDataStream[index] && it->GetStartedFlag()) {
progress += (it->GetListenedIndex() + 1) / totalFrames;
}
++index;
@@ -746,9 +746,9 @@ void Implementation::stopReceiver() {
std::string summary;
if (!activated) {
summary = "\n\tDeactivated Receiver";
} else if (!detectorDataStream[i]) {
summary = (i == 0 ? "\n\tDeactivated Left Port"
: "\n\tDeactivated Right Port");
} else if (!udpDataStream[i]) {
summary = "\n\tDeactivated " + ToString(udpDataStreamType[i]) +
" Port";
} else if (portRois[i].noRoi()) {
summary = "\n\tNo Roi on Port[" + std::to_string(i) + ']';
} else {
@@ -895,9 +895,9 @@ void Implementation::SetupWriter() {
std::string fileNamePrefix =
fileName + "_d" +
std::to_string(modulePos * generalData->numUDPInterfaces + i);
dataProcessor[i]->CreateFirstFiles(
filePath, fileNamePrefix, fileIndex, overwriteEnable,
silentMode, detectorDataStream[i]);
dataProcessor[i]->CreateFirstFiles(filePath, fileNamePrefix,
fileIndex, overwriteEnable,
silentMode, udpDataStream[i]);
}
} catch (const RuntimeError &e) {
shutDownUDPSockets();
@@ -1612,15 +1612,15 @@ void Implementation::setTenGigaEnable(const bool b) {
// datastream can be disabled/enabled only for Eiger 10GbE
if (generalData->detType == EIGER) {
if (!b) {
detectorDataStream[LEFT] = 1;
detectorDataStream[RIGHT] = 1;
udpDataStream[LEFT] = 1;
udpDataStream[RIGHT] = 1;
} else {
detectorDataStream[LEFT] = detectorDataStream10GbE[LEFT];
detectorDataStream[RIGHT] = detectorDataStream10GbE[RIGHT];
udpDataStream[LEFT] = udpDataStream10GbE[LEFT];
udpDataStream[RIGHT] = udpDataStream10GbE[RIGHT];
}
LOG(logDEBUG) << "Detector datastream updated [Left: "
<< ToString(detectorDataStream[LEFT])
<< ", Right: " << ToString(detectorDataStream[RIGHT])
<< ToString(udpDataStream[LEFT])
<< ", Right: " << ToString(udpDataStream[RIGHT])
<< "]";
}
}
@@ -1670,24 +1670,39 @@ void Implementation::setActivate(bool enable) {
LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled");
}
bool Implementation::getDetectorDataStream(const portPosition port) const {
int index = (port == LEFT ? 0 : 1);
return detectorDataStream[index];
bool Implementation::getUDPDataStream(const portPosition port) const {
int index = 0;
if (port == BOTTOM || port == RIGHT)
index = 1;
return udpDataStream[index];
}
void Implementation::setDetectorDataStream(const portPosition port,
const bool enable) {
int index = (port == LEFT ? 0 : 1);
detectorDataStream10GbE[index] = enable;
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
<< " Port): " << ToString(detectorDataStream10GbE[index]);
// update datastream for 10g
if (generalData->tengigaEnable) {
detectorDataStream[index] = detectorDataStream10GbE[index];
LOG(logDEBUG) << "Detector datastream updated ["
<< (index == 0 ? "Left" : "Right")
<< "] : " << ToString(detectorDataStream[index]);
void Implementation::setUDPDataStream(const portPosition port,
const bool enable) {
int index = 0;
if (port == BOTTOM || port == RIGHT)
index = 1;
udpDataStreamType[index] = port;
// jungfrau and moench: straightforward
if (generalData->detType != EIGER) {
udpDataStream[index] = enable;
LOG(logINFO) << "Detector datastream (" << ToString(port)
<< " Port): " << ToString(udpDataStream[index]);
}
// eiger: data stream can be disabled/enabled only for 10GbE
else {
udpDataStream10GbE[index] = enable;
LOG(logINFO) << "Detector 10GbE datastream (" << ToString(port)
<< " Port): " << ToString(udpDataStream10GbE[index]);
// update datastream for 10g
if (generalData->tengigaEnable) {
udpDataStream[index] = udpDataStream10GbE[index];
LOG(logDEBUG) << "Detector datastream updated (" << ToString(port)
<< " Port): " << ToString(udpDataStream[index]);
}
}
for (size_t i = 0; i != listener.size(); ++i)
listener[i]->SetUDPDatastream(udpDataStream[i]);
}
int Implementation::getReadNRows() const { return readNRows; }
+9 -8
View File
@@ -225,12 +225,11 @@ class Implementation : private virtual slsDetectorDefs {
/** [Eiger] If deactivated, receiver will create dummy data if deactivated
* padding is enabled (as it will receive nothing from detector) */
void setActivate(const bool enable);
bool getDetectorDataStream(const portPosition port) const;
/** [Eiger] If datastream is disabled, receiver will create dummy data if
* deactivated
* padding for that port is enabled (as it will receive nothing from
* detector) */
void setDetectorDataStream(const portPosition port, const bool enable);
bool getUDPDataStream(const portPosition port) const;
/** [Jungfrau][Moench] deactivated at receiver level only
* [Eiger] deactivated at module level
*/
void setUDPDataStream(const portPosition port, const bool enable);
int getReadNRows() const;
/* [Eiger][Jungfrau][Moench] */
void setReadNRows(const int value);
@@ -366,8 +365,10 @@ class Implementation : private virtual slsDetectorDefs {
bool flipRows{false};
bool quadEnable{false};
bool activated{true};
std::array<bool, 2> detectorDataStream = {{true, true}};
std::array<bool, 2> detectorDataStream10GbE = {{true, true}};
std::array<bool, 2> udpDataStream = {{true, true}};
std::array<portPosition, 2> udpDataStreamType = {{LEFT, RIGHT}};
// only for Eiger to remember (10Gbe selectable)
std::array<bool, 2> udpDataStream10GbE = {{true, true}};
int readNRows{0};
int thresholdEnergyeV{-1};
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
+5 -5
View File
@@ -85,17 +85,17 @@ void Listener::SetEthernetInterface(const std::string e) {
void Listener::SetActivate(bool enable) {
activated = enable;
disabledPort = (!activated || !detectorDataStream || isOutsideRoi);
disabledPort = (!activated || !udpDataStream || isOutsideRoi);
}
void Listener::SetDetectorDatastream(bool enable) {
detectorDataStream = enable;
disabledPort = (!activated || !detectorDataStream || isOutsideRoi);
void Listener::SetUDPDatastream(bool enable) {
udpDataStream = enable;
disabledPort = (!activated || !udpDataStream || isOutsideRoi);
}
void Listener::SetIsOutsideRoi(bool enable) {
isOutsideRoi = enable;
disabledPort = (!activated || !detectorDataStream || isOutsideRoi);
disabledPort = (!activated || !udpDataStream || isOutsideRoi);
}
void Listener::SetSilentMode(bool enable) { silentMode = enable; }
+2 -2
View File
@@ -42,7 +42,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
void SetUdpPortNumber(const uint16_t portNumber);
void SetEthernetInterface(const std::string e);
void SetActivate(bool enable);
void SetDetectorDatastream(bool enable);
void SetUDPDatastream(bool enable);
void SetIsOutsideRoi(bool enable);
void SetSilentMode(bool enable);
@@ -115,7 +115,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
uint16_t udpPortNumber{0};
std::string eth;
bool activated{false};
bool detectorDataStream{true};
bool udpDataStream{true};
bool isOutsideRoi{false};
bool silentMode;
bool disabledPort{false};