Version: 9.16.0
YACS::HMI::BatchJobsListDialog Class Reference

#include <ListJobs_GUI.hxx>

Inheritance diagram for YACS::HMI::BatchJobsListDialog:
Collaboration diagram for YACS::HMI::BatchJobsListDialog:

Public Member Functions

 BatchJobsListDialog (QString title, GenericGui *genericGui)
 
virtual ~BatchJobsListDialog ()
 

Protected Attributes

QTimer * _timer1
 
QTimer * _timer2
 
QPushButton * _ok
 
QTableWidget * _table
 
QString _jobFile
 
QString _dumpStateFile
 
QString _filteredJobFile
 
QString _filteredDumpStateFile
 
QString _hostname
 
long _id
 
Engines::SalomeLauncher_var _salome_launcher
 
GenericGui_genericGui
 
YACS::ENGINE::Proc_proc
 

Private Slots

void userOK ()
 
void userCancel ()
 
void userCell (QTableWidgetItem *cell)
 
void build_table ()
 
void get_dump_file ()
 

Private Member Functions

QWidgetbuild_buttons ()
 
void getSalomeLauncher ()
 
void filterJobFile ()
 
void filterDumpStateFile ()
 

Detailed Description

Definition at line 54 of file ListJobs_GUI.hxx.

Constructor & Destructor Documentation

◆ BatchJobsListDialog()

BatchJobsListDialog::BatchJobsListDialog ( QString  title,
GenericGui genericGui 
)

Definition at line 43 of file ListJobs_GUI.cxx.

43 : QWidget(),_genericGui(genericGui),_proc(NULL) {
44
45 setWindowTitle(title);
46
47 // Connection to Salome Launcher
49
50 // Add a layout
51 QBoxLayout* box = new QBoxLayout(QBoxLayout::TopToBottom, this);
52 setLayout(box);
53
54 _table = new QTableWidget(this);
55 _table->setColumnCount(4);
56
58
59 // Add table
60 box->addWidget(_table);
61
62 // Add buttons
63 QWidget* buttons = build_buttons();
64 box->addWidget(buttons);
65
66 // No line selected
67 _ok->setEnabled(false);
68 _id = -1;
69
70 // Set timer to refresh table
71 _timer1 = new QTimer(this);
72 connect(_timer1, SIGNAL(timeout()), this, SLOT(build_table()));
73 _timer1->start(30000);
74
75}
YACS::ENGINE::Proc * _proc

References _id, _ok, _table, _timer1, gui.GraphViewer::box, build_buttons(), build_table(), and getSalomeLauncher().

◆ ~BatchJobsListDialog()

BatchJobsListDialog::~BatchJobsListDialog ( )
virtual

Definition at line 77 of file ListJobs_GUI.cxx.

77 {
78}

Member Function Documentation

◆ build_buttons()

QWidget * BatchJobsListDialog::build_buttons ( )
private

Definition at line 148 of file ListJobs_GUI.cxx.

148 {
149 _ok = new QPushButton("OK" , this);
150 QPushButton* cancel = new QPushButton("Cancel", this);
151
152 connect(_ok , SIGNAL(clicked()), this, SLOT(userOK ()));
153 connect(cancel, SIGNAL(clicked()), this, SLOT(userCancel()));
154
155 QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, this);
156
157 layout->addWidget(_ok);
158 layout->addWidget(cancel);
159
160 QWidget* buttons = new QWidget(this);
161 buttons->setLayout(layout);
162
163 return(buttons);
164}

References _ok, userCancel(), and userOK().

Referenced by BatchJobsListDialog().

◆ build_table

void BatchJobsListDialog::build_table ( )
privateslot

Definition at line 91 of file ListJobs_GUI.cxx.

91 {
92
93 int irow = 0;
94
95 _table->clear();
96
97 Engines::JobsList* joblist = _salome_launcher->getJobsList();
98
99 int nblines = joblist->length();
100 _table->setRowCount(nblines);
101
102 QStringList titres;
103 titres << "Job Name" << "State" << "Resource" << "Launcher Id";
104 _table->setHorizontalHeaderLabels(titres);
105
106 for(int i=0;i<nblines;i++){
107 Engines::JobDescription descr = (*joblist)[i];
108 string jobType = CORBA::string_dup(descr.job_parameters.job_type);
109 // We display only jobs of type yacs_file
110 if(jobType.find("yacs_file")!=string::npos){
111 long jobId = descr.job_id;
112 ostringstream sstId;
113 sstId << jobId;
114 string jobName = CORBA::string_dup(descr.job_parameters.job_name);
115 string jobState = _salome_launcher->getJobState(jobId);
116 string jobMachine = CORBA::string_dup(descr.job_parameters.resource_required.name);
117 QTableWidgetItem* item0 = new QTableWidgetItem(jobName.c_str() , type_job);
118 QTableWidgetItem* item1 = new QTableWidgetItem(jobState.c_str() , type_state);
119 QTableWidgetItem* item2 = new QTableWidgetItem(jobMachine.c_str() , type_res );
120 QTableWidgetItem* item3 = new QTableWidgetItem(sstId.str().c_str(), type_id );
121 _table->setItem(irow, 0, item0);
122 _table->setItem(irow, 1, item1);
123 _table->setItem(irow, 2, item2);
124 _table->setItem(irow, 3, item3);
125 if(jobState != "RUNNING"){
126 item0->setFlags(Qt::NoItemFlags);
127 item1->setFlags(Qt::NoItemFlags);
128 item2->setFlags(Qt::NoItemFlags);
129 item3->setFlags(Qt::NoItemFlags);
130 }
131 else if(jobId == _id){
132 item0->setSelected(true);
133 item1->setSelected(true);
134 item2->setSelected(true);
135 item3->setSelected(true);
136 }
137 irow++;
138 }
139 }
140
141 connect(_table, SIGNAL( itemClicked(QTableWidgetItem*) ), this, SLOT( userCell(QTableWidgetItem*) ));
142
143}
#define type_id
#define type_job
#define type_state
#define type_res
void userCell(QTableWidgetItem *cell)
Engines::SalomeLauncher_var _salome_launcher

References _id, _salome_launcher, _table, yacsorb.CORBAEngineTest::i, type_id, type_job, type_res, type_state, and userCell().

Referenced by BatchJobsListDialog().

◆ filterDumpStateFile()

void BatchJobsListDialog::filterDumpStateFile ( )
private

Definition at line 301 of file ListJobs_GUI.cxx.

302{
303 string buffer;
304 _filteredDumpStateFile = QString("/tmp/%1/filtered_%2.xml").arg(getenv("USER")).arg(QFileInfo(_dumpStateFile).baseName());
305 ifstream infile(_dumpStateFile.toStdString().c_str());
306 if(!infile){
307 string errmsg = "File " + _dumpStateFile.toStdString() + " doesn't exist!!";
308 throw YACS::Exception(errmsg);
309 }
310 ofstream outfile(_filteredDumpStateFile.toStdString().c_str());
311 if(!outfile){
312 string errmsg = "Impossible to create the file " + _filteredDumpStateFile.toStdString() + "!!";
313 throw YACS::Exception(errmsg);
314 }
315 // replace objref by string in dump state file
316 while( !infile.eof() ){
317 getline(infile,buffer);
318 size_t pos = buffer.find("objref");
319 while(pos != string::npos){
320 buffer.replace(pos,6,"string");
321 pos = buffer.find("objref");
322 }
323 outfile << buffer << endl;
324 }
325}

References _dumpStateFile, and _filteredDumpStateFile.

Referenced by get_dump_file().

◆ filterJobFile()

void BatchJobsListDialog::filterJobFile ( )
private

Definition at line 256 of file ListJobs_GUI.cxx.

257{
258 _filteredJobFile = QString("/tmp/%1/%2.xml").arg(getenv("USER")).arg(QFileInfo(_jobFile).baseName());
259 // reading input file
260 ifstream infile(_jobFile.toStdString().c_str());
261 if(!infile){
262 string errmsg = "File " + _jobFile.toStdString() + " doesn't exist!!";
263 throw YACS::Exception(errmsg);
264 }
265 string buffer;
266 vector<string> objref;
267 while( !infile.eof() ){
268 getline(infile,buffer);
269 // look for objref and memorize them in vector
270 if( (buffer.find("objref") != string::npos) && (buffer.find("IDL") != string::npos) ){
271 size_t pos1 = buffer.find("\"");
272 size_t pos2 = buffer.find("\"",pos1+1);
273 objref.push_back(buffer.substr(pos1+1,pos2-pos1-1));
274 }
275 }
276 infile.close();
277 // reread the input file
278 infile.open(_jobFile.toStdString().c_str());
279 // open the output file
280 ofstream outfile(_filteredJobFile.toStdString().c_str());
281 if(!outfile){
282 string errmsg = "Impossible to create the file " + _filteredJobFile.toStdString() + "!!";
283 throw YACS::Exception(errmsg);
284 }
285 while( !infile.eof() ){
286 getline(infile,buffer);
287 // replace objref by string
288 if( ((buffer.find("objref") == string::npos) || (buffer.find("IDL") == string::npos)) && (buffer.find("/objref") == string::npos) ){
289 string tmp = buffer;
290 for(int i=0;i<objref.size();i++){
291 size_t pos = buffer.find(objref[i]);
292 if(pos != string::npos)
293 tmp = buffer.substr(0,pos) + "string" + buffer.substr(pos+objref[i].size());
294 }
295 outfile << tmp << endl;
296 }
297 }
298}

References _filteredJobFile, _jobFile, and yacsorb.CORBAEngineTest::i.

Referenced by userOK().

◆ get_dump_file

void BatchJobsListDialog::get_dump_file ( )
privateslot

Definition at line 234 of file ListJobs_GUI.cxx.

235{
236 int execState = YACS::NOTYETINITIALIZED;
237 // get batch job state
238 string jobState = _salome_launcher->getJobState(_id);
239 // get dump state remote file
240 bool ret = _salome_launcher->getJobDumpState(_id, QFileInfo(_dumpStateFile).absolutePath().toLatin1().constData());
241 if(ret){
242 // replace objref by string in dump state file
244 // parse dump state file and load proc
246 // display remote graph states
248 execState = executor->updateSchema(jobState);
249 }
250 // stop timer if job is not running
251 if((execState!=YACS::RUNNING)&&(execState!=YACS::NOTYETINITIALIZED))
252 _timer2->stop();
253}
YACS::ExecutorState updateSchema(std::string jobState)
static QtGuiContext * getQtCurrent()
YACS::HMI::GuiExecutor * getGuiExecutor()
YACSLOADER_EXPORT void loadState(YACS::ENGINE::Proc *p, const std::string &xmlStateFile)
Load state from a file into a Proc.
Definition: LoadState.cxx:950
@ RUNNING
Definition: define.hxx:67
@ NOTYETINITIALIZED
Definition: define.hxx:65

References _dumpStateFile, _filteredDumpStateFile, _id, _proc, _salome_launcher, _timer2, filterDumpStateFile(), YACS::HMI::QtGuiContext::getGuiExecutor(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::ENGINE::loadState(), YACS::NOTYETINITIALIZED, YACS::RUNNING, and YACS::HMI::GuiExecutor::updateSchema().

Referenced by userOK().

◆ getSalomeLauncher()

void BatchJobsListDialog::getSalomeLauncher ( )
private

Definition at line 80 of file ListJobs_GUI.cxx.

80 {
82 CORBA::ORB_ptr orb = runTime->getOrb();
84 CORBA::Object_var obj = NS.Resolve("/SalomeLauncher");
85 _salome_launcher = Engines::SalomeLauncher::_narrow(obj);
86 if (CORBA::is_nil(_salome_launcher))
87 throw YACS::Exception("Salome Launcher not reachable!!");
88}
CORBA::Object_ptr Resolve(const char *Path) override
CORBA::ORB_ptr getOrb() const
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()
CORBA::ORB_ptr orb
Definition: yacsSrv.cxx:39

References _salome_launcher, YACS::ENGINE::RuntimeSALOME::getOrb(), YACS::ENGINE::getSALOMERuntime(), orb, and SALOME_NamingService_Wrapper::Resolve().

Referenced by BatchJobsListDialog().

◆ userCancel

void BatchJobsListDialog::userCancel ( )
privateslot

Definition at line 227 of file ListJobs_GUI.cxx.

227 {
228 _timer1->stop();
229 hide();
230}

References _timer1.

Referenced by build_buttons().

◆ userCell

void BatchJobsListDialog::userCell ( QTableWidgetItem *  cell)
privateslot

Definition at line 169 of file ListJobs_GUI.cxx.

169 {
170 if ( cell->flags() ) {
171 int line = cell->row();
172 string sid = _table->item(line,3)->text().toStdString();
173 _id = atoi(sid.c_str());
174 _ok->setEnabled(true);
175
176 QTableWidget* table = cell->tableWidget();
177 for (int c=0; c<4; c++) {
178 QTableWidgetItem* it = table->item(line, c);
179 it->setSelected(true);
180 };
181 };
182}

References _id, _ok, _table, and gui.CONNECTOR::c.

Referenced by build_table().

◆ userOK

void BatchJobsListDialog::userOK ( )
privateslot

Definition at line 187 of file ListJobs_GUI.cxx.

187 {
188
189 // get job file name
190 Engines::JobParameters* jobParam = _salome_launcher->getJobParameters(_id);
191 _jobFile = CORBA::string_dup(jobParam->job_file);
192 _dumpStateFile = QString("/tmp/%1/dumpState_%2.xml").arg(getenv("USER")).arg(QFileInfo(_jobFile).baseName());
193
194 // stop first timer and hide window
195 _timer1->stop();
196 hide();
197
198 // replace objref by string in YACS schema job file to avoid trying to reach remote objects
200
201 // display yacs graph
203 _proc = loader->load(_filteredJobFile.toLatin1());
204 if (!_proc) {
205 QMessageBox msgBox(QMessageBox::Critical, "Import Batch Schema, native YACS XML format",
206 "The xml graph has not the native YACS XML format or is not readable." );
207 msgBox.exec();
208 }
209 else {
210 YACS::ENGINE::Logger* logger= _proc->getLogger("parser");
211 if(!logger->isEmpty()) {
212 DEBTRACE(logger->getStr());
213 };
215 };
216
217 // start second timer to get remote graph state xml file
218 _timer2 = new QTimer(this);
219 connect(_timer2, SIGNAL(timeout()), this, SLOT(get_dump_file()));
220 _timer2->start(30000);
222}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
Class for logging error messages.
Definition: Logger.hxx:38
virtual bool isEmpty()
Definition: Logger.cxx:96
virtual std::string getStr()
Definition: Logger.cxx:85
virtual Logger * getLogger(const std::string &name)
Definition: Proc.cxx:431
void createContext(YACS::ENGINE::Proc *proc, const QString &schemaName, const QString &runName, bool forEdition)
YACSGuiLoader * getLoader()
Definition: GenericGui.hxx:87
YACS::YACSLoader::YACSLoader * loader
Definition: yacs_clt.cxx:31

References _dumpStateFile, _filteredJobFile, _genericGui, _id, _jobFile, _proc, _salome_launcher, _timer1, _timer2, YACS::HMI::GenericGui::createContext(), DEBTRACE, filterJobFile(), get_dump_file(), YACS::HMI::GenericGui::getLoader(), YACS::ENGINE::Proc::getLogger(), YACS::ENGINE::Logger::getStr(), YACS::ENGINE::Logger::isEmpty(), and loader.

Referenced by build_buttons().

Member Data Documentation

◆ _dumpStateFile

QString YACS::HMI::BatchJobsListDialog::_dumpStateFile
protected

Definition at line 79 of file ListJobs_GUI.hxx.

Referenced by filterDumpStateFile(), get_dump_file(), and userOK().

◆ _filteredDumpStateFile

QString YACS::HMI::BatchJobsListDialog::_filteredDumpStateFile
protected

Definition at line 81 of file ListJobs_GUI.hxx.

Referenced by filterDumpStateFile(), and get_dump_file().

◆ _filteredJobFile

QString YACS::HMI::BatchJobsListDialog::_filteredJobFile
protected

Definition at line 80 of file ListJobs_GUI.hxx.

Referenced by filterJobFile(), and userOK().

◆ _genericGui

GenericGui* YACS::HMI::BatchJobsListDialog::_genericGui
protected

Definition at line 85 of file ListJobs_GUI.hxx.

Referenced by userOK().

◆ _hostname

QString YACS::HMI::BatchJobsListDialog::_hostname
protected

Definition at line 82 of file ListJobs_GUI.hxx.

◆ _id

long YACS::HMI::BatchJobsListDialog::_id
protected

Definition at line 83 of file ListJobs_GUI.hxx.

Referenced by BatchJobsListDialog(), build_table(), get_dump_file(), userCell(), and userOK().

◆ _jobFile

QString YACS::HMI::BatchJobsListDialog::_jobFile
protected

Definition at line 78 of file ListJobs_GUI.hxx.

Referenced by filterJobFile(), and userOK().

◆ _ok

QPushButton* YACS::HMI::BatchJobsListDialog::_ok
protected

Definition at line 76 of file ListJobs_GUI.hxx.

Referenced by BatchJobsListDialog(), build_buttons(), and userCell().

◆ _proc

YACS::ENGINE::Proc* YACS::HMI::BatchJobsListDialog::_proc
protected

Definition at line 86 of file ListJobs_GUI.hxx.

Referenced by get_dump_file(), and userOK().

◆ _salome_launcher

Engines::SalomeLauncher_var YACS::HMI::BatchJobsListDialog::_salome_launcher
protected

Definition at line 84 of file ListJobs_GUI.hxx.

Referenced by build_table(), get_dump_file(), getSalomeLauncher(), and userOK().

◆ _table

QTableWidget* YACS::HMI::BatchJobsListDialog::_table
protected

Definition at line 77 of file ListJobs_GUI.hxx.

Referenced by BatchJobsListDialog(), build_table(), and userCell().

◆ _timer1

QTimer* YACS::HMI::BatchJobsListDialog::_timer1
protected

Definition at line 75 of file ListJobs_GUI.hxx.

Referenced by BatchJobsListDialog(), userCancel(), and userOK().

◆ _timer2

QTimer * YACS::HMI::BatchJobsListDialog::_timer2
protected

Definition at line 75 of file ListJobs_GUI.hxx.

Referenced by get_dump_file(), and userOK().


The documentation for this class was generated from the following files: