113 thr()->push_back(thread);
128 auto tit =
thr()->begin();
129 while (tit !=
thr()->end()) {
143 for (
auto* thread : *
thr()) {
157 for (yarp::robotinterface::ParamList::const_iterator it = p.begin(); it != p.end(); ++it) {
161 std::string stringFormatValue = param.
value();
163 for (
size_t i = 0; i < stringFormatValue.size() && counter >= 0; i++) {
164 if (stringFormatValue[i] ==
'(') {
166 }
else if (stringFormatValue[i] ==
')') {
171 yWarning() <<
"Parentheses not balanced for param " << param.
name();
174 std::string s =
"(" + param.
name() +
" " + param.
value() +
")";
190 dbg <<
"(name = \"" <<
t.name() <<
"\", type = \"" <<
t.type() <<
"\"";
191 if (!
t.params().empty()) {
192 dbg <<
", params = [";
196 if (!
t.actions().empty()) {
197 dbg <<
", actions = [";
212 const std::string& type,
224 mPriv(new
Private(*other.mPriv))
235 if (&other !=
this) {
237 mPriv->type = other.mPriv->
type;
239 mPriv->params.clear();
240 mPriv->params = other.mPriv->
params;
242 mPriv->actions.clear();
243 mPriv->actions = other.mPriv->
actions;
245 *mPriv->driver = *other.mPriv->
driver;
267 return mPriv->params;
272 return mPriv->actions;
287 return mPriv->params;
292 return mPriv->actions;
297 if (mPriv->isValid()) {
298 yError() <<
"Trying to open an already opened device.";
302 if (!mPriv->open()) {
303 yWarning() <<
"Cannot open device" << mPriv->name;
312 if (!mPriv->isValid()) {
318 if (!mPriv->close()) {
319 yWarning() <<
"Cannot close device" << mPriv->name;
343 mPriv->registerThread(thread);
348 mPriv->joinThreads();
353 mPriv->stopThreads();
364 if (!driver()->view(calibrator)) {
370 if (!target.
poly->
view(controlCalibrator)) {
381 bool rem_calibrator_available =
true;
383 if (!target.
poly->
view(rem_calibrator_wrap)) {
384 yWarning() <<
"Device " << target.
key <<
"is not implementing a yarp::dev::IRemoteCalibrator, therefore it cannot attach to a Calibrator device. \n \
385 Please verify that the target of calibrate action is a controlBoard_nws_yarp device. \
386 This doesn't prevent the yarprobotinterface to correctly operate, but no remote calibration and homing will be available";
387 rem_calibrator_available =
false;
390 if ((rem_calibrator_available) && (!driver()->view(rem_calibrator_calib))) {
391 yWarning() <<
"Device " << name() <<
"is not implementing a yarp::dev::IRemoteCalibrator, therefore it cannot be used as a remote calibration device. \n \
392 This doesn't prevent the yarprobotinterface to correctly operate, but no remote calibration and homing will be available";
393 rem_calibrator_available =
false;
396 if (rem_calibrator_available) {
406 registerThread(calibratorThread);
408 if (!calibratorThread->
start()) {
424 driver()->view(multiplewrapper);
426 if (drivers.
size() == 1) {
428 if (!driver()->view(wrapper)) {
429 yInfo() << name() <<
"is not an IWrapper. Trying IMultipleWrapper";
430 }
else if (wrapper->
attach(drivers[0]->poly)) {
432 }
else if (!multiplewrapper) {
436 yInfo() << name() <<
"IWrapper::attach() failed. Trying IMultipleWrapper::attach().";
440 if (!multiplewrapper) {
445 if (!multiplewrapper->
attachAll(drivers)) {
462 driver()->view(wrapper);
463 driver()->view(multiplewrapper);
465 if (!wrapper && !multiplewrapper) {
470 if (multiplewrapper) {
478 yInfo() << name() <<
"IMultipleWrapper::detachAll() failed. Trying IWrapper::detach().";
481 if (wrapper && !wrapper->
detach()) {
497 if (!driver()->isValid()) {
498 yError() <<
"park device do not exists";
502 if (!driver()->view(calibrator)) {
508 if (!target.
poly->
view(controlCalibrator)) {
520 registerThread(parkerThread);
522 if (!parkerThread->
start()) {
define control board standard interfaces
yarp::os::LogStream operator<<(yarp::os::LogStream dbg, const yarp::robotinterface::Device &t)
#define YARP_FIXME_NOTIMPLEMENTED(what)
bool view(T *&x)
Get an interface to the device driver.
Interface for a calibrator device.
Interface for control devices, calibration commands.
virtual bool setCalibrator(ICalibrator *c)
Set the calibrator object to be used to calibrate the robot.
Interface for an object that can wrap/attach to to another.
virtual bool detachAll()=0
Detach the object (you must have first called attach).
virtual bool attachAll(const PolyDriverList &drivers)=0
Attach to a list of objects.
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
virtual bool setCalibratorDevice(yarp::dev::IRemoteCalibrator *dev)
setCalibratorDevice: store the pointer to the calibrator device.
Interface for an object that can wrap/or "attach" to another.
virtual bool detach()=0
Detach the object (you must have first called attach).
virtual bool attach(PolyDriver *driver)=0
Attach to another object.
A container for a device driver.
bool close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A class for storing options and configuration information.
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.
A class for thread synchronization and mutual exclusion.
void wait()
Decrement the counter, even if we must wait to do that.
void post()
Increment the counter.
An abstraction for a thread of execution.
bool join(double seconds=-1)
The function returns when the thread execution has completed.
bool start()
Start the new thread running.
Private & operator=(const Private &other)
yarp::os::Semaphore * reg_sem() const
yarp::dev::PolyDriver * drv() const
Private(const Private &other)
yarp::os::Property paramsAsProperty() const
yarp::os::Semaphore * lst_sem() const
void registerThread(yarp::os::Thread *thread) const
yarp::robotinterface::ThreadList * thr() const
bool attach(const yarp::dev::PolyDriverList &drivers) const
bool park(const yarp::dev::PolyDriverDescriptor &target) const
yarp::dev::PolyDriver * driver() const
bool hasParam(const std::string &name) const
bool calibrate(const yarp::dev::PolyDriverDescriptor &target) const
Device & operator=(const Device &other)
std::string findParam(const std::string &name) const
void registerThread(yarp::os::Thread *thread) const
robotinterface::ParamList mergeDuplicateGroups(const robotinterface::ParamList &list)
std::vector< robotinterface::Action > ActionList
std::string ActionTypeToString(robotinterface::ActionType actiontype)
bool hasParam(const robotinterface::ParamList &list, const std::string &name)
std::vector< robotinterface::Param > ParamList
std::string findParam(const robotinterface::ParamList &list, const std::string &name)
std::list< yarp::os::Thread * > ThreadList
The main, catch-all namespace for YARP.
ThreadList runningThreads
Driver(yarp::dev::PolyDriver *d)
yarp::dev::PolyDriver * driver
yarp::os::Semaphore registerThreadSemaphore
yarp::os::Semaphore threadListSemaphore