Skip to content
Snippets Groups Projects
Commit 5f371f0b authored by Peter Albrecht's avatar Peter Albrecht
Browse files

feature: stop all button

parent 73fc3e36
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
Pipeline #16855 failed
...@@ -174,6 +174,8 @@ namespace armarx ...@@ -174,6 +174,8 @@ namespace armarx
widget.skillDescription, widget.skillDescription,
widget.skillDescription->parentWidget()->layout(), widget.skillDescription->parentWidget()->layout(),
widget.stopAllLayout,
this->mem_wrapper); this->mem_wrapper);
connectSignals(); connectSignals();
......
...@@ -15,6 +15,8 @@ namespace armarx::skills::gui ...@@ -15,6 +15,8 @@ namespace armarx::skills::gui
QWidget* skillDescription, QWidget* skillDescription,
QLayout* skillDescriptionParentLayout, QLayout* skillDescriptionParentLayout,
QLayout* stopAllLayout,
std::shared_ptr<SkillManagerWrapper> _memory) std::shared_ptr<SkillManagerWrapper> _memory)
{ {
Logging::setTag("SkillMemoryGui"); Logging::setTag("SkillMemoryGui");
...@@ -58,6 +60,11 @@ namespace armarx::skills::gui ...@@ -58,6 +60,11 @@ namespace armarx::skills::gui
_skillGroupBoxParentLayout->insertWidget(0, this->skillDetailGroupBox); _skillGroupBoxParentLayout->insertWidget(0, this->skillDetailGroupBox);
_skillGroupBoxParentLayout->insertWidget(0, this->skillGroupBox); _skillGroupBoxParentLayout->insertWidget(0, this->skillGroupBox);
// setup stop all button
stopAllButton = new QPushButton(QString::fromStdString(STOP_ALL_BUTTON_TEXT));
stopAllButton->setStyleSheet("background-color: red");
stopAllLayout->addWidget(stopAllButton);
setupUi(); setupUi();
} }
...@@ -107,5 +114,11 @@ namespace armarx::skills::gui ...@@ -107,5 +114,11 @@ namespace armarx::skills::gui
// timer -> update // timer -> update
connect( connect(
this->updateWidget, &PeriodicUpdateWidget::update, this, &SkillMemoryGUI::updateGui); this->updateWidget, &PeriodicUpdateWidget::update, this, &SkillMemoryGUI::updateGui);
// stop all
connect(stopAllButton,
&QPushButton::clicked,
memory.get(),
&SkillManagerWrapper::stopAllExecutions);
} }
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
...@@ -22,6 +22,7 @@ namespace armarx::skills::gui ...@@ -22,6 +22,7 @@ namespace armarx::skills::gui
Q_OBJECT Q_OBJECT
public: public:
static const constexpr char* STOP_ALL_BUTTON_TEXT = "Stop all executions";
SkillMemoryGUI(QTreeWidget* _skillExecutionTreeWidget, SkillMemoryGUI(QTreeWidget* _skillExecutionTreeWidget,
QLayout* _skillExecutionTreeWidgetParentLayout, QLayout* _skillExecutionTreeWidgetParentLayout,
QGroupBox* _skillGroupBox, QGroupBox* _skillGroupBox,
...@@ -33,6 +34,8 @@ namespace armarx::skills::gui ...@@ -33,6 +34,8 @@ namespace armarx::skills::gui
QWidget* skillDescription, QWidget* skillDescription,
QLayout* skillDescriptionParentLayout, QLayout* skillDescriptionParentLayout,
QLayout* stopAllLayout,
std::shared_ptr<SkillManagerWrapper> _memory); std::shared_ptr<SkillManagerWrapper> _memory);
signals: signals:
...@@ -65,7 +68,7 @@ namespace armarx::skills::gui ...@@ -65,7 +68,7 @@ namespace armarx::skills::gui
PeriodicUpdateWidget* updateWidget = nullptr; PeriodicUpdateWidget* updateWidget = nullptr;
SkillDescriptionWidget* skillDescriptionWidget = nullptr; QPushButton* stopAllButton = nullptr;
}; };
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
......
...@@ -122,22 +122,6 @@ namespace armarx::skills::gui ...@@ -122,22 +122,6 @@ namespace armarx::skills::gui
return selectedExecution.skillExecutionId.skillId.skillName != skills::SkillID::UNKNOWN; return selectedExecution.skillExecutionId.skillId.skillName != skills::SkillID::UNKNOWN;
} }
void
SkillExecutionTreeWidget::stopAllExecutions()
{
for (ssize_t i = 0; i < this->topLevelItemCount(); ++i)
{
auto item = dynamic_cast<SkillExecutionTreeWidgetItem*>(this->topLevelItem(i));
if (!item)
{
continue;
}
memory->stopExecution(item->getExecutionId());
}
}
void void
SkillExecutionTreeWidget::executionSelectionChanged(QTreeWidgetItem* current, SkillExecutionTreeWidget::executionSelectionChanged(QTreeWidgetItem* current,
QTreeWidgetItem* previous) QTreeWidgetItem* previous)
......
...@@ -53,7 +53,6 @@ namespace armarx::skills::gui ...@@ -53,7 +53,6 @@ namespace armarx::skills::gui
void updateExecutions(); void updateExecutions();
private slots: private slots:
void stopAllExecutions();
void executionSelectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); void executionSelectionChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
void runContextMenu(const QPoint& pos); void runContextMenu(const QPoint& pos);
void stopSelectedExecution(); void stopSelectedExecution();
......
...@@ -163,6 +163,22 @@ namespace armarx::skills::gui ...@@ -163,6 +163,22 @@ namespace armarx::skills::gui
this->currentSkillSearch = search; this->currentSkillSearch = search;
} }
void
SkillManagerWrapper::stopAllExecutions()
{
ARMARX_IMPORTANT << "Stopping all running executions.";
const auto& executions = this->fetchExecutions();
for (auto& [executionId, status] : executions)
{
// select all running executions...
if (!status.hasBeenTerminated())
{
// ... and kill them.
this->stopExecution(executionId, 3);
}
}
}
const std::optional<ProviderID> const std::optional<ProviderID>
SkillManagerWrapper::findFirstProvider(SkillMap const& map, SkillID const& skillId) SkillManagerWrapper::findFirstProvider(SkillMap const& map, SkillID const& skillId)
{ {
......
...@@ -79,6 +79,11 @@ namespace armarx::skills::gui ...@@ -79,6 +79,11 @@ namespace armarx::skills::gui
*/ */
void acceptSearchRequest(std::string const& search); void acceptSearchRequest(std::string const& search);
/**
* @brief Stops all available (and running) executions.
*/
void stopAllExecutions();
private: private:
mutable std::mutex mutex_memory; mutable std::mutex mutex_memory;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment