PeriodicUpdateWorker.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2025, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package RobotStateComponent::
19 * @author Samet Soenmez (uewtt at student dot kit dot edu)
20 * @date 2025t
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <QObject>
28
30
31class QTimer;
32
34{
35 /**
36 * @brief handles updating and periodically checks for new readers/writers and query results
37 *
38 * this worker handles two main tasks: 1. periodically check for new readers/writers and
39 * query results. 2. starting new queries either through incomming signals or periodically
40 * after starting Auto Update
41 */
42 class PeriodicUpdateWorker : public QObject, public armarx::Logging
43 {
44 Q_OBJECT
45 using This = PeriodicUpdateWorker;
46
47 public:
49 std::shared_ptr<armem::gui::model::MemoryViewerModel> model);
50
51 public slots:
52 void init();
53 void cleanup();
54
55 void startPeriodicTimer();
56 void stopPeriodicTimer();
59 void setAutoUpdateTimerInterval(int freq);
60
61 void onUpdate();
62
63 private slots:
64 void onPeriodicTimerTimeout();
65
66 signals:
67 void updateQueryWidget(QStringList activeMemoryNames);
68 void updateLabelAndTree(int errorCount);
70
71 private:
72 void startDueQueries();
73 void updateMemoryReadersWriters();
74 void processQueryResults();
75 void updateStatusLabel(int errorCount);
76 std::map<std::string, client::QueryResult> collectQueryResults();
77 void applyQueryResults(const std::map<std::string, client::QueryResult>& results,
78 int* outErrorCount = nullptr);
79
80 private:
81 std::shared_ptr<armem::gui::model::MemoryViewerModel> _model;
82
83 // Periodically triggers query result collection and updates the available memories
84 QTimer* _periodicTimer;
85 QTimer* _autoUpdateTimer;
86
87 std::map<std::string, std::future<armem::query::data::Result>> _runningQueries;
88 std::vector<std::string> _activeMemoryNames;
89 bool _updateLabelAndTree = false;
90 };
91}
Base Class for all Logging classes.
Definition Logging.h:240
PeriodicUpdateWorker(std::shared_ptr< armem::gui::model::MemoryViewerModel > model)
void updateQueryWidget(QStringList activeMemoryNames)