From 0b7d58968b37dc9d36a90d3fb439891a57b81a18 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 17 Jan 2024 09:48:56 +0100 Subject: Update ClockTAI and RemoteControl --- lib/RemoteControl.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/RemoteControl.h') diff --git a/lib/RemoteControl.h b/lib/RemoteControl.h index 2358b3a..26f30d9 100644 --- a/lib/RemoteControl.h +++ b/lib/RemoteControl.h @@ -3,7 +3,7 @@ Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2019 + Copyright (C) 2023 Matthias P. Braendli, matthias.braendli@mpb.li http://www.opendigitalradio.org @@ -36,6 +36,8 @@ #endif #include +#include +#include #include #include #include @@ -46,6 +48,7 @@ #include "Log.h" #include "Socket.h" +#include "Json.h" #define RC_ADD_PARAMETER(p, desc) { \ std::vector p; \ @@ -113,13 +116,13 @@ class RemoteControllable { } /* Base function to set parameters. */ - virtual void set_parameter( - const std::string& parameter, - const std::string& value) = 0; + virtual void set_parameter(const std::string& parameter, const std::string& value) = 0; /* Getting a parameter always returns a string. */ virtual const std::string get_parameter(const std::string& parameter) const = 0; + virtual const json::map_t get_all_values() const = 0; + protected: std::string m_rc_name; std::list< std::vector > m_parameters; @@ -135,6 +138,7 @@ class RemoteControllers { void check_faults(); std::list< std::vector > get_param_list_values(const std::string& name); std::string get_param(const std::string& name, const std::string& param); + std::string get_showjson(); void set_param( const std::string& name, -- cgit v1.2.3 From aaa415b62f6d1b815aa9a8954d2cf1ddb6a8317d Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 5 May 2024 21:20:26 +0200 Subject: Update common: make remotecontrol optional --- lib/ClockTAI.cpp | 6 ++++++ lib/ClockTAI.h | 11 ++++++++--- lib/Globals.cpp | 2 ++ lib/RemoteControl.h | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) (limited to 'lib/RemoteControl.h') diff --git a/lib/ClockTAI.cpp b/lib/ClockTAI.cpp index d8e37ea..06e88f8 100644 --- a/lib/ClockTAI.cpp +++ b/lib/ClockTAI.cpp @@ -379,6 +379,7 @@ void Bulletin::clear_expiry_if_overridden() } } +#if ENABLE_REMOTECONTROL ClockTAI::ClockTAI(const std::vector& bulletin_urls) : RemoteControllable("clocktai") { @@ -386,6 +387,9 @@ ClockTAI::ClockTAI(const std::vector& bulletin_urls) : RC_ADD_PARAMETER(expiry, "Number of seconds until TAI Bulletin expires"); RC_ADD_PARAMETER(expires_at, "UNIX timestamp when TAI Bulletin expires"); RC_ADD_PARAMETER(url, "URLs used to fetch the bulletin, separated by pipes"); +#else +ClockTAI::ClockTAI(const std::vector& bulletin_urls) { +#endif // ENABLE_REMOTECONTROL if (bulletin_urls.empty()) { etiLog.level(debug) << "Initialising default TAI Bulletin URLs"; @@ -629,6 +633,7 @@ void Bulletin::store_to_cache(const char* cache_filename) const } } +#if ENABLE_REMOTECONTROL void ClockTAI::set_parameter(const string& parameter, const string& value) { if (parameter == "expiry" or parameter == "expires_at") { @@ -719,6 +724,7 @@ const json::map_t ClockTAI::get_all_values() const return stat; } +#endif // ENABLE_REMOTECONTROL #if 0 // Example testing code diff --git a/lib/ClockTAI.h b/lib/ClockTAI.h index 8cd00e5..d11dd10 100644 --- a/lib/ClockTAI.h +++ b/lib/ClockTAI.h @@ -35,8 +35,6 @@ #pragma once #include -#include -#include #include #include #include @@ -44,6 +42,7 @@ #include #include #include + #include "RemoteControl.h" // EDI needs to know UTC-TAI, but doesn't need the CLOCK_TAI to be set. @@ -86,7 +85,11 @@ class Bulletin { }; /* Loads, parses and represents TAI-UTC offset information from the IETF bulletin */ -class ClockTAI : public RemoteControllable { +class ClockTAI +#if ENABLE_REMOTECONTROL +: public RemoteControllable +#endif // ENABLE_REMOTECONTROL +{ public: ClockTAI(const std::vector& bulletin_urls); @@ -125,6 +128,7 @@ class ClockTAI : public RemoteControllable { std::optional m_state; std::chrono::steady_clock::time_point m_state_last_updated; +#if ENABLE_REMOTECONTROL public: /* Remote control */ virtual void set_parameter(const std::string& parameter, @@ -134,5 +138,6 @@ class ClockTAI : public RemoteControllable { virtual const std::string get_parameter(const std::string& parameter) const; virtual const json::map_t get_all_values() const; +#endif // ENABLE_REMOTECONTROL }; diff --git a/lib/Globals.cpp b/lib/Globals.cpp index 6be26ec..6bd38fb 100644 --- a/lib/Globals.cpp +++ b/lib/Globals.cpp @@ -32,5 +32,7 @@ // the RC needs logging, and needs to be initialised later. Logger etiLog; +#if ENABLE_REMOTECONTROL RemoteControllers rcs; +#endif // ENABLE_REMOTECONTROL diff --git a/lib/RemoteControl.h b/lib/RemoteControl.h index 26f30d9..7dd763d 100644 --- a/lib/RemoteControl.h +++ b/lib/RemoteControl.h @@ -31,6 +31,8 @@ # include "config.h" #endif +#define ENABLE_REMOTECONTROL 1 + #if defined(HAVE_ZEROMQ) # include "zmq.hpp" #endif -- cgit v1.2.3