60 double tmpDT=
now-prev;
83 getEnvelope(newStamp);
86 if (lastStamp.isValid()==
false)
100 lastStamp = newStamp;
122 double voltage = lastBottle.get(0).asFloat64();
130 double current = lastBottle.get(1).asFloat64();
138 double charge = lastBottle.get(2).asFloat64();
146 int status = lastBottle.get(4).asInt32();
154 double temperature = lastBottle.get(3).asFloat64();
196 yCError(BATTERYCLIENT,
"open(): Invalid local name. --local parameter missing.");
201 yCError(BATTERYCLIENT,
"open(): Invalid remote name. --remote parameter missing.");
205 std::string local_stream = local;
206 local_stream +=
"/data:i";
207 std::string local_rpc = local;
208 local_rpc +=
"/rpc:o";
209 std::string remote_stream = remote;
210 remote_stream +=
"/data:o";
211 std::string remote_rpc = remote;
212 remote_rpc +=
"/rpc:i";
214 if (!inputPort.open(local_stream))
216 yCError(BATTERYCLIENT,
"open(): Could not open port %s, check network", local_stream.c_str());
219 inputPort.useCallback();
221 if (!rpcPort.open(local_rpc))
223 yCError(BATTERYCLIENT,
"open(): Could not open rpc port %s, check network", local_rpc.c_str());
227 bool ok=Network::connect(remote_stream.c_str(), local_stream.c_str(),
"udp");
230 yCError(BATTERYCLIENT,
"open(): Could not connect %s -> %s", remote_stream.c_str(), local_stream.c_str());
234 ok=Network::connect(local_rpc, remote_rpc);
237 yCError(BATTERYCLIENT,
"open() Could not connect %s -> %s", remote_rpc.c_str(), local_rpc.c_str());
253 voltage = inputPort.getVoltage();
259 current = inputPort.getCurrent();
265 charge = inputPort.getCharge();
277 temperature = inputPort.getTemperature();
286 bool ok = rpcPort.write(cmd, response);
287 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 addVocab(int 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.