aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-07 16:53:32 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-07 16:53:32 +0200
commitb455a74818b35566f4bf524e4824c000bcf3194f (patch)
tree1691540516982c48d5d98d07a2b55620be089783 /src
parent7a66d48f815b475d98e56a99a5125ba3b8592e8d (diff)
downloaddabmod-b455a74818b35566f4bf524e4824c000bcf3194f.tar.gz
dabmod-b455a74818b35566f4bf524e4824c000bcf3194f.tar.bz2
dabmod-b455a74818b35566f4bf524e4824c000bcf3194f.zip
Rework remotecontrol
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp22
-rw-r--r--src/DabModulator.cpp12
-rw-r--r--src/DabModulator.h2
-rw-r--r--src/EtiReader.cpp5
-rw-r--r--src/EtiReader.h3
-rw-r--r--src/OutputUHD.h3
-rw-r--r--src/RemoteControl.cpp57
-rw-r--r--src/RemoteControl.h300
-rw-r--r--src/TimestampDecoder.h3
9 files changed, 143 insertions, 264 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 904c3c8..1cbbcbc 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -76,10 +76,6 @@ typedef std::complex<float> complexf;
using namespace std;
-// We need global lifetime for the RemoteControllers because
-// some destructors of long lived objects use it.
-RemoteControllers rcs;
-
volatile sig_atomic_t running = 1;
void signalHandler(int signalNb)
@@ -338,7 +334,7 @@ int launch_modulator(int argc, char* argv[])
if (pt.get("remotecontrol.telnet", 0) == 1) {
try {
int telnetport = pt.get<int>("remotecontrol.telnetport");
- RemoteControllerTelnet* telnetrc = new RemoteControllerTelnet(telnetport);
+ auto telnetrc = make_shared<RemoteControllerTelnet>(telnetport);
rcs.add_controller(telnetrc);
}
catch (std::exception &e) {
@@ -353,7 +349,7 @@ int launch_modulator(int argc, char* argv[])
try {
std::string zmqCtrlEndpoint = pt.get("remotecontrol.zmqctrlendpoint", "");
std::cerr << "ZmqCtrlEndpoint: " << zmqCtrlEndpoint << std::endl;
- RemoteControllerZmq* zmqrc = new RemoteControllerZmq(zmqCtrlEndpoint);
+ auto zmqrc = make_shared<RemoteControllerZmq>(zmqCtrlEndpoint);
rcs.add_controller(zmqrc);
}
catch (std::exception &e) {
@@ -588,12 +584,6 @@ int launch_modulator(int argc, char* argv[])
tiiConfig.pattern = pt.get("tii.pattern", 0);
}
- if (rcs.get_no_controllers() == 0) {
- etiLog.level(warn) << "No Remote-Control started";
- rcs.add_controller(new RemoteControllerDummy());
- }
-
-
etiLog.level(info) << "Starting up version " <<
#if defined(GITVERSION)
GITVERSION;
@@ -739,7 +729,7 @@ int launch_modulator(int argc, char* argv[])
normalise = 1.0f / normalise_factor;
outputuhd_conf.sampleRate = outputRate;
output = make_shared<OutputUHD>(outputuhd_conf);
- ((OutputUHD*)output.get())->enrol_at(rcs);
+ rcs.enrol((OutputUHD*)output.get());
}
#endif
#if defined(HAVE_ZEROMQ)
@@ -774,7 +764,7 @@ int launch_modulator(int argc, char* argv[])
shared_ptr<InputMemory> input(new InputMemory(&m.data));
shared_ptr<DabModulator> modulator(
- new DabModulator(tist_offset_s, tist_delay_stages, &rcs,
+ new DabModulator(tist_offset_s, tist_delay_stages,
tiiConfig, outputRate, clockRate, dabMode, gainMode,
digitalgain, normalise, filterTapsFilename));
@@ -888,8 +878,8 @@ run_modulator_state_t run_modulator(modulator_data& m)
/* Check every once in a while if the remote control
* is still working */
- if (m.rcs->get_no_controllers() > 0 && (m.framecount % 250) == 0) {
- m.rcs->check_faults();
+ if ((m.framecount % 250) == 0) {
+ rcs.check_faults();
}
}
if (framesize == 0) {
diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp
index 61e5ce8..927c7bd 100644
--- a/src/DabModulator.cpp
+++ b/src/DabModulator.cpp
@@ -56,7 +56,6 @@
DabModulator::DabModulator(
double& tist_offset_s, unsigned tist_delay_stages,
- RemoteControllers* rcs,
tii_config_t& tiiConfig,
unsigned outputRate, unsigned clockRate,
unsigned dabMode, GainMode gainMode,
@@ -70,11 +69,10 @@ DabModulator::DabModulator(
myGainMode(gainMode),
myDigGain(digGain),
myNormalise(normalise),
- myEtiReader(tist_offset_s, tist_delay_stages, rcs),
+ myEtiReader(tist_offset_s, tist_delay_stages),
myFlowgraph(NULL),
myFilterTapsFilename(filterTapsFilename),
- myTiiConfig(tiiConfig),
- myRCs(rcs)
+ myTiiConfig(tiiConfig)
{
PDEBUG("DabModulator::DabModulator(%u, %u, %u, %u) @ %p\n",
outputRate, clockRate, dabMode, gainMode, this);
@@ -198,7 +196,7 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
shared_ptr<TII> tii;
try {
tii = make_shared<TII>(myDabMode, myTiiConfig);
- tii->enrol_at(*myRCs);
+ rcs.enrol(tii.get());
}
catch (TIIError& e) {
etiLog.level(error) << "Could not initialise TII: " << e.what();
@@ -210,7 +208,7 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
auto cifGain = make_shared<GainControl>(
mySpacing, myGainMode, myDigGain, myNormalise);
- cifGain->enrol_at(*myRCs);
+ rcs.enrol(cifGain.get());
auto cifGuard = make_shared<GuardIntervalInserter>(
myNbSymbols, mySpacing, myNullSize, mySymSize);
@@ -218,7 +216,7 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
shared_ptr<FIRFilter> cifFilter;
if (myFilterTapsFilename != "") {
cifFilter = make_shared<FIRFilter>(myFilterTapsFilename);
- cifFilter->enrol_at(*myRCs);
+ rcs.enrol(cifFilter.get());
}
auto myOutput = make_shared<OutputMemory>(dataOut);
diff --git a/src/DabModulator.h b/src/DabModulator.h
index 2e5691f..fb2d758 100644
--- a/src/DabModulator.h
+++ b/src/DabModulator.h
@@ -51,7 +51,6 @@ class DabModulator : public ModCodec
public:
DabModulator(
double& tist_offset_s, unsigned tist_delay_stages,
- RemoteControllers* rcs,
tii_config_t& tiiConfig,
unsigned outputRate, unsigned clockRate,
unsigned dabMode, GainMode gainMode,
@@ -81,7 +80,6 @@ protected:
OutputMemory* myOutput;
std::string& myFilterTapsFilename;
tii_config_t& myTiiConfig;
- RemoteControllers* myRCs;
size_t myNbSymbols;
size_t myNbCarriers;
diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp
index 067d6d0..1511015 100644
--- a/src/EtiReader.cpp
+++ b/src/EtiReader.cpp
@@ -54,14 +54,13 @@ enum ETI_READER_STATE {
EtiReader::EtiReader(
double& tist_offset_s,
- unsigned tist_delay_stages,
- RemoteControllers* rcs) :
+ unsigned tist_delay_stages) :
state(EtiReaderStateSync),
myTimestampDecoder(tist_offset_s, tist_delay_stages)
{
PDEBUG("EtiReader::EtiReader()\n");
- myTimestampDecoder.enrol_at(*rcs);
+ rcs.enrol(&myTimestampDecoder);
myCurrentFrame = 0;
eti_fc_valid = false;
diff --git a/src/EtiReader.h b/src/EtiReader.h
index 4c0d4f3..33c4230 100644
--- a/src/EtiReader.h
+++ b/src/EtiReader.h
@@ -49,8 +49,7 @@ class EtiReader
public:
EtiReader(
double& tist_offset_s,
- unsigned tist_delay_stages,
- RemoteControllers* rcs);
+ unsigned tist_delay_stages);
std::shared_ptr<FicSource>& getFic();
unsigned getMode();
diff --git a/src/OutputUHD.h b/src/OutputUHD.h
index 1c59136..8ef4037 100644
--- a/src/OutputUHD.h
+++ b/src/OutputUHD.h
@@ -229,9 +229,6 @@ class OutputUHD: public ModOutput, public RemoteControllable {
void setETIReader(EtiReader *etiReader);
/*********** REMOTE CONTROL ***************/
- /* virtual void enrol_at(BaseRemoteController& controller)
- * is inherited
- */
/* Base function to set parameters. */
virtual void set_parameter(const std::string& parameter,
diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp
index 3872dc3..a053431 100644
--- a/src/RemoteControl.cpp
+++ b/src/RemoteControl.cpp
@@ -3,8 +3,10 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://www.opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -30,18 +32,43 @@
#include <boost/thread.hpp>
#include "RemoteControl.h"
-#include "Utils.h"
using boost::asio::ip::tcp;
using namespace std;
+RemoteControllers rcs;
void RemoteControllerTelnet::restart()
{
- m_restarter_thread = boost::thread(&RemoteControllerTelnet::restart_thread,
+ m_restarter_thread = boost::thread(
+ &RemoteControllerTelnet::restart_thread,
this, 0);
}
+RemoteControllable::~RemoteControllable() {
+ rcs.remove_controllable(this);
+}
+
+std::list<std::string> RemoteControllable::get_supported_parameters() const {
+ std::list<std::string> parameterlist;
+ for (const auto& param : m_parameters) {
+ parameterlist.push_back(param[0]);
+ }
+ return parameterlist;
+}
+
+RemoteControllable* RemoteControllers::get_controllable_(const std::string& name) {
+ auto rc = std::find_if(controllables.begin(), controllables.end(),
+ [&](RemoteControllable* r) { return r->get_rc_name() == name; });
+
+ if (rc == controllables.end()) {
+ throw ParameterError("Module name unknown");
+ }
+ else {
+ return *rc;
+ }
+}
+
// This runs in a separate thread, because
// it would take too long to be done in the main loop
// thread.
@@ -59,7 +86,6 @@ void RemoteControllerTelnet::restart_thread(long)
void RemoteControllerTelnet::process(long)
{
- set_thread_name("telnet_rc");
std::string m_welcome = "ODR-DabMod Remote Control CLI\n"
"Write 'help' for help.\n"
"**********\n";
@@ -96,7 +122,7 @@ void RemoteControllerTelnet::process(long)
boost::asio::streambuf buffer;
length = boost::asio::read_until( socket, buffer, "\n", ignored_error);
- std::istream str(&buffer);
+ std::istream str(&buffer);
std::getline(str, in_message);
if (length == 0) {
@@ -104,7 +130,7 @@ void RemoteControllerTelnet::process(long)
break;
}
- while (in_message.length() > 0 &&
+ while (in_message.length() > 0 &&
(in_message[in_message.length()-1] == '\r' ||
in_message[in_message.length()-1] == '\n')) {
in_message.erase(in_message.length()-1, 1);
@@ -151,7 +177,7 @@ void RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string comman
stringstream ss;
if (cmd.size() == 1) {
- for (auto &controllable : m_cohort) {
+ for (auto &controllable : rcs.controllables) {
ss << controllable->get_rc_name() << endl;
list< vector<string> > params = controllable->get_parameter_descriptions();
@@ -170,7 +196,7 @@ void RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string comman
if (cmd.size() == 2) {
try {
stringstream ss;
- list< vector<string> > r = get_param_list_values_(cmd[1]);
+ list< vector<string> > r = rcs.get_param_list_values(cmd[1]);
for (auto &param_val : r) {
ss << param_val[0] << ": " << param_val[1] << endl;
}
@@ -188,7 +214,7 @@ void RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string comman
else if (cmd[0] == "get") {
if (cmd.size() == 3) {
try {
- string r = get_param_(cmd[1], cmd[2]);
+ string r = rcs.get_param(cmd[1], cmd[2]);
reply(socket, r);
}
catch (ParameterError &e) {
@@ -211,7 +237,7 @@ void RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string comman
}
}
- set_param_(cmd[1], cmd[2], new_param_value.str());
+ rcs.set_param(cmd[1], cmd[2], new_param_value.str());
reply(socket, "ok");
}
catch (ParameterError &e) {
@@ -300,7 +326,6 @@ void RemoteControllerZmq::send_fail_reply(zmq::socket_t &pSocket, const std::str
void RemoteControllerZmq::process()
{
- set_thread_name("zmq_rc");
// create zmq reply socket for receiving ctrl parameters
etiLog.level(info) << "Starting zmq remote control thread";
try {
@@ -329,8 +354,8 @@ void RemoteControllerZmq::process()
send_ok_reply(repSocket);
}
else if (msg.size() == 1 && command == "list") {
- size_t cohort_size = m_cohort.size();
- for (auto &controllable : m_cohort) {
+ size_t cohort_size = rcs.controllables.size();
+ for (auto &controllable : rcs.controllables) {
std::stringstream ss;
ss << controllable->get_rc_name();
@@ -346,7 +371,7 @@ void RemoteControllerZmq::process()
else if (msg.size() == 2 && command == "show") {
std::string module((char*) msg[1].data(), msg[1].size());
try {
- list< vector<string> > r = get_param_list_values_(module);
+ list< vector<string> > r = rcs.get_param_list_values(module);
size_t r_size = r.size();
for (auto &param_val : r) {
std::stringstream ss;
@@ -367,7 +392,7 @@ void RemoteControllerZmq::process()
std::string parameter((char*) msg[2].data(), msg[2].size());
try {
- std::string value = get_param_(module, parameter);
+ std::string value = rcs.get_param(module, parameter);
zmq::message_t msg(value.size());
memcpy ((void*) msg.data(), value.data(), value.size());
repSocket.send(msg, 0);
@@ -382,7 +407,7 @@ void RemoteControllerZmq::process()
std::string value((char*) msg[3].data(), msg[3].size());
try {
- set_param_(module, parameter, value);
+ rcs.set_param(module, parameter, value);
send_ok_reply(repSocket);
}
catch (ParameterError &err) {
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index deae961..e4345de 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -3,11 +3,12 @@
Her Majesty the Queen in Right of Canada (Communications Research
Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
+ http://www.opendigitalradio.org
+
This module adds remote-control capability to some of the dabmod modules.
- see testremotecontrol/test.cpp for an example of how to use this.
*/
/*
This file is part of ODR-DabMod.
@@ -26,20 +27,21 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _REMOTECONTROL_H
-#define _REMOTECONTROL_H
+#pragma once
#ifdef HAVE_CONFIG_H
-# include "config.h"
+# include "config.h"
#endif
#if defined(HAVE_ZEROMQ)
-#include "zmq.hpp"
+# include "zmq.hpp"
#endif
#include <list>
#include <map>
+#include <memory>
#include <string>
+#include <atomic>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
@@ -57,7 +59,6 @@
m_parameters.push_back(p); \
}
-
class ParameterError : public std::exception
{
public:
@@ -76,14 +77,8 @@ class RemoteControllable;
*/
class BaseRemoteController {
public:
- /* Add a new controllable under this controller's command */
- virtual void enrol(RemoteControllable* controllable) = 0;
-
- /* Remove a controllable under this controller's command */
- virtual void disengage(RemoteControllable* controllable) = 0;
-
/* When this returns one, the remote controller cannot be
- * used anymore, and must be restarted by dabmux
+ * used anymore, and must be restarted by DabMod
*/
virtual bool fault_detected() = 0;
@@ -95,25 +90,60 @@ class BaseRemoteController {
virtual ~BaseRemoteController() {}
};
-/* Holds all our remote controllers, i.e. we may have more than
- * one type of controller running.
+/* Objects that support remote control must implement the following class */
+class RemoteControllable {
+ public:
+ RemoteControllable(const std::string& name) :
+ m_name(name) {}
+
+ RemoteControllable(const RemoteControllable& other) = delete;
+ RemoteControllable& operator=(const RemoteControllable& other) = delete;
+
+ virtual ~RemoteControllable();
+
+ /* return a short name used to identify the controllable.
+ * It might be used in the commands the user has to type, so keep
+ * it short
+ */
+ virtual std::string get_rc_name() const { return m_name; }
+
+ /* Return a list of possible parameters that can be set */
+ virtual std::list<std::string> get_supported_parameters() const;
+
+ /* Return a mapping of the descriptions of all parameters */
+ virtual std::list< std::vector<std::string> >
+ get_parameter_descriptions() const
+ {
+ return m_parameters;
+ }
+
+ /* Base function to set parameters. */
+ 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;
+
+ protected:
+ std::string m_name;
+ std::list< std::vector<std::string> > m_parameters;
+};
+
+/* Holds all our remote controllers and controlled object.
*/
class RemoteControllers {
public:
- void add_controller(BaseRemoteController *rc) {
+ void add_controller(std::shared_ptr<BaseRemoteController> rc) {
m_controllers.push_back(rc);
}
- void add_controllable(RemoteControllable *rc) {
- for (auto &controller : m_controllers) {
- controller->enrol(rc);
- }
+ void enrol(RemoteControllable *rc) {
+ controllables.push_back(rc);
}
void remove_controllable(RemoteControllable *rc) {
- for (auto &controller : m_controllers) {
- controller->disengage(rc);
- }
+ controllables.remove(rc);
}
void check_faults() {
@@ -126,72 +156,42 @@ class RemoteControllers {
}
}
}
- size_t get_no_controllers() { return m_controllers.size(); }
-
- private:
- std::list<BaseRemoteController*> m_controllers;
-};
-/* Objects that support remote control must implement the following class */
-class RemoteControllable {
- public:
+ std::list< std::vector<std::string> >
+ get_param_list_values(const std::string& name) {
+ RemoteControllable* controllable = get_controllable_(name);
- RemoteControllable(std::string name) :
- m_rcs_enrolled_at(nullptr),
- m_name(name) {}
+ std::list< std::vector<std::string> > allparams;
+ for (auto &param : controllable->get_supported_parameters()) {
+ std::vector<std::string> item;
+ item.push_back(param);
+ item.push_back(controllable->get_parameter(param));
- virtual ~RemoteControllable() {
- if (m_rcs_enrolled_at) {
- m_rcs_enrolled_at->remove_controllable(this);
+ allparams.push_back(item);
}
+ return allparams;
}
- /* return a short name used to identify the controllable.
- * It might be used in the commands the user has to type, so keep
- * it short
- */
- virtual std::string get_rc_name() const { return m_name; }
-
- /* Tell the controllable to enrol at the given controller */
- virtual void enrol_at(RemoteControllers& controllers) {
- if (m_rcs_enrolled_at) {
- throw std::runtime_error("This controllable is already enrolled");
- }
-
- m_rcs_enrolled_at = &controllers;
- controllers.add_controllable(this);
+ std::string get_param(const std::string& name, const std::string& param) {
+ RemoteControllable* controllable = get_controllable_(name);
+ return controllable->get_parameter(param);
}
- /* Return a list of possible parameters that can be set */
- virtual std::list<std::string> get_supported_parameters() const {
- std::list<std::string> parameterlist;
- for (const auto& param : m_parameters) {
- parameterlist.push_back(param[0]);
- }
- return parameterlist;
+ void set_param(const std::string& name, const std::string& param, const std::string& value) {
+ RemoteControllable* controllable = get_controllable_(name);
+ return controllable->set_parameter(param, value);
}
- /* Return a mapping of the descriptions of all parameters */
- virtual std::list< std::vector<std::string> >
- get_parameter_descriptions() const {
- return m_parameters;
- }
+ std::list<RemoteControllable*> controllables;
- /* Base function to set parameters. */
- virtual void set_parameter(const std::string& parameter,
- const std::string& value) = 0;
+ private:
+ RemoteControllable* get_controllable_(const std::string& name);
- /* Getting a parameter always returns a string. */
- virtual const std::string get_parameter(const std::string& parameter) const = 0;
+ std::list<std::shared_ptr<BaseRemoteController> > m_controllers;
+};
- protected:
- RemoteControllers* m_rcs_enrolled_at;
- std::string m_name;
- std::list< std::vector<std::string> > m_parameters;
+extern RemoteControllers rcs;
- RemoteControllable(const RemoteControllable& other) = delete;
- RemoteControllable& operator=(const RemoteControllable& other) = delete;
-};
/* Implements a Remote controller based on a simple telnet CLI
* that listens on localhost
@@ -205,8 +205,10 @@ class RemoteControllerTelnet : public BaseRemoteController {
RemoteControllerTelnet(int port)
: m_running(true), m_fault(false),
m_child_thread(&RemoteControllerTelnet::process, this, 0),
- m_port(port)
- { }
+ m_port(port) { }
+
+ RemoteControllerTelnet& operator=(const RemoteControllerTelnet& other) = delete;
+ RemoteControllerTelnet(const RemoteControllerTelnet& other) = delete;
~RemoteControllerTelnet() {
m_running = false;
@@ -217,14 +219,6 @@ class RemoteControllerTelnet : public BaseRemoteController {
}
}
- void enrol(RemoteControllable* controllable) {
- m_cohort.push_back(controllable);
- }
-
- void disengage(RemoteControllable* controllable) {
- m_cohort.remove(controllable);
- }
-
virtual bool fault_detected() { return m_fault; }
virtual void restart();
@@ -239,9 +233,6 @@ class RemoteControllerTelnet : public BaseRemoteController {
void reply(boost::asio::ip::tcp::socket& socket, std::string message);
- RemoteControllerTelnet& operator=(const RemoteControllerTelnet& other);
- RemoteControllerTelnet(const RemoteControllerTelnet& other);
-
std::vector<std::string> tokenise_(std::string message) {
std::vector<std::string> all_tokens;
@@ -253,64 +244,14 @@ class RemoteControllerTelnet : public BaseRemoteController {
return all_tokens;
}
- RemoteControllable* get_controllable_(std::string name) {
- for (std::list<RemoteControllable*>::iterator it = m_cohort.begin();
- it != m_cohort.end(); ++it) {
- if ((*it)->get_rc_name() == name)
- {
- return *it;
- }
- }
- throw ParameterError("Module name unknown");
- }
-
- std::list< std::vector<std::string> >
- get_parameter_descriptions_(std::string name) {
- RemoteControllable* controllable = get_controllable_(name);
- return controllable->get_parameter_descriptions();
- }
-
- std::list<std::string> get_param_list_(std::string name) {
- RemoteControllable* controllable = get_controllable_(name);
- return controllable->get_supported_parameters();
- }
-
- std::list< std::vector<std::string> >
- get_param_list_values_(std::string name) {
- RemoteControllable* controllable = get_controllable_(name);
-
- std::list< std::vector<std::string> > allparams;
- for (auto &param : controllable->get_supported_parameters()) {
- std::vector<std::string> item;
- item.push_back(param);
- item.push_back(controllable->get_parameter(param));
-
- allparams.push_back(item);
- }
- return allparams;
- }
-
- std::string get_param_(std::string name, std::string param) {
- RemoteControllable* controllable = get_controllable_(name);
- return controllable->get_parameter(param);
- }
-
- void set_param_(std::string name, std::string param, std::string value) {
- RemoteControllable* controllable = get_controllable_(name);
- return controllable->set_parameter(param, value);
- }
-
- bool m_running;
+ std::atomic<bool> m_running;
/* This is set to true if a fault occurred */
- bool m_fault;
+ std::atomic<bool> m_fault;
boost::thread m_restarter_thread;
boost::thread m_child_thread;
- /* This controller commands the controllables in the cohort */
- std::list<RemoteControllable*> m_cohort;
-
int m_port;
};
@@ -325,12 +266,15 @@ class RemoteControllerZmq : public BaseRemoteController {
m_zmqContext(1),
m_endpoint("") { }
- RemoteControllerZmq(std::string endpoint)
+ RemoteControllerZmq(const std::string& endpoint)
: m_running(true), m_fault(false),
m_zmqContext(1),
m_endpoint(endpoint),
m_child_thread(&RemoteControllerZmq::process, this) { }
+ RemoteControllerZmq& operator=(const RemoteControllerZmq& other) = delete;
+ RemoteControllerZmq(const RemoteControllerZmq& other) = delete;
+
~RemoteControllerZmq() {
m_running = false;
m_fault = false;
@@ -340,14 +284,6 @@ class RemoteControllerZmq : public BaseRemoteController {
}
}
- void enrol(RemoteControllable* controllable) {
- m_cohort.push_back(controllable);
- }
-
- void disengage(RemoteControllable* controllable) {
- m_cohort.remove(controllable);
- }
-
virtual bool fault_detected() { return m_fault; }
virtual void restart();
@@ -360,76 +296,16 @@ class RemoteControllerZmq : public BaseRemoteController {
void send_fail_reply(zmq::socket_t &pSocket, const std::string &error);
void process();
-
- RemoteControllerZmq& operator=(const RemoteControllerZmq& other);
- RemoteControllerZmq(const RemoteControllerZmq& other);
-
- RemoteControllable* get_controllable_(std::string name) {
- for (std::list<RemoteControllable*>::iterator it = m_cohort.begin();
- it != m_cohort.end(); ++it) {
- if ((*it)->get_rc_name() == name)
- {
- return *it;
- }
- }
- throw ParameterError("Module name unknown");
- }
-
- std::string get_param_(std::string name, std::string param) {
- RemoteControllable* controllable = get_controllable_(name);
- return controllable->get_parameter(param);
- }
-
- void set_param_(std::string name, std::string param, std::string value) {
- RemoteControllable* controllable = get_controllable_(name);
- return controllable->set_parameter(param, value);
- }
-
- std::list< std::vector<std::string> >
- get_param_list_values_(std::string name) {
- RemoteControllable* controllable = get_controllable_(name);
-
- std::list< std::vector<std::string> > allparams;
-
- for (auto &param : controllable->get_supported_parameters()) {
- std::vector<std::string> item;
- item.push_back(param);
- item.push_back(controllable->get_parameter(param));
-
- allparams.push_back(item);
- }
-
- return allparams;
- }
-
-
- bool m_running;
+ std::atomic<bool> m_running;
/* This is set to true if a fault occurred */
- bool m_fault;
+ std::atomic<bool> m_fault;
boost::thread m_restarter_thread;
zmq::context_t m_zmqContext;
- /* This controller commands the controllables in the cohort */
- std::list<RemoteControllable*> m_cohort;
-
std::string m_endpoint;
boost::thread m_child_thread;
};
#endif
-/* The Dummy remote controller does nothing, and never fails
- */
-class RemoteControllerDummy : public BaseRemoteController {
- public:
- void enrol(RemoteControllable*) {}
- void disengage(RemoteControllable*) {}
-
- bool fault_detected() { return false; }
-
- virtual void restart() {}
-};
-
-#endif
-
diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h
index c538ea0..29e12c2 100644
--- a/src/TimestampDecoder.h
+++ b/src/TimestampDecoder.h
@@ -143,9 +143,6 @@ class TimestampDecoder : public RemoteControllable
int32_t fct);
/*********** REMOTE CONTROL ***************/
- /* virtual void enrol_at(BaseRemoteController& controller)
- * is inherited
- */
/* Base function to set parameters. */
virtual void set_parameter(const std::string& parameter,