Salome HOME
532a90f89d4905b3f2b6a0c5d0ef32761e5aa9b8
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
1 // Copyright (C) 2009-2016  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _BL_CREATEJOBWIZARD_HXX_
21 #define _BL_CREATEJOBWIZARD_HXX_
22
23 #include "BL_Traces.hxx"
24 #include "BL_SALOMEServices.hxx"
25 #include "JM_ResourceCatalog.hxx"
26
27 #include <QWizard>
28 #include <QWizardPage>
29 #include <string>
30 #include <list>
31
32 class QGridLayout;
33 class QLabel;
34 class QLineEdit;
35 class QListWidget;
36
37 namespace Ui {
38   class ResourceRequirementsWizardPage;
39   class FilesWizardPage;
40   class AdvancedParametersWizardPage;
41 }
42
43 namespace BL {
44
45   class JobsManager_QT;
46   class JobNamePage;
47   class BatchParametersPage;
48   class CreateJobWizard: public QWizard
49   {
50     Q_OBJECT
51
52     public:
53       CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services);
54       virtual ~CreateJobWizard();
55
56       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
57
58       void clone(const std::string & name);
59
60     public slots:
61       void end(int result);
62
63     private:
64       BL::JobsManager_QT * _jobs_manager;
65       QListWidget * _input_files_list;
66       QListWidget * _output_files_list;
67
68       BL::JobNamePage * _job_name_page;
69       BL::BatchParametersPage * _batch_parameters_page;
70       BL::SALOMEServices * _salome_services;
71
72     public:
73       // Results
74       std::string job_name;
75       enum {YACS, COMMAND, PYTHON_SALOME} job_type;
76
77       std::string yacs_file;
78       std::string command;
79       std::string python_salome_file;
80
81       std::string env_file;
82       std::string pre_command;
83
84       std::string batch_directory;
85
86       // For COORM
87       std::string coorm_batch_directory;
88
89       std::string maximum_duration;
90       long mem_limit;
91       BL::Job::MemReqType mem_req_type;
92       int nb_proc;
93       int nb_node;
94       bool exclusive;
95
96       // Parameters for COORM
97       std::string launcher_file;
98       std::string launcher_args;
99
100       std::string result_directory;
101       std::list<std::string> input_files_list;
102       std::list<std::string> output_files_list;
103
104       std::string resource_choosed;
105       std::string batch_queue;
106       std::string batch_partition;
107       std::string wckey;
108       std::string extra_params;
109
110       bool start_job;
111       int dump_yacs_state;
112       std::string ll_jobtype;
113       std::string yacs_driver_options;
114
115     public:
116       enum {Page_JobName,
117             Page_YACSSchema,
118             Page_Command_Main_Definitions,
119             Page_PythonSalome_Main_Definitions,
120             Page_BatchParameters,
121             Page_COORM_BatchParameters,
122             Page_Files,
123             Page_Resource,
124             Page_Advanced,
125             Page_Conclusion};
126   };
127
128   class JobNamePage: public QWizardPage
129   {
130     Q_OBJECT
131
132     public:
133       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
134       virtual ~JobNamePage();
135
136       virtual bool validatePage();
137       virtual int nextId() const ;
138       virtual void cleanupPage() {}
139
140     public slots:
141       void yacs_schema_button(bool checked);
142       void command_button(bool checked);
143       void python_salome_button(bool checked);
144
145     private:
146       BL::JobsManager_QT * _jobs_manager;
147       QLabel * _explanation;
148
149     public:
150       bool _check_name;
151   };
152
153   class ConclusionPage: public QWizardPage
154   {
155     public:
156       ConclusionPage(QWidget * parent);
157       virtual ~ConclusionPage();
158
159       virtual bool validatePage();
160       virtual int nextId() const ;
161       virtual void cleanupPage() {}
162   };
163
164   class BatchParametersPage: public QWizardPage
165   {
166     Q_OBJECT
167
168     public:
169       enum MemUnit {MB, GB};
170
171       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
172       virtual ~BatchParametersPage();
173
174       virtual void initializePage();
175       virtual int nextId() const;
176       virtual void cleanupPage();
177
178       MemUnit getMemUnit() const;
179       void setMemUnit(MemUnit mem_unit);
180
181       BL::Job::MemReqType getMemReqType() const;
182       void setMemReqType(BL::Job::MemReqType mem_req_type);
183
184     public slots:
185       void timeChanged();
186       void memChanged();
187
188     private:
189       Ui::ResourceRequirementsWizardPage * ui;
190       BL::SALOMEServices * _salome_services;
191       std::string resource_choosed;
192   };
193
194   // For COORM
195   class COORM_BatchParametersPage: public QWizardPage
196   {
197     Q_OBJECT
198
199     public:
200       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
201       virtual ~COORM_BatchParametersPage();
202
203       virtual bool validatePage();
204       virtual int nextId() const;
205       virtual void cleanupPage();
206       virtual void initializePage();
207
208     public slots:
209       void choose_launcher_file();
210
211     private:
212       BL::SALOMEServices * _salome_services;
213       QLineEdit * _launcher_file_text;
214       QString resource_choosed;
215   };
216
217   class FilesPage: public QWizardPage
218   {
219     Q_OBJECT
220
221     public:
222       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
223       virtual ~FilesPage();
224
225       virtual void initializePage();
226       virtual int nextId() const;
227       virtual bool isComplete() const;
228       virtual void cleanupPage() {}
229
230     public slots:
231       void choose_input_files();
232       void remove_input_files();
233       void input_itemSelectionChanged();
234       void choose_local_directory();
235
236       void add_output_file();
237       void remove_output_files();
238       void output_itemSelectionChanged();
239
240     private:
241       Ui::FilesWizardPage * ui;
242       BL::SALOMEServices * _salome_services;
243       QString resource_choosed;
244   };
245
246   class ResourcePage: public QWizardPage
247   {
248     Q_OBJECT
249
250     public:
251       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
252       virtual ~ResourcePage();
253
254       virtual int nextId() const;
255       virtual bool validatePage();
256       virtual void initializePage();
257       virtual void cleanupPage() {}
258
259     public slots:
260       void itemSelected(QListWidgetItem * item);
261
262     private:
263       JM::ResourceCatalog * _resource_list;
264       QLineEdit * _resource_choosed;
265       BL::SALOMEServices * _salome_services;
266
267       QLabel * _ll_label;
268       QLineEdit * _ll_value;
269       QGridLayout * _main_layout;
270   };
271
272   class YACSSchemaPage: public QWizardPage
273   {
274     Q_OBJECT
275
276     public:
277       YACSSchemaPage(QWidget * parent);
278       virtual ~YACSSchemaPage();
279
280       virtual bool validatePage();
281       virtual int nextId() const ;
282       virtual void cleanupPage() {}
283
284     public slots:
285       void choose_file();
286       void choose_env_file();
287       void choose_pre_command_file();
288
289     private:
290       QLineEdit * _yacs_file_text;
291       QLineEdit * _line_env_file;
292       QLineEdit * _line_pre_command;
293   };
294
295   class CommandMainPage: public QWizardPage
296   {
297     Q_OBJECT
298
299     public:
300       CommandMainPage(QWidget * parent);
301       virtual ~CommandMainPage();
302
303       virtual bool validatePage();
304       virtual int nextId() const ;
305       virtual void cleanupPage() {}
306
307     public slots:
308       void choose_command_file();
309       void choose_env_file();
310       void choose_pre_command_file();
311
312     private:
313       QLineEdit * _line_command;
314       QLineEdit * _line_env_file;
315       QLineEdit * _line_pre_command;
316   };
317
318   class PythonSalomeMainPage: public QWizardPage
319   {
320     Q_OBJECT
321
322     public:
323       PythonSalomeMainPage(QWidget * parent);
324       virtual ~PythonSalomeMainPage();
325
326       virtual bool validatePage();
327       virtual int nextId() const ;
328       virtual void cleanupPage() {}
329
330     public slots:
331       void choose_PythonSalome_file();
332       void choose_env_file();
333       void choose_pre_command_file();
334
335     private:
336       QLineEdit * _line_PythonSalome;
337       QLineEdit * _line_env_file;
338       QLineEdit * _line_pre_command;
339   };
340
341   class AdvancedParametersPage: public QWizardPage
342   {
343     Q_OBJECT
344
345     public:
346       AdvancedParametersPage(BL::CreateJobWizard * parent);
347       virtual ~AdvancedParametersPage();
348
349       virtual int nextId() const;
350       virtual void cleanupPage() {}
351
352     private:
353       Ui::AdvancedParametersWizardPage * ui;
354
355   };
356
357 }
358
359 #endif
360