47 double tmpDT=
now-prev;
49 if (tmpDT > deltaTMax) {
52 if (tmpDT < deltaTMin) {
72 getEnvelope(newStamp);
75 if (lastStamp.isValid()==
false)
111 double voltage = lastBottle.get(0).asFloat64();
119 double current = lastBottle.get(1).asFloat64();
127 double charge = lastBottle.get(2).asFloat64();
135 int status = lastBottle.get(4).asInt32();
143 double temperature = lastBottle.get(3).asFloat64();
185 yCError(BATTERYCLIENT,
"open(): Invalid local name. --local parameter missing.");
190 yCError(BATTERYCLIENT,
"open(): Invalid remote name. --remote parameter missing.");
194 std::string local_stream = local;
195 local_stream +=
"/data:i";
196 std::string local_rpc = local;
197 local_rpc +=
"/rpc:o";
198 std::string remote_stream = remote;
199 remote_stream +=
"/data:o";
200 std::string remote_rpc = remote;
201 remote_rpc +=
"/rpc:i";
203 if (!inputPort.open(local_stream))
205 yCError(BATTERYCLIENT,
"open(): Could not open port %s, check network", local_stream.c_str());
208 inputPort.useCallback();
210 if (!rpcPort.open(local_rpc))
212 yCError(BATTERYCLIENT,
"open(): Could not open rpc port %s, check network", local_rpc.c_str());
216 bool ok=Network::connect(remote_stream.c_str(), local_stream.c_str(),
"udp");
219 yCError(BATTERYCLIENT,
"open(): Could not connect %s -> %s", remote_stream.c_str(), local_stream.c_str());
223 ok=Network::connect(local_rpc, remote_rpc);
226 yCError(BATTERYCLIENT,
"open() Could not connect %s -> %s", remote_rpc.c_str(), local_rpc.c_str());
242 voltage = inputPort.getVoltage();
248 current = inputPort.getCurrent();
254 charge = inputPort.getCharge();
266 temperature = inputPort.getTemperature();
275 bool ok = rpcPort.write(cmd, response);
276 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
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.
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 std::string toString() const =0
Return a standard text representation of the content of the object.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
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,...)
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.