1 // Copyright (C) 2009-2013 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 "BL_JobTab.hxx"
21 #include "BL_Traces.hxx"
27 BL::JobTab::JobTab(QWidget *parent, BL::JobsManager_QT * jobs_manager) : QTabWidget(parent)
29 DEBTRACE("Creating BL::JobTab");
31 BL_ASSERT(jobs_manager);
33 _jobs_manager = jobs_manager;
36 createJobSummaryTab();
42 DEBTRACE("Destroying BL::JobTab");
46 BL::JobTab::setModel(QStandardItemModel * model)
48 DEBTRACE("Call setModel BL::JobTab");
55 BL::JobTab::createJobSummaryTab()
57 _summary_tab = new QWidget(this);
59 QLabel * job_name_label = new QLabel("Name:");
60 _job_name_label_value = new QLabel("");
61 QLabel * job_type_label = new QLabel("Type:");
62 _job_type_label_value = new QLabel("");
63 QLabel * job_state_label = new QLabel("State:");
64 _job_state_label_value = new QLabel("");
65 QLabel * job_launcher_label = new QLabel("Launcher Id:");
66 _job_launcher_label_value = new QLabel("");
67 QLabel * job_resource_label = new QLabel("Resource:");
68 _job_resource_label_value = new QLabel("");
69 QLabel * job_jobfile_label = new QLabel("Job File:");
70 _job_jobfile_label_value = new QLabel("");
71 QLabel * job_envfile_label = new QLabel("Env File:");
72 _job_envfile_label_value = new QLabel("");
76 _yacs_dump_state_label = new QLabel("YACS dump state:");
77 _yacs_dump_state_value = new QLabel("");
79 QGroupBox * main_values_box = new QGroupBox("Main values");
80 _main_values_form = new QFormLayout;
81 _main_values_form->insertRow(0, job_name_label, _job_name_label_value);
82 _main_values_form->insertRow(1, job_type_label, _job_type_label_value);
83 _main_values_form->insertRow(2, job_state_label, _job_state_label_value);
84 _main_values_form->insertRow(3, job_launcher_label, _job_launcher_label_value);
85 _main_values_form->insertRow(4, job_resource_label, _job_resource_label_value);
86 _main_values_form->insertRow(5, job_jobfile_label, _job_jobfile_label_value);
87 _main_values_form->insertRow(6, job_envfile_label, _job_envfile_label_value);
88 main_values_box->setLayout(_main_values_form);
90 QLabel * job_nif_label = new QLabel("Number of Input Files:");
91 _job_nif_label_value = new QLabel("");
92 QLabel * job_nof_label = new QLabel("Number of Output Files:");
93 _job_nof_label_value = new QLabel("");
94 QLabel * job_bd_label = new QLabel("Execution directory:");
95 _job_bd_label_value = new QLabel("");
96 QLabel * job_rd_label = new QLabel("Result directory:");
97 _job_rd_label_value = new QLabel("");
99 QLabel * job_mdt_label = new QLabel("Maximum duration:");
100 _job_mdt_label_value = new QLabel("");
101 QLabel * job_em_label = new QLabel("Expected memory:");
102 _job_em_label_value = new QLabel("");
103 QLabel * job_nop_label = new QLabel("Number of processors:");
104 _job_nop_label_value = new QLabel("");
105 QLabel * job_excl_label = new QLabel("Exclusive:");
106 _job_excl_label_value = new QLabel("");
108 // Parameters for COORM
109 QLabel * job_lf_label = new QLabel("Launcher file:");
110 _job_lf_label_value = new QLabel("");
111 QLabel * job_la_label = new QLabel("Launcher args:");
112 _job_la_label_value = new QLabel("");
115 _batch_queue_label = new QLabel("Batch queue:");
116 _batch_queue_value = new QLabel("");
117 _ll_jobtype_label = new QLabel("LoadLeveler JobType:");
118 _ll_jobtype_value = new QLabel("");
120 QGroupBox * run_values_box = new QGroupBox("Run values");
121 _run_values_form = new QFormLayout;
122 _run_values_form->insertRow(0, job_nif_label, _job_nif_label_value);
123 _run_values_form->insertRow(1, job_nof_label, _job_nof_label_value);
124 _run_values_form->insertRow(2, job_bd_label, _job_bd_label_value);
125 _run_values_form->insertRow(3, job_rd_label, _job_rd_label_value);
127 // Parameters for COORM
128 _run_values_form->insertRow(4, job_lf_label, _job_lf_label_value);
130 _other_run_values_form = new QFormLayout;
131 _other_run_values_form->insertRow(0, job_mdt_label, _job_mdt_label_value);
132 _other_run_values_form->insertRow(1, job_em_label, _job_em_label_value);
133 _other_run_values_form->insertRow(2, job_nop_label, _job_nop_label_value);
134 _other_run_values_form->insertRow(3, job_excl_label, _job_excl_label_value);
136 // Parameters for COORM
137 _other_run_values_form->insertRow(4, job_la_label, _job_la_label_value);
139 QHBoxLayout * box_layout = new QHBoxLayout();
140 box_layout->addLayout(_run_values_form);
141 box_layout->addLayout(_other_run_values_form);
142 run_values_box->setLayout(box_layout);
144 QVBoxLayout * mainLayout = new QVBoxLayout();
145 mainLayout->addWidget(main_values_box);
146 mainLayout->addWidget(run_values_box);
147 _summary_tab->setLayout(mainLayout);
150 insertTab(0, _summary_tab, "Job Summary");
155 BL::JobTab::createJobFilesTab()
157 _files_tab = new QWidget(this);
159 _input_files_list = new QListWidget(this);
160 _input_files_list->setSelectionMode(QAbstractItemView::NoSelection);
161 QGroupBox * input_files_box = new QGroupBox("Input Files");
162 QVBoxLayout * input_layout = new QVBoxLayout();
163 input_layout->addWidget(_input_files_list);
164 input_files_box->setLayout(input_layout);
166 _output_files_list = new QListWidget(this);
167 _output_files_list->setSelectionMode(QAbstractItemView::NoSelection);
168 QGroupBox * output_files_box = new QGroupBox("Output Files");
169 QVBoxLayout * output_layout = new QVBoxLayout();
170 output_layout->addWidget(_output_files_list);
171 output_files_box->setLayout(output_layout);
173 QVBoxLayout * mainLayout = new QVBoxLayout();
174 mainLayout->addWidget(input_files_box);
175 mainLayout->addWidget(output_files_box);
176 _files_tab->setLayout(mainLayout);
178 insertTab(1, _files_tab, "Job Files");
182 BL::JobTab::job_selected(const QModelIndex & index)
184 DEBTRACE("BL::JobTab::job_selected slot");
185 QStandardItem * item = _model->itemFromIndex(index);
186 QStandardItem * item_name = _model->item(item->row());
189 BL::Job * job = _jobs_manager->getJob(item_name->text().toStdString());
193 _job_name_label_value->setText(QString(job->getName().c_str()));
195 if (job->getState() == BL::Job::CREATED)
196 _job_state_label_value->setText("Created");
197 else if (job->getState() == BL::Job::IN_PROCESS)
198 _job_state_label_value->setText("In Process");
199 else if (job->getState() == BL::Job::QUEUED)
200 _job_state_label_value->setText("Queued");
201 else if (job->getState() == BL::Job::RUNNING)
202 _job_state_label_value->setText("Running");
203 else if (job->getState() == BL::Job::PAUSED)
204 _job_state_label_value->setText("Paused");
205 else if (job->getState() == BL::Job::ERROR)
206 _job_state_label_value->setText("Error");
207 else if (job->getState() == BL::Job::FAILED)
208 _job_state_label_value->setText("Failed");
209 else if (job->getState() == BL::Job::NOT_CREATED)
210 _job_state_label_value->setText("Not Created");
212 _job_state_label_value->setText("Finished");
214 _job_launcher_label_value->setText(QVariant(job->getSalomeLauncherId()).toString());
215 _job_jobfile_label_value->setText(QString(job->getJobFile().c_str()));
216 _job_envfile_label_value->setText(QString(job->getEnvFile().c_str()));
217 if (job->getType() == BL::Job::YACS_SCHEMA)
218 _job_type_label_value->setText("YACS_Schema");
219 else if (job->getType() == BL::Job::COMMAND)
220 _job_type_label_value->setText("Command");
221 else if (job->getType() == BL::Job::PYTHON_SALOME)
222 _job_type_label_value->setText("Python_Salome");
224 _job_resource_label_value->setText(QString(job->getResource().c_str()));
226 BL::Job::BatchParam batch_params = job->getBatchParameters();
228 BL::Job::FilesParam files_params = job->getFilesParameters();
229 int nif = files_params.input_files_list.size();
230 _job_nif_label_value->setText(QVariant(nif).toString());
231 int nof = files_params.output_files_list.size();
232 _job_nof_label_value->setText(QVariant(nof).toString());
233 _job_bd_label_value->setText(QString(batch_params.batch_directory.c_str()));
234 _job_rd_label_value->setText(QString(files_params.result_directory.c_str()));
236 _job_mdt_label_value->setText(QString(batch_params.maximum_duration.c_str()));
237 _job_em_label_value->setText(QString(batch_params.expected_memory.c_str()));
238 _job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString());
239 QString exclText = (batch_params.exclusive)? "yes" : "no";
240 _job_excl_label_value->setText(exclText);
242 // Parameters for COORM
243 _job_lf_label_value->setText(QString(batch_params.launcher_file.c_str()));
244 _job_la_label_value->setText(QString(batch_params.launcher_args.c_str()));
246 _input_files_list->clear();
247 _output_files_list->clear();
248 std::list<std::string>::iterator it;
249 for (it = files_params.input_files_list.begin(); it != files_params.input_files_list.end(); it++)
251 std::string file = *it;
252 _input_files_list->addItem(QString(file.c_str()));
254 for (it = files_params.output_files_list.begin(); it != files_params.output_files_list.end(); it++)
256 std::string file = *it;
257 _output_files_list->addItem(QString(file.c_str()));
260 // Specific parameters management
261 if (job->getDumpYACSState() > 0)
263 // Add widget in the layout
264 _yacs_dump_state_value->setText(QVariant(job->getDumpYACSState()).toString());
265 _main_values_form->insertRow(7, _yacs_dump_state_label, _yacs_dump_state_value);
267 if (job->getBatchQueue() != "")
269 _batch_queue_value->setText(QVariant(job->getBatchQueue().c_str()).toString());
270 _other_run_values_form->insertRow(_other_run_values_form->rowCount(), _batch_queue_label, _batch_queue_value);
272 if (job->getLoadLevelerJobType() != "")
274 _ll_jobtype_value->setText(QVariant(job->getLoadLevelerJobType().c_str()).toString());
275 _other_run_values_form->insertRow(_other_run_values_form->rowCount(), _ll_jobtype_label, _ll_jobtype_value);
279 DEBTRACE ("itemFromIndex returns 0 !");
283 BL::JobTab::itemChanged(QStandardItem * item)
285 DEBTRACE("BL::JobTab::itemChanged slot");
287 QStandardItem * item_name = _model->item(item->row());
288 BL::Job * job = _jobs_manager->getJob(item_name->text().toStdString());
290 if (_job_name_label_value->text() == QString(job->getName().c_str()))
292 if (job->getState() == BL::Job::CREATED)
293 _job_state_label_value->setText("Created");
294 else if (job->getState() == BL::Job::IN_PROCESS)
295 _job_state_label_value->setText("In Process");
296 else if (job->getState() == BL::Job::QUEUED)
297 _job_state_label_value->setText("Queued");
298 else if (job->getState() == BL::Job::RUNNING)
299 _job_state_label_value->setText("Running");
300 else if (job->getState() == BL::Job::PAUSED)
301 _job_state_label_value->setText("Paused");
302 else if (job->getState() == BL::Job::ERROR)
303 _job_state_label_value->setText("Error");
304 else if (job->getState() == BL::Job::FAILED)
305 _job_state_label_value->setText("Failed");
306 else if (job->getState() == BL::Job::NOT_CREATED)
307 _job_state_label_value->setText("Not Created");
309 _job_state_label_value->setText("Finished");
314 BL::JobTab::reset(QString job_name)
316 if (job_name == _job_name_label_value->text() || job_name == "")
318 _job_name_label_value->setText("");
319 _job_type_label_value->setText("");
320 _job_state_label_value->setText("");
321 _job_launcher_label_value->setText("");
322 _job_resource_label_value->setText("");
323 _job_nif_label_value->setText("");
324 _job_nof_label_value->setText("");
325 _job_bd_label_value->setText("");
326 _job_rd_label_value->setText("");
327 _job_mdt_label_value->setText("");
328 _job_em_label_value->setText("");
329 _job_nop_label_value->setText("");
330 _job_excl_label_value->setText("");
331 _job_jobfile_label_value->setText("");
332 _job_envfile_label_value->setText("");
334 _input_files_list->clear();
335 _output_files_list->clear();
337 _yacs_dump_state_value->setText("");
338 _batch_queue_value->setText("");
339 _ll_jobtype_value->setText("");
341 // Parameters for COORM
342 _job_lf_label_value->setText("");
343 _job_la_label_value->setText("");