]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
Adding dump yacs state option
authorribes <ribes>
Thu, 28 Apr 2011 11:35:31 +0000 (11:35 +0000)
committerribes <ribes>
Thu, 28 Apr 2011 11:35:31 +0000 (11:35 +0000)
src/engine/BL_Job.cxx
src/engine/BL_Job.hxx
src/engine/BL_SALOMEServices.cxx
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_CreateJobWizard.hxx
src/genericgui/BL_JobTab.cxx
src/genericgui/BL_JobTab.hxx
src/genericgui/BL_JobsManager_QT.cxx

index 6cf4c84c1c1365d2f93578945eab002cf5321536..2e5c22a576e506118f6c3c357697aa7d7f37981f 100644 (file)
@@ -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)
 {
index 210ee0faab7b767b984221602b1bc7e62e43bffd..7d39dcca09bf4526ef111c122c38e62d6b1f9cbe 100644 (file)
@@ -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;
 
index 24ffcb069138b9259ea23790cbbc3e21768d9dd4..64568318e7b0a7a92075b85a96e5882ff4de9ddc 100644 (file)
@@ -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") {}
index d87215c655c0b23687b57ee78ab407e187453474..4420c445bdfe3f4406751d7df4500c8af637bd8f 100644 (file)
@@ -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);
 };
 
index 56b1a15751112638acca7b2b02adce8b832880d0..ded0a2d29de4acd27e6619e96221974ea064310d 100644 (file)
@@ -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
index 14ca50cc24daddb441e0011f3e56384cb5cd64ce..335f5d62e1c1da48ea3ba0d293b3fc5ed3488270 100644 (file)
@@ -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();
+  }
 }
index 14d07fd2d137bd3976e48e484ca7672b5af262df..72232bfce6469b24ae4c4385a45c24c309cf3823 100644 (file)
@@ -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;
index cf745110f4b9eb30aa7a97d610a362c80a61cada..ec742af18ed6849bc55c3d3542950ce8e837f9f4 100644 (file)
@@ -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 != "")
   {