Changeset 455 in PSPA for Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
- Timestamp:
- Dec 16, 2013, 5:16:54 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r449 r455 8 8 #include "GWt_pspaApplication.h" 9 9 #include "GWt_console.h" 10 11 #include "softwareParmela.h" 12 #include "softwareTransport.h" 13 #include "softwareGenerator.h" 14 #include "softwareGenerator.h" 15 #include "softwareUsersprogram.h" 16 #include "softwareTest.h" 17 #include "softwareMadx.h" //xx 18 #include "softwareUnknown.h" //xx 10 #include "GWt_ligneFaisceau.h" // FIXME to be removed ! 19 11 20 12 #include <boost/filesystem.hpp> … … 46 38 } 47 39 48 string dataManager::getLabelFromElementNumero(int numero) 49 { 50 abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(numero-1); 40 string dataManager::getLabelFromElementNumero_deprecated(int numero) 41 { 42 /* 43 abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(numero-1); 51 44 if ( ptr == NULL ) return ""; 52 45 return ptr->getLabel(); 53 } 54 55 int dataManager::getNumeroFromElementLabel(string label) 56 { 57 int index = -1; 46 */ 47 return ""; 48 } 49 50 int dataManager::getNumeroFromElementLabel_deprecated(string label) 51 { 52 /* int index = -1; 58 53 for (int k = 0; k < getBeamLineSize() ; k++) { 59 54 if (pspa_->getBeamLine()->getAbstractElement(k) != NULL) { … … 66 61 } 67 62 return index; 68 } 69 70 abstractElement* dataManager::getElementPointerFromNumero(int k) 71 { 72 return pspa_->getBeamLine()->getAbstractElement(k-1); 73 } 74 75 sectionToExecute* dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, nomDeLogiciel logiciel) 76 { 77 #if BAVARD > 0 78 cout << "***********************************" << endl; 79 cout << " dataManager::addSectionToExecute " << endl << endl; 80 #endif 81 82 abstractSoftware* prog; 83 string inputFileName; 84 if(logiciel == nomDeLogiciel::parmela) { 85 inputFileName = "parmin"; 86 prog = new softwareParmela(inputFileName, &globParam_, this); 87 } else if (logiciel == nomDeLogiciel::transport) { 88 inputFileName = "transport.input"; 89 prog = new softwareTransport(inputFileName, &globParam_, this); 90 } else if (logiciel == nomDeLogiciel::generator) { 91 inputFileName = "generator.in"; 92 prog = new softwareGenerator(inputFileName, &globParam_, this); 93 } else if (logiciel == nomDeLogiciel::madx) { 94 inputFileName = "madx.input"; 95 prog = new softwareMadx(inputFileName,§orParam_,this); 96 } else if (logiciel == nomDeLogiciel::usersprogram) { 97 inputFileName = "dummy"; 98 prog = new softwareUsersprogram(inputFileName, &globParam_, this); 99 } else if (logiciel == nomDeLogiciel::test) { 100 prog = new softwareTest(inputFileName, &globParam_, this); 101 } else { 102 prog = new softwareUnknown(); // xx 103 } 104 105 jobList_.push_back(new sectionToExecute(debut,debutIndex,fin,finIndex,prog)); 106 return jobList_.back(); 107 } 108 109 void dataManager::clearSectionToExecute() 110 { 111 unsigned k; 112 for(k = 0; k < jobList_.size(); k++) 113 { 114 if ( jobList_[k] != NULL ) clearSectionToExecute(k); 115 } 116 jobList_.clear(); 117 } 118 119 void dataManager::clearSectionToExecute(int a) 120 { 121 cout << " dataManager::clearSectionToExecute : effacement de la section d'index = " << a << endl; 122 if (a < 0) return; 123 if (a >= (int)jobList_.size()) return; 124 125 // lors de la creation de la section on a fait un 'new' d'un 126 // softwareXXXX : on fait ici le 'delete' 127 128 const abstractSoftware* soft = jobList_.at(a)->getSoftware(); 129 if ( soft != NULL ) delete soft; 130 jobList_.erase (jobList_.begin()+a); 131 } 63 */ 64 return 0; 65 } 66 132 67 133 68 void dataManager::initializeExecution() … … 148 83 indexElementToIndexDiag_.clear(); 149 84 currentBeam_ = NULL; 150 f irstComputedElemNumero_ = getBeamLineSize();151 lastComputedElemNumero_ = 1;152 clearSectionToExecute();85 for (unsigned int a=0; a< jobList_.size(); a++) { 86 jobList_[a]->clearSectionToExecute(); 87 } 153 88 } 154 89 … … 171 106 172 107 bool success = true; 173 abstractSoftware* softw = NULL;174 108 string workingDir = pspa_->getWorkingDir(); 175 109 176 // on verifie la consecution des sections 177 int lastel = 0;110 111 // Main loop ! 178 112 for(unsigned k = 0; k < jobList_.size(); k++) { 179 if ( jobList_[k]->getElementNumberInSection() != lastel +1 ) { 180 consoleMessage("dataManager::executeAll ERROR : sections should be consecutive "); 181 return false; 182 } else { 183 lastel = jobList_[k]->getLastElementNumberInSection(); 184 } 185 } 186 187 unsigned debut; 188 unsigned fin; 189 for(unsigned k = 0; k < jobList_.size(); k++) { 190 191 #if BAVARD > 0 113 sector* sector = jobList_[k]; 114 115 // for the moment, we put everything in one line without loops 116 for (unsigned int l=0; l <sector->getSectionsToExecute().size(); l++) { 117 sectionToExecute* section = sector->getSectionsToExecute()[l]; 118 abstractSoftware* softw = section->getSoftware(); 119 120 #if BAVARD > 0 192 121 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl; 193 122 #endif 194 195 debut = jobList_[k]->getElementNumberInSection(); 196 fin = jobList_[k]->getLastElementNumberInSection(); 197 softw = jobList_[k]->getSoftware(); 198 199 //cout << "k= " << k << ", de " << jobList_[k]->getFirstElement()->getLabel() << " à " << jobList_[k]->getLastElement()->getLabel() << " avec " << softw->getName() << endl; 200 123 124 //cout << "k= " << k << ", de " << jobList_[k]->getFirstElement()->getLabel() << " à " << jobList_[k]->getLastElement()->getLabel() << " avec " << softw->getName() << endl; 125 201 126 if (softw == NULL) { 202 127 success = false; … … 205 130 } 206 131 207 success = softw->createInputFile(currentBeam_, debut,fin,workingDir);132 success = softw->createInputFile(currentBeam_,workingDir); 208 133 if ( success ) { 209 134 success = softw->execute(workingDir); … … 222 147 if ( !success ) break; 223 148 224 if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut; 225 if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin; 226 227 #if BAVARD > 0 228 cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; 229 cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; 230 for (unsigned j = debut; j <= fin; j++) { 231 abstractElement* elPtr= getElementPointerFromNumero(j); 232 cout << "[" << j << "] " << elPtr->getNomdElement().getExpandedName() << endl; 233 } 149 #if BAVARD > 0 150 cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; 151 cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; 152 std::vector< abstractElement* > elements = section->getElements(); 153 for (unsigned j = 0; j < elements.size(); j++) { 154 cout << "[" << j << "] " << elements[j]->getNomdElement().getExpandedName() << endl; 155 } 234 156 #endif 235 157 } //l 236 158 } //k 237 159 // if ( currentBeam_ ) { … … 241 163 // currentBeam_->readFromAMLFile(aml_file); 242 164 // } 243 cout << " dataManager::executeAll() : premier element = " << firstComputedElemNumero_ << " dernier = " << lastComputedElemNumero_<< endl;165 cout << " dataManager::executeAll() " << endl; 244 166 245 167 return success; … … 264 186 265 187 outfile << globParam_.FileOutputFlow(); 266 outfile << sectorParam_.FileOutputFlow(); 267 188 189 // FIXME Francois: Comment sauver la configuration des section ? 190 for (unsigned int a=0; a< jobList_.size(); a++) { 191 outfile << jobList_[a]->getSectorParameters().FileOutputFlow(); 192 } 193 // END 194 268 195 abstractElement* elPtr; 269 for(int k = 0; k < getBeamLineSize() ; k++) 270 { 271 elPtr = pspa_->getBeamLine()->getAbstractElement(k); 272 outfile << elPtr->FileOutputFlow(); 273 } 196 for (unsigned k = 0; k < jobList_.size(); k++) { 197 sector* sector = jobList_[k]; 198 for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { 199 sectionToExecute* section = sector->getSectionsToExecute()[l]; 200 for (unsigned m = 0; m < section->getElements().size(); m++) { 201 elPtr = section->getElements()[m]; 202 outfile << elPtr->FileOutputFlow(); 203 } 204 } 205 } 274 206 outfile.close(); 275 207 } … … 300 232 301 233 abstractElement* elPtr; 302 for(int k = 0; k < getBeamLineSize() ; k++) { 303 elPtr = pspa_->getBeamLine()->getAbstractElement(k); 304 elPtr->InputRep(sect); 305 } 306 234 for (unsigned k = 0; k < jobList_.size(); k++) { 235 sector* sector = jobList_[k]; 236 for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { 237 sectionToExecute* section = sector->getSectionsToExecute()[l]; 238 for (unsigned m = 0; m < section->getElements().size(); m++) { 239 elPtr = section->getElements()[m]; 240 elPtr->InputRep(sect); 241 } 242 } 243 } 307 244 cout << "!Create the AML file ---------------------------" << endl; 308 245 AMLReader reader; … … 335 272 globParam_.FileInput(infile); 336 273 } else if (elementLabel == string("sectors") ) { 337 sectorParam_.raz(); 338 sectorParam_.FileInput(infile); 274 // FIXME Francois !!!!!!! 275 // sectorParam_.raz(); 276 // sectorParam_.FileInput(infile); 277 // END 339 278 } else { 340 279 elementType = nomdElements::getTypeFromLabel(elementLabel); … … 371 310 } 372 311 373 particleBeam* dataManager::getDiagnosticBeam(string elementLabel) 374 { 375 return getDiagnosticBeam( getNumeroFromElementLabel(elementLabel) -1); 312 particleBeam* dataManager::getDiagnosticBeam_deprecated(string elementLabel) 313 { 314 // FIXME : Devra etre changé par une récupération par "abstractElement" et non pas par label 315 unsigned int number = 0; 316 abstractElement* elPtr; 317 for (unsigned k = 0; k < jobList_.size(); k++) { 318 sector* sector = jobList_[k]; 319 for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { 320 sectionToExecute* section = sector->getSectionsToExecute()[l]; 321 for (unsigned m = 0; m < section->getElements().size(); m++) { 322 elPtr = section->getElements()[m]; 323 if (elPtr->getLabel() == elementLabel) { 324 return getDiagnosticBeam(number); 325 } 326 number ++; 327 } 328 } 329 } 330 return NULL; 376 331 } 377 332 … … 390 345 if ( type == "x" ) { 391 346 unsigned i = 0; 392 cout << " dataManager::donneesRmsEnveloppe BeamLineSize = " << getBeamLineSize()<< endl;347 cout << " dataManager::donneesRmsEnveloppe " << endl; 393 348 // for (unsigned k = 0; k < getBeamLineSize(); k++) { 394 for (unsigned k = firstComputedElemNumero_ -1 ; k < lastComputedElemNumero_ ; k++) { 395 abstractElement* elPtr = pspa_->getBeamLine()->getAbstractElement(k); 396 // if(elPtr->getNomdElement().getElementType() == snapshot) continue; 397 // if(elPtr->getNomdElement().getElementType() == fit) continue; 398 particleBeam* beamToDraw = getDiagnosticBeam(i); 399 if ( !beamToDraw->momentRepresentationOk() ) { 400 beamToDraw->buildMomentRepresentation(); 401 } 402 403 longueur += elPtr->getLenghtOfElement(); 404 valeur = beamToDraw->getXmaxRms(); 405 cout << " dataManager::donneesRmsEnveloppe index = " << k << " longueur = " << longueur << " enveloppe : " << valeur << endl; 406 xcor.push_back(0.01*longueur); // on passe en metres 407 ycor.push_back(valeur); 408 i++; 349 for (unsigned k = 0; k < jobList_.size(); k++) { 350 sector* sector = jobList_[k]; 351 for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { 352 sectionToExecute* section = sector->getSectionsToExecute()[l]; 353 for (unsigned m = 0; m < section->getElements().size(); m++) { 354 abstractElement* elPtr = section->getElements()[m]; 355 // if(elPtr->getNomdElement().getElementType() == snapshot) continue; 356 // if(elPtr->getNomdElement().getElementType() == fit) continue; 357 particleBeam* beamToDraw = getDiagnosticBeam(i); 358 if ( !beamToDraw->momentRepresentationOk() ) { 359 beamToDraw->buildMomentRepresentation(); 360 } 361 362 longueur += elPtr->getLenghtOfElement(); 363 valeur = beamToDraw->getXmaxRms(); 364 cout << " dataManager::donneesRmsEnveloppe index = " << k << " longueur = " << longueur << " enveloppe : " << valeur << endl; 365 xcor.push_back(0.01*longueur); // on passe en metres 366 ycor.push_back(valeur); 367 i++; 368 } 369 } 409 370 } 410 371 legendy.clear(); … … 413 374 } 414 375 415 int dataManager::getBeamLineSize() { 416 return pspa_->getBeamLine()->getBeamLineSize(); 417 } 418 419 420 abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) 421 { 422 string inputFileName; 423 if(logi == nomDeLogiciel::parmela) { 424 cout << " dataManager::createSoftwareConnexion : logiciel identifie : parmela " << endl; 425 inputFileName = "parmin"; 426 return new softwareParmela(inputFileName, &globParam_, this); 427 } else if (logi == nomDeLogiciel::transport) { 428 cout << " dataManager::createSoftwareConnexion : logiciel identifie : transport " << endl; 429 inputFileName = "transport.input"; 430 return new softwareTransport(inputFileName, &globParam_, this); 431 } else if (logi == nomDeLogiciel::generator) { 432 cout << " dataManager::createSoftwareConnexion : logiciel identifie : generator " << endl; 433 inputFileName = "generator.in"; 434 return new softwareGenerator(inputFileName, &globParam_, this); 435 } else if (logi == nomDeLogiciel::test) { 436 cout << " dataManager::createSoftwareConnexion : logiciel identifie : test " << endl; 437 return new softwareTest(inputFileName, &globParam_, this); 438 } else { 439 cout << " dataManager::createSoftwareConnexion : logiciel identifie : null " << endl; 440 return NULL; 441 } 442 } 376 int dataManager::getBeamLineSize_deprecated() { 377 // FIXME : Cette methode ne doit pas exister, mis a part pour savoir quelle est la taille de la beamLine 378 unsigned int i = 0; 379 for (unsigned k = 0; k < jobList_.size(); k++) { 380 sector* sector = jobList_[k]; 381 for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) { 382 i += sector->getSectionsToExecute()[l]->getElements().size(); 383 } 384 } 385 return i; 386 } 387 443 388 444 389 sector* dataManager::addNewSector() { … … 448 393 str >> result; 449 394 450 sector* sect = new sector( std::string("sector ") + result);451 sectors_.push_back(sect);395 sector* sect = new sector(this, std::string("sector ") + result); 396 jobList_.push_back(sect); 452 397 return sect; 453 398 }
Note: See TracChangeset
for help on using the changeset viewer.