35#include <QDoubleSpinBox>
47 std::shared_ptr<armem::gui::model::MemoryViewerModel>
model)
49 _model = std::move(
model);
51 _memoryGroupBoxController = std::make_unique<MemoryGroupBoxController>(
59 connect(_periodicUpdateView,
64 if (_model->connected()) {
65 _periodicUpdateView->showUpdatingLabel();
70 connect(_periodicUpdateView,
75 connect(_periodicUpdateView,
80 connect(_periodicUpdateView,
85 connect(_periodicUpdateView,
90 connect(_memoryGroupBoxController->memoryGroupBoxView(),
95 _periodicUpdateView->toggleSplitButton();
104 if (_periodicUpdateWorkerThread)
106 _periodicUpdateWorkerThread->quit();
107 _periodicUpdateWorkerThread->wait();
111 void PeriodicUpdateController::startWorker()
113 _periodicUpdateWorkerThread =
new QThread();
115 _periodicUpdateWorker->moveToThread(_periodicUpdateWorkerThread);
117 connect(_periodicUpdateWorkerThread,
119 _periodicUpdateWorker,
122 connect(_periodicUpdateWorkerThread,
124 _periodicUpdateWorker,
127 connect(_periodicUpdateWorkerThread,
129 _periodicUpdateWorker,
130 &QObject::deleteLater);
132 connect(_periodicUpdateWorkerThread,
134 _periodicUpdateWorkerThread,
135 &QObject::deleteLater);
137 connect(_periodicUpdateWorker,
142 connect(_periodicUpdateWorker,
146 if (_model->connected()) {
151 connect(_periodicUpdateWorker,
158 _periodicUpdateWorker,
163 _periodicUpdateWorker,
168 _periodicUpdateWorker,
173 _periodicUpdateWorker,
178 _periodicUpdateWorker,
181 connect(_periodicUpdateWorkerThread,
188 _periodicUpdateWorker,
191 _periodicUpdateWorkerThread->start();
202 if (_periodicUpdateView->autoCheckBox()->isChecked())
210 _memoryGroupBoxController->memoryGroupBoxView()->tree()->collapseAll();
215 _periodicUpdateView->toggleSplitButton();
216 _memoryGroupBoxController->memoryGroupBoxView()->splitBox();
226 _periodicUpdateView->frequencySpinBox()->setEnabled(enabled);
240 updateStatusLabel(errorCount);
241 _memoryGroupBoxController->updateMemoryTree();
243 _periodicUpdateView->hideUpdatingLabel();
247 PeriodicUpdateController::updateStatusLabel(
int errorCount)
250 if (_statusLabel and errorCount > 0)
252 auto now = std::chrono::system_clock::now();
253 auto in_time_t = std::chrono::system_clock::to_time_t(now);
255 std::stringstream ss;
256 ss <<
"Last update: " << std::put_time(std::localtime(&in_time_t),
"%Y-%m-%d %X");
257 ss <<
"\nThe query produced " << errorCount <<
" errors! Please check log.";
259 _statusLabel->setText(QString::fromStdString(ss.str()));
266 std::vector<std::string> activeMemoryNamesVec;
267 activeMemoryNamesVec.reserve(activeMemoryNames.size());
268 for (
const QString& s : activeMemoryNames) {
269 activeMemoryNamesVec.push_back(s.toStdString());
273 _memoryGroupBoxController
274 ->memoryGroupBoxView()
276 ->update(activeMemoryNamesVec);
278 _memoryGroupBoxController
279 ->memoryGroupBoxView()
281 ->update(activeMemoryNamesVec);
287 return _memoryGroupBoxController.get();
controlls predictions, commits, LTM recording/storing
void autoUpdateTimerIntervalSignal(int freq)
void updateStatusLabelAndMemoryTree(int errorCount)
void stopAutoUpdateTimerSignal()
void onTimerFrequencyChanged()
void startPeriodicTimerSignal()
~PeriodicUpdateController()
MemoryGroupBoxController * memoryGroupBoxController() const
void stopPeriodicTimerSignal()
void updateListOfActiveMemories(QStringList activeMemoryNames)
void onToggleAutoUpdates(bool enabled)
void startAutoUpdateTimerSignal()
void startAutoUpdateTimerIfEnabled()
PeriodicUpdateController(MemoryViewerUIContext &uiContext, std::shared_ptr< armem::gui::model::MemoryViewerModel > model)
handles updating and periodically checks for new readers/writers and query results
void startPeriodicTimer()
void updateLabelAndTree(int errorCount)
void setAutoUpdateTimerInterval(int freq)
void updateQueryWidget(QStringList activeMemoryNames)
void stopAutoUpdateTimer()
void startAutoUpdateTimer()
void timerFrequencyChanged()
void toggleAutoUpdates(bool enabled)
#define ARMARX_VERBOSE
The logging level for verbose information.
#define TIMING_START(name)
Helper macro to do timing tests.
#define TIMING_END_STREAM(name, os)
Prints duration.
QBoxLayout * periodicUpdateViewLayout