36 state=IBattery::BATTERY_GENERAL_ERROR;
47 double tmpDT=now-prev;
49 if (tmpDT > deltaTMax) {
52 if (tmpDT < deltaTMin) {
98 if (
ret != IBattery::BATTERY_GENERAL_ERROR)
186 yCError(BATTERYCLIENT,
"open(): Invalid local name. --local parameter missing.");
191 yCError(BATTERYCLIENT,
"open(): Invalid remote name. --remote parameter missing.");
195 std::string local_stream =
local;
196 local_stream +=
"/data:i";
197 std::string local_rpc =
local;
198 local_rpc +=
"/rpc:o";
199 std::string remote_stream =
remote;
200 remote_stream +=
"/data:o";
201 std::string remote_rpc =
remote;
202 remote_rpc +=
"/rpc:i";
206 yCError(BATTERYCLIENT,
"open(): Could not open port %s, check network", local_stream.c_str());
213 yCError(BATTERYCLIENT,
"open(): Could not open rpc port %s, check network", local_rpc.c_str());
217 bool ok=Network::connect(remote_stream.c_str(), local_stream.c_str(),
m_carrier);
220 yCError(BATTERYCLIENT,
"open(): Could not connect %s -> %s", remote_stream.c_str(), local_stream.c_str());
224 ok=Network::connect(local_rpc, remote_rpc);
227 yCError(BATTERYCLIENT,
"open() Could not connect %s -> %s", remote_rpc.c_str(), local_rpc.c_str());
277 if (CHECK_FAIL(ok, response)!=
false)
const int BATTERY_TIMEOUT
constexpr yarp::conf::vocab32_t VOCAB_IBATTERY
constexpr yarp::conf::vocab32_t VOCAB_BATTERY_INFO
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getBatteryCurrent(double ¤t) override
Get the instantaneous current measurement.
bool close() override
Close the DeviceDriver.
bool getBatteryTemperature(double &temperature) override
get the battery temperature
yarp::os::Stamp getLastInputStamp() override
Get the time stamp for the last read data.
bool getBatteryVoltage(double &voltage) override
Get the instantaneous voltage measurement.
bool getBatteryInfo(std::string &battery_info) override
get the battery hardware charactestics (e.g.
bool getBatteryStatus(Battery_status &status) override
get the battery status
bool getBatteryCharge(double &charge) override
get the battery status of charge
BatteryInputPortProcessor inputPort
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.
Value & get(size_type index) const
Reads a Value v from a certain part 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 std::string toString() const =0
Return a standard text representation of the content of the object.
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 yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
#define yCError(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.