23inline
int checkResponse(
bool ok, const
yarp::os::
Bottle& response)
45 state=IAnalogSensor::AS_ERROR;
56 double tmpDT=now-prev;
58 if (tmpDT > deltaTMax) {
61 if (tmpDT < deltaTMin) {
68 state=IAnalogSensor::AS_OK;
72 state=IAnalogSensor::AS_TIMEOUT;
92 state=IAnalogSensor::AS_OK;
96 state=IAnalogSensor::AS_TIMEOUT;
107 if (
ret!=IAnalogSensor::AS_ERROR)
151 if (state==IAnalogSensor::AS_ERROR)
157 return (
int)lastVector.
size();
168 if (found == std::string::npos)
174 yCDebug(ANALOGSENSORCLIENT) <<
"found is " << found <<
"; length is : " << name.length();
176 if( (found == 0) || (found == name.length()-1 ) )
185 yCDebug(ANALOGSENSORCLIENT) << name;
190 yCWarning(ANALOGSENSORCLIENT) <<
"The 'inertial' device is deprecated in favour of 'multipleanalogsensorsclient'";
191 yCWarning(ANALOGSENSORCLIENT) <<
"The old device is no longer supported, and it will be deprecated in YARP 3.7 and removed in YARP 4.";
192 yCWarning(ANALOGSENSORCLIENT) <<
"Please update your scripts.";
194 std::string carrier = config.
check(
"carrier",
Value(
"udp"),
"default carrier for streaming robot state").asString();
204 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid local name");
209 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error you have to provide valid remote name\n");
213 std::string local_rpc =
local;
214 local_rpc +=
"/rpc:o";
215 std::string remote_rpc =
remote;
216 remote_rpc +=
"/rpc:i";
220 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open port %s, check network",
local.c_str());
227 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not open rpc port %s, check network", local_rpc.c_str());
231 bool ok=Network::connect(
remote.c_str(),
local.c_str(), carrier.c_str());
234 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s",
remote.c_str());
238 ok=Network::connect(local_rpc, remote_rpc);
241 yCError(ANALOGSENSORCLIENT,
"AnalogSensorClient::open() error could not connect to %s\n", remote_rpc.c_str());
277 return checkResponse(ok, response);
290 return checkResponse(ok, response);
300 return checkResponse(ok, response);
311 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.
InputPortProcessor inputPort
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.
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.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number 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.
bool getEnvelope(PortReader &envelope) override
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
bool isValid() const
Check if this Stamp is valid.
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 yCWarning(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
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.