116 thr()->push_back(thread);
131 auto tit =
thr()->begin();
132 while (tit !=
thr()->end()) {
146 for (
auto* thread : *
thr()) {
160 for (yarp::robotinterface::ParamList::const_iterator it = p.begin(); it != p.end(); ++it) {
164 std::string stringFormatValue = param.
value();
166 for (
size_t i = 0; i < stringFormatValue.size() && counter >= 0; i++) {
167 if (stringFormatValue[i] ==
'(') {
169 }
else if (stringFormatValue[i] ==
')') {
174 yCWarning(YRI_DEVICE) <<
"Parentheses not balanced for param " << param.
name();
177 std::string s =
"(" + param.
name() +
" " + param.
value() +
")";
193 dbg <<
"(name = \"" << t.
name() <<
"\", type = \"" << t.
type() <<
"\"";
194 if (!t.
params().empty()) {
195 dbg <<
", params = [";
200 dbg <<
", actions = [";
215 const std::string& type,
227 mPriv(new
Private(*other.mPriv))
238 if (&other !=
this) {
240 mPriv->type = other.mPriv->
type;
242 mPriv->params.clear();
243 mPriv->params = other.mPriv->
params;
245 mPriv->actions.clear();
246 mPriv->actions = other.mPriv->
actions;
248 *mPriv->driver = *other.mPriv->
driver;
270 return mPriv->params;
275 return mPriv->actions;
290 return mPriv->params;
295 return mPriv->actions;
300 if (mPriv->isValid()) {
301 yCError(YRI_DEVICE) <<
"Trying to open an already opened device.";
305 if (!mPriv->open()) {
306 yCWarning(YRI_DEVICE) <<
"Cannot open device" << mPriv->name;
315 if (!mPriv->isValid()) {
321 if (!mPriv->close()) {
322 yCWarning(YRI_DEVICE) <<
"Cannot close device" << mPriv->name;
346 mPriv->registerThread(thread);
351 mPriv->joinThreads();
356 mPriv->stopThreads();
367 if (!driver()->view(calibrator)) {
373 if (!target.
poly->
view(controlCalibrator)) {
384 bool rem_calibrator_available =
true;
386 if (!target.
poly->
view(rem_calibrator_wrap)) {
387 yCWarning(YRI_DEVICE) <<
"Device " << target.
key <<
"is not implementing a yarp::dev::IRemoteCalibrator, therefore it cannot attach to a Calibrator device. \n \
388 Please verify that the target of calibrate action is a controlBoard_nws_yarp device. \
389 This doesn't prevent the yarprobotinterface to correctly operate, but no remote calibration and homing will be available";
390 rem_calibrator_available =
false;
393 if ((rem_calibrator_available) && (!driver()->view(rem_calibrator_calib))) {
394 yCWarning(YRI_DEVICE) <<
"Device " << name() <<
"is not implementing a yarp::dev::IRemoteCalibrator, therefore it cannot be used as a remote calibration device. \n \
395 This doesn't prevent the yarprobotinterface to correctly operate, but no remote calibration and homing will be available";
396 rem_calibrator_available =
false;
399 if (rem_calibrator_available) {
409 registerThread(calibratorThread);
411 if (!calibratorThread->
start()) {
427 driver()->view(multiplewrapper);
429 if (drivers.
size() == 1) {
431 if (!driver()->view(wrapper)) {
433 yCDebug(YRI_DEVICE) << name() <<
"is not an IWrapper. Trying IMultipleWrapper";
434 }
else if (wrapper->
attach(drivers[0]->poly)) {
436 }
else if (!multiplewrapper) {
440 yCInfo(YRI_DEVICE) << name() <<
"IWrapper::attach() failed. Trying IMultipleWrapper::attach().";
444 if (!multiplewrapper) {
449 if (!multiplewrapper->
attachAll(drivers)) {
466 driver()->view(wrapper);
467 driver()->view(multiplewrapper);
469 if (!wrapper && !multiplewrapper) {
474 if (multiplewrapper) {
482 yCInfo(YRI_DEVICE) << name() <<
"IMultipleWrapper::detachAll() failed. Trying IWrapper::detach().";
485 if (wrapper && !wrapper->
detach()) {
501 if (!driver()->isValid()) {
502 yCError(YRI_DEVICE) <<
"park device do not exists";
506 if (!driver()->view(calibrator)) {
512 if (!target.
poly->
view(controlCalibrator)) {
524 registerThread(parkerThread);
526 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
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
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