Merge branch 'developer' into dev/matterhorn_server_funcs
Build on RHEL9 docker image / build (push) Successful in 4m1s
Build on RHEL8 docker image / build (push) Successful in 5m38s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m56s
Run Simulator Tests on local RHEL8 / build (push) Successful in 22m23s

This commit is contained in:
2026-07-14 10:55:00 +02:00
48 changed files with 1269 additions and 142431 deletions
+78 -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,10 @@ 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;
flist[F_RECEIVER_SET_UDP_PORT_DISABLE_META] = &ClientInterface::set_udp_port_disable_meta;
flist[F_RECEIVER_GET_UDP_PORT_DISABLE_META] = &ClientInterface::get_udp_port_disable_meta;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@@ -383,8 +387,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]);
}
@@ -1667,27 +1671,58 @@ 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 "
<< ToString(enable);
if (detType != EIGER)
if (!exists) {
modeNotImplemented("Port type", port);
}
}
int ClientInterface::set_port_udp_datastream(Interface &socket) {
if (detType != EIGER && detType != JUNGFRAU && detType != MOENCH)
functionNotImplemented();
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]);
if (impl()->getNumberofUDPInterfaces() == 1)
throw RuntimeError("Cannot change UDP port datastream with only 1 "
"interface enabled. Hint: set 'numinterfaces' to 2");
LOG(logDEBUG1) << "Setting udp datastream (" << ToString(port) << ") to "
<< ToString(enable);
verifyIdle(socket);
impl()->setDetectorDataStream(port, enable);
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;
@@ -1898,4 +1933,35 @@ int ClientInterface::set_readout_speed(Interface &socket) {
return socket.Send(OK);
}
int ClientInterface::set_udp_port_disable_meta(Interface &socket) {
auto nports = socket.Receive<int>();
std::vector<int> portsDisabled;
if (nports > 0) {
portsDisabled.resize(nports);
socket.Receive(portsDisabled);
LOG(logDEBUG1) << "Disabled Ports Metadata:" << ToString(portsDisabled);
}
verifyIdle(socket);
try {
impl()->setUDPPortsDisabledMetadata(portsDisabled);
} catch (const std::exception &e) {
throw RuntimeError("Could not update UDP ports disabled metadata [" +
std::string(e.what()) + ']');
}
return socket.Send(OK);
}
int ClientInterface::get_udp_port_disable_meta(Interface &socket) {
auto retvals = impl()->getUDPPortsDisabledMetadata();
LOG(logDEBUG1) << "Receiver disabled udp ports retval:"
<< ToString(retvals);
socket.Send(OK);
auto size = static_cast<int>(retvals.size());
socket.Send(size);
if (size > 0)
socket.Send(retvals);
return OK;
}
} // namespace sls
+5 -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);
@@ -168,6 +170,8 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_dbit_reorder(ServerInterface &socket);
int get_roi_metadata(ServerInterface &socket);
int set_readout_speed(ServerInterface &socket);
int set_udp_port_disable_meta(ServerInterface &socket);
int get_udp_port_disable_meta(ServerInterface &socket);
Implementation *impl() {
if (receiver != nullptr) {
+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;
}
+1 -1
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,
+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();
};
+63 -29
View File
@@ -192,7 +192,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);
}
@@ -614,7 +614,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;
@@ -754,9 +754,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(generalData->udpPortTypes[i]) + " Port";
} else if (portRois[i].noRoi()) {
summary = "\n\tNo Roi on Port[" + std::to_string(i) + ']';
} else {
@@ -908,9 +908,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();
@@ -1007,6 +1007,10 @@ void Implementation::StartMasterWriter() {
masterAttributes.gates = numberOfGates;
masterAttributes.additionalJsonHeader = additionalJsonHeader;
masterAttributes.readoutSpeed = readoutSpeed;
masterAttributes.udpPortTypes = {
ToString(generalData->udpPortTypes[0]),
ToString(generalData->udpPortTypes[1])};
masterAttributes.udpPortsDisabled = udpPortsDisabledMetadata;
// create master file
masterFileName = dataProcessor[0]->CreateMasterFile(
@@ -1108,6 +1112,11 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
// number of portrois should be equal to number of interfaces
ResetRois();
// reset udp data stream
udpDataStream[0] = true;
udpDataStream[1] = true;
udpPortsDisabledMetadata.clear();
// create threads
for (int i = 0; i < generalData->numUDPInterfaces; ++i) {
// listener and dataprocessor threads
@@ -1626,15 +1635,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] = true;
udpDataStream[RIGHT] = true;
} 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])
<< "]";
}
}
@@ -1684,24 +1693,49 @@ 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;
// top goes to udp port 2 (jungfrau & moench)
if (port == TOP || 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;
// top goes to udp port 2 (jungfrau & moench)
if (port == TOP || port == RIGHT)
index = 1;
// 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]);
}
void Implementation::setUDPPortsDisabledMetadata(
const std::vector<int> &portsDisabled) {
udpPortsDisabledMetadata = portsDisabled;
}
std::vector<int> Implementation::getUDPPortsDisabledMetadata() const {
return udpPortsDisabledMetadata;
}
int Implementation::getReadNRows() const { return readNRows; }
+11 -8
View File
@@ -225,12 +225,13 @@ 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);
void setUDPPortsDisabledMetadata(const std::vector<int> &portsDisabled);
std::vector<int> getUDPPortsDisabledMetadata() const;
int getReadNRows() const;
/* [Eiger][Jungfrau][Moench] */
void setReadNRows(const int value);
@@ -366,8 +367,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::vector<int> udpPortsDisabledMetadata;
// 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};
+58 -8
View File
@@ -53,6 +53,10 @@ void MasterAttributes::GetJungfrauBinaryAttributes(writer *w) {
WriteBinaryExposureTme(w);
WriteBinaryAcquisitionPeriod(w);
WriteBinaryNumberOfUDPInterfaces(w);
if (numUDPInterfaces == 2) {
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
}
WriteBinaryNumberOfRows(w);
WriteBinaryReadoutSpeed(w);
}
@@ -63,6 +67,10 @@ void MasterAttributes::WriteJungfrauHDF5Attributes(H5::Group *group) {
WriteHDF5ExposureTime(group);
WriteHDF5AcquisitionPeriod(group);
WriteHDF5NumberOfUDPInterfaces(group);
if (numUDPInterfaces == 2) {
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
}
WriteHDF5NumberOfRows(group);
WriteHDF5ReadoutSpeed(group);
}
@@ -73,6 +81,10 @@ void MasterAttributes::GetMoenchBinaryAttributes(writer *w) {
WriteBinaryExposureTme(w);
WriteBinaryAcquisitionPeriod(w);
WriteBinaryNumberOfUDPInterfaces(w);
if (numUDPInterfaces == 2) {
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
}
WriteBinaryNumberOfRows(w);
WriteBinaryReadoutSpeed(w);
}
@@ -83,6 +95,10 @@ void MasterAttributes::WriteMoenchHDF5Attributes(H5::Group *group) {
WriteHDF5ExposureTime(group);
WriteHDF5AcquisitionPeriod(group);
WriteHDF5NumberOfUDPInterfaces(group);
if (numUDPInterfaces == 2) {
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
}
WriteHDF5NumberOfRows(group);
WriteHDF5ReadoutSpeed(group);
}
@@ -98,6 +114,8 @@ void MasterAttributes::GetEigerBinaryAttributes(writer *w) {
WriteBinarySubExposureTime(w);
WriteBinarySubAcquisitionPeriod(w);
WriteBinaryQuad(w);
WriteBinaryUDPPortsType(w);
WriteBinaryUDPPortsDisabled(w);
WriteBinaryNumberOfRows(w);
WriteBinaryRateCorrections(w);
WriteBinaryReadoutSpeed(w);
@@ -114,6 +132,8 @@ void MasterAttributes::WriteEigerHDF5Attributes(H5::Group *group) {
WriteHDF5SubExposureTime(group);
WriteHDF5SubAcquisitionPeriod(group);
WriteHDF5Quad(group);
WriteHDF5UDPPortsType(group);
WriteHDF5UDPPortsDisabled(group);
WriteHDF5NumberOfRows(group);
WriteHDF5RateCorrections(group);
WriteHDF5ReadoutSpeed(group);
@@ -690,6 +710,26 @@ void MasterAttributes::WriteHDF5TransceiverSamples(H5::Group *group) {
}
#endif
void MasterAttributes::WriteBinaryUDPPortsType(writer *w) {
WriteBinary(w, N_UDP_PORTS_TYPE.data(), udpPortTypes);
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5UDPPortsType(H5::Group *group) {
WriteHDF5StringArray(group, N_UDP_PORTS_TYPE.data(), udpPortTypes);
}
#endif
void MasterAttributes::WriteBinaryUDPPortsDisabled(writer *w) {
WriteBinary(w, N_UDP_PORTS_DISABLED.data(), udpPortsDisabled);
}
#ifdef HDF5C
void MasterAttributes::WriteHDF5UDPPortsDisabled(H5::Group *group) {
WriteHDF5Int(group, N_UDP_PORTS_DISABLED.data(), udpPortsDisabled);
}
#endif
#ifdef HDF5C
void MasterAttributes::WriteHDF5String(H5::Group *group,
const std::string &name,
@@ -704,15 +744,25 @@ void MasterAttributes::WriteHDF5String(H5::Group *group,
void MasterAttributes::WriteHDF5StringArray(
H5::Group *group, const std::string &name,
const std::vector<std::string> &value) {
std::vector<const char *> c;
for (auto &s : value) {
c.push_back(s.c_str());
try {
std::vector<const char *> c;
for (auto &s : value) {
c.push_back(s.c_str());
}
hsize_t dims[1] = {c.size()};
H5::DataSpace dataspace(1, dims);
H5::StrType strdatatype(H5::PredType::C_S1, H5T_VARIABLE);
H5::DataSet dataset =
group->createDataSet(name, strdatatype, dataspace);
dataset.write(c.data(), strdatatype);
} catch (H5::Exception &e) {
e.printErrorStack();
throw RuntimeError("Could not write attribute " + name +
" in HDf5 file");
} catch (std::exception &e) {
throw RuntimeError("Other excetion: Could not write attribute " + name +
" in HDf5 file. " + std::string(e.what()));
}
hsize_t dims[1] = {c.size()};
H5::DataSpace dataspace(1, dims);
H5::StrType strdatatype(H5::PredType::C_S1, H5T_VARIABLE);
H5::DataSet dataset = group->createDataSet(name, strdatatype, dataspace);
dataset.write(c.data(), strdatatype);
}
#endif
+34 -10
View File
@@ -68,6 +68,8 @@ class MasterAttributes {
std::map<std::string, std::string> additionalJsonHeader;
uint64_t framesInFile{0};
slsDetectorDefs::speedLevel readoutSpeed{slsDetectorDefs::FULL_SPEED};
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";
@@ -125,6 +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_PORTS_DISABLED =
"UDP Ports Disabled";
inline static const std::string_view N_UDP_PORTS_TYPE = "UDP Ports Type";
MasterAttributes() = default;
~MasterAttributes() = default;
@@ -334,7 +339,14 @@ class MasterAttributes {
#ifdef HDF5C
void WriteHDF5TransceiverSamples(H5::Group *group);
#endif
void WriteBinaryUDPPortsType(writer *w);
#ifdef HDF5C
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) {
if constexpr (std::is_same_v<T, int>) {
@@ -402,10 +414,16 @@ class MasterAttributes {
template <typename T>
typename std::enable_if<!std::is_class<T>::value, void>::type
WriteHDF5Int(H5::Group *group, const std::string &name, const T &value) {
H5::DataSpace dataspace(H5S_SCALAR);
auto h5type = GetHDF5Type<T>();
H5::DataSet dataset = group->createDataSet(name, *h5type, dataspace);
dataset.write(&value, *h5type);
try {
H5::DataSpace dataspace(H5S_SCALAR);
auto h5type = GetHDF5Type<T>();
H5::DataSet dataset =
group->createDataSet(name, *h5type, dataspace);
dataset.write(&value, *h5type);
} catch (std::exception &e) {
throw RuntimeError("Could not write attribute " + name +
" in HDf5 file");
}
}
/** For arrays */
@@ -413,11 +431,17 @@ class MasterAttributes {
typename std::enable_if<std::is_class<T>::value, void>::type
WriteHDF5Int(H5::Group *group, const std::string &name, const T &value) {
using ElemT = typename T::value_type;
auto h5type = GetHDF5Type<ElemT>();
hsize_t dims[1] = {value.size()};
H5::DataSpace dataspace(1, dims);
H5::DataSet dataset = group->createDataSet(name, *h5type, dataspace);
dataset.write(value.data(), *h5type);
try {
auto h5type = GetHDF5Type<ElemT>();
hsize_t dims[1] = {value.size()};
H5::DataSpace dataspace(1, dims);
H5::DataSet dataset =
group->createDataSet(name, *h5type, dataspace);
dataset.write(value.data(), *h5type);
} catch (std::exception &e) {
throw RuntimeError("Could not write attribute " + name +
" in HDf5 file");
}
}
#endif
+2 -2
View File
@@ -19,8 +19,8 @@ namespace sls {
// files
// versions
#define HDF5_WRITER_VERSION (7.0) // 1 decimal places
#define BINARY_WRITER_VERSION (8.0) // 1 decimal places
#define HDF5_WRITER_VERSION (7.1) // 1 decimal places
#define BINARY_WRITER_VERSION (8.1) // 1 decimal places
#define MAX_FRAMES_PER_FILE 20000
#define SHORT_MAX_FRAMES_PER_FILE 100000