HLCC Documentation 2.2.0
Loading...
Searching...
No Matches
telifCmdsImpl.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_TELIF_TELIFCMDSIMPL_HPP
14#define HLCC_TELIF_TELIF_TELIFCMDSIMPL_HPP
15
16#include <rad/exceptions.hpp>
17#include <rad/smAdapter.hpp>
18
19#include "telif/telifCmds.rad.hpp"
20#include "telif/logger.hpp"
21
22namespace hlcc::telif {
23
24
25class TelifCmdsImpl : public telifif::AsyncTelifCmds {
26public:
27 explicit TelifCmdsImpl(rad::SMAdapter& sm) : m_sm(sm) {
28 RAD_TRACE(GetLogger());
29 }
30
31 virtual ~TelifCmdsImpl() {
32 RAD_TRACE(GetLogger());
33 }
34
35 virtual elt::mal::future<std::string> MoveToNamedPos(const std::string& position_name) override {
36
37 RAD_TRACE(GetLogger());
38 LOG4CPLUS_INFO(GetLogger(), "Received MoveToNamedPos with: position_name " << position_name);
39 auto ev = std::make_shared<TelifCmds::MoveToNamedPos>(position_name);
40 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::MoveToNamedPos>();
41 m_sm.PostEvent(ev);
42 RAD_TRACE(GetLogger());
43
44 return ev->GetPayload().GetReplyFuture();
45
46 }
47
48 virtual elt::mal::future<std::string> MoveToAltAzPos(const std::shared_ptr<ccsinsif::AltAz>& axes_position) override {
49
50 RAD_TRACE(GetLogger());
51 LOG4CPLUS_INFO(GetLogger(), "Received MoveToAltAzPos with: Alt " << axes_position->getAlt()
52 << ", Az " << axes_position->getAz());
53 auto ev = std::make_shared<TelifCmds::MoveToAltAzPos>(axes_position->clone());
54 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::MoveToAltAzPos>();
55 m_sm.PostEvent(ev);
56
57 return ev->GetPayload().GetReplyFuture();
58 }
59
60 virtual elt::mal::future<std::string> StopTracking() override {
61
62 RAD_TRACE(GetLogger());
63 LOG4CPLUS_INFO(GetLogger(), "Received StopTracking");
64 auto ev = std::make_shared<TelifCmds::StopTracking>();
65 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::StopTracking>();
66 m_sm.PostEvent(ev);
67
68 return ev->GetPayload().GetReplyFuture();
69 }
70
71 virtual ::elt::mal::future<std::string> SetPresetSequenceMode(telifif::SequenceMode sequence_mode) override {
72 RAD_TRACE(GetLogger());
73 LOG4CPLUS_INFO(GetLogger(), "Received SetPresetSequenceMode with: sequence_mode " << sequence_mode);
74 auto ev = std::make_shared<TelifCmds::SetPresetSequenceMode>(sequence_mode);
75 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::SetPresetSequenceMode>();
76 m_sm.PostEvent(ev);
77 return ev->GetPayload().GetReplyFuture();
78 }
79
80 virtual ::elt::mal::future<std::string> SetPresetSequence(const std::string& sequence) override {
81 RAD_TRACE(GetLogger());
82 LOG4CPLUS_INFO(GetLogger(), "Received SetPresetSequence with: sequence " << sequence);
83 auto ev = std::make_shared<TelifCmds::SetPresetSequence>(sequence);
84 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::SetPresetSequence>();
85 m_sm.PostEvent(ev);
86 return ev->GetPayload().GetReplyFuture();
87 }
88
89 virtual ::elt::mal::future<std::string> SetOffsetSequenceMode(telifif::SequenceMode sequence_mode) override {
90 RAD_TRACE(GetLogger());
91 LOG4CPLUS_INFO(GetLogger(), "Received SetOffsetSequenceMode with: sequence_mode " << sequence_mode);
92 auto ev = std::make_shared<TelifCmds::SetOffsetSequenceMode>(sequence_mode);
93 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::SetOffsetSequenceMode>();
94 m_sm.PostEvent(ev);
95 return ev->GetPayload().GetReplyFuture();
96 }
97
98 virtual ::elt::mal::future<std::string> SetOffsetSequence(const std::string& sequence) override {
99 RAD_TRACE(GetLogger());
100 LOG4CPLUS_INFO(GetLogger(), "Received SetOffsetSequence with: sequence " << sequence);
101 auto ev = std::make_shared<TelifCmds::SetOffsetSequence>(sequence);
102 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::SetOffsetSequence>();
103 m_sm.PostEvent(ev);
104 return ev->GetPayload().GetReplyFuture();
105 }
106
107 virtual ::elt::mal::future<std::string> SetGuideProbe(const std::shared_ptr<pfsif::GuideStarArgs>& guide_star_args) override {
108 RAD_TRACE(GetLogger());
109 LOG4CPLUS_INFO(GetLogger(), "Received SetGuideProbe with: id " << guide_star_args->getId() << ", Ra "
110 << guide_star_args->getRa() << ", Dec " << guide_star_args->getDec() << ", Epoch "
111 << guide_star_args->getEpoch() << ", Band " << guide_star_args->getBand() << ", Rshift "
112 << guide_star_args->getRshift() << ", Radvel " << guide_star_args->getRadvel()
113 << ", Magnitude " << guide_star_args->getMagnitude() << ", Parallax "
114 << guide_star_args->getParallax() << ", Proper_motion_ra " << guide_star_args->getProper_motion_ra()
115 << ", Proper_motion_dec " << guide_star_args->getProper_motion_dec());
116 auto ev = std::make_shared<TelifCmds::SetGuideProbe>(guide_star_args->clone());
117
118 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::SetGuideProbe>();
119
120 m_sm.PostEvent(ev);
121
122 return ev->GetPayload().GetReplyFuture();
123 }
124
125 virtual ::elt::mal::future<std::string> SetGpHierarchy(const std::shared_ptr<pfsif::GpHierarchyArgs>& gp_hierarchy_args) override {
126 RAD_TRACE(GetLogger());
127 LOG4CPLUS_INFO(GetLogger(), "Received SetGpHierarchy with: A " << gp_hierarchy_args->getA() << ", B "
128 << gp_hierarchy_args->getB() << ", C " << gp_hierarchy_args->getC());
129 auto ev = std::make_shared<TelifCmds::SetGpHierarchy>(gp_hierarchy_args->clone());
130
131 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::SetGpHierarchy>();
132
133 m_sm.PostEvent(ev);
134
135 return ev->GetPayload().GetReplyFuture();
136 }
137
138 virtual ::elt::mal::future<std::string> StopGuideProbe(const pfsif::GuideProbeId guide_probe_id) override {
139 RAD_TRACE(GetLogger());
140 LOG4CPLUS_INFO(GetLogger(), "Received StopGuideProbe with: id " << guide_probe_id );
141 auto ev = std::make_shared<TelifCmds::StopGuideProbe>(guide_probe_id);
142
143 m_sm.RegisterDefaultRequestRejectHandler<TelifCmds::StopGuideProbe>();
144
145 m_sm.PostEvent(ev);
146
147 return ev->GetPayload().GetReplyFuture();
148 }
149
150private:
151 rad::SMAdapter& m_sm;
152
153 static std::string ContinuationCheckRejection(elt::mal::future<std::string> future, std::string method_name) {
154 std::string reply = future.get(); // the future is (normally) already fulfilled when called from a then-continuation.
155 if (reply.find("Request rejected in state") != std::string::npos) { // TODO C++20 use std::string::starts_with.
156 LOG4CPLUS_INFO(GetLogger(), method_name << " command rejected by eltpk: " << reply);
157 }
158 return reply;
159 };
160};
161
162} // namespace hlcc::telif
163
164#endif // HLCC_TELIF_TELIF_TELIFCMDSIMPL_HPP
Default logger name.
Definition telifCmdsImpl.hpp:25
virtual ::elt::mal::future< std::string > SetOffsetSequenceMode(telifif::SequenceMode sequence_mode) override
Definition telifCmdsImpl.hpp:89
virtual ::elt::mal::future< std::string > StopGuideProbe(const pfsif::GuideProbeId guide_probe_id) override
Definition telifCmdsImpl.hpp:138
virtual ::elt::mal::future< std::string > SetPresetSequence(const std::string &sequence) override
Definition telifCmdsImpl.hpp:80
virtual elt::mal::future< std::string > MoveToAltAzPos(const std::shared_ptr< ccsinsif::AltAz > &axes_position) override
Definition telifCmdsImpl.hpp:48
virtual ::elt::mal::future< std::string > SetGpHierarchy(const std::shared_ptr< pfsif::GpHierarchyArgs > &gp_hierarchy_args) override
Definition telifCmdsImpl.hpp:125
virtual elt::mal::future< std::string > StopTracking() override
Definition telifCmdsImpl.hpp:60
virtual ::elt::mal::future< std::string > SetPresetSequenceMode(telifif::SequenceMode sequence_mode) override
Definition telifCmdsImpl.hpp:71
virtual ::elt::mal::future< std::string > SetGuideProbe(const std::shared_ptr< pfsif::GuideStarArgs > &guide_star_args) override
Definition telifCmdsImpl.hpp:107
virtual ~TelifCmdsImpl()
Definition telifCmdsImpl.hpp:31
virtual ::elt::mal::future< std::string > SetOffsetSequence(const std::string &sequence) override
Definition telifCmdsImpl.hpp:98
virtual elt::mal::future< std::string > MoveToNamedPos(const std::string &position_name) override
Definition telifCmdsImpl.hpp:35
TelifCmdsImpl(rad::SMAdapter &sm)
Definition telifCmdsImpl.hpp:27
Definition configTest.cpp:22
log4cplus::Logger & GetLogger()
Definition logger.cpp:21