1 // Copyright (C) 2009-2015 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"
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 _can_launch_batch_jobs = new QCheckBox("This resource can be used to launch batch jobs", this);
51 _can_run_containers = new QCheckBox("This resource can be used to run interactive containers", this);
52 QGridLayout * m_layout = new QGridLayout;
53 m_layout->addWidget(name_label, 0, 0);
54 m_layout->addWidget(_name_line, 0, 1);
55 m_layout->addWidget(hostname_label, 1, 0);
56 m_layout->addWidget(_hostname_line, 1, 1);
57 m_layout->addWidget(protocol_label, 2, 0);
58 m_layout->addWidget(_protocol_line, 2, 1);
59 m_layout->addWidget(username_label, 3, 0);
60 m_layout->addWidget(_username_line, 3, 1);
61 m_layout->addWidget(applipath_label, 4, 0);
62 m_layout->addWidget(_applipath_line, 4, 1);
63 m_layout->addWidget(componentList_label, 5, 0);
64 m_layout->addWidget(_componentList, 5, 1);
65 m_layout->addWidget(working_directory_label, 6, 0);
66 m_layout->addWidget(_working_directory, 6, 1);
67 m_layout->addWidget(_can_launch_batch_jobs, 7, 1);
68 m_layout->addWidget(_can_run_containers, 8, 1);
69 main_groupBox->setLayout(m_layout);
71 QGroupBox * config_groupBox = new QGroupBox("Configuration values");
72 QLabel * os_label = new QLabel("OS:");
73 _os_line = new QLineEdit(this);
74 QLabel * mem_mb_label = new QLabel("Memory (mb):");
75 _mem_mb_line = new QLineEdit(this);
76 QLabel * cpu_clock_label = new QLabel("CPU Clock:");
77 _cpu_clock_line = new QLineEdit(this);
78 QLabel * nb_node_label = new QLabel("Nb node:");
79 _nb_node_line = new QLineEdit(this);
80 QLabel * nb_proc_per_node_label = new QLabel("Nb proc/node:");
81 _nb_proc_per_node_line = new QLineEdit(this);
82 QLabel * batch_label = new QLabel("Batch:");
83 _batch_line = new QLineEdit(this);
84 QLabel * mpiImpl_label = new QLabel("MPI impl:");
85 _mpiImpl_line = new QLineEdit(this);
86 QLabel * iprotocol_label = new QLabel("Internal proctocol:");
87 _iprotocol_line = new QLineEdit(this);
88 QGridLayout * c_layout = new QGridLayout;
89 c_layout->addWidget(os_label, 0, 0);
90 c_layout->addWidget(_os_line, 0, 1);
91 c_layout->addWidget(mem_mb_label, 1, 0);
92 c_layout->addWidget(_mem_mb_line, 1, 1);
93 c_layout->addWidget(cpu_clock_label, 2, 0);
94 c_layout->addWidget(_cpu_clock_line, 2, 1);
95 c_layout->addWidget(nb_node_label, 3, 0);
96 c_layout->addWidget(_nb_node_line, 3, 1);
97 c_layout->addWidget(nb_proc_per_node_label, 4, 0);
98 c_layout->addWidget(_nb_proc_per_node_line, 4, 1);
99 c_layout->addWidget(batch_label, 5, 0);
100 c_layout->addWidget(_batch_line, 5, 1);
101 c_layout->addWidget(mpiImpl_label, 6, 0);
102 c_layout->addWidget(_mpiImpl_line, 6, 1);
103 c_layout->addWidget(iprotocol_label, 7, 0);
104 c_layout->addWidget(_iprotocol_line, 7, 1);
105 config_groupBox->setLayout(c_layout);
108 QVBoxLayout * mainLayout = new QVBoxLayout(this);
109 mainLayout->addWidget(main_groupBox);
110 mainLayout->addWidget(config_groupBox);
111 setLayout(mainLayout);
113 setWindowTitle("Resource");
116 // Line cannot be changed
117 _name_line->setCursorPosition(0);
118 _hostname_line->setCursorPosition(0);
119 _protocol_line->setCursorPosition(0);
120 _username_line->setCursorPosition(0);
121 _applipath_line->setCursorPosition(0);
122 _os_line->setCursorPosition(0);
123 _mem_mb_line->setCursorPosition(0);
124 _cpu_clock_line->setCursorPosition(0);
125 _nb_node_line->setCursorPosition(0);
126 _nb_proc_per_node_line->setCursorPosition(0);
127 _batch_line->setCursorPosition(0);
128 _mpiImpl_line->setCursorPosition(0);
129 _iprotocol_line->setCursorPosition(0);
130 _working_directory->setCursorPosition(0);
132 _name_line->setReadOnly(true);
133 _hostname_line->setReadOnly(true);
134 _protocol_line->setReadOnly(true);
135 _username_line->setReadOnly(true);
136 _applipath_line->setReadOnly(true);
137 _os_line->setReadOnly(true);
138 _mem_mb_line->setReadOnly(true);
139 _cpu_clock_line->setReadOnly(true);
140 _nb_node_line->setReadOnly(true);
141 _nb_proc_per_node_line->setReadOnly(true);
142 _batch_line->setReadOnly(true);
143 _mpiImpl_line->setReadOnly(true);
144 _iprotocol_line->setReadOnly(true);
145 _working_directory->setReadOnly(true);
146 _can_launch_batch_jobs->setEnabled(false);
147 _can_run_containers->setEnabled(false);
150 JM::SalomeResource::~SalomeResource()
152 DEBTRACE("Destroying JM::SalomeResource");
156 JM::SalomeResource::get_infos()
158 BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_name);
160 _name_line->setText(QString(resource_descr.name.c_str()));
161 _hostname_line->setText(QString(resource_descr.hostname.c_str()));
162 _protocol_line->setText(QString(resource_descr.protocol.c_str()));
163 _username_line->setText(QString(resource_descr.username.c_str()));
164 _applipath_line->setText(QString(resource_descr.applipath.c_str()));
165 _os_line->setText(QString(resource_descr.OS.c_str()));
166 _batch_line->setText(QString(resource_descr.batch.c_str()));
167 _mpiImpl_line->setText(QString(resource_descr.mpiImpl.c_str()));
168 _iprotocol_line->setText(QString(resource_descr.iprotocol.c_str()));
169 _working_directory->setText(QString(resource_descr.working_directory.c_str()));
171 if (resource_descr.can_launch_batch_jobs)
172 _can_launch_batch_jobs->setCheckState(Qt::Checked);
174 _can_launch_batch_jobs->setCheckState(Qt::Unchecked);
176 if (resource_descr.can_run_containers)
177 _can_run_containers->setCheckState(Qt::Checked);
179 _can_run_containers->setCheckState(Qt::Unchecked);
182 _mem_mb_line->setText(value.setNum(resource_descr.mem_mb));
183 _cpu_clock_line->setText(value.setNum(resource_descr.cpu_clock));
184 _nb_node_line->setText(value.setNum(resource_descr.nb_node));
185 _nb_proc_per_node_line->setText(value.setNum(resource_descr.nb_proc_per_node));
187 std::list<std::string>::iterator it = resource_descr.componentList.begin();
188 for(; it != resource_descr.componentList.end(); it++)
189 _componentList->addItem(QString((*it).c_str()));