HLCC Documentation 3.0.1
Loading...
Searching...
No Matches
oldbInterface.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020-2025 European Southern Observatory (ESO)
2//
3// SPDX-License-Identifier: LGPL-3.0-only
4
13#ifndef HLCC_TELIF_ELTPK_OLDBINTERFACE_HPP
14#define HLCC_TELIF_ELTPK_OLDBINTERFACE_HPP
15
16#include <vector>
17#include <optional>
18#include <memory> // shared_ptr
19
22#include <boost/asio/thread_pool.hpp>
23#include <taiclock/taiClock.hpp>
24#include <ptk/posastro.hpp>
25#include <rad/oldbInterface.hpp>
26#include <rad/cii/oldbAdapter.hpp>
27#include "Ccsinsif.hpp"
28#include "Ccsinsdetif.hpp"
29#include <Eltpkif.hpp>
30#include <Msif.hpp>
31#include "eltpk/determPub.hpp"
32#include "eltpk/monitoring.hpp"
34
35
36namespace hlcc::eltpk {
37
38/*
39 * Monitor OLDB Attributes.
40 */
41const std::string KEY_MON_STATE = "mon/state";
42const std::string KEY_MON_TRS_HKS_DATA_OK = "mon/trs/hks_data_ok";
43const std::string KEY_MON_TRS_HKS_DATA_DUT1 = "mon/trs/hks_dut1";
44const std::string KEY_MON_TRS_HKS_DATA_XP = "mon/trs/hks_xp";
45const std::string KEY_MON_TRS_HKS_DATA_YP = "mon/trs/hks_yp";
46//const std::string KEY_MON_RA = "mon/ra";
47//const std::string KEY_MON_DEC = "mon/dec";
48
49/*
50 * Telmon Oldb Attibutes - These attributes are provided by Eltpk but stored in the telmon
51 * branch in Oldb.
52 */
53// Backward calculated CIRS position (Ra, Dec) from the current (alt, az) of the mount.
54const std::string KEY_TELMON_MON_RADEC_BACKCALC_FROM_ALTAZ = "/elt/cs/hlcc/telmon/mon/radec_backcalc_from_altaz";
55
56// Observed hour angle HOB, from the current (alt, az) of the mount.
57const std::string KEY_TELMON_MON_OBSERVED_HOUR_ANGLE = "/elt/cs/hlcc/telmon/mon/observed_hour_angle";
58
59class Config;
60struct OldbData{
61 std::shared_ptr<::ccscommonif::AltAz> target_alt_az;
62 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::AltAz>> target_alt_az_publisher;
63
64 std::shared_ptr<::ccscommonif::AltAz> current_alt_az;
65 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::AltAz>> current_alt_az_publisher;
66
67 std::shared_ptr<::ccscommonif::RaDec> current_ra_dec_backcalc;
68 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::RaDec>> current_ra_dec_backcalc_publisher;
69 std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync<std::vector<double>>> current_ra_dec_backcalc_dp_async; // exposed here to set quality also separately from publishing
70
71 std::shared_ptr<::ccscommonif::RaDec> current_hour_angle; // we abuse RA for HA
72 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::RaDec>> current_hour_angle_publisher;
73
74 std::shared_ptr<::ccsinsif::CurrentTime> current_time;
75 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::CurrentTime>> current_time_publisher;
76
77 std::shared_ptr<::ccsinsif::TrackingData> tracking_data;
78 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::TrackingData>> tracking_data_publisher;
79 std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync<std::vector<double>>> radec_gs_dp_async; // exposed here to set quality also separately from publishing
80
81 std::shared_ptr<::ccsinsif::TrackingDataExtended> tracking_data_extended;
82 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::TrackingDataExtended>> tracking_data_extended_publisher;
83
84 std::shared_ptr<::ccsinsif::SiteInfo> site_info;
85 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::SiteInfo>> site_info_publisher;
86
87 std::shared_ptr<::stdif::Status> status_data;
88 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::stdif::Status>> status_data_publisher;
89 std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::PresetArgs>> preset_args_publisher;
90 std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync<std::vector<double>>> target_ra_dec_dp_async; // exposed here to set quality also separately from publishing
91
92 std::unique_ptr<::elt::mal::ps::Subscriber<::msif::TrackTarget>> track_target_subscriber;
93 std::shared_ptr<::msif::TrackTarget> track_target;
94 std::unique_ptr<::elt::mal::ps::MrvSubscriber<::msif::TrackSv>> track_sv_subscriber;
95 std::shared_ptr<::msif::TrackSv> track_sv;
96
97 std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync<double>> heartbeat_subscriber;
98
99 std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync<double>> time_lst_subscriber;
100 };
101
104struct AsmData {
105 bool data_quality; /* false means the quality of the data in this struct is not reliable */
112};
113
117class OldbInterface : public rad::OldbInterface {
118 public:
125 OldbInterface(const std::string& prefix = "");
126
130 virtual ~OldbInterface();
131
136 void Init(::hlcc::eltpk::Config& config);
137
141 void PublishTargets(ElapsedTimeStats& stats);
142
147 void PublishCurrentPositions(ElapsedTimeStats& stats, const bool& radec_validity);
148
152 void SetTargetRaDecValidity(const bool& ra_dec_validity);
153
157 double GetTimeLst();
158
162 void SetTimeLst(double lst);
163
168
173
177 void PublishPresetArgs(const std::shared_ptr<::ccsinsif::PresetArgs>& preset_args);
178
183 ptk::HorizonPositionEsoTimestamped GetCurrentObservedAltAz();
184
185
186 /* TODO: make the following fields private with getters. */
187
193
200 void SetControlState(const std::string& value,
201 const taiclock::TaiClock::time_point& timestamp,
202 ElapsedTimeStats& stats);
203
210 void SetTrsHksDataState(bool hks_data_ok);
211
217 void WriteTrsHksData(ptk::Dut1 dut1, ptk::Arcsecs xp, ptk::Arcsecs yp);
218
225 std::optional<ptk::Dut1> ReadTrsHksDut1();
226
233 std::optional<ptk::Arcsecs> ReadTrsHksPolar(std::string oldb_key);
234
235
236 void SetConfig(const rad::Config& cfg); // solves hidden virtual function
237
238 void SetControlState(const std::string& value); // solves hidden virtual function
240 OldbInterface(const OldbInterface&) = delete;
242 std::shared_ptr<determ::LlnetioPub> GetLlnetioPub();
243 std::shared_ptr<determ::MudpiPub> GetMudpiPub();
244 void UpdateHeartbeat();
245
246 private:
250 std::tuple<std::optional<double>, std::optional<std::chrono::system_clock::time_point>>
251 ReadTrsHksParamInternal(std::string oldb_key);
252
262 boost::asio::thread_pool m_async_exec {5};
263
271 log4cplus::Logger m_logger_oldb_async;
272
276 OldbData m_oldb_data {};
277
281 std::shared_ptr<determ::LlnetioPub> m_llnetio_pub;
282
283 double m_time_lst;
284
288 std::shared_ptr<determ::MudpiPub> m_mudpi_pub {};
289};
290
291} // namespace hlcc::eltpk
292
293#endif // HLCC_TELIF_ELTPK_OLDBINTERFACE_HPP
Performance and other monitoring.
Definition config.hpp:248
Definition monitoring.hpp:31
void PublishPresetArgs(const std::shared_ptr<::ccsinsif::PresetArgs > &preset_args)
Definition oldbInterface.cpp:692
void SetControlState(const std::string &value, const taiclock::TaiClock::time_point &timestamp, ElapsedTimeStats &stats)
Definition oldbInterface.cpp:764
OldbData & GetOldbData()
Definition oldbInterface.cpp:921
void PublishCurrentPositions(ElapsedTimeStats &stats, const bool &radec_validity)
Definition oldbInterface.cpp:593
void SetTimeLst(double lst)
Definition oldbInterface.cpp:869
void PublishCurrentTime(ElapsedTimeStats &stats)
Definition oldbInterface.cpp:673
void PublishSiteInfo(ElapsedTimeStats &stats)
Definition oldbInterface.cpp:684
std::optional< ptk::Dut1 > ReadTrsHksDut1()
Definition oldbInterface.cpp:829
ptk::HorizonPositionEsoTimestamped GetCurrentObservedAltAz()
Definition oldbInterface.cpp:885
OldbInterface & operator=(const OldbInterface &)=delete
Disable copy constructor.
std::shared_ptr< determ::LlnetioPub > GetLlnetioPub()
Disable assignment operator.
Definition oldbInterface.cpp:925
void PublishTargets(ElapsedTimeStats &stats)
Definition oldbInterface.cpp:583
std::shared_ptr< determ::MudpiPub > GetMudpiPub()
Definition oldbInterface.cpp:929
OldbInterface(const OldbInterface &)=delete
void WriteTrsHksData(ptk::Dut1 dut1, ptk::Arcsecs xp, ptk::Arcsecs yp)
Definition oldbInterface.cpp:784
void SetTargetRaDecValidity(const bool &ra_dec_validity)
Definition oldbInterface.cpp:647
std::optional< ptk::Arcsecs > ReadTrsHksPolar(std::string oldb_key)
Definition oldbInterface.cpp:850
virtual ~OldbInterface()
Definition oldbInterface.cpp:57
void Init(::hlcc::eltpk::Config &config)
Definition oldbInterface.cpp:81
void UpdateHeartbeat()
Definition oldbInterface.cpp:874
double GetTimeLst()
Definition oldbInterface.cpp:864
void SetTrsHksDataState(bool hks_data_ok)
Definition oldbInterface.cpp:776
OldbInterface(const std::string &prefix="")
Definition oldbInterface.cpp:47
void SetConfig(hlcc::eltpk::Config &cfg)
Definition oldbInterface.cpp:699
Determ Pub class header file.
Definition actionMgr.cpp:31
const std::string KEY_MON_TRS_HKS_DATA_DUT1
Definition oldbInterface.hpp:43
const std::string KEY_TELMON_MON_RADEC_BACKCALC_FROM_ALTAZ
Definition oldbInterface.hpp:54
const std::string KEY_TELMON_MON_OBSERVED_HOUR_ANGLE
Definition oldbInterface.hpp:57
const std::string KEY_MON_TRS_HKS_DATA_YP
Definition oldbInterface.hpp:45
const std::string KEY_MON_STATE
Definition oldbInterface.hpp:41
const std::string KEY_MON_TRS_HKS_DATA_OK
Definition oldbInterface.hpp:42
const std::string KEY_MON_TRS_HKS_DATA_XP
Definition oldbInterface.hpp:44
Definition oldbInterface.hpp:104
double air_temperature
Definition oldbInterface.hpp:106
double relative_humidity_average
Definition oldbInterface.hpp:109
double ambient_pressure
Definition oldbInterface.hpp:110
double ambient_pressure_average
Definition oldbInterface.hpp:111
double relative_humidity
Definition oldbInterface.hpp:108
double air_temperature_average
Definition oldbInterface.hpp:107
bool data_quality
Definition oldbInterface.hpp:105
Definition oldbInterface.hpp:60
std::unique_ptr<::elt::mal::ps::Subscriber<::msif::TrackTarget > > track_target_subscriber
Definition oldbInterface.hpp:92
std::shared_ptr<::ccscommonif::RaDec > current_ra_dec_backcalc
Definition oldbInterface.hpp:67
std::shared_ptr<::stdif::Status > status_data
Definition oldbInterface.hpp:87
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::CurrentTime > > current_time_publisher
Definition oldbInterface.hpp:75
std::shared_ptr<::msif::TrackSv > track_sv
Definition oldbInterface.hpp:95
std::shared_ptr<::msif::TrackTarget > track_target
Definition oldbInterface.hpp:93
std::shared_ptr<::ccsinsif::CurrentTime > current_time
Definition oldbInterface.hpp:74
std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync< std::vector< double > > > target_ra_dec_dp_async
Definition oldbInterface.hpp:90
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::PresetArgs > > preset_args_publisher
Definition oldbInterface.hpp:89
std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync< double > > heartbeat_subscriber
Definition oldbInterface.hpp:97
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::AltAz > > current_alt_az_publisher
Definition oldbInterface.hpp:65
std::shared_ptr<::ccsinsif::TrackingData > tracking_data
Definition oldbInterface.hpp:77
std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync< double > > time_lst_subscriber
Definition oldbInterface.hpp:99
std::shared_ptr<::ccscommonif::RaDec > current_hour_angle
Definition oldbInterface.hpp:71
std::shared_ptr<::ccscommonif::AltAz > target_alt_az
Definition oldbInterface.hpp:61
std::shared_ptr<::ccsinsif::TrackingDataExtended > tracking_data_extended
Definition oldbInterface.hpp:81
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::TrackingData > > tracking_data_publisher
Definition oldbInterface.hpp:78
std::shared_ptr<::ccsinsif::SiteInfo > site_info
Definition oldbInterface.hpp:84
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::AltAz > > target_alt_az_publisher
Definition oldbInterface.hpp:62
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::stdif::Status > > status_data_publisher
Definition oldbInterface.hpp:88
std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync< std::vector< double > > > radec_gs_dp_async
Definition oldbInterface.hpp:79
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::RaDec > > current_hour_angle_publisher
Definition oldbInterface.hpp:72
std::shared_ptr<::ccscommonif::AltAz > current_alt_az
Definition oldbInterface.hpp:64
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::SiteInfo > > site_info_publisher
Definition oldbInterface.hpp:85
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccsinsif::TrackingDataExtended > > tracking_data_extended_publisher
Definition oldbInterface.hpp:82
std::shared_ptr<::hlcc::oldbmux::ObservablePublisher<::ccscommonif::RaDec > > current_ra_dec_backcalc_publisher
Definition oldbInterface.hpp:68
std::unique_ptr<::elt::mal::ps::MrvSubscriber<::msif::TrackSv > > track_sv_subscriber
Definition oldbInterface.hpp:94
std::shared_ptr<::hlcc::oldbmux::CiiOldbDataPointAsync< std::vector< double > > > current_ra_dec_backcalc_dp_async
Definition oldbInterface.hpp:69