Changeset 342 in PSPA


Ignore:
Timestamp:
Feb 26, 2013, 2:35:45 PM (11 years ago)
Author:
touze
Message:

nvx element snapshot

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  
    8787
    8888};
    89 
    90 
    91 
    92 
    9389#endif
  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r341 r342  
    1818{
    1919  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_;}
    2129   
    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);
    2831   
    29     particleBeam* getDiagnosticBeam(unsigned index);
     32  void addSectionToExecute(int debut, int fin, nomDeLogiciel prog);
    3033   
    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  /**
    3738     Get the label from the order number in the beam line
    3839     @return return "" if not found
    39      */
    40     string getLabelFromElementNumero(int numero);
    41 
    42     /**
     40  */
     41  string getLabelFromElementNumero(int numero);
     42 
     43  /**
    4344     Get the numero from the label in the beam line
    4445     @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  }
    4862   
    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_;
    5968   
    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  };
    7475#endif
  • Interface_Web/trunk/pspaWT/sources/controler/include/nomdElements.h

    r271 r342  
    44using namespace std;
    55
    6 enum typedElement {beam, RFgun, drift, cell, bend, soleno, fit, inconnu};
     6enum typedElement {beam, RFgun, drift, cell, bend, soleno, fit, snapshot, inconnu};
    77
    88
  • Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h

    r341 r342  
    44#include <sstream>
    55#include <stdio.h>
    6 
    76#include<cmath>
    8 
    97#include <vector>
    108
    119#include "bareParticle.h"
    12 //#include "mathematicalTools.h"
    1310#include "nomdElements.h"
    1411#include "beam2Moments.h"
     
    1613using namespace std;
    1714
    18 
    19 
    2015class particleBeam
    2116{
    22 
    2317  bool particleRepresentationOk_;
    2418  bool momentRepresentationOk_;
    25 
    2619  bareParticle referenceParticle_;
     20  beam2Moments rij_;
     21  double P0Transport_;
    2722
    2823  vector<bareParticle> goodPartic_;
    29 
    30   beam2Moments rij_;
    31 
    32 
    3324  vector<double> centroid_;
    34   double P0Transport_;
    35 
    3625
    3726  void impressionDesMoments() const;
    3827  void razDesMoments();
    3928
    40 
    4129 public:
    4230
    4331  particleBeam();
    44 
    4532  virtual ~particleBeam() {;}
    4633
    4734  void buildMomentRepresentation();
    48 
    49 
    5035  void clear();
    51 
    5236  int getNbParticles() const;
    53 
    5437  const beam2Moments&  getTransportMoments() const;
    5538  double getSigmaTransportij(unsigned i, unsigned j);
     
    5942  bool particleRepresentationOk() const;
    6043  bool momentRepresentationOk() const;
    61 
    62 
    6344  void  addParticle( bareParticle p);
    64 
    65 
    66 
    6745  const vector<bareParticle>& getParticleVector() const;
    68 
    6946  vector<bareParticle>& getParticleVector();
    70 
    7147  double getXmaxRms();
    72 
    7348  void getVariance(double& varx, double& vary, double& varz) const;
    74  
    7549  void set2Moments(beam2Moments& moments);
    7650  void setWithParticles(vector<double>& centroid, bareParticle& referencePart, vector<bareParticle>& particles);
    7751  void printAllXYZ() const;
    78 
    79 
    8052  void Zrange(double& zmin, double& zmax) const;
    81 
    8253  void donneesDessinEllipseXxp(vector<double>& xcor, vector<double>& ycor);
    8354  void donneesDessinEllipse(vector<double>& xcor, vector<double>& ycor, unsigned indexAbs, unsigned indexOrd);
    8455
    8556  virtual string FileOutputFlow() const;
    86 
    87 
    8857  virtual bool FileInput(ifstream& ifs);
    89 
    9058  void histogramme(vector<double>&xcor,vector<int>& hist,int& cnts,double out[3]);
    9159};
    92 
    93 
    9460#endif
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc

    r304 r342  
    7777
    7878trivaluedBool abstractElement::is_accepted_by_software(nomDeLogiciel soft) const {
    79     cout << " abstractElement : generic method is_accepted_by_software()  " << endl;
     79  cout << " abstractElement : generic method is_accepted_by_software()  " << endl;
    8080  return error;
    8181}
    82 
    8382
    8483double abstractElement::getInitialKineticEnergy() const {
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc

    r316 r342  
    66  globParamPtr_ = NULL;
    77  dataManager_ = NULL;
    8 
    98}
    109
     
    1817bool abstractSoftware::launchJob(string commandLine, string& resul)
    1918{
     19  bool ExecuteStatus = true;
     20
     21  FILE* pp = popen(commandLine.c_str(), "r");
    2022  ostringstream sortie;
    21   bool ExecuteStatus = true;
    22   FILE* pp = popen(commandLine.c_str(), "r");
    2323  if (pp == NULL) {
    2424    sortie << " launching  failed : " << commandLine << endl;
    2525    ExecuteStatus = false;
    26   }
    27   else {
    28     cout << " executind command :  "  << commandLine << endl;
     26  } else {
     27    cout << " executing command :  "  << commandLine << endl;
    2928    // on copie la sortie dans le fichier assigne
    3029    char buf[132];
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r341 r342  
    1111#include <stdio.h>
    1212#include <fstream>
    13 //#include <algorithm>
    14 
    1513
    1614dataManager::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
     19dataManager::~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_;
    3026}
    3127
    3228void dataManager::consoleMessage(string message) {
    33    GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    34    if (console) console->addConsoleMessage(message);
    35    pspa_->processEvents();
     29  GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     30  if (console) console->addConsoleMessage(message);
     31  pspa_->processEvents();
    3632}
    3733
     
    4440
    4541
    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);
     42int 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
     60abstractElement* dataManager::getElementPointerFromNumero(int k)
     61{
     62  return pspa_->getBeamLine()->getAbstractElement(k-1);
    6663}
    6764
     
    6966void dataManager::addSectionToExecute(int debut, int fin, nomDeLogiciel prog)
    7067{
    71     jobList_.push_back(new sectionToExecute);
    72     jobList_.back()->firstElement = debut;
    73     jobList_.back()->lastElement = fin;
    74     jobList_.back()->software  = prog;
     68  jobList_.push_back(new sectionToExecute);
     69  jobList_.back()->firstElement = debut;
     70  jobList_.back()->lastElement = fin;
     71  jobList_.back()->software  = prog;
    7572}
    7673
    7774void dataManager::clearSectionToExecute()
    7875{
    79     unsigned k;
    80     for(k = 0; k < jobList_.size(); k++)
    81     {
    82         if ( jobList_[k] != NULL ) delete jobList_[k];
    83     }
    84     jobList_.clear();
     76  unsigned k;
     77  for(k = 0; k < jobList_.size(); k++)
     78    {
     79      if ( jobList_[k] != NULL ) delete jobList_[k];
     80    }
     81  jobList_.clear();
    8582}
    8683
    8784trivaluedBool dataManager::checkExecute(string& diagnostic)
    8885{
    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 
    9489  trivaluedBool resul = ok;
    95   unsigned k,j;
    9690  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
    113103    string checkCompatibility;
    114     resul = checkElementsForExec(jobList_[k]->software, numeroDeb, numeroFin, checkCompatibility);
     104    resul = checkElementsForExec(jobList_[k]->software,numeroDeb,numeroFin,checkCompatibility);
    115105    diagnostic += checkCompatibility;
     106  } //k
     107
     108  return resul;
     109}
     110
     111trivaluedBool 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    }
    116130  }
    117   cout << " data manager renvoie resul = " << resul << endl;
     131
    118132  return resul;
    119133}
    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 
    144134
    145135void dataManager::initializeExecution()
     
    174164bool dataManager::executeAll()
    175165{
    176     bool success = true;
    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     
    184174      int debut = jobList_[k]->firstElement;
    185175      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) {
    191179        success = false;
    192180        consoleMessage("dataManager::executeAll : unknown software");
    193         //      resultatPartiel =  " unknown software -- STOP \n ";     
    194181        break;
    195182      }
    196183
    197       success = softw->createInputFile(currentBeam_, debut, fin, workingDir);
     184      success = softw->createInputFile(currentBeam_,debut,fin,workingDir);
    198185      if ( success ) {
    199186        success = softw->execute(debut,fin,workingDir);
    200187        if ( success ) {
    201           success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir);
     188          success = softw->buildBeamAfterElements(debut,fin,diagnosticBeam_,workingDir);
    202189        }
    203190      }
     191     
    204192      delete softw;
    205193      if ( success ) {
     
    211199      }
    212200      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}
    217214
    218215void dataManager::saveConfiguration( string nameOfCase)
    219216{
    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}
    238233
    239234bool dataManager::restoreElements( string inputFileName)
     
    281276
    282277    // 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
     286particleBeam* dataManager::getDiagnosticBeam(unsigned index)
     287{
     288  if (index >= diagnosticBeam_.size()) {
     289    return NULL;
     290  } else {
     291    return &diagnosticBeam_.at(index);
     292  }
     293}
     294
     295void 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();
    286300       
    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++)
    319308        {
    320             if ( !diagnosticBeam_.at(k-1).momentRepresentationOk() ) diagnosticBeam_.at(k-1).buildMomentRepresentation();
    321             longueur += pspa_->getBeamLine()->getAbstractElement(k-1)->getLenghtOfElement();
    322             valeur = diagnosticBeam_.at(k-1).getXmaxRms();
    323             xcor.push_back(longueur);
    324             ycor.push_back(valeur);
     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);
    325314        }
    326315    }
    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
     324void 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  }
    332354}
    333355
    334356int 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
     360abstractSoftware* 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  
    1313  else if( strstr(s.c_str(),"soleno") ) return soleno;
    1414  else if( strstr(s.c_str(),"fit") ) return fit;
     15  else if( strstr(s.c_str(),"shot") ) return snapshot;
    1516  return inconnu;
    1617}
     
    2425  else if( s == "bend" ) return bend;
    2526  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;
    2729  return inconnu;
    2830}
    29 
    30 
    3131
    3232std::string nomdElements::toName(typedElement eType)
     
    4040  case soleno : return "SOLENOID"; break;
    4141  case fit : return "FIT"; break;
     42  case snapshot : return "SNAPSHOT"; break;
    4243  default : return "UNKNOWN";
    4344  }
    4445}
    45 
    4646
    4747std::string nomdElements::toLabel(typedElement eType)
     
    5555  case soleno :   return "solnd";
    5656  case fit :   return "fit";
     57  case snapshot : return "shot";
    5758  default : return string("");
    5859  }
     
    6970  case soleno :   return 5;
    7071  case fit :   return 4;
     72  case snapshot : return 1;
    7173  default : return 0;
    7274  }
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r341 r342  
     1
    12#include "particleBeam.h"
    23#include "mathematicalConstants.h"
    34#include "PhysicalConstants.h"
    45#include "mathematicalTools.h"
    5 //#include <string>
     6
    67#include <stdio.h>
    78#include <algorithm>
    89#include <sstream>
    9 //#include "environmentVariables.h"
     10
    1011using namespace std;
    1112
    1213particleBeam::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   // }
    1914  P0Transport_ = 0.0;
    2015  particleRepresentationOk_ = false;
     
    3429}
    3530
    36 const beam2Moments&   particleBeam::getTransportMoments() const  {
    37     return rij_;
     31const beam2Moments& particleBeam::getTransportMoments() const  {
     32  return rij_;
    3833}
    3934
     
    5853}
    5954
    60 
    61 double particleBeam::getUnnormalizedEmittanceX() {
     55double particleBeam::getUnnormalizedEmittanceX()
     56{
    6257  double r = getSigmaTransportij(2,1);
    6358  double rac = (1 - r*r);
     
    8277  }
    8378}
    84 
    85 
    8679
    8780void particleBeam::set2Moments(beam2Moments& moments) {
     
    9891  goodPartic_ = particles;
    9992  cout << " particleBeam::setWithParticles taille vect. part. ENREGISTRE " << goodPartic_.size() << endl;
    100   //  printAllXYZ();
    10193  particleRepresentationOk_ = true;
    10294}
    103 
    10495
    10596bool particleBeam::particleRepresentationOk() const {
     
    119110  return goodPartic_;
    120111}
     112
    121113vector<bareParticle>& particleBeam::getParticleVector()
    122114{
    123115  return goodPartic_;
    124116}
    125 
    126 
    127 
    128117
    129118void particleBeam::getVariance(double& varx, double& vary, double& varz) const {
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc

    r316 r342  
     1
    12#include "softwareGenerator.h"
    23#include "abstractElement.h"
     
    45#include "mathematicalConstants.h"
    56#include "PhysicalConstants.h"
    6 //#include "dataManager.h"
    7 
    87
    98softwareGenerator::softwareGenerator() : abstractSoftware()
    10 {
    11   ;
    12 }
    13 
    14 
    15 
     9{;}
    1610
    1711softwareGenerator::softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt)
    18 {
    19   ;
    20 }
    21 
     12{;}
    2213
    2314bool softwareGenerator::createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
     
    3324    return false;
    3425  }
     26
    3527  ofstream outfile;
    3628  string name = workingDir + inputFileName_;
     
    5345}
    5446
    55 
    56 bool  softwareGenerator::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) {
     47bool softwareGenerator::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) {
     48 
     49  bool ExecuteStatus = true;
     50 
    5751  ostringstream sortie;
    58   bool ExecuteStatus = true;
    59   //  resul.clear();
    6052  sortie << " EXECUTION DE GENERATOR DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl;
    6153
    62   char buf[132];
    6354  string generatorJob = workingDir + "generator";
    6455  generatorJob += string("   ");
    6556  generatorJob += workingDir + inputFileName_;
    6657
    67 
    68   ofstream outfile;
    69   string nameOut = workingDir + "generator.output";
    7058  string resultOfRun;
    71   bool success = launchJob(generatorJob, resultOfRun);
     59  bool success = launchJob(generatorJob,resultOfRun);
    7260  sortie << resultOfRun << endl;
    73   if ( !success) {
     61  if ( !success ) {
    7462    sortie << " launching of generator failed " << endl;
    7563    ExecuteStatus = false;
    76   }
    77   else {
     64  } else {
    7865    cout << " execution generator MARCHE " << endl;
    7966    sortie << resultOfRun;
     67    string nameOut = workingDir + "generator.output";
     68    ofstream outfile;
    8069    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 {
    8774      // on copie la sortie dans un fichier 'generator.out'
    8875      outfile << resultOfRun << endl;
     
    9077    }
    9178  }
    92   //  resul =  sortie.str();
    93     dataManager_->consoleMessage(sortie.str());
     79 
     80  dataManager_->consoleMessage(sortie.str());
    9481  return ExecuteStatus;
    9582}
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc

    r333 r342  
    88
    99softwareParmela::softwareParmela() : abstractSoftware()
    10 {
    11   ;
    12 }
     10{;}
    1311
    1412softwareParmela::softwareParmela(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt)
    15 {
    16   ;
    17 }
     13{;}
    1814
    1915bool softwareParmela::createInputFile( particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
     
    2622    return false;
    2723  }
    28 
    2924
    3025  ofstream outfile;
     
    5449  }
    5550
    56 
     51 
    5752  outfile << "TITLE" << endl;
    5853  outfile << " titre provisoire " << endl;
     
    6661    outfile << "INPUT 0 /NP=" << beamBefore->getNbParticles() << endl;
    6762  }
     63
     64 
    6865  for ( k = premier; k <= numeroFin; k++)
    6966    {
    7067      elPtr = dataManager_->getElementPointerFromNumero(k);
     68      if(elPtr->getNomdElement().getElementType() == snapshot) continue;
    7169      outfile << elPtr->parmelaOutputFlow() << endl;
    7270    }
    73 
     71 
    7472  outfile << "ZOUT" << endl;
    7573  outfile << "START /wt=0.0 /dwt=" << globParamPtr_->getIntegrationStep() << "  /nsteps=" << globParamPtr_->getNbSteps() << "  nsc=" << globParamPtr_->getScPeriod() << "  /nout=10" << endl;
     
    8179
    8280
    83 bool  softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir)
    84 {
     81bool softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir)
     82{
     83  bool ExecuteStatus = true;
     84 
    8585  ostringstream sortie;
    86   bool ExecuteStatus = true;
    87   //  resul.clear();
    8886  sortie << " EXECUTION DE PARMELA DE l'ELEMENT " << numeroDeb << " A L'ELEMENT " << numeroFin << endl;
    8987
    90   char buf[132];
    9188  string parmelaJob = workingDir + "parmela";
    9289  parmelaJob += string("   ");
    9390  parmelaJob += workingDir;
    94   //  cout << " job parmela= " << parmelaJob << endl;
    95 
     91 
    9692  string resultOfRun;
    97   bool success = launchJob(parmelaJob, resultOfRun);
     93  bool success = launchJob(parmelaJob,resultOfRun);
    9894  sortie << resultOfRun << endl;
    99   if ( !success) {
     95  if ( !success ) {
    10096    sortie << " launching of parmela failed " << endl;
    10197    ExecuteStatus = false;
    102   }
    103   else {
     98  } else {
    10499    sortie << " successful launching of parmela " << endl;
    105100    cout << " execution parmela MARCHE " << endl;
     
    112107  }
    113108
    114   //  resul =  sortie.str();
    115     dataManager_->consoleMessage(sortie.str());
    116  
     109  dataManager_->consoleMessage(sortie.str());
    117110  return ExecuteStatus;
    118111}
    119112
    120 
    121 bool  softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) {
     113bool softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir)
     114{
    122115  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
    127133      beams.push_back(particleBeam());
    128134      vector<double> centroid;
    129135      bareParticle refPart;
    130136      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))
    132140        {
    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) {
    135142            int avantDernier = beams.size() -2;
    136143            beams.back() = beams.at(avantDernier);
    137144          } else {
    138             // sortie << " reading parmdesz  failed " << endl;
    139             dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : reading parmdesz  failed " );
     145            dataManager_->consoleMessage("softwareParmela::buildBeamAfterElements : reading parmdesz failed");
    140146            result = false;
    141147            break;
    142148          }
    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++;
    147155    }
     156
    148157  return result;
    149158}
    150159
    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;
     160bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles )
     161{
    157162  string nomfilefais = workingDir + "parmdesz";
    158163  cout << " nom fichier desz : " << nomfilefais << endl;
    159   filefais = fopen(nomfilefais.c_str(), "r");
     164  FILE *filefais = fopen(nomfilefais.c_str(), "r");
    160165
    161166  if ( filefais == (FILE*)0 ) {
    162167    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   else cout << " 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 
    168173  parmelaParticle partic;
    169174  std::vector<parmelaParticle> faisceau;
    170 
    171   //  unsigned indexElement = numeroElement-1;
    172  
    173 
    174 
    175 
    176175  int testNombrePartRef =0;
    177176  double phaseRef = 0.0;
    178177
    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 ) {
    182182        faisceau.push_back(partic);
    183 
    184183        if ( partic.np == 1 ) {
    185184          // en principe on est sur la particule de reference
     
    200199        }
    201200      }
    202   }
     201    } //while
    203202
    204203  if ( faisceau.size() == 0)
     
    213212  // avec freq en Mhz et dphi en degres et résultat en cm:
    214213  double FACTEUR =  83.3333;  // ameliorer la precision
    215 
    216 
    217214
    218215  // pour l'instant on choisit un centroid nul;
     
    232229  // contrairement a ce qu'indique la notice PARMELA, dans parmdesz, les xp et yp
    233230  // 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;
    236233    xp=faisceau.at(k).xxp;
    237     y=faisceau.at(k).yy;
     234    y= faisceau.at(k).yy;
    238235    yp=faisceau.at(k).yyp;
    239 
    240236    // dephasage par rapport a la reference 
    241237    dephas = faisceau.at(k).phi - phaseRef; // degrés
     
    250246    particles.at(k) = bareParticle(pos,betagamma);
    251247  }
     248 
    252249  return true;
    253250}
Note: See TracChangeset for help on using the changeset viewer.