Changeset 386 in PSPA for Interface_Web
- Timestamp:
- Mar 12, 2013, 1:54:41 PM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/History
r382 r386 5 5 PSPA - Plateforme de simulation en physique des accélérateurs 6 6 ========================================================= 7 12 mars : Guy Le Meur 8 -softwareXXX : changé l'indexation ders éléments pour tenir compte des éléments ignorés par les softwares. 9 -dataManager : création d'une méthode getDiagnosticBeam(string elementLabel); 7 10 8 11 11 Mars : Laurent Garnier -
Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h
r375 r386 4 4 #include "globalParameters.h" 5 5 #include "particleBeam.h" 6 6 #include "nomDeLogiciel.h" 7 7 #include <iostream> 8 8 #include <string> … … 17 17 protected : 18 18 19 unsigned numeroDeb_, numeroFin_; 19 20 globalParameters* globParamPtr_; 20 21 dataManager* dataManager_; 21 22 string inputFileName_; 22 23 nomDeLogiciel nameOfSoftware_; 23 24 abstractSoftware(); 24 25 25 26 bool launchJob(string commandLine, string& resul); 26 27 bool initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin); 28 bool ComputationLimitsOk() const; 27 29 public : 28 30 … … 30 32 ~abstractSoftware() {;} 31 33 34 inline nomDeLogiciel getNomDeLogiciel() const { 35 return nameOfSoftware_; 36 } 37 32 38 virtual bool createInputFile(particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir) = 0; 33 39 34 40 35 virtual bool execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir) = 0;41 virtual bool execute(string workingDir) = 0; 36 42 37 virtual bool buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir) = 0;43 virtual bool buildBeamAfterElements(string workingDir) = 0; 38 44 39 45 /** Color of the background of this sofware … … 44 50 /** Name of this software 45 51 */ 46 virtual string getName() = 0; 52 inline string getName() const { 53 return nameOfSoftware_.getString(); 54 } 47 55 48 56 }; -
Interface_Web/trunk/pspaWT/sources/controler/include/beam2Moments.h
r257 r386 36 36 37 37 // void readFromTransportOutput(ifstream& inp); 38 voidreadFromTransportOutput(stringstream& inp);38 bool readFromTransportOutput(stringstream& inp); 39 39 string writeToTransportInput(double P0) const; 40 40 -
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r381 r386 29 29 30 30 particleBeam* getDiagnosticBeam(unsigned index); 31 31 particleBeam* getDiagnosticBeam(string elementLabel); 32 32 33 void addSectionToExecute(int debut, int fin, nomDeLogiciel prog); 33 34 … … 64 65 bool restoreElements(string inputFileName); 65 66 66 67 68 // si newBeam = true, on cree un nouveau diag 69 // si newBeam = false, on utilise le dernier 70 inline particleBeam* updateCurrentDiagnostic(bool newBeam) { 71 if ( newBeam ) { 72 diagnosticBeam_.push_back(particleBeam()); 73 } 74 indexElementToIndexDiag_.push_back(diagnosticBeam_.size() -1); 75 return &diagnosticBeam_.back(); 76 } 67 77 68 78 … … 73 83 unsigned firstComputedElemNumero_; 74 84 unsigned lastComputedElemNumero_; 85 75 86 vector<particleBeam> diagnosticBeam_; 76 87 vector<unsigned> indexElementToIndexDiag_; 88 // numeroElementToIndexDiag_[k] contient, pour l'element d'index k, l'indice ind tel que diagnosticBeam_[ind] 89 // soit le faisceau resultat, en l'etat qu'il doit avoir apres l'element k 90 77 91 vector<sectionToExecute*> jobList_; 78 92 -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h
r375 r386 27 27 28 28 29 virtual bool execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir);29 virtual bool execute(string workingDir); 30 30 31 31 32 virtual bool buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir);32 virtual bool buildBeamAfterElements(string workingDir); 33 33 34 34 inline string getColor() { … … 36 36 } 37 37 38 inline string getName() {39 return "generator";40 }38 /* inline string getName() const { */ 39 /* return "generator"; */ 40 /* } */ 41 41 }; 42 42 -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h
r381 r386 9 9 protected : 10 10 11 12 11 13 // les elements de parmela sont indexes à partir du premier, il faut 12 14 // donc prevoir un offset pour le raccord a pspa 13 unsigned offsetNumElem_; 14 // vector<unsigned> relativeParmelaElementNumbers_; 15 // unsigned offsetNumElem_; 16 17 vector<int> relativeParmelaElementIndices_; 15 18 16 19 bool beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ); 17 20 18 21 bool beamToParmela(string workingDir, particleBeam* partic ); 19 22 void setRelativeParmelaElementIndices(); 20 23 public : 21 24 softwareParmela(); … … 28 31 virtual bool createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir); 29 32 30 virtual bool execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir);33 virtual bool execute(string workingDir); 31 34 32 35 33 virtual bool buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir);36 virtual bool buildBeamAfterElements(string workingDir); 34 37 35 38 inline string getColor() { … … 37 40 } 38 41 39 inline string getName() {40 return "parmela";41 }42 /* inline string getName() const { */ 43 /* return "parmela"; */ 44 /* } */ 42 45 43 46 }; -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareTest.h
r375 r386 26 26 27 27 28 virtual bool execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir);28 virtual bool execute(string workingDir); 29 29 30 30 31 virtual bool buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir);31 virtual bool buildBeamAfterElements(string workingDir); 32 32 33 33 inline string getColor() { … … 35 35 } 36 36 37 inline string getName() {38 return "test";39 }37 /* inline string getName() const { */ 38 /* return "test"; */ 39 /* } */ 40 40 41 41 }; -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h
r375 r386 18 18 virtual bool createInputFile( particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir); 19 19 20 virtual bool execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir);20 virtual bool execute(string workingDir); 21 21 22 22 23 virtual bool buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir);23 virtual bool buildBeamAfterElements(string workingDir); 24 24 25 25 inline string getColor() { … … 27 27 } 28 28 29 inline string getName() {30 return "transport";31 }29 /* inline string getName() const { */ 30 /* return "transport"; */ 31 /* } */ 32 32 33 33 }; -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc
r342 r386 6 6 globParamPtr_ = NULL; 7 7 dataManager_ = NULL; 8 nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); 8 9 } 9 10 … … 12 13 globParamPtr_ = globals; 13 14 dataManager_ = dt; 15 numeroDeb_ = 0; 16 numeroFin_ = 0; 17 nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); 14 18 } 15 19 20 bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin) { 21 numeroDeb_ = numeroDeb; 22 numeroFin_ = numeroFin; 23 return ComputationLimitsOk(); 24 } 25 26 bool abstractSoftware::ComputationLimitsOk() const { 27 if ( numeroDeb_ < 1 || numeroFin_ < 1 || numeroDeb_ > dataManager_->getBeamLineSize() || numeroFin_ > dataManager_->getBeamLineSize() ) { 28 dataManager_->consoleMessage(" abstractSoftware::initComputationLimit : numero of element out of limits in software " + getName() ); 29 return false; 30 } else { 31 return true; 32 } 33 } 16 34 17 35 bool abstractSoftware::launchJob(string commandLine, string& resul) -
Interface_Web/trunk/pspaWT/sources/controler/src/beam2Moments.cc
r355 r386 78 78 79 79 // suppose qu'on est bien positionné dans le stream (a revoir) 80 voidbeam2Moments::readFromTransportOutput(stringstream& inp) {80 bool beam2Moments::readFromTransportOutput(stringstream& inp) { 81 81 string bidString, bidString1, bidString2; 82 82 double bidon, bidon1, bidon2; … … 87 87 string buf; 88 88 // sauter les eventuels 'VARY' 89 90 string varied = "VARIED:"; 91 // while ( varied == "VARIED:" ) { 92 // getline(inp, buf); 93 // cout << " beam2Moments::readFromTransportOutput ligne lue : " << buf << endl; 94 // stringstream str(buf); 95 // str >> varied; 96 // } 97 98 string testVary; 89 99 while ( notFound ) { 90 100 getline(inp, buf); 91 stringstream str(buf); 101 // cout << " beam2Moments::readFromTransportOutput ligne lue : " << buf << endl; 102 stringstream str(buf); 92 103 if ( str >> bidon1 >> bidString1 >> bidon2 >> ( rij_secondOrderMoments_.at(0) ).at(0) >> bidString2 ) { 93 notFound = false; 94 } 95 } 96 // test = inp >> bidon >> bidString >> bidon >> ( rij_secondOrderMoments_.at(0) ).at(0) >> bidString; 97 // cout << " beam2Moments::readFromTransportOutput TEST= " << test << endl; 98 // } 99 inp >> bidon >> ( rij_secondOrderMoments_.at(1) ).at(1) >> bidString >> ( rij_secondOrderMoments_.at(1) ).at(0); 100 inp >> bidon >> ( rij_secondOrderMoments_.at(2) ).at(2) >> bidString >> ( rij_secondOrderMoments_.at(2) ).at(0) >> ( rij_secondOrderMoments_.at(2) ).at(1); 101 inp >> bidon >> ( rij_secondOrderMoments_.at(3) ).at(3) >> bidString >> ( rij_secondOrderMoments_.at(3) ).at(0) >> ( rij_secondOrderMoments_.at(3) ).at(1) >> ( rij_secondOrderMoments_.at(3) ).at(2); 102 103 inp >> bidon >> ( rij_secondOrderMoments_.at(4) ).at(4) >> bidString >> ( rij_secondOrderMoments_.at(4) ).at(0) >> ( rij_secondOrderMoments_.at(4) ).at(1) >> ( rij_secondOrderMoments_.at(4) ).at(2) >> ( rij_secondOrderMoments_.at(4) ).at(3); 104 105 inp >> bidon >> ( rij_secondOrderMoments_.at(5) ).at(5) >> bidString >> ( rij_secondOrderMoments_.at(5) ).at(0) >> ( rij_secondOrderMoments_.at(5) ).at(1) >> ( rij_secondOrderMoments_.at(5) ).at(2) >> ( rij_secondOrderMoments_.at(5) ).at(3) >> ( rij_secondOrderMoments_.at(5) ).at(4); 106 104 // le format semble correct 105 if ( bidString1 != "M" ) { 106 // c'est bien ce qu'on attend : la longuer en metres 107 cout << " beam2Moments::readFromTransportOutput ON N'A PAS 'M' ligne lue : " << buf << endl; 108 notFound = true; 109 break; 110 } else { 111 // on a trouve la bonne ligne 112 cout << " beam2Moments::readFromTransportOutput lecture OK : ligne lue : " << buf << endl; 113 notFound = false; 114 } 115 } else { 116 // la ligne lue n'est pas au format 117 cout << " beam2Moments::readFromTransportOutput format non conforme ligne lue : " << buf << endl; 118 stringstream test(buf); 119 if ( test >> testVary ) { 120 if ( testVary == varied ) { 121 // ca peut arriver... on continue 122 cout << " beam2Moments::readFromTransportOutput VARIED RENCONTRE ligne lue : " << buf << endl; 123 notFound = true; 124 } else { 125 // on essaie de voir ce qui se passe (ce sera probablement a completer) 126 if ( testVary == "(" ) { 127 // on est trop loin, on est sur l'element suivant, on arrete 128 cout << " beam2Moments::readFromTransportOutput ON EST TOMBE SUR ELEMNT SUIVANT ligne lue : " << buf << endl; 129 notFound = true; 130 break; 131 } 132 if ( testVary == "0" ) { 133 // on doit etre a la fin du fichier, ce qu'on verifie 134 if ( test >> bidString ) { 135 if ( bidString == "*LENGTH*" ) { 136 // c'est bien ca, on arrete 137 cout << " beam2Moments::readFromTransportOutput ON EST A LA FIN DU FICHIER ligne lue : " << buf << endl; 138 notFound = true; 139 break; 140 } else { 141 // on n'y comprend plus grans chose, on arrete de toute facon 142 cout << " beam2Moments::readFromTransportOutput SITUATION NON PREVUE 1 ligne lue : " << buf << endl; 143 notFound = true; 144 break; 145 } // fin test lecture d'une chaine de caracteres 146 } else { 147 // on n'a pas pu lire la chaine, on n'y comprend rien, on arrete 148 cout << " beam2Moments::readFromTransportOutput SITUATION NON PREVUE 2 ligne lue : " << buf << endl; 149 notFound = true; 150 break; 151 } 152 } else { 153 // le premier element lu n'est pas 0, on n'est pas a la fin 154 // mais il n'y a pas de faisceau a cet endroit, sortie normale 155 cout << " beam2Moments::readFromTransportOutput SORTIE NORMALE ligne lue : " << buf << endl; 156 notFound = true; 157 break; 158 } 159 // si on arrive la, on est en pleine panade 160 cout << " beam2Moments::readFromTransportOutput SITUATION NON PREVUE 4 ligne lue : " << buf << endl; 161 notFound = true; 162 break; 163 } 164 } else { 165 // on n'a pas pu lire le premier element de la ligne (bizarre) 166 cout << " beam2Moments::readFromTransportOutput SITUATION NON PREVUE 5 ligne lue : " << buf << endl; 167 notFound = true; 168 break; 169 } 170 } 171 } // fin de boucle sur les lignes 172 173 if ( notFound ) return false; 174 175 176 if ( ! ( inp >> bidon >> ( rij_secondOrderMoments_.at(1) ).at(1) >> bidString >> ( rij_secondOrderMoments_.at(1) ).at(0) ) ) return false; 177 if ( ! (inp >> bidon >> ( rij_secondOrderMoments_.at(2) ).at(2) >> bidString >> ( rij_secondOrderMoments_.at(2) ).at(0) >> ( rij_secondOrderMoments_.at(2) ).at(1) ) ) return false; 178 if ( ! (inp >> bidon >> ( rij_secondOrderMoments_.at(3) ).at(3) >> bidString >> ( rij_secondOrderMoments_.at(3) ).at(0) >> ( rij_secondOrderMoments_.at(3) ).at(1) >> ( rij_secondOrderMoments_.at(3) ).at(2) ) ) return false; 179 180 if ( ! ( inp >> bidon >> ( rij_secondOrderMoments_.at(4) ).at(4) >> bidString >> ( rij_secondOrderMoments_.at(4) ).at(0) >> ( rij_secondOrderMoments_.at(4) ).at(1) >> ( rij_secondOrderMoments_.at(4) ).at(2) >> ( rij_secondOrderMoments_.at(4) ).at(3) ) ) return false; 181 182 if ( ! (inp >> bidon >> ( rij_secondOrderMoments_.at(5) ).at(5) >> bidString >> ( rij_secondOrderMoments_.at(5) ).at(0) >> ( rij_secondOrderMoments_.at(5) ).at(1) >> ( rij_secondOrderMoments_.at(5) ).at(2) >> ( rij_secondOrderMoments_.at(5) ).at(3) >> ( rij_secondOrderMoments_.at(5) ).at(4) ) ) return false; 183 184 return true; 107 185 } 108 186 -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r381 r386 98 98 removeFile(workingDir + "generator.output"); 99 99 diagnosticBeam_.clear(); 100 indexElementToIndexDiag_.clear(); 100 101 currentBeam_ = NULL; 101 102 firstComputedElemNumero_ = getBeamLineSize(); … … 136 137 success = softw->createInputFile(currentBeam_,debut,fin,workingDir); 137 138 if ( success ) { 138 success = softw->execute( debut,fin,workingDir);139 success = softw->execute(workingDir); 139 140 if ( success ) { 140 success = softw->buildBeamAfterElements( debut,fin,diagnosticBeam_,workingDir);141 success = softw->buildBeamAfterElements(workingDir); 141 142 } 142 143 } … … 144 145 delete softw; 145 146 if ( success ) { 146 currentBeam_ = &diagnosticBeam_. back();147 currentBeam_ = &diagnosticBeam_.at(indexElementToIndexDiag_.back()); 147 148 cout << " execute termine avec succes " << endl; 148 149 } else { … … 251 252 particleBeam* dataManager::getDiagnosticBeam(unsigned index) 252 253 { 253 if (index >= diagnosticBeam_.size()) { 254 return NULL; 255 } else { 256 return &diagnosticBeam_.at(index); 257 } 258 } 259 254 if (index >= indexElementToIndexDiag_.size() ) { 255 return NULL; 256 } else { 257 int indDiag = indexElementToIndexDiag_.at(index); 258 return &diagnosticBeam_.at(indDiag); 259 } 260 } 261 262 particleBeam* dataManager::getDiagnosticBeam(string elementLabel) 263 { 264 return getDiagnosticBeam( getNumeroFromElementLabel(elementLabel) -1); 265 } 260 266 261 267 … … 277 283 for (unsigned k = firstComputedElemNumero_ -1 ; k < lastComputedElemNumero_ ; k++) { 278 284 abstractElement* elPtr = pspa_->getBeamLine()->getAbstractElement(k); 279 if(elPtr->getNomdElement().getElementType() == snapshot) continue;285 // if(elPtr->getNomdElement().getElementType() == snapshot) continue; 280 286 // if(elPtr->getNomdElement().getElementType() == fit) continue; 281 282 if ( ! diagnosticBeam_.at(i).momentRepresentationOk() ) {283 diagnosticBeam_.at(i).buildMomentRepresentation();287 particleBeam* beamToDraw = getDiagnosticBeam(i); 288 if ( !beamToDraw->momentRepresentationOk() ) { 289 beamToDraw->buildMomentRepresentation(); 284 290 } 285 291 286 292 longueur += elPtr->getLenghtOfElement(); 287 valeur = diagnosticBeam_.at(i).getXmaxRms();293 valeur = beamToDraw->getXmaxRms(); 288 294 cout << " dataManager::donneesRmsEnveloppe index = " << k << " longueur = " << longueur << " enveloppe : " << valeur << endl; 289 295 xcor.push_back(0.01*longueur); // on passe en metres -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc
r359 r386 8 8 9 9 softwareGenerator::softwareGenerator() : abstractSoftware() 10 {;} 10 { 11 nameOfSoftware_ = nomDeLogiciel("generator"); 12 } 11 13 12 14 softwareGenerator::softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt) 13 {;} 15 { 16 nameOfSoftware_ = nomDeLogiciel("generator"); 17 } 14 18 15 19 bool softwareGenerator::createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir) 16 20 { 17 if ( numeroDeb != numeroFin ) return false; 21 if ( !initComputationLimits(numeroDeb,numeroFin) ) return false; 22 23 if ( numeroDeb_ != numeroFin_ ) return false; 18 24 19 25 abstractElement* elPtr; 20 elPtr = dataManager_->getElementPointerFromNumero(numeroDeb );26 elPtr = dataManager_->getElementPointerFromNumero(numeroDeb_); 21 27 22 28 if ( elPtr->getNomdElement().getElementType() != RFgun ) { … … 46 52 } 47 53 48 bool softwareGenerator::execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir) {54 bool softwareGenerator::execute(string workingDir) { 49 55 50 56 bool ExecuteStatus = true; 51 57 52 58 ostringstream sortie; 53 sortie << " EXECUTION DE GENERATOR DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin<< endl;59 sortie << " EXECUTION DE GENERATOR DE l'ELEMENT " << numeroDeb_ << " A L'ELEMENT " << numeroFin_ << endl; 54 60 55 61 string generatorJob = workingDir + "generator"; … … 83 89 } 84 90 85 bool softwareGenerator::buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir) {91 bool softwareGenerator::buildBeamAfterElements( string workingDir) { 86 92 87 93 bool result = true; 88 if ( numeroDeb != numeroFin ) { 94 if ( !ComputationLimitsOk() ) return false; 95 96 if ( numeroDeb_ != numeroFin_ ) { 89 97 dataManager_->consoleMessage(" softwareGenerator::buildBeamAfterElements : only one element (rfgun) must be calculated " ); 90 98 return false; 91 99 } 92 93 beams.push_back(particleBeam()); 100 // on initialise une nouvelle sortie diagnostic 101 particleBeam* newDiag = dataManager_->updateCurrentDiagnostic(true); 102 103 // beams.push_back(particleBeam()); 94 104 vector<double> centroid; 95 105 bareParticle refPart; … … 97 107 vector<bareParticle> particlesPassives; // on ne fait rien de ces particules pour l'instant 98 108 if (beamFromGenerator(string("faisceau.ini"),workingDir, centroid, refPart,particles, particlesPassives )) { 99 beams.back().setWithParticles(centroid, refPart,particles);109 newDiag->setWithParticles(centroid, refPart,particles); 100 110 } else { 101 111 dataManager_->consoleMessage(" softwareGenerator::buildBeamAfterElements : error " ); -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
r381 r386 6 6 #include "dataManager.h" 7 7 #include "mixedTools.h" 8 8 //#include "nomDeLogiciel.h" 9 9 softwareParmela::softwareParmela() : abstractSoftware() 10 {;} 10 { 11 nameOfSoftware_ = nomDeLogiciel("parmela"); 12 } 11 13 12 14 softwareParmela::softwareParmela(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt) 13 {;} 15 { 16 nameOfSoftware_ = nomDeLogiciel("parmela"); 17 } 18 19 void softwareParmela::setRelativeParmelaElementIndices() { 20 relativeParmelaElementIndices_.clear(); 21 relativeParmelaElementIndices_.resize(numeroFin_ - numeroDeb_ + 1, -1); 22 cout << " setRelativeParmelaElementIndices() taille a priori : " << relativeParmelaElementIndices_.size() << endl; 23 abstractElement* elPtr = dataManager_->getElementPointerFromNumero(numeroDeb_); 24 bool there_is_rfgun = ( elPtr->getNomdElement().getElementType() == RFgun ); 25 unsigned offsetNumElem; 26 // les elements de parmela sont indexes de 1 Ã max, s'il n'y a pas de rfgun 27 if ( !there_is_rfgun ) { 28 offsetNumElem = numeroDeb_ -1; 29 // les elements de parmela sont indexes de 0 Ã max, s'il y a un rfgun 30 } else { 31 offsetNumElem = numeroDeb_; 32 } 33 34 // index du premier element de parmela 35 int id= numeroDeb_ - offsetNumElem; 36 unsigned k; 37 unsigned curseur = 0; 38 for ( k=numeroDeb_; k <= numeroFin_ ; k++ ) { 39 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 40 cout << " liste PARMELA no absolu " << k << " relatif provisoire " << relativeParmelaElementIndices_.at(curseur) << endl; 41 if ( elem->is_accepted_by_software(nameOfSoftware_) == TBoolOk ) { 42 relativeParmelaElementIndices_.at(curseur) = id; 43 cout << " mis a " << id << endl; 44 id++; 45 } 46 curseur++; 47 } 48 } 49 14 50 15 51 bool softwareParmela::createInputFile(particleBeam* beamBefore,unsigned int numeroDeb,unsigned int numeroFin,string workingDir) 16 52 { 17 53 unsigned int k; 18 19 if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) { 20 dataManager_->consoleMessage(" softwareParmela::createInputFile : numero of element out of limits " ); 21 cerr << " numero of element out of limits " << endl; 22 return false; 23 } 24 54 if ( !initComputationLimits(numeroDeb,numeroFin) ) return false; 55 setRelativeParmelaElementIndices(); 25 56 string name = workingDir + inputFileName_; 26 57 ofstream outfile; … … 34 65 abstractElement* elPtr; 35 66 double initalKineticEnergy = 0.0; 36 elPtr = dataManager_->getElementPointerFromNumero(numeroDeb );67 elPtr = dataManager_->getElementPointerFromNumero(numeroDeb_); 37 68 bool there_is_rfgun = ( elPtr->getNomdElement().getElementType() == RFgun ); 38 69 … … 42 73 initalKineticEnergy = beamBefore->referenceKineticEnergyMeV(); 43 74 // les elements de parmela sont indexes de 1 Ã max, s'il n'y a pas de rfgun 44 offsetNumElem_ = numeroDeb-1;75 // offsetNumElem_ = numeroDeb_ -1; 45 76 } else { 46 77 elPtr->setPhaseStep( globParamPtr_->getIntegrationStep() ); 47 78 initalKineticEnergy = elPtr->getInitialKineticEnergy(); 48 79 // les elements de parmela sont indexes de 0 Ã max, s'il y a un rfgun 49 offsetNumElem_ = numeroDeb;80 // offsetNumElem_ = numeroDeb_; 50 81 } 51 82 … … 54 85 outfile << "RUN /n0=1 /ip=999 /freq=" << globParamPtr_->getFrequency() << " /z0=0.0 /W0=" << initalKineticEnergy << " /itype=1" << endl; 55 86 outfile << "OUTPUT 0" << endl; 56 unsigned int premier = numeroDeb ;87 unsigned int premier = numeroDeb_ ; 57 88 if ( there_is_rfgun ) { 58 outfile << dataManager_->getElementPointerFromNumero(numeroDeb )->parmelaOutputFlow() << endl;89 outfile << dataManager_->getElementPointerFromNumero(numeroDeb_)->parmelaOutputFlow() << endl; 59 90 premier++; 60 91 } else { … … 63 94 64 95 // commentaire : si l'element est un snapshot ne rien ecrire dans inputFileName_ (= parmin) un saut de ligne perturbe l'execution de parmela 65 for ( k = premier; k <= numeroFin ; k++)96 for ( k = premier; k <= numeroFin_; k++) 66 97 { 67 98 elPtr = dataManager_->getElementPointerFromNumero(k); … … 80 111 } 81 112 82 bool softwareParmela::execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir)113 bool softwareParmela::execute(string workingDir) 83 114 { 84 115 bool ExecuteStatus = true; 85 116 86 117 ostringstream sortie; 87 sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin<< endl;118 sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb_ << " A L'ELEMENT " << numeroFin_ << endl; 88 119 89 120 string parmelaJob = workingDir + "parmela"; … … 114 145 115 146 116 bool softwareParmela::buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir)147 bool softwareParmela::buildBeamAfterElements( string workingDir) 117 148 { 118 149 bool result = true; 119 //cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl; 120 121 // index du premier element de parmela 122 int id= numeroDeb-offsetNumElem_; 123 124 for(unsigned k = numeroDeb; k <= numeroFin; k++) 150 151 if ( !ComputationLimitsOk() ) return false; 152 unsigned curseur; 153 for(unsigned k = numeroDeb_; k <= numeroFin_; k++) 125 154 { 126 155 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 127 128 // si l'element est un snapshot, recuperer la sortie precedente 129 if(elem->getNomdElement().getElementType() == snapshot) { 130 int avantDernier = beams.size() - 1; 131 string* param = elem->getParametersString(); 132 string cliche = workingDir + param[2].c_str(); 133 if( beamToParmela(cliche,&beams.at(avantDernier)) ) { 134 cout << "[" << k << "] : ecrit sur fichier " << cliche << " le contenu de beam["<<avantDernier<<"]"<<endl; 156 if ( elem == NULL ) { 157 dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : null pointer on element " ); 158 return false; 159 } 160 161 curseur = k - numeroDeb_; 162 163 if ( relativeParmelaElementIndices_.at(curseur) < 0 ) { 164 165 // si l'element doit etre ignore de parmela, on renvoie sur le diag precedent 166 particleBeam* lastDiag = dataManager_->updateCurrentDiagnostic(false); 167 168 if(elem->getNomdElement().getElementType() == snapshot) { 169 // si cet element est un snapshot, on organise la sortie correspondante 170 string* param = elem->getParametersString(); 171 string cliche = workingDir + param[2].c_str(); 172 if( beamToParmela(cliche,lastDiag) ) { 173 // cout << "[" << k << "] : ecrit sur fichier " << cliche << " le contenu de beam["<<avantDernier<<"]"<<endl; 174 cout << "[" << k << "] : ecrit sur fichier " << cliche << " le contenu de beam[ ]"<<endl; 175 } 135 176 } 136 // continue;137 } 138 139 // sinon c'est un element de parmela d'index id 140 beams.push_back(particleBeam());141 cout << " creation diagn. no " << beams.size() << " par PARMELA " << endl;142 143 vector<double> centroid;144 bareParticle refPart;145 vector<bareParticle> particles;146 double freq= globParamPtr_->getFrequency();147 148 cout << " lecture PARMELA el no absolu " << k << " nom " << elem->getNomdElement().getElementName() << endl;149 if(!beamFromParmela(workingDir,id,freq,centroid,refPart,particles))150 151 if(elem->is_accepted_by_software(nomDeLogiciel::parmela) == TBoolIgnore) {152 int avantDernier = beams.size() -2;153 beams.back() = beams.at(avantDernier);177 // si le numero est reconnu de parmela 178 } else { 179 180 // on initialise une nouvelle sortie diagnostic 181 particleBeam* newDiag = dataManager_->updateCurrentDiagnostic(true); 182 vector<double> centroid; 183 bareParticle refPart; 184 vector<bareParticle> particles; 185 double freq= globParamPtr_->getFrequency(); 186 unsigned numeroParmel; 187 numeroParmel = (unsigned)relativeParmelaElementIndices_.at(curseur); 188 cout << " lecture PARMELA el no absolu " << k << " numero relatif " << numeroParmel << " nom " << elem->getNomdElement().getElementName() << endl; 189 // lecture sortie parmela 190 if(!beamFromParmela(workingDir,numeroParmel,freq,centroid,refPart,particles)) 191 { 192 // si echec, fin 193 dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : failure in reading parmela result for element " + elem->getLabel() + " for unknown reason " ); 194 return false; 154 195 } else { 155 dataManager_->consoleMessage("softwareParmela::buildBeamAfterElements : reading parmdesz failed"); 156 result = false; 157 break; 158 } 159 160 } else { 161 beams.back().setWithParticles(centroid,refPart,particles); 162 } 163 164 // l'element de parmela suivant 165 id++; 166 } 167 196 // si succes, on complete le diagnostic 197 newDiag->setWithParticles(centroid,refPart,particles); 198 } 199 } 200 } 168 201 return result; 169 202 } 170 171 203 bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ) 172 204 { -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareTest.cc
r333 r386 8 8 softwareTest::softwareTest() : abstractSoftware() 9 9 { 10 ;10 nameOfSoftware_ = nomDeLogiciel("test"); 11 11 } 12 12 … … 16 16 softwareTest::softwareTest(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware( inputFileName, globals, dt) 17 17 { 18 ;18 nameOfSoftware_ = nomDeLogiciel("test"); 19 19 } 20 20 … … 30 30 } 31 31 32 bool softwareTest::execute( unsigned int numeroDeb,unsigned int numeroFin,string workingDir) {32 bool softwareTest::execute(string workingDir) { 33 33 dataManager_->consoleMessage(" softwareTest::execute " ); 34 34 return true; 35 35 } 36 36 37 bool softwareTest::buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir) {37 bool softwareTest::buildBeamAfterElements(string workingDir) { 38 38 dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements " ); 39 39 bool result = true; 40 40 unsigned k; 41 for ( k= numeroDeb ; k <= numeroFin; k++)41 for ( k= numeroDeb_; k <= numeroFin_; k++) 42 42 { 43 beams.push_back(particleBeam()); 43 particleBeam* newDiag = dataManager_->updateCurrentDiagnostic(true); 44 // beams.push_back(particleBeam()); 44 45 vector<double> centroid = vector<double>(6,0.0); 45 46 bareParticle refPart; … … 55 56 else { 56 57 bareParticle refPart (particles.at(0)); 57 beams.back().setWithParticles(centroid, refPart,particles);58 newDiag->setWithParticles(centroid, refPart,particles); 58 59 } 59 60 } -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc
r381 r386 7 7 8 8 softwareTransport::softwareTransport() : abstractSoftware() 9 {;} 9 { 10 nameOfSoftware_ = nomDeLogiciel("transport"); 11 } 10 12 11 13 softwareTransport::softwareTransport(string inputFileName,globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt) 12 {;} 14 { 15 nameOfSoftware_ = nomDeLogiciel("transport"); 16 } 13 17 14 18 bool softwareTransport::createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir) 15 19 { 16 if ( numeroDeb < 1 || numeroFin > dataManager_->getBeamLineSize() ) { 17 dataManager_->consoleMessage(" softwareTransport::createInputFile : numero of element out of limits " ); 18 cerr << " numero of element out of limits " << endl; 19 return false; 20 } 20 21 if ( !initComputationLimits(numeroDeb,numeroFin) ) return false; 21 22 22 23 abstractElement* premierEl = NULL; 23 premierEl = dataManager_->getElementPointerFromNumero(numeroDeb );24 premierEl = dataManager_->getElementPointerFromNumero(numeroDeb_); 24 25 25 26 // ceinture et bretelles … … 79 80 80 81 abstractElement* elPtr; 81 for (unsigned k = numeroDeb ; k <= numeroFin; k++)82 for (unsigned k = numeroDeb_; k <= numeroFin_; k++) 82 83 { 83 84 elPtr = dataManager_->getElementPointerFromNumero(k); 84 85 cout << "debug:: element [" << k << "] " << elPtr->getNomdElement().getElementName() << endl; 85 if(elPtr->getNomdElement().getElementType() == snapshot) continue;86 86 outfile << elPtr->transportOutputFlow() << endl; 87 87 } … … 95 95 } 96 96 97 bool softwareTransport::execute( unsigned int numeroDeb, unsigned int numeroFin,string workingDir)97 bool softwareTransport::execute(string workingDir) 98 98 { 99 99 bool ExecuteStatus = true; 100 100 101 101 ostringstream sortie; 102 sortie << " EXECUTION DE TRANSPORT DE " << numeroDeb << " a " << numeroFin<< endl;102 sortie << " EXECUTION DE TRANSPORT DE " << numeroDeb_ << " a " << numeroFin_ << endl; 103 103 104 104 string transportJob = workingDir + "transport"; … … 132 132 } 133 133 134 bool softwareTransport::buildBeamAfterElements( unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams,string workingDir)134 bool softwareTransport::buildBeamAfterElements(string workingDir) 135 135 { 136 136 137 137 bool result = true; 138 139 for (unsigned k = numeroDeb; k <= numeroFin; k++) 138 if ( !ComputationLimitsOk() ) return false; 139 140 for (unsigned k = numeroDeb_; k <= numeroFin_; k++) 140 141 { 141 142 abstractElement* ptr = dataManager_->getElementPointerFromNumero(k); … … 143 144 dataManager_->consoleMessage(" softwareTransport::buildBeamAfterElements : null pointer on element " ); 144 145 cout << " softwareTransport::buildBeamAfterElements : null pointer on element " << endl; 145 result = false; 146 break; 147 } 148 146 return false; 147 } 148 149 150 if ( ptr->is_accepted_by_software(nameOfSoftware_) != TBoolOk ) { 151 // si l'element doit etre ignore, on renvoie sur le diag precedent 152 dataManager_->updateCurrentDiagnostic(false); 149 153 // si l'element est un snapshot, recuperer la sortie precedente 150 if(ptr->getNomdElement().getElementType() == snapshot) { 151 int avantDernier = beams.size() - 1; 152 string* param = ptr->getParametersString(); 153 string cliche = workingDir + param[2].c_str(); 154 cout<<"["<<k<<"] : ecrit sur fichier " << cliche << " le contenu de beam["<<avantDernier<<"]"<<endl; 155 // continue; 156 } 157 158 beams.push_back(particleBeam()); 159 cout << " creation diagn. no " << beams.size() << " par TRANSPORT " << endl; 160 string elemLabel = ptr->getLabel(); 161 beam2Moments transpMoments; 162 163 if (!moments2FromTransport(workingDir,elemLabel,ptr->getNomdElement(),transpMoments) ) 164 { 165 dataManager_->consoleMessage(" softwareTransport::buildBeamAfterElements : failure in reading moments " ); 166 cout << " softwareTransport::buildBeamAfterElements plantage dans lecture moments " << endl; 167 result = false; 168 break; 169 } 170 beams.back().set2Moments(transpMoments); 154 if(ptr->getNomdElement().getElementType() == snapshot) { 155 string* param = ptr->getParametersString(); 156 string cliche = workingDir + param[2].c_str(); 157 cout<<"["<<k<<"] : ecrit sur fichier " << cliche << " le contenu de beam[ ]"<<endl; 158 } 159 } else { 160 // si le numero est reconnu de transport 161 162 163 164 string elemLabel = ptr->getLabel(); 165 beam2Moments transpMoments; 166 // lecture sortie transport 167 if (!moments2FromTransport(workingDir,elemLabel,ptr->getNomdElement(),transpMoments) ) 168 { 169 // si echec, on renvoie sur le diag precedent 170 dataManager_->updateCurrentDiagnostic(false); 171 172 dataManager_->consoleMessage(" softwareTransport::buildBeamAfterElements : element skipped in reading moments from transport output : " + elemLabel); 173 // cout << " softwareTransport::buildBeamAfterElements plantage dans lecture moments " << endl; 174 return true; 175 } else { 176 // si succes, 177 // on initialise une nouvelle sortie diagnostic 178 particleBeam* newDiag = dataManager_->updateCurrentDiagnostic(true); 179 // et on la complete 180 newDiag->set2Moments(transpMoments); 181 } 182 } 171 183 } 172 184 return result; 173 185 } 174 175 186 bool softwareTransport::moments2FromTransport(string workingDir,string elLab,const nomdElements elem,beam2Moments& moments) const 176 187 { … … 226 237 } 227 238 228 moments.readFromTransportOutput(fichierStream); 229 return true; 230 } 239 return moments.readFromTransportOutput(fichierStream); 240 } -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r381 r386 87 87 88 88 // void setModelComponentForPhaseSpace(WStandardItemModel* model, vector<bareParticle>& partic, unsigned indexParticleComponent, unsigned modelComponent); 89 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam, string namex, string namey );90 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam, string namex, string namey);89 //void faireDessinParmela(WContainerWidget* toto, particleBeam* beam, string namex, string namey ); 90 // void faireDessinTransport(WContainerWidget* toto, particleBeam* beam, string namex, string namey); 91 91 void faireDessinEnveloppe(WContainerWidget* toto, string type); 92 92 // void scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r381 r386 500 500 for(int i = 1; i <= nombre; i++) { 501 501 abstractElement* elPtr = dtmanage_->getElementPointerFromNumero(i); 502 if(elPtr->getNomdElement().getElementType() == snapshot) continue;502 // if(elPtr->getNomdElement().getElementType() == snapshot) continue; 503 503 504 504 choixElementDessin_->addItem(elPtr->getLabel()); … … 511 511 512 512 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 513 int index = choixElementDessin_->currentIndex();513 // int index = choixElementDessin_->currentIndex(); 514 514 string nameAbs = choixAbsPhase_->currentText().toUTF8(); 515 515 string nameOrd = choixOrdPhase_->currentText().toUTF8(); … … 519 519 return; 520 520 } 521 522 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 521 string elementLabel = choixElementDessin_->currentText().toUTF8(); 522 particleBeam* beam = dtmanage_->getDiagnosticBeam(elementLabel); 523 // particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 523 524 524 525 if ( beam == NULL ) { … … 626 627 627 628 628 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, string namex, string namey )629 {630 cout << " faireDessinParmela " << endl;631 GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false);632 eDialog_.push_back(pointsDialog);633 pointsDialog->setMinimumSize(400,400);634 pointsDialog->setClosable(true);635 // pointsDialog->show();629 // void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, string namex, string namey ) 630 // { 631 // cout << " faireDessinParmela " << endl; 632 // GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false); 633 // eDialog_.push_back(pointsDialog); 634 // pointsDialog->setMinimumSize(400,400); 635 // pointsDialog->setClosable(true); 636 // // pointsDialog->show(); 636 637 637 new WText(nameOfCase_, pointsDialog->contents());638 639 640 vector<double> xcor;641 vector<double> ycor;642 vector<string> legende;643 beam->particlesPhaseSpaceData(xcor, ycor, legende, namex, namey);644 for (int k=0 ; k < legende.size(); k++) {645 new WBreak(pointsDialog->contents());646 new WText(legende.at(k), pointsDialog->contents());647 }648 string titre = " phase space ";649 chartPlot2vec(pointsDialog->contents(), xcor, ycor, true,titre,namex, namey,400,400);650 651 652 653 pointsDialog->show();654 655 // chart->setMargin(10, Top | Bottom); // add margin vertically656 // chart->setMargin(WLength::Auto, Left | Right); // center horizontally657 }658 659 void PspaApplication::faireDessinTransport(WContainerWidget* toto, particleBeam* beam, string namex, string namey)660 {661 GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false);662 eDialog_.push_back(ellipseDialog);663 ellipseDialog->setMinimumSize(400,400);664 ellipseDialog->setClosable(true);665 ellipseDialog->show();666 new WText(nameOfCase_, ellipseDialog->contents());667 668 vector<double> xcor;669 vector<double> ycor;670 vector<string> legende;671 beam->donneesDessinEllipse(xcor,ycor,legende, namex, namey);672 673 for (int k=0 ; k < legende.size(); k++) {674 new WBreak(ellipseDialog->contents());675 new WText(legende.at(k), ellipseDialog->contents());676 }677 string titre = "phase space rms";678 chartPlot2vec(ellipseDialog->contents(), xcor, ycor, false,titre, namex, namey,500,300);679 }638 // new WText(nameOfCase_, pointsDialog->contents()); 639 640 641 // vector<double> xcor; 642 // vector<double> ycor; 643 // vector<string> legende; 644 // beam->particlesPhaseSpaceData(xcor, ycor, legende, namex, namey); 645 // for (int k=0 ; k < legende.size(); k++) { 646 // new WBreak(pointsDialog->contents()); 647 // new WText(legende.at(k), pointsDialog->contents()); 648 // } 649 // string titre = " phase space "; 650 // chartPlot2vec(pointsDialog->contents(), xcor, ycor, true,titre,namex, namey,400,400); 651 652 653 654 // pointsDialog->show(); 655 656 // // chart->setMargin(10, Top | Bottom); // add margin vertically 657 // // chart->setMargin(WLength::Auto, Left | Right); // center horizontally 658 // } 659 660 // void PspaApplication::faireDessinTransport(WContainerWidget* toto, particleBeam* beam, string namex, string namey) 661 // { 662 // GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false); 663 // eDialog_.push_back(ellipseDialog); 664 // ellipseDialog->setMinimumSize(400,400); 665 // ellipseDialog->setClosable(true); 666 // ellipseDialog->show(); 667 // new WText(nameOfCase_, ellipseDialog->contents()); 668 669 // vector<double> xcor; 670 // vector<double> ycor; 671 // vector<string> legende; 672 // beam->donneesDessinEllipse(xcor,ycor,legende, namex, namey); 673 674 // for (int k=0 ; k < legende.size(); k++) { 675 // new WBreak(ellipseDialog->contents()); 676 // new WText(legende.at(k), ellipseDialog->contents()); 677 // } 678 // string titre = "phase space rms"; 679 // chartPlot2vec(ellipseDialog->contents(), xcor, ycor, false,titre, namex, namey,500,300); 680 // } 680 681 681 682 … … 848 849 histoDialog->setClosable(true); 849 850 850 int index = choixHistoDessin_->currentIndex(); 851 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 851 // int index = choixHistoDessin_->currentIndex(); 852 // particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 853 string elementLabel = choixHistoDessin_->currentText().toUTF8(); 854 particleBeam* beam = dtmanage_->getDiagnosticBeam(elementLabel); 852 855 if (beam == NULL) { 853 856 GWt_dialog warningBeamState("histogram","the beam does not exist at the end of this element !", GWt_dialog::Error, false,true);
Note: See TracChangeset
for help on using the changeset viewer.