1 // Copyright (C) 2009-2022 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, or (at your option) any later version.
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"
24 #include <QGridLayout>
28 #include <QListWidget>
29 #include <QVBoxLayout>
31 JM::SalomeResource::SalomeResource(QWidget *parent, BL::SALOMEServices * salome_services,
32 const std::string & resource_name)
33 : QDialog(parent, Qt::Window)
35 DEBTRACE("Creating JM::SalomeResource");
37 BL_ASSERT(salome_services);
39 _salome_services = salome_services;
40 _resource_name = resource_name;
43 QGroupBox * main_groupBox = new QGroupBox("Main values");
44 QLabel * name_label = new QLabel("Name:");
45 _name_line = new QLineEdit(this);
46 QLabel * hostname_label = new QLabel("Hostname:");
47 _hostname_line = new QLineEdit(this);
48 QLabel * protocol_label = new QLabel("Protocol:");
49 _protocol_line = new QLineEdit(this);
50 QLabel * username_label = new QLabel("Username:");
51 _username_line = new QLineEdit(this);
52 QLabel * applipath_label = new QLabel("Applipath:");
53 _applipath_line = new QLineEdit(this);
54 QLabel * componentList_label = new QLabel("Component List:");
55 _componentList = new QListWidget(this);
56 _componentList->setViewMode(QListView::ListMode);
57 QLabel * working_directory_label = new QLabel("Working Directory:");
58 _working_directory = new QLineEdit(this);
59 _can_launch_batch_jobs = new QCheckBox("This resource can be used to launch batch jobs", this);
60 _can_run_containers = new QCheckBox("This resource can be used to run interactive containers", this);
61 QGridLayout * m_layout = new QGridLayout;
62 m_layout->addWidget(name_label, 0, 0);
63 m_layout->addWidget(_name_line, 0, 1);
64 m_layout->addWidget(hostname_label, 1, 0);
65 m_layout->addWidget(_hostname_line, 1, 1);
66 m_layout->addWidget(protocol_label, 2, 0);
67 m_layout->addWidget(_protocol_line, 2, 1);
68 m_layout->addWidget(username_label, 3, 0);
69 m_layout->addWidget(_username_line, 3, 1);
70 m_layout->addWidget(applipath_label, 4, 0);
71 m_layout->addWidget(_applipath_line, 4, 1);
72 m_layout->addWidget(componentList_label, 5, 0);
73 m_layout->addWidget(_componentList, 5, 1);
74 m_layout->addWidget(working_directory_label, 6, 0);
75 m_layout->addWidget(_working_directory, 6, 1);
76 m_layout->addWidget(_can_launch_batch_jobs, 7, 1);
77 m_layout->addWidget(_can_run_containers, 8, 1);
78 main_groupBox->setLayout(m_layout);
80 QGroupBox * config_groupBox = new QGroupBox("Configuration values");
81 QLabel * os_label = new QLabel("OS:");
82 _os_line = new QLineEdit(this);
83 QLabel * mem_mb_label = new QLabel("Memory (mb):");
84 _mem_mb_line = new QLineEdit(this);
85 QLabel * cpu_clock_label = new QLabel("CPU Clock:");
86 _cpu_clock_line = new QLineEdit(this);
87 QLabel * nb_node_label = new QLabel("Nb node:");
88 _nb_node_line = new QLineEdit(this);
89 QLabel * nb_proc_per_node_label = new QLabel("Nb proc/node:");
90 _nb_proc_per_node_line = new QLineEdit(this);
91 QLabel * batch_label = new QLabel("Batch:");
92 _batch_line = new QLineEdit(this);
93 QLabel * mpiImpl_label = new QLabel("MPI impl:");
94 _mpiImpl_line = new QLineEdit(this);
95 QLabel * iprotocol_label = new QLabel("Internal proctocol:");
96 _iprotocol_line = new QLineEdit(this);
97 QGridLayout * c_layout = new QGridLayout;
98 c_layout->addWidget(os_label, 0, 0);
99 c_layout->addWidget(_os_line, 0, 1);
100 c_layout->addWidget(mem_mb_label, 1, 0);
101 c_layout->addWidget(_mem_mb_line, 1, 1);
102 c_layout->addWidget(cpu_clock_label, 2, 0);
103 c_layout->addWidget(_cpu_clock_line, 2, 1);
104 c_layout->addWidget(nb_node_label, 3, 0);
105 c_layout->addWidget(_nb_node_line, 3, 1);
106 c_layout->addWidget(nb_proc_per_node_label, 4, 0);
107 c_layout->addWidget(_nb_proc_per_node_line, 4, 1);
108 c_layout->addWidget(batch_label, 5, 0);
109 c_layout->addWidget(_batch_line, 5, 1);
110 c_layout->addWidget(mpiImpl_label, 6, 0);
111 c_layout->addWidget(_mpiImpl_line, 6, 1);
112 c_layout->addWidget(iprotocol_label, 7, 0);
113 c_layout->addWidget(_iprotocol_line, 7, 1);
114 config_groupBox->setLayout(c_layout);
117 QVBoxLayout * mainLayout = new QVBoxLayout(this);
118 mainLayout->addWidget(main_groupBox);
119 mainLayout->addWidget(config_groupBox);
120 setLayout(mainLayout);
122 setWindowTitle("Resource");
125 // Line cannot be changed
126 _name_line->setCursorPosition(0);
127 _hostname_line->setCursorPosition(0);
128 _protocol_line->setCursorPosition(0);
129 _username_line->setCursorPosition(0);
130 _applipath_line->setCursorPosition(0);
131 _os_line->setCursorPosition(0);
132 _mem_mb_line->setCursorPosition(0);
133 _cpu_clock_line->setCursorPosition(0);
134 _nb_node_line->setCursorPosition(0);
135 _nb_proc_per_node_line->setCursorPosition(0);
136 _batch_line->setCursorPosition(0);
137 _mpiImpl_line->setCursorPosition(0);
138 _iprotocol_line->setCursorPosition(0);
139 _working_directory->setCursorPosition(0);
141 _name_line->setReadOnly(true);
142 _hostname_line->setReadOnly(true);
143 _protocol_line->setReadOnly(true);
144 _username_line->setReadOnly(true);
145 _applipath_line->setReadOnly(true);
146 _os_line->setReadOnly(true);
147 _mem_mb_line->setReadOnly(true);
148 _cpu_clock_line->setReadOnly(true);
149 _nb_node_line->setReadOnly(true);
150 _nb_proc_per_node_line->setReadOnly(true);
151 _batch_line->setReadOnly(true);
152 _mpiImpl_line->setReadOnly(true);
153 _iprotocol_line->setReadOnly(true);
154 _working_directory->setReadOnly(true);
155 _can_launch_batch_jobs->setEnabled(false);
156 _can_run_containers->setEnabled(false);
159 JM::SalomeResource::~SalomeResource()
161 DEBTRACE("Destroying JM::SalomeResource");
165 JM::SalomeResource::get_infos()
167 BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_name);
169 _name_line->setText(QString(resource_descr.name.c_str()));
170 _hostname_line->setText(QString(resource_descr.hostname.c_str()));
171 _protocol_line->setText(QString(resource_descr.protocol.c_str()));
172 _username_line->setText(QString(resource_descr.username.c_str()));
173 _applipath_line->setText(QString(resource_descr.applipath.c_str()));
174 _os_line->setText(QString(resource_descr.OS.c_str()));
175 _batch_line->setText(QString(resource_descr.batch.c_str()));
176 _mpiImpl_line->setText(QString(resource_descr.mpiImpl.c_str()));
177 _iprotocol_line->setText(QString(resource_descr.iprotocol.c_str()));
178 _working_directory->setText(QString(resource_descr.working_directory.c_str()));
180 if (resource_descr.can_launch_batch_jobs)
181 _can_launch_batch_jobs->setCheckState(Qt::Checked);
183 _can_launch_batch_jobs->setCheckState(Qt::Unchecked);
185 if (resource_descr.can_run_containers)
186 _can_run_containers->setCheckState(Qt::Checked);
188 _can_run_containers->setCheckState(Qt::Unchecked);
191 _mem_mb_line->setText(value.setNum(resource_descr.mem_mb));
192 _cpu_clock_line->setText(value.setNum(resource_descr.cpu_clock));
193 _nb_node_line->setText(value.setNum(resource_descr.nb_node));
194 _nb_proc_per_node_line->setText(value.setNum(resource_descr.nb_proc_per_node));
196 std::list<std::string>::iterator it = resource_descr.componentList.begin();
197 for(; it != resource_descr.componentList.end(); it++)
198 _componentList->addItem(QString((*it).c_str()));