30 if (m_local_name ==
"")
32 yCError(ROBOTDESCRIPTIONSERVER,
"open(): Invalid local name");
36 std::string local_rpc = m_local_name;
39 if (!m_rpc_port.open(local_rpc))
41 yCError(ROBOTDESCRIPTIONSERVER,
"open(): Could not open rpc port %s, check network", local_rpc.c_str());
45 m_rpc_port.setReader(*
this);
51 std::lock_guard<std::mutex> guard(m_external_mutex);
52 for (
int i = 0; i < p.
size(); i++)
54 yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getOptions().toString();
55 yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getValue(
"device").toString();
56 yCTrace(ROBOTDESCRIPTIONSERVER) << p[i]->poly->getValue(
"name").toString();
58 dev.
device_name = p[i]->poly->getValue(
"name").toString();
59 dev.
device_type = p[i]->poly->getValue(
"device").toString();
60 if (this->add_device(dev) ==
false)
62 yCError(ROBOTDESCRIPTIONSERVER) <<
"attachAll(): Something strange happened here";
71 std::lock_guard<std::mutex> guard(m_external_mutex);
72 m_robot_devices.clear();
84 std::lock_guard<std::mutex> guard(m_internal_mutex);
85 for (
auto& m_robot_device : m_robot_devices)
89 yCWarning(ROBOTDESCRIPTIONSERVER) <<
"add_device(): Device" << dev.
device_name <<
"already exists, skipping";
93 m_robot_devices.push_back(dev);
99 std::lock_guard<std::mutex> guard(m_internal_mutex);
100 for (
auto it = m_robot_devices.begin(); it != m_robot_devices.end(); it++)
104 m_robot_devices.erase(it);
113 std::lock_guard<std::mutex> guard(m_external_mutex);
119 bool ok = in.
read(connection);
138 for (
auto& m_robot_device : m_robot_devices)
150 for (
auto& m_robot_device : m_robot_devices)
152 if (m_robot_device.device_type == type)
163 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
175 bool b_rem = this->remove_device(dev);
178 yCError(ROBOTDESCRIPTIONSERVER) <<
"remove_device failed";
189 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
200 bool b_add = this->add_device(desc);
203 yCError(ROBOTDESCRIPTIONSERVER) <<
"add_device failed";
214 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
220 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
226 yCError(ROBOTDESCRIPTIONSERVER,
"Invalid vocab received");
237 if (returnToSender !=
nullptr)
239 out.
write(*returnToSender);
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_FAILED
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_SET
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_DEVICE
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_DELETE
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_DESCRIPTION
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_BY_TYPE
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_ALL
constexpr yarp::conf::vocab32_t VOCAB_IROBOT_GET
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool detachAll() override
Detach the object (you must have first called attach).
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool attachAll(const yarp::dev::PolyDriverList &l) override
Attach to a list of objects.
bool close() override
Close the DeviceDriver.
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define yCTrace(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.