RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
fitsDataRecorder.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_COMPONENTFRAMEWORK_FITSDATARECORDER_HPP
13#define RTCTK_COMPONENTFRAMEWORK_FITSDATARECORDER_HPP
14
17
18#include <filesystem>
19#include <fitsio2.h>
20#include <functional>
21#include <gsl/span>
22#include <map>
23#include <memory>
24#include <string_view>
25
27
29public:
31 explicit FitsDataRecorderFitsError(const std::string& error)
32 : RtctkException("FITS error: " + error) {
33 }
34};
35
36struct FitsColumn {
37 std::string_view name;
38 std::string_view unit;
39
40 constexpr FitsColumn(std::string_view new_name, std::string_view new_unit)
42 }
43};
44
70template <class... T>
71class FitsRecorder : public DataRecorder<T...> {
72public:
74
83 const std::array<bool, sizeof...(T)>& disable = {},
84 const std::string& extension_name = "recording");
85 virtual ~FitsRecorder() = default;
86 void Open(const std::filesystem::path& file) override;
87 void Write(const std::tuple<T...>& data) override;
88 void Close() override;
99 void SetColumnLength(size_t column, size_t length);
100 void SetColumnLength(const std::tuple<T...>& data);
101
102 std::string DefaultFileExtension() override {
103 return std::string{".fits"};
104 }
105
106private:
107 static void CloseFits(fitsfile* pointer);
111 std::unique_ptr<fitsfile, decltype(&CloseFits)> m_fits_handle;
115 std::string m_extension_name;
119 long int m_row_index;
123 std::array<std::optional<size_t>, sizeof...(T)> m_column_length;
124};
125
126} // namespace rtctk::componentFramework
127
129
130#endif // RTCTK_COMPONENTFRAMEWORK_FITSDATARECORDER_HPP
This is an abstract class that can be used to implement an OutputStage for a Recording Unit.
Definition dataRecorder.hpp:29
const std::array< ColumnMetaData, sizeof...(T)> ColumnDescription
Definition dataRecorder.hpp:49
FitsDataRecorderFitsError(const std::string &error)
Definition fitsDataRecorder.hpp:31
Definition fitsDataRecorder.hpp:71
FitsRecorder(const ColumnDescription &columns, const std::array< bool, sizeof...(T)> &disable={}, const std::string &extension_name="recording")
create a new recorder
Definition fitsDataRecorder.ipp:164
void Open(const std::filesystem::path &file) override
Open a file.
Definition fitsDataRecorder.ipp:175
std::string DefaultFileExtension() override
Default filename extension for the recorder.
Definition fitsDataRecorder.hpp:102
void SetColumnLength(size_t column, size_t length)
Set the exact length of a column.
Definition fitsDataRecorder.ipp:230
void Write(const std::tuple< T... > &data) override
Write a single row of data.
Definition fitsDataRecorder.ipp:274
void Close() override
Close the currently open file.
Definition fitsDataRecorder.ipp:358
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:211
RtctkException() noexcept
Definition exceptions.cpp:113
Provides an abstract DataRecorder class as the output stage for a recording unit.
Provides macros and utilities for exception handling.
FitsRecorder allows to write ColumnData to into fits files in a specified directory.
Definition commandReplier.cpp:22
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Definition fitsDataRecorder.hpp:36
constexpr FitsColumn(std::string_view new_name, std::string_view new_unit)
Definition fitsDataRecorder.hpp:40
std::string_view name
Definition fitsDataRecorder.hpp:37
std::string_view unit
Definition fitsDataRecorder.hpp:38