From 57f0a1f5dd71af03e32f7de031cdda2bb475529e Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 24 Mar 2026 14:11:40 +0100 Subject: [PATCH] Minor fixes to httplib/OpenAPI --- broker/JFJochBrokerHttp.cpp | 12 +++++------- broker/JFJochBrokerHttp.h | 8 +++----- broker/jfjoch_api.yaml | 11 ----------- broker/redoc-static.html | 6 ++---- docs/python_client/docs/DefaultApi.md | 16 +++++----------- frontend/src/openapi/index.ts | 1 - frontend/src/openapi/models/compression.ts | 9 --------- frontend/src/openapi/services/DefaultService.ts | 11 +---------- 8 files changed, 16 insertions(+), 58 deletions(-) delete mode 100644 frontend/src/openapi/models/compression.ts diff --git a/broker/JFJochBrokerHttp.cpp b/broker/JFJochBrokerHttp.cpp index d7a4b6db..dd5c48d1 100644 --- a/broker/JFJochBrokerHttp.cpp +++ b/broker/JFJochBrokerHttp.cpp @@ -310,7 +310,6 @@ void JFJochBrokerHttp::register_routes(httplib::Server &server) { try { preview_plot_get(parse_query_string(req, "type"), parse_query_value(req, "binning"), - parse_query_value(req, "compression"), parse_query_value(req, "fill"), parse_query_value(req, "experimental_coord"), parse_query_string(req, "azint_unit"), @@ -328,7 +327,7 @@ void JFJochBrokerHttp::register_routes(httplib::Server &server) { server.Get("/statistics", [this](const httplib::Request &req, httplib::Response &res) { try { - statistics_get(parse_query_value(req, "compression"), res); + statistics_get(res); } catch (const std::exception &e) { auto [c, s] = handleOperationException(e); send_plain(res, c, s); @@ -462,6 +461,7 @@ void JFJochBrokerHttp::statistics_calibration_get(httplib::Response &response) { nlohmann::json j; for (const auto &d: Convert(state_machine.GetCalibrationStatistics())) j.push_back(d); + logger.Info("Calibration statistics: {}", j.dump()); response.set_content(j.dump(), "application/json"); response.status = 200; } @@ -512,7 +512,7 @@ void JFJochBrokerHttp::fpga_status_get(httplib::Response &response) { response.status = 200; } -void JFJochBrokerHttp::statistics_get(const std::optional &compression, httplib::Response &response) { +void JFJochBrokerHttp::statistics_get(httplib::Response &response) { Jfjoch_statistics statistics; auto data_collection_statistics = state_machine.GetMeasurementStatistics(); @@ -774,7 +774,7 @@ void JFJochBrokerHttp::config_indexing_put(const Indexing_settings &indexingSett void JFJochBrokerHttp::result_scan_get(httplib::Response &response) { auto ret = state_machine.GetScanResult(); if (ret.has_value()) - ProcessOutput(Convert(ret.value()), response, true); + ProcessOutput(Convert(ret.value()), response); else response.status = 404; } @@ -832,7 +832,6 @@ void JFJochBrokerHttp::preview_plot_bin_get(const std::optional &ty void JFJochBrokerHttp::preview_plot_get(const std::optional &type, const std::optional &binning, - const std::optional &compression, const std::optional &fill, const std::optional &experimentalCoord, const std::optional &azintUnit, @@ -863,9 +862,8 @@ void JFJochBrokerHttp::preview_plot_get(const std::optional &type, } req.binning = binning.value(); } - auto plot = state_machine.GetPlots(req); - ProcessOutput(Convert(plot), response, compression.value_or(false)); + ProcessOutput(Convert(plot), response); } void JFJochBrokerHttp::config_roi_get(httplib::Response &response) { diff --git a/broker/JFJochBrokerHttp.h b/broker/JFJochBrokerHttp.h index 64072297..3cfe134e 100644 --- a/broker/JFJochBrokerHttp.h +++ b/broker/JFJochBrokerHttp.h @@ -50,7 +50,7 @@ class JFJochBrokerHttp { } template - void ProcessOutput(const T &output, httplib::Response &response, bool compression = false) { + void ProcessOutput(const T &output, httplib::Response &response) { std::stringstream s; if (!output.validate(s)) { logger.Error(s.str()); @@ -60,8 +60,6 @@ class JFJochBrokerHttp { } nlohmann::json j = output; - if (compression) - response.set_header("Content-Encoding", "deflate"); response.status = 200; response.set_content(j.dump(), "application/json"); } @@ -113,7 +111,7 @@ class JFJochBrokerHttp { void fpga_status_get(httplib::Response &response); - void statistics_get(const std::optional &compression, httplib::Response &response); + void statistics_get(httplib::Response &response); void config_zeromq_preview_get(httplib::Response &response); void config_zeromq_preview_put(const org::openapitools::server::model::Zeromq_preview_settings &zeromqPreviewSettings, @@ -151,7 +149,7 @@ class JFJochBrokerHttp { void preview_plot_bin_get(const std::optional &type, const std::optional &roi, httplib::Response &response); void preview_plot_get(const std::optional &type, const std::optional &binning, - const std::optional &compression, const std::optional &fill, + const std::optional &fill, const std::optional &experimentalCoord, const std::optional &azintUnit, httplib::Response &response); diff --git a/broker/jfjoch_api.yaml b/broker/jfjoch_api.yaml index 4d1b2385..d67990fb 100644 --- a/broker/jfjoch_api.yaml +++ b/broker/jfjoch_api.yaml @@ -42,14 +42,6 @@ components: default: 1 type: integer description: Binning of frames for the plot (0 = default binning) - compression: - in: query - name: compression - required: false - schema: - type: boolean - default: false - description: Enable DEFLATE compression of output data. experimental_coord: in: query name: experimental_coord @@ -3082,8 +3074,6 @@ paths: /statistics: get: summary: Get general statistics - parameters: - - $ref: '#/components/parameters/compression' responses: "200": description: Everything OK @@ -3258,7 +3248,6 @@ paths: summary: Generate 1D plot from Jungfraujoch parameters: - $ref: "#/components/parameters/binning" - - $ref: "#/components/parameters/compression" - $ref: "#/components/parameters/plot_type" - $ref: "#/components/parameters/fill_value" - $ref: "#/components/parameters/experimental_coord" diff --git a/broker/redoc-static.html b/broker/redoc-static.html index 5afd1ef4..2b631c89 100644 --- a/broker/redoc-static.html +++ b/broker/redoc-static.html @@ -790,8 +790,7 @@ This can only be done when detector is Idle, Error or

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

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

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

Responses

Generate 1D plot from Jungfraujoch

query Parameters
binning
integer
Default: 1

Binning of frames for the plot (0 = default binning)

-
compression
boolean
Default: false

Enable DEFLATE compression of output data.

type
required
string
Enum: "bkg_estimate" "azint" "azint_1d" "spot_count" "spot_count_low_res" "spot_count_indexed" "spot_count_ice" "indexing_rate" "indexing_time" "indexing_unit_cell_length" "indexing_unit_cell_angle" "profile_radius" "mosaicity" "b_factor" "error_pixels" "saturated_pixels" "image_collection_efficiency" "receiver_delay" "receiver_free_send_buf" "strong_pixels" "roi_sum" "roi_mean" "roi_max_count" "roi_pixels" "roi_weighted_x" "roi_weighted_y" "packets_received" "max_pixel_value" "resolution_estimate" "pixel_sum" "processing_time" "beam_center_x" "beam_center_y"

Type of requested plot

fill
number <float>

Fill value for elements that were missed during data collection

experimental_coord
boolean
Default: false

If measurement has goniometer axis defined, plot X-axis will represent rotation angle @@ -915,7 +913,7 @@ then image might be replaced in the buffer between calling /images and /image.cb