mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-02 08:54:55 +01:00
add documentation to code
This commit is contained in:
@@ -77,7 +77,7 @@ std::string ZmqHeader::to_string() const {
|
||||
write_digit(s, "ndety", ndety);
|
||||
write_digit(s, "npixelsx", npixelsx);
|
||||
write_digit(s, "npixelsy", npixelsy);
|
||||
write_digit(s, "imageSize", imageSize);
|
||||
write_digit(s, "size", size);
|
||||
write_digit(s, "acqIndex", acqIndex);
|
||||
write_digit(s, "frameIndex", frameIndex);
|
||||
write_digit(s, "progress", progress);
|
||||
@@ -117,7 +117,6 @@ void ZmqHeader::from_string(std::string &s) {
|
||||
|
||||
for (auto field : object) {
|
||||
std::string_view key = field.unescaped_key();
|
||||
|
||||
if (key == "data") {
|
||||
data = uint64_t(field.value()) ? true : false;
|
||||
} else if (key == "jsonversion") {
|
||||
@@ -134,8 +133,8 @@ void ZmqHeader::from_string(std::string &s) {
|
||||
npixelsx = uint32_t(field.value());
|
||||
} else if (key == "npixelsy") {
|
||||
npixelsy = uint32_t(field.value());
|
||||
} else if (key == "imageSize") {
|
||||
imageSize = uint32_t(field.value());
|
||||
} else if (key == "size") {
|
||||
size = uint32_t(field.value());
|
||||
} else if (key == "acqIndex") {
|
||||
acqIndex = uint64_t(field.value());
|
||||
} else if (key == "frameIndex") {
|
||||
@@ -187,7 +186,7 @@ void ZmqHeader::from_string(std::string &s) {
|
||||
bool ZmqHeader::operator==(const ZmqHeader &other) const {
|
||||
return data == other.data && jsonversion == other.jsonversion && dynamicRange == other.dynamicRange &&
|
||||
fileIndex == other.fileIndex && ndetx == other.ndetx && ndety == other.ndety && npixelsx == other.npixelsx &&
|
||||
npixelsy == other.npixelsy && imageSize == other.imageSize && acqIndex == other.acqIndex &&
|
||||
npixelsy == other.npixelsy && size == other.size && acqIndex == other.acqIndex &&
|
||||
frameIndex == other.frameIndex && progress == other.progress && fname == other.fname &&
|
||||
frameNumber == other.frameNumber && expLength == other.expLength && packetNumber == other.packetNumber &&
|
||||
detSpec1 == other.detSpec1 && timestamp == other.timestamp && modId == other.modId && row == other.row &&
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
namespace aare {
|
||||
|
||||
/**
|
||||
* @brief closes the socket and destroys the context
|
||||
* @return void
|
||||
* @note this function is called by the destructor
|
||||
*/
|
||||
void ZmqSocket::disconnect() {
|
||||
zmq_close(m_socket);
|
||||
zmq_ctx_destroy(m_context);
|
||||
@@ -10,6 +15,10 @@ void ZmqSocket::disconnect() {
|
||||
m_context = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief destructor
|
||||
* @note called from child classes (ZmqSocketReceiver and ZmqSocketSender)
|
||||
*/
|
||||
ZmqSocket::~ZmqSocket() {
|
||||
if (m_socket)
|
||||
disconnect();
|
||||
|
||||
@@ -79,6 +79,10 @@ int ZmqSocketReceiver::receive_data(std::byte *data, size_t size) {
|
||||
return data_bytes_received;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief receive a ZmqFrame (header and data)
|
||||
* @return ZmqFrame
|
||||
*/
|
||||
ZmqFrame ZmqSocketReceiver::receive_zmqframe() {
|
||||
// receive header from zmq and parse it
|
||||
ZmqHeader header = receive_header();
|
||||
@@ -94,13 +98,17 @@ ZmqFrame ZmqSocketReceiver::receive_zmqframe() {
|
||||
if (bytes_received == -1) {
|
||||
throw network_io::NetworkError(LOCATION + "Error receiving frame");
|
||||
}
|
||||
if ((uint32_t)bytes_received != header.imageSize) {
|
||||
if ((uint32_t)bytes_received != header.size) {
|
||||
throw network_io::NetworkError(
|
||||
fmt::format("{} Expected {} bytes but received {}", LOCATION, header.imageSize, bytes_received));
|
||||
fmt::format("{} Expected {} bytes but received {}", LOCATION, header.size, bytes_received));
|
||||
}
|
||||
return {header, std::move(frame)};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief receive multiple ZmqFrames (header and data)
|
||||
* @return std::vector<ZmqFrame>
|
||||
*/
|
||||
std::vector<ZmqFrame> ZmqSocketReceiver::receive_n() {
|
||||
std::vector<ZmqFrame> frames;
|
||||
while (true) {
|
||||
|
||||
Reference in New Issue
Block a user