65 lines
2.0 KiB
C++
65 lines
2.0 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#ifndef JUNGFRAUJOCH_CBORSTREAM2DESERIALIZER_H
|
|
#define JUNGFRAUJOCH_CBORSTREAM2DESERIALIZER_H
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
|
|
#include "../common/SpotToSave.h"
|
|
#include "tinycbor/src/cbor.h"
|
|
#include "JFJochMessages.h"
|
|
#include <mutex>
|
|
|
|
class CBORStream2Deserializer {
|
|
public:
|
|
enum class Type {START, END, IMAGE, CALIBRATION, NONE};
|
|
private:
|
|
mutable std::mutex m;
|
|
|
|
Type msg_type = Type::NONE;
|
|
|
|
DataMessage data_message;
|
|
|
|
StartMessage start_message;
|
|
EndMessage end_message;
|
|
CompressedImage calibration;
|
|
|
|
void DecodeType(CborValue &value);
|
|
|
|
void GetCBORSpots(CborValue &value);
|
|
void ProcessGoniometerMap(CborValue &value);
|
|
void ProcessGoniometerOmega(CborValue &value);
|
|
void ProcessAxis(CborValue &value, float v[3]);
|
|
|
|
void ProcessChannels(CborValue &value);
|
|
void ProcessImageData(CborValue &value, CompressedImage& image);
|
|
void ProcessPixelMaskElement(CborValue &value);
|
|
void ProcessRadIntResultElement(CborValue &value);
|
|
void ProcessADUHistogramElement(CborValue &value);
|
|
void ProcessROIElement(CborValue &value);
|
|
void ProcessROIElementMap(CborValue &value);
|
|
void ProcessUnitCellElement(CborValue &value);
|
|
void ProcessStartUserData(CborValue &value);
|
|
|
|
bool ProcessCalibration(CborValue &value);
|
|
bool ProcessImageMessageElement(CborValue &value);
|
|
bool ProcessStartMessageElement(CborValue &value);
|
|
bool ProcessEndMessageElement(CborValue &value);
|
|
public:
|
|
void Process(const std::vector<uint8_t>& buffer);
|
|
void Process(const uint8_t *msg, size_t msg_size);
|
|
[[nodiscard]] Type GetType() const;
|
|
[[nodiscard]] EndMessage GetEndMessage() const;
|
|
[[nodiscard]] StartMessage GetStartMessage() const;
|
|
|
|
// WARNING!!! pointer to data is valid only as long as input buffer is valid
|
|
[[nodiscard]] DataMessage GetDataMessage() const;
|
|
[[nodiscard]] CompressedImage GetCalibrationImage() const;
|
|
};
|
|
|
|
|
|
#endif //JUNGFRAUJOCH_CBORSTREAM2DESERIALIZER_H
|