27 #include <Ice/ObjectAdapter.h>
31 #include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_IceGridNodeView.h>
32 #include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_IceGridViewer.h>
46 qRegisterMetaType<QVector<int>>(
"QVector<int>");
47 qRegisterMetaType<IceGrid::ServerDynamicInfo>(
"IceGrid::ServerDynamicInfo");
48 connect(ui->gridNodeSelector,
49 SIGNAL(currentIndexChanged(
int)),
53 Ui::IceGridNodeView* content =
new Ui::IceGridNodeView();
54 content->setupUi(ui->contentWidget);
56 content->NodeInfo->setModel(nodeInfoModel);
58 content->ServerInfo->setModel(serverInfoModel);
60 content->AdapterInfo->setModel(adapterInfoModel);
62 connect(serverInfoModel,
67 selectorModel =
new QStringListModel;
68 ui->gridNodeSelector->setModel(selectorModel);
94 iceGridAdmin->removeObservers();
100 IceGrid::AdminSessionPrx adminSession = iceGridAdmin->adminSession();
103 Ice::ObjectPrx objectProxy =
104 iceGridAdmin->registerObjectWithNewAdapter(observer, ADAPTER_NAME, observerAdapter);
105 IceGrid::NodeObserverPrx nodeObserver = IceGrid::NodeObserverPrx::checkedCast(objectProxy);
107 adminSession->setObservers(NULL, NULL, NULL, NULL, NULL);
108 adminSession->setObservers(NULL, nodeObserver, NULL, NULL, NULL);
115 iceGridAdmin->stop();
117 iceGridAdmin->adminSession()->setObservers(NULL, NULL, NULL, NULL, NULL);
119 observerAdapter->destroy();
125 QString lastSelectionText = ui->gridNodeSelector->currentText();
127 std::unique_lock guard(gridNodeListMutex);
128 gridNodeList = nodeSeq;
129 QStringList nodeNames;
131 for (
size_t i = 0; i < gridNodeList.size(); ++i)
133 nodeNames.append(QString::fromStdString(gridNodeList[i].info.name));
136 selectorModel->setStringList(nodeNames);
139 int index = ui->gridNodeSelector->findText(lastSelectionText);
142 ui->gridNodeSelector->setCurrentIndex(
index);
149 std::unique_lock guard(gridNodeListMutex);
150 QStringList currentEntries = selectorModel->stringList();
151 currentEntries.append(QString::fromStdString(node.info.name));
152 gridNodeList.push_back(node);
153 selectorModel->setStringList(currentEntries);
159 QString lastSelectionText = ui->gridNodeSelector->currentText();
161 std::unique_lock guard(gridNodeListMutex);
163 QStringList currentEntries = selectorModel->stringList();
164 currentEntries.removeOne(node);
166 for (IceGrid::NodeDynamicInfoSeq::iterator nodeInfo = gridNodeList.begin();
167 nodeInfo != gridNodeList.end();
170 if (nodeInfo->info.name == node.toStdString())
172 nodeInfo = gridNodeList.erase(nodeInfo);
176 selectorModel->setStringList(currentEntries);
178 int index = std::max<int>(0, ui->gridNodeSelector->findText(lastSelectionText));
179 ui->gridNodeSelector->setCurrentIndex(
index);
185 const IceGrid::ServerDynamicInfo& serverUpdateInfo)
188 std::unique_lock guard(gridNodeListMutex);
189 IceGrid::NodeDynamicInfoSeq::iterator nodeEntry =
190 std::find_if(gridNodeList.begin(),
192 [nodeName](IceGrid::NodeDynamicInfo nodeInfo)
193 { return nodeName == nodeInfo.info.name; });
195 if (nodeEntry == gridNodeList.end())
200 IceGrid::ServerDynamicInfoSeq::iterator serverEntry =
201 std::find_if(nodeEntry->servers.begin(),
202 nodeEntry->servers.end(),
203 [serverUpdateInfo](IceGrid::ServerDynamicInfo serverInfo)
204 { return serverUpdateInfo.id == serverInfo.id; });
206 if (serverEntry == nodeEntry->servers.end())
208 nodeEntry->servers.push_back(serverUpdateInfo);
212 if (serverUpdateInfo.pid == 0)
214 nodeEntry->servers.erase(serverEntry);
218 (*serverEntry) = serverUpdateInfo;
228 const IceGrid::AdapterDynamicInfo& adapterUpdateInfo)
231 std::unique_lock guard(gridNodeListMutex);
232 IceGrid::NodeDynamicInfoSeq::iterator nodeEntry =
233 std::find_if(gridNodeList.begin(),
235 [nodeName](IceGrid::NodeDynamicInfo nodeInfo)
236 { return nodeName == nodeInfo.info.name; });
238 if (nodeEntry == gridNodeList.end())
243 IceGrid::AdapterDynamicInfoSeq::iterator adapterEntry =
244 std::find_if(nodeEntry->adapters.begin(),
245 nodeEntry->adapters.end(),
246 [adapterUpdateInfo](IceGrid::AdapterDynamicInfo adapterInfo)
247 { return adapterUpdateInfo.id == adapterInfo.id; });
249 if (adapterEntry == nodeEntry->adapters.end())
251 nodeEntry->adapters.push_back(adapterUpdateInfo);
255 if (!adapterUpdateInfo.proxy)
257 nodeEntry->adapters.erase(adapterEntry);
261 (*adapterEntry) = adapterUpdateInfo;
272 iceGridAdmin->getAdmin()->enableServer(serverInfo.id, serverInfo.enabled);
278 if (
index >= (
int)gridNodeList.size() ||
index < 0)
283 std::unique_lock guard(gridNodeListMutex);
286 adapterInfoModel->
setData(gridNodeList[
index].adapters);