From fc1f1640278e7eb228ec1a6290d30b95f1b6a476 Mon Sep 17 00:00:00 2001 From: KuntzeM Date: Sun, 15 Mar 2020 13:46:08 +0100 Subject: add linkage set activator flag to remote controllable --- src/ConfigParser.cpp | 3 ++- src/MuxElements.cpp | 49 +++++++++++++++++++++++++++++++++++++------------ src/MuxElements.h | 34 ++++++++++++++++++++++++++++++---- 3 files changed, 69 insertions(+), 17 deletions(-) diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 4240add..7a69202 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -193,6 +193,7 @@ static void parse_linkage(ptree& pt, linkageset->id_list.push_back(link); } } + rcs.enrol(linkageset.get()); ensemble->linkagesets.push_back(linkageset); } } @@ -580,7 +581,7 @@ void parse_ptree( etiLog.level(warn) << "Cannot parse '" << clusterlist << "' announcement clusters for service " << serviceuid << ": " << e.what(); - } + } } if (service->ASu != 0 and service->clusters.empty()) { diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index cb2d545..70930cb 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -805,22 +805,11 @@ size_t DabSubchannel::readFrame(uint8_t *buffer, size_t size, std::time_t second throw logic_error("Unhandled case"); } -LinkageSet::LinkageSet(const std::string& name, - uint16_t lsn, - bool active, - bool hard, - bool international) : - lsn(lsn), - active(active), - hard(hard), - international(international), - m_name(name) -{} LinkageSet LinkageSet::filter_type(const ServiceLinkType type) { - LinkageSet lsd(m_name, lsn, active, hard, international); + LinkageSet lsd(m_rc_name, lsn, active, hard, international); lsd.active = active; lsd.keyservice = keyservice; @@ -833,3 +822,39 @@ LinkageSet LinkageSet::filter_type(const ServiceLinkType type) return lsd; } + + +void LinkageSet::set_parameter(const string& parameter, + const string& value) +{ + if (parameter == "active") { + stringstream ss; + ss << value; + + lock_guard lock(m_active_mutex); + ss >> active; + } + else { + stringstream ss; + ss << "Parameter '" << parameter << + "' is not exported by controllable " << get_rc_name(); + throw ParameterError(ss.str()); + } +} + +const string LinkageSet::get_parameter(const string& parameter) const +{ + using namespace std::chrono; + + stringstream ss; + if (parameter == "active") { + lock_guard lock(m_active_mutex); + ss << active; + } + else { + ss << "Parameter '" << parameter << + "' is not exported by controllable " << get_rc_name(); + throw ParameterError(ss.str()); + } + return ss.str(); +} diff --git a/src/MuxElements.h b/src/MuxElements.h index 98de70e..55bddaf 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -542,15 +542,32 @@ struct ServiceLink { * TS 103 176 Clause 5.2.3 "Linkage sets". This information will * be encoded in FIG 0/6. */ -class LinkageSet { +class LinkageSet : public RemoteControllable { public: LinkageSet(const std::string& name, uint16_t lsn, bool active, bool hard, - bool international); + bool international) : + RemoteControllable(name), + lsn(lsn), + active(active), + hard(hard), + international(international) + { + RC_ADD_PARAMETER(active, "Signal this linkage set active [0 or 1]"); + } + + LinkageSet(const LinkageSet& other) : + LinkageSet(other.m_rc_name, + other.lsn, + other.active, + other.hard, + other.international) + { + } - std::string get_name(void) const { return m_name; } + std::string get_name(void) const { return m_rc_name; } std::list id_list; @@ -566,13 +583,22 @@ class LinkageSet { std::string keyservice; // TODO replace by pointer to service + //LinkageSet& operator=(const LinkageSet& other) = default; + /* Return a LinkageSet with id_list filtered to include * only those links of a given type */ LinkageSet filter_type(const ServiceLinkType type); + /* Remote control */ + virtual void set_parameter(const std::string& parameter, + const std::string& value); + + /* Getting a parameter always returns a string. */ + virtual const std::string get_parameter(const std::string& parameter) const; + private: - std::string m_name; + mutable std::mutex m_active_mutex; }; // FIG 0/21 -- cgit v1.2.3