37 if (!writer.
writeTag(
"setBatteryVoltage", 1, 1)) {
74 if (!writer.
writeTag(
"setBatteryCurrent", 1, 1)) {
111 if (!writer.
writeTag(
"setBatteryCharge", 1, 1)) {
148 if (!writer.
writeTag(
"setBatteryInfo", 1, 1)) {
175 m_temperature{temperature}
185 if (!writer.
writeTag(
"setBatteryTemperature", 1, 1)) {
224 if (!writer.
writeTag(
"getBatteryVoltage", 1, 1)) {
267 if (!writer.
writeTag(
"getBatteryCurrent", 1, 1)) {
310 if (!writer.
writeTag(
"getBatteryCharge", 1, 1)) {
353 if (!writer.
writeTag(
"getBatteryStatus", 1, 1)) {
396 if (!writer.
writeTag(
"getBatteryInfo", 1, 1)) {
439 if (!writer.
writeTag(
"getBatteryTemperature", 1, 1)) {
467 if (!
yarp().canWrite()) {
468 yError(
"Missing server method '%s'?",
"void FakeBatteryService::setBatteryVoltage(const double voltage)");
476 if (!
yarp().canWrite()) {
477 yError(
"Missing server method '%s'?",
"void FakeBatteryService::setBatteryCurrent(const double current)");
485 if (!
yarp().canWrite()) {
486 yError(
"Missing server method '%s'?",
"void FakeBatteryService::setBatteryCharge(const double charge)");
494 if (!
yarp().canWrite()) {
495 yError(
"Missing server method '%s'?",
"void FakeBatteryService::setBatteryInfo(const std::string& info)");
503 if (!
yarp().canWrite()) {
504 yError(
"Missing server method '%s'?",
"void FakeBatteryService::setBatteryTemperature(const double temperature)");
512 if (!
yarp().canWrite()) {
513 yError(
"Missing server method '%s'?",
"double FakeBatteryService::getBatteryVoltage()");
522 if (!
yarp().canWrite()) {
523 yError(
"Missing server method '%s'?",
"double FakeBatteryService::getBatteryCurrent()");
532 if (!
yarp().canWrite()) {
533 yError(
"Missing server method '%s'?",
"double FakeBatteryService::getBatteryCharge()");
542 if (!
yarp().canWrite()) {
543 yError(
"Missing server method '%s'?",
"std::string FakeBatteryService::getBatteryStatus()");
552 if (!
yarp().canWrite()) {
553 yError(
"Missing server method '%s'?",
"std::string FakeBatteryService::getBatteryInfo()");
562 if (!
yarp().canWrite()) {
563 yError(
"Missing server method '%s'?",
"double FakeBatteryService::getBatteryTemperature()");
572 bool showAll = (functionName ==
"--all");
573 std::vector<std::string> helpString;
575 helpString.emplace_back(
"*** Available commands:");
576 helpString.emplace_back(
"setBatteryVoltage");
577 helpString.emplace_back(
"setBatteryCurrent");
578 helpString.emplace_back(
"setBatteryCharge");
579 helpString.emplace_back(
"setBatteryInfo");
580 helpString.emplace_back(
"setBatteryTemperature");
581 helpString.emplace_back(
"getBatteryVoltage");
582 helpString.emplace_back(
"getBatteryCurrent");
583 helpString.emplace_back(
"getBatteryCharge");
584 helpString.emplace_back(
"getBatteryStatus");
585 helpString.emplace_back(
"getBatteryInfo");
586 helpString.emplace_back(
"getBatteryTemperature");
587 helpString.emplace_back(
"help");
589 if (functionName ==
"setBatteryVoltage") {
590 helpString.emplace_back(
"void setBatteryVoltage(const double voltage) ");
592 if (functionName ==
"setBatteryCurrent") {
593 helpString.emplace_back(
"void setBatteryCurrent(const double current) ");
595 if (functionName ==
"setBatteryCharge") {
596 helpString.emplace_back(
"void setBatteryCharge(const double charge) ");
598 if (functionName ==
"setBatteryInfo") {
599 helpString.emplace_back(
"void setBatteryInfo(const std::string& info) ");
601 if (functionName ==
"setBatteryTemperature") {
602 helpString.emplace_back(
"void setBatteryTemperature(const double temperature) ");
604 if (functionName ==
"getBatteryVoltage") {
605 helpString.emplace_back(
"double getBatteryVoltage() ");
607 if (functionName ==
"getBatteryCurrent") {
608 helpString.emplace_back(
"double getBatteryCurrent() ");
610 if (functionName ==
"getBatteryCharge") {
611 helpString.emplace_back(
"double getBatteryCharge() ");
613 if (functionName ==
"getBatteryStatus") {
614 helpString.emplace_back(
"std::string getBatteryStatus() ");
616 if (functionName ==
"getBatteryInfo") {
617 helpString.emplace_back(
"std::string getBatteryInfo() ");
619 if (functionName ==
"getBatteryTemperature") {
620 helpString.emplace_back(
"double getBatteryTemperature() ");
622 if (functionName ==
"help") {
623 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
624 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
625 helpString.emplace_back(
"@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
626 helpString.emplace_back(
"@return list of strings (one string per line)");
629 if (helpString.empty()) {
630 helpString.emplace_back(
"Command not found");
645 std::string tag = reader.
readTag();
646 bool direct = (tag ==
"__direct__");
651 if (tag ==
"setBatteryVoltage") {
672 if (tag ==
"setBatteryCurrent") {
693 if (tag ==
"setBatteryCharge") {
714 if (tag ==
"setBatteryInfo") {
735 if (tag ==
"setBatteryTemperature") {
756 if (tag ==
"getBatteryVoltage") {
770 if (tag ==
"getBatteryCurrent") {
784 if (tag ==
"getBatteryCharge") {
798 if (tag ==
"getBatteryStatus") {
812 if (tag ==
"getBatteryInfo") {
826 if (tag ==
"getBatteryTemperature") {
841 std::string functionName;
843 functionName =
"--all";
845 auto help_strings =
help(functionName);
851 if (!writer.
writeTag(
"many", 1, 0)) {
857 for (
const auto& help_string : help_strings) {
873 std::string next_tag = reader.
readTag();
874 if (next_tag ==
"") {
877 tag.append(
"_").append(next_tag);
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
FakeBatteryService_getBatteryCharge_helper()
static thread_local double s_return_helper
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
FakeBatteryService_getBatteryCurrent_helper()
static thread_local double s_return_helper
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static thread_local std::string s_return_helper
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
FakeBatteryService_getBatteryInfo_helper()
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static thread_local std::string s_return_helper
FakeBatteryService_getBatteryStatus_helper()
FakeBatteryService_getBatteryTemperature_helper()
static thread_local double s_return_helper
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static thread_local double s_return_helper
FakeBatteryService_getBatteryVoltage_helper()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
FakeBatteryService_setBatteryCharge_helper(const double charge)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
FakeBatteryService_setBatteryCurrent_helper(const double current)
FakeBatteryService_setBatteryInfo_helper(const std::string &info)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
FakeBatteryService_setBatteryTemperature_helper(const double temperature)
FakeBatteryService_setBatteryVoltage_helper(const double voltage)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual std::string getBatteryInfo()
virtual double getBatteryVoltage()
virtual void setBatteryInfo(const std::string &info)
virtual void setBatteryTemperature(const double temperature)
virtual double getBatteryCharge()
virtual std::string getBatteryStatus()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual void setBatteryCharge(const double charge)
virtual void setBatteryVoltage(const double voltage)
virtual double getBatteryCurrent()
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual void setBatteryCurrent(const double current)
virtual double getBatteryTemperature()
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
bool write(PortWriter &writer)
Write a message to the associated port or reader.
bool callback(PortWriter &writer, PortReader &reader, const std::string &tag="")
Put a message in a stack to call later, asynchronously.
bool setOwner(yarp::os::PortReader &owner)
Set the owner of this WireLink.
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
IDL-friendly connection reader.
bool readString(std::string &str, bool *is_vocab=nullptr)
bool readFloat64(yarp::conf::float64_t &x)
IDL-friendly connection writer.
bool writeListHeader(int len) const
bool writeTag(const char *tag, int split, int len) const
bool writeListBegin(int tag, std::uint32_t len) const
bool writeFloat64(yarp::conf::float64_t x) const
bool writeOnewayResponse() const
bool writeListEnd() const
bool writeString(const std::string &tag) const