diff options
-rw-r--r-- | src/DabMux.cpp | 12 | ||||
-rw-r--r-- | src/MuxElements.cpp | 41 | ||||
-rw-r--r-- | src/MuxElements.h | 39 | ||||
-rw-r--r-- | src/ParserConfigfile.cpp | 4 |
4 files changed, 80 insertions, 16 deletions
diff --git a/src/DabMux.cpp b/src/DabMux.cpp index 275175b..734643c 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -354,6 +354,10 @@ int main(int argc, char *argv[]) global_stats = new StatsServer(); } + if (rc) { + ensemble->enrol_at(*rc); + } + etiLog.level(info) << PACKAGE_NAME << " " << @@ -1627,7 +1631,13 @@ int main(int argc, char *argv[]) fig0_9->ext = 0; fig0_9->lto = 0; // Unique LTO for ensemble - fig0_9->ensembleLto = ensemble->lto; + if (ensemble->lto >= 0) { + fig0_9->ensembleLto = ensemble->lto; + } + else { + /* Convert to 1-complement representation */ + fig0_9->ensembleLto = (-ensemble->lto) | (1<<5); + } fig0_9->ensembleEcc = ensemble->ecc; fig0_9->tableId = ensemble->international_table; index += 5; diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index 11eb4bf..03e9bbf 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -383,6 +383,47 @@ const string DabService::get_parameter(const string& parameter) const } +void dabEnsemble::set_parameter(const string& parameter, const string& value) +{ + stringstream ss(value); + ss.exceptions ( stringstream::failbit | stringstream::badbit ); + + if (parameter == "localtimeoffset") { + int new_lto = atol(value.c_str()); + + if (new_lto < -24) { + throw ParameterError("Desired local time offset too small." + " Minimum -24" ); + } + else if (new_lto > 24) { + throw ParameterError("Desired local time offset too large." + " Maximum 24" ); + } + + this->lto = new_lto; + } + else { + stringstream ss; + ss << "Parameter '" << parameter << + "' is not exported by controllable " << get_rc_name(); + throw ParameterError(ss.str()); + } +} + +const string dabEnsemble::get_parameter(const string& parameter) const +{ + stringstream ss; + if (parameter == "localtimeoffset") { + ss << this->lto; + } + else { + ss << "Parameter '" << parameter << + "' is not exported by controllable " << get_rc_name(); + throw ParameterError(ss.str()); + } + return ss.str(); +} + unsigned short getSizeCu(dabSubchannel* subchannel) { if (subchannel->protection.form == 0) { diff --git a/src/MuxElements.h b/src/MuxElements.h index 3bcc903..82e839d 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -90,17 +90,34 @@ class DabService; class DabComponent; struct dabSubchannel; -struct dabEnsemble { - uint16_t id; - uint8_t ecc; - DabLabel label; - uint8_t mode; - int lto; // local time offset in half-hours - // range: -24 to +24 - int international_table; - vector<DabService*> services; - vector<DabComponent*> components; - vector<dabSubchannel*> subchannels; +class dabEnsemble : public RemoteControllable { + public: + dabEnsemble() + : RemoteControllable("ensemble") + { + RC_ADD_PARAMETER(localtimeoffset, + "local time offset, -24 to +24 [half-hours]"); + } + + /* Remote control */ + virtual void set_parameter(const string& parameter, + const string& value); + + /* Getting a parameter always returns a string. */ + virtual const string get_parameter(const string& parameter) const; + + /* all fields are public, since this was a struct before */ + uint16_t id; + uint8_t ecc; + DabLabel label; + uint8_t mode; + int lto; // local time offset in half-hours + // range: -24 to +24 + int international_table; + + vector<DabService*> services; + vector<DabComponent*> components; + vector<dabSubchannel*> subchannels; }; diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp index d699ed0..f781b78 100644 --- a/src/ParserConfigfile.cpp +++ b/src/ParserConfigfile.cpp @@ -204,10 +204,6 @@ void parse_configfile(string configuration_file, } ensemble->lto = abs(rint(lto_hours * 2)); - if (lto_hours < 0.0) { // ensemble->lto is 1-bit complement - ensemble->lto |= (1<<5); // sign bit - } - int success = -5; string ensemble_label = pt_ensemble.get<string>("label"); string ensemble_short_label(ensemble_label); |