Changeset 302 in PSPA
- Timestamp:
- Jan 31, 2013, 10:35:20 AM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/History
r301 r302 5 5 PSPA - Plateforme de simulation en physique des accélérateurs 6 6 ========================================================= 7 8 31 Janvier 2012 Laurent Garnier 9 - dataManager : Suppression des références au workingDir et passage de 10 cette variable dans la classe elle même 11 - GWt_LigneFaisceau : Mise à jour des sections à la fin de l'ajout d'un élément 12 - GWt_pspaApplication : Extraction de l'executeWidget de cette classe 13 - GWt_softwarePanel : Création de cette classe pour gérer l'ancien "executeWidget" 7 14 8 15 30 Janvier 2012 Laurent Garnier -
Interface_Web/trunk/pspaWT/cmt/requirements
r296 r302 48 48 ../sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc \ 49 49 ../sources/userInterface/src/GWt_abstractElementFactory.cc \ 50 ../sources/userInterface/src/GWt_softwarePanel.cc \ 50 51 ../sources/userInterface/src/GWt_draggableImage.cc 51 52 -
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r299 r302 17 17 class dataManager 18 18 { 19 20 elementsCollection elementsGallery_; 21 globalParameters globParam_; 22 particleBeam* currentBeam_; 23 24 vector<particleBeam> diagnosticBeam_; 25 26 vector<sectionToExecute*> jobList_; 27 28 void removeFile(string nameOfFile); 29 void clearSectionToExecute(); 30 public: 31 32 dataManager() {currentBeam_ = NULL;} 33 ~dataManager() { 34 unsigned k; 35 for (k=0; k < jobList_.size();k++) { 36 if ( jobList_[k] != NULL ) delete jobList_[k]; 19 20 elementsCollection elementsGallery_; 21 globalParameters globParam_; 22 particleBeam* currentBeam_; 23 24 vector<particleBeam> diagnosticBeam_; 25 26 vector<sectionToExecute*> jobList_; 27 28 void removeFile(string nameOfFile); 29 void clearSectionToExecute(); 30 public: 31 32 dataManager() { 33 currentBeam_ = NULL; 34 workingDir_=""; 37 35 } 38 if ( currentBeam_ == NULL ) delete currentBeam_; 39 } 40 41 inline int beamLineSize() {return elementsGallery_.size();} 42 inline globalParameters* getGlobalParameters() {return &globParam_;} 43 inline elementsCollection* getCollection() {return &elementsGallery_;} 44 inline particleBeam* getCurrentBeam() {return currentBeam_;} 45 46 particleBeam* getDiagnosticBeam(unsigned index); 47 48 void addSectionToExecute(int debut, int fin, nomDeLogiciel prog); 49 50 abstractElement* addElement(typedElement elemType); 51 void removeElement(string); 52 string getLabelFromElementNumero(int numero); 53 void initializeExecution(string workingDir); 54 trivaluedBool checkExecute(string& diagnostic); 55 trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic); 56 bool executeAll(string workingDir, string& resul); 57 void saveConfiguration(string workingDir, string nameOfFile); 58 bool restoreElements(string workingDir, string inputFileName); 59 void donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor); 60 61 36 ~dataManager() { 37 unsigned k; 38 for (k=0; k < jobList_.size();k++) { 39 if ( jobList_[k] != NULL ) delete jobList_[k]; 40 } 41 if ( currentBeam_ == NULL ) delete currentBeam_; 42 } 43 44 inline int beamLineSize() {return elementsGallery_.size();} 45 inline globalParameters* getGlobalParameters() {return &globParam_;} 46 inline elementsCollection* getCollection() {return &elementsGallery_;} 47 inline particleBeam* getCurrentBeam() {return currentBeam_;} 48 49 particleBeam* getDiagnosticBeam(unsigned index); 50 51 void addSectionToExecute(int debut, int fin, nomDeLogiciel prog); 52 53 abstractElement* addElement(typedElement elemType); 54 void removeElement(string); 55 string getLabelFromElementNumero(int numero); 56 void initializeExecution(); 57 trivaluedBool checkExecute(string& diagnostic); 58 trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic); 59 bool executeAll(string& resul); 60 void saveConfiguration(string nameOfFile); 61 bool restoreElements(string inputFileName); 62 void donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor); 63 inline void setWorkingDir(string wd) { 64 workingDir_ = wd; 65 } 66 67 private: 68 string workingDir_; 62 69 }; 63 70 #endif -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r299 r302 99 99 100 100 101 void dataManager::initializeExecution(string workingDir) 102 { 103 removeFile(workingDir + "parmdesz"); 104 removeFile(workingDir + "parmin"); 105 removeFile(workingDir + "transport.input"); 106 removeFile(workingDir + "transport.output"); 107 diagnosticBeam_.clear(); 108 currentBeam_ = NULL; 109 clearSectionToExecute(); 101 void dataManager::initializeExecution() 102 { 103 if (workingDir_ == "") { 104 return; 105 } 106 removeFile(workingDir_ + "parmdesz"); 107 removeFile(workingDir_ + "parmin"); 108 removeFile(workingDir_ + "transport.input"); 109 removeFile(workingDir_ + "transport.output"); 110 diagnosticBeam_.clear(); 111 currentBeam_ = NULL; 112 clearSectionToExecute(); 110 113 } 111 114 … … 120 123 } 121 124 122 bool dataManager::executeAll(string workingDir, string&resul)125 bool dataManager::executeAll(string &resul) 123 126 { 124 127 bool success = true; … … 145 148 } 146 149 147 success = softw->createInputFile(currentBeam_, debut, fin, workingDir );150 success = softw->createInputFile(currentBeam_, debut, fin, workingDir_); 148 151 if ( !success ) { 149 152 resultatPartiel += " error creating input file \n"; 150 153 } else { 151 success = softw->execute(debut,fin,workingDir ,resultatPartiel);154 success = softw->execute(debut,fin,workingDir_,resultatPartiel); 152 155 if ( success ) { 153 success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir );156 success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir_); 154 157 if ( !success ) { 155 158 resultatPartiel += " readingt results failed \n"; … … 166 169 } 167 170 168 void dataManager::saveConfiguration( string workingDir,string nameOfFile)171 void dataManager::saveConfiguration( string nameOfFile) 169 172 { 170 173 ofstream outfile; 171 string name = workingDir + nameOfFile + ".save";174 string name = workingDir_ + nameOfFile + ".save"; 172 175 outfile.open(name.c_str(), ios::out); 173 176 if (!outfile) { … … 186 189 } 187 190 188 bool dataManager::restoreElements( string workingDir,string inputFileName)191 bool dataManager::restoreElements( string inputFileName) 189 192 { 190 193 cout << "dataManager::restoreElements() fichier " << inputFileName << endl; 191 194 ifstream infile; 192 string name = workingDir + inputFileName + ".save";195 string name = workingDir_ + inputFileName + ".save"; 193 196 infile.open(name.c_str(), ios::in); 194 197 if (!infile) { -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r292 r302 21 21 #include "GWt_console.h" 22 22 #include "GWt_abstractElementFactory.h" 23 #include "GWt_softwarePanel.h" 23 24 24 25 using namespace Wt; … … 29 30 class PspaApplication : public WApplication 30 31 { 31 32 typedef struct { 33 WLineEdit* debut; 34 WLineEdit* fin; 35 WComboBox* selection; 36 WContainerWidget* ligneDeWidget; 37 } GWt_sectionToExecute; 38 32 39 33 private : 40 34 … … 54 48 GWt_dialog* graphicsDialog_; 55 49 56 WPushButton *exec_go_;57 50 WText* probleme_; 58 51 WComboBox* choixElementDessin_; … … 60 53 WComboBox* choixEnveloppeDessin_; 61 54 WContainerWidget* toto_; 62 WContainerWidget* contenuSections_; 63 list<GWt_sectionToExecute*> selectedSections_; 55 GWt_softwarePanel* executeWidget_; 64 56 WFileUpload* uploadFileSelectorWidget_; 65 57 GWt_console* console_; … … 75 67 76 68 void createDragImage(const char *url,const char *smallurl,const char *mimeType,WContainerWidget *p,WString name); 77 void executer();78 69 void sauver(); 79 70 void dialogSaveDone(WDialog::DialogCode code); … … 85 76 void dessiner(); 86 77 87 void addSectionToExecuteW();88 void deleteSectionToExecuteW();89 void checkSectionSelection();90 void disableSectionExecute();91 bool areDataCoherent();92 78 void dialogOnGraphics(); 93 void faireDessin();94 79 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam); 95 80 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam); … … 113 98 // void addConsoleMessage(WString msg); 114 99 115 void updateSelections();116 100 string getSelection(); 101 void faireDessin(); 102 inline WWidget* getGlobalParam() { 103 return globalParam_; 104 }; 105 inline GWt_softwarePanel* getExecuteWidget() { 106 return executeWidget_; 107 }; 108 117 109 inline GWt_abstractElementFactory* getAbstractElementFactory() { 118 110 return abstractElementFactory_; 119 } 111 }; 120 112 }; 121 113 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r301 r302 71 71 } 72 72 manageLineFaisceauLayout(); 73 74 pspa_->updateSelections();75 73 } 76 74 … … 165 163 } 166 164 } 165 pspa_->getExecuteWidget()->updateSelections(); 167 166 } 168 167 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r292 r302 5 5 #include "GWt_pspaApplication.h" 6 6 #include "GWt_ligneFaisceau.h" 7 #include "GWt_softwarePanel.h" 7 8 #include "GWt_globalParameters.h" 8 9 // #include "GWt_dialog.h" … … 17 18 #include "trivaluedBool.h" 18 19 19 #include <Wt/WLineEdit>20 20 #include <Wt/WGridLayout> 21 21 #include <Wt/WVBoxLayout> … … 32 32 #include <Wt/WRasterImage> 33 33 #include <Wt/WScrollArea> 34 #include <Wt/WLineEdit> 34 35 35 36 using namespace Wt::Chart; … … 67 68 useStyleSheet ("htdocs/pspa.css"); 68 69 dtmanage_ = new dataManager(); 69 70 dtmanage_->setWorkingDir(workingDir_); 70 71 /* 71 72 * The main layout is a 3x2 grid layout. … … 159 160 160 161 161 WWidget* executeWidget = createExecuteWidget();162 executeWidget_ = new GWt_softwarePanel(dtmanage_,this); 162 163 163 164 layout->addWidget( globalParam_, 3, 1); 164 165 // layout->addWidget( leDessin_, 3, 2); 165 layout->addWidget( executeWidget , 4, 1);166 layout->addWidget( executeWidget_ , 4, 1); 166 167 //----------- 167 168 … … 226 227 } 227 228 228 WWidget* PspaApplication::createExecuteWidget()229 {230 231 WContainerWidget* executeW = new WContainerWidget();232 executeW->setMaximumSize(600,150);233 executeW->setMinimumSize(600,150);234 235 // bouton execute236 exec_go_ = new WPushButton("execute!");237 // exec_go_->setMinimumSize(300,300);238 exec_go_->setDisabled(true);239 exec_go_->clicked().connect(this, &PspaApplication::executer);240 241 // preparation du bouton add242 WPushButton* exec_add = new WPushButton("add");243 exec_add->clicked().connect(this, &PspaApplication::addSectionToExecuteW);244 245 // preparation du bouton delete246 WPushButton* exec_delete = new WPushButton("delete");247 exec_delete->clicked().connect(this, &PspaApplication::deleteSectionToExecuteW);248 249 // preparation du bouton push_ok250 WPushButton* exec_ok = new WPushButton("check/ok");251 exec_ok->clicked().connect(this, &PspaApplication::checkSectionSelection);252 253 // le panel254 WPanel *panelLogiciels = new WPanel(executeW);255 panelLogiciels->setTitle(" sections of beam Line for executing softwares ");256 257 contenuSections_ = new WContainerWidget();258 contenuSections_->addWidget(exec_add);259 contenuSections_->addWidget(exec_delete);260 contenuSections_->addWidget(exec_ok);261 contenuSections_->addWidget(exec_go_);262 contenuSections_->addWidget(new WBreak());263 contenuSections_->addWidget(new WBreak());264 addSectionToExecuteW();265 266 panelLogiciels->setCentralWidget(contenuSections_);267 return executeW;268 }269 229 270 230 void PspaApplication::dialogOnGraphics() … … 330 290 } 331 291 332 void PspaApplication::addSectionToExecuteW() 333 { 334 335 disableSectionExecute(); 336 337 string premierText, dernierText; 338 if(selectedSections_.size() == 0) 339 { 340 premierText = dtmanage_->getLabelFromElementNumero(1); 341 342 dernierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize()); 343 } 344 else 345 { 346 dernierText = selectedSections_.back()->fin->text().toUTF8(); 347 int dernierNumero = dtmanage_->getCollection()->getNumeroFromLabel(dernierText); 348 dernierNumero++; 349 if ( dernierNumero <= dtmanage_->beamLineSize() ) 350 { 351 premierText = dtmanage_->getLabelFromElementNumero(dernierNumero); 352 } 353 else 354 { 355 premierText = dtmanage_->getLabelFromElementNumero(dtmanage_->beamLineSize()); 356 } 357 dernierText = premierText; 358 } 359 360 // cout << "PspaApplication::addSectionToExecute() : " << premierText << " Ã " << dernierText << endl; 361 362 WContainerWidget* newSection = new WContainerWidget; 363 364 selectedSections_.push_back(new GWt_sectionToExecute); 365 selectedSections_.back()->debut = new WLineEdit(); 366 selectedSections_.back()->debut->setDisabled(true); 367 selectedSections_.back()->debut->setText(premierText); 368 selectedSections_.back()->fin = new WLineEdit(); 369 selectedSections_.back()->fin->changed().connect(this,&PspaApplication::disableSectionExecute); 370 selectedSections_.back()->fin->setText(dernierText); 371 selectedSections_.back()->selection = new WComboBox(); 372 selectedSections_.back()->ligneDeWidget = newSection; 373 newSection->addWidget(new WText(" from : ")); 374 newSection->addWidget(selectedSections_.back()->debut); 375 newSection->addWidget(new WText(" to : ")); 376 newSection->addWidget(selectedSections_.back()->fin); 377 newSection->addWidget(selectedSections_.back()->selection); 378 379 contenuSections_->addWidget(newSection); 380 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 381 unsigned k; 382 for(k = 0; k < nb; k++) { 383 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString()); 384 } 385 } 386 387 void PspaApplication::disableSectionExecute() 388 { 389 exec_go_->setDisabled(true); 390 } 391 392 void PspaApplication::checkSectionSelection() 393 { 394 if ( selectedSections_.empty() ) return; 395 396 // traitement de la premiere ligne 397 // on impose le depart du calcul au premier element 398 string premier = dtmanage_->getLabelFromElementNumero(1); 399 (*selectedSections_.begin())->debut->setText(premier); 400 401 string currentString = (*selectedSections_.begin())->fin->text().toUTF8(); 402 int current = dtmanage_->getCollection()->getNumeroFromLabel( currentString); 403 404 cout << " numero " << current << endl; 405 // si la fin est mal definie on prend toute la config par defaut 406 if ( current <= 0 || current > dtmanage_->beamLineSize() ) 407 { 408 current = dtmanage_->beamLineSize(); 409 currentString = dtmanage_->getLabelFromElementNumero(current); 410 (*selectedSections_.begin())->fin->setText(currentString); 411 } 412 current++; 413 currentString = dtmanage_->getLabelFromElementNumero(current); 414 415 // traitement des suivantes (on avance d'un cran dans la liste) 416 list<GWt_sectionToExecute*>::iterator itr, itr0; 417 itr0 = selectedSections_.begin(); 418 itr0++; 419 for (itr = itr0; itr != selectedSections_.end(); itr++) 420 { 421 // debut 422 if ( current >= dtmanage_->beamLineSize() ) 423 { 424 // GWt_tools::addConsoleMessage(" bad section definition ! \n "); 425 GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error,true,true); 426 warningDialog.exec(); 427 return; 428 } 429 430 (*itr)->debut->setText(currentString); 431 // fin 432 string finString = (*itr)->fin->text().toUTF8(); 433 434 int numeroFin = dtmanage_->getCollection()->getNumeroFromLabel( finString); 435 436 if ( numeroFin <= current || numeroFin > dtmanage_->beamLineSize()) 437 { 438 // GWt_tools::addConsoleMessage(" bad section definition ! \n "); 439 GWt_dialog warningDialog("PSPA : Vérification des sections", " bad section definition !", GWt_dialog::Error, true,true); 440 warningDialog.exec(); 441 return; 442 } 443 444 // preparation de la ligne suivante 445 current = numeroFin +1; 446 currentString = dtmanage_->getLabelFromElementNumero(current); 447 } 448 449 if (!areDataCoherent()) { 450 GWt_dialog warningDialog("PSPA : Vérification des sections", " donnees incoherentes !", GWt_dialog::Error,true,true); 451 warningDialog.exec(); 452 } 453 else 454 { 455 exec_go_->setDisabled(false); 456 } 457 } 458 459 bool PspaApplication::areDataCoherent() 460 { 461 bool caMarche = true; 462 dtmanage_->initializeExecution(workingDir_); 463 464 list<GWt_sectionToExecute*>::iterator itr; 465 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 466 { 467 string debString = (*itr)->debut->text().toUTF8(); 468 string finString = (*itr)->fin->text().toUTF8(); 469 470 471 int debut = dtmanage_->getCollection()->getNumeroFromLabel(debString); 472 int fin = dtmanage_->getCollection()->getNumeroFromLabel(finString); 473 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 474 dtmanage_->addSectionToExecute(debut,fin,prog); 475 } 476 477 string diagnostic; 478 trivaluedBool essai = dtmanage_->checkExecute(diagnostic); 479 cout << " retour verif , essai = " << essai << endl; 480 if ( essai == error ) { 481 cout << " appli : erreur " << endl; 482 caMarche = false; 483 GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true); 484 calculDialog.exec(); 485 } else if ( essai == warning ) { 486 cout << " appli : warnig " << endl; 487 caMarche = true; 488 GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true); 489 calculDialog.exec(); 490 } 491 492 return caMarche; 493 } 494 495 void PspaApplication::deleteSectionToExecuteW() 496 { 497 if ( selectedSections_.empty() ) return; 498 disableSectionExecute(); 499 selectedSections_.back()->ligneDeWidget->clear(); 500 delete selectedSections_.back()->ligneDeWidget; 501 selectedSections_.pop_back(); 502 } 503 504 void PspaApplication::executer() 505 { 506 console_->addConsoleMessage(string("on va peut etre y arriver")); 507 508 509 static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals(); 510 511 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); 512 calculDialog.show(); 513 514 processEvents(); 515 516 string resultat; 517 if ( !dtmanage_->executeAll(workingDir_, resultat)) { 518 GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true); 519 warningDialog.exec(); 520 } 521 // cout << " PspaApplication : retour d'execution resultat = " << resultat << endl; 522 console_->addConsoleMessage(resultat); 523 // cout << " PspaApplication : affichage console termine " << endl; 524 525 exec_go_->setDisabled(true); 526 527 calculDialog.hide(); 528 529 faireDessin(); 530 } 292 293 531 294 532 295 void PspaApplication::sauver() … … 558 321 bibi->updateGlobals(); 559 322 // dtmanage_->saveConfiguration(nameOfCase_); 560 dtmanage_->saveConfiguration( workingDir_ ,nameOfCase_);323 dtmanage_->saveConfiguration( nameOfCase_); 561 324 } 562 325 … … 588 351 dialogSave_ = NULL; 589 352 590 bool test = dtmanage_->restoreElements( workingDir_,nameOfCase_);353 bool test = dtmanage_->restoreElements(nameOfCase_); 591 354 if ( !test ) { 592 355 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); … … 649 412 console_->addConsoleMessage(string("restauration...")); 650 413 651 if ( !dtmanage_->restoreElements( workingDir_,uploadFileSelectorWidget_->spoolFileName()) ) {414 if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) { 652 415 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 653 416 restoreWarning.exec(); … … 996 759 } 997 760 998 void PspaApplication::updateSelections() 999 { 1000 string premierText, dernierText; 1001 if ( selectedSections_.size() > 0 ) 1002 { 1003 premierText = dtmanage_->getLabelFromElementNumero(1); 1004 dernierText = dtmanage_->getLabelFromElementNumero( dtmanage_->beamLineSize() ); 1005 (*selectedSections_.begin())->debut->setText(premierText); 1006 (*selectedSections_.begin())->fin->setText(dernierText); 1007 } 1008 1009 cout << "PspaApplication::updateSelections(): " << premierText << " Ã " << dernierText << endl; 1010 } 1011 1012 string PspaApplication::getSelection() 1013 { 1014 list<GWt_sectionToExecute*>::iterator itr = selectedSections_.begin(); 1015 string str = (*itr)->fin->text().toUTF8(); 1016 return str; 1017 } 761 1018 762 1019 763 WText* PspaApplication::createTitle(const WString& title)
Note: See TracChangeset
for help on using the changeset viewer.