From bf1461acd585a2f5fede6bad4e1366c57f5199e7 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 10 Nov 2026 16:06:38 +0100 Subject: [PATCH] Regenerate the OpenAPI clients and redoc page for the Q binning settings Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK --- broker/gen/model/Azim_int_settings.cpp | 103 ++++++++++++++++-- broker/gen/model/Azim_int_settings.h | 25 ++++- broker/gen/model/Q_binning.cpp | 116 +++++++++++++++++++++ broker/gen/model/Q_binning.h | 79 ++++++++++++++ broker/redoc-static.html | 17 ++- docs/python_client/README.md | 1 + docs/python_client/docs/AzimIntSettings.md | 4 +- docs/python_client/docs/QBinning.md | 13 +++ frontend/src/client/index.ts | 2 +- frontend/src/client/types.gen.ts | 30 +++++- frontend/src/client/zod.gen.ts | 12 ++- 11 files changed, 385 insertions(+), 17 deletions(-) create mode 100644 broker/gen/model/Q_binning.cpp create mode 100644 broker/gen/model/Q_binning.h create mode 100644 docs/python_client/docs/QBinning.md diff --git a/broker/gen/model/Azim_int_settings.cpp b/broker/gen/model/Azim_int_settings.cpp index 0f6e1f05b..ea59ab9f6 100644 --- a/broker/gen/model/Azim_int_settings.cpp +++ b/broker/gen/model/Azim_int_settings.cpp @@ -27,6 +27,10 @@ Azim_int_settings::Azim_int_settings() m_High_q_recipAIsSet = false; m_Low_q_recipA = 0.0f; m_Q_spacing = 0.0f; + m_Q_spacingIsSet = false; + m_Q_bins = 0L; + m_Q_binsIsSet = false; + m_Q_binningIsSet = false; m_Azimuthal_bins = 1L; m_Azimuthal_binsIsSet = false; m_Force_cpu = false; @@ -92,8 +96,8 @@ bool Azim_int_settings::validate(std::stringstream& msg, const std::string& path } - - /* Q_spacing */ { + if (qSpacingIsSet()) + { const float& value = m_Q_spacing; const std::string currentValuePath = _pathPrefix + ".qSpacing"; @@ -106,6 +110,25 @@ bool Azim_int_settings::validate(std::stringstream& msg, const std::string& path } + if (qBinsIsSet()) + { + const int64_t& value = m_Q_bins; + const std::string currentValuePath = _pathPrefix + ".qBins"; + + + if (value < 1ll) + { + success = false; + msg << currentValuePath << ": must be greater than or equal to 1;"; + } + if (value > 65534ll) + { + success = false; + msg << currentValuePath << ": must be less than or equal to 65534;"; + } + + } + if (azimuthalBinsIsSet()) { const int64_t& value = m_Azimuthal_bins; @@ -145,8 +168,14 @@ bool Azim_int_settings::operator==(const Azim_int_settings& rhs) const (getLowQRecipA() == rhs.getLowQRecipA()) && - (getQSpacing() == rhs.getQSpacing()) - && + + ((!qSpacingIsSet() && !rhs.qSpacingIsSet()) || (qSpacingIsSet() && rhs.qSpacingIsSet() && getQSpacing() == rhs.getQSpacing())) && + + + ((!qBinsIsSet() && !rhs.qBinsIsSet()) || (qBinsIsSet() && rhs.qBinsIsSet() && getQBins() == rhs.getQBins())) && + + + ((!qBinningIsSet() && !rhs.qBinningIsSet()) || (qBinningIsSet() && rhs.qBinningIsSet() && getQBinning() == rhs.getQBinning())) && ((!azimuthalBinsIsSet() && !rhs.azimuthalBinsIsSet()) || (azimuthalBinsIsSet() && rhs.azimuthalBinsIsSet() && getAzimuthalBins() == rhs.getAzimuthalBins())) && @@ -170,7 +199,12 @@ void to_json(nlohmann::json& j, const Azim_int_settings& o) if(o.highQRecipAIsSet()) j["high_q_recipA"] = o.m_High_q_recipA; j["low_q_recipA"] = o.m_Low_q_recipA; - j["q_spacing"] = o.m_Q_spacing; + if(o.qSpacingIsSet()) + j["q_spacing"] = o.m_Q_spacing; + if(o.qBinsIsSet()) + j["q_bins"] = o.m_Q_bins; + if(o.qBinningIsSet()) + j["q_binning"] = o.m_Q_binning; if(o.azimuthalBinsIsSet()) j["azimuthal_bins"] = o.m_Azimuthal_bins; if(o.forceCpuIsSet()) @@ -188,7 +222,21 @@ void from_json(const nlohmann::json& j, Azim_int_settings& o) o.m_High_q_recipAIsSet = true; } j.at("low_q_recipA").get_to(o.m_Low_q_recipA); - j.at("q_spacing").get_to(o.m_Q_spacing); + if(j.find("q_spacing") != j.end()) + { + j.at("q_spacing").get_to(o.m_Q_spacing); + o.m_Q_spacingIsSet = true; + } + if(j.find("q_bins") != j.end()) + { + j.at("q_bins").get_to(o.m_Q_bins); + o.m_Q_binsIsSet = true; + } + if(j.find("q_binning") != j.end()) + { + j.at("q_binning").get_to(o.m_Q_binning); + o.m_Q_binningIsSet = true; + } if(j.find("azimuthal_bins") != j.end()) { j.at("azimuthal_bins").get_to(o.m_Azimuthal_bins); @@ -250,6 +298,49 @@ float Azim_int_settings::getQSpacing() const void Azim_int_settings::setQSpacing(float const value) { m_Q_spacing = value; + m_Q_spacingIsSet = true; +} +bool Azim_int_settings::qSpacingIsSet() const +{ + return m_Q_spacingIsSet; +} +void Azim_int_settings::unsetQ_spacing() +{ + m_Q_spacingIsSet = false; +} +int64_t Azim_int_settings::getQBins() const +{ + return m_Q_bins; +} +void Azim_int_settings::setQBins(int64_t const value) +{ + m_Q_bins = value; + m_Q_binsIsSet = true; +} +bool Azim_int_settings::qBinsIsSet() const +{ + return m_Q_binsIsSet; +} +void Azim_int_settings::unsetQ_bins() +{ + m_Q_binsIsSet = false; +} +org::openapitools::server::model::Q_binning Azim_int_settings::getQBinning() const +{ + return m_Q_binning; +} +void Azim_int_settings::setQBinning(org::openapitools::server::model::Q_binning const& value) +{ + m_Q_binning = value; + m_Q_binningIsSet = true; +} +bool Azim_int_settings::qBinningIsSet() const +{ + return m_Q_binningIsSet; +} +void Azim_int_settings::unsetQ_binning() +{ + m_Q_binningIsSet = false; } int64_t Azim_int_settings::getAzimuthalBins() const { diff --git a/broker/gen/model/Azim_int_settings.h b/broker/gen/model/Azim_int_settings.h index f8ef7ad05..bb13b651b 100644 --- a/broker/gen/model/Azim_int_settings.h +++ b/broker/gen/model/Azim_int_settings.h @@ -19,6 +19,7 @@ #define Azim_int_settings_H_ +#include "Q_binning.h" #include namespace org::openapitools::server::model @@ -80,10 +81,26 @@ public: float getLowQRecipA() const; void setLowQRecipA(float const value); /// - /// + /// Width of a Q bin [1/Angstrom], for linear binning only. Linear binning takes either this or `q_bins`, not both; with neither, the spacing is 0.01 1/Angstrom. /// float getQSpacing() const; void setQSpacing(float const value); + bool qSpacingIsSet() const; + void unsetQ_spacing(); + /// + /// Number of Q bins between low and high Q. Required for `log10` binning; for `linear` binning an alternative to `q_spacing`. + /// + int64_t getQBins() const; + void setQBins(int64_t const value); + bool qBinsIsSet() const; + void unsetQ_bins(); + /// + /// + /// + org::openapitools::server::model::Q_binning getQBinning() const; + void setQBinning(org::openapitools::server::model::Q_binning const& value); + bool qBinningIsSet() const; + void unsetQ_binning(); /// /// Numer of azimuthal (phi) bins; 1 = standard 1D azimuthal integration /// @@ -111,7 +128,11 @@ protected: float m_Low_q_recipA; float m_Q_spacing; - + bool m_Q_spacingIsSet; + int64_t m_Q_bins; + bool m_Q_binsIsSet; + org::openapitools::server::model::Q_binning m_Q_binning; + bool m_Q_binningIsSet; int64_t m_Azimuthal_bins; bool m_Azimuthal_binsIsSet; bool m_Force_cpu; diff --git a/broker/gen/model/Q_binning.cpp b/broker/gen/model/Q_binning.cpp new file mode 100644 index 000000000..b50a1fdb5 --- /dev/null +++ b/broker/gen/model/Q_binning.cpp @@ -0,0 +1,116 @@ +/** +* Jungfraujoch +* API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates. # License Clarification While this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply** when this file is used solely to generate OpenAPI clients or when implementing applications that interact with the API. Generated client code and applications using this API definition are not subject to the GPL license requirements and may be distributed under terms of your choosing. This exception is similar in spirit to the Linux Kernel's approach to userspace API headers and the GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that user programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not derivative works of the kernel and are not subject to the terms of the GPL. This exception is intended to allow wider use of this API specification without imposing GPL requirements on applications that merely interact with the API, regardless of whether they communicate through network calls or other mechanisms. +* +* The version of the OpenAPI document: 1.0.0-rc.184 +* Contact: filip.leonarski@psi.ch +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ + + +#include "Q_binning.h" +#include "Helpers.h" +#include +#include + +namespace org::openapitools::server::model +{ + +Q_binning::Q_binning() +{ + +} + +void Q_binning::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Q_binning::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool Q_binning::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Q_binning" : pathPrefix; + + + if (m_value == Q_binning::eQ_binning::INVALID_VALUE_OPENAPI_GENERATED) + { + success = false; + msg << _pathPrefix << ": has no value;"; + } + + return success; +} + +bool Q_binning::operator==(const Q_binning& rhs) const +{ + return + getValue() == rhs.getValue() + + ; +} + +bool Q_binning::operator!=(const Q_binning& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const Q_binning& o) +{ + j = nlohmann::json::object(); + + switch (o.getValue()) + { + case Q_binning::eQ_binning::INVALID_VALUE_OPENAPI_GENERATED: + j = "INVALID_VALUE_OPENAPI_GENERATED"; + break; + case Q_binning::eQ_binning::LINEAR: + j = "linear"; + break; + case Q_binning::eQ_binning::LOG10: + j = "log10"; + break; + } +} + +void from_json(const nlohmann::json& j, Q_binning& o) +{ + + auto s = j.get(); + if (s == "linear") { + o.setValue(Q_binning::eQ_binning::LINEAR); + } + else if (s == "log10") { + o.setValue(Q_binning::eQ_binning::LOG10); + } else { + std::stringstream ss; + ss << "Unexpected value " << s << " in json" + << " cannot be converted to enum of type" + << " Q_binning::eQ_binning"; + throw std::invalid_argument(ss.str()); + } + +} + +Q_binning::eQ_binning Q_binning::getValue() const +{ + return m_value; +} +void Q_binning::setValue(Q_binning::eQ_binning value) +{ + m_value = value; +} + +} // namespace org::openapitools::server::model + diff --git a/broker/gen/model/Q_binning.h b/broker/gen/model/Q_binning.h new file mode 100644 index 000000000..7f950f58b --- /dev/null +++ b/broker/gen/model/Q_binning.h @@ -0,0 +1,79 @@ +/** +* Jungfraujoch +* API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates. # License Clarification While this API definition is licensed under GPL-3.0, **the GPL copyleft provisions do not apply** when this file is used solely to generate OpenAPI clients or when implementing applications that interact with the API. Generated client code and applications using this API definition are not subject to the GPL license requirements and may be distributed under terms of your choosing. This exception is similar in spirit to the Linux Kernel's approach to userspace API headers and the GCC Runtime Library Exception. The Linux Kernel developers have explicitly stated that user programs that merely use the kernel interfaces (syscalls, ioctl definitions, etc.) are not derivative works of the kernel and are not subject to the terms of the GPL. This exception is intended to allow wider use of this API specification without imposing GPL requirements on applications that merely interact with the API, regardless of whether they communicate through network calls or other mechanisms. +* +* The version of the OpenAPI document: 1.0.0-rc.184 +* Contact: filip.leonarski@psi.ch +* +* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +* https://openapi-generator.tech +* Do not edit the class manually. +*/ +/* + * Q_binning.h + * + * How the Q bins of azimuthal integration are laid out between low and high Q. linear - equal steps in Q. log10 - equal steps in log10(Q): fine bins at low Q, coarse at high Q. Needs `q_bins`. + */ + +#ifndef Q_binning_H_ +#define Q_binning_H_ + + +#include + +namespace org::openapitools::server::model +{ + +/// +/// How the Q bins of azimuthal integration are laid out between low and high Q. linear - equal steps in Q. log10 - equal steps in log10(Q): fine bins at low Q, coarse at high Q. Needs `q_bins`. +/// +class Q_binning +{ +public: + Q_binning(); + virtual ~Q_binning() = default; + + enum class eQ_binning { + // To have a valid default value. + // Avoiding name clashes with user defined + // enum values + INVALID_VALUE_OPENAPI_GENERATED = 0, + LINEAR, + LOG10 + }; + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + /// + /// Helper overload for validate. Used when one model stores another model and calls it's validate. + /// Not meant to be called outside that case. + /// + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; + + bool operator==(const Q_binning& rhs) const; + bool operator!=(const Q_binning& rhs) const; + + ///////////////////////////////////////////// + /// Q_binning members + + Q_binning::eQ_binning getValue() const; + void setValue(Q_binning::eQ_binning value); + + friend void to_json(nlohmann::json& j, const Q_binning& o); + friend void from_json(const nlohmann::json& j, Q_binning& o); +protected: + Q_binning::eQ_binning m_value = Q_binning::eQ_binning::INVALID_VALUE_OPENAPI_GENERATED; +}; + +} // namespace org::openapitools::server::model + +#endif /* Q_binning_H_ */ diff --git a/broker/redoc-static.html b/broker/redoc-static.html index af44de58c..5a5fcf076 100644 --- a/broker/redoc-static.html +++ b/broker/redoc-static.html @@ -814,7 +814,14 @@ About 100 suits a multi-megapixel detector. Ignored unless adaptive_threshold is high_q_recipA
number <float> [ 0.00002 .. 10 ]

Upper q limit of the azimuthal integration [1/Angstrom]. Optional: if omitted, the integration (and the adaptive spot detection that shares these q bins) extends to the highest q the detector reaches.

-
low_q_recipA
required
number <float> [ 0.00001 .. 10 ]
q_spacing
required
number <float> >= 0.00001
azimuthal_bins
integer <int64> [ 1 .. 512 ]
Default: 1

Numer of azimuthal (phi) bins; 1 = standard 1D azimuthal integration

+
low_q_recipA
required
number <float> [ 0.00001 .. 10 ]
q_spacing
number <float> >= 0.00001

Width of a Q bin [1/Angstrom], for linear binning only. Linear binning takes either this or +q_bins, not both; with neither, the spacing is 0.01 1/Angstrom.

+
q_bins
integer <int64> [ 1 .. 65534 ]

Number of Q bins between low and high Q. Required for log10 binning; for linear binning +an alternative to q_spacing.

+
q_binning
string (q_binning)
Default: "linear"
Enum: "linear" "log10"

How the Q bins of azimuthal integration are laid out between low and high Q. +linear - equal steps in Q. +log10 - equal steps in log10(Q): fine bins at low Q, coarse at high Q. Needs q_bins.

+
azimuthal_bins
integer <int64> [ 1 .. 512 ]
Default: 1

Numer of azimuthal (phi) bins; 1 = standard 1D azimuthal integration

force_cpu
boolean
Default: false

Force CPU processing of azimuthal integration in the FPGA data acquisition workflow. This allows to extend number of azimuthal integration bins, as well as to calculate standard deviation of the azimuthal integration results.

@@ -822,10 +829,10 @@ of the azimuthal integration results.

Request samples

Content type
application/json
{
  • "polarization_corr": true,
  • "solid_angle_corr": true,
  • "high_q_recipA": 0.00002,
  • "low_q_recipA": 0.00001,
  • "q_spacing": 0.00001,
  • "azimuthal_bins": 1,
  • "force_cpu": false
}

Response samples

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

Get azimuthal integration configuration

Can be done anytime

+
http://localhost:5232/config/azim_int

Request samples

Content type
application/json
{
  • "polarization_corr": true,
  • "solid_angle_corr": true,
  • "high_q_recipA": 0.00002,
  • "low_q_recipA": 0.00001,
  • "q_spacing": 0.00001,
  • "q_bins": 1,
  • "q_binning": "linear",
  • "azimuthal_bins": 1,
  • "force_cpu": false
}

Response samples

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

Get azimuthal integration configuration

Can be done anytime

Responses

Response samples

Content type
application/json
{
  • "polarization_corr": true,
  • "solid_angle_corr": true,
  • "high_q_recipA": 0.00002,
  • "low_q_recipA": 0.00001,
  • "q_spacing": 0.00001,
  • "azimuthal_bins": 1,
  • "force_cpu": false
}

Load binary image for internal FPGA generator

Load image for internal FPGA generator. This can only happen in Idle state of the detector. +

http://localhost:5232/config/azim_int

Response samples

Content type
application/json
{
  • "polarization_corr": true,
  • "solid_angle_corr": true,
  • "high_q_recipA": 0.00002,
  • "low_q_recipA": 0.00001,
  • "q_spacing": 0.00001,
  • "q_bins": 1,
  • "q_binning": "linear",
  • "azimuthal_bins": 1,
  • "force_cpu": false
}

Load binary image for internal FPGA generator

Load image for internal FPGA generator. This can only happen in Idle state of the detector. Requires binary blob with 16-bit integer numbers of size of detector in raw/converted coordinates (depending on detector settings).

query Parameters
id
integer <int64> [ 0 .. 127 ]

Image id to upload

@@ -985,7 +992,7 @@ This can only be done when detector is Idle, Error or dataset (see tokens in /start).

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": {
    },
  • "bragg_integration": {
    },
  • "image_pusher": {
    }
}

Get data collection statistics

Results of the last data collection (dataset name, unit cell, ...)

+
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": {
    },
  • "bragg_integration": {
    },
  • "image_pusher": {
    }
}

Get data collection statistics

Results of the last data collection (dataset name, unit cell, ...)

Authorizations:
bearerAuth

Responses