Changeset 112 in PSPA for Interface_Web/trunk
- Timestamp:
- Nov 28, 2012, 4:24:04 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc
r106 r112 1 2 #include <iostream> 1 3 2 4 #include "GWt_LigneFaisceau.h" … … 6 8 #include "GWt_soleno.h" 7 9 #include "GWt_bend.h" 8 #include <iostream>9 #include "nomdElements.h"10 11 10 12 11 #include <Wt/WComboBox> 13 12 #include <Wt/WVBoxLayout> 14 15 13 16 14 GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) : pspa_(ps) … … 19 17 decorationStyle().setBackgroundColor (WColor("orange")); 20 18 setLayout(beamLayout_); 19 20 int k; 21 for(k = 0; k < nElements; k++) nObjets_[k]= new Compteur(); 21 22 22 23 acceptDrops("icons/beam.jpg"); … … 36 37 abstractElement* newDrift = pspa_->getDataManager()->addElement(drift); 37 38 GWt_drift* gdrift = new GWt_drift(pspa_,newDrift, evt.mimeType()); 39 gdrift->setLabel(nObjets_[drift]->incr()); 38 40 wc= gdrift->getWidget(); 39 41 } … … 43 45 abstractElement* newInitialBeam = pspa_->getDataManager()->addElement(initialBeam); 44 46 GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,newInitialBeam, evt.mimeType()); 47 gwInitialBeam->setLabel(nObjets_[initialBeam]->incr()); 45 48 wc= gwInitialBeam->getWidget(); 46 49 } … … 50 53 abstractElement* newCell = pspa_->getDataManager()->addElement(cell); 51 54 GWt_cell* gwCell = new GWt_cell(pspa_,newCell, evt.mimeType()); 55 gwCell->setLabel(nObjets_[cell]->incr()); 52 56 wc= gwCell->getWidget(); 53 57 } … … 57 61 abstractElement* newSoleno = pspa_->getDataManager()->addElement(soleno); 58 62 GWt_soleno* gwSoleno = new GWt_soleno(pspa_,newSoleno, evt.mimeType()); 63 gwSoleno->setLabel(nObjets_[soleno]->incr()); 59 64 wc= gwSoleno->getWidget(); 60 65 } … … 64 69 abstractElement* newBend = pspa_->getDataManager()->addElement(bend); 65 70 GWt_bend* gwBend = new GWt_bend(pspa_,newBend, evt.mimeType()); 71 gwBend->setLabel(nObjets_[bend]->incr()); 66 72 wc= gwBend->getWidget(); 67 73 } … … 76 82 // pourVoir 77 83 int nElts= pspa_->getDataManager()->beamLineSize(); 78 cout << " pourVoir:: nElts= " << nElts << endl;84 cout << "GWt_LigneFaisceau:: nElts= " << nElts << endl; 79 85 unsigned int k; 80 86 for(k = 0; k < (unsigned)nElts; k++) { 81 87 abstractElement* ptr= pspa_->getDataManager()->getCollection()->getElementPointer(k); 82 88 string label= ptr->getLabel(); 83 cout << " pourVoir:: " << label << " a été ajouté" << endl;89 cout << "GWt_LigneFaisceau:: " << label << " dans la liste" << endl; 84 90 } 85 91 … … 88 94 void GWt_LigneFaisceau::restoreElementCollection() 89 95 { 96 beamLayout_->clear(); 97 unsigned int k; 98 for(k = 0; k < nElements; k++) delete nObjets_[k]; 99 for(k = 0; k < nElements; k++) nObjets_[k]= new Compteur(); 90 100 int nbElem = pspa_->getDataManager()->beamLineSize(); 91 unsigned int k; 92 beamLayout_->clear(); 93 for ( k=0; k < (unsigned)nbElem; k++) 94 { 95 abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k); 96 nomdElement nom = ptr->getName(); 97 switch (nom) 98 { 99 case initialBeam : 100 { 101 GWt_initialBeam* gwInitialBeam = new GWt_initialBeam(pspa_,ptr, string("icons/beam.jpg")); 102 beamLayout_->addWidget(gwInitialBeam->getButton()); 103 break; 104 } 105 case drift : 106 { 107 GWt_drift* gdrift = new GWt_drift(pspa_,ptr, string("icons/drift.jpg")); 108 beamLayout_->addWidget(gdrift->getButton()); 109 break; 110 } 111 case cell : 112 { 113 GWt_cell* gwCell = new GWt_cell(pspa_,ptr, string("icons/cell.jpg")); 114 beamLayout_->addWidget(gwCell->getButton()); 115 break; 116 } 117 118 case soleno : 119 { 120 GWt_soleno* gwSoleno = new GWt_soleno(pspa_,ptr, string("icons/lens.jpg")); 121 beamLayout_->addWidget(gwSoleno->getButton()); 122 break; 123 } 124 case bend : 125 { 126 GWt_bend* gwBend = new GWt_bend(pspa_,ptr, string("icons/bend.jpg")); 127 beamLayout_->addWidget(gwBend->getButton()); 128 break; 129 } 130 default : 131 { 132 cerr << " GWt_LigneFaisceau element type " << nom << " inconnu " << endl; 133 break; 134 } 135 } 136 137 } 138 101 102 for(k = 0; k < (unsigned)nbElem; k++) { 103 abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k); 104 nomdElement nom = ptr->getName(); 105 switch (nom) { 106 case initialBeam : 107 { 108 GWt_initialBeam* gw = new GWt_initialBeam(pspa_,ptr,string("icons/beam.jpg")); 109 gw->setLabel(nObjets_[initialBeam]->incr()); 110 beamLayout_->addWidget(gw->getWidget()); 111 break; 112 } 113 case drift : 114 { 115 GWt_drift* gw = new GWt_drift(pspa_,ptr,string("icons/drift.jpg")); 116 gw->setLabel(nObjets_[drift]->incr()); 117 beamLayout_->addWidget(gw->getWidget()); 118 break; 119 } 120 case cell : 121 { 122 GWt_cell* gw = new GWt_cell(pspa_,ptr,string("icons/cell.jpg")); 123 gw->setLabel(nObjets_[cell]->incr()); 124 beamLayout_->addWidget(gw->getWidget()); 125 break; 126 } 127 case soleno : 128 { 129 GWt_soleno* gw = new GWt_soleno(pspa_,ptr,string("icons/lens.jpg")); 130 gw->setLabel(nObjets_[soleno]->incr()); 131 beamLayout_->addWidget(gw->getWidget()); 132 break; 133 } 134 case bend : 135 { 136 GWt_bend* gw = new GWt_bend(pspa_,ptr,string("icons/bend.jpg")); 137 gw->setLabel(nObjets_[bend]->incr()); 138 beamLayout_->addWidget(gw->getWidget()); 139 break; 140 } 141 default : 142 { 143 cerr << "GWt_LigneFaisceau::restaure element type " << nom << " inconnu " << endl; 144 break; 145 } 146 } 147 } 139 148 } -
Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc
r106 r112 6 6 GWt_abstractElement::GWt_abstractElement(PspaApplication* ps,abstractElement* elem,string image) 7 7 { 8 cout << "GWt_abstractElement::GWt_abstractElement()" << endl; 9 8 10 pspa_ = ps; 9 11 pspa_->updateSelections(); … … 23 25 } 24 26 25 void GWt_abstractElement::setLabel( abstractElement* elem,int n)27 void GWt_abstractElement::setLabel(int n) 26 28 { 27 29 string str; 28 30 if(n < 10) { 29 str= elem ->getNameOfElement()+"0"+mixedTools::intToString(n);31 str= element_->getNameOfElement()+"0"+mixedTools::intToString(n); 30 32 } else { 31 str= elem ->getNameOfElement()+mixedTools::intToString(n);33 str= element_->getNameOfElement()+mixedTools::intToString(n); 32 34 } 33 cout << " GWt_abstractElement::label= " << str << endl;35 cout << "2-GWt_abstractElement::label= " << str << endl; 34 36 35 elem ->setLabel(str);37 element_->setLabel(str); 36 38 37 39 WText *item = new WText(str); … … 52 54 cout << "GWt_abstractElement:: " << label << " a été supprimé" << endl; 53 55 pspa_->getDataManager()->getCollection()->eraseElement(label); 54 56 pspa_->updateSelections(); 55 57 } 56 58 -
Interface_Web/trunk/pspaWT/src/GWt_bend.cc
r106 r112 8 8 #include <Wt/WPushButton> 9 9 10 int GWt_bend::nObjets_= 0;11 12 10 GWt_bend::GWt_bend(PspaApplication* ps,abstractElement* elem,string image) : GWt_abstractElement(ps,elem,image) 13 11 { 14 nObjets_++;15 setLabel(elem,nObjets_);16 17 12 string* param = element_-> getParametersString(); 18 13 if ( param == NULL ) -
Interface_Web/trunk/pspaWT/src/GWt_cell.cc
r106 r112 9 9 #include <Wt/WPanel> 10 10 11 int GWt_cell::nObjets_= 0;12 13 11 GWt_cell::GWt_cell(PspaApplication* ps,abstractElement* elem,string image) : GWt_abstractElement(ps,elem,image) 14 12 { 15 nObjets_++;16 setLabel(elem,nObjets_);17 18 13 string* param = element_-> getParametersString(); 19 14 if ( param == NULL ) { -
Interface_Web/trunk/pspaWT/src/GWt_drift.cc
r106 r112 8 8 #include <Wt/WPushButton> 9 9 10 int GWt_drift::nObjets_= 0;11 12 10 GWt_drift::GWt_drift(PspaApplication* ps,abstractElement* elem,string image) : GWt_abstractElement(ps,elem,image) 13 11 { 14 nObjets_++;15 setLabel(elem,nObjets_);16 //string str = elem->getNameOfElement()+mixedTools::intToString(nObjets_);17 //cout << "GWt_drift::label= " << str << endl;18 //WText *item = new WText(str);19 //wc_->addWidget(item);20 21 12 string* param = element_-> getParametersString(); 22 13 if ( param == NULL ) -
Interface_Web/trunk/pspaWT/src/GWt_initialBeam.cc
r106 r112 7 7 #include <Wt/WPushButton> 8 8 9 int GWt_initialBeam::nObjets_= 0;10 11 9 GWt_initialBeam::GWt_initialBeam(PspaApplication* ps,abstractElement* elem,string image) : GWt_abstractElement(ps,elem,image) 12 10 { 13 nObjets_++;14 setLabel(elem,nObjets_);15 16 11 string* param = element_-> getParametersString(); 17 12 if ( param == NULL ) -
Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc
r111 r112 156 156 WWidget* PspaApplication::createExecuteWidget() 157 157 { 158 cout << "PspaApplication::createExecuteWidget()" << endl; 159 158 160 WContainerWidget* executeW = new WContainerWidget(); 159 161 executeW->setMaximumSize(600,150); … … 165 167 exec_go_->setDisabled(true); 166 168 exec_go_->clicked().connect(this, &PspaApplication::executer); 169 167 170 // preparation du bouton add 168 171 WPushButton* exec_add = new WPushButton("add"); … … 186 189 panelLogiciels->setTitle(" sections of beam Line for executing softwares "); 187 190 188 contenuSections_ = new WContainerWidget(); 189 190 contenuSections_->addWidget( exec_add); 191 contenuSections_->addWidget( exec_delete); 192 contenuSections_->addWidget( exec_ok); 191 contenuSections_ = new WContainerWidget(); 192 contenuSections_->addWidget(exec_add); 193 contenuSections_->addWidget(exec_delete); 194 contenuSections_->addWidget(exec_ok); 193 195 contenuSections_->addWidget(exec_go_); 194 196 contenuSections_->addWidget(probleme_); … … 203 205 void PspaApplication::addSectionToExecuteW() 204 206 { 205 unsigned k; 207 cout << "PspaApplication::addSectionToExecute() : " << selectedSections_.size() << endl; 208 209 disableSectionExecute(); 210 206 211 string premierText, dernierText; 207 208 disableSectionExecute(); 209 210 211 if ( selectedSections_.size() == 0) 212 if(selectedSections_.size() == 0) 212 213 { 213 214 premierText = "1"; … … 230 231 } 231 232 } 232 233 234 cout << "PspaApplication::addSectionToExecute() : " << premierText << ",Ã " << dernierText << endl; 233 235 234 236 WContainerWidget* newSection = new WContainerWidget; … … 238 240 selectedSections_.back()->debut->setDisabled(true); 239 241 selectedSections_.back()->debut->setText(premierText); 240 241 242 selectedSections_.back()->fin = new WLineEdit(); 242 selectedSections_.back()->fin->changed().connect(this, &PspaApplication::disableSectionExecute); 243 243 selectedSections_.back()->fin->changed().connect(this,&PspaApplication::disableSectionExecute); 244 244 selectedSections_.back()->fin->setText(dernierText); 245 245 selectedSections_.back()->selection = new WComboBox(); 246 247 246 selectedSections_.back()->ligneDeWidget = newSection; 248 249 250 // contenuSections_->addWidget(new WText(" from : "));251 // contenuSections_->addWidget(selectedSections_.back()->debut);252 // contenuSections_->addWidget(new WText(" to : "));253 // contenuSections_->addWidget(selectedSections_.back()->fin);254 // contenuSections_->addWidget(selectedSections_.back()->selection);255 256 // newSection->addWidget(new WBreak());257 247 newSection->addWidget(new WText(" from : ")); 258 248 newSection->addWidget(selectedSections_.back()->debut); … … 261 251 newSection->addWidget(selectedSections_.back()->selection); 262 252 263 264 contenuSections_->addWidget(newSection); 265 266 253 contenuSections_->addWidget(newSection); 267 254 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 268 for ( k=0; k < nb; k++) selectedSections_.back()->selection->addItem( nomDeLogiciel(k).getString() ); 255 unsigned k; 256 for(k = 0; k < nb; k++) { 257 selectedSections_.back()->selection->addItem(nomDeLogiciel(k).getString()); 258 } 269 259 } 270 260 271 261 void PspaApplication::disableSectionExecute() 272 262 { 273 263 exec_go_->setDisabled(true); 274 264 } 275 265 … … 291 281 currentString = mixedTools::intToString(current); 292 282 293 294 283 // traitement des suivantes (on avance d'un cran dans la liste) 295 284 list<GWt_sectionToExecute*>::iterator itr, itr0; 296 itr0 = selectedSections_.begin();285 itr0 = selectedSections_.begin(); 297 286 itr0++; 298 for (itr= itr0; itr != selectedSections_.end(); itr++) 299 { 300 // string debString = (*itr)->debut->text().toUTF8(); 287 for (itr = itr0; itr != selectedSections_.end(); itr++) 288 { 301 289 // debut 302 (*itr)->debut->setText( currentString);290 (*itr)->debut->setText(currentString); 303 291 // fin 304 292 string finString = (*itr)->fin->text().toUTF8(); 305 293 if ( atoi(finString.c_str() ) < current) 306 294 { 307 (*itr)->fin->setText( currentString);295 (*itr)->fin->setText(currentString); 308 296 } 309 297 … … 314 302 currentString = mixedTools::intToString(current); 315 303 } 304 316 305 if (!areDataCoherent()) probleme_->setHidden(false); 317 306 else … … 321 310 } 322 311 } 312 323 313 bool PspaApplication::areDataCoherent() 324 314 { 325 326 bool caMarche=true; 327 int debut, fin; 328 nomDeLogiciel prog; 329 315 bool caMarche = true; 330 316 dtmanage_->initializeExecution(); 317 331 318 list<GWt_sectionToExecute*>::iterator itr; 332 for (itr= selectedSections_.begin(); itr != selectedSections_.end(); itr++)319 for(itr = selectedSections_.begin(); itr != selectedSections_.end(); itr++) 333 320 { 334 321 string debString = (*itr)->debut->text().toUTF8(); 335 322 string finString = (*itr)->fin->text().toUTF8(); 336 debut = atoi( debString.c_str() ); 337 fin = atoi( finString.c_str() ); 338 prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 339 dtmanage_->addSectionToExecute(debut, fin, prog); 340 } 323 int debut = atoi(debString.c_str()); 324 int fin = atoi(finString.c_str()); 325 nomDeLogiciel prog = nomDeLogiciel ( (*itr)->selection->currentIndex() ); 326 dtmanage_->addSectionToExecute(debut,fin,prog); 327 } 328 341 329 string diagnostic = dtmanage_->checkExecute(); 342 330 if ( !diagnostic.empty() ) … … 346 334 } 347 335 348 349 350 // int debut, fin;351 // nomDeLogiciel prog;352 // list<GWt_sectionToExecute*>::iterator itr;353 // for (itr= selectedSections_.begin(); itr != selectedSections_.end(); itr++)354 // {355 // string debString = (*itr)->debut->text().toUTF8();356 // string finString = (*itr)->fin->text().toUTF8();357 // debut = atoi( debString.c_str() );358 // fin = atoi( finString.c_str() );359 // prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );360 // if ( prog == nomDeLogiciel::parmela )361 // {362 // }363 // else if ( prog == nomDeLogiciel::transport )364 // {365 // string diagnostic = dtmanage_->checkExecuteTransport( debut, fin);366 // if ( !diagnostic.empty() )367 // {368 // caMarche = false;369 // addConsoleMessage(diagnostic.c_str());370 // }371 // }372 // else373 // {374 // caMarche = false;375 // addConsoleMessage(" unknown software -- STOP ");376 // }377 // }378 336 return caMarche; 379 380 337 } 381 338 … … 389 346 } 390 347 391 392 393 394 348 void PspaApplication::executer() 395 349 { … … 397 351 static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals(); 398 352 399 // int debut, fin;400 // nomDeLogiciel prog;401 // // dtmanage_->clearSectionToExecute();402 // dtmanage_->initializeExecution();403 // list<GWt_sectionToExecute*>::iterator itr;404 // for (itr= selectedSections_.begin(); itr != selectedSections_.end(); itr++)405 // {406 // string debString = (*itr)->debut->text().toUTF8();407 // string finString = (*itr)->fin->text().toUTF8();408 // debut = atoi( debString.c_str() );409 // fin = atoi( finString.c_str() );410 // prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );411 // dtmanage_->addSectionToExecute(debut, fin, prog);412 // }413 353 string resultat; 414 354 if ( !dtmanage_->executeAll(resultat)) probleme_->setHidden(false); … … 419 359 } 420 360 421 // void PspaApplication::executer()422 // {423 // addConsoleMessage(string("on va peut etre y arriver"));424 // static_cast<GWt_globalParameters*>(globalParam_)->updateGlobals();425 426 // int debut, fin;427 // nomDeLogiciel prog;428 // list<GWt_sectionToExecute*>::iterator itr;429 // dtmanage_->initializeExecution();430 // for (itr= selectedSections_.begin(); itr != selectedSections_.end(); itr++)431 // {432 // string debString = (*itr)->debut->text().toUTF8();433 // string finString = (*itr)->fin->text().toUTF8();434 // debut = atoi( debString.c_str() );435 // fin = atoi( finString.c_str() );436 // prog = nomDeLogiciel ( (*itr)->selection->currentIndex() );437 // cout << " PspaApplication::executer() on lance l'execution de : " << prog.getString() << endl;438 // string resul;439 // if ( prog == nomDeLogiciel::parmela )440 // {441 // resul = dtmanage_->executeParmela( debut, fin);442 // faireDessinParmela();443 // addConsoleMessage(resul);444 // }445 // else if ( prog == nomDeLogiciel::transport )446 // {447 448 // // if ( !dtmanage_->getCurrentBeam().momentRepresentationOk() )449 // // {450 // // addConsoleMessage(" the beam is not OK for transport");451 // // probleme_->setHidden(false);452 // // return;453 // // }454 455 456 // resul = dtmanage_->executeTransport( debut, fin);457 // faireDessinTransport();458 // addConsoleMessage(resul);459 // }460 // else461 // {462 // resul = " unknown software -- STOP \n ";463 // addConsoleMessage(resul);464 // break;465 // }466 // }467 // }468 469 470 361 void PspaApplication::sauver() 471 362 { … … 480 371 void PspaApplication::restaurer() 481 372 { 482 483 373 addConsoleMessage(string("restauration...")); 484 374 … … 489 379 490 380 GWt_LigneFaisceau* bobo = static_cast<GWt_LigneFaisceau*>(beamLine_); 491 492 381 bobo->restoreElementCollection(); 382 493 383 addConsoleMessage(string("...terminee")); 494 384 } … … 609 499 (*selectedSections_.begin())->fin->setText(dernierText); 610 500 } 501 502 cout << "PspaApplication::updateSelections(): " << premierText << ",Ã " << dernierText << endl; 611 503 } 612 504 -
Interface_Web/trunk/pspaWT/src/GWt_soleno.cc
r106 r112 7 7 #include <Wt/WPushButton> 8 8 9 int GWt_soleno::nObjets_= 0;10 11 9 GWt_soleno::GWt_soleno(PspaApplication* ps,abstractElement* elem,string image) : GWt_abstractElement(ps,elem,image) 12 10 { 13 nObjets_++;14 setLabel(elem,nObjets_);15 16 11 string* param = element_-> getParametersString(); 17 12 if ( param == NULL ) -
Interface_Web/trunk/pspaWT/src/dataManager.cc
r111 r112 5 5 #include <fstream> 6 6 7 //using namespace std;8 9 7 abstractElement* dataManager::addElement(nomdElement elemType) 10 8 { … … 12 10 } 13 11 14 15 16 17 18 19 20 12 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog) 13 { 14 jobList_.push_back(new sectionToExecute); 15 jobList_.back()->firstElement = debut; 16 jobList_.back()->lastElement = fin; 17 jobList_.back()->software = prog; 18 } 21 19 22 20 void dataManager::clearSectionToExecute() 23 21 { 24 22 unsigned k; 25 for (k=0; k < jobList_.size();k++)23 for(k = 0; k < jobList_.size(); k++) 26 24 { 27 25 if ( jobList_[k] != NULL ) delete jobList_[k]; … … 32 30 string dataManager::checkExecute() 33 31 { 32 cout << "dataManager::checkExecute()" << endl; 33 34 34 int k,j; 35 35 string diagnostic; 36 36 int indexDeb, indexFin; 37 cout << " controle execution : " << endl; 38 for ( k=0; k< jobList_.size(); k++) 37 cout << "controle execution : " << endl; 38 for(k = 0; k < jobList_.size(); k++) { 39 indexDeb = jobList_[k]->firstElement; 40 indexFin = jobList_[k]->lastElement; 41 indexDeb--; 42 indexFin--; 43 abstractElement* elPtr; 44 if(jobList_[k]->software == nomDeLogiciel::parmela ) 39 45 { 40 indexDeb = jobList_[k]->firstElement; 41 indexFin = jobList_[k]->lastElement; 42 indexDeb--; 43 indexFin--; 44 abstractElement* elPtr; 45 if ( jobList_[k]->software == nomDeLogiciel::parmela ) 46 { 47 for ( j=indexDeb; j <= indexFin; j++) 48 { 49 elPtr = elementsGallery_.getElementPointer(j); 50 if ( !elPtr->is_parmela_element() ) 51 { 52 diagnostic += " the element " + elPtr->getNameString() + " is not allowed for PARMELA \n"; 53 } 54 } 46 for(j = indexDeb; j <= indexFin; j++) { 47 elPtr = elementsGallery_.getElementPointer(j); 48 49 cout << "elPtr parmela: " << elPtr->getLabel() << endl; 50 51 if(!elPtr->is_parmela_element()) { 52 diagnostic += " the element " + elPtr->getNameString() + " is not allowed for PARMELA \n"; 55 53 } 56 else if ( jobList_[k]->software == nomDeLogiciel::transport ) 57 { 58 for ( j=indexDeb; j <= indexFin; j++) 59 { 60 elPtr = elementsGallery_.getElementPointer(j); 61 if ( !elPtr->is_transport_element() ) 62 { 63 diagnostic += " the element " + elPtr->getNameString() + " is not allowed for TRANSPORT \n"; 64 } 65 } 54 } 55 } 56 else if (jobList_[k]->software == nomDeLogiciel::transport) 57 { 58 for(j = indexDeb; j <= indexFin; j++) { 59 elPtr = elementsGallery_.getElementPointer(j); 60 61 cout << "elPtr transp: " << elPtr->getLabel() << endl; 62 63 if (!elPtr->is_transport_element()) { 64 diagnostic += " the element " + elPtr->getNameString() + " is not allowed for TRANSPORT \n"; 66 65 } 67 else 68 { 69 diagnostic += (jobList_[k]->software).getString() + " : unknown software \n "; 70 } 71 } 66 } 67 } 68 else 69 { 70 diagnostic += (jobList_[k]->software).getString() + " : unknown software \n "; 71 } 72 } 73 72 74 return diagnostic; 73 75 } … … 155 157 } 156 158 157 158 bool dataManager::executeParmela( unsigned int indexDeb, unsigned int indexFin, string& resul) 159 bool dataManager::executeParmela(unsigned int indexDeb,unsigned int indexFin,string& resul) 159 160 { 160 161 bool success = true; 161 162 resul.clear(); 162 createInputFileParmela(indexDeb, 163 createInputFileParmela(indexDeb,indexFin); 163 164 164 165 ostringstream sortie; … … 171 172 cout << " job parmela= " << parmelaJob << endl; 172 173 FILE* pp = popen(parmelaJob.c_str(), "r"); 173 if (pp != NULL) 174 { 175 cout << " execution parmela MARCHE " << endl; 176 while (fgets(buf, sizeof buf, pp)) 177 { 178 sortie << buf; 179 } 180 181 // cout << " sortie parmela " << sortie.str() << endl; 182 string::size_type nn = (sortie.str()).find("normal"); 183 if ( nn == string::npos ) 184 { 185 sortie << " abnormal exit of parmela " << endl; 186 resul = sortie.str(); 187 success = false; 188 return success; 189 } 190 191 currentBeam_.setFromParmela(globParam_.getFrequency()); 192 pclose(pp); 193 resul = sortie.str(); 194 } 195 else 196 { 197 sortie << " launching of parmela failed " << endl; 198 resul = sortie.str(); 199 success = false; 200 } 201 174 if (pp != NULL) { 175 cout << " execution parmela MARCHE " << endl; 176 while (fgets(buf, sizeof buf, pp)) 177 { 178 sortie << buf; 179 } 180 181 // cout << " sortie parmela " << sortie.str() << endl; 182 string::size_type nn = (sortie.str()).find("normal"); 183 if ( nn == string::npos ) 184 { 185 sortie << " abnormal exit of parmela " << endl; 186 resul = sortie.str(); 187 success = false; 188 return success; 189 } 190 191 currentBeam_.setFromParmela(globParam_.getFrequency()); 192 pclose(pp); 193 resul = sortie.str(); 194 } else { 195 sortie << " launching of parmela failed " << endl; 196 resul = sortie.str(); 197 success = false; 198 } 202 199 return success; 203 200 } 204 205 201 206 202 bool dataManager::createInputFileTransport( unsigned int indexDeb, unsigned int indexFin) … … 273 269 indexFin--; 274 270 275 276 277 278 271 ofstream outfile; 279 272 string name = WORKINGAREA + "parmin"; 280 273 outfile.open(name.c_str(), ios::out); 281 if (!outfile) 282 { 283 cerr << " error opening output stream " << name << endl; 284 } 274 if (!outfile) { 275 cerr << " error opening output stream " << name << endl; 276 } 277 278 abstractElement* elPtr; 279 elPtr = elementsGallery_.getElementPointer(indexDeb); 280 if ( elPtr->getName() != initialBeam ) { 281 cerr << " dataManager::createInputFileParmela : the first element should be initialBeam" << endl; 282 } 283 285 284 unsigned int k; 286 abstractElement* elPtr;287 288 elPtr = elementsGallery_.getElementPointer(indexDeb);289 if ( elPtr->getName() != initialBeam )290 {291 cerr << " dataManager::createInputFileParmela : the first element should be initialBeam" << endl;292 }293 294 295 285 double initalKineticEnergy = 0.0; 296 for ( k =indexDeb; k <= indexFin; k++)286 for ( k = indexDeb; k <= indexFin; k++) 297 287 { 298 288 if ( elPtr->getName() == initialBeam ) … … 310 300 outfile << "OUTPUT 0" << endl; 311 301 312 for ( k =indexDeb; k <= indexFin; k++)302 for ( k = indexDeb; k <= indexFin; k++) 313 303 { 314 304 elPtr = elementsGallery_.getElementPointer(k); 315 305 outfile << elPtr->parmelaOutputFlow() << endl; 316 306 } 307 317 308 outfile << "ZOUT" << endl; 318 309 outfile << "START /wt=0.0 /dwt=" << globParam_.getIntegrationStep() << " /nsteps=" << globParam_.getNbSteps() << " nsc=" << globParam_.getScPeriod() << " /nout=10" << endl; … … 336 327 string completeName = WORKINGAREA + nameOfFile; 337 328 fileExists.open(completeName.c_str(), ios::in); 338 if (fileExists) 339 { 340 fileExists.close(); 341 remove(completeName.c_str()); 342 } 343 } 344 345 bool dataManager::executeAll(string &resul) 346 { 347 unsigned k; 348 int debut, fin; 349 bool success = true; 350 string resultatPartiel; 351 resul.clear(); 352 for ( k=0; k< jobList_.size(); k++) 353 { 354 debut = jobList_[k]->firstElement; 355 fin = jobList_[k]->lastElement; 356 resultatPartiel.clear(); 357 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl; 358 if ( jobList_[k]->software == nomDeLogiciel::parmela ) 359 { 360 success = executeParmela( debut, fin, resultatPartiel); 361 } 362 else if ( jobList_[k]->software == nomDeLogiciel::transport ) 363 { 364 success = executeTransport( debut, fin, resultatPartiel); 365 // cout << " retour transport success = " << success << " listing= " << resul << endl; 366 } 367 else 368 { 369 success = false; 370 resultatPartiel = " unknown software -- STOP \n "; 371 break; 372 } 373 resul += resultatPartiel; 374 if ( !success ) break;; 375 } 376 return success; 377 } 378 379 380 void dataManager::saveAll() 381 { 382 ofstream outfile; 383 string name = WORKINGAREA + "pspa.save"; 329 if (fileExists) { 330 fileExists.close(); 331 remove(completeName.c_str()); 332 } 333 } 334 335 bool dataManager::executeAll(string &resul) 336 { 337 bool success = true; 338 resul.clear(); 339 string resultatPartiel; 340 unsigned k; 341 for(k = 0; k < jobList_.size(); k++) 342 { 343 int debut = jobList_[k]->firstElement; 344 int fin = jobList_[k]->lastElement; 345 resultatPartiel.clear(); 346 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl; 347 348 if(jobList_[k]->software == nomDeLogiciel::parmela) { 349 success = executeParmela( debut, fin, resultatPartiel); 350 } else if (jobList_[k]->software == nomDeLogiciel::transport) { 351 success = executeTransport( debut, fin, resultatPartiel); 352 } else { 353 success = false; 354 resultatPartiel = " unknown software -- STOP \n "; 355 break; 356 } 357 resul += resultatPartiel; 358 if ( !success ) break; 359 } 360 return success; 361 } 362 363 void dataManager::saveAll() 364 { 365 ofstream outfile; 366 string name = WORKINGAREA + "pspa.save"; 384 367 outfile.open(name.c_str(), ios::out); 385 if (!outfile)386 { 387 cerr << " error opening output file for persistency " << name << endl; 388 } 368 if (!outfile) { 369 cerr << " error opening output file for persistency " << name << endl; 370 } 371 389 372 outfile << globParam_.FileOutputFlow(); 390 373 int k; … … 395 378 outfile << elPtr->FileOutputFlow(); 396 379 } 397 outfile.close(); 398 } 399 400 void dataManager::restoreElements() 401 { 402 ifstream infile; 403 string name = WORKINGAREA + "pspa.save"; 404 infile.open(name.c_str(), ios::in); 405 if (!infile) 406 { 407 cerr << " error opening input stream " << name << endl; 408 } 409 int ielem; 410 411 string globalTitle; 412 if ( infile >> globalTitle ) 413 { 414 if ( globalTitle == string("globals") ) 415 { 416 globParam_.raz(); 417 globParam_.FileInput(infile); 418 } 419 else 420 { 421 cerr << " dataManager::restoreAll ERROR : global parameters seems to be missing" << endl; 422 } 423 } 424 else 425 { 426 cerr << " dataManager::restoreAll ERROR : reading data save file" << endl; 427 } 428 elementsGallery_.raz(); 429 nomdElement elem; 430 while (infile >> ielem) 431 { 432 elem = (nomdElement)ielem; 433 abstractElement* nouveau = addElement(elem); 434 nouveau->FileInput(infile); 435 } 436 437 438 infile.close(); 439 } 380 outfile.close(); 381 } 382 383 void dataManager::restoreElements() 384 { 385 cout << "dataManager::restoreElements()" << endl; 386 387 ifstream infile; 388 string name = WORKINGAREA + "pspa.save"; 389 infile.open(name.c_str(), ios::in); 390 if (!infile) { 391 cerr << " error opening input stream " << name << endl; 392 } 393 394 int ielem; 395 string globalTitle; 396 if ( infile >> globalTitle ) { 397 if ( globalTitle == string("globals") ) { 398 globParam_.raz(); 399 globParam_.FileInput(infile); 400 } else { 401 cerr << " dataManager::restoreAll ERROR : global parameters seems to be missing" << endl; 402 } 403 } else { 404 cerr << " dataManager::restoreAll ERROR : reading data save file" << endl; 405 } 406 407 elementsGallery_.raz(); 408 nomdElement elem; 409 while (infile >> ielem) { 410 elem = (nomdElement)ielem; 411 abstractElement* nouveau = addElement(elem); 412 nouveau->FileInput(infile); 413 } 414 infile.close(); 415 416 // debug 417 int k; 418 for(k = 0; k < elementsGallery_.size(); k++) { 419 abstractElement* ptr= elementsGallery_.getElementPointer(k); 420 cout << "reupere " << ptr->getLabel() << endl; 421 } 422 } 423
Note: See TracChangeset
for help on using the changeset viewer.