26 YARP_LOG_COMPONENT(REMOTECONTROLBOARDREMAPPER,
"yarp.device.remotecontrolboardremapper")
30 void RemoteControlBoardRemapper::closeAllRemoteControlBoards()
32 for(
auto& m_remoteControlBoardDevice : m_remoteControlBoardDevices)
34 if( m_remoteControlBoardDevice )
36 m_remoteControlBoardDevice->close();
37 delete m_remoteControlBoardDevice;
38 m_remoteControlBoardDevice =
nullptr;
42 m_remoteControlBoardDevices.resize(0);
58 closeAllRemoteControlBoards();
68 std::string localPortPrefix;
69 std::vector<std::string> remoteControlBoardsPorts;
74 localPortPrefix = prop.
find(
"localPortPrefix").
asString();
78 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Parsing parameters: \"localPortPrefix\" should be a string.";
83 if(remoteControlBoards==
nullptr)
85 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Parsing parameters: \"remoteControlBoards\" should be followed by a list.";
89 remoteControlBoardsPorts.resize(remoteControlBoards->
size());
90 for(
size_t ax=0; ax < remoteControlBoards->
size(); ax++)
92 remoteControlBoardsPorts[ax] = remoteControlBoards->
get(ax).
asString();
98 Bottle & optionsGroupBot = prop.
findGroup(
"REMOTE_CONTROLBOARD_OPTIONS");
99 if( !(optionsGroupBot.
isNull()) )
106 m_remoteControlBoardDevices.resize(remoteControlBoardsPorts.size(),
nullptr);
110 for(
size_t ctrlBrd=0; ctrlBrd < remoteControlBoardsPorts.size(); ctrlBrd++ )
112 std::string remote = remoteControlBoardsPorts[ctrlBrd];
114 std::string local = localPortPrefix+remote;
116 Property options = remoteControlBoardsOptions;
117 options.
put(
"device",
"remote_controlboard");
118 options.
put(
"local", local);
119 options.
put(
"remote", remote);
121 m_remoteControlBoardDevices[ctrlBrd] =
new PolyDriver();
123 bool ok = m_remoteControlBoardDevices[ctrlBrd]->open(options);
125 if( !ok || !(m_remoteControlBoardDevices[ctrlBrd]->
isValid()) )
127 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Opening remote_controlboard with remote \"" << remote <<
"\", opening the device failed.";
128 closeAllRemoteControlBoards();
133 remoteControlBoardsList.
push((m_remoteControlBoardDevices[ctrlBrd]),remote.c_str());
141 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Opening the controlboardremapper device, opening the device failed.";
143 closeAllRemoteControlBoards();
152 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Calling attachAll in the controlboardremapper device, opening the device failed.";
154 closeAllRemoteControlBoards();
bool close() override
Close the device driver by deallocating all resources and closing ports.
bool open(yarp::os::Searchable &prop) override
Open the device driver.
bool detachAll() override
Detach the object (you must have first called attach).
bool attachAll(const yarp::dev::PolyDriverList &l) override
Attach to a list of objects.
bool open(yarp::os::Searchable &prop) override
Open the device driver.
bool close() override
Close the device driver by deallocating all resources and closing ports.
void push(PolyDriver *p, const char *k)
A container for a device driver.
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool isNull() const override
Checks if the object is invalid.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
A base class for nested structures that can be searched.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual bool isString() const
Checks if value is a string.
virtual Bottle * asList() const
Get list value.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
bool isValid()
Check if time is valid (non-zero).
An interface to the operating system, including Port based communication.