24 #include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_IceGridViewer.h>
30 #include <ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ui_IceGridNodeView.h>
33 #include <Ice/ObjectAdapter.h>
42 ADAPTER_NAME(
"IceGridNodeObserverGui")
46 qRegisterMetaType<QVector<int>>(
"QVector<int>");
47 qRegisterMetaType<IceGrid::ServerDynamicInfo>(
"IceGrid::ServerDynamicInfo");
48 connect(ui->gridNodeSelector, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
selectGridNode(
int)));
50 Ui::IceGridNodeView* content =
new Ui::IceGridNodeView();
51 content->setupUi(ui->contentWidget);
53 content->NodeInfo->setModel(nodeInfoModel);
55 content->ServerInfo->setModel(serverInfoModel);
57 content->AdapterInfo->setModel(adapterInfoModel);
61 selectorModel =
new QStringListModel;
62 ui->gridNodeSelector->setModel(selectorModel);
89 iceGridAdmin->removeObservers();
95 IceGrid::AdminSessionPrx adminSession = iceGridAdmin->adminSession();
98 Ice::ObjectPrx objectProxy = iceGridAdmin->registerObjectWithNewAdapter(observer, ADAPTER_NAME, observerAdapter);
99 IceGrid::NodeObserverPrx nodeObserver = IceGrid::NodeObserverPrx::checkedCast(objectProxy);
101 adminSession->setObservers(NULL, NULL, NULL, NULL, NULL);
102 adminSession->setObservers(NULL,
112 iceGridAdmin->stop();
114 iceGridAdmin->adminSession()->setObservers(NULL, NULL, NULL, NULL, NULL);
116 observerAdapter->destroy();
122 QString lastSelectionText = ui->gridNodeSelector->currentText();
124 std::unique_lock guard(gridNodeListMutex);
125 gridNodeList = nodeSeq;
126 QStringList nodeNames;
128 for (
size_t i = 0; i < gridNodeList.size(); ++i)
130 nodeNames.append(QString::fromStdString(gridNodeList[i].info.name));
133 selectorModel->setStringList(nodeNames);
136 int index = ui->gridNodeSelector->findText(lastSelectionText);
139 ui->gridNodeSelector->setCurrentIndex(
index);
146 std::unique_lock guard(gridNodeListMutex);
147 QStringList currentEntries = selectorModel->stringList();
148 currentEntries.append(QString::fromStdString(node.info.name));
149 gridNodeList.push_back(node);
150 selectorModel->setStringList(currentEntries);
156 QString lastSelectionText = ui->gridNodeSelector->currentText();
158 std::unique_lock guard(gridNodeListMutex);
160 QStringList currentEntries = selectorModel->stringList();
161 currentEntries.removeOne(node);
163 for (IceGrid::NodeDynamicInfoSeq::iterator nodeInfo = gridNodeList.begin(); nodeInfo != gridNodeList.end(); nodeInfo++)
165 if (nodeInfo->info.name == node.toStdString())
167 nodeInfo = gridNodeList.erase(nodeInfo);
171 selectorModel->setStringList(currentEntries);
174 int index = std::max<int>(0, ui->gridNodeSelector->findText(lastSelectionText));
175 ui->gridNodeSelector->setCurrentIndex(
index);
183 std::unique_lock guard(gridNodeListMutex);
184 IceGrid::NodeDynamicInfoSeq::iterator nodeEntry =
185 std::find_if(gridNodeList.begin(), gridNodeList.end(), [nodeName](IceGrid::NodeDynamicInfo nodeInfo)
187 return nodeName == nodeInfo.info.name;
190 if (nodeEntry == gridNodeList.end())
195 IceGrid::ServerDynamicInfoSeq::iterator serverEntry =
196 std::find_if(nodeEntry->servers.begin(), nodeEntry->servers.end(), [serverUpdateInfo](IceGrid::ServerDynamicInfo serverInfo)
198 return serverUpdateInfo.id == serverInfo.id;
201 if (serverEntry == nodeEntry->servers.end())
203 nodeEntry->servers.push_back(serverUpdateInfo);
207 if (serverUpdateInfo.pid == 0)
209 nodeEntry->servers.erase(serverEntry);
213 (*serverEntry) = serverUpdateInfo;
225 std::unique_lock guard(gridNodeListMutex);
226 IceGrid::NodeDynamicInfoSeq::iterator nodeEntry =
227 std::find_if(gridNodeList.begin(), gridNodeList.end(), [nodeName](IceGrid::NodeDynamicInfo nodeInfo)
229 return nodeName == nodeInfo.info.name;
232 if (nodeEntry == gridNodeList.end())
237 IceGrid::AdapterDynamicInfoSeq::iterator adapterEntry =
238 std::find_if(nodeEntry->adapters.begin(), nodeEntry->adapters.end(), [adapterUpdateInfo](IceGrid::AdapterDynamicInfo adapterInfo)
240 return adapterUpdateInfo.id == adapterInfo.id;
243 if (adapterEntry == nodeEntry->adapters.end())
245 nodeEntry->adapters.push_back(adapterUpdateInfo);
249 if (!adapterUpdateInfo.proxy)
251 nodeEntry->adapters.erase(adapterEntry);
255 (*adapterEntry) = adapterUpdateInfo;
266 iceGridAdmin->getAdmin()->enableServer(serverInfo.id, serverInfo.enabled);
272 if (
index >= (
int)gridNodeList.size() ||
index < 0)
277 std::unique_lock guard(gridNodeListMutex);
280 adapterInfoModel->
setData(gridNodeList[
index].adapters);