18 #include <yarp/os/Bottle.h>
19 #include <yarp/os/BufferedPort.h>
20 #include <yarp/dev/ControlBoardInterfaces.h>
21 #include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
22 #include <yarp/sig/Vector.h>
28 using namespace yarp::os;
30 using namespace yarp::sig;
44 bool SensorEncoders::configure(
void *source,
const Property &options)
46 if ((source==NULL) || !options.check(
"name") ||
47 !options.check(
"size") || !options.check(
"index"))
51 name=options.find(
"name").asString();
52 size=options.find(
"size").asInt32();
53 index=options.find(
"index").asInt32();
55 return configured=
true;
60 bool SensorEncoders::getOutput(Value &in)
const
66 static_cast<IEncoders*
>(source)->getEncoders(vect.data());
67 in=Value(vect[index]);
74 bool SensorEncoderArrays::configure(
void *source,
const Property &options)
76 if ((source==NULL) || !options.check(
"name") || !options.check(
"num_arrays") ||
77 !options.check(
"index_array") || !options.check(
"index_element"))
81 name=options.find(
"name").asString();
82 num_arrays=options.find(
"num_arrays").asInt32();
83 index_array=options.find(
"index_array").asInt32();
84 index_element=options.find(
"index_element").asInt32();
86 return configured=
true;
91 bool SensorEncoderArrays::getOutput(Value &in)
const
93 auto* iencarray=
static_cast<IEncoderArrays*
>(source);
97 if ((index_array<0) || (index_array>=iencarray->getNrOfEncoderArrays()))
100 if ((index_element<0) || (index_element>=iencarray->getEncoderArraySize(index_array)))
103 if (iencarray->getEncoderArrayStatus(index_array)!=MAS_OK)
110 Vector vect(iencarray->getEncoderArraySize(index_array));
111 iencarray->getEncoderArrayMeasure(index_array,vect,stamp);
112 in=Value(vect[index_element]);
120 bool SensorPort::configure(
void *source,
const Property &options)
122 if ((source==NULL) || !options.check(
"name") || !options.check(
"index"))
126 name=options.find(
"name").asString();
127 index=options.find(
"index").asInt32();
129 return configured=
true;
134 bool SensorPort::getOutput(Value &in)
const