jfjoch_broker: Add binary plot option

This commit is contained in:
2025-12-06 22:14:41 +01:00
parent 7c63e90c2d
commit 6d12773b28
10 changed files with 205 additions and 11 deletions

View File

@@ -579,6 +579,28 @@ void JFJochBrokerHttp::preview_plot_get(const std::optional<std::string> &type,
ProcessOutput(Convert(plot), response, compression.value_or(false));
}
void JFJochBrokerHttp::preview_plot_bin_get(const std::optional<std::string> &type,
Pistache::Http::ResponseWriter &response) {
PlotRequest req{
.type = ConvertPlotType(type),
.binning = 1,
.experimental_coord = false,
.azint_unit = PlotAzintUnit::Q_recipA,
.fill_value = NAN
};
auto plots_container = state_machine.GetPlots(req);
const auto &plots = plots_container.GetPlots();
if (plots.empty())
response.send(Pistache::Http::Code::Ok);
else
response.send(Pistache::Http::Code::Ok,
reinterpret_cast<const char *>(plots[0].y.data()),
plots[0].y.size() * sizeof(float),
Pistache::Http::Mime::MediaType::fromString("application/octet-stream"));
}
void JFJochBrokerHttp::config_indexing_get(Pistache::Http::ResponseWriter &response) {
ProcessOutput(Convert(state_machine.GetIndexingSettings()), response);
}

View File

@@ -169,6 +169,7 @@ class JFJochBrokerHttp : public org::openapitools::server::api::DefaultApi {
const std::optional<bool> &compression, const std::optional<float> &fill,
const std::optional<bool> &experimentalCoord, const std::optional<std::string> &azintUnit,
Pistache::Http::ResponseWriter &response) override;
void preview_plot_bin_get(const std::optional<std::string> &type, Pistache::Http::ResponseWriter &response) override;
void config_indexing_get(Pistache::Http::ResponseWriter &response) override;

View File

@@ -80,6 +80,7 @@ void DefaultApi::setupRoutes() {
Routes::Post(*router, base + "/initialize", Routes::bind(&DefaultApi::initialize_post_handler, this));
Routes::Post(*router, base + "/pedestal", Routes::bind(&DefaultApi::pedestal_post_handler, this));
Routes::Get(*router, base + "/preview/pedestal.tiff", Routes::bind(&DefaultApi::preview_pedestal_tiff_get_handler, this));
Routes::Get(*router, base + "/preview/plot.bin", Routes::bind(&DefaultApi::preview_plot_bin_get_handler, this));
Routes::Get(*router, base + "/preview/plot", Routes::bind(&DefaultApi::preview_plot_get_handler, this));
Routes::Get(*router, base + "/result/scan", Routes::bind(&DefaultApi::result_scan_get_handler, this));
Routes::Post(*router, base + "/start", Routes::bind(&DefaultApi::start_post_handler, this));
@@ -1279,6 +1280,35 @@ void DefaultApi::preview_pedestal_tiff_get_handler(const Pistache::Rest::Request
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::preview_plot_bin_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {
// Getting the query params
auto typeQuery = request.query().get("type");
std::optional<std::string> type;
if(typeQuery.has_value()){
std::string valueQuery_instance;
if(fromStringValue(typeQuery.value(), valueQuery_instance)){
type = valueQuery_instance;
}
}
try {
this->preview_plot_bin_get(type, response);
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
this->handleOperationException(e, response);
return;
}
} catch (std::exception &e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void DefaultApi::preview_plot_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
try {

View File

@@ -116,6 +116,7 @@ private:
void initialize_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void pedestal_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void preview_pedestal_tiff_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void preview_plot_bin_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void preview_plot_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void result_scan_get_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void start_post_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
@@ -514,6 +515,14 @@ private:
/// <param name="sc">Storage cell number (optional, default to 0)</param>
virtual void preview_pedestal_tiff_get(const std::optional<int32_t> &gainLevel, const std::optional<int32_t> &sc, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Generate 1D plot from Jungfraujoch and send in binary format. This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset. No binning is available.
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="type">Type of requested plot</param>
virtual void preview_plot_bin_get(const std::optional<std::string> &type, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Generate 1D plot from Jungfraujoch
/// </summary>
/// <remarks>

View File

@@ -3136,6 +3136,29 @@ paths:
schema:
type: string
description: Exception error
/preview/plot.bin:
get:
summary: |
Generate 1D plot from Jungfraujoch and send in binary format.
This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset.
No binning is available.
parameters:
- $ref: "#/components/parameters/plot_type"
responses:
"200":
description: Everything OK.
content:
application/octet-stream:
schema:
type: string
format: binary
"400":
description: Input parsing or validation error
content:
text/plain:
schema:
type: string
description: Exception error
/result/scan:
get:
summary: Get full scan result

File diff suppressed because one or more lines are too long

View File

@@ -148,6 +148,7 @@ Class | Method | HTTP request | Description
*DefaultApi* | [**initialize_post**](docs/DefaultApi.md#initialize_post) | **POST** /initialize | Initialize detector and data acquisition
*DefaultApi* | [**pedestal_post**](docs/DefaultApi.md#pedestal_post) | **POST** /pedestal | Collect dark current for the detector
*DefaultApi* | [**preview_pedestal_tiff_get**](docs/DefaultApi.md#preview_pedestal_tiff_get) | **GET** /preview/pedestal.tiff | Get pedestal in TIFF format
*DefaultApi* | [**preview_plot_bin_get**](docs/DefaultApi.md#preview_plot_bin_get) | **GET** /preview/plot.bin | Generate 1D plot from Jungfraujoch and send in binary format. This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset. No binning is available.
*DefaultApi* | [**preview_plot_get**](docs/DefaultApi.md#preview_plot_get) | **GET** /preview/plot | Generate 1D plot from Jungfraujoch
*DefaultApi* | [**result_scan_get**](docs/DefaultApi.md#result_scan_get) | **GET** /result/scan | Get full scan result
*DefaultApi* | [**start_post**](docs/DefaultApi.md#start_post) | **POST** /start | Start detector

View File

@@ -51,6 +51,7 @@ Method | HTTP request | Description
[**initialize_post**](DefaultApi.md#initialize_post) | **POST** /initialize | Initialize detector and data acquisition
[**pedestal_post**](DefaultApi.md#pedestal_post) | **POST** /pedestal | Collect dark current for the detector
[**preview_pedestal_tiff_get**](DefaultApi.md#preview_pedestal_tiff_get) | **GET** /preview/pedestal.tiff | Get pedestal in TIFF format
[**preview_plot_bin_get**](DefaultApi.md#preview_plot_bin_get) | **GET** /preview/plot.bin | Generate 1D plot from Jungfraujoch and send in binary format. This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset. No binning is available.
[**preview_plot_get**](DefaultApi.md#preview_plot_get) | **GET** /preview/plot | Generate 1D plot from Jungfraujoch
[**result_scan_get**](DefaultApi.md#result_scan_get) | **GET** /result/scan | Get full scan result
[**start_post**](DefaultApi.md#start_post) | **POST** /start | Start detector
@@ -3138,6 +3139,72 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **preview_plot_bin_get**
> bytearray preview_plot_bin_get(type)
Generate 1D plot from Jungfraujoch and send in binary format. This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset. No binning is available.
### Example
```python
import jfjoch_client
from jfjoch_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:5232
# See configuration.py for a list of all supported configuration parameters.
configuration = jfjoch_client.Configuration(
host = "http://localhost:5232"
)
# Enter a context with an instance of the API client
with jfjoch_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = jfjoch_client.DefaultApi(api_client)
type = 'type_example' # str | Type of requested plot
try:
# Generate 1D plot from Jungfraujoch and send in binary format. This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset. No binning is available.
api_response = api_instance.preview_plot_bin_get(type)
print("The response of DefaultApi->preview_plot_bin_get:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling DefaultApi->preview_plot_bin_get: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**type** | **str**| Type of requested plot |
### Return type
**bytearray**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/octet-stream, text/plain
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | Everything OK. | - |
**400** | Input parsing or validation error | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **preview_plot_get**
> Plots preview_plot_get(type, binning=binning, compression=compression, fill=fill, experimental_coord=experimental_coord, azint_unit=azint_unit)

View File

@@ -1,12 +1,12 @@
{
"name": "jungfraujoch-frontend",
"version": "1.0.0-rc.118",
"version": "1.0.0-rc.119",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jungfraujoch-frontend",
"version": "1.0.0-rc.118",
"version": "1.0.0-rc.119",
"license": "GPL-3.0",
"dependencies": {
"@emotion/react": "^11.10.4",

View File

@@ -1015,6 +1015,30 @@ export class DefaultService {
});
}
/**
* Generate 1D plot from Jungfraujoch and send in binary format.
* This format is unsuitable for azimuthal integration plots, only to per image plots for a dataset.
* No binning is available.
*
* @param type Type of requested plot
* @returns binary Everything OK.
* @throws ApiError
*/
public static getPreviewPlotBin(
type: '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' | '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',
): CancelablePromise<Blob> {
return __request(OpenAPI, {
method: 'GET',
url: '/preview/plot.bin',
query: {
'type': type,
},
errors: {
400: `Input parsing or validation error`,
},
});
}
/**
* Get full scan result
* @returns scan_result Everything OK.