Salome HOME
Copyright update 2022
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
1 // Copyright (C) 2009-2022  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, COMMAND_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 command_salome_button(bool checked);
144       void python_salome_button(bool checked);
145
146     private:
147       BL::JobsManager_QT * _jobs_manager;
148       QLabel * _explanation;
149
150     public:
151       bool _check_name;
152   };
153
154   class ConclusionPage: public QWizardPage
155   {
156     public:
157       ConclusionPage(QWidget * parent);
158       virtual ~ConclusionPage();
159
160       virtual bool validatePage();
161       virtual int nextId() const ;
162       virtual void cleanupPage() {}
163   };
164
165   class BatchParametersPage: public QWizardPage
166   {
167     Q_OBJECT
168
169     public:
170       enum MemUnit {MB, GB};
171
172       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
173       virtual ~BatchParametersPage();
174
175       virtual void initializePage();
176       virtual int nextId() const;
177       virtual void cleanupPage();
178
179       MemUnit getMemUnit() const;
180       void setMemUnit(MemUnit mem_unit);
181
182       BL::Job::MemReqType getMemReqType() const;
183       void setMemReqType(BL::Job::MemReqType mem_req_type);
184
185     public slots:
186       void timeChanged();
187       void memChanged();
188
189     private:
190       Ui::ResourceRequirementsWizardPage * ui;
191       BL::SALOMEServices * _salome_services;
192       std::string resource_choosed;
193   };
194
195   // For COORM
196   class COORM_BatchParametersPage: public QWizardPage
197   {
198     Q_OBJECT
199
200     public:
201       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
202       virtual ~COORM_BatchParametersPage();
203
204       virtual bool validatePage();
205       virtual int nextId() const;
206       virtual void cleanupPage();
207       virtual void initializePage();
208
209     public slots:
210       void choose_launcher_file();
211
212     private:
213       BL::SALOMEServices * _salome_services;
214       QLineEdit * _launcher_file_text;
215       QString resource_choosed;
216   };
217
218   class FilesPage: public QWizardPage
219   {
220     Q_OBJECT
221
222     public:
223       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
224       virtual ~FilesPage();
225
226       virtual void initializePage();
227       virtual int nextId() const;
228       virtual bool isComplete() const;
229       virtual void cleanupPage() {}
230
231     public slots:
232       void choose_input_files();
233       void remove_input_files();
234       void input_itemSelectionChanged();
235       void choose_local_directory();
236
237       void add_output_file();
238       void remove_output_files();
239       void output_itemSelectionChanged();
240
241     private:
242       Ui::FilesWizardPage * ui;
243       BL::SALOMEServices * _salome_services;
244       QString resource_choosed;
245   };
246
247   class ResourcePage: public QWizardPage
248   {
249     Q_OBJECT
250
251     public:
252       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
253       virtual ~ResourcePage();
254
255       virtual int nextId() const;
256       virtual bool validatePage();
257       virtual void initializePage();
258       virtual void cleanupPage() {}
259
260     public slots:
261       void itemSelected(QListWidgetItem * item);
262
263     private:
264       JM::ResourceCatalog * _resource_list;
265       QLineEdit * _resource_choosed;
266       BL::SALOMEServices * _salome_services;
267
268       QLabel * _ll_label;
269       QLineEdit * _ll_value;
270       QGridLayout * _main_layout;
271   };
272
273   class YACSSchemaPage: public QWizardPage
274   {
275     Q_OBJECT
276
277     public:
278       YACSSchemaPage(QWidget * parent);
279       virtual ~YACSSchemaPage();
280
281       virtual bool validatePage();
282       virtual int nextId() const ;
283       virtual void cleanupPage() {}
284
285     public slots:
286       void choose_file();
287       void choose_env_file();
288       void choose_pre_command_file();
289
290     private:
291       QLineEdit * _yacs_file_text;
292       QLineEdit * _line_env_file;
293       QLineEdit * _line_pre_command;
294   };
295
296   class CommandMainPage: public QWizardPage
297   {
298     Q_OBJECT
299
300     public:
301       CommandMainPage(QWidget * parent);
302       virtual ~CommandMainPage();
303
304       virtual bool validatePage();
305       virtual int nextId() const ;
306       virtual void cleanupPage() {}
307
308     public slots:
309       void choose_command_file();
310       void choose_env_file();
311       void choose_pre_command_file();
312
313     private:
314       QLineEdit * _line_command;
315       QLineEdit * _line_env_file;
316       QLineEdit * _line_pre_command;
317   };
318
319   class PythonSalomeMainPage: public QWizardPage
320   {
321     Q_OBJECT
322
323     public:
324       PythonSalomeMainPage(QWidget * parent);
325       virtual ~PythonSalomeMainPage();
326
327       virtual bool validatePage();
328       virtual int nextId() const ;
329       virtual void cleanupPage() {}
330
331     public slots:
332       void choose_PythonSalome_file();
333       void choose_env_file();
334       void choose_pre_command_file();
335
336     private:
337       QLineEdit * _line_PythonSalome;
338       QLineEdit * _line_env_file;
339       QLineEdit * _line_pre_command;
340   };
341
342   class AdvancedParametersPage: public QWizardPage
343   {
344     Q_OBJECT
345
346     public:
347       AdvancedParametersPage(BL::CreateJobWizard * parent);
348       virtual ~AdvancedParametersPage();
349
350       virtual int nextId() const;
351       virtual void cleanupPage() {}
352
353     private:
354       Ui::AdvancedParametersWizardPage * ui;
355
356   };
357
358 }
359
360 #endif
361