works in file. still needs refactoring

This commit is contained in:
2026-05-13 13:44:11 +02:00
parent 794c9f506a
commit fa263d1d21
14 changed files with 130 additions and 113 deletions
+4
View File
@@ -193,6 +193,8 @@ class GeneralData {
slsDetectorDefs::NO_DISCARD};
/* actual image size after ctboffset and ctbreorder */
uint32_t actualImageSize{0};
/* bottom & top or left & right for 2 interfaces */
std::array<defs::portPosition, 2> udpPortTypes{defs::LEFT, defs::RIGHT};
GeneralData(){};
virtual ~GeneralData(){};
@@ -344,6 +346,7 @@ class JungfrauData : public GeneralData {
fifoDepth = 2500;
standardheader = true;
maxRowsPerReadout = 512;
udpPortTypes = {defs::BOTTOM, defs::TOP};
UpdateImageSize();
};
@@ -376,6 +379,7 @@ class MoenchData : public GeneralData {
standardheader = true;
maxRowsPerReadout = 400;
frameDiscardMode = slsDetectorDefs::DISCARD_PARTIAL_FRAMES;
udpPortTypes = {defs::BOTTOM, defs::TOP};
UpdateImageSize();
};
+10 -9
View File
@@ -747,8 +747,8 @@ void Implementation::stopReceiver() {
if (!activated) {
summary = "\n\tDeactivated Receiver";
} else if (!udpDataStream[i]) {
summary = "\n\tDeactivated " + ToString(udpDataStreamType[i]) +
" Port";
summary = "\n\tDeactivated " +
ToString(generalData->udpPortTypes[i]) + " Port";
} else if (portRois[i].noRoi()) {
summary = "\n\tNo Roi on Port[" + std::to_string(i) + ']';
} else {
@@ -994,9 +994,10 @@ void Implementation::StartMasterWriter() {
masterAttributes.gates = numberOfGates;
masterAttributes.additionalJsonHeader = additionalJsonHeader;
masterAttributes.readoutSpeed = readoutSpeed;
masterAttributes.udpPortEnables = udpPortEnables;
masterAttributes.udpPortType[0] = ToString(udpDataStreamType[0]);
masterAttributes.udpPortType[1] = ToString(udpDataStreamType[1]);
masterAttributes.udpPortTypes = {
ToString(generalData->udpPortTypes[0]),
ToString(generalData->udpPortTypes[1])};
masterAttributes.udpPortsDisabled = udpPortsDisabledMetadata;
// create master file
masterFileName = dataProcessor[0]->CreateMasterFile(
@@ -1101,6 +1102,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
// reset udp data stream
udpDataStream[0] = true;
udpDataStream[1] = true;
udpPortsDisabledMetadata.clear();
// create threads
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
@@ -1691,7 +1693,6 @@ void Implementation::setUDPDataStream(const portPosition port,
// top goes to udp port 2 (jungfrau & moench)
if (port == TOP || port == RIGHT)
index = 1;
udpDataStreamType[index] = port;
// jungfrau and moench: straightforward
if (generalData->detType != EIGER) {
udpDataStream[index] = enable;
@@ -1714,9 +1715,9 @@ void Implementation::setUDPDataStream(const portPosition port,
listener[i]->SetUDPDatastream(udpDataStream[i]);
}
void Implementation::updateUDPDatastreamMetadata(
const std::array<std::vector<int>, 2> &portEnables) {
udpPortEnables = portEnables;
void Implementation::updateUDPPortsDisabledMetadata(
const std::vector<int> &portsDisabled) {
udpPortsDisabledMetadata = portsDisabled;
}
int Implementation::getReadNRows() const { return readNRows; }
-2
View File
@@ -368,8 +368,6 @@ class Implementation : private virtual slsDetectorDefs {
bool activated{true};
std::array<bool, 2> udpDataStream = {{true, true}};
std::vector<int> udpPortsDisabledMetadata;
std::vector<bool> udpPort2Enable;
std::array<portPosition, 2> udpDataStreamType = {{LEFT, RIGHT}};
// only for Eiger to remember (10Gbe selectable)
std::array<bool, 2> udpDataStream10GbE = {{true, true}};
int readNRows{0};
+20 -34
View File
@@ -55,8 +55,6 @@ void MasterAttributes::GetJungfrauBinaryAttributes(writer *w) {
WriteBinaryNumberOfUDPInterfaces(w);
WriteBinaryNumberOfRows(w);
WriteBinaryReadoutSpeed(w);
if (numUDPInterfaces == 2)
WriteBinaryUDPPortEnables(w);
}
#ifdef HDF5C
@@ -67,8 +65,6 @@ void MasterAttributes::WriteJungfrauHDF5Attributes(H5::Group *group) {
WriteHDF5NumberOfUDPInterfaces(group);
WriteHDF5NumberOfRows(group);
WriteHDF5ReadoutSpeed(group);
if (numUDPInterfaces == 2)
WriteHDF5UDPPortEnables(group);
}
#endif
@@ -79,8 +75,6 @@ void MasterAttributes::GetMoenchBinaryAttributes(writer *w) {
WriteBinaryNumberOfUDPInterfaces(w);
WriteBinaryNumberOfRows(w);
WriteBinaryReadoutSpeed(w);
if (numUDPInterfaces == 2)
WriteBinaryUDPPortEnables(w);
}
#ifdef HDF5C
@@ -91,8 +85,6 @@ void MasterAttributes::WriteMoenchHDF5Attributes(H5::Group *group) {
WriteHDF5NumberOfUDPInterfaces(group);
WriteHDF5NumberOfRows(group);
WriteHDF5ReadoutSpeed(group);
if (numUDPInterfaces == 2)
WriteHDF5UDPPortEnables(group);
}
#endif
@@ -109,7 +101,6 @@ void MasterAttributes::GetEigerBinaryAttributes(writer *w) {
WriteBinaryNumberOfRows(w);
WriteBinaryRateCorrections(w);
WriteBinaryReadoutSpeed(w);
WriteBinaryUDPPortEnables(w);
}
#ifdef HDF5C
@@ -126,7 +117,6 @@ void MasterAttributes::WriteEigerHDF5Attributes(H5::Group *group) {
WriteHDF5NumberOfRows(group);
WriteHDF5RateCorrections(group);
WriteHDF5ReadoutSpeed(group);
WriteHDF5UDPPortEnables(group);
}
#endif
@@ -423,11 +413,19 @@ void MasterAttributes::WriteHDF5AcquisitionPeriod(H5::Group *group) {
void MasterAttributes::WriteBinaryNumberOfUDPInterfaces(writer *w) {
WriteBinary(w, N_NUM_UDP_INTERFACES.data(), numUDPInterfaces);
if (numUDPInterfaces == 2 && detType != defs::GOTTHARD2) {
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
}
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5NumberOfUDPInterfaces(H5::Group *group) {
WriteHDF5Int(group, N_NUM_UDP_INTERFACES.data(), numUDPInterfaces);
if (numUDPInterfaces == 2 && detType != defs::GOTTHARD2) {
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
}
}
#endif
@@ -700,35 +698,23 @@ void MasterAttributes::WriteHDF5TransceiverSamples(H5::Group *group) {
}
#endif
void MasterAttributes::WriteBinaryUDPPortEnables(writer *w) {
for (size_t i = 0; i != udpPortType.size(); ++i) {
std::string key = udpPortType[i] + std::string(N_UDP_PORT_ENABLES);
w->Key(key.c_str());
w->StartArray();
for (const int u : udpPortEnables[i]) {
w->Int(u);
}
w->EndArray();
}
void MasterAttributes::WriteBinaryUDPPortsType(writer *w) {
WriteBinary(w, N_UDP_PORTS_TYPE.data(), udpPortTypes);
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5UDPPortEnables(H5::Group *group) {
for (size_t i = 0; i != udpPortType.size(); ++i) {
// convert vector<bool> -> vector<uint8_t>
std::vector<int> vals(udpPortEnables[i].begin(),
udpPortEnables[i].end());
void MasterAttributes::WriteHDF5UDPPortsType(H5::Group *group) {
WriteHDF5StringArray(group, N_UDP_PORTS_TYPE.data(), udpPortTypes);
}
#endif
hsize_t dims[1] = {vals.size()};
H5::DataSpace dataspace(1, dims);
void MasterAttributes::WriteBinaryUDPPortsDisabled(writer *w) {
WriteBinary(w, N_UDP_PORTS_DISBLED.data(), udpPortsDisabled);
}
std::string key = udpPortType[i] + std::string(N_UDP_PORT_ENABLES);
H5::DataSet dataset =
group->createDataSet(key, H5::PredType::NATIVE_UINT32, dataspace);
dataset.write(vals.data(), H5::PredType::NATIVE_UINT32);
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5UDPPortsDisabled(H5::Group *group) {
WriteHDF5Int(group, N_UDP_PORTS_DISBLED.data(), udpPortsDisabled);
}
#endif
+11 -6
View File
@@ -68,8 +68,8 @@ class MasterAttributes {
std::map<std::string, std::string> additionalJsonHeader;
uint64_t framesInFile{0};
slsDetectorDefs::speedLevel readoutSpeed{slsDetectorDefs::FULL_SPEED};
std::array<std::vector<int>, 2> udpPortEnables;
std::array<std::string, 2> udpPortType;
std::vector<std::string> udpPortTypes;
std::vector<int> udpPortsDisabled;
inline static const std::string_view N_DETECTOR_TYPE = "Detector Type";
inline static const std::string_view N_TIMING_MODE = "Timing Mode";
@@ -127,8 +127,9 @@ class MasterAttributes {
inline static const std::string_view N_SCAN_PARAMETERS = "Scan Parameters";
inline static const std::string_view N_ADDITIONAL_JSON_HEADER =
"Additional JSON Header";
inline static const std::string_view N_UDP_PORT_ENABLES =
" UDP Port Enables";
inline static const std::string_view N_UDP_PORTS_DISBLED =
"UDP Ports Disabled";
inline static const std::string_view N_UDP_PORTS_TYPE = "UDP Ports Type";
MasterAttributes() = default;
~MasterAttributes() = default;
@@ -338,9 +339,13 @@ class MasterAttributes {
#ifdef HDF5C
void WriteHDF5TransceiverSamples(H5::Group *group);
#endif
void WriteBinaryUDPPortEnables(writer *w);
void WriteBinaryUDPPortsType(writer *w);
#ifdef HDF5C
void WriteHDF5UDPPortEnables(H5::Group *group);
void WriteHDF5UDPPortsType(H5::Group *group);
#endif
void WriteBinaryUDPPortsDisabled(writer *w);
#ifdef HDF5C
void WriteHDF5UDPPortsDisabled(H5::Group *group);
#endif
/** writes according to type */
template <typename T> void WriteBinaryValue(writer *w, const T &value) {