RTC Toolkit  2.0.0
fitsDataRecorder.hpp
Go to the documentation of this file.
1 
11 #ifndef RTCTK_COMPONENTFRAMEWORK_FITSDATARECORDER_HPP
12 #define RTCTK_COMPONENTFRAMEWORK_FITSDATARECORDER_HPP
13 
14 #include <functional>
15 #include <string_view>
16 #include <memory>
17 #include <filesystem>
18 #include <CCfits/FITS.h>
19 #include <CCfits/Table.h>
20 #include <gsl/span>
24 
25 namespace rtctk::componentFramework {
26 
27 struct FitsColumn {
28  std::string_view name;
29  std::string_view unit;
30 
31  constexpr FitsColumn(std::string_view new_name, std::string_view new_unit) : name(new_name), unit(new_unit) {}
32 };
33 
34 /* *
35  * The FITSRecorder
36  */
37 template <class... T>
38 class FitsRecorder : public DataRecorder<T...> {
39 public:
40 
41  class FitsError : public RtctkException {
42  public:
44  explicit FitsError(const CCfits::FitsException& exception) :
45  RtctkException("FITS error: " + exception.message()) {}
46  };
47 
48 
49  using ColumnDescription = std::array<FitsColumn, sizeof...(T)>;
56  explicit FitsRecorder(const ColumnDescription& columns, const std::array<bool, sizeof...(T)>& disable = {}, const std::string& extension_name = "recording");
57  ~FitsRecorder() = default;
58  void Open(const std::filesystem::path& file) override;
59  void Write(const std::tuple<T...>& data) override;
60  void Close() override;
61 
62 
63 private:
67  std::unique_ptr<CCfits::FITS> m_fits_handle;
71  CCfits::Table* m_fits_table_handle;
75  ColumnDescription m_columns;
79  std::string m_extension_name;
83  long int m_row_index;
84 };
85 
86 } // namespace rtctk::componentFramework
87 
88 #include "fitsDataRecorder.ipp"
89 
90 #endif // RTCTK_COMPONENTFRAMEWORK_FITSDATARECORDER_HPP
rtctk::componentFramework::FitsRecorder::FitsError::FitsError
FitsError(const CCfits::FitsException &exception)
Definition: fitsDataRecorder.hpp:44
exceptions.hpp
Provides macros and utilities for exception handling.
rtctk::componentFramework::FitsRecorder::FitsError
Definition: fitsDataRecorder.hpp:41
rtctk::componentFramework::FitsColumn::unit
std::string_view unit
Definition: fitsDataRecorder.hpp:29
rtctk::componentFramework::RtctkException::RtctkException
RtctkException() noexcept
Definition: exceptions.cpp:99
rtctk::componentFramework
Definition: commandReplier.cpp:20
dataRecorder.hpp
FitsRecorder allows to write ColumnData to into fits files in a specified directory.
rtctk::componentFramework::RtctkException
The RtctkException class is the base class for all Rtctk exceptions.
Definition: exceptions.hpp:207
rtctk::componentFramework::DataRecorder
Definition: dataRecorder.hpp:21
rtctk::componentFramework::FitsRecorder
Definition: fitsDataRecorder.hpp:38
rtctk::componentFramework::FitsRecorder::Close
void Close() override
Close the currently open file.
rtctk::componentFramework::FitsColumn::FitsColumn
constexpr FitsColumn(std::string_view new_name, std::string_view new_unit)
Definition: fitsDataRecorder.hpp:31
rtctk::componentFramework::FitsRecorder::FitsRecorder
FitsRecorder(const ColumnDescription &columns, const std::array< bool, sizeof...(T)> &disable={}, const std::string &extension_name="recording")
create a new recorder
rtctk_config_tool.message
message
Definition: rtctk_config_tool.py:42
rtctk::componentFramework::FitsRecorder::~FitsRecorder
~FitsRecorder()=default
rtctk::componentFramework::FitsRecorder::Open
void Open(const std::filesystem::path &file) override
Open a file.
rtctk::componentFramework::FitsColumn::name
std::string_view name
Definition: fitsDataRecorder.hpp:28
rtctk::componentFramework::FitsRecorder< ecs::TaiClock::time_point::rep, std::string >::ColumnDescription
std::array< FitsColumn, sizeof...(T)> ColumnDescription
Definition: fitsDataRecorder.hpp:49
rtctk::componentFramework::FitsRecorder::Write
void Write(const std::tuple< T... > &data) override
Write a row of data.
rtctk::componentFramework::FitsColumn
Definition: fitsDataRecorder.hpp:27
fitsColumnFormat.hpp
fitscolumnFormat is used to get a fits type from a C++ type. Supports arrays and vectors