Skip to content

Commit

Permalink
[ontoloGUI] use feeder callback for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Dec 6, 2023
1 parent 0c1e22e commit 9ccac5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/ontologenius/graphical/ontoloGUI/ontologui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 11 additions & 5 deletions src/graphical/ontoloGUI/ontologui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,14 @@ 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
{
onto_ == nullptr;
multi_usage_ = true;
}

//feeder_notifications_subs_["_"] = n_->subscribe("ontologenius/feeder_notifications", QUEU_SIZE, &ontoloGUI::feederCallback, this);
}

void ontoloGUI::wait()
Expand All @@ -275,7 +274,6 @@ void ontoloGUI::wait()
"</style></head><body style=\" font-family:'Noto Sans'; font-size:9pt; font-weight:400; font-style:normal;\">"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt; color:#a40000;\">Wainting for </span><span style=\" font-size:12pt; font-weight:600; color:#a40000;\">ontologenius</span></p></body></html>";
ui->InfoArea->setHtml(html);
//ros::service::waitForService("ontologenius/reasoner", -1);
}

void ontoloGUI::start()
Expand Down Expand Up @@ -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);
Expand All @@ -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();
}
}
Expand Down Expand Up @@ -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_ += "<p>-" + msg.data + "</p>";
feeder_notifications_ += "<p>-" + msg + "</p>";

std::string html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">"
Expand Down

0 comments on commit 9ccac5d

Please sign in to comment.