From 1758417702ba704e8a1c4becb58ab769fdcdc014 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Thu, 5 Mar 2026 19:59:23 +0100 Subject: [PATCH] jfjoch_broker: Export writer FIFO utilization for TCP socket --- broker/OpenAPIConvert.cpp | 1 + broker/gen/model/Image_pusher_status.cpp | 98 ++++++++++++++++++- broker/gen/model/Image_pusher_status.h | 9 ++ broker/gen/model/Tcp_settings.cpp | 2 +- broker/jfjoch_api.yaml | 15 ++- broker/redoc-static.html | 6 +- docs/python_client/docs/ImagePusherStatus.md | 1 + docs/python_client/docs/TcpSettings.md | 2 +- etc/broker_local.json | 6 +- .../src/openapi/models/image_pusher_status.ts | 7 ++ image_pusher/ImagePusher.h | 5 +- image_pusher/TCPStreamPusher.cpp | 12 +++ image_pusher/TCPStreamPusher.h | 2 + 13 files changed, 157 insertions(+), 9 deletions(-) diff --git a/broker/OpenAPIConvert.cpp b/broker/OpenAPIConvert.cpp index 108cc5eb..f6414d57 100644 --- a/broker/OpenAPIConvert.cpp +++ b/broker/OpenAPIConvert.cpp @@ -1118,5 +1118,6 @@ org::openapitools::server::model::Image_pusher_status Convert(const ImagePusherS ret.setImagesWritten(input.images_written.value()); if (input.images_write_error) ret.setImagesWriteError(input.images_write_error.value()); + ret.setWriterFifoUtilization(input.writer_fifo_utilization); return ret; } \ No newline at end of file diff --git a/broker/gen/model/Image_pusher_status.cpp b/broker/gen/model/Image_pusher_status.cpp index 5a15cd18..9ce63a8e 100644 --- a/broker/gen/model/Image_pusher_status.cpp +++ b/broker/gen/model/Image_pusher_status.cpp @@ -26,6 +26,7 @@ Image_pusher_status::Image_pusher_status() m_Images_writtenIsSet = false; m_Images_write_error = 0L; m_Images_write_errorIsSet = false; + m_Writer_fifo_utilizationIsSet = false; } @@ -69,7 +70,75 @@ bool Image_pusher_status::validate(std::stringstream& msg, const std::string& pa } } + + + /* Connected_writers */ { + const int64_t& value = m_Connected_writers; + const std::string currentValuePath = _pathPrefix + ".connectedWriters"; + + if (value < 0ll) + { + success = false; + msg << currentValuePath << ": must be greater than or equal to 0;"; + } + + } + + if (imagesWrittenIsSet()) + { + const int64_t& value = m_Images_written; + const std::string currentValuePath = _pathPrefix + ".imagesWritten"; + + + if (value < 0ll) + { + success = false; + msg << currentValuePath << ": must be greater than or equal to 0;"; + } + + } + + if (imagesWriteErrorIsSet()) + { + const int64_t& value = m_Images_write_error; + const std::string currentValuePath = _pathPrefix + ".imagesWriteError"; + + + if (value < 0ll) + { + success = false; + msg << currentValuePath << ": must be greater than or equal to 0;"; + } + + } + + if (writerFifoUtilizationIsSet()) + { + const std::vector& value = m_Writer_fifo_utilization; + const std::string currentValuePath = _pathPrefix + ".writerFifoUtilization"; + + + { // Recursive validation of array elements + const std::string oldValuePath = currentValuePath; + int i = 0; + for (const int64_t& value : value) + { + const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]"; + + + if (value < 0ll) + { + success = false; + msg << currentValuePath << ": must be greater than or equal to 0;"; + } + + i++; + } + } + + } + return success; } @@ -91,7 +160,10 @@ bool Image_pusher_status::operator==(const Image_pusher_status& rhs) const ((!imagesWrittenIsSet() && !rhs.imagesWrittenIsSet()) || (imagesWrittenIsSet() && rhs.imagesWrittenIsSet() && getImagesWritten() == rhs.getImagesWritten())) && - ((!imagesWriteErrorIsSet() && !rhs.imagesWriteErrorIsSet()) || (imagesWriteErrorIsSet() && rhs.imagesWriteErrorIsSet() && getImagesWriteError() == rhs.getImagesWriteError())) + ((!imagesWriteErrorIsSet() && !rhs.imagesWriteErrorIsSet()) || (imagesWriteErrorIsSet() && rhs.imagesWriteErrorIsSet() && getImagesWriteError() == rhs.getImagesWriteError())) && + + + ((!writerFifoUtilizationIsSet() && !rhs.writerFifoUtilizationIsSet()) || (writerFifoUtilizationIsSet() && rhs.writerFifoUtilizationIsSet() && getWriterFifoUtilization() == rhs.getWriterFifoUtilization())) ; } @@ -111,6 +183,8 @@ void to_json(nlohmann::json& j, const Image_pusher_status& o) j["images_written"] = o.m_Images_written; if(o.imagesWriteErrorIsSet()) j["images_write_error"] = o.m_Images_write_error; + if(o.writerFifoUtilizationIsSet() || !o.m_Writer_fifo_utilization.empty()) + j["writer_fifo_utilization"] = o.m_Writer_fifo_utilization; } @@ -129,6 +203,11 @@ void from_json(const nlohmann::json& j, Image_pusher_status& o) j.at("images_write_error").get_to(o.m_Images_write_error); o.m_Images_write_errorIsSet = true; } + if(j.find("writer_fifo_utilization") != j.end()) + { + j.at("writer_fifo_utilization").get_to(o.m_Writer_fifo_utilization); + o.m_Writer_fifo_utilizationIsSet = true; + } } @@ -190,6 +269,23 @@ void Image_pusher_status::unsetImages_write_error() { m_Images_write_errorIsSet = false; } +std::vector Image_pusher_status::getWriterFifoUtilization() const +{ + return m_Writer_fifo_utilization; +} +void Image_pusher_status::setWriterFifoUtilization(std::vector const value) +{ + m_Writer_fifo_utilization = value; + m_Writer_fifo_utilizationIsSet = true; +} +bool Image_pusher_status::writerFifoUtilizationIsSet() const +{ + return m_Writer_fifo_utilizationIsSet; +} +void Image_pusher_status::unsetWriter_fifo_utilization() +{ + m_Writer_fifo_utilizationIsSet = false; +} } // namespace org::openapitools::server::model diff --git a/broker/gen/model/Image_pusher_status.h b/broker/gen/model/Image_pusher_status.h index cf859961..fce07c70 100644 --- a/broker/gen/model/Image_pusher_status.h +++ b/broker/gen/model/Image_pusher_status.h @@ -89,6 +89,13 @@ public: void setImagesWriteError(int64_t const value); bool imagesWriteErrorIsSet() const; void unsetImages_write_error(); + /// + /// Utilization of internal writer FIFO. This number is updated live during operation for TCP/IP image socket. No other socket use it. + /// + std::vector getWriterFifoUtilization() const; + void setWriterFifoUtilization(std::vector const value); + bool writerFifoUtilizationIsSet() const; + void unsetWriter_fifo_utilization(); friend void to_json(nlohmann::json& j, const Image_pusher_status& o); friend void from_json(const nlohmann::json& j, Image_pusher_status& o); @@ -103,6 +110,8 @@ protected: bool m_Images_writtenIsSet; int64_t m_Images_write_error; bool m_Images_write_errorIsSet; + std::vector m_Writer_fifo_utilization; + bool m_Writer_fifo_utilizationIsSet; }; diff --git a/broker/gen/model/Tcp_settings.cpp b/broker/gen/model/Tcp_settings.cpp index a4bcfcfb..a240894a 100644 --- a/broker/gen/model/Tcp_settings.cpp +++ b/broker/gen/model/Tcp_settings.cpp @@ -24,7 +24,7 @@ Tcp_settings::Tcp_settings() m_Send_buffer_size = 0L; m_Send_buffer_sizeIsSet = false; m_Addr = ""; - m_Nwriters = 1L; + m_Nwriters = 32L; m_NwritersIsSet = false; } diff --git a/broker/jfjoch_api.yaml b/broker/jfjoch_api.yaml index f644d37e..77bf1af2 100644 --- a/broker/jfjoch_api.yaml +++ b/broker/jfjoch_api.yaml @@ -1368,6 +1368,7 @@ components: connected_writers: type: integer format: int64 + minimum: 0 description: | Number of connected writers For ZeroMQ image socket: number is constant @@ -1375,6 +1376,7 @@ components: images_written: type: integer format: int64 + minimum: 0 description: | Number of images written to the image socket. This number is updated live during operation for TCP/IP image socket and direct HDF5 writer. @@ -1382,10 +1384,21 @@ components: images_write_error: type: integer format: int64 + minimum: 0 description: | Number of images that could not be written to the image socket. This number is updated live during operation for TCP/IP image socket. No other socket use it. + writer_fifo_utilization: + type: array + items: + type: integer + format: int64 + minimum: 0 + description: | + Utilization of internal writer FIFO. + This number is updated live during operation for TCP/IP image socket. + No other socket use it. plot: type: object required: @@ -2164,7 +2177,7 @@ components: format: int64 minimum: 1 maximum: 100 - default: 1 + default: 32 description: Number of TCP/IP writers to be used for streaming images pcie_devices: type: array diff --git a/broker/redoc-static.html b/broker/redoc-static.html index fcd5f82b..bb1ac807 100644 --- a/broker/redoc-static.html +++ b/broker/redoc-static.html @@ -776,7 +776,7 @@ This can only be done when detector is Idle, Error or
http://localhost:5232/xfel/event_code

Response samples

Content type
application/json
[
  • 0
]

Get status of image pusher

Responses

Response samples

Content type
application/json
{
  • "pusher_type": "ZeroMQ",
  • "addr": [
    ],
  • "connected_writers": 0,
  • "images_written": 0,
  • "images_write_error": 0
}

Get detector status

Status of the JUNGFRAU detector

+
http://localhost:5232/image_pusher/status

Response samples

Content type
application/json
{
  • "pusher_type": "ZeroMQ",
  • "addr": [
    ],
  • "connected_writers": 0,
  • "images_written": 0,
  • "images_write_error": 0,
  • "writer_fifo_utilization": [
    ]
}

Get detector status

Status of the JUNGFRAU detector

Responses

Request samples

Content type
application/json
{
  • "box": {
    },
  • "circle": {
    },
  • "azim": {
    }
}

Response samples

Content type
application/json
{
  • "msg": "Detector in wrong state",
  • "reason": "WrongDAQState"
}

Get general statistics

query Parameters
compression
boolean
Default: false

Enable DEFLATE compression of output data.

Responses

Response samples

Content type
application/json
{
  • "detector": {
    },
  • "detector_list": {
    },
  • "detector_settings": {
    },
  • "image_format_settings": {
    },
  • "instrument_metadata": {
    },
  • "file_writer_settings": {
    },
  • "data_processing_settings": {
    },
  • "measurement": {
    },
  • "broker": {
    },
  • "fpga": [
    ],
  • "calibration": [
    ],
  • "zeromq_preview": {
    },
  • "zeromq_metadata": {
    },
  • "dark_mask": {
    },
  • "pixel_mask": {
    },
  • "roi": {
    },
  • "az_int": {
    },
  • "buffer": {
    },
  • "indexing": {
    },
  • "image_pusher": {
    }
}

Get data collection statistics

Results of the last data collection

+
http://localhost:5232/statistics

Response samples

Content type
application/json
{
  • "detector": {
    },
  • "detector_list": {
    },
  • "detector_settings": {
    },
  • "image_format_settings": {
    },
  • "instrument_metadata": {
    },
  • "file_writer_settings": {
    },
  • "data_processing_settings": {
    },
  • "measurement": {
    },
  • "broker": {
    },
  • "fpga": [
    ],
  • "calibration": [
    ],
  • "zeromq_preview": {
    },
  • "zeromq_metadata": {
    },
  • "dark_mask": {
    },
  • "pixel_mask": {
    },
  • "roi": {
    },
  • "az_int": {
    },
  • "buffer": {
    },
  • "indexing": {
    },
  • "image_pusher": {
    }
}

Get data collection statistics

Results of the last data collection

Responses