From 9ccac5dcad84ab8c8c89dfd8725d9113471b803d Mon Sep 17 00:00:00 2001 From: Guillaume Sarthou Date: Wed, 6 Dec 2023 14:01:21 +0100 Subject: [PATCH] [ontoloGUI] use feeder callback for notifications --- .../ontologenius/graphical/ontoloGUI/ontologui.h | 2 +- src/graphical/ontoloGUI/ontologui.cpp | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/ontologenius/graphical/ontoloGUI/ontologui.h b/include/ontologenius/graphical/ontoloGUI/ontologui.h index d37128be..466b385d 100644 --- a/include/ontologenius/graphical/ontoloGUI/ontologui.h +++ b/include/ontologenius/graphical/ontoloGUI/ontologui.h @@ -82,7 +82,7 @@ public slots: void OntologyNameAddDelChangedSlot(const QString&); void OntologyNameChangedSlot(const QString&); - void feederCallback(const std_msgs::String& msg); + void feederCallback(const std::string& msg); void feederAddSlot(); void feederDelSlot(); void feederCommitSlot(); diff --git a/src/graphical/ontoloGUI/ontologui.cpp b/src/graphical/ontoloGUI/ontologui.cpp index c6a0cb45..c8937fe5 100644 --- a/src/graphical/ontoloGUI/ontologui.cpp +++ b/src/graphical/ontoloGUI/ontologui.cpp @@ -256,6 +256,7 @@ void ontoloGUI::init() if(ontos_.waitInit(1000) == false) { onto_ = new onto::OntologyManipulator(); + onto_->feeder.registerNotificationCallback([this](auto msg){ this->feederCallback(msg); }); multi_usage_ = false; } else @@ -263,8 +264,6 @@ void ontoloGUI::init() onto_ == nullptr; multi_usage_ = true; } - - //feeder_notifications_subs_["_"] = n_->subscribe("ontologenius/feeder_notifications", QUEU_SIZE, &ontoloGUI::feederCallback, this); } void ontoloGUI::wait() @@ -275,7 +274,6 @@ void ontoloGUI::wait() "" "

Wainting for ontologenius

"; ui->InfoArea->setHtml(html); - //ros::service::waitForService("ontologenius/reasoner", -1); } void ontoloGUI::start() @@ -713,13 +711,17 @@ void ontoloGUI::currentTabChangedSlot(int index) void ontoloGUI::addOntologySlot() { std::string param = ui->OntologyNameAddDel->text().toStdString(); + std::string onto_name = param; std::regex base_regex("(.*)=(.*)"); std::smatch base_match; if (std::regex_match(param, base_match, base_regex)) { if (base_match.size() == 3) + { ontos_.copy(base_match[1].str(), base_match[2].str()); + onto_name = base_match[1].str(); + } } else ontos_.add(param); @@ -735,7 +737,11 @@ void ontoloGUI::addOntologySlot() else if(err == 1) ui->ResultArea->setText(QString::fromStdString("fail to stop " + param + " : please retry")); else + { ui->ResultArea->setText(QString::fromStdString("")); + ontos_.get(onto_name)->feeder.registerNotificationCallback([this](auto msg){ this->feederCallback(msg); }); + } + displayOntologiesList(); } } @@ -831,9 +837,9 @@ void ontoloGUI::OntologyNameChangedSlot(const QString& text) ui->OntologyNameAddDel->setText(text); } -void ontoloGUI::feederCallback(const std_msgs::String& msg) +void ontoloGUI::feederCallback(const std::string& msg) { - feeder_notifications_ += "

-" + msg.data + "

"; + feeder_notifications_ += "

-" + msg + "

"; std::string html = "" "