Changeset 342 in PSPA
- Timestamp:
- Feb 26, 2013, 2:35:45 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources/controler
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/bareParticle.h
r312 r342 87 87 88 88 }; 89 90 91 92 93 89 #endif -
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r341 r342 18 18 { 19 19 abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi); 20 public: 20 21 public: 22 23 dataManager(PspaApplication*); 24 virtual ~dataManager(); 25 void consoleMessage(string message); 26 int getBeamLineSize(); 27 inline globalParameters* getGlobalParameters() {return &globParam_;} 28 inline particleBeam* getCurrentBeam() {return currentBeam_;} 21 29 22 dataManager(PspaApplication*); 23 virtual ~dataManager(); 24 void consoleMessage(string message); 25 int getBeamLineSize(); 26 inline globalParameters* getGlobalParameters() {return &globParam_;} 27 inline particleBeam* getCurrentBeam() {return currentBeam_;} 30 particleBeam* getDiagnosticBeam(unsigned index); 28 31 29 particleBeam* getDiagnosticBeam(unsigned index);32 void addSectionToExecute(int debut, int fin, nomDeLogiciel prog); 30 33 31 void addSectionToExecute(int debut, int fin, nomDeLogiciel prog); 32 33 abstractElement* addElement(typedElement elemType); 34 void removeElement(string); 35 36 /** 34 abstractElement* addElement(typedElement elemType); 35 void removeElement(string); 36 37 /** 37 38 Get the label from the order number in the beam line 38 39 @return return "" if not found 39 40 41 42 40 */ 41 string getLabelFromElementNumero(int numero); 42 43 /** 43 44 Get the numero from the label in the beam line 44 45 @return return -1 if not found 45 */ 46 int getNumeroFromElementLabel(string); 47 abstractElement* getElementPointerFromNumero(int); 46 */ 47 int getNumeroFromElementLabel(string); 48 abstractElement* getElementPointerFromNumero(int); 49 50 void initializeExecution(); 51 trivaluedBool checkExecute(string& diagnostic); 52 trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic); 53 bool executeAll(); 54 void saveConfiguration(string nameOfCase); 55 bool restoreElements(string inputFileName); 56 void donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor); 57 void donneesRmsEnveloppe(string type,unsigned int lineSize,vector<double>& xcor,vector<double>& ycor); 58 59 inline void setWorkingDir(string wd) { 60 workingDir_ = wd; 61 } 48 62 49 void initializeExecution(); 50 trivaluedBool checkExecute(string& diagnostic); 51 trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic); 52 bool executeAll(); 53 void saveConfiguration(string nameOfCase); 54 bool restoreElements(string inputFileName); 55 void donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor); 56 /* inline void setWorkingDir(string wd) { */ 57 /* workingDir_ = wd; */ 58 /* } */ 63 private : 64 65 PspaApplication* pspa_; 66 globalParameters globParam_; 67 particleBeam* currentBeam_; 59 68 60 private: 61 globalParameters globParam_; 62 particleBeam* currentBeam_; 63 64 vector<particleBeam> diagnosticBeam_; 65 66 vector<sectionToExecute*> jobList_; 67 68 void removeFile(string nameOfFile); 69 void clearSectionToExecute(); 70 71 // string workingDir_; 72 PspaApplication* pspa_; 73 }; 69 vector<particleBeam> diagnosticBeam_; 70 vector<sectionToExecute*> jobList_; 71 72 void removeFile(string nameOfFile); 73 void clearSectionToExecute(); 74 }; 74 75 #endif -
Interface_Web/trunk/pspaWT/sources/controler/include/nomdElements.h
r271 r342 4 4 using namespace std; 5 5 6 enum typedElement {beam, RFgun, drift, cell, bend, soleno, fit, inconnu};6 enum typedElement {beam, RFgun, drift, cell, bend, soleno, fit, snapshot, inconnu}; 7 7 8 8 -
Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h
r341 r342 4 4 #include <sstream> 5 5 #include <stdio.h> 6 7 6 #include<cmath> 8 9 7 #include <vector> 10 8 11 9 #include "bareParticle.h" 12 //#include "mathematicalTools.h"13 10 #include "nomdElements.h" 14 11 #include "beam2Moments.h" … … 16 13 using namespace std; 17 14 18 19 20 15 class particleBeam 21 16 { 22 23 17 bool particleRepresentationOk_; 24 18 bool momentRepresentationOk_; 25 26 19 bareParticle referenceParticle_; 20 beam2Moments rij_; 21 double P0Transport_; 27 22 28 23 vector<bareParticle> goodPartic_; 29 30 beam2Moments rij_;31 32 33 24 vector<double> centroid_; 34 double P0Transport_;35 36 25 37 26 void impressionDesMoments() const; 38 27 void razDesMoments(); 39 28 40 41 29 public: 42 30 43 31 particleBeam(); 44 45 32 virtual ~particleBeam() {;} 46 33 47 34 void buildMomentRepresentation(); 48 49 50 35 void clear(); 51 52 36 int getNbParticles() const; 53 54 37 const beam2Moments& getTransportMoments() const; 55 38 double getSigmaTransportij(unsigned i, unsigned j); … … 59 42 bool particleRepresentationOk() const; 60 43 bool momentRepresentationOk() const; 61 62 63 44 void addParticle( bareParticle p); 64 65 66 67 45 const vector<bareParticle>& getParticleVector() const; 68 69 46 vector<bareParticle>& getParticleVector(); 70 71 47 double getXmaxRms(); 72 73 48 void getVariance(double& varx, double& vary, double& varz) const; 74 75 49 void set2Moments(beam2Moments& moments); 76 50 void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles); 77 51 void printAllXYZ() const; 78 79 80 52 void Zrange(double& zmin, double& zmax) const; 81 82 53 void donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor); 83 54 void donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd); 84 55 85 56 virtual string FileOutputFlow() const; 86 87 88 57 virtual bool FileInput(ifstream& ifs); 89 90 58 void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]); 91 59 }; 92 93 94 60 #endif -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc
r304 r342 77 77 78 78 trivaluedBool abstractElement::is_accepted_by_software(nomDeLogiciel soft) const { 79 79 cout << " abstractElement : generic method is_accepted_by_software() " << endl; 80 80 return error; 81 81 } 82 83 82 84 83 double abstractElement::getInitialKineticEnergy() const { -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc
r316 r342 6 6 globParamPtr_ = NULL; 7 7 dataManager_ = NULL; 8 9 8 } 10 9 … … 18 17 bool abstractSoftware::launchJob(string commandLine, string& resul) 19 18 { 19 bool ExecuteStatus = true; 20 21 FILE* pp = popen(commandLine.c_str(), "r"); 20 22 ostringstream sortie; 21 bool ExecuteStatus = true;22 FILE* pp = popen(commandLine.c_str(), "r");23 23 if (pp == NULL) { 24 24 sortie << " launching failed : " << commandLine << endl; 25 25 ExecuteStatus = false; 26 } 27 else { 28 cout << " executind command : " << commandLine << endl; 26 } else { 27 cout << " executing command : " << commandLine << endl; 29 28 // on copie la sortie dans le fichier assigne 30 29 char buf[132]; -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r341 r342 11 11 #include <stdio.h> 12 12 #include <fstream> 13 //#include <algorithm>14 15 13 16 14 dataManager::dataManager(PspaApplication* pspa) : 17 currentBeam_(NULL) 18 ,pspa_ ( pspa) 19 { 20 // workingDir_ = pspa_->getWorkingDir(); 21 } 22 23 24 dataManager::~dataManager() { 25 unsigned k; 26 for (k=0; k < jobList_.size();k++) { 27 if ( jobList_[k] != NULL ) delete jobList_[k]; 28 } 29 if ( currentBeam_ == NULL ) delete currentBeam_; 15 currentBeam_(NULL), 16 pspa_ (pspa) 17 {} 18 19 dataManager::~dataManager() 20 { 21 unsigned k; 22 for (k=0; k < jobList_.size();k++) { 23 if ( jobList_[k] != NULL ) delete jobList_[k]; 24 } 25 if ( currentBeam_ == NULL ) delete currentBeam_; 30 26 } 31 27 32 28 void dataManager::consoleMessage(string message) { 33 34 35 29 GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console")); 30 if (console) console->addConsoleMessage(message); 31 pspa_->processEvents(); 36 32 } 37 33 … … 44 40 45 41 46 int dataManager::getNumeroFromElementLabel(string label){ 47 int index = -1; 48 unsigned int k; 49 50 for (k = 0; k < getBeamLineSize() ; k++) 51 { 52 if (pspa_->getBeamLine()->getAbstractElement(k) != NULL){ 53 if ( pspa_->getBeamLine()->getAbstractElement(k)->getLabel() == label ) 54 { 55 index = (int)k + 1; 56 return index; 57 } 58 } 59 } 60 return index; 61 } 62 63 64 abstractElement* dataManager::getElementPointerFromNumero(int k){ 65 return pspa_->getBeamLine()->getAbstractElement(k-1); 42 int dataManager::getNumeroFromElementLabel(string label) 43 { 44 int index = -1; 45 46 for (int k = 0; k < getBeamLineSize() ; k++) 47 { 48 if (pspa_->getBeamLine()->getAbstractElement(k) != NULL){ 49 if ( pspa_->getBeamLine()->getAbstractElement(k)->getLabel() == label ) 50 { 51 index = (int)k + 1; 52 return index; 53 } 54 } 55 } 56 return index; 57 } 58 59 60 abstractElement* dataManager::getElementPointerFromNumero(int k) 61 { 62 return pspa_->getBeamLine()->getAbstractElement(k-1); 66 63 } 67 64 … … 69 66 void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog) 70 67 { 71 72 73 74 68 jobList_.push_back(new sectionToExecute); 69 jobList_.back()->firstElement = debut; 70 jobList_.back()->lastElement = fin; 71 jobList_.back()->software = prog; 75 72 } 76 73 77 74 void dataManager::clearSectionToExecute() 78 75 { 79 80 81 { 82 83 } 84 76 unsigned k; 77 for(k = 0; k < jobList_.size(); k++) 78 { 79 if ( jobList_[k] != NULL ) delete jobList_[k]; 80 } 81 jobList_.clear(); 85 82 } 86 83 87 84 trivaluedBool dataManager::checkExecute(string& diagnostic) 88 85 { 89 cout << "dataManager::checkExecute()" << endl; 90 consoleMessage(" VERIFICATION AVANT EXECUTION "); 91 // console_ = static_cast<GWt_console*> (wApp->findWidget ("console")); 92 // if (console_) console_->addConsoleMessage(" VERIFICATION AVANT EXECUTION "); 93 86 cout << "dataManager::checkExecute()" << endl; 87 consoleMessage(" VERIFICATION AVANT EXECUTION "); 88 94 89 trivaluedBool resul = ok; 95 unsigned k,j;96 90 diagnostic.clear(); 97 unsigned numeroDeb, numeroFin; 98 cout << "controle execution : " << endl; 99 for(k = 0; k < jobList_.size(); k++) { 100 numeroDeb = jobList_[k]->firstElement; 101 numeroFin = jobList_[k]->lastElement; 102 if ( numeroFin < numeroDeb ) 103 { 104 diagnostic += " last element before first for job " + (jobList_[k]->software).getString() + " \n"; 105 resul = error; 106 break; 107 } 108 cout << " numeroDeb= " << numeroDeb << " numeroFin= " << numeroFin << endl; 109 // indexDeb--; 110 // indexFin--; 111 112 abstractElement* elPtr; 91 92 for(unsigned k = 0; k < jobList_.size(); k++) { 93 94 unsigned numeroDeb = jobList_[k]->firstElement; 95 unsigned numeroFin = jobList_[k]->lastElement; 96 97 if ( numeroFin < numeroDeb ) { 98 diagnostic += " last element before first for job " + (jobList_[k]->software).getString() + " \n"; 99 resul = error; 100 break; 101 } 102 113 103 string checkCompatibility; 114 resul = checkElementsForExec(jobList_[k]->software, numeroDeb, numeroFin,checkCompatibility);104 resul = checkElementsForExec(jobList_[k]->software,numeroDeb,numeroFin,checkCompatibility); 115 105 diagnostic += checkCompatibility; 106 } //k 107 108 return resul; 109 } 110 111 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel,unsigned numeroDeb,unsigned numeroFin,string& diagnostic) 112 { 113 trivaluedBool resul = ok; 114 trivaluedBool accepted; 115 116 diagnostic.clear(); 117 abstractElement* elPtr; 118 119 for(unsigned j = numeroDeb; j <= numeroFin; j++) { 120 elPtr = pspa_->getBeamLine()->getAbstractElement(j-1); 121 accepted = elPtr->is_accepted_by_software(logiciel); 122 123 if(accepted == error) { 124 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed with " + logiciel.getString() + " \n"; 125 resul = error; 126 } else if (accepted == warning) { 127 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " will be ignored by " + logiciel.getString() + " \n"; 128 if ( resul != error ) resul = warning; 129 } 116 130 } 117 cout << " data manager renvoie resul = " << resul << endl; 131 118 132 return resul; 119 133 } 120 121 122 trivaluedBool dataManager::checkElementsForExec(nomDeLogiciel logiciel, unsigned numeroDeb, unsigned numeroFin, string& diagnostic)123 {124 trivaluedBool resul = ok;125 diagnostic.clear();126 trivaluedBool accepted;127 abstractElement* elPtr;128 for(unsigned j = numeroDeb; j <= numeroFin; j++) {129 elPtr = pspa_->getBeamLine()->getAbstractElement(j-1);130 accepted = elPtr->is_accepted_by_software(logiciel);131 if(accepted == error ) {132 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " is not allowed with " + logiciel.getString() + " \n";133 resul = error;134 } else if ( accepted == warning ) {135 diagnostic += " the element " + elPtr->getNomdElement().getElementName() + " will be ignored by " + logiciel.getString() + " \n";136 if ( resul != error ) resul = warning;137 }138 }139 return resul;140 }141 142 143 144 134 145 135 void dataManager::initializeExecution() … … 174 164 bool dataManager::executeAll() 175 165 { 176 177 // resul.clear();178 // string resultatPartiel;179 unsigned k; 180 abstractSoftware* softw =NULL;181 string workingDir = pspa_->getWorkingDir();182 for(k = 0; k < jobList_.size(); k++)183 {166 bool success = true; 167 abstractSoftware* softw = NULL; 168 string workingDir = pspa_->getWorkingDir(); 169 170 for(unsigned k = 0; k < jobList_.size(); k++) 171 { 172 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl; 173 184 174 int debut = jobList_[k]->firstElement; 185 175 int fin = jobList_[k]->lastElement; 186 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl; 187 188 softw = createSoftwareConnexion(jobList_[k]->software ); 189 190 if ( softw == NULL ) { 176 softw = createSoftwareConnexion(jobList_[k]->software); 177 178 if (softw == NULL) { 191 179 success = false; 192 180 consoleMessage("dataManager::executeAll : unknown software"); 193 // resultatPartiel = " unknown software -- STOP \n ";194 181 break; 195 182 } 196 183 197 success = softw->createInputFile(currentBeam_, debut, fin,workingDir);184 success = softw->createInputFile(currentBeam_,debut,fin,workingDir); 198 185 if ( success ) { 199 186 success = softw->execute(debut,fin,workingDir); 200 187 if ( success ) { 201 success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_,workingDir);188 success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir); 202 189 } 203 190 } 191 204 192 delete softw; 205 193 if ( success ) { … … 211 199 } 212 200 if ( !success ) break; 213 } 214 return success; 215 } 216 201 202 //debug 203 cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl; 204 cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl; 205 for (int j = debut; j <= fin; j++) { 206 abstractElement* elPtr= getElementPointerFromNumero(j); 207 cout << "[" << j << "] " << elPtr->getNomdElement().getElementName() << endl; 208 } 209 210 } //k 211 212 return success; 213 } 217 214 218 215 void dataManager::saveConfiguration( string nameOfCase) 219 216 { 220 ofstream outfile; 221 string name = pspa_->getWorkingDir() + nameOfCase + ".save"; 222 outfile.open(name.c_str(), ios::out); 223 if (!outfile) { 224 cerr << " error opening output file for persistency " << name << endl; 225 } 226 227 outfile << globParam_.FileOutputFlow(); 228 unsigned k; 229 abstractElement* elPtr; 230 for ( k=0 ; k < getBeamLineSize() ; k++) 231 { 232 elPtr = pspa_->getBeamLine()->getAbstractElement(k); 233 outfile << elPtr->FileOutputFlow(); 234 } 235 outfile.close(); 236 } 237 217 ofstream outfile; 218 string name = pspa_->getWorkingDir() + nameOfCase + ".save"; 219 outfile.open(name.c_str(), ios::out); 220 if (!outfile) { 221 cerr << " error opening output file for persistency " << name << endl; 222 } 223 224 outfile << globParam_.FileOutputFlow(); 225 abstractElement* elPtr; 226 for(unsigned k = 0; k < getBeamLineSize() ; k++) 227 { 228 elPtr = pspa_->getBeamLine()->getAbstractElement(k); 229 outfile << elPtr->FileOutputFlow(); 230 } 231 outfile.close(); 232 } 238 233 239 234 bool dataManager::restoreElements( string inputFileName) … … 281 276 282 277 // debug 283 unsigned k; 284 for(k = 0; k < getBeamLineSize(); k++) { 285 abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k); 278 // unsigned k; 279 // for(k = 0; k < getBeamLineSize(); k++) { 280 // abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k); 281 // cout << "reupere " << ptr->getLabel() << endl; 282 // } 283 return true; 284 } 285 286 particleBeam* dataManager::getDiagnosticBeam(unsigned index) 287 { 288 if (index >= diagnosticBeam_.size()) { 289 return NULL; 290 } else { 291 return &diagnosticBeam_.at(index); 292 } 293 } 294 295 void dataManager::donneesRmsEnveloppe(string type,unsigned int numeroDeb,unsigned int numeroFin, vector<double>& xcor,vector<double>& ycor) 296 { 297 unsigned k; 298 if ( numeroDeb < 1 ) numeroDeb = 1; 299 if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size(); 286 300 287 cout << "reupere " << ptr->getLabel() << endl; 288 } 289 return true; 290 } 291 292 293 particleBeam* dataManager::getDiagnosticBeam(unsigned index) 294 { 295 296 297 if ( index >= diagnosticBeam_.size() ) { 298 return NULL; 299 } 300 else { 301 return &diagnosticBeam_.at(index); 302 } 303 } 304 305 306 void dataManager::donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor) 307 { 308 unsigned k; 309 if ( numeroDeb < 1 ) numeroDeb = 1; 310 if ( numeroFin > diagnosticBeam_.size() ) numeroFin = diagnosticBeam_.size(); 311 312 double longueur = 0.0; 313 double valeur = 0.0; 314 xcor.clear(); 315 ycor.clear(); 316 if ( type == "x" ) 317 { 318 for (k= numeroDeb; k <= numeroFin; k++) 301 double longueur = 0.0; 302 double valeur = 0.0; 303 xcor.clear(); 304 ycor.clear(); 305 if ( type == "x" ) 306 { 307 for (k= numeroDeb; k <= numeroFin; k++) 319 308 { 320 321 322 323 324 309 if ( !diagnosticBeam_.at(k-1).momentRepresentationOk() ) diagnosticBeam_.at(k-1).buildMomentRepresentation(); 310 longueur += pspa_->getBeamLine()->getAbstractElement(k-1)->getLenghtOfElement(); 311 valeur = diagnosticBeam_.at(k-1).getXmaxRms(); 312 xcor.push_back(longueur); 313 ycor.push_back(valeur); 325 314 } 326 315 } 327 else 328 { 329 cerr << " dataManager::donneesRmsEnveloppe type " << type << " not programmed " << endl; 330 return; 331 } 316 else 317 { 318 cerr << " dataManager::donneesRmsEnveloppe type " << type << " not programmed " << endl; 319 return; 320 } 321 } 322 323 // on ne tient pas compte des elements "snapshot" presents dans la beamLine 324 void dataManager::donneesRmsEnveloppe(string type,unsigned int lineSize,vector<double>& xcor,vector<double>& ycor) 325 { 326 double longueur = 0.0; 327 double valeur = 0.0; 328 xcor.clear(); 329 ycor.clear(); 330 331 if ( type == "x" ) { 332 unsigned i = 0; 333 for (unsigned k = 0; k < lineSize; k++) { 334 abstractElement* elPtr = pspa_->getBeamLine()->getAbstractElement(k); 335 if(elPtr->getNomdElement().getElementType() == snapshot) { 336 cout << "TOP 1" << endl; 337 continue; 338 } 339 340 if ( !diagnosticBeam_.at(i).momentRepresentationOk() ) { 341 diagnosticBeam_.at(i).buildMomentRepresentation(); 342 } 343 344 longueur += elPtr->getLenghtOfElement(); 345 valeur = diagnosticBeam_.at(i).getXmaxRms(); 346 xcor.push_back(longueur); 347 ycor.push_back(valeur); 348 i++; 349 } 350 } else { 351 cerr << " dataManager::donneesRmsEnveloppe type " << type << " not programmed " << endl; 352 return; 353 } 332 354 } 333 355 334 356 int dataManager::getBeamLineSize() { 335 return pspa_->getBeamLine()->getBeamLineSize(); 336 } 337 338 abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) { 339 340 string inputFileName; 341 if(logi == nomDeLogiciel::parmela) { 342 inputFileName = "parmin"; 343 return new softwareParmela(inputFileName, &globParam_, this); 344 } else if (logi == nomDeLogiciel::transport) { 345 inputFileName = "transport.input"; 346 return new softwareTransport(inputFileName, &globParam_, this); 347 } else if (logi == nomDeLogiciel::generator) { 348 inputFileName = "generator.in"; 349 return new softwareGenerator(inputFileName, &globParam_, this); 350 } else if (logi == nomDeLogiciel::test) { 351 return new softwareTest(inputFileName, &globParam_, this); 352 } else { 353 return NULL; 354 } 355 356 } 357 return pspa_->getBeamLine()->getBeamLineSize(); 358 } 359 360 abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) 361 { 362 string inputFileName; 363 if(logi == nomDeLogiciel::parmela) { 364 inputFileName = "parmin"; 365 return new softwareParmela(inputFileName, &globParam_, this); 366 } else if (logi == nomDeLogiciel::transport) { 367 inputFileName = "transport.input"; 368 return new softwareTransport(inputFileName, &globParam_, this); 369 } else if (logi == nomDeLogiciel::generator) { 370 inputFileName = "generator.in"; 371 return new softwareGenerator(inputFileName, &globParam_, this); 372 } else if (logi == nomDeLogiciel::test) { 373 return new softwareTest(inputFileName, &globParam_, this); 374 } else { 375 return NULL; 376 } 377 } -
Interface_Web/trunk/pspaWT/sources/controler/src/nomdElements.cc
r304 r342 13 13 else if( strstr(s.c_str(),"soleno") ) return soleno; 14 14 else if( strstr(s.c_str(),"fit") ) return fit; 15 else if( strstr(s.c_str(),"shot") ) return snapshot; 15 16 return inconnu; 16 17 } … … 24 25 else if( s == "bend" ) return bend; 25 26 else if( s == "solnd" ) return soleno; 26 else if( s == "fit" ) return fit; 27 else if( s == "fit" ) return fit; 28 else if( s == "shot" ) return snapshot; 27 29 return inconnu; 28 30 } 29 30 31 31 32 32 std::string nomdElements::toName(typedElement eType) … … 40 40 case soleno : return "SOLENOID"; break; 41 41 case fit : return "FIT"; break; 42 case snapshot : return "SNAPSHOT"; break; 42 43 default : return "UNKNOWN"; 43 44 } 44 45 } 45 46 46 47 47 std::string nomdElements::toLabel(typedElement eType) … … 55 55 case soleno : return "solnd"; 56 56 case fit : return "fit"; 57 case snapshot : return "shot"; 57 58 default : return string(""); 58 59 } … … 69 70 case soleno : return 5; 70 71 case fit : return 4; 72 case snapshot : return 1; 71 73 default : return 0; 72 74 } -
Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc
r341 r342 1 1 2 #include "particleBeam.h" 2 3 #include "mathematicalConstants.h" 3 4 #include "PhysicalConstants.h" 4 5 #include "mathematicalTools.h" 5 //#include <string> 6 6 7 #include <stdio.h> 7 8 #include <algorithm> 8 9 #include <sstream> 9 //#include "environmentVariables.h" 10 10 11 using namespace std; 11 12 12 13 particleBeam::particleBeam() { 13 // rij_transportMoments_.resize(6);14 // unsigned dim=0;15 // unsigned k;16 // for ( k=0; k < 6; k++){17 // rij_transportMoments_.at(k).resize(++dim);18 // }19 14 P0Transport_ = 0.0; 20 15 particleRepresentationOk_ = false; … … 34 29 } 35 30 36 const beam2Moments& 37 31 const beam2Moments& particleBeam::getTransportMoments() const { 32 return rij_; 38 33 } 39 34 … … 58 53 } 59 54 60 61 double particleBeam::getUnnormalizedEmittanceX(){55 double particleBeam::getUnnormalizedEmittanceX() 56 { 62 57 double r = getSigmaTransportij(2,1); 63 58 double rac = (1 - r*r); … … 82 77 } 83 78 } 84 85 86 79 87 80 void particleBeam::set2Moments(beam2Moments& moments) { … … 98 91 goodPartic_ = particles; 99 92 cout << " particleBeam::setWithParticles taille vect. part. ENREGISTRE " << goodPartic_.size() << endl; 100 // printAllXYZ();101 93 particleRepresentationOk_ = true; 102 94 } 103 104 95 105 96 bool particleBeam::particleRepresentationOk() const { … … 119 110 return goodPartic_; 120 111 } 112 121 113 vector<bareParticle>& particleBeam::getParticleVector() 122 114 { 123 115 return goodPartic_; 124 116 } 125 126 127 128 117 129 118 void particleBeam::getVariance(double& varx, double& vary, double& varz) const { -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc
r316 r342 1 1 2 #include "softwareGenerator.h" 2 3 #include "abstractElement.h" … … 4 5 #include "mathematicalConstants.h" 5 6 #include "PhysicalConstants.h" 6 //#include "dataManager.h"7 8 7 9 8 softwareGenerator::softwareGenerator() : abstractSoftware() 10 { 11 ; 12 } 13 14 15 9 {;} 16 10 17 11 softwareGenerator::softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt) 18 { 19 ; 20 } 21 12 {;} 22 13 23 14 bool softwareGenerator::createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir) … … 33 24 return false; 34 25 } 26 35 27 ofstream outfile; 36 28 string name = workingDir + inputFileName_; … … 53 45 } 54 46 55 56 bool softwareGenerator::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) { 47 bool softwareGenerator::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) { 48 49 bool ExecuteStatus = true; 50 57 51 ostringstream sortie; 58 bool ExecuteStatus = true;59 // resul.clear();60 52 sortie << " EXECUTION DE GENERATOR DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl; 61 53 62 char buf[132];63 54 string generatorJob = workingDir + "generator"; 64 55 generatorJob += string(" "); 65 56 generatorJob += workingDir + inputFileName_; 66 57 67 68 ofstream outfile;69 string nameOut = workingDir + "generator.output";70 58 string resultOfRun; 71 bool success = launchJob(generatorJob, 59 bool success = launchJob(generatorJob,resultOfRun); 72 60 sortie << resultOfRun << endl; 73 if ( !success ) {61 if ( !success ) { 74 62 sortie << " launching of generator failed " << endl; 75 63 ExecuteStatus = false; 76 } 77 else { 64 } else { 78 65 cout << " execution generator MARCHE " << endl; 79 66 sortie << resultOfRun; 67 string nameOut = workingDir + "generator.output"; 68 ofstream outfile; 80 69 outfile.open(nameOut.c_str(), ios::out); 81 if (!outfile) 82 { 83 sortie << " error first opening transport output stream " << nameOut << endl; 84 ExecuteStatus = false; 85 } 86 else { 70 if (!outfile) { 71 sortie << " error first opening transport output stream " << nameOut << endl; 72 ExecuteStatus = false; 73 } else { 87 74 // on copie la sortie dans un fichier 'generator.out' 88 75 outfile << resultOfRun << endl; … … 90 77 } 91 78 } 92 // resul = sortie.str();93 79 80 dataManager_->consoleMessage(sortie.str()); 94 81 return ExecuteStatus; 95 82 } -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
r333 r342 8 8 9 9 softwareParmela::softwareParmela() : abstractSoftware() 10 { 11 ; 12 } 10 {;} 13 11 14 12 softwareParmela::softwareParmela(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt) 15 { 16 ; 17 } 13 {;} 18 14 19 15 bool softwareParmela::createInputFile( particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir) … … 26 22 return false; 27 23 } 28 29 24 30 25 ofstream outfile; … … 54 49 } 55 50 56 51 57 52 outfile << "TITLE" << endl; 58 53 outfile << " titre provisoire " << endl; … … 66 61 outfile << "INPUT 0 /NP=" << beamBefore->getNbParticles() << endl; 67 62 } 63 64 68 65 for ( k = premier; k <= numeroFin; k++) 69 66 { 70 67 elPtr = dataManager_->getElementPointerFromNumero(k); 68 if(elPtr->getNomdElement().getElementType() == snapshot) continue; 71 69 outfile << elPtr->parmelaOutputFlow() << endl; 72 70 } 73 71 74 72 outfile << "ZOUT" << endl; 75 73 outfile << "START /wt=0.0 /dwt=" << globParamPtr_->getIntegrationStep() << " /nsteps=" << globParamPtr_->getNbSteps() << " nsc=" << globParamPtr_->getScPeriod() << " /nout=10" << endl; … … 81 79 82 80 83 bool softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) 84 { 81 bool softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) 82 { 83 bool ExecuteStatus = true; 84 85 85 ostringstream sortie; 86 bool ExecuteStatus = true;87 // resul.clear();88 86 sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl; 89 87 90 char buf[132];91 88 string parmelaJob = workingDir + "parmela"; 92 89 parmelaJob += string(" "); 93 90 parmelaJob += workingDir; 94 // cout << " job parmela= " << parmelaJob << endl; 95 91 96 92 string resultOfRun; 97 bool success = launchJob(parmelaJob, 93 bool success = launchJob(parmelaJob,resultOfRun); 98 94 sortie << resultOfRun << endl; 99 if ( !success ) {95 if ( !success ) { 100 96 sortie << " launching of parmela failed " << endl; 101 97 ExecuteStatus = false; 102 } 103 else { 98 } else { 104 99 sortie << " successful launching of parmela " << endl; 105 100 cout << " execution parmela MARCHE " << endl; … … 112 107 } 113 108 114 // resul = sortie.str(); 115 dataManager_->consoleMessage(sortie.str()); 116 109 dataManager_->consoleMessage(sortie.str()); 117 110 return ExecuteStatus; 118 111 } 119 112 120 121 bool softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir){113 bool softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) 114 { 122 115 bool result = true; 123 unsigned k; 124 125 for ( k= numeroDeb; k <= numeroFin; k++) 126 { 116 cout << "debug:: debut " << numeroDeb << ", fin " << numeroFin << endl; 117 118 // index du premier element de parmela 119 int id= numeroDeb-offsetNumElem_; 120 121 for(unsigned k = numeroDeb; k <= numeroFin; k++) 122 { 123 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 124 125 // si l'element est un snapshot, recuperer la sortie precedente 126 if(elem->getNomdElement().getElementType() == snapshot) { 127 int avantDernier = beams.size() - 1; 128 cout<<"["<<k<<"] : ecrit sur fichier le contenu de beam["<<avantDernier<<"]"<<endl; 129 continue; 130 } 131 132 // sinon c'est un element de parmela d'index id 127 133 beams.push_back(particleBeam()); 128 134 vector<double> centroid; 129 135 bareParticle refPart; 130 136 vector<bareParticle> particles; 131 if (!beamFromParmela(workingDir,k - offsetNumElem_ , globParamPtr_->getFrequency(), centroid, refPart,particles )) 137 double freq= globParamPtr_->getFrequency(); 138 139 if(!beamFromParmela(workingDir,id,freq,centroid,refPart,particles)) 132 140 { 133 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 134 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 141 if(elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 135 142 int avantDernier = beams.size() -2; 136 143 beams.back() = beams.at(avantDernier); 137 144 } else { 138 // sortie << " reading parmdesz failed " << endl; 139 dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : reading parmdesz failed " ); 145 dataManager_->consoleMessage("softwareParmela::buildBeamAfterElements : reading parmdesz failed"); 140 146 result = false; 141 147 break; 142 148 } 143 } 144 else { 145 beams.back().setWithParticles(centroid, refPart,particles); 146 } 149 } else { 150 beams.back().setWithParticles(centroid,refPart,particles); 151 } 152 153 // l'element de parmela suivant 154 id++; 147 155 } 156 148 157 return result; 149 158 } 150 159 151 152 153 154 bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ) { 155 unsigned k; 156 FILE* filefais; 160 bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ) 161 { 157 162 string nomfilefais = workingDir + "parmdesz"; 158 163 cout << " nom fichier desz : " << nomfilefais << endl; 159 filefais = fopen(nomfilefais.c_str(), "r");164 FILE *filefais = fopen(nomfilefais.c_str(), "r"); 160 165 161 166 if ( filefais == (FILE*)0 ) { 162 167 dataManager_->consoleMessage(" beamFromParmela() erreur a l'ouverture du fichier 'parmdesz'"); 163 cerr << " beamFromParmela() erreur a l'ouverture du fichier" << nomfilefais << endl; ;164 return false; 165 } 166 elsecout << " beamFromParmela() : ouverture du fichier " << nomfilefais << endl;167 168 cerr << " beamFromParmela() erreur a l'ouverture du fichier" << nomfilefais << endl; 169 return false; 170 } else 171 cout << " beamFromParmela() : ouverture du fichier " << nomfilefais << endl; 172 168 173 parmelaParticle partic; 169 174 std::vector<parmelaParticle> faisceau; 170 171 // unsigned indexElement = numeroElement-1;172 173 174 175 176 175 int testNombrePartRef =0; 177 176 double phaseRef = 0.0; 178 177 179 while( partic.readFromParmelaFile(filefais) > 0 ) { 180 if ( partic.ne == (int)numeroParmel ) 181 { 178 while( partic.readFromParmelaFile(filefais) > 0 ) 179 { 180 181 if ( partic.ne == (int)numeroParmel ) { 182 182 faisceau.push_back(partic); 183 184 183 if ( partic.np == 1 ) { 185 184 // en principe on est sur la particule de reference … … 200 199 } 201 200 } 202 }201 } //while 203 202 204 203 if ( faisceau.size() == 0) … … 213 212 // avec freq en Mhz et dphi en degres et résultat en cm: 214 213 double FACTEUR = 83.3333; // ameliorer la precision 215 216 217 214 218 215 // pour l'instant on choisit un centroid nul; … … 232 229 // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp 233 230 // sont donnes en radians 234 for ( k=0; k < faisceau.size(); k++) {235 x= faisceau.at(k).xx;231 for (unsigned k = 0; k < faisceau.size(); k++) { 232 x= faisceau.at(k).xx; 236 233 xp=faisceau.at(k).xxp; 237 y= faisceau.at(k).yy;234 y= faisceau.at(k).yy; 238 235 yp=faisceau.at(k).yyp; 239 240 236 // dephasage par rapport a la reference 241 237 dephas = faisceau.at(k).phi - phaseRef; // degrés … … 250 246 particles.at(k) = bareParticle(pos,betagamma); 251 247 } 248 252 249 return true; 253 250 }
Note: See TracChangeset
for help on using the changeset viewer.