33#include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_ThreadViewer.h>
42 periodicTaskModel(0), runningTaskModel(0), ui(new
Ui::
ThreadViewer)
49 ui->threadListView->setModel(periodicTaskModel);
50 ui->threadListView->setItemDelegateForColumn(3,
55 ui->threadListView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
59 ui->runningTaskView->setModel(runningTaskModel);
60 ui->runningTaskView->setItemDelegateForColumn(
63 ui->runningTaskView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
67 ui->threadListView->setFont(font);
68 ui->runningTaskView->setFont(font);
75 connect(ui->cbThreadListManager,
76 SIGNAL(currentIndexChanged(QString)),
92 restoredSelection = settings->value(
"ThreadViewer/selectedManager").toString();
98 settings->setValue(
"ThreadViewer/selectedManager", ui->cbThreadListManager->currentText());
113 periodicTask->start();
121 periodicTask->stop();
124 if (managerUpdateTask)
126 managerUpdateTask->stop();
133 if (managerUpdateTask && managerUpdateTask->isRunning())
138 ui->btnRefresh->setEnabled(
false);
139 ui->btnRefresh->setToolTip(
"Refreshing manager list...please wait");
142 managerUpdateTask->start();
148 std::vector<std::string> managerList;
149 QStringList qManagerList;
155 ->getIceGridSession()
156 ->getRegisteredObjectNames<ThreadListInterfacePrx>(
"*ThreadList");
158 for (
unsigned int i = 0; i < managerList.size(); ++i)
160 qManagerList << QString::fromStdString(managerList.at(i));
178 const QString lastSelectionText = ui->cbThreadListManager->currentText();
179 ui->cbThreadListManager->clear();
180 ui->cbThreadListManager->addItems(list);
187 if (!restoredSelection.isEmpty())
189 index = ui->cbThreadListManager->findText(restoredSelection);
192 restoredSelection.clear();
197 index = ui->cbThreadListManager->findText(lastSelectionText);
204 ui->cbThreadListManager->setCurrentIndex(
index);
207 ui->btnRefresh->setEnabled(
true);
208 ui->btnRefresh->setToolTip(
"Refresh the thread manager list");
214 if (selectedString.size() == 0)
224 std::unique_lock lock(proxyMutex);
225 threadManagerProxy = proxy;
227 ARMARX_VERBOSE <<
"new proxy for ThreadViewerModel set: " << selectedString;
234 ui->cpuUsageProgressBar->setValue(value);
238 ThreadViewer::runThreadManagerUpdate()
243 ThreadListInterfacePrx proxy;
245 std::unique_lock lock(proxyMutex);
246 proxy = threadManagerProxy;
256 PeriodicTaskList periodicTaskList = proxy->getPeriodicTasks();
257 RunningTaskList runningTaskList = proxy->getRunningTasks();
258 Ice::Double cpuProcTotalTime = proxy->getCpuUsage();
259 int value =
static_cast<int>(cpuProcTotalTime);
267 [
this, periodicTaskList, runningTaskList]()
269 periodicTaskModel->setPeriodicTaskListData(periodicTaskList);
270 runningTaskModel->setRunningTaskListData(runningTaskList);
IceManagerPtr getIceManager() const
Returns the IceManager.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
void onInitComponent() override
void managedSelectionChanged(QString selectedString)
void loadSettings(QSettings *settings) override
Load stored manager models.
void saveSettings(QSettings *settings) override
Saves the manager models.
void updateThreadManagerList(QStringList list)
void cpuUsageValueUpdated(int value)
void triggerThreadManagerListUpdate()
void retrieveThreadManagerList()
void onConnectComponent() override
void threadManagerListUpdated(QStringList list)
void onExitComponent() override
Hook for subclass.
void cpuUsageValueSet(int value)
#define ARMARX_VERBOSE
The logging level for verbose information.
This file offers overloads of toIce() and fromIce() functions for STL container types.
void postToObject(QObject *context, Function &&function)
Run function on the GUI (main) thread's event loop.
std::shared_ptr< Value > value()