HLCC Documentation 3.0.0
Loading...
Searching...
No Matches
simCmdsImpl.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_SIMCMDSIMPL_HPP
14#define HLCC_TELIF_TELIF_SIMCMDSIMPL_HPP
15
16#include <rad/exceptions.hpp>
17#include <rad/smAdapter.hpp>
18
19#include "telif/simCmds.rad.hpp"
20#include "telif/logger.hpp"
21
22namespace hlcc::telif {
23
24
25class SimCmdsImpl : public telifif::AsyncSimCmds {
26public:
27 explicit SimCmdsImpl(rad::SMAdapter& sm) : m_sm(sm) {
28 RAD_TRACE(GetLogger());
29 }
30
31 virtual ~SimCmdsImpl() {
32 RAD_TRACE(GetLogger());
33 }
34
35 virtual elt::mal::future<std::string> UpdateRousTimer(std::uint16_t new_time) override {
36
37 RAD_TRACE(GetLogger());
38 LOG4CPLUS_INFO(GetLogger(), "Received UpdateRousTimer with: new_time " << new_time);
39
40 auto ev = std::make_shared<SimCmds::UpdateRousTimer>(new_time);
41 m_sm.RegisterDefaultRequestRejectHandler<SimCmds::UpdateRousTimer>();
42 m_sm.PostEvent(ev);
43
44 return ev->GetPayload().GetReplyFuture();
45 }
46
47private:
48 rad::SMAdapter& m_sm;
49
50 static std::string ContinuationCheckRejection(elt::mal::future<std::string> future, std::string method_name) {
51 std::string reply = future.get(); // the future is (normally) already fulfilled when called from a then-continuation.
52 if (reply.find("Request rejected in state") != std::string::npos) { // TODO C++20 use std::string::starts_with.
53 LOG4CPLUS_INFO(GetLogger(), method_name << " command rejected by eltpk: " << reply);
54 }
55 return reply;
56 };
57
58};
59
60} // namespace hlcc::telif
61
62#endif // HLCC_TELIF_TELIF_SIMCMDSIMPL_HPP
Default logger name.
virtual elt::mal::future< std::string > UpdateRousTimer(std::uint16_t new_time) override
Definition simCmdsImpl.hpp:35
SimCmdsImpl(rad::SMAdapter &sm)
Definition simCmdsImpl.hpp:27
virtual ~SimCmdsImpl()
Definition simCmdsImpl.hpp:31
Definition configTest.cpp:22
log4cplus::Logger & GetLogger()
Definition logger.cpp:21