aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-31 14:31:32 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-31 14:31:32 +0200
commitae70341365e27d766c8530924209fc4826036aea (patch)
treeb18247e0b96b45b6f74b66d0ab5b5d69bb63f143 /src
parentfe19871f8ee362f65d194b864eb989618b994e58 (diff)
downloaddabmod-ae70341365e27d766c8530924209fc4826036aea.tar.gz
dabmod-ae70341365e27d766c8530924209fc4826036aea.tar.bz2
dabmod-ae70341365e27d766c8530924209fc4826036aea.zip
Add JSON output to RC
Diffstat (limited to 'src')
-rw-r--r--src/DabModulator.cpp7
-rw-r--r--src/DabModulator.h10
-rw-r--r--src/FIRFilter.cpp9
-rw-r--r--src/FIRFilter.h10
-rw-r--r--src/GainControl.cpp20
-rw-r--r--src/GainControl.h12
-rw-r--r--src/GuardIntervalInserter.cpp9
-rw-r--r--src/GuardIntervalInserter.h14
-rw-r--r--src/MemlessPoly.cpp10
-rw-r--r--src/MemlessPoly.h14
-rw-r--r--src/OfdmGenerator.cpp9
-rw-r--r--src/OfdmGenerator.h13
-rw-r--r--src/TII.cpp11
-rw-r--r--src/TII.h14
-rw-r--r--src/TimestampDecoder.cpp21
-rw-r--r--src/TimestampDecoder.h12
-rw-r--r--src/output/SDR.cpp26
-rw-r--r--src/output/SDR.h2
-rw-r--r--src/output/SDRDevice.h3
-rw-r--r--src/output/UHD.h8
20 files changed, 156 insertions, 78 deletions
diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp
index 3d8bd46..67764ba 100644
--- a/src/DabModulator.cpp
+++ b/src/DabModulator.cpp
@@ -410,3 +410,10 @@ const string DabModulator::get_parameter(const string& parameter) const
}
return ss.str();
}
+
+const RemoteControllable::map_t DabModulator::get_all_values() const
+{
+ map_t map;
+ map["rate"] = m_settings.outputRate;
+ return map;
+}
diff --git a/src/DabModulator.h b/src/DabModulator.h
index 00d71f5..0d46e9f 100644
--- a/src/DabModulator.h
+++ b/src/DabModulator.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://opendigitalradio.org
@@ -60,11 +60,9 @@ public:
EtiSource* getEtiSource() { return &myEtiSource; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) override;
-
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
void setMode(unsigned mode);
diff --git a/src/FIRFilter.cpp b/src/FIRFilter.cpp
index 89cf0da..523d405 100644
--- a/src/FIRFilter.cpp
+++ b/src/FIRFilter.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -347,3 +347,10 @@ const string FIRFilter::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t FIRFilter::get_all_values() const
+{
+ map_t map;
+ map["ntaps"] = m_taps.size();
+ map["tapsfile"] = m_taps_file;
+ return map;
+}
diff --git a/src/FIRFilter.h b/src/FIRFilter.h
index 8d2e707..2a469aa 100644
--- a/src/FIRFilter.h
+++ b/src/FIRFilter.h
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -59,11 +59,9 @@ public:
const char* name() override { return "FIRFilter"; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) override;
-
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) override;
diff --git a/src/GainControl.cpp b/src/GainControl.cpp
index b781640..c111de3 100644
--- a/src/GainControl.cpp
+++ b/src/GainControl.cpp
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -574,3 +574,21 @@ const string GainControl::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t GainControl::get_all_values() const
+{
+ map_t map;
+ map["digital"] = m_digGain;
+ switch (m_gainmode) {
+ case GainMode::GAIN_FIX:
+ map["mode"] = "fix";
+ break;
+ case GainMode::GAIN_MAX:
+ map["mode"] = "max";
+ break;
+ case GainMode::GAIN_VAR:
+ map["mode"] = "var";
+ break;
+ }
+ map["var"] = m_var_variance_rc;
+ return map;
+}
diff --git a/src/GainControl.h b/src/GainControl.h
index 4c9a2bc..f0fd6b6 100644
--- a/src/GainControl.h
+++ b/src/GainControl.h
@@ -3,7 +3,7 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -63,13 +63,9 @@ class GainControl : public PipelinedModCodec, public RemoteControllable
const char* name() override { return "GainControl"; }
/* Functions for the remote control */
- /* Base function to set parameters. */
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) override;
-
- /* Getting a parameter always returns a string. */
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
virtual int internal_process(
diff --git a/src/GuardIntervalInserter.cpp b/src/GuardIntervalInserter.cpp
index 0cd5bd5..d5c71fb 100644
--- a/src/GuardIntervalInserter.cpp
+++ b/src/GuardIntervalInserter.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2206, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -302,3 +302,10 @@ const std::string GuardIntervalInserter::get_parameter(const std::string& parame
}
return ss.str();
}
+
+const RemoteControllable::map_t GuardIntervalInserter::get_all_values() const
+{
+ map_t map;
+ map["windowlen"] = d_windowOverlap;
+ return map;
+}
diff --git a/src/GuardIntervalInserter.h b/src/GuardIntervalInserter.h
index 02ba72c..f88bdac 100644
--- a/src/GuardIntervalInserter.h
+++ b/src/GuardIntervalInserter.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -52,15 +52,13 @@ class GuardIntervalInserter : public ModCodec, public RemoteControllable
size_t symSize,
size_t& windowOverlap);
- int process(Buffer* const dataIn, Buffer* dataOut);
- const char* name() { return "GuardIntervalInserter"; }
+ int process(Buffer* const dataIn, Buffer* dataOut) override;
+ const char* name() override { return "GuardIntervalInserter"; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
void update_window(size_t new_window_overlap);
diff --git a/src/MemlessPoly.cpp b/src/MemlessPoly.cpp
index 905ca67..4801ba0 100644
--- a/src/MemlessPoly.cpp
+++ b/src/MemlessPoly.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
Andreas Steger, andreas.steger@digris.ch
@@ -467,3 +467,11 @@ const string MemlessPoly::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t MemlessPoly::get_all_values() const
+{
+ map_t map;
+ map["ncoefs"] = m_coefs_am.size();
+ map["coefs"] = serialise_coefficients();
+ map["coeffile"] = m_coefs_file;
+ return map;
+}
diff --git a/src/MemlessPoly.h b/src/MemlessPoly.h
index 4642596..09adc13 100644
--- a/src/MemlessPoly.h
+++ b/src/MemlessPoly.h
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -63,17 +63,15 @@ public:
MemlessPoly& operator=(const MemlessPoly& other) = delete;
virtual ~MemlessPoly();
- virtual const char* name() { return "MemlessPoly"; }
+ virtual const char* name() override { return "MemlessPoly"; }
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
private:
- int internal_process(Buffer* const dataIn, Buffer* dataOut);
+ int internal_process(Buffer* const dataIn, Buffer* dataOut) override;
void load_coefficients(std::istream& coefData);
std::string serialise_coefficients() const;
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp
index 2e68df0..d161861 100644
--- a/src/OfdmGenerator.cpp
+++ b/src/OfdmGenerator.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -457,3 +457,10 @@ const std::string OfdmGenerator::get_parameter(const std::string& parameter) con
}
return ss.str();
}
+
+const RemoteControllable::map_t OfdmGenerator::get_all_values() const
+{
+ map_t map;
+ // TODO needs rework of the values
+ return map;
+}
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index 30fdff4..90e562a 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2017
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -59,14 +59,9 @@ class OfdmGenerator : public ModCodec, public RemoteControllable
const char* name() override { return "OfdmGenerator"; }
/* Functions for the remote control */
- /* Base function to set parameters. */
- virtual void set_parameter(
- const std::string& parameter,
- const std::string& value) override;
-
- /* Getting a parameter always returns a string. */
- virtual const std::string get_parameter(
- const std::string& parameter) const override;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
struct cfr_iter_stat_t {
diff --git a/src/TII.cpp b/src/TII.cpp
index 904f3ff..b329cdb 100644
--- a/src/TII.cpp
+++ b/src/TII.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -385,3 +385,12 @@ const std::string TII::get_parameter(const std::string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t TII::get_all_values() const
+{
+ map_t map;
+ map["enable"] = m_conf.enable;
+ map["pattern"] = m_conf.pattern;
+ map["comb"] = m_conf.comb;
+ map["old_variant"] = m_conf.old_variant;
+ return map;
+}
diff --git a/src/TII.h b/src/TII.h
index d8c785d..b0ba646 100644
--- a/src/TII.h
+++ b/src/TII.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -83,15 +83,13 @@ class TII : public ModCodec, public RemoteControllable
public:
TII(unsigned int dabmode, tii_config_t& tii_config);
- int process(Buffer* dataIn, Buffer* dataOut);
- const char* name();
+ int process(Buffer* dataIn, Buffer* dataOut) override;
+ const char* name() override;
/******* REMOTE CONTROL ********/
- virtual void set_parameter(const std::string& parameter,
- const std::string& value);
-
- virtual const std::string get_parameter(
- const std::string& parameter) const;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
protected:
// Fill m_Acp with the correct carriers for the pattern/comb
diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp
index 6e97af6..149cd50 100644
--- a/src/TimestampDecoder.cpp
+++ b/src/TimestampDecoder.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2018
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -301,3 +301,22 @@ const std::string TimestampDecoder::get_parameter(
return ss.str();
}
+const RemoteControllable::map_t TimestampDecoder::get_all_values() const
+{
+ map_t map;
+ map["offset"] = timestamp_offset;
+ if (full_timestamp_received) {
+ map["timestamp"] = time_secs + ((double)time_pps / 16384000.0);
+ }
+ else {
+ map["timestamp"] = std::nullopt;
+ }
+
+ if (full_timestamp_received) {
+ map["timestamp0"] = time_secs_of_frame0 + ((double)time_pps_of_frame0 / 16384000.0);
+ }
+ else {
+ map["timestamp0"] = std::nullopt;
+ }
+ return map;
+}
diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h
index 597b777..dc5aa78 100644
--- a/src/TimestampDecoder.h
+++ b/src/TimestampDecoder.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2022
+ Copyright (C) 2023
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -118,16 +118,12 @@ class TimestampDecoder : public RemoteControllable
/*********** REMOTE CONTROL ***************/
/* Base function to set parameters. */
- 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;
+ virtual void set_parameter(const std::string& parameter, const std::string& value) override;
+ virtual const std::string get_parameter(const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
const char* name() { return "TS"; }
-
protected:
/* Push a new MNSC field into the decoder */
void pushMNSCData(uint8_t framephase, uint16_t mnsc);
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp
index cc080dc..860d8ed 100644
--- a/src/output/SDR.cpp
+++ b/src/output/SDR.cpp
@@ -491,6 +491,9 @@ const string SDR::get_parameter(const string& parameter) const
else if (std::holds_alternative<bool>(value)) {
ss << (std::get<bool>(value) ? 1 : 0);
}
+ else if (std::holds_alternative<std::nullopt_t>(value)) {
+ ss << "";
+ }
else {
throw std::logic_error("variant alternative not handled");
}
@@ -507,4 +510,27 @@ const string SDR::get_parameter(const string& parameter) const
return ss.str();
}
+const RemoteControllable::map_t SDR::get_all_values() const
+{
+ map_t stat = m_device->get_run_statistics();
+
+ stat["txgain"] = m_config.txgain;
+ stat["rxgain"] = m_config.rxgain;
+ stat["freq"] = m_config.frequency;
+ stat["muting"] = m_config.muting;
+ stat["temp"] = std::nullopt;
+
+ if (m_device) {
+ const std::optional<double> temp = m_device->get_temperature();
+ if (temp) {
+ stat["temp"] = *temp;
+ }
+ }
+ stat["queued_frames_ms"] = m_queue.size() *
+ (size_t)chrono::duration_cast<chrono::milliseconds>(transmission_frame_duration(m_config.dabMode))
+ .count();
+
+ return stat;
+}
+
} // namespace Output
diff --git a/src/output/SDR.h b/src/output/SDR.h
index eb0ed9d..9f08348 100644
--- a/src/output/SDR.h
+++ b/src/output/SDR.h
@@ -67,6 +67,8 @@ class SDR : public ModOutput, public ModMetadata, public RemoteControllable {
virtual const std::string get_parameter(
const std::string& parameter) const override;
+ virtual const RemoteControllable::map_t get_all_values() const override;
+
private:
void process_thread_entry(void);
void handle_frame(struct FrameData&& frame);
diff --git a/src/output/SDRDevice.h b/src/output/SDRDevice.h
index a4f551c..628372a 100644
--- a/src/output/SDRDevice.h
+++ b/src/output/SDRDevice.h
@@ -112,8 +112,7 @@ struct FrameData {
// All SDR Devices must implement the SDRDevice interface
class SDRDevice {
public:
- using run_statistic_t = std::variant<std::string, double, size_t, ssize_t, bool>;
- using run_statistics_t = std::unordered_map<std::string, run_statistic_t>;
+ using run_statistics_t = RemoteControllable::map_t;
virtual void tune(double lo_offset, double frequency) = 0;
virtual double get_tx_freq(void) const = 0;
diff --git a/src/output/UHD.h b/src/output/UHD.h
index 5823c0e..97a821e 100644
--- a/src/output/UHD.h
+++ b/src/output/UHD.h
@@ -55,14 +55,6 @@ DESCRIPTION:
#include <stdio.h>
#include <sys/types.h>
-// If the timestamp is further in the future than
-// 100 seconds, abort
-#define TIMESTAMP_ABORT_FUTURE 100
-
-// Add a delay to increase buffers when
-// frames are too far in the future
-#define TIMESTAMP_MARGIN_FUTURE 0.5
-
namespace Output {
class UHD : public Output::SDRDevice