From c897008d6e1f196d7eae6229eb71b1d453c3bc67 Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Sat, 28 Feb 2026 21:22:58 +0100 Subject: [PATCH] ImageBuffer: Improved logic for slot management --- broker/OpenAPIConvert.cpp | 6 + broker/gen/model/Image_buffer_status.cpp | 30 +++- broker/gen/model/Image_buffer_status.h | 14 ++ broker/jfjoch_api.yaml | 12 ++ broker/redoc-static.html | 6 +- common/ImageBuffer.cpp | 134 +++++++++++++----- common/ImageBuffer.h | 25 ++-- common/ZeroCopyReturnValue.cpp | 24 +++- common/ZeroCopyReturnValue.h | 5 +- docs/python_client/docs/ImageBufferStatus.md | 2 + .../src/openapi/models/image_buffer_status.ts | 10 ++ receiver/JFJochReceiverFPGA.cpp | 1 + receiver/JFJochReceiverLite.cpp | 1 + tests/ImageBufferTest.cpp | 29 +++- 14 files changed, 242 insertions(+), 57 deletions(-) diff --git a/broker/OpenAPIConvert.cpp b/broker/OpenAPIConvert.cpp index 13576b9d..3b603dcc 100644 --- a/broker/OpenAPIConvert.cpp +++ b/broker/OpenAPIConvert.cpp @@ -753,6 +753,9 @@ org::openapitools::server::model::Image_buffer_status Convert(const ImageBufferS ret.setImageNumbers(input.images_in_the_buffer); ret.setMaxImageNumber(input.max_image_number); ret.setMinImageNumber(input.min_image_number); + ret.setInPreparationSlots(input.preparation_slots); + ret.setInSendingSlots(input.sending_slots); + if (input.current_counter.has_value()) ret.setCurrentCounter(input.current_counter.value()); return ret; @@ -765,6 +768,9 @@ ImageBufferStatus Convert(const org::openapitools::server::model::Image_buffer_s ret.images_in_the_buffer = input.getImageNumbers(); ret.max_image_number = input.getMaxImageNumber(); ret.min_image_number = input.getMinImageNumber(); + ret.sending_slots = input.getInSendingSlots(); + ret.preparation_slots = input.getInPreparationSlots(); + if (input.currentCounterIsSet()) ret.current_counter = input.getCurrentCounter(); return ret; diff --git a/broker/gen/model/Image_buffer_status.cpp b/broker/gen/model/Image_buffer_status.cpp index 198ae9f2..9e415bf2 100644 --- a/broker/gen/model/Image_buffer_status.cpp +++ b/broker/gen/model/Image_buffer_status.cpp @@ -25,6 +25,8 @@ Image_buffer_status::Image_buffer_status() m_Max_image_number = 0L; m_Total_slots = 0L; m_Available_slots = 0L; + m_In_preparation_slots = 0L; + m_In_sending_slots = 0L; m_Current_counter = 0L; m_Current_counterIsSet = false; @@ -98,7 +100,7 @@ bool Image_buffer_status::validate(std::stringstream& msg, const std::string& pa } } - + return success; } @@ -122,6 +124,12 @@ bool Image_buffer_status::operator==(const Image_buffer_status& rhs) const (getAvailableSlots() == rhs.getAvailableSlots()) && + (getInPreparationSlots() == rhs.getInPreparationSlots()) + && + + (getInSendingSlots() == rhs.getInSendingSlots()) + && + ((!currentCounterIsSet() && !rhs.currentCounterIsSet()) || (currentCounterIsSet() && rhs.currentCounterIsSet() && getCurrentCounter() == rhs.getCurrentCounter())) @@ -141,6 +149,8 @@ void to_json(nlohmann::json& j, const Image_buffer_status& o) j["image_numbers"] = o.m_Image_numbers; j["total_slots"] = o.m_Total_slots; j["available_slots"] = o.m_Available_slots; + j["in_preparation_slots"] = o.m_In_preparation_slots; + j["in_sending_slots"] = o.m_In_sending_slots; if(o.currentCounterIsSet()) j["current_counter"] = o.m_Current_counter; @@ -153,6 +163,8 @@ void from_json(const nlohmann::json& j, Image_buffer_status& o) j.at("image_numbers").get_to(o.m_Image_numbers); j.at("total_slots").get_to(o.m_Total_slots); j.at("available_slots").get_to(o.m_Available_slots); + j.at("in_preparation_slots").get_to(o.m_In_preparation_slots); + j.at("in_sending_slots").get_to(o.m_In_sending_slots); if(j.find("current_counter") != j.end()) { j.at("current_counter").get_to(o.m_Current_counter); @@ -201,6 +213,22 @@ void Image_buffer_status::setAvailableSlots(int64_t const value) { m_Available_slots = value; } +int64_t Image_buffer_status::getInPreparationSlots() const +{ + return m_In_preparation_slots; +} +void Image_buffer_status::setInPreparationSlots(int64_t const value) +{ + m_In_preparation_slots = value; +} +int64_t Image_buffer_status::getInSendingSlots() const +{ + return m_In_sending_slots; +} +void Image_buffer_status::setInSendingSlots(int64_t const value) +{ + m_In_sending_slots = value; +} int64_t Image_buffer_status::getCurrentCounter() const { return m_Current_counter; diff --git a/broker/gen/model/Image_buffer_status.h b/broker/gen/model/Image_buffer_status.h index 84337033..e38c6b53 100644 --- a/broker/gen/model/Image_buffer_status.h +++ b/broker/gen/model/Image_buffer_status.h @@ -84,6 +84,16 @@ public: int64_t getAvailableSlots() const; void setAvailableSlots(int64_t const value); /// + /// Number of slots in the image buffer that are currently in preparation for sending. + /// + int64_t getInPreparationSlots() const; + void setInPreparationSlots(int64_t const value); + /// + /// Number of slots in the image buffer that are currently sending/writing data. + /// + int64_t getInSendingSlots() const; + void setInSendingSlots(int64_t const value); + /// /// Counter of changes in the image buffer - either new start message or new image added. For optimization one can only load new images/datasets from the HTTP if this value changes. Counter is optional as it was not implemented in older versions to avoid breaking change /// int64_t getCurrentCounter() const; @@ -104,6 +114,10 @@ protected: int64_t m_Available_slots; + int64_t m_In_preparation_slots; + + int64_t m_In_sending_slots; + int64_t m_Current_counter; bool m_Current_counterIsSet; diff --git a/broker/jfjoch_api.yaml b/broker/jfjoch_api.yaml index 25329822..1d520b2f 100644 --- a/broker/jfjoch_api.yaml +++ b/broker/jfjoch_api.yaml @@ -695,6 +695,8 @@ components: required: - image_numbers - total_slots + - in_preparation_slots + - in_sending_slots - available_slots - max_image_number - min_image_number @@ -725,6 +727,16 @@ components: type: integer format: int64 description: Slots available for the data collection + in_preparation_slots: + type: integer + format: int64 + description: | + Number of slots in the image buffer that are currently in preparation for sending. + in_sending_slots: + type: integer + format: int64 + description: | + Number of slots in the image buffer that are currently sending/writing data. current_counter: type: integer format: int64 diff --git a/broker/redoc-static.html b/broker/redoc-static.html index f66e2520..133d60e3 100644 --- a/broker/redoc-static.html +++ b/broker/redoc-static.html @@ -790,7 +790,7 @@ This can only be done when detector is Idle, Error or
http://localhost:5232/config/roi

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": {
    }
}

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": {
    }
}

Get data collection statistics

Results of the last data collection

Responses

Response samples

Content type
application/json
{
  • "min_image_number": 0,
  • "max_image_number": 0,
  • "image_numbers": [
    ],
  • "total_slots": 0,
  • "available_slots": 0,
  • "current_counter": 0
}

Get Jungfraujoch version of jfjoch_broker

Responses

Response samples

Content type
application/json
{
  • "min_image_number": 0,
  • "max_image_number": 0,
  • "image_numbers": [
    ],
  • "total_slots": 0,
  • "available_slots": 0,
  • "in_preparation_slots": 0,
  • "in_sending_slots": 0,
  • "current_counter": 0
}

Get Jungfraujoch version of jfjoch_broker

Responses