Files
Jungfraujoch/common/StatusVector.h
Filip Leonarski 36d0507758
Some checks failed
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 10m11s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 10m22s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 10m27s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 8m19s
Build Packages / Generate python client (push) Successful in 17s
Build Packages / Build documentation (push) Successful in 42s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m44s
Build Packages / build:rpm (rocky8) (push) Successful in 8m44s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 8m33s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 9m11s
Build Packages / build:rpm (rocky9) (push) Successful in 9m54s
Build Packages / Unit tests (push) Failing after 1h11m12s
v1.0.0-rc.119 (#26)
This is an UNSTABLE release and not recommended for production use (please use rc.111 instead).

* jfjoch_broker: Add binary export of data analysis plots over OpenAPI
* jfjoch_broker: Minor fixes to HTTP error handling
* jfjoch_viewer: Prefer binary plots over JSON plots
* jfjoch_viewer: Change foreground with F button + wheel
* jfjoch_viewer: Change way how angles are displayed
* jfjoch_viewer: Display resolution of the mouse cursor in top left corner

Reviewed-on: #26
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
2025-12-08 19:53:35 +01:00

60 lines
2.4 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef JUNGFRAUJOCH_STATUSVECTOR_H
#define JUNGFRAUJOCH_STATUSVECTOR_H
#include <vector>
#include <map>
#include <mutex>
#include <cmath>
#include <optional>
#include <memory>
#include "JFJochException.h"
#include "MultiLinePlot.h"
class StatusVector {
mutable std::mutex m;
std::vector<float> content;
float mean = NAN;
size_t count = 0;
double sum = 0;
public:
void Clear();
void AddElement(uint32_t id, std::optional<float> val);
void AddElement(uint32_t id, float val);
std::optional<float> GetElement(uint32_t id) const;
size_t GetImageNumber() const;
bool empty() const;
int32_t GetActualBinning(int32_t bin_size) const;
[[nodiscard]] std::vector<float> ExportArray(float def_value) const;
[[nodiscard]] float Mean() const;
MultiLinePlotStruct GetMeanPerBin(int32_t bin_size, float x_start, float x_incr,
const std::optional<float> &fill_value = {}) const;
[[nodiscard]] MultiLinePlotStruct GetMaxPerBin(int32_t bin_size, float x_start, float x_incr,
const std::optional<float> &fill_value = {}) const;
MultiLinePlot GetMeanPlot(int64_t bin_size, float x_start, float x_incr,
const std::optional<float> &fill_value = {}) const;
MultiLinePlot GetMaxPlot(int64_t bin_size, float x_start, float x_incr,
const std::optional<float> &fill_value = {}) const;
};
class StatusMultiVector {
std::mutex m;
std::map<std::string, std::unique_ptr<StatusVector>> status;
public:
void Clear();
void AddElement(const std::string& s, uint32_t id, float val);
void AddElement(const std::string& s, uint32_t id, std::optional<float> val);
[[nodiscard]] MultiLinePlotStruct GetMeanPerBin(const std::string& in_key, int64_t bin_size, float x_start, float x_incr,
const std::optional<float> &fill_value = {}) const;
[[nodiscard]] MultiLinePlot GetMeanPlot(int64_t bin_size, float x_start, float x_incr,
const std::optional<float> &fill_value = {}) const;
[[nodiscard]] std::vector<float> ExportArray(const std::string& s, float def_value) const;
};
#endif //JUNGFRAUJOCH_STATUSVECTOR_H