Changeset 488 in PSPA


Ignore:
Timestamp:
Feb 7, 2014, 2:00:55 PM (10 years ago)
Author:
lemeur
Message:

lecture fichier sauvegarde AML

Location:
Interface_Web/trunk/pspaWT
Files:
2 added
2 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/History

    r485 r488  
    55     PSPA - Plateforme de simulation en physique des accélérateurs
    66     =========================================================
     7
     87 février 2014  : Guy Le Meur
     9- implémentation de la lecture du fichier de sauvegarde AML.
     10
    711
    81228 janvier 2014 : Guy Le Meur
  • Interface_Web/trunk/pspaWT/cmt/requirements

    r467 r488  
    2727 ../sources/controler/src/elementSnapshot.cc \
    2828 ../sources/controler/src/elementMultipole.cc \
     29 ../sources/controler/src/elementQuadrupole.cc \       
     30 ../sources/controler/src/elementSextupole.cc \
    2931 ../sources/controler/src/globalParameters.cc \
    3032 ../sources/controler/src/abstractElement.cc \
     
    5557 ../sources/userInterface/src/GWt_elementSnapshot.cc \
    5658 ../sources/userInterface/src/GWt_elementMpole.cc \
     59 ../sources/userInterface/src/GWt_elementQpole.cc \
     60 ../sources/userInterface/src/GWt_elementSpole.cc \
    5761 ../sources/userInterface/src/GWt_abstractElement.cc \
    5862 ../sources/userInterface/src/GWt_console.cc \
  • Interface_Web/trunk/pspaWT/sources/controler/include/abstractElement.h

    r469 r488  
    1010
    1111#include "UAP/UAPNode.hpp"
     12#include "AMLtools.h"
     13
    1214using namespace std;
    1315
     
    3436  void setDefaultValues();
    3537  void setDefaults();
    36  
     38
     39
     40 inline  UAPNode* setAMLelementHeader(UAPNode* elementNode) {
     41  UAPNode* ele = elementNode->addChild("element");
     42  ele->addAttribute("name",specificName_);
     43  UAPNode* node = ele->addChild("description");
     44  node->addAttribute("type",elementName_.getGenericLabel());
     45  return ele;
     46 }
     47 
     48 inline bool checkAMLelementGenericName(UAPNode* entree) {
     49  if ( !entree ) return false;
     50  string nonGenerique;
     51  AMLtools::readAMLParameterAttribut(entree, "description", "type", nonGenerique);
     52  if ( nonGenerique != elementName_.getGenericLabel() ) {
     53    cout << " abstractElement::checkAMLelementGenericName ERREUR d'element : " << nonGenerique << " ? attendu : " <<  elementName_.getGenericLabel() << endl;
     54    return false;
     55  }
     56  specificName_ = entree->getAttribute("name")->getValue();
     57  return true;
     58 }
     59
    3760 public :
    3861 
     
    5679  virtual void setParametersString(string* param) = 0;
    5780  virtual string* getParametersString() const = 0;
    58   virtual string FileOutputFlow() const = 0;
     81  //  virtual string FileOutputFlow() const = 0;
    5982  virtual vector< pair<string, vector<string> > > parametersToSoftware () const =0;
    60   virtual void FileInput(ifstream& ifs) = 0;
     83  //  virtual void FileInput(ifstream& ifs) = 0;
    6184  virtual string print() = 0;
    6285  virtual void InputRep(UAPNode* root) = 0;
     86  virtual void FileAMLInput(UAPNode* entree) = 0;
    6387   
    6488};
  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r481 r488  
    5454   @param filename
    5555   */
    56   void saveConfiguration(string folder, string filename);
    57   bool restoreElements(string inputFileName);
    58  
     56  //  void saveConfiguration(string folder, string filename);
     57  //  bool restoreElements(string inputFileName);
     58  bool restoreAMLElements(string inputFileName);
     59
    5960  void writeToAMLFile(string fileName);
    6061   
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementBeam.h

    r424 r488  
    3535    //    virtual string transportOutputFlow() const;
    3636   
    37     virtual string FileOutputFlow() const;   
    38     virtual void FileInput(ifstream& ifs);
     37    //    virtual string FileOutputFlow() const;   
     38    //    virtual void FileInput(ifstream& ifs);
    3939    virtual void InputRep(UAPNode* root);
     40  virtual void FileAMLInput(UAPNode* entree);
    4041
    4142    /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementBend.h

    r424 r488  
    77#include "mathematicalTools.h"
    88//#include "PhysicalConstants.h"
     9
    910
    1011using namespace std;
     
    4243  //   virtual string transportOutputFlow() const;
    4344 
    44   virtual string FileOutputFlow() const;
    45   virtual void FileInput(ifstream& ifs);
     45  //  virtual string FileOutputFlow() const;
     46  //  virtual void FileInput(ifstream& ifs);
     47
    4648  virtual void InputRep(UAPNode* root);
     49  virtual void FileAMLInput(UAPNode* entree);
    4750 
    4851  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementCell.h

    r424 r488  
    55#include <iostream>
    66#include <sstream>
     7
    78
    89#include "abstractElement.h"
     
    4243  // virtual string transportOutputFlow() const */
    4344 
    44   virtual string FileOutputFlow() const;
    45   virtual void FileInput(ifstream& ifs);
     45  //  virtual string FileOutputFlow() const;
     46  //  virtual void FileInput(ifstream& ifs);
    4647  virtual void InputRep(UAPNode* root);
     48  virtual void FileAMLInput(UAPNode* entree);
    4749 
    4850  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementDrift.h

    r424 r488  
    2424  //    virtual string transportOutputFlow() const;
    2525   
    26     virtual string FileOutputFlow() const;
    27     virtual void FileInput(ifstream& ifs);
    28     virtual void InputRep(UAPNode* root);
     26  //  virtual string FileOutputFlow() const;
     27  //  virtual void FileInput(ifstream& ifs);
     28  virtual void InputRep(UAPNode* root);
     29  virtual void FileAMLInput(UAPNode* entree);
    2930
    3031    /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementFit.h

    r424 r488  
    3030  //  virtual string transportOutputFlow() const;
    3131   
    32   virtual  string FileOutputFlow() const;
    33   virtual void FileInput(ifstream& ifs);
     32  // virtual  string FileOutputFlow() const;
     33  //  virtual void FileInput(ifstream& ifs);
    3434  virtual void InputRep(UAPNode* root);
     35  virtual void FileAMLInput(UAPNode* entree);
    3536
    3637  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementMultipole.h

    r431 r488  
    2020  virtual void setParametersString(string* param);
    2121  virtual vector< pair<string, vector<string> > > parametersToSoftware () const;
    22   virtual string FileOutputFlow() const;
    23   virtual void FileInput(ifstream& ifs);
     22  // virtual string FileOutputFlow() const;
     23  //  virtual void FileInput(ifstream& ifs);
    2424  virtual void InputRep(UAPNode* root);
     25  virtual void FileAMLInput(UAPNode* entree);
    2526
    2627  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementQuadrupole.h

    r487 r488  
    99class elementQuadrupole : public abstractElement
    1010{
    11   double length_;
     11  //  double length_;
    1212  double component_;
    1313   
     
    2020  virtual void setParametersString(string* param);
    2121  virtual vector< pair<string, vector<string> > > parametersToSoftware () const;
    22   virtual string FileOutputFlow() const;
    23   virtual void FileInput(ifstream& ifs);
     22  // virtual string FileOutputFlow() const;
     23  //  virtual void FileInput(ifstream& ifs);
    2424  virtual void InputRep(UAPNode* root);
     25  virtual void FileAMLInput(UAPNode* entree);
    2526
    2627  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementRfgun.h

    r424 r488  
    5151  // virtual string generatorOutputFlow() const;
    5252
    53   virtual string FileOutputFlow() const;   
    54   virtual void FileInput(ifstream& ifs);
     53  // virtual string FileOutputFlow() const;   
     54  //  virtual void FileInput(ifstream& ifs);
    5555  virtual void InputRep(UAPNode* root);
     56  virtual void FileAMLInput(UAPNode* entree);
    5657
    5758  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementSextupole.h

    r487 r488  
    99class elementSextupole : public abstractElement
    1010{
    11   double length_;
     11  //  double length_;
    1212  double component_;
    1313   
     
    2020  virtual void setParametersString(string* param);
    2121  virtual vector< pair<string, vector<string> > > parametersToSoftware () const;
    22   virtual string FileOutputFlow() const;
    23   virtual void FileInput(ifstream& ifs);
     22  // virtual string FileOutputFlow() const;
     23  //  virtual void FileInput(ifstream& ifs);
    2424  virtual void InputRep(UAPNode* root);
     25  virtual void FileAMLInput(UAPNode* entree);
    2526
    2627  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementSnapshot.h

    r442 r488  
    2525  virtual void setParametersString(string* param);
    2626  virtual vector< pair<string, vector<string> > > parametersToSoftware () const;
    27   // virtual  string parmelaOutputFlow() const;
    28   // virtual string transportOutputFlow() const; 
    2927   
    30   virtual string FileOutputFlow() const; 
    31   virtual void FileInput(ifstream& ifs);
     28  //  virtual string FileOutputFlow() const; 
     29  //  virtual void FileInput(ifstream& ifs);
    3230  virtual void InputRep(UAPNode* root);
     31  virtual void FileAMLInput(UAPNode* entree);
    3332  string print(); 
    3433};
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementSoleno.h

    r424 r488  
    2727  virtual string* getParametersString() const;
    2828  virtual vector< pair<string, vector<string> > > parametersToSoftware () const;
    29   // virtual  string parmelaOutputFlow() const;
    30   // virtual string transportOutputFlow() const;
    3129   
    32   virtual  string FileOutputFlow() const;
    33   virtual void FileInput(ifstream& ifs);
     30  //  virtual  string FileOutputFlow() const;
     31  //  virtual void FileInput(ifstream& ifs);
    3432  virtual void InputRep(UAPNode* root);
     33  virtual void FileAMLInput(UAPNode* entree);
    3534
    3635  /** return a string with all parameters and value */
  • Interface_Web/trunk/pspaWT/sources/controler/include/globalParameters.h

    r424 r488  
    4141  }
    4242 
     43/* inline  bool readAMLParameterAttribut(UAPNode* parametersNode, string parameterName, string attributName, double& resultat) { */
     44/*   if ( !parametersNode ) return false; */
     45/*   UAPNode* parametre = parametersNode->getChildByName(parameterName); */
     46/*   if ( !parametre ) return false; */
     47/*   UAPAttribute* att =  parametre->getAttribute(attributName); */
     48/*   if ( att ) { */
     49/*     att->getDouble( resultat); */
     50/*     return true; */
     51/*   } else return false; */
     52/* } */
     53
     54/* inline  bool readAMLParameterAttribut(UAPNode* parametersNode, string parameterName, string attributName, int& resultat) { */
     55/*   if ( !parametersNode ) return false; */
     56/*   UAPNode* parametre = parametersNode->getChildByName(parameterName); */
     57/*   if ( !parametre ) return false; */
     58/*   UAPAttribute* att =  parametre->getAttribute(attributName); */
     59/*   if ( att ) { */
     60/*     att->getInt( resultat); */
     61/*     return true; */
     62/*   } else return false; */
     63/* } */
     64
    4365 public:
    4466 
     
    5678  string* getParametersString() const;
    5779  void setParametersString(string* param);
    58   string FileOutputFlow() const;
    59   void FileInput(ifstream& ifs);
     80  // string FileOutputFlow() const;
     81  //  void FileInput(ifstream& ifs);
     82  void FileAMLInput( UAPNode* entree);
    6083
    6184  void InputRep(UAPNode* root);
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r485 r488  
    1414#include "UAP/UAPUtilities.hpp"
    1515#include "AML/AMLReader.hpp"
     16#include "AMLtools.h"
    1617
    1718#define BAVARD 0
     
    139140}
    140141
    141 void dataManager::saveConfiguration(string folder, string nameOfFile)
    142 {
    143   ofstream outfile;
    144   //string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save";
    145   cout << " dataManager::saveConfiguration : suppression du folder dans le nom de " << endl;
    146   cout << " sauvegarde, en attendant que ce soit autre chose que le sessionId" << endl;
    147   cout << " et qu'on puisse restaurer normalement" << endl;
    148 
    149   string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save"; 
    150   // make dir if not exist
    151   boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/");
    152  
    153   outfile.open(name.c_str(), ios::out);
    154   if (!outfile) {
    155     cerr<<" ERROR opening output file for persistency "<<name<<endl;
    156   }
    157  
    158   outfile << globParam_.FileOutputFlow();
    159 
    160   // FIXME Francois: Comment sauver la configuration des section ?
    161   for (unsigned int a=0; a< jobList_.size(); a++) {
    162     outfile << jobList_[a]->getSectorParameters().FileOutputFlow();
    163   }
    164   // END
    165  
    166   abstractElement* elPtr;
    167   for (unsigned k = 0; k < jobList_.size(); k++) {
    168     sector* sector = jobList_[k];
    169     for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) {
    170       sectionToExecute* section = sector->getSectionsToExecute()[l];
    171       for (unsigned m = 0; m < section->getElements().size(); m++) {
    172         elPtr = section->getElements()[m];
    173         outfile << elPtr->FileOutputFlow();
    174       }
    175     }
    176   }
    177   outfile.close();
    178 }
     142// void dataManager::saveConfiguration(string folder, string nameOfFile)
     143// {
     144//   ofstream outfile;
     145//   //string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save";
     146//   cout << " dataManager::saveConfiguration : suppression du folder dans le nom de " << endl;
     147//   cout << " sauvegarde, en attendant que ce soit autre chose que le sessionId" << endl;
     148//   cout << " et qu'on puisse restaurer normalement" << endl;
     149
     150//   string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save"; 
     151//   // make dir if not exist
     152//   boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/");
     153 
     154//   outfile.open(name.c_str(), ios::out);
     155//   if (!outfile) {
     156//     cerr<<" ERROR opening output file for persistency "<<name<<endl;
     157//   }
     158 
     159//   outfile << globParam_.FileOutputFlow();
     160
     161//   // FIXME Francois: Comment sauver la configuration des section ?
     162//   for (unsigned int a=0; a< jobList_.size(); a++) {
     163//     outfile << jobList_[a]->getSectorParameters().FileOutputFlow();
     164//   }
     165//   // END
     166 
     167//   abstractElement* elPtr;
     168//   for (unsigned k = 0; k < jobList_.size(); k++) {
     169//     sector* sector = jobList_[k];
     170//     for (unsigned l = 0; l < sector->getSectionsToExecute().size(); l++) {
     171//       sectionToExecute* section = sector->getSectionsToExecute()[l];
     172//       for (unsigned m = 0; m < section->getElements().size(); m++) {
     173//         elPtr = section->getElements()[m];
     174//         outfile << elPtr->FileOutputFlow();
     175//       }
     176//     }
     177//   }
     178//   outfile.close();
     179// }
    179180
    180181// ecriture sur fichier AML
     
    219220}
    220221
    221 bool dataManager::restoreElements(string inputFileName)
     222// bool dataManager::restoreElements(string inputFileName)
     223// {
     224//   cout << "***********************************" << endl;
     225//   cout << " dataManager::restoreElements() fichier :" << inputFileName << endl << endl;
     226
     227//   ifstream infile;
     228//   string name = inputFileName;
     229//   infile.open(name.c_str(), ios::in);
     230//   if (!infile) {
     231//     cerr << " error opening input stream " << name << endl;
     232//     return false;
     233//   }
     234//   else cout << " successful opening input stream : " << name << endl;
     235 
     236//   //NOTE:: je ne sais pas si les "secteurs" seront conservés, aussi pour ne pas trop changer les fichiers je lis les données aprÚs "globals" dans la boucle
     237 
     238//   // Clear the BeamLine
     239//   jobList_.clear();
     240
     241//   // FIXME : For test purpose !!!
     242//   sector* mySect = addNewSector();
     243 
     244//   nomdElements::typedElement elementType;
     245//   string elementLabel;
     246//   abstractElement* nouveau = NULL;
     247//   while (infile >> elementLabel) {
     248//     if (elementLabel == string("globals") ) {
     249//       globParam_.raz();
     250//       globParam_.FileInput(infile);
     251//     } else if (elementLabel == string("sectors") ) {
     252//       // FIXME Francois !!!!!!!
     253// //      sectorParam_.raz();
     254// //      sectorParam_.FileInput(infile);
     255//       // END
     256//     } else {
     257//       elementType = nomdElements::getTypeFromLabel(elementLabel);
     258//       nouveau = mySect->addElementAfter(elementType,nouveau);
     259//       if ( nouveau == NULL ) {
     260//      cerr << " dataManager::restoreElements() : restore element " << elementLabel << " failed " << endl;
     261//      return false;
     262//       } else {
     263//      nouveau->FileInput(infile);
     264//       }
     265//     }
     266//   }// while
     267 
     268// #if BAVARD > 1
     269// /*  unsigned k;
     270//   for(k = 0; k < getBeamLineSize(); k++) {
     271//     abstractElement* ptr = pspa_->getBeamLine_deprecated()->getAbstractElement(k);
     272//     cout << "recupere " << ptr->getLabel() << endl;
     273//   }
     274// */
     275// #endif
     276
     277//   infile.close();
     278//   return true;
     279// }
     280
     281bool dataManager::restoreAMLElements(string inputFileName)
    222282{
    223283  cout << "***********************************" << endl;
    224   cout << " dataManager::restoreElements() fichier :" << inputFileName << endl << endl;
    225 
    226   ifstream infile;
    227   string name = inputFileName;
    228   infile.open(name.c_str(), ios::in);
    229   if (!infile) {
    230     cerr << " error opening input stream " << name << endl;
     284  cout << " dataManager::restoreAMLElements() fichier :" << inputFileName << endl << endl;
     285
     286  AMLReader reader;
     287  UAPNode* uap_root = NULL;
     288  uap_root = reader.AMLFileToAMLRep (inputFileName);
     289  if ( !uap_root ) {
     290    cout << " dataManager::restoreAMLElements ERREUR AML lecture fichier  " << inputFileName << endl;
    231291    return false;
    232292  }
    233   else cout << " successful opening input stream : " << name << endl;
    234  
     293
     294  else cout << " successful opening  : " << inputFileName << " UAP_ROOT= " << uap_root->getName() << endl;
     295  UAPNode* uap_labname = NULL;
     296
     297NodeVec laboratories = uap_root->getSubNodesByName(string("laboratory"));
     298 cout << " dataManager::restoreAMLElements nombre de <laboratory> : " << laboratories.size() << endl;
     299
     300 uap_labname = *laboratories.begin();
     301
     302 if ( !uap_labname ) {
     303   cout << " dataManager::restoreAMLElements : fichier non conforme, on ne trouve pas <laboratory...> " << endl;
     304 } else {
     305   cout << " dataManager::restoreAMLElements : GO !" << endl;
     306 }
     307
     308
    235309  //NOTE:: je ne sais pas si les "secteurs" seront conservés, aussi pour ne pas trop changer les fichiers je lis les données aprÚs "globals" dans la boucle
    236310 
     
    241315  sector* mySect = addNewSector();
    242316 
     317
     318   UAPNode* parametresGlobaux = uap_labname->getChildByName(string("global"));
     319  if ( !parametresGlobaux ) {
     320    cout << " dataManager::restoreAMLElements GLOBAUX NON TROUVES " << endl;
     321  } else {
     322    cout << " dataManager::restoreAMLElements GENIAL ! " << endl;
     323  }
     324  globParam_.raz();
     325  globParam_.FileAMLInput(parametresGlobaux);
     326
     327
    243328  nomdElements::typedElement elementType;
    244329  string elementLabel;
    245330  abstractElement* nouveau = NULL;
    246   while (infile >> elementLabel) {
    247     if (elementLabel == string("globals") ) {
    248       globParam_.raz();
    249       globParam_.FileInput(infile);
    250     } else if (elementLabel == string("sectors") ) {
    251       // FIXME Francois !!!!!!!
    252 //      sectorParam_.raz();
    253 //      sectorParam_.FileInput(infile);
    254       // END
    255     } else {
    256       elementType = nomdElements::getTypeFromLabel(elementLabel);
    257       nouveau = mySect->addElementAfter(elementType,nouveau);
     331
     332
     333  NodeVec sectorNode = uap_root->getSubNodesByName(string("sector"));
     334
     335  if ( !sectorNode.size() ) {
     336    cout << " dataManager::restoreAMLElements ERREUR lecture fichier : pas de sectors ? " << endl;
     337    return false;
     338  }
     339
     340
     341  NodeVec& listElem = ( *sectorNode.begin() )->getChildren();
     342  if (  !listElem.size() ) {
     343    cout << " dataManager::restoreAMLElements ERREUR lecture fichier : pas d'elements ? " << endl;
     344    return false;
     345  } else {
     346    cout << " dataManager::restoreAMLElements : liste elements non vide : SUCCES " << endl;
     347  }
     348
     349  for (NodeVecIter iter = listElem.begin(); iter != listElem.end(); iter++) {
     350
     351    string nomNoeud = (*iter)->getName();
     352    if ( nomNoeud != string("element") ) {
     353      cout << " le secteur contient un non-element : " << nomNoeud << endl;
     354      continue;
     355    }
     356
     357    UAPAttribute* att = NULL;
     358    att = (*iter)->getAttribute("name");
     359
     360    cout << " dataManager::restoreAMLElements trouve element " << att->getValue();
     361
     362    string nomGenerique;
     363    AMLtools::readAMLParameterAttribut(*iter, "description", "type", nomGenerique);
     364
     365    // UAPNode*  genericName = (*iter)->getChildByName("description");
     366    // att = genericName->getAttribute("type");
     367
     368    cout <<  " de type " << nomGenerique << endl;
     369
     370
     371    elementType = nomdElements::getTypeFromLabel(nomGenerique);
     372    nouveau = mySect->addElementAfter(elementType,nouveau);
     373
    258374      if ( nouveau == NULL ) {
    259         cerr << " dataManager::restoreElements() : restore element " << elementLabel << " failed " << endl;
     375        cerr << " dataManager::restoreAMLElements() : restore element " << att->getValue() << " failed " << endl;
    260376        return false;
    261377      } else {
    262         nouveau->FileInput(infile);
     378        nouveau->FileAMLInput(*iter);
    263379      }
    264     }
    265   }// while
    266  
    267 #if BAVARD > 1
    268 /*  unsigned k;
    269   for(k = 0; k < getBeamLineSize(); k++) {
    270     abstractElement* ptr = pspa_->getBeamLine_deprecated()->getAbstractElement(k);
    271     cout << "recupere " << ptr->getLabel() << endl;
    272   }
    273 */
    274 #endif
    275 
    276   infile.close();
     380  }
     381
     382 
    277383  return true;
    278384}
     385
    279386
    280387particleBeam* dataManager::getDiagnosticBeam(unsigned index)
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementBeam.cc

    r424 r488  
    9797// }
    9898
    99 string elementBeam::FileOutputFlow() const
    100 {
    101   ostringstream sortie;
    102   // sortie << elementName_.getElementType() << endl;
    103   sortie << elementName_.getGenericLabel() << endl;
    104   sortie  << specificName_ << endl;
    105   sortie << x_ << "  " << xp_ << " " <<  y_  << " " <<  yp_  << endl;
    106   sortie << dl_ << "  " << del_ << " " <<  p0_  << endl;
    107   cout << " elementBeam::FileOutputFlow, p0 = " << p0_ << endl;
    108   return sortie.str();
    109 }
     99// string elementBeam::FileOutputFlow() const
     100// {
     101//   ostringstream sortie;
     102//   // sortie << elementName_.getElementType() << endl;
     103//   sortie << elementName_.getGenericLabel() << endl;
     104//   sortie  << specificName_ << endl;
     105//   sortie << x_ << "  " << xp_ << " " <<  y_  << " " <<  yp_  << endl;
     106//   sortie << dl_ << "  " << del_ << " " <<  p0_  << endl;
     107//   cout << " elementBeam::FileOutputFlow, p0 = " << p0_ << endl;
     108//   return sortie.str();
     109// }
    110110
    111111vector< pair<string, vector<string> > > elementBeam::parametersToSoftware () const
     
    128128}
    129129
    130 void elementBeam::elementBeam::FileInput(ifstream& ifs)
    131 {
    132   ifs >> specificName_;
    133   ifs >> x_ >> xp_ >>  y_ >> yp_;
    134   ifs >> dl_ >> del_ >> p0_;
    135   cout << " elementBeam::FileFileInput, p0 = " << p0_ << endl;
     130// void elementBeam::FileInput(ifstream& ifs)
     131// {
     132//   ifs >> specificName_;
     133//   ifs >> x_ >> xp_ >>  y_ >> yp_;
     134//   ifs >> dl_ >> del_ >> p0_;
     135//   cout << " elementBeam::FileFileInput, p0 = " << p0_ << endl;
     136//   lenghtElem_ = getLenghtOfElement();
     137//   cout << " elementBeam::FileInput calcule longueur = " << lenghtElem_ << endl;
     138// }
     139
     140void elementBeam::FileAMLInput(UAPNode* entree)
     141{
     142  // if ( !entree ) return;
     143  // string nonGenerique;
     144  // AMLtools::readAMLParameterAttribut(*iter, "description", "type", nonGenerique);
     145  // if ( nonGenerique != elementName_.getGenericLabel() ) {
     146  //   cout << " elementBeam::FileAMLInput ERREUR d'element : " << nonGenerique << " ? attendu : " <<  elementName_.getGenericLabel() << endl;
     147  //   return;
     148  // }
     149
     150  if ( !checkAMLelementGenericName(entree) ) return;
     151  UAPNode* faisceau = entree->getChildByName("beam");
     152  if ( !faisceau ) {
     153    cout << " elementBeam::FileAMLInput ERREUR pas de noeud AML <beam> : " << endl;
     154    return;
     155  }
     156  AMLtools::readAMLParameterAttribut(faisceau, "11", "design", x_);
     157  AMLtools::readAMLParameterAttribut(faisceau, "22", "design", xp_);
     158  AMLtools::readAMLParameterAttribut(faisceau, "33", "design", y_);
     159  AMLtools::readAMLParameterAttribut(faisceau, "44", "design", yp_);
     160  AMLtools::readAMLParameterAttribut(faisceau, "55", "design", dl_);
     161  AMLtools::readAMLParameterAttribut(faisceau, "66", "design", del_);
     162  AMLtools::readAMLParameterAttribut(faisceau, "pc", "design", p0_);
    136163  lenghtElem_ = getLenghtOfElement();
    137   cout << " elementBeam::FileInput calcule longueur = " << lenghtElem_ << endl;
    138 }
     164  cout << " elementBeam::FileAMLInput calcule longueur = " << lenghtElem_ << endl;
     165}
     166
     167
    139168
    140169string elementBeam::print()
     
    161190void elementBeam::InputRep(UAPNode* root)
    162191{
    163   UAPNode* ele = root->addChild("element");
    164   ele->addAttribute("name",specificName_);
     192  // UAPNode* ele = root->addChild("element");
     193  // ele->addAttribute("name",specificName_);
     194  UAPNode* ele = setAMLelementHeader(root);
    165195 
    166196  UAPNode* node = ele->addChild("beam");
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementBend.cc

    r424 r488  
    106106
    107107
    108 string elementBend::FileOutputFlow() const
    109 {
    110   ostringstream sortie;
    111   //    sortie << elementName_.getElementType() << endl;
    112   sortie << elementName_.getGenericLabel() << endl;
    113   sortie  << specificName_ << endl;
    114   sortie << angleDeg_ << "  " << radius_ << " " <<  aperture_  << endl;
    115   sortie << beta1_ << "  " << beta2_ << " " << momentum_ << endl;
    116   return sortie.str();
    117 }
     108// string elementBend::FileOutputFlow() const
     109// {
     110//   ostringstream sortie;
     111//   //    sortie << elementName_.getElementType() << endl;
     112//   sortie << elementName_.getGenericLabel() << endl;
     113//   sortie  << specificName_ << endl;
     114//   sortie << angleDeg_ << "  " << radius_ << " " <<  aperture_  << endl;
     115//   sortie << beta1_ << "  " << beta2_ << " " << momentum_ << endl;
     116//   return sortie.str();
     117// }
    118118
    119119vector< pair<string, vector<string> > > elementBend::parametersToSoftware () const
     
    138138}
    139139
    140 void elementBend::FileInput(ifstream& ifs)
    141 {
    142   ifs >> specificName_;
    143   ifs >> angleDeg_ >> radius_ >>  aperture_;
    144   ifs >> beta1_ >> beta2_ >> momentum_;
    145     lenghtElem_ = getLenghtOfElement();
    146     cout << " elementBend::FileInput calcule longueur = " << lenghtElem_ << endl;
    147 }
     140// void elementBend::FileInput(ifstream& ifs)
     141// {
     142//   ifs >> specificName_;
     143//   ifs >> angleDeg_ >> radius_ >>  aperture_;
     144//   ifs >> beta1_ >> beta2_ >> momentum_;
     145//     lenghtElem_ = getLenghtOfElement();
     146//     cout << " elementBend::FileInput calcule longueur = " << lenghtElem_ << endl;
     147// }
    148148
    149149string elementBend::print()
     
    167167  return txt;
    168168}
     169void elementBend::FileAMLInput(UAPNode* entree)
     170{
     171  if ( !checkAMLelementGenericName(entree) ) return;
     172
     173  AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_);
     174  AMLtools::readAMLParameterAttribut(entree, "momentum", "design", momentum_);
     175
     176  UAPNode* bend = entree->getChildByName("bend");
     177  if ( !bend ) {
     178    cout << " elementBend::FileAMLInput ERREUR pas de noeud AML <bend>  " << endl;
     179    return;
     180  }
     181  AMLtools::readAMLParameterAttribut(bend, "g", "design", radius_);
     182  // g = 1/r
     183
     184  if ( radius_ != 0.0 ) {
     185    radius_ = 1./radius_;
     186  // angle en degres, la longeur est en cm, le rayon en metres :
     187    angleDeg_ = 0.01*lenghtElem_/(radius_*DEG_TO_RADIANS);
     188  }
     189  AMLtools::readAMLParameterAttribut(bend, "e1", "design", beta1_);
     190  AMLtools::readAMLParameterAttribut(bend, "e2", "design", beta2_);
     191
     192
     193  UAPNode* ouverture = entree->getChildByName("aperture");
     194  if ( !ouverture ) {
     195    cout << " elementBend::FileAMLInput ERREUR pas de noeud AML <aperture>  " << endl;
     196    return;
     197  }
     198  AMLtools::readAMLParameterAttribut(ouverture, "xy_limit", "design", aperture_);
     199
     200
     201
     202
     203}
     204
    169205
    170206void elementBend::InputRep(UAPNode* root)
    171207{
    172   UAPNode* ele = root->addChild("element");
    173   ele->addAttribute("name",specificName_);
     208  // UAPNode* ele = root->addChild("element");
     209  // ele->addAttribute("name",specificName_);
     210  UAPNode* ele = setAMLelementHeader(root);
    174211
    175212  string txt = "";
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementCell.cc

    r424 r488  
    102102
    103103
    104 string elementCell::FileOutputFlow() const
    105 {
    106   ostringstream sortie;
    107   //    sortie << elementName_.getElementType()  << endl;
    108   sortie << elementName_.getGenericLabel() << endl;
    109   sortie  << specificName_ << endl;
    110   sortie << lenghtElem_ << " " << aperture_ << endl;
    111   sortie << initialPhase_ << "  " << acceleratingField_ << endl;
    112   sortie << phaseStepMax_ << endl;
    113   sortie << acceleratingShapeFile_ << endl;
    114   sortie << focusingMagFile_ << endl;
    115   sortie << offsetMag_ << " " << scaleFactor_ << endl;
    116   return sortie.str();
    117 }
     104// string elementCell::FileOutputFlow() const
     105// {
     106//   ostringstream sortie;
     107//   //    sortie << elementName_.getElementType()  << endl;
     108//   sortie << elementName_.getGenericLabel() << endl;
     109//   sortie  << specificName_ << endl;
     110//   sortie << lenghtElem_ << " " << aperture_ << endl;
     111//   sortie << initialPhase_ << "  " << acceleratingField_ << endl;
     112//   sortie << phaseStepMax_ << endl;
     113//   sortie << acceleratingShapeFile_ << endl;
     114//   sortie << focusingMagFile_ << endl;
     115//   sortie << offsetMag_ << " " << scaleFactor_ << endl;
     116//   return sortie.str();
     117// }
    118118
    119119vector< pair<string, vector<string> > > elementCell::parametersToSoftware () const
     
    140140}
    141141
    142 void elementCell::FileInput(ifstream& ifs)
    143 {
    144   ifs >> specificName_;
    145   ifs >> lenghtElem_ >>  aperture_;
    146   ifs >> initialPhase_ >> acceleratingField_;
    147   ifs >> phaseStepMax_;
    148   ifs >> acceleratingShapeFile_;
    149   ifs >> focusingMagFile_;
    150   ifs >> offsetMag_ >> scaleFactor_;
    151 }
     142// void elementCell::FileInput(ifstream& ifs)
     143// {
     144//   ifs >> specificName_;
     145//   ifs >> lenghtElem_ >>  aperture_;
     146//   ifs >> initialPhase_ >> acceleratingField_;
     147//   ifs >> phaseStepMax_;
     148//   ifs >> acceleratingShapeFile_;
     149//   ifs >> focusingMagFile_;
     150//   ifs >> offsetMag_ >> scaleFactor_;
     151// }
    152152
    153153string elementCell::print()
     
    178178void elementCell::InputRep(UAPNode* root)
    179179{
    180   UAPNode* ele = root->addChild("element");
    181   ele->addAttribute("name",specificName_);
     180  // UAPNode* ele = root->addChild("element");
     181  // ele->addAttribute("name",specificName_);
     182
     183  UAPNode* ele = setAMLelementHeader(root);
     184
    182185
    183186  UAPNode* node = ele->addChild("methods");
     
    216219  }
    217220}
     221
     222
     223void elementCell::FileAMLInput(UAPNode* entree)
     224{
     225  if ( !checkAMLelementGenericName(entree) ) return;
     226  AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_);
     227
     228  UAPNode* ouverture = entree->getChildByName("aperture");
     229  if ( !ouverture ) {
     230    cout << " elementCell::FileAMLInput ERREUR pas de noeud AML <aperture>  " << endl;
     231    return;
     232  }
     233  AMLtools::readAMLParameterAttribut(ouverture, "xy_limit", "design", aperture_);
     234
     235  UAPNode* cavite = entree->getChildByName("linac_cavity");
     236  if ( !cavite ) {
     237    cout << " elementCell::FileAMLInput ERREUR pas de noeud AML <linac_cavity>  " << endl;
     238    return;
     239  }
     240
     241  AMLtools::readAMLParameterAttribut(cavite, "phase0", "design", initialPhase_);
     242  AMLtools::readAMLParameterAttribut(cavite, "gradient", "design", acceleratingField_);
     243
     244  AMLtools::readAMLParameterAttribut(entree, "phaseStepMax", "value", phaseStepMax_);
     245  AMLtools::readAMLParameterAttribut(entree, "acceleratingShapeField", "name", acceleratingShapeFile_);
     246  AMLtools::readAMLParameterAttribut(entree, "focusingMagneticField", "name", focusingMagFile_);
     247  AMLtools::readAMLParameterAttribut(entree, "z_offset", "value", offsetMag_);
     248  AMLtools::readAMLParameterAttribut(entree, "scaling_factor", "value", scaleFactor_);
     249
     250}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementDrift.cc

    r442 r488  
    7070
    7171
    72 string elementDrift::FileOutputFlow() const
    73 {
    74   ostringstream sortie;
    75   //  sortie << elementName_.getElementType()  << endl;
    76   sortie << elementName_.getGenericLabel() << endl;
    77   sortie  << specificName_ << endl;
    78   sortie << lenghtElem_ << "  " << aperture_ <<endl;
    79   return sortie.str();
    80 }
     72// string elementDrift::FileOutputFlow() const
     73// {
     74//   ostringstream sortie;
     75//   //  sortie << elementName_.getElementType()  << endl;
     76//   sortie << elementName_.getGenericLabel() << endl;
     77//   sortie  << specificName_ << endl;
     78//   sortie << lenghtElem_ << "  " << aperture_ <<endl;
     79//   return sortie.str();
     80// }
    8181
    8282vector< pair<string, vector<string> > > elementDrift::parametersToSoftware () const
     
    9292}
    9393
    94 void elementDrift::FileInput(ifstream& ifs)
    95 {
    96   ifs >> specificName_;
    97   ifs >> lenghtElem_ >>  aperture_;
    98 }
     94// void elementDrift::FileInput(ifstream& ifs)
     95// {
     96//   ifs >> specificName_;
     97//   ifs >> lenghtElem_ >>  aperture_;
     98// }
    9999
    100100string elementDrift::print()
     
    111111void elementDrift::InputRep(UAPNode* root)
    112112{
    113   UAPNode* ele = root->addChild("element");
    114   ele->addAttribute("name",specificName_);
     113  // UAPNode* ele = root->addChild("element");
     114  // ele->addAttribute("name",specificName_);
     115  UAPNode* ele = setAMLelementHeader(root);
    115116
    116117  string txt = "";
     
    124125  node->addChild("xy_limit")->addAttribute("design",txt);
    125126}
     127
     128void elementDrift::FileAMLInput(UAPNode* entree)
     129{
     130  if ( !checkAMLelementGenericName(entree) ) return;
     131  AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_);
     132
     133  UAPNode* ouverture = entree->getChildByName("aperture");
     134  if ( !ouverture ) {
     135    cout << "  elementDrift::FileAMLInput ERREUR pas de noeud AML <aperture>  " << endl;
     136    return;
     137  }
     138  AMLtools::readAMLParameterAttribut(ouverture, "xy_limit", "design", aperture_);
     139
     140
     141}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementFit.cc

    r424 r488  
    8181// }
    8282
    83 string elementFit::FileOutputFlow() const
    84 {
    85   ostringstream sortie;
    86   //    sortie << elementName_.getElementType() << endl;
    87   sortie << elementName_.getGenericLabel() << endl;
    88   sortie  << specificName_ << endl;
    89   sortie  <<    variableName_ << " " << variableValue_ << " " << tolerance_ << endl;
    90   return sortie.str();
    91 }
     83// string elementFit::FileOutputFlow() const
     84// {
     85//   ostringstream sortie;
     86//   //    sortie << elementName_.getElementType() << endl;
     87//   sortie << elementName_.getGenericLabel() << endl;
     88//   sortie  << specificName_ << endl;
     89//   sortie  <<    variableName_ << " " << variableValue_ << " " << tolerance_ << endl;
     90//   return sortie.str();
     91// }
    9292
    9393vector< pair<string, vector<string> > > elementFit::parametersToSoftware () const
     
    104104}
    105105
    106 void elementFit::FileInput(ifstream& ifs)
    107 {
    108   ifs >> specificName_;
    109   ifs  >>  variableName_ >>  variableValue_   >> tolerance_;
    110 }
     106// void elementFit::FileInput(ifstream& ifs)
     107// {
     108//   ifs >> specificName_;
     109//   ifs  >>  variableName_ >>  variableValue_   >> tolerance_;
     110// }
    111111
    112112string elementFit::print()
     
    119119void elementFit::InputRep(UAPNode* root)
    120120{
    121   UAPNode* ele = root->addChild("element");
    122   ele->addAttribute("name",specificName_);
     121  // UAPNode* ele = root->addChild("element");
     122  // ele->addAttribute("name",specificName_);
     123  UAPNode* ele = setAMLelementHeader(root);
    123124
    124125  UAPNode* node = ele->addChild("fit");
     
    130131  node->addAttribute("err",txt);
    131132}
     133
     134void elementFit::FileAMLInput(UAPNode* entree)
     135{
     136  if ( !checkAMLelementGenericName(entree) ) return;
     137  AMLtools::readAMLParameterAttribut(entree, "fit", "attribute", variableName_);
     138  AMLtools::readAMLParameterAttribut(entree, "fit", "design", variableValue_);
     139  AMLtools::readAMLParameterAttribut(entree, "fit", "err", tolerance_);
     140}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementMultipole.cc

    r431 r488  
    5151}
    5252
    53 string elementMultipole::FileOutputFlow() const
    54 {
    55   ostringstream sortie;
    56   sortie << elementName_.getGenericLabel() << endl;
    57   sortie  << specificName_ << endl;
    58   sortie << order_ << "  " << component_ <<endl;
    59   return sortie.str();
    60 }
     53// string elementMultipole::FileOutputFlow() const
     54// {
     55//   ostringstream sortie;
     56//   sortie << elementName_.getGenericLabel() << endl;
     57//   sortie  << specificName_ << endl;
     58//   sortie << order_ << "  " << component_ <<endl;
     59//   return sortie.str();
     60// }
    6161
    6262vector< pair<string, vector<string> > > elementMultipole::parametersToSoftware () const
     
    7272}
    7373
    74 void elementMultipole::FileInput(ifstream& ifs)
    75 {
    76   ifs >> specificName_;
    77   ifs >> order_ >> component_;
    78 }
     74// void elementMultipole::FileInput(ifstream& ifs)
     75// {
     76//   ifs >> specificName_;
     77//   ifs >> order_ >> component_;
     78// }
    7979
    8080string elementMultipole::print()
     
    9191void elementMultipole::InputRep(UAPNode* root)
    9292{
    93   UAPNode* ele = root->addChild("element");
    94   ele->addAttribute("name",specificName_);
     93  // UAPNode* ele = root->addChild("element");
     94  // ele->addAttribute("name",specificName_);
     95  UAPNode* ele = setAMLelementHeader(root);
    9596
    9697  string txt = "";
     
    103104  knl->addAttribute("design",txt);
    104105}
     106
     107void elementMultipole::FileAMLInput(UAPNode* entree)
     108{
     109  if ( !checkAMLelementGenericName(entree) ) return;
     110  UAPNode* multipNode = entree->getChildByName("multipole");
     111  if ( ! multipNode ) {
     112    cout << " elementMultipole::FileAMLInput ERREUR pas de noeud AML <multipole>  " << endl;
     113    return;
     114  }
     115  AMLtools::readAMLParameterAttribut(multipNode, "kl", "n", order_);
     116  AMLtools::readAMLParameterAttribut(multipNode, "kl", "design", component_);
     117}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementQuadrupole.cc

    r487 r488  
    99  defaultSpecificName_ = "qpole";
    1010  specificName_ = defaultSpecificName_;
    11   length_ = 0;
     11  //  length_ = 0;
    1212  component_ = 0.0;
    1313 
     
    2222  parametersString_[++compteur]= mixedTools::intToString(nbParam_);
    2323  parametersString_[++compteur]= specificName_;
    24   parametersString_[++compteur]= mixedTools::doubleToString(length_);
     24  parametersString_[++compteur]= mixedTools::doubleToString(lenghtElem_);
    2525  parametersString_[++compteur]= mixedTools::doubleToString(component_);
    2626  if ( compteur != nbParam_ ) {
     
    4747
    4848  specificName_ = param[++compteur];
    49   length_ = atof(param[++compteur].c_str());
     49  lenghtElem_ = atof(param[++compteur].c_str());
    5050  component_ = atof(param[++compteur].c_str());
    5151}
    5252
    53 string elementQuadrupole::FileOutputFlow() const
    54 {
    55   ostringstream sortie;
    56   sortie << elementName_.getGenericLabel() << endl;
    57   sortie  << specificName_ << endl;
    58   sortie << length_ << "  " << component_ <<endl;
    59   return sortie.str();
    60 }
     53// string elementQuadrupole::FileOutputFlow() const
     54// {
     55//   ostringstream sortie;
     56//   sortie << elementName_.getGenericLabel() << endl;
     57//   sortie  << specificName_ << endl;
     58//   sortie << lenghtElem_ << "  " << component_ <<endl;
     59//   return sortie.str();
     60// }
    6161
    6262vector< pair<string, vector<string> > > elementQuadrupole::parametersToSoftware () const
     
    6767  sortie.back().second.push_back(specificName_);
    6868  sortie.push_back( pair<string, vector<string> >("attributes",vector<string>() ) );
    69   sortie.back().second.push_back(mixedTools::doubleToString(length_));
     69  sortie.back().second.push_back(mixedTools::doubleToString(lenghtElem_));
    7070  sortie.back().second.push_back(mixedTools::doubleToString(component_));
    7171  return sortie;
    7272}
    7373
    74 void elementQuadrupole::FileInput(ifstream& ifs)
    75 {
    76   ifs >> specificName_;
    77   ifs >> length_ >> component_;
    78 }
     74// void elementQuadrupole::FileInput(ifstream& ifs)
     75// {
     76//   ifs >> specificName_;
     77//   ifs >> lenghtElem_ >> component_;
     78// }
    7979
    8080string elementQuadrupole::print()
     
    8383  txt += specificName_;
    8484  txt += "\nlength (m): ";
    85   txt += mixedTools::doubleToString(length_);
     85  txt += mixedTools::doubleToString(lenghtElem_);
    8686  txt += "\ncomponent (m^-2): ";
    8787  txt += mixedTools::doubleToString(component_); 
     
    9191void elementQuadrupole::InputRep(UAPNode* root)
    9292{
    93   UAPNode* ele = root->addChild("element");
    94   ele->addAttribute("name",specificName_);
     93  UAPNode* ele = setAMLelementHeader(root);
    9594
    9695  string txt = "";
     
    10099  knl->addAttribute("design",txt);
    101100
    102   txt = mixedTools::doubleToString(length_);
     101  txt = mixedTools::doubleToString(lenghtElem_);
    103102  ele->addChild("length")->addAttribute("design",txt);
    104103}
     104
     105
     106void elementQuadrupole::FileAMLInput(UAPNode* entree)
     107{
     108  if ( !checkAMLelementGenericName(entree) ) return;
     109
     110 AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_);
     111
     112
     113  UAPNode* quadrupole = entree->getChildByName("quadrupole");
     114  if ( ! quadrupole ) {
     115    cout << " elementQuadrupole::FileAMLInput ERREUR pas de noeud AML <quadrupole>  " << endl;
     116    return;
     117  }
     118  AMLtools::readAMLParameterAttribut(quadrupole, "k", "design", component_);
     119}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementRfgun.cc

    r424 r488  
    126126// }
    127127
    128 string elementRfgun::FileOutputFlow() const
    129 {
    130   ostringstream sortie;
    131   // on prend les troncatures tmax et rmax à 3 sigmas
    132   //    sortie << elementName_.getElementType() << endl;
    133   sortie << elementName_.getGenericLabel() << endl;
    134   sortie  << specificName_ << endl;
    135   sortie <<  nmacrop_ << "  " << sigma_t_ << "  " << sigma_r_ << endl;
    136   sortie << emit_x_ << "  " << emit_y_ << endl;
    137   sortie << E_cin_ << " " << sigma_E_ << endl;
    138   sortie << phaseStep_ << "  "  << totalCharge_ << endl;
    139   return sortie.str();
    140 }
     128// string elementRfgun::FileOutputFlow() const
     129// {
     130//   ostringstream sortie;
     131//   // on prend les troncatures tmax et rmax à 3 sigmas
     132//   //    sortie << elementName_.getElementType() << endl;
     133//   sortie << elementName_.getGenericLabel() << endl;
     134//   sortie  << specificName_ << endl;
     135//   sortie <<  nmacrop_ << "  " << sigma_t_ << "  " << sigma_r_ << endl;
     136//   sortie << emit_x_ << "  " << emit_y_ << endl;
     137//   sortie << E_cin_ << " " << sigma_E_ << endl;
     138//   sortie << phaseStep_ << "  "  << totalCharge_ << endl;
     139//   return sortie.str();
     140// }
    141141
    142142vector< pair<string, vector<string> > > elementRfgun::parametersToSoftware () const
     
    164164}
    165165
    166 void elementRfgun::FileInput(ifstream& ifs)
    167 {
    168   ifs >> specificName_;
    169   ifs >> nmacrop_ >> sigma_t_ >> sigma_r_;
    170   ifs >> emit_x_  >>  emit_y_;
    171   ifs >> E_cin_ >> sigma_E_;
    172   ifs >> phaseStep_ >> totalCharge_;
    173 }
     166// void elementRfgun::FileInput(ifstream& ifs)
     167// {
     168//   ifs >> specificName_;
     169//   ifs >> nmacrop_ >> sigma_t_ >> sigma_r_;
     170//   ifs >> emit_x_  >>  emit_y_;
     171//   ifs >> E_cin_ >> sigma_E_;
     172//   ifs >> phaseStep_ >> totalCharge_;
     173// }
    174174
    175175string elementRfgun::print()
     
    198198void elementRfgun::InputRep(UAPNode* root)
    199199{
    200   UAPNode* ele = root->addChild("element");
    201   ele->addAttribute("name",specificName_);
    202 
     200  // UAPNode* ele = root->addChild("element");
     201  // ele->addAttribute("name",specificName_);
     202  // UAPNode* node = NULL;
     203  // node = ele->addChild("description");
     204  // node->addAttribute("type",elementName_.getGenericLabel());
     205  UAPNode* ele = setAMLelementHeader(root);
    203206  UAPNode* node = ele->addChild("comment");
    204207  node->addAttribute("type","RFgun");
     
    217220  node->addChild("emittance_b")->addAttribute("design",txt);
    218221  txt = mixedTools::doubleToString(E_cin_);
    219   txt = mixedTools::doubleToString(E_cin_);
    220222  node->addChild("total_energy")->addAttribute("design",txt);
    221223  txt = mixedTools::doubleToString(sigma_E_);
     
    232234}
    233235
     236void elementRfgun::FileAMLInput(UAPNode* entree)
     237{
     238  if ( !checkAMLelementGenericName(entree) ) return;
     239  UAPNode* beam = entree->getChildByName("beam");
     240  AMLtools::readAMLParameterAttribut(beam, "n_particles", "design", nmacrop_);
     241  AMLtools::readAMLParameterAttribut(beam, "sig_t", "design", sigma_t_);
     242  AMLtools::readAMLParameterAttribut(beam, "emittance_a", "design", emit_x_);
     243  AMLtools::readAMLParameterAttribut(beam, "emittance_b", "design", emit_y_);
     244  AMLtools::readAMLParameterAttribut(beam, "total_energy", "design", E_cin_);
     245  AMLtools::readAMLParameterAttribut(beam, "sig_e", "design", sigma_E_);
     246  AMLtools::readAMLParameterAttribut(beam, "particle_charge", "design", totalCharge_);
     247
     248  AMLtools::readAMLParameterAttribut(entree, "sigma_r", "value", sigma_r_);
     249  AMLtools::readAMLParameterAttribut(entree, "phaseStep", "value", phaseStep_);
     250
     251}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementSextupole.cc

    r487 r488  
    99  defaultSpecificName_ = "spole";
    1010  specificName_ = defaultSpecificName_;
    11   length_ = 0;
     11  //  length_ = 0;
    1212  component_ = 0.0;
    1313 
     
    2222  parametersString_[++compteur]= mixedTools::intToString(nbParam_);
    2323  parametersString_[++compteur]= specificName_;
    24   parametersString_[++compteur]= mixedTools::doubleToString(length_);
     24  parametersString_[++compteur]= mixedTools::doubleToString(lenghtElem_);
    2525  parametersString_[++compteur]= mixedTools::doubleToString(component_);
    2626  if ( compteur != nbParam_ ) {
     
    4747
    4848  specificName_ = param[++compteur];
    49   length_ = atof(param[++compteur].c_str());
     49  lenghtElem_ = atof(param[++compteur].c_str());
    5050  component_ = atof(param[++compteur].c_str());
    5151}
    5252
    53 string elementSextupole::FileOutputFlow() const
    54 {
    55   ostringstream sortie;
    56   sortie << elementName_.getGenericLabel() << endl;
    57   sortie  << specificName_ << endl;
    58   sortie << length_ << "  " << component_ <<endl;
    59   return sortie.str();
    60 }
     53// string elementSextupole::FileOutputFlow() const
     54// {
     55//   ostringstream sortie;
     56//   sortie << elementName_.getGenericLabel() << endl;
     57//   sortie  << specificName_ << endl;
     58//   sortie << lenghtElem_ << "  " << component_ <<endl;
     59//   return sortie.str();
     60// }
    6161
    6262vector< pair<string, vector<string> > > elementSextupole::parametersToSoftware () const
     
    6767  sortie.back().second.push_back(specificName_);
    6868  sortie.push_back( pair<string, vector<string> >("attributes",vector<string>() ) );
    69   sortie.back().second.push_back(mixedTools::doubleToString(length_));
     69  sortie.back().second.push_back(mixedTools::doubleToString(lenghtElem_));
    7070  sortie.back().second.push_back(mixedTools::doubleToString(component_));
    7171  return sortie;
    7272}
    7373
    74 void elementSextupole::FileInput(ifstream& ifs)
    75 {
    76   ifs >> specificName_;
    77   ifs >> length_ >> component_;
    78 }
     74// void elementSextupole::FileInput(ifstream& ifs)
     75// {
     76//   ifs >> specificName_;
     77//   ifs >> lenghtElem_ >> component_;
     78// }
    7979
    8080string elementSextupole::print()
     
    8383  txt += specificName_;
    8484  txt += "\nlength (m): ";
    85   txt += mixedTools::doubleToString(length_);
     85  txt += mixedTools::doubleToString(lenghtElem_);
    8686  txt += "\ncomponent (m^-3): ";
    8787  txt += mixedTools::doubleToString(component_); 
     
    9191void elementSextupole::InputRep(UAPNode* root)
    9292{
    93   UAPNode* ele = root->addChild("element");
    94   ele->addAttribute("name",specificName_);
     93  UAPNode* ele = setAMLelementHeader(root);
    9594
    9695  string txt = "";
     
    10099  knl->addAttribute("design",txt);
    101100
    102   txt = mixedTools::doubleToString(length_);
     101  txt = mixedTools::doubleToString(lenghtElem_);
    103102  ele->addChild("length")->addAttribute("design",txt);
    104103}
     104
     105void elementSextupole::FileAMLInput(UAPNode* entree)
     106{
     107  if ( !checkAMLelementGenericName(entree) ) return;
     108
     109 AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_);
     110
     111
     112  UAPNode* sextupole = entree->getChildByName("sextupole");
     113  if ( ! sextupole ) {
     114    cout << " elementSextupole::FileAMLInput ERREUR pas de noeud AML <sextupole>  " << endl;
     115    return;
     116  }
     117  AMLtools::readAMLParameterAttribut(sextupole, "k", "design", component_);
     118}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc

    r442 r488  
    8282// }
    8383
    84 string elementSnapshot::FileOutputFlow() const
    85 {
    86   ostringstream sortie;
    87   sortie << elementName_.getGenericLabel() << endl;
    88   sortie  << specificName_ << endl;
    89   sortie << programFile_ << endl;
    90   sortie << inputBeamFile_ << endl;
    91   sortie << outputBeamFile_ << endl;
    92   return sortie.str();
    93 }
     84// string elementSnapshot::FileOutputFlow() const
     85// {
     86//   ostringstream sortie;
     87//   sortie << elementName_.getGenericLabel() << endl;
     88//   sortie  << specificName_ << endl;
     89//   sortie << programFile_ << endl;
     90//   sortie << inputBeamFile_ << endl;
     91//   sortie << outputBeamFile_ << endl;
     92//   return sortie.str();
     93// }
    9494
    9595vector< pair<string, vector<string> > > elementSnapshot::parametersToSoftware () const {
     
    105105}
    106106
    107 void elementSnapshot::FileInput(ifstream& ifs)
    108 {
    109   ifs >> specificName_;
    110   ifs >> programFile_;
    111   ifs >> inputBeamFile_;
    112   ifs >> outputBeamFile_;;
    113 }
     107// void elementSnapshot::FileInput(ifstream& ifs)
     108// {
     109//   ifs >> specificName_;
     110//   ifs >> programFile_;
     111//   ifs >> inputBeamFile_;
     112//   ifs >> outputBeamFile_;;
     113// }
    114114
    115115string elementSnapshot::print()
     
    128128void elementSnapshot::InputRep(UAPNode* root)
    129129{
    130   UAPNode* node= root->addChild("snapshot");
    131   node->addAttribute("name",specificName_);
     130  // UAPNode* node= root->addChild("snapshot");
     131  // node->addAttribute("name",specificName_);
     132  UAPNode* ele = setAMLelementHeader(root);
    132133
    133   UAPNode* fichiers = node->addChild("names_of_files");
     134  UAPNode* fichiers = ele->addChild("names_of_files");
    134135  fichiers->addAttribute("program",programFile_);
    135136  fichiers->addAttribute("inputf",inputBeamFile_);
    136137  fichiers->addAttribute("outputf",outputBeamFile_);
    137138}
     139
     140void elementSnapshot::FileAMLInput(UAPNode* entree)
     141{
     142  if ( !checkAMLelementGenericName(entree) ) return;
     143  AMLtools::readAMLParameterAttribut(entree, "names_of_files", "program", programFile_);
     144  AMLtools::readAMLParameterAttribut(entree, "names_of_files", "inputf", inputBeamFile_);
     145  AMLtools::readAMLParameterAttribut(entree, "names_of_files", "outputf", outputBeamFile_);
     146}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementSoleno.cc

    r424 r488  
    8484//   }
    8585
    86 string elementSoleno::FileOutputFlow() const
    87 {
    88   ostringstream sortie;
    89   //    sortie << elementName_.getElementType() << endl;
    90   sortie << elementName_.getGenericLabel() << endl;
    91   sortie  << specificName_ << endl;
    92   sortie << lenghtElem_ << "  " << aperture_<< " "  << B0_ << " " << varyB0_ << endl;
    93   return sortie.str();
    94 }
     86// string elementSoleno::FileOutputFlow() const
     87// {
     88//   ostringstream sortie;
     89//   //    sortie << elementName_.getElementType() << endl;
     90//   sortie << elementName_.getGenericLabel() << endl;
     91//   sortie  << specificName_ << endl;
     92//   sortie << lenghtElem_ << "  " << aperture_<< " "  << B0_ << " " << varyB0_ << endl;
     93//   return sortie.str();
     94// }
    9595
    9696
     
    110110}
    111111
    112 void elementSoleno::FileInput(ifstream& ifs)
    113 {
    114   ifs >> specificName_;
    115   ifs >> lenghtElem_ >>  aperture_ >> B0_ >> varyB0_ ;
    116 }
     112// void elementSoleno::FileInput(ifstream& ifs)
     113// {
     114//   ifs >> specificName_;
     115//   ifs >> lenghtElem_ >>  aperture_ >> B0_ >> varyB0_ ;
     116// }
    117117
    118118string elementSoleno::print()
     
    133133void elementSoleno::InputRep(UAPNode* root)
    134134{
    135   UAPNode* ele = root->addChild("element");
    136   ele->addAttribute("name",specificName_);
     135  // UAPNode* ele = root->addChild("element");
     136  // ele->addAttribute("name",specificName_);
     137  UAPNode* ele = setAMLelementHeader(root);
    137138
    138139  string txt = "";
     
    158159  }
    159160}
     161
     162void elementSoleno::FileAMLInput(UAPNode* entree)
     163{
     164  if ( !checkAMLelementGenericName(entree) ) return;
     165  AMLtools::readAMLParameterAttribut(entree, "length", "design", lenghtElem_);
     166
     167  UAPNode* ouverture = entree->getChildByName("aperture");
     168  if ( !ouverture ) {
     169    cout << " elementSoleno::FileAMLInput ERREUR pas de noeud AML <aperture>  " << endl;
     170    return;
     171  }
     172  AMLtools::readAMLParameterAttribut(ouverture, "xy_limit", "design", aperture_);
     173  UAPNode* solenoide = entree->getChildByName("solenoid");
     174  if ( !solenoide ) {
     175    cout << " elementSoleno::FileAMLInput ERREUR pas de noeud AML <solenoide>  " << endl;
     176    return;
     177  }
     178  AMLtools::readAMLParameterAttribut(solenoide, "ksol", "design", B0_);
     179  string vrai;
     180  AMLtools::readAMLParameterAttribut(solenoide, "vary", "is_on", vrai);
     181  if ( vrai == string("true")) varyB0_ = true;
     182  else varyB0_ = false;
     183}
  • Interface_Web/trunk/pspaWT/sources/controler/src/globalParameters.cc

    r436 r488  
    44#include "globalParameters.h"
    55#include "mixedTools.h"
     6#include "AMLtools.h"
    67
    78globalParameters::globalParameters() : parametersString_(NULL)
     
    4243}
    4344
    44 string globalParameters::FileOutputFlow() const
     45// string globalParameters::FileOutputFlow() const
     46// {
     47//   ostringstream sortie;
     48//   sortie << " globals " << endl;
     49//   sortie << frequency_ << " " << integrationStep_ << " " << nstepsMax_ << " " << nsc_ << endl;
     50//   return sortie.str(); 
     51// }
     52
     53// void globalParameters::FileInput(ifstream& ifs)
     54// {
     55//   ifs >> frequency_ >> integrationStep_ >> nstepsMax_ >> nsc_;
     56// }
     57
     58
     59
     60void globalParameters::FileAMLInput(UAPNode* entree)
    4561{
    46   ostringstream sortie;
    47   sortie << " globals " << endl;
    48   sortie << frequency_ << " " << integrationStep_ << " " << nstepsMax_ << " " << nsc_ << endl;
    49   return sortie.str(); 
     62  AMLtools::readAMLParameterAttribut(entree, "ref_freq", "design", frequency_);
     63  AMLtools::readAMLParameterAttribut(entree, "integrationStep", "value", integrationStep_);
     64  AMLtools::readAMLParameterAttribut(entree, "nSteps", "value", nstepsMax_);
     65  AMLtools::readAMLParameterAttribut(entree, "nsc", "value", nsc_);
     66  //  cout << " PARAMETRES GLOBAUX : " << FileOutputFlow() << endl;
    5067}
    5168
    52 void globalParameters::FileInput(ifstream& ifs)
    53 {
    54   ifs >> frequency_ >> integrationStep_ >> nstepsMax_ >> nsc_;
    55 }
     69
     70
    5671
    5772void globalParameters::InputRep(UAPNode* root)
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h

    r437 r488  
    5757 
    5858  void updateLabelAndToolTipWidget();
    59   void FileInput(ifstream& ifs);
     59  //  void FileInput(ifstream& ifs);
    6060 
    6161  WContainerWidget* getWidget();
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r481 r488  
    7676 
    7777  bool removePathFromConfigName(string& config);
    78   bool removeExtensionFromConfigName(string& config);
     78  bool removeExtensionFromConfigName(string& config, string extension);
    7979  void createAccelerator();
    8080 
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r485 r488  
    122122}
    123123
    124 void GWt_abstractElement::FileInput(ifstream& ifs)
    125 {
    126   getAbstractElement()->FileInput(ifs);
    127   initilializeDialog();
    128   updateLabelAndToolTipWidget();
     124// void GWt_abstractElement::FileInput(ifstream& ifs)
     125// {
     126//   getAbstractElement()->FileInput(ifs);
     127//   initilializeDialog();
     128//   updateLabelAndToolTipWidget();
    129129 
    130   // update parameters
    131   GWt_ligneFaisceau* ligneFaisceau = NULL;
    132   if ( static_cast<GWt_ligneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
    133     ligneFaisceau = static_cast<GWt_ligneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
    134     ligneFaisceau->update();
    135   }
    136 }
     130//   // update parameters
     131//   GWt_ligneFaisceau* ligneFaisceau = NULL;
     132//   if ( static_cast<GWt_ligneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     133//     ligneFaisceau = static_cast<GWt_ligneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     134//     ligneFaisceau->update();
     135//   }
     136// }
    137137
    138138abstractElement* GWt_abstractElement::getAbstractElement() {
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r485 r488  
    287287  //globalParam_->updateGlobals();
    288288
    289   //  dtmanage_->saveConfiguration(nameOfCase_);
    290   dtmanage_->saveConfiguration(sessionId(),nameOfCase_);
     289  //  dtmanage_->saveConfiguration(sessionId(),nameOfCase_);
    291290
    292291  // en test: j'ajoute la sauvegarde sur .aml
     
    308307  removePathFromConfigName(nameOfCase_);
    309308  cout << " nom sans path " << nameOfCase_ << endl;
    310   removeExtensionFromConfigName(nameOfCase_);
     309    removeExtensionFromConfigName(nameOfCase_, string(".aml"));
     310    //  removeExtensionFromConfigName(nameOfCase_, string(".save"));
    311311  cout << " nom sans extension " << nameOfCase_ << endl;
    312312  if (nameOfCase_ == "") return;
     
    314314  dialogSave_ = NULL;
    315315 
    316   bool test = dtmanage_->restoreElements(fileName);
     316  //  bool test = dtmanage_->restoreElements(fileName);
     317  bool test = dtmanage_->restoreAMLElements(fileName);
    317318  if ( !test ) {
    318319    GWt_dialog restoreWarning(" element restoring", "failure in restoring elements from file : " + fileName , GWt_dialog::Error, false,true);
     
    364365  string nomDuFichier = (uploadFileSelectorWidget_->clientFileName()).toUTF8();
    365366  cout << " fichier client : " << nomDuFichier << endl;
    366   bool test = removeExtensionFromConfigName(nomDuFichier);
     367  bool test = removeExtensionFromConfigName(nomDuFichier, string(".aml"));
    367368  cout << " fichier client sans extension : " << nomDuFichier << endl;
    368369 
     
    371372    console_->addConsoleMessage(string("restauration..."));
    372373     
    373     if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) {
     374    if ( !dtmanage_->restoreAMLElements(uploadFileSelectorWidget_->spoolFileName()) ) {
    374375      GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
    375376      restoreWarning.exec();
     
    582583}
    583584
    584 bool PspaApplication::removeExtensionFromConfigName(string& config)
     585bool PspaApplication::removeExtensionFromConfigName(string& config, string extension)
    585586{
    586587    //  string configName;
    587     string extension(".save");
     588  //    string extension(".save");
    588589    bool test = true;
    589590    string::size_type nn = config.rfind('.');
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_serverFileSelector.cc

    r418 r488  
    5959    treeFileRoot->setLoadPolicy(Wt::WTreeNode::NextLevelLoading);
    6060   
    61     buildConfigurationFileTree(treeFileRoot, workingDir_.c_str(), ".save");
     61    //    buildConfigurationFileTree(treeFileRoot, workingDir_.c_str(), ".save");
     62        buildConfigurationFileTree(treeFileRoot, workingDir_.c_str(), ".aml");
    6263
    6364    // Add user files
    6465    Wt::WTreeNode* userTreeFileRoot = new Wt::WTreeNode("MySession", folderIcon);
    65     buildConfigurationFileTree(treeFileRoot, (workingDir_+WApplication::instance()->sessionId()).c_str(), ".save");
     66    // buildConfigurationFileTree(treeFileRoot, (workingDir_+WApplication::instance()->sessionId()).c_str(), ".save");
     67    buildConfigurationFileTree(treeFileRoot, (workingDir_+WApplication::instance()->sessionId()).c_str(), ".aml");
    6668
    6769    treeFileRoot->expand();
Note: See TracChangeset for help on using the changeset viewer.