From 1227bd47943f4084892f59921cba515e87d36098 Mon Sep 17 00:00:00 2001 From: ribes Date: Thu, 28 Apr 2011 11:35:31 +0000 Subject: [PATCH] Adding dump yacs state option --- src/engine/BL_Job.cxx | 14 +++++++ src/engine/BL_Job.hxx | 4 ++ src/engine/BL_SALOMEServices.cxx | 28 ++++++++++++++ src/genericgui/BL_CreateJobWizard.cxx | 32 +++++++++++++--- src/genericgui/BL_CreateJobWizard.hxx | 19 +++++----- src/genericgui/BL_JobTab.cxx | 53 ++++++++++++++++++++------- src/genericgui/BL_JobTab.hxx | 8 +++- src/genericgui/BL_JobsManager_QT.cxx | 1 + 8 files changed, 131 insertions(+), 28 deletions(-) diff --git a/src/engine/BL_Job.cxx b/src/engine/BL_Job.cxx index 6cf4c84..2e5c22a 100644 --- a/src/engine/BL_Job.cxx +++ b/src/engine/BL_Job.cxx @@ -35,6 +35,7 @@ BL::Job::Job() _state = BL::Job::CREATED; _thread_state = BL::Job::NOTHING; _salome_launcher_id = -1; + _dump_yacs_state = 0; } BL::Job::Job(const std::string & name) @@ -53,6 +54,7 @@ BL::Job::Job(const std::string & name) _state = BL::Job::CREATED; _thread_state = BL::Job::NOTHING; _salome_launcher_id = -1; + _dump_yacs_state = 0; } BL::Job::~Job() @@ -99,6 +101,18 @@ BL::Job::getType() return _type; } +void +BL::Job::setDumpYACSState(const int & dump_yacs_state) +{ + _dump_yacs_state = dump_yacs_state; +} + +int +BL::Job::getDumpYACSState() +{ + return _dump_yacs_state; +} + void BL::Job::setJobFile(const std::string & job_file) { diff --git a/src/engine/BL_Job.hxx b/src/engine/BL_Job.hxx index 210ee0f..7d39dcc 100644 --- a/src/engine/BL_Job.hxx +++ b/src/engine/BL_Job.hxx @@ -48,6 +48,9 @@ namespace BL{ void setEnvFile(const std::string & env_file); std::string & getEnvFile(); + void setDumpYACSState(const int & dump_yacs_state); + int getDumpYACSState(); + struct BatchParam { std::string batch_directory; @@ -88,6 +91,7 @@ namespace BL{ private: BL::Job::State _state; BL::Job::ThreadState _thread_state; + int _dump_yacs_state; std::string _name; diff --git a/src/engine/BL_SALOMEServices.cxx b/src/engine/BL_SALOMEServices.cxx index 24ffcb0..6456831 100644 --- a/src/engine/BL_SALOMEServices.cxx +++ b/src/engine/BL_SALOMEServices.cxx @@ -251,6 +251,21 @@ BL::SALOMEServices::create_job(BL::Job * job) job_parameters->job_type = CORBA::string_dup("python_salome"); } + // Specific parameters + if (job->getType() == BL::Job::YACS_SCHEMA) + { + if (job->getDumpYACSState() > 0) + { + job_parameters->specific_parameters.length(job_parameters->specific_parameters.length() + 1); + std::ostringstream oss; + oss << job->getDumpYACSState(); + Engines::Parameter_var new_parameter = new Engines::Parameter; + new_parameter->name = CORBA::string_dup("EnableDumpYACS"); + new_parameter->value = CORBA::string_dup(oss.str().c_str()); + job_parameters->specific_parameters[job_parameters->specific_parameters.length() - 1] = new_parameter; + } + } + // Files job_parameters->job_name = CORBA::string_dup(job->getName().c_str()); job_parameters->job_file = CORBA::string_dup(job->getJobFile().c_str()); @@ -539,6 +554,19 @@ BL::SALOMEServices::get_new_job(int job_number) job_return->setResource(job_parameters->resource_required.name.in()); + // Specific parameters + for (CORBA::ULong i = 0; i < job_parameters->specific_parameters.length(); i++) + { + if (std::string(job_parameters->specific_parameters[i].name.in()) == "EnableDumpYACS") + { + std::string user_value = job_parameters->specific_parameters[i].value.in(); + std::istringstream iss(user_value); + int value; + iss >> value; + job_return->setDumpYACSState(value); + } + } + // Get current state std::string result_job = job_return->setStringState(refresh_job(job_return)); if (result_job == "new_state") {} diff --git a/src/genericgui/BL_CreateJobWizard.cxx b/src/genericgui/BL_CreateJobWizard.cxx index d87215c..4420c44 100644 --- a/src/genericgui/BL_CreateJobWizard.cxx +++ b/src/genericgui/BL_CreateJobWizard.cxx @@ -47,6 +47,7 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO batch_queue = ""; start_job = false; + dump_yacs_state = -1; setOptions(QWizard::IndependentPages | QWizard::NoBackButtonOnStartPage); @@ -95,6 +96,12 @@ BL::CreateJobWizard::clone(const std::string & name) setField("yacs_file", QString(job->getJobFile().c_str())); _job_name_page->_yacs_schema_button->click(); setField("env_yacs_file", QString(job->getEnvFile().c_str())); + if (job->getDumpYACSState() != -1) + { + QString value; + value.setNum(job->getDumpYACSState()); + setField("dump_yacs_state", value); + } } else if (job->getType() == BL::Job::COMMAND) { @@ -174,15 +181,16 @@ BL::CreateJobWizard::end(int result) // YACS Schema Panel QString f_yacs_file = field("yacs_file").toString(); yacs_file = f_yacs_file.toStdString(); - + dump_yacs_state = field("dump_yacs_state").toInt(); + // Command Panel QString f_command = field("command").toString(); command = f_command.toStdString(); - + // Command Panel QString f_python_salome_file = field("PythonSalome").toString(); python_salome_file = f_python_salome_file.toStdString(); - + QString f_env_file; if (yacs_file != "") f_env_file = field("env_yacs_file").toString(); @@ -376,9 +384,9 @@ BL::JobNamePage::nextId() const BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent) : QWizardPage(parent) { - setTitle("Choose YACS Schema"); + setTitle("Configure YACS Execution"); - QLabel *label = new QLabel("In this step you have to choose what YACS Schema you want to execute"); + QLabel *label = new QLabel("In this step you have to configure your YACS execution"); label->setWordWrap(true); QPushButton * yacs_file_button = new QPushButton(tr("Choose YACS Schema file")); @@ -395,6 +403,19 @@ BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent) registerField("env_yacs_file", _line_env_file); _line_env_file->setReadOnly(true); + QGroupBox * spec_param_box = new QGroupBox("YACS specific parameters"); + QLabel * label_dump = new QLabel("Dump YACS state each secs (0 disable this feature)"); + QLabel * label_dump_warning = new QLabel("(WARNING: can only be used with SALOME >= 6.3.0)"); + QSpinBox * spin_dump = new QSpinBox(this); + spin_dump->setMinimum(0); + spin_dump->setMaximum(1000000); + registerField("dump_yacs_state", spin_dump); + QGridLayout * specific_layout = new QGridLayout; + specific_layout->addWidget(label_dump, 0, 0); + specific_layout->addWidget(spin_dump, 0, 1); + specific_layout->addWidget(label_dump_warning, 1, 0); + spec_param_box->setLayout(specific_layout); + QVBoxLayout * main_layout = new QVBoxLayout; main_layout->addWidget(label); QGridLayout *layout = new QGridLayout; @@ -403,6 +424,7 @@ BL::YACSSchemaPage::YACSSchemaPage(QWidget * parent) layout->addWidget(command_env_file_button, 1, 0); layout->addWidget(_line_env_file, 1, 1); main_layout->insertLayout(-1, layout); + main_layout->addWidget(spec_param_box); setLayout(main_layout); }; diff --git a/src/genericgui/BL_CreateJobWizard.hxx b/src/genericgui/BL_CreateJobWizard.hxx index 56b1a15..ded0a2d 100644 --- a/src/genericgui/BL_CreateJobWizard.hxx +++ b/src/genericgui/BL_CreateJobWizard.hxx @@ -60,7 +60,7 @@ namespace BL{ public: // Results std::string job_name; - + std::string yacs_file; std::string command; std::string python_salome_file; @@ -80,16 +80,17 @@ namespace BL{ std::string batch_queue; bool start_job; + int dump_yacs_state; public: - enum {Page_JobName, - Page_YACSSchema, - Page_Command_Main_Definitions, - Page_PythonSalome_Main_Definitions, - Page_BatchParameters, - Page_Files, - Page_Resource, - Page_Conclusion}; + enum {Page_JobName, + Page_YACSSchema, + Page_Command_Main_Definitions, + Page_PythonSalome_Main_Definitions, + Page_BatchParameters, + Page_Files, + Page_Resource, + Page_Conclusion}; }; class JobNamePage: virtual public QWizardPage diff --git a/src/genericgui/BL_JobTab.cxx b/src/genericgui/BL_JobTab.cxx index 14ca50c..335f5d6 100644 --- a/src/genericgui/BL_JobTab.cxx +++ b/src/genericgui/BL_JobTab.cxx @@ -31,9 +31,6 @@ BL::JobTab::JobTab(QWidget *parent, BL::JobsManager_QT * jobs_manager) : QTabWid createJobSummaryTab(); createJobFilesTab(); - - addTab(_summary_tab, "Job Summary"); - addTab(_files_tab, "Job Files"); } BL::JobTab::~JobTab() @@ -70,16 +67,21 @@ BL::JobTab::createJobSummaryTab() QLabel * job_envfile_label = new QLabel("Env File:"); _job_envfile_label_value = new QLabel(""); + + // Specific values + _yacs_dump_state_label = new QLabel("YACS dump state:"); + _yacs_dump_state_value = new QLabel(""); + QGroupBox * main_values_box = new QGroupBox("Main values"); - QFormLayout * values_form = new QFormLayout; - values_form->insertRow(0, job_name_label, _job_name_label_value); - values_form->insertRow(1, job_type_label, _job_type_label_value); - values_form->insertRow(2, job_state_label, _job_state_label_value); - values_form->insertRow(3, job_launcher_label, _job_launcher_label_value); - values_form->insertRow(4, job_resource_label, _job_resource_label_value); - values_form->insertRow(5, job_jobfile_label, _job_jobfile_label_value); - values_form->insertRow(6, job_envfile_label, _job_envfile_label_value); - main_values_box->setLayout(values_form); + _main_values_form = new QFormLayout; + _main_values_form->insertRow(0, job_name_label, _job_name_label_value); + _main_values_form->insertRow(1, job_type_label, _job_type_label_value); + _main_values_form->insertRow(2, job_state_label, _job_state_label_value); + _main_values_form->insertRow(3, job_launcher_label, _job_launcher_label_value); + _main_values_form->insertRow(4, job_resource_label, _job_resource_label_value); + _main_values_form->insertRow(5, job_jobfile_label, _job_jobfile_label_value); + _main_values_form->insertRow(6, job_envfile_label, _job_envfile_label_value); + main_values_box->setLayout(_main_values_form); QLabel * job_nif_label = new QLabel("Number of Input Files:"); _job_nif_label_value = new QLabel(""); @@ -116,13 +118,17 @@ BL::JobTab::createJobSummaryTab() mainLayout->addWidget(main_values_box); mainLayout->addWidget(run_values_box); _summary_tab->setLayout(mainLayout); + + removeTab(0); + insertTab(0, _summary_tab, "Job Summary"); + setCurrentIndex(0); } void BL::JobTab::createJobFilesTab() { _files_tab = new QWidget(this); - + _input_files_list = new QListWidget(this); _input_files_list->setSelectionMode(QAbstractItemView::NoSelection); QGroupBox * input_files_box = new QGroupBox("Input Files"); @@ -141,6 +147,8 @@ BL::JobTab::createJobFilesTab() mainLayout->addWidget(input_files_box); mainLayout->addWidget(output_files_box); _files_tab->setLayout(mainLayout); + + insertTab(1, _files_tab, "Job Files"); } void @@ -153,6 +161,10 @@ BL::JobTab::job_selected(const QModelIndex & index) { BL::Job * job = _jobs_manager->getJob(item_name->text().toStdString()); + // create a new tab + // to be replaced if it is too long + createJobSummaryTab(); + _job_name_label_value->setText(QString(job->getName().c_str())); if (job->getState() == BL::Job::CREATED) @@ -214,6 +226,13 @@ BL::JobTab::job_selected(const QModelIndex & index) _output_files_list->addItem(QString(file.c_str())); } + // Specific parameters management + if (job->getDumpYACSState() > 0) + { + // Add widget in the layout + _yacs_dump_state_value->setText(QVariant(job->getDumpYACSState()).toString()); + _main_values_form->insertRow(7, _yacs_dump_state_label, _yacs_dump_state_value); + } } else DEBTRACE ("itemFromIndex returns 0 !"); @@ -270,4 +289,12 @@ BL::JobTab::reset(QString job_name) _input_files_list->clear(); _output_files_list->clear(); + + // Specific parameters management + DEBTRACE("_yacs_dump_state_value->text():--" << _yacs_dump_state_value->text().toStdString() << "--"); + if (_yacs_dump_state_value->text() != "") + { + _yacs_dump_state_value->setText(""); + createJobSummaryTab(); + } } diff --git a/src/genericgui/BL_JobTab.hxx b/src/genericgui/BL_JobTab.hxx index 14d07fd..72232bf 100644 --- a/src/genericgui/BL_JobTab.hxx +++ b/src/genericgui/BL_JobTab.hxx @@ -50,7 +50,11 @@ namespace BL BL::JobsManager_QT * _jobs_manager; QWidget * _summary_tab; + QWidget * _files_tab; + // Main Values + QGroupBox * _main_values_box; + QFormLayout * _main_values_form; QLabel * _job_name_label_value; QLabel * _job_type_label_value; QLabel * _job_state_label_value; @@ -68,7 +72,9 @@ namespace BL QLabel * _job_em_label_value; QLabel * _job_nop_label_value; - QWidget * _files_tab; + // Specific Values + QLabel * _yacs_dump_state_label; + QLabel * _yacs_dump_state_value; QListWidget * _input_files_list; QListWidget * _output_files_list; diff --git a/src/genericgui/BL_JobsManager_QT.cxx b/src/genericgui/BL_JobsManager_QT.cxx index cf74511..ec742af 100644 --- a/src/genericgui/BL_JobsManager_QT.cxx +++ b/src/genericgui/BL_JobsManager_QT.cxx @@ -253,6 +253,7 @@ BL::JobsManager_QT::create_job_with_wizard(BL::CreateJobWizard & wizard) // YACS schema job new_job->setType(BL::Job::YACS_SCHEMA); new_job->setJobFile(wizard.yacs_file); + new_job->setDumpYACSState(wizard.dump_yacs_state); } else if (wizard.command != "") { -- 2.39.2