1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "JM_SalomeResource.hxx"
21 #include "BL_Traces.hxx"
23 JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_services,
24 const std::string & resource_name) : QDialog(parent)
26 DEBTRACE("Creating JM::SalomeResource");
28 BL_ASSERT(salome_services);
30 _salome_services = salome_services;
31 _resource_name = resource_name;
34 QGroupBox * main_groupBox = new QGroupBox("Main values");
35 QLabel * name_label = new QLabel("Name:");
36 _name_line = new QLineEdit(this);
37 QLabel * hostname_label = new QLabel("Hostname:");
38 _hostname_line = new QLineEdit(this);
39 QLabel * protocol_label = new QLabel("Protocol:");
40 _protocol_line = new QLineEdit(this);
41 QLabel * username_label = new QLabel("Username:");
42 _username_line = new QLineEdit(this);
43 QLabel * applipath_label = new QLabel("Applipath:");
44 _applipath_line = new QLineEdit(this);
45 QLabel * componentList_label = new QLabel("Component List:");
46 _componentList = new QListWidget(this);
47 _componentList->setViewMode(QListView::ListMode);
48 QLabel * working_directory_label = new QLabel("Working Directory:");
49 _working_directory = new QLineEdit(this);
50 QLabel * is_cluster_head_label = new QLabel("Is Cluster Head:");
51 _is_cluster_head = new QPushButton(this);
52 toggle_is_cluster_head(false); // Default is false
53 QGridLayout * m_layout = new QGridLayout;
54 m_layout->addWidget(name_label, 0, 0);
55 m_layout->addWidget(_name_line, 0, 1);
56 m_layout->addWidget(hostname_label, 1, 0);
57 m_layout->addWidget(_hostname_line, 1, 1);
58 m_layout->addWidget(protocol_label, 2, 0);
59 m_layout->addWidget(_protocol_line, 2, 1);
60 m_layout->addWidget(username_label, 3, 0);
61 m_layout->addWidget(_username_line, 3, 1);
62 m_layout->addWidget(applipath_label, 4, 0);
63 m_layout->addWidget(_applipath_line, 4, 1);
64 m_layout->addWidget(componentList_label, 5, 0);
65 m_layout->addWidget(_componentList, 5, 1);
66 m_layout->addWidget(is_cluster_head_label, 6, 0);
67 m_layout->addWidget(_is_cluster_head, 6, 1);
68 m_layout->addWidget(working_directory_label, 7, 0);
69 m_layout->addWidget(_working_directory, 7, 1);
70 main_groupBox->setLayout(m_layout);
72 QGroupBox * config_groupBox = new QGroupBox("Configuration values");
73 QLabel * os_label = new QLabel("OS:");
74 _os_line = new QLineEdit(this);
75 QLabel * mem_mb_label = new QLabel("Memory (mb):");
76 _mem_mb_line = new QLineEdit(this);
77 QLabel * cpu_clock_label = new QLabel("CPU Clock:");
78 _cpu_clock_line = new QLineEdit(this);
79 QLabel * nb_node_label = new QLabel("Nb node:");
80 _nb_node_line = new QLineEdit(this);
81 QLabel * nb_proc_per_node_label = new QLabel("Nb proc/node:");
82 _nb_proc_per_node_line = new QLineEdit(this);
83 QLabel * batch_label = new QLabel("Batch:");
84 _batch_line = new QLineEdit(this);
85 QLabel * mpiImpl_label = new QLabel("MPI impl:");
86 _mpiImpl_line = new QLineEdit(this);
87 QLabel * iprotocol_label = new QLabel("Internal proctocol:");
88 _iprotocol_line = new QLineEdit(this);
89 QGridLayout * c_layout = new QGridLayout;
90 c_layout->addWidget(os_label, 0, 0);
91 c_layout->addWidget(_os_line, 0, 1);
92 c_layout->addWidget(mem_mb_label, 1, 0);
93 c_layout->addWidget(_mem_mb_line, 1, 1);
94 c_layout->addWidget(cpu_clock_label, 2, 0);
95 c_layout->addWidget(_cpu_clock_line, 2, 1);
96 c_layout->addWidget(nb_node_label, 3, 0);
97 c_layout->addWidget(_nb_node_line, 3, 1);
98 c_layout->addWidget(nb_proc_per_node_label, 4, 0);
99 c_layout->addWidget(_nb_proc_per_node_line, 4, 1);
100 c_layout->addWidget(batch_label, 5, 0);
101 c_layout->addWidget(_batch_line, 5, 1);
102 c_layout->addWidget(mpiImpl_label, 6, 0);
103 c_layout->addWidget(_mpiImpl_line, 6, 1);
104 c_layout->addWidget(iprotocol_label, 7, 0);
105 c_layout->addWidget(_iprotocol_line, 7, 1);
106 config_groupBox->setLayout(c_layout);
109 QVBoxLayout * mainLayout = new QVBoxLayout(this);
110 mainLayout->addWidget(main_groupBox);
111 mainLayout->addWidget(config_groupBox);
112 setLayout(mainLayout);
114 setWindowTitle("Resource");
117 // Line cannot be changed
118 _name_line->setCursorPosition(0);
119 _hostname_line->setCursorPosition(0);
120 _protocol_line->setCursorPosition(0);
121 _username_line->setCursorPosition(0);
122 _applipath_line->setCursorPosition(0);
123 _os_line->setCursorPosition(0);
124 _mem_mb_line->setCursorPosition(0);
125 _cpu_clock_line->setCursorPosition(0);
126 _nb_node_line->setCursorPosition(0);
127 _nb_proc_per_node_line->setCursorPosition(0);
128 _batch_line->setCursorPosition(0);
129 _mpiImpl_line->setCursorPosition(0);
130 _iprotocol_line->setCursorPosition(0);
131 _working_directory->setCursorPosition(0);
133 _name_line->setReadOnly(true);
134 _hostname_line->setReadOnly(true);
135 _protocol_line->setReadOnly(true);
136 _username_line->setReadOnly(true);
137 _applipath_line->setReadOnly(true);
138 _os_line->setReadOnly(true);
139 _mem_mb_line->setReadOnly(true);
140 _cpu_clock_line->setReadOnly(true);
141 _nb_node_line->setReadOnly(true);
142 _nb_proc_per_node_line->setReadOnly(true);
143 _batch_line->setReadOnly(true);
144 _mpiImpl_line->setReadOnly(true);
145 _iprotocol_line->setReadOnly(true);
146 _working_directory->setReadOnly(true);
149 JM::SalomeResource::~SalomeResource()
151 DEBTRACE("Destroying JM::SalomeResource");
155 JM::SalomeResource::get_infos()
157 BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_name);
159 _name_line->setText(QString(resource_descr.name.c_str()));
160 _hostname_line->setText(QString(resource_descr.hostname.c_str()));
161 _protocol_line->setText(QString(resource_descr.protocol.c_str()));
162 _username_line->setText(QString(resource_descr.username.c_str()));
163 _applipath_line->setText(QString(resource_descr.applipath.c_str()));
164 _os_line->setText(QString(resource_descr.OS.c_str()));
165 _batch_line->setText(QString(resource_descr.batch.c_str()));
166 _mpiImpl_line->setText(QString(resource_descr.mpiImpl.c_str()));
167 _iprotocol_line->setText(QString(resource_descr.iprotocol.c_str()));
168 _working_directory->setText(QString(resource_descr.working_directory.c_str()));
169 toggle_is_cluster_head(resource_descr.is_cluster_head);
172 _mem_mb_line->setText(value.setNum(resource_descr.mem_mb));
173 _cpu_clock_line->setText(value.setNum(resource_descr.cpu_clock));
174 _nb_node_line->setText(value.setNum(resource_descr.nb_node));
175 _nb_proc_per_node_line->setText(value.setNum(resource_descr.nb_proc_per_node));
177 std::list<std::string>::iterator it = resource_descr.componentList.begin();
178 for(; it != resource_descr.componentList.end(); it++)
179 _componentList->addItem(QString((*it).c_str()));
183 JM::SalomeResource::toggle_is_cluster_head(bool checked)
186 _is_cluster_head->setText("true");
188 _is_cluster_head->setText("false");