26 inline
int checkResponse(
bool ok, const
yarp::os::
Bottle& response)
59 double tmpDT=
now-prev;
82 getEnvelope(newStamp);
85 if (lastStamp.isValid()==
false)
158 return (
int)lastVector.size();
167 std::size_t found = name.find(
'/');
169 if (found == std::string::npos)
175 yCDebug(ANALOGSENSORCLIENT) <<
"found is " << found <<
"; length is : " << name.length();
177 if( (found == 0) || (found == name.length()-1 ) )
186 yCDebug(ANALOGSENSORCLIENT) << name;
191 std::string carrier = config.
check(
"carrier",
Value(
"udp"),
"default carrier for streaming robot state").asString();
201 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid local name");
206 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid remote name\n");
210 std::string local_rpc = local;
211 local_rpc +=
"/rpc:o";
212 std::string remote_rpc = remote;
213 remote_rpc +=
"/rpc:i";
215 if (!inputPort.open(local))
217 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open port %s, check network", local.c_str());
220 inputPort.useCallback();
222 if (!rpcPort.open(local_rpc))
224 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open rpc port %s, check network", local_rpc.c_str());
228 bool ok=Network::connect(remote.c_str(), local.c_str(), carrier.c_str());
231 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s", remote.c_str());
235 ok=Network::connect(local_rpc, remote_rpc);
238 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s\n", remote_rpc.c_str());
254 return inputPort.getLast(out, lastTs);
265 return inputPort.getChannels();
273 bool ok = rpcPort.write(cmd, response);
274 return checkResponse(ok, response);
283 for (
int i = 0; i < this->getChannels(); i++)
285 bool ok = rpcPort.write(cmd, response);
286 return checkResponse(ok, response);
295 bool ok = rpcPort.write(cmd, response);
296 return checkResponse(ok, response);
306 bool ok = rpcPort.write(cmd, response);
307 return checkResponse(ok, response);
constexpr yarp::conf::vocab32_t VOCAB_IANALOG
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE
constexpr yarp::conf::vocab32_t VOCAB_CALIBRATE_CHANNEL
void removeLeadingTrailingSlashesOnly(std::string &name)
yarp::os::Stamp getLastInputStamp() override
Get the time stamp for the last read data.
bool close() override
Close the DeviceDriver.
int calibrateChannel(int ch) override
Calibrates one single channel.
int calibrateSensor() override
Calibrates the whole sensor.
int read(yarp::sig::Vector &out) override
Read a vector from the sensor.
int getState(int ch) override
Check the state value of a given channel.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
int getChannels() override
Get the number of channels of the sensor.
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
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 bool check(const std::string &key) const =0
Check if there exists a property of the given name.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
A single value (typically within a Bottle).
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual bool isInt32() const
Checks if value is a 32-bit integer.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.