Changeset 431 in PSPA


Ignore:
Timestamp:
Nov 15, 2013, 3:30:50 PM (11 years ago)
Author:
touze
Message:

systeme periodique (mailles) + multipoles + madx

Location:
Interface_Web/trunk/pspaWT/sources
Files:
12 added
26 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/include/abstractElement.h

    r424 r431  
    77
    88#include "nomdElements.h"
    9 //#include "nomDeLogiciel.h"
    10 //#include "trivaluedBool.h"
    119#include "abstractSoftware.h"
    12 /* #include "softwareGenerator.h" */
    13 /* #include "softwareParmela.h" */
    14 /* #include "softwareTest.h" */
    15 /* #include "softwareTransport.h" */
    1610
    1711#include "UAP/UAPNode.hpp"
    18 
    1912using namespace std;
    2013
     
    2619  int nbParam_;
    2720  string* parametersString_;
    28   double phaseStepMax_;
     21 
     22  string defaultSpecificName_;
     23  string specificName_;
     24  nomdElements elementName_;
    2925   
    3026  double defaultLength_;
    3127  double defaultAperture_;
    32   string defaultSpecificName_;
    33  
    34   string specificName_;
    35   nomdElements elementName_;
     28  double phaseStepMax_;
    3629 
    3730  double lenghtElem_; // cm
    3831  double aperture_; // cm
    39  
    4032  double stepmaxcm_;
    41   //  bool curvedTrajectory_;
    4233 
    4334  void setDefaultValues();
     
    5142 
    5243  void setParameters(double ll,double aper);
     44 
     45  nomdElements getNomdElement() const;
     46  int getNbParams() const;
     47
    5348  void setLabel(string lab);
    5449  string getLabel() const;
    55   nomdElements getNomdElement() const;
    56  
     50
    5751  double getLenghtOfElement() const;
    58   int getNbParams() const;
    5952 
    6053  virtual void setPhaseStep(double);
     
    6760  virtual void FileInput(ifstream& ifs) = 0;
    6861  virtual string print() = 0;
    69  
    7062  virtual void InputRep(UAPNode* root) = 0;
    7163
  • Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h

    r418 r431  
    33
    44#include "globalParameters.h"
     5#include "sectorParameters.h"
    56#include "particleBeam.h"
    67#include "nomDeLogiciel.h"
     
    1920
    2021 protected :
    21 
     22 
    2223  unsigned numeroDeb_, numeroFin_;
    2324  globalParameters* globParamPtr_;
     25  sectorParameters* sectParamPtr_; //xx
    2426  dataManager* dataManager_;
    2527  string inputFileName_;
    2628  nomDeLogiciel nameOfSoftware_;
    2729
    28     /**
     30  /**
    2931     Accepted elements list for this software
    30      */
     32  */
    3133  std::vector <nomdElements::typedElement> acceptedElements_;
    3234
    33     /**
     35  /**
    3436     Ignore software list for this element
    35      */
     37  */
    3638  std::vector <nomdElements::typedElement> ignoredElements_;
    37 
     39 
    3840  abstractSoftware();
    3941
     
    4244  bool ComputationLimitsOk() const;
    4345
    44 
    4546  void registerElement(nomdElements::typedElement nomdel,trivaluedBool b);
    4647
    4748 public :
    4849
    49   abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt);
     50  abstractSoftware(string,globalParameters*,dataManager*);
     51  abstractSoftware(string,sectorParameters*,dataManager*);
    5052  ~abstractSoftware() {;}
    5153
    5254  inline const nomDeLogiciel* getNomDeLogiciel() const {
    5355    return &nameOfSoftware_;
    54 }
     56  }
    5557
    5658  trivaluedBool doAcceptElement(nomdElements::typedElement typdel);
    5759
     60  virtual bool createInputFile(particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir) = 0;
     61  virtual bool execute(string workingDir) = 0;
     62  virtual bool buildBeamAfterElements(string workingDir) = 0;
    5863
    59   virtual bool createInputFile(particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir) = 0;
    60 
    61 
    62   virtual bool  execute(string workingDir) = 0;
    63 
    64  virtual bool buildBeamAfterElements(string workingDir) = 0;
    65 
    66     /** Color of the background of this sofware
    67      Should be a valid Css name as FFEEDD
    68      */
    69     virtual string getColor() = 0;
    70 
    71     /** Name of this software
    72      */
    73     inline string getName() const {
    74       return nameOfSoftware_.getString();
    75     }
    76 
     64  /** Color of the background of this sofware
     65      Should be a valid Css name as FFEEDD
     66  */
     67  virtual string getColor() = 0;
     68 
     69  /** Name of this software
     70   */
     71  inline string getName() const {
     72    return nameOfSoftware_.getString();
     73  }
    7774};
    7875#endif
  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r424 r431  
    1414#include "nomDeLogiciel.h"
    1515
     16#include "sectorParameters.h" //xx
     17
    1618class PspaApplication;
    1719
     
    2123 public:
    2224 
     25  dataManager() {;}
    2326  dataManager(PspaApplication*);
    2427  virtual ~dataManager();
     
    2730  inline globalParameters* getGlobalParameters()  {return &globParam_;}
    2831  inline particleBeam* getCurrentBeam() {return currentBeam_;}
     32
     33  // xx
     34  inline sectorParameters* getSectorParameters() {return &sectorParam_;}
    2935   
    3036  particleBeam* getDiagnosticBeam(unsigned index);
     
    5056 
    5157  void initializeExecution();
    52 //  trivaluedBool checkExecute(string& diagnostic);
    53 //  trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic);
     58
    5459  bool executeAll();
    5560 
     
    8186    return &diagnosticBeam_.back();
    8287  }
    83  
    84   /** return a specific jobList index
    85       return NULL if the index does not exist
    86   */
    87  
    88   /* inline sectionToExecute* getJobListAt(int a) { */
    89     /*     if (a < 0) return NULL; */
    90     /*     if (a >= getJobListSize()) return NULL; */
    91     /*     return jobList_[a]; */
    92     /* } */
    93 
    94  
    95  
    96     /* inline const abstractSoftware* getSoftwareOfSection( int index) const { */
    97     /*     if (index < 0) return NULL; */
    98     /*     if (index >= getJobListSize()) return NULL; */
    99     /*  return jobList_[index]->getSoftware(); */
    100     /* } */
    10188   
    102     /** Clear a specific jobList */
     89  /** Clear a specific jobList */
    10390  void clearSectionToExecute(int a);
    10491   
     
    10693
    10794  globalParameters globParam_;
     95  sectorParameters sectorParam_; //xx
    10896  particleBeam* currentBeam_;
    10997  PspaApplication* pspa_;
     
    113101  vector<particleBeam> diagnosticBeam_;
    114102  vector<unsigned> indexElementToIndexDiag_;
    115   // numeroElementToIndexDiag_[k] contient, pour l'element d'index k, l'indice ind tel que diagnosticBeam_[ind]
    116   // soit le faisceau resultat, en l'etat qu'il doit avoir apres l'element k
    117  
    118103  vector<sectionToExecute*> jobList_;
    119104 
  • Interface_Web/trunk/pspaWT/sources/controler/include/nomDeLogiciel.h

    r418 r431  
    66using namespace std;
    77
    8 
    9 
    108class nomDeLogiciel
    119{
    1210
    13  public:
    14 
    15 
     11 public :
     12 
    1613  enum Logiciel
    1714  {
    18     parmela, transport, generator, useraction, test, unknownSoftware
     15    parmela, transport, generator, useraction, test, madx, unknownSoftware
    1916  };
    20 
     17 
    2118   
    22  private:
     19 private :
    2320
    2421  Logiciel program_;
    2522  std::string progString_;
    26   //  int value_;
    27  
     23   
    2824  static Logiciel fromString( std::string s);
    2925  static std::string toString( Logiciel lg); 
     
    3127 
    3228 public :
    33   // constructors
    34  
     29 
    3530  nomDeLogiciel(); 
    3631  nomDeLogiciel(const string& s); 
     
    3934 
    4035  inline std::string getString() const {return progString_;}
     36  inline nomDeLogiciel::Logiciel getLogiciel() const {return program_;}
    4137
    42   inline nomDeLogiciel::Logiciel getLogiciel() const { return program_; }
    43 
    44     /** Color of the background of the sofware
    45      Should be a valid Css name as FFEEDD
    46      */
     38  /** Color of the background of the sofware
     39      Should be a valid Css name as FFEEDD
     40  */
    4741  inline std::string  getColor() const {return getWtColor(program_);}
    4842  // operators
    49  
    5043  nomDeLogiciel& operator= (const nomDeLogiciel& nl); 
    5144  bool operator== (const nomDeLogiciel& nl); 
    5245  bool operator!= (const nomDeLogiciel& nl);
    53  
    5446};
    55 
    56 
    57 
    58 
    5947#endif
  • Interface_Web/trunk/pspaWT/sources/controler/include/nomdElements.h

    r418 r431  
    1313 public :
    1414
    15 enum typedElement {beam, RFgun, drift, cell, bend, soleno, fit, snapshot, inconnu};
     15  enum typedElement {beam, RFgun, drift, cell, bend, soleno, fit, snapshot, mpole, inconnu};
    1616
    1717 private :
  • Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h

    r419 r431  
    88class sectionToExecute
    99{
    10     public :
    11     sectionToExecute(abstractElement*, abstractElement*, abstractSoftware*);
     10 public :
    1211
    13     /** Deprecated : To be removed ! */
    14     sectionToExecute(abstractElement*, int, abstractElement*, int, abstractSoftware*);
     12  sectionToExecute(abstractElement*,abstractElement*,abstractSoftware*);
     13 
     14  /** Deprecated : To be removed ! */
     15  sectionToExecute(abstractElement*, int, abstractElement*, int, abstractSoftware*);
    1516
    16     ~sectionToExecute() {;}
     17  ~sectionToExecute() {;}
    1718
    18     inline abstractElement* getFirstElement() {
    19         return firstElement;
    20     }
     19  inline abstractElement* getFirstElement() {
     20    return firstElement;
     21  }
    2122   
    22     inline abstractElement* getLastElement() {
    23         return lastElement;
    24     }
     23  inline abstractElement* getLastElement() {
     24    return lastElement;
     25  }
    2526   
    26     /** Deprecated : To be removed ! */
    27     inline int getElementNumberInSection() const {
    28         return firstElementNumberInBeamLine;
    29     }
     27  /** Deprecated : To be removed ! */
     28  inline int getElementNumberInSection() const {
     29    return firstElementNumberInBeamLine;
     30  }
    3031   
    31     /** Deprecated : To be removed ! */
    32     inline int getLastElementNumberInSection()  const {
    33         return lastElementNumberInBeamLine;
    34     }
    35     inline abstractSoftware* getSoftware() const {
    36         return software;
    37     }
    38    
    39     private :
    40     abstractElement*  firstElement;
    41     abstractElement*  lastElement;
     32  /** Deprecated : To be removed ! */
     33  inline int getLastElementNumberInSection()  const {
     34    return lastElementNumberInBeamLine;
     35  }
    4236
    43     int firstElementNumberInBeamLine;
    44     int lastElementNumberInBeamLine;
    45    
    46     abstractSoftware* software;
     37  inline abstractSoftware* getSoftware() const {
     38    return software;
     39  }
     40 
     41 private :
     42
     43  abstractElement*  firstElement;
     44  abstractElement*  lastElement;
     45  abstractSoftware* software;
     46
     47  int firstElementNumberInBeamLine;
     48  int lastElementNumberInBeamLine; 
    4749};
    48 
    4950#endif
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h

    r418 r431  
    77class softwareGenerator : public abstractSoftware
    88{
     9 protected :
     10 
     11  bool beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles );
    912
    10  protected :
    11 
    12 
    13 
    14  bool beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles );
    15 
    16 
    17  string elementsData(const vector< pair<string, vector<string> > >& donnees) const;
    18  string rfgunData(const vector< pair<string, vector<string> > >& donnees) const;
    19 
     13  string elementsData(const vector< pair<string, vector<string> > >& donnees) const;
     14 
     15  string rfgunData(const vector< pair<string, vector<string> > >& donnees) const;
    2016
    2117 public :
    22 
    23 
    24     softwareGenerator();
    25    
    26     softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt);
     18 
     19  softwareGenerator(); 
     20  softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt);
    2721
    2822  virtual ~softwareGenerator() {;}
    2923
    30 
    3124  virtual bool createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    32 
    33 
    34   virtual bool  execute(string workingDir);
    35 
    36 
     25  virtual bool execute(string workingDir);
    3726  virtual bool buildBeamAfterElements(string workingDir);
    3827
    39     inline string getColor() {
    40         return "#a3c0ed";
    41     }
    42 
    43     /* inline string getName() const { */
    44     /*     return "generator"; */
    45     /* } */
     28  inline string getColor() {
     29    return "#a3c0ed";
     30  }
    4631};
    47 
    4832#endif
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc

    r418 r431  
    55#include "abstractElement.h"
    66
    7 abstractElement::abstractElement()
    8 //: nameOfSoftware_(NULL)
    9   : abstractSoftware_(NULL)
     7abstractElement::abstractElement() : abstractSoftware_(NULL)
    108{
    119  setDefaultValues();
     
    1412}
    1513
    16 abstractElement::abstractElement(string lab)
    17   //: nameOfSoftware_(NULL)
    18   : abstractSoftware_(NULL)
     14abstractElement::abstractElement(string lab) : abstractSoftware_(NULL)
    1915{
    2016  specificName_ = lab;
     
    2723{
    2824  if (parametersString_ != NULL) delete [] parametersString_ ;
    29   //  if ( nameOfSoftware_ != NULL ) delete nameOfSoftware_;
    3025}
    3126
     
    6257}
    6358
    64 string abstractElement::getLabel() const
    65 {
     59string abstractElement::getLabel() const {
    6660  return specificName_;
    6761}
    6862
    69 
    70 nomdElements abstractElement::getNomdElement() const
    71 {
     63nomdElements abstractElement::getNomdElement() const {
    7264  return elementName_;
    7365}
    74 
    75 
    7666
    7767double abstractElement::getLenghtOfElement() const {
     
    8373}
    8474
    85 
    8675double abstractElement::getInitialKineticEnergy() const {
    8776  return 0.0;
    8877}
    89 
    90 
    91 
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc

    r419 r431  
    22#include "dataManager.h"
    33#include <algorithm>
     4
    45abstractSoftware::abstractSoftware()
    56{
    67  globParamPtr_ = NULL;
     8  sectParamPtr_ = NULL; //xx
    79  dataManager_ = NULL;
    810  nameOfSoftware_ = nomDeLogiciel("unknownSoftware");
    911}
    1012
    11 abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt) {
     13abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt)
     14{
    1215  inputFileName_ = inputFileName;
    1316  globParamPtr_ = globals;
     17  sectParamPtr_ = NULL; //xx
    1418  dataManager_ = dt;
    1519  numeroDeb_ = 0;
     
    1822}
    1923
    20 bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin) {
     24abstractSoftware::abstractSoftware(string inputFileName,sectorParameters* lattice,dataManager* dt)
     25{
     26  inputFileName_ = inputFileName;
     27  globParamPtr_ = NULL;
     28  sectParamPtr_ = lattice;
     29  dataManager_ = dt;
     30  numeroDeb_ = 0;
     31  numeroFin_ = 0;
     32  nameOfSoftware_ = nomDeLogiciel("unknownSoftware");
     33}
     34
     35bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin)
     36{
    2137  numeroDeb_ = numeroDeb;
    2238  numeroFin_ = numeroFin;
     
    2440}
    2541
    26 bool abstractSoftware::ComputationLimitsOk() const {
    27   if (   numeroDeb_ < 1 ||  numeroFin_ < 1 || numeroDeb_ > dataManager_->getBeamLineSize() || numeroFin_ > dataManager_->getBeamLineSize() ) {
    28   dataManager_->consoleMessage(" abstractSoftware::initComputationLimit : numero of element out of limits in software " + getName() );
     42bool abstractSoftware::ComputationLimitsOk() const
     43{
     44  if (numeroDeb_ < 1 || numeroFin_ < 1 || numeroDeb_ > dataManager_->getBeamLineSize() || numeroFin_ > dataManager_->getBeamLineSize() ) {
     45    dataManager_->consoleMessage(" abstractSoftware::initComputationLimit : num of element out of limits in software " + getName() );
    2946    return false;
    3047  } else {
     
    3350}
    3451
    35 
    36 void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b) {
     52void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b)
     53{
    3754  if (b == TBoolIgnore) {
    3855    ignoredElements_.push_back(nomdel);
     
    4259}
    4360
    44 trivaluedBool abstractSoftware::doAcceptElement(nomdElements::typedElement typdel) {
    45   if (acceptedElements_.size() == 0) {
     61trivaluedBool abstractSoftware::doAcceptElement(nomdElements::typedElement typdel)
     62{
     63
     64  //xx
     65  if (acceptedElements_.size() == 0 && nameOfSoftware_ != nomDeLogiciel::unknownSoftware) {
    4666    return TBoolError;
    4767  }
    48   if ( std::find(acceptedElements_.begin(), acceptedElements_.end(), typdel) != acceptedElements_.end()) {
     68
     69  if (std::find(acceptedElements_.begin(),acceptedElements_.end(),typdel) != acceptedElements_.end()) {
    4970    return TBoolOk;
    5071  }
     72
    5173  if (ignoredElements_.size() == 0) {
    5274    return TBoolError;
    5375  }
    54   if ( std::find(ignoredElements_.begin(), ignoredElements_.end(), typdel) != ignoredElements_.end()) {
     76
     77  if (std::find(ignoredElements_.begin(),ignoredElements_.end(),typdel) != ignoredElements_.end()) {
    5578    return TBoolIgnore;
    5679  }
     80
    5781  return TBoolOk;
    5882}
    59 
    6083
    6184bool abstractSoftware::launchJob(string commandLine, string& resul)
     
    6689  ostringstream sortie;
    6790  if (pp == NULL) {
    68     sortie << " launching  failed : " << commandLine << endl;
     91    sortie << " launching failed : " << commandLine << endl;
    6992    ExecuteStatus = false;
    7093  } else {
    71     cout << " executing command :  "  << commandLine << endl;
    7294    // on copie la sortie dans le fichier assigne
    7395    char buf[132];
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r424 r431  
     1#include <stdio.h>
     2#include <fstream>
     3
    14#include "dataManager.h"
    25#include "mathematicalConstants.h"
    36#include "PhysicalConstants.h"
     7
     8#include "GWt_pspaApplication.h"
     9#include "GWt_console.h"
     10
    411#include "softwareParmela.h"
    512#include "softwareTransport.h"
    6 #include "GWt_pspaApplication.h"
    7 #include "GWt_console.h"
    813#include "softwareGenerator.h"
    914#include "softwareTest.h"
     15#include "softwareMadx.h" //xx
     16#include "softwareUnknown.h" //xx
    1017
    1118#include <boost/filesystem.hpp>
    12 #include <stdio.h>
    13 #include <fstream>
    1419
    1520#include "UAP/UAPUtilities.hpp"
    1621#include "AML/AMLReader.hpp"
     22
     23#define BAVARD 0
    1724
    1825dataManager::dataManager(PspaApplication* pspa) :
     
    2330dataManager::~dataManager()
    2431{
    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_;
    30 }
    31 
    32 void dataManager::consoleMessage(string message) {
    33     GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    34     if (console) console->addConsoleMessage(message + "\n");
    35     pspa_->processEvents();
     32  unsigned k;
     33  for (k=0; k < jobList_.size();k++) {
     34    if ( jobList_[k] != NULL ) delete jobList_[k];
     35  }
     36  if ( currentBeam_ == NULL ) delete currentBeam_;
     37}
     38
     39void dataManager::consoleMessage(string message)
     40{
     41  GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     42  if (console) console->addConsoleMessage(message + "\n");
     43  pspa_->processEvents();
    3644}
    3745
    3846string dataManager::getLabelFromElementNumero(int numero)
    3947{
    40     abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(numero-1);
    41     if ( ptr == NULL ) return "";
    42     return ptr->getLabel();
    43 }
    44 
     48  abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(numero-1);
     49  if ( ptr == NULL ) return "";
     50  return ptr->getLabel();
     51}
    4552
    4653int dataManager::getNumeroFromElementLabel(string label)
    4754{
    48     int index = -1;
    49    
    50     for (int 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 
     55  int index = -1;   
     56  for (int k = 0; k < getBeamLineSize() ; k++) {
     57    if (pspa_->getBeamLine()->getAbstractElement(k) != NULL) {
     58      if ( pspa_->getBeamLine()->getAbstractElement(k)->getLabel() == label )
     59        {
     60          index = (int)k + 1;
     61          return index;
     62        }
     63    }
     64  }
     65  return index;
     66}
    6367
    6468abstractElement* dataManager::getElementPointerFromNumero(int k)
     
    6771}
    6872
    69 sectionToExecute*  dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, nomDeLogiciel logiciel)
    70 {
     73sectionToExecute* dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, nomDeLogiciel logiciel)
     74{
     75  #if BAVARD > 0
     76  cout << "***********************************" << endl;
     77  cout << " dataManager::addSectionToExecute " << endl << endl;
     78#endif
     79
    7180  abstractSoftware* prog;
    7281  string inputFileName;
     
    8291  } else if (logiciel  == nomDeLogiciel::test) {
    8392    prog = new softwareTest(inputFileName, &globParam_, this);
     93  } else if (logiciel  == nomDeLogiciel::madx) {
     94    inputFileName = "madx.input";
     95    prog = new softwareMadx(inputFileName,&sectorParam_,this); 
    8496  } else {
    85     prog = NULL;
    86   }
    87 
    88   //  abstractSoftware* prog = createSoftwareConnexion(logiciel);
    89   jobList_.push_back(new sectionToExecute(debut, debutIndex, fin, finIndex, prog));
    90   //  return prog;
     97    prog = new softwareUnknown(); // xx
     98  }
     99
     100  jobList_.push_back(new sectionToExecute(debut,debutIndex,fin,finIndex,prog));
    91101  return jobList_.back();
    92102}
     
    94104void dataManager::clearSectionToExecute()
    95105{
    96     unsigned k;
    97     for(k = 0; k < jobList_.size(); k++)
     106  unsigned k;
     107  for(k = 0; k < jobList_.size(); k++)
    98108    {
    99         if ( jobList_[k] != NULL ) clearSectionToExecute(k);
    100     }
    101     jobList_.clear();
    102 }
    103 
    104 
    105 void dataManager::clearSectionToExecute(int a) {
    106   cout << " dataManager::clearSectionToExecute efaacement section d'index : " << a << endl;
     109      if ( jobList_[k] != NULL ) clearSectionToExecute(k);
     110    }
     111  jobList_.clear();
     112}
     113
     114void dataManager::clearSectionToExecute(int a)
     115{
     116  cout << " dataManager::clearSectionToExecute : effacement de la section d'index = " << a << endl;
    107117  if (a < 0) return;
    108118  if (a >= (int)jobList_.size()) return;
    109 
     119 
    110120  // lors de la creation de la section on a fait un 'new' d'un
    111121  // softwareXXXX : on fait ici le 'delete'
    112 
     122 
    113123  const abstractSoftware* soft = jobList_.at(a)->getSoftware();
    114124  if ( soft != NULL ) delete soft;
    115125  jobList_.erase (jobList_.begin()+a);
    116126}
    117 
    118127
    119128void dataManager::initializeExecution()
     
    141150void dataManager::removeFile(string nameOfFile)
    142151{
    143     ifstream fileExists;
    144     fileExists.open(nameOfFile.c_str(), ios::in);
    145     if (fileExists) {
    146         fileExists.close();
    147         remove(nameOfFile.c_str());
    148     }
     152  ifstream fileExists;
     153  fileExists.open(nameOfFile.c_str(), ios::in);
     154  if (fileExists) {
     155    fileExists.close();
     156    remove(nameOfFile.c_str());
     157  }
    149158}
    150159
    151160bool dataManager::executeAll()
    152161{
     162  cout << "***********************************" << endl;
     163  cout << " dataManager::executeAll() " << endl << endl;
     164
    153165  bool success = true;
    154166  abstractSoftware* softw = NULL;
    155167  string workingDir = pspa_->getWorkingDir();
    156  
     168  
    157169  // on verifie la consecution des sections
    158170  int lastel = 0;
     
    165177    }
    166178  }
    167 
     179 
    168180  unsigned debut;
    169181  unsigned fin;
    170182  for(unsigned k = 0; k < jobList_.size(); k++) {
     183 
    171184    cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
    172      
     185   
    173186    debut = jobList_[k]->getElementNumberInSection();
    174187    fin = jobList_[k]->getLastElementNumberInSection();
    175188    softw = jobList_[k]->getSoftware();
    176189   
     190    //cout << "k= " << k << ", de " << jobList_[k]->getFirstElement()->getLabel() << " à " << jobList_[k]->getLastElement()->getLabel() << " avec " << softw->getName() << endl;
     191
    177192    if (softw == NULL) {
    178         success = false;
    179         consoleMessage("dataManager::executeAll : unknown software");
    180         break;
     193      success = false;
     194      consoleMessage("dataManager::executeAll : unknown software");
     195      break;
     196    }
     197   
     198    success = softw->createInputFile(currentBeam_,debut,fin,workingDir);
     199    if ( success ) {
     200      success = softw->execute(workingDir);
     201      if ( success ) {
     202        success = softw->buildBeamAfterElements(workingDir);
    181203      }
    182      
    183       success = softw->createInputFile(currentBeam_,debut,fin,workingDir);
    184       if ( success ) {
    185         success = softw->execute(workingDir);
    186         if ( success ) {
    187           success = softw->buildBeamAfterElements(workingDir);
    188         }
    189       }
    190      
    191       if ( success ) {
    192         currentBeam_ = &diagnosticBeam_.at(indexElementToIndexDiag_.back());
    193         cout << " execute termine avec succes " << endl;
    194       } else {
    195         currentBeam_ = NULL;
    196         cout << " execute termine en ECHEC " << endl;
    197       }
    198       if ( !success ) break;
    199      
    200       if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut;
    201       if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin;
    202      
    203       //debug
    204       cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
    205       cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
    206       for (unsigned j = debut; j <= fin; j++) {
    207         abstractElement* elPtr= getElementPointerFromNumero(j);
    208         cout << "[" << j << "] " << elPtr->getNomdElement().getExpandedName() << endl;
    209       }
     204    }
     205   
     206    if ( success ) {
     207      currentBeam_ = &diagnosticBeam_.at(indexElementToIndexDiag_.back());
     208      cout << " execute termine avec succes " << endl;
     209    } else {
     210      currentBeam_ = NULL;
     211      cout << " execute termine en ECHEC " << endl;
     212    }
     213    if ( !success ) break;
     214   
     215    if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut;
     216    if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin;
     217   
     218    //debug
     219    cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
     220    cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
     221    for (unsigned j = debut; j <= fin; j++) {
     222      abstractElement* elPtr= getElementPointerFromNumero(j);
     223      cout << "[" << j << "] " << elPtr->getNomdElement().getExpandedName() << endl;
     224    }
    210225  } //k
    211226 
     
    216231void dataManager::saveConfiguration(string folder, string nameOfFile)
    217232{
    218     ofstream outfile;
    219     //    string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save";
    220     cout << " dataManager::saveConfiguration : suppression du folder dans le nom de " << endl;
    221     cout << " sauvegarde, en attendant que ce soit autre chose que le sessionId" << endl;
    222     cout << " et qu'on puisse restaurer normalement" << endl;
    223     string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save";
    224    
    225     // make dir if not exist
    226     boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/");
    227    
    228     outfile.open(name.c_str(), ios::out);
    229     if (!outfile) {
    230         cerr << " error opening output file for persistency " << name << endl;
    231     }
    232    
    233     outfile << globParam_.FileOutputFlow();
    234     abstractElement* elPtr;
    235     for(int k = 0; k < getBeamLineSize() ; k++)
     233  ofstream outfile;
     234  //    string name = pspa_->getWorkingDir()+ folder + "/" + nameOfFile + ".save";
     235  cout << " dataManager::saveConfiguration : suppression du folder dans le nom de " << endl;
     236  cout << " sauvegarde, en attendant que ce soit autre chose que le sessionId" << endl;
     237  cout << " et qu'on puisse restaurer normalement" << endl;
     238
     239  string name = pspa_->getWorkingDir() + "/" + nameOfFile + ".save"; 
     240  // make dir if not exist
     241  boost::filesystem::create_directories(pspa_->getWorkingDir() + folder + "/");
     242 
     243  outfile.open(name.c_str(), ios::out);
     244  if (!outfile) {
     245    cerr<<" ERROR opening output file for persistency "<<name<<endl;
     246  }
     247 
     248  outfile << globParam_.FileOutputFlow();
     249  outfile << sectorParam_.FileOutputFlow();
     250  abstractElement* elPtr;
     251  for(int k = 0; k < getBeamLineSize() ; k++)
    236252    {
    237253      elPtr = pspa_->getBeamLine()->getAbstractElement(k);
    238254      outfile << elPtr->FileOutputFlow();
    239255    }
    240     outfile.close();
     256  outfile.close();
    241257}
    242258
     
    247263  uap_root = new UAPNode("UAP_root");
    248264  UAPNode* rep = uap_root->addChild("AML_representation");
    249 
     265 
    250266  // root node in the hierarchy
    251267  UAPNode* lab = rep->addChild("laboratory");
    252268  lab->addAttribute("name","PSPA lab");
    253 
     269 
    254270  // general global parameters
    255271  globParam_.InputRep(lab);
    256 
     272 
    257273  // accelerator or section of accelerator
    258274  //UAPNode* acc = lab->addChild("machine");
    259275  //acc->addAttribute("name",fileName);
     276
     277  sectorParam_.InputRep(lab);
    260278
    261279  // sequence of elements
     
    275293}
    276294
    277 bool dataManager::restoreElements( string inputFileName)
    278 {
    279     cout << "dataManager::restoreElements() fichier " << inputFileName << endl;
    280     ifstream infile;
    281     string name = inputFileName;
    282     infile.open(name.c_str(), ios::in);
    283     if (!infile) {
    284         cerr << " error opening input stream " << name << endl;
    285         return false;
    286     }
    287     else cout << " successful opening input stream " << name << endl;
    288    
    289     string globalTitle;
    290     if ( infile >> globalTitle ) {
    291         if ( globalTitle == string("globals") ) {
    292             globParam_.raz();
    293             globParam_.FileInput(infile);
    294         } else {
    295             cerr << " dataManager::restoreElements ERROR : global parameters seems to be missing" << endl;
    296             return false;
    297         }
     295bool dataManager::restoreElements(string inputFileName)
     296{
     297  cout << "***********************************" << endl;
     298  cout << " dataManager::restoreElements() fichier :" << inputFileName << endl << endl;
     299
     300  ifstream infile;
     301  string name = inputFileName;
     302  infile.open(name.c_str(), ios::in);
     303  if (!infile) {
     304    cerr << " error opening input stream " << name << endl;
     305    return false;
     306  }
     307  else cout << " successful opening input stream : " << name << endl;
     308 
     309  string globalTitle;
     310  if ( infile >> globalTitle ) {
     311    if ( globalTitle == string("globals") ) {
     312      globParam_.raz();
     313      globParam_.FileInput(infile);
    298314    } else {
    299         cerr << " dataManager::restoreElements ERROR : reading data save file" << endl;
    300         return false;
    301     }
    302    
    303     pspa_->getBeamLine()->clear();
    304    
    305     nomdElements::typedElement elementType;
    306     string elementLabel;
    307     while (infile >> elementLabel) {
    308         elementType = nomdElements::getTypeFromLabel(elementLabel);
    309        
    310         GWt_abstractElement* nouveau = pspa_->getBeamLine()->addElement(elementType);
    311        
    312         if ( nouveau == NULL ) {
    313             cerr << " dataManager::restoreElements ERROR : restoring element " << elementLabel << " failed " << endl;
    314             return false;
    315         }
    316         nouveau->FileInput(infile);
    317     }
    318     infile.close();
    319    
    320     // debug
    321     // unsigned k;
    322     // for(k = 0; k < getBeamLineSize(); k++) {
    323     //     abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k);
    324     //     cout << "reupere " << ptr->getLabel() << endl;
    325     // }
    326     return true;
     315      //cout << " INFO::dataManager::restoreElements : global parameters seems to be missing" << endl;
     316      //return false;
     317    }
     318  } else {
     319    cerr << " ERROR::dataManager::restoreElements : reading globalParameters in save file" << endl;
     320    return false;
     321  }
     322
     323  //NOTE:: je ne sais pas si les parametres "secteur" seront conservés, aussi pour ne pas trop changer les fichiers je lis les données aprÚs "globals" dans la boucle
     324 
     325  pspa_->getBeamLine()->clear();
     326  nomdElements::typedElement elementType;
     327  string elementLabel;
     328  while (infile >> elementLabel) {
     329
     330    if (elementLabel == string("lattice") ) {
     331      sectorParam_.raz();
     332      sectorParam_.FileInput(infile);
     333    } else {
     334      elementType = nomdElements::getTypeFromLabel(elementLabel);
     335      GWt_abstractElement* nouveau = pspa_->getBeamLine()->addElement(elementType);
     336      if ( nouveau == NULL ) {
     337        cerr << " dataManager::restoreElements() : restore element " << elementLabel << " failed " << endl;
     338        return false;
     339      } else {
     340        nouveau->FileInput(infile);
     341      }
     342    }
     343  }// while
     344 
     345 #if BAVARD > 1
     346  unsigned k;
     347  for(k = 0; k < getBeamLineSize(); k++) {
     348    abstractElement* ptr = pspa_->getBeamLine()->getAbstractElement(k);
     349    cout << "recupere " << ptr->getLabel() << endl;
     350  }
     351#endif
     352
     353  infile.close();
     354  return true;
    327355}
    328356
     
    386414abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi)
    387415{
    388     string inputFileName;
    389     if(logi == nomDeLogiciel::parmela) {
    390       cout << " dataManager::createSoftwareConnexion : logiciel identifie : parmela " << endl;
    391         inputFileName = "parmin";
    392         return new softwareParmela(inputFileName, &globParam_, this);
    393     } else if (logi == nomDeLogiciel::transport) {
    394       cout << " dataManager::createSoftwareConnexion : logiciel identifie : transport " << endl;
    395         inputFileName = "transport.input";
    396         return new softwareTransport(inputFileName, &globParam_, this);
    397     } else if (logi == nomDeLogiciel::generator) {
    398       cout << " dataManager::createSoftwareConnexion : logiciel identifie : generator " << endl;
    399         inputFileName = "generator.in";
    400         return new softwareGenerator(inputFileName, &globParam_, this);
    401     } else if (logi == nomDeLogiciel::test) {
    402       cout << " dataManager::createSoftwareConnexion : logiciel identifie : test " << endl;
     416  string inputFileName;
     417  if(logi == nomDeLogiciel::parmela) {
     418    cout << " dataManager::createSoftwareConnexion : logiciel identifie : parmela " << endl;
     419    inputFileName = "parmin";
     420    return new softwareParmela(inputFileName, &globParam_, this);
     421  } else if (logi == nomDeLogiciel::transport) {
     422    cout << " dataManager::createSoftwareConnexion : logiciel identifie : transport " << endl;
     423    inputFileName = "transport.input";
     424    return new softwareTransport(inputFileName, &globParam_, this);
     425  } else if (logi == nomDeLogiciel::generator) {
     426    cout << " dataManager::createSoftwareConnexion : logiciel identifie : generator " << endl;
     427    inputFileName = "generator.in";
     428    return new softwareGenerator(inputFileName, &globParam_, this);
     429  } else if (logi == nomDeLogiciel::test) {
     430    cout << " dataManager::createSoftwareConnexion : logiciel identifie : test " << endl;
    403431        return new softwareTest(inputFileName, &globParam_, this);
    404     } else {
    405       cout << " dataManager::createSoftwareConnexion : logiciel identifie : null " << endl;
    406         return NULL;
    407     }
    408 }
     432  } else {
     433    cout << " dataManager::createSoftwareConnexion : logiciel identifie : null " << endl;
     434    return NULL;
     435  }
     436}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementDrift.cc

    r424 r431  
    2929{
    3030  int compteur = -1;
    31   parametersString_[++compteur] = mixedTools::intToString(nbParam_);
    32   parametersString_[++compteur] = specificName_;
    33   parametersString_[++compteur] = mixedTools::doubleToString(lenghtElem_);
    34   parametersString_[++compteur] = mixedTools::doubleToString(aperture_);
     31  parametersString_[++compteur]= mixedTools::intToString(nbParam_);
     32  parametersString_[++compteur]= specificName_;
     33  parametersString_[++compteur]= mixedTools::doubleToString(lenghtElem_);
     34  parametersString_[++compteur]= mixedTools::doubleToString(aperture_);
    3535  if ( compteur != nbParam_ ) {
    3636    cerr << " elementDrift::getParametersString() : ERROR nr pf parameters dosnt match " << endl;
  • Interface_Web/trunk/pspaWT/sources/controler/src/nomDeLogiciel.cc

    r418 r431  
    11#include "nomDeLogiciel.h"
    2 
    32
    43nomDeLogiciel::Logiciel nomDeLogiciel::fromString( std::string s)
     
    98    else if ( s == "useraction" ) return useraction;
    109    else if ( s == "test" ) return test;
     10    else if ( s == "madx" ) return madx;
    1111    return unknownSoftware;
    1212  }
    1313
    14  std::string nomDeLogiciel::toString( nomDeLogiciel::Logiciel lg)
    15   {
    16     switch (lg)
    17       {
    18       case parmela : { return "parmela"; }
    19       case transport : { return "transport"; }
    20       case generator : { return "generator"; }
    21       case useraction : { return "useraction"; }
    22       case test : { return "test"; }
    23       case unknownSoftware : { return "unknownSoftware"; }
    24       }
    25     return "unknownSoftware";
    26   }
     14std::string nomDeLogiciel::toString(nomDeLogiciel::Logiciel lg)
     15{
     16  switch (lg)
     17    {
     18    case parmela : { return "parmela"; }
     19    case transport : { return "transport"; }
     20    case generator : { return "generator"; }
     21    case useraction : { return "useraction"; }
     22    case test : { return "test"; }
     23    case madx : { return "madx"; }
     24    case unknownSoftware : { return "unknownSoftware"; }
     25    }
     26  return "unknownSoftware";
     27}
    2728
    28     /** Color of the background of the sofware
    29      Should be a valid Css name as FFEEDD
    30      */
    31  std::string nomDeLogiciel::getWtColor( nomDeLogiciel::Logiciel lg) const
    32   {
    33     switch (lg)
    34       {
    35       case parmela : { return "#e09bdf"; }
    36       case transport : { return "#c0ea8e"; }
    37       case generator : { return "#a3c0ed"; }
    38       case useraction : { return "#FFFFFF"; }
    39       case test : { return "#ecc38e"; }
    40       case unknownSoftware : { return "#FFFFFF"; }
    41       }
    42     return "#FFFFFF";
    43   }
    44 
     29/** Color of the background of the sofware
     30    Should be a valid Css name as FFEEDD
     31*/
     32std::string nomDeLogiciel::getWtColor( nomDeLogiciel::Logiciel lg) const
     33{
     34  switch (lg)
     35    {
     36    case parmela : { return "#e09bdf"; }
     37    case transport : { return "#c0ea8e"; }
     38    case generator : { return "#a3c0ed"; }
     39    case useraction : { return "#FFFFFF"; }
     40    case test : { return "#ecc38e"; }
     41    case madx : { return "#ecc38e"; } //{ return "#FFFF00"; }
     42    case unknownSoftware : { return "#FFFFFF"; }
     43    }
     44  return "#FFFFFF";
     45}
    4546
    4647 nomDeLogiciel::nomDeLogiciel() 
    47   {
    48     program_ = unknownSoftware;
    49     progString_ = toString(program_);
    50     //    value_ = toValue(program_);
    51   }
     48 {
     49   program_ = unknownSoftware;
     50   progString_ = toString(program_);
     51 }
    5252
    53   nomDeLogiciel::nomDeLogiciel(const string& s)
    54     {
    55       program_ = fromString(s);
    56       progString_ = toString(program_);
    57       //      value_ = toValue(program_);
    58     }
     53nomDeLogiciel::nomDeLogiciel(const string& s)
     54{
     55  program_ = fromString(s);
     56  progString_ = toString(program_);
     57}
    5958
    60   nomDeLogiciel::nomDeLogiciel(int val)
    61     { 
    62       program_ = (Logiciel)val;
    63       progString_ = toString(program_);
    64       //      program_ = fromValue(val);
    65       //      value_ = toValue(program_);
    66     }
    67 
    68 
     59nomDeLogiciel::nomDeLogiciel(int val)
     60
     61  program_ = (Logiciel)val;
     62  progString_ = toString(program_);
     63}
    6964
    7065int nomDeLogiciel::getNumberOfSoftwares()
    7166{
    72   //  return toValue(unknownSoftware);
    7367  return unknownSoftware;
    7468}
    7569
    76   // operators
    77  
    78   nomDeLogiciel& nomDeLogiciel::operator= (const nomDeLogiciel& nl)
    79     {
    80       program_ = nl.program_;
    81       progString_ = nl.progString_;
    82       //      value_ = nl.value_;
    83       return *this;
    84     }
     70// operators
     71nomDeLogiciel& nomDeLogiciel::operator= (const nomDeLogiciel& nl)
     72{
     73  program_ = nl.program_;
     74  progString_ = nl.progString_;
     75  return *this;
     76}
    8577
    86   bool nomDeLogiciel::operator== (const nomDeLogiciel& nl)
    87   {
    88     return ( program_ == nl.program_);
    89   }
     78bool nomDeLogiciel::operator== (const nomDeLogiciel& nl)
     79{
     80  return ( program_ == nl.program_);
     81}
    9082
    91   bool nomDeLogiciel::operator!= (const nomDeLogiciel& nl)
    92   {
    93     return ( program_ != nl.program_);
    94   }
     83bool nomDeLogiciel::operator!= (const nomDeLogiciel& nl)
     84{
     85  return ( program_ != nl.program_);
     86}
  • Interface_Web/trunk/pspaWT/sources/controler/src/nomdElements.cc

    r418 r431  
    1414  else if( strstr(s.c_str(),"fit") ) return fit;
    1515  else if( strstr(s.c_str(),"snapshot") ) return snapshot;
     16  else if( strstr(s.c_str(),"mpole") ) return mpole;
    1617  return inconnu;
    1718}
     
    2728  else if( s == "fit" ) return fit;
    2829  else if( s == "snapshot" ) return snapshot;
     30  else if( s == "mpole" ) return mpole;
    2931  return inconnu;
    3032}
     
    4143  case fit : return "FIT"; break;
    4244  case snapshot : return "SNAPSHOT"; break;
     45  case mpole : return "MPOLE"; break;
    4346  default : return "UNKNOWN";
    4447  }
     
    5659  case fit :   return "fit";
    5760  case snapshot : return "snapshot";
     61  case mpole :   return "mpole";
    5862  default : return string("");
    5963  }
     
    7175  case fit :   return 4;
    7276  case snapshot : return 2;
     77  case mpole :   return 3;
    7378  default : return 0;
    7479  }
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h

    r365 r431  
    33
    44#include "GWt_draggableImage.h"
     5#include "GWt_console.h"
     6
    57#include "abstractElement.h"
    6 #include "GWt_console.h"
    78#include "elementDrift.h"
    89#include "elementRfgun.h"
     
    1314#include "elementFit.h"
    1415#include "elementSnapshot.h"
     16#include "elementMultipole.h"
    1517
    1618#include <Wt/WDialog>
     
    3335class GWt_abstractElement : public WContainerWidget
    3436{
    35     protected :
     37 protected :
    3638   
    37     abstractElement* abstractElement_;
     39  abstractElement* abstractElement_;
    3840   
    39     WDialog* dialog_;
    40     GWt_draggableImage* dropped_;
    41     WContainerWidget* wc_;
    42     WText* wc_item_;
    43     WLineEdit* labelEdit_;
     41  WDialog* dialog_;
     42  GWt_draggableImage* dropped_;
     43  WContainerWidget* wc_;
     44  WText* wc_item_;
     45  WLineEdit* labelEdit_;
    4446   
    45     GWt_abstractElement() {;}
    46     string* beginDialog();
    47    
    48     public :
    49    
    50     GWt_abstractElement(abstractElement*);
    51    
    52     void initialize();
    53     void showParameters();
    54     void deleteElement();
     47  GWt_abstractElement() {;}
     48  string* beginDialog();
     49 
     50 public :
     51 
     52  GWt_abstractElement(abstractElement*);
     53 
     54  void initialize();
     55  void showParameters();
     56  void deleteElement();
     57 
     58  void updateLabelAndToolTipWidget();
     59  void FileInput(ifstream& ifs);
     60 
     61  WContainerWidget* getWidget();
     62  abstractElement* getAbstractElement();
    5563
    56     void updateLabelAndToolTipWidget();
    57     void FileInput(ifstream& ifs);
    58    
    59     //  GWt_draggableImage* getImage();
    60     WContainerWidget* getWidget();
    61     abstractElement* getAbstractElement();
    62    
    63     virtual void dialogDone(WDialog::DialogCode code) = 0;
    64    
    65     inline WString print() {
    66         return abstractElement_->print();
    67     }
    68    
    69     virtual string getMimeType() = 0;
    70     virtual string getSmallImageURL() = 0;
    71     virtual string getBigImageURL() = 0;
    72     virtual string getName() = 0;
    73     virtual void initilializeDialog() = 0;
    74    
    75     void createDragImage(WContainerWidget*);
    76     WImage* getImage();
    77    
    78 protected:
    79    
     64  inline WString print() {
     65    return abstractElement_->print();
     66  }
     67
     68  virtual void dialogDone(WDialog::DialogCode code) = 0;
     69  virtual string getMimeType() = 0;
     70  virtual string getSmallImageURL() = 0;
     71  virtual string getBigImageURL() = 0;
     72  virtual string getName() = 0;
     73  virtual void initilializeDialog() = 0;
     74 
     75  void createDragImage(WContainerWidget*);
     76  WImage* getImage();
     77 
     78 protected:
     79 
    8080    WImage* image_;
    8181    GWt_elementLigneFaisceau* elementLigneFaiseauContainer_;
     
    8686   
    8787    inline void registerParam(string name, variant<int, string, bool, float, NullType> value, string desc) {
    88         parameterMapValue[name] = value;
    89         parameterMapDescription[name] = desc;
     88      parameterMapValue[name] = value;
     89      parameterMapDescription[name] = desc;
    9090    }
    9191   
    92     variant<int, string, bool, float, NullType> getParamValue(string elem);
    93     string getParamDescription(string elem);
     92    variant<int, string, bool, float, NullType> getParamValue(string);
     93    string getParamDescription(string);
    9494};
    9595#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElementFactory.h

    r343 r431  
    1818#include "GWt_fit.h"
    1919#include "GWt_snapshot.h"
     20#include "GWt_mpole.h"
    2021
    2122using namespace Wt;
     
    6263  inline void setSnapshotEnable(bool a) { isSnapshotElementEnable = a;};
    6364 
     65  /* Enable the mpole element creation
     66   */
     67  inline void setMPoleEnable(bool a) { isMPoleElementEnable = a;};
     68 
    6469  GWt_drift* createDriftElement();
    6570  GWt_rfgun* createRFGunElement();
     
    7075  GWt_fit* createFitElement();
    7176  GWt_snapshot* createSnapshotElement();
     77  GWt_mpole* createMPoleElement();
    7278  vector <GWt_abstractElement*> getAllElements();
    7379 
     
    8288  bool isFitElementEnable;
    8389  bool isSnapshotElementEnable;
     90  bool isMPoleElementEnable;
    8491};
    8592#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_globalParameters.h

    r428 r431  
    3939  void updateGlobals();
    4040  void renew();
    41   void setText(WContainerWidget*);
     41  void setText(WText*);
    4242};
    4343#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r426 r431  
    33
    44#include <cstdlib>
    5 #include <list>
     5#include <string.h>
     6#include <vector>
    67
    78#include <Wt/WApplication>
     
    910#include <Wt/WContainerWidget>
    1011#include <Wt/WText>
     12#include <Wt/WLineEdit>
    1113#include <Wt/WPanel>
    1214#include <Wt/WComboBox>
     
    2426#include "GWt_ligneFaisceau.h"
    2527#include "GWt_globalParameters.h"
     28#include "GWt_sectorParameters.h"
    2629
    2730#include "dataManager.h"
     
    4346  GWt_LigneFaisceau* beamLine_;
    4447   
    45   // WWidget* globalParam_;
    46   GWt_globalParameters* globalParam_; // xx
     48  GWt_globalParameters* globalParam_;
     49  GWt_sectorParameters* sectorParam_;
    4750 
    4851  GWt_dialog* graphicsDialog_;
     
    7376  WContainerWidget* createDrawingWidget();
    7477
    75   //WWidget* createGlobalParamWidget();
    76   WWidget* createDashBoard(); // xx
    77   void messageBox1(); // xx
    78   void messageBox2(); // xx
     78  WWidget* createDashBoard();
     79  void messageBox1();
     80  void messageBox2();
    7981 
    8082  // extensions (.001, .002,...) pour les fichiers "snapshot"
     
    119121  }
    120122
    121 
    122   /* inline WWidget* getGlobalParam() { */
    123   /*   return globalParam_; */
    124   /* } */
    125 
    126123  inline GWt_softwarePanel* getExecuteWidget() {
    127124    return executeWidget_;
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_softwarePanel.h

    r407 r431  
    2323class GWt_softwarePanel  : public WContainerWidget
    2424{
    25     public :
    26     GWt_softwarePanel(dataManager*, PspaApplication*);
    27     virtual ~GWt_softwarePanel();
     25 public :
     26 
     27  GWt_softwarePanel(dataManager*, PspaApplication*);
     28  virtual ~GWt_softwarePanel();
    2829
    29     void addSectionToExecuteW();
    30     void updateSections();
     30  void addSectionToExecuteW();
     31  void updateSections();
    3132   
    32     private :
    33     //    void disableSectionExecute();
    34     //    void checkSectionSelection();
    35     bool updateSectionSelection();
    36     void deleteSectionToExecuteW(int section);
    37     string getSelection();
    38     void executer();
    39     bool areDataCoherent();
    40     void fillComboWithElements(Wt::WComboBox* cBox);
    41     void fillComboWithSoftwares(Wt::WComboBox* cBox);
    42     Wt::WContainerWidget* createAddDeletePushButtons(int sectionIndex);
     33 private :
     34 
     35  bool updateSectionSelection();
     36  void deleteSectionToExecuteW(int section);
     37  string getSelection();
     38  void executer();
     39  bool areDataCoherent();
     40  void fillComboWithElements(Wt::WComboBox* cBox);
     41  void fillComboWithSoftwares(Wt::WComboBox* cBox);
     42  Wt::WContainerWidget* createAddDeletePushButtons(int sectionIndex);
    4343
    44     dataManager* dtmanage_;
    45     WPushButton *exec_go_;
    46     WContainerWidget* contenuSections_;
    47     PspaApplication* pspa_;
     44  dataManager* dtmanage_;
     45  WPushButton *exec_go_;
     46  WContainerWidget* contenuSections_;
     47  PspaApplication* pspa_;
    4848
    49     std::vector <GWt_sectionToExecute*> sections_;
     49  std::vector <GWt_sectionToExecute*> sections_;
    5050};
    51 
    5251#endif /* defined(__PSPA__GWt_softwarePanel__) */
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r418 r431  
    1414#include "GWt_beam.h"
    1515#include "GWt_fit.h"
    16 #include "GWt_snapshot.h"
     16//#include "GWt_snapshot.h"
     17
    1718#include "GWt_draggableImage.h"
    1819#include "GWt_ligneFaisceau.h"
     
    2930
    3031GWt_abstractElement::GWt_abstractElement(abstractElement* elem)
    31 : WContainerWidget()
     32  : WContainerWidget()
    3233{
    33     abstractElement_ = elem;
     34  abstractElement_ = elem;
    3435}
    35 
    3636
    3737void GWt_abstractElement::initialize()
    3838{
    39     // make image
    40     image_ = new WImage(getBigImageURL(),this);
    41    
    42     addWidget(image_);
    43     updateLabelAndToolTipWidget();
     39  image_ = new WImage(getBigImageURL(),this); // make image 
     40  addWidget(image_);
     41  updateLabelAndToolTipWidget();
    4442}
    45 
    4643
    4744string* GWt_abstractElement::beginDialog()
    4845{
    49   string* param = abstractElement_-> getParametersString();
    50    
    51   if ( param == NULL )
    52     {
    53       if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    54         GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    55         console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getExpandedName());
    56         }
     46  string* param = abstractElement_->getParametersString();
     47 
     48  if ( param == NULL ) {
     49    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     50      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     51      console->addConsoleMessage(" GWt_abstractElement::beginDialog : empty parameter set for element " + abstractElement_->getNomdElement().getExpandedName());
    5752    }
    58   //   int compteur = -1;
     53  }
     54
     55  int nbparam = atoi(param->c_str());
     56  if ( nbparam != abstractElement_->getNbParams()) {
     57    if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
     58      GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
     59      console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getExpandedName());
     60    }
     61  }
    5962 
    60   //  int nbparam = atoi(param[++compteur].c_str());
    61   int nbparam = atoi(param->c_str());
    62   if ( nbparam != abstractElement_->getNbParams())
    63     {
    64         if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    65           GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    66           console->addConsoleMessage(" element seems not to be a " + abstractElement_->getNomdElement().getExpandedName());
    67         }
    68     }
    69  
    70   dialog_ = new WDialog("element " + abstractElement_->getNomdElement().getExpandedName());
    71     new WText(" label of the element : ",dialog_->contents());
    72     //  labelEdit_ = new WLineEdit(param[++compteur].c_str(), dialog_->contents());
    73    
    74     labelEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents());
    75     new WBreak(dialog_->contents());
    76     return ++param;
     63  dialog_ = new WDialog("element "+abstractElement_->getNomdElement().getExpandedName());
     64  new WText(" label of the element : ",dialog_->contents());
     65  labelEdit_ = new WLineEdit( (++param)->c_str(),dialog_->contents());
     66  new WBreak(dialog_->contents());
     67  return ++param;
    7768}
    7869
    7970void GWt_abstractElement::updateLabelAndToolTipWidget()
    8071{
    81     if (abstractElement_ != NULL) {
     72  if (abstractElement_ != NULL) {
    8273    elementLigneFaiseauContainer_->setElementLabel(abstractElement_->getLabel());
    8374    setToolTip(print());
    84     }
     75  }
    8576}
    8677
     
    9182}
    9283
    93 
    9484void GWt_abstractElement::deleteElement()
    9585{
    96     StandardButton result = WMessageBox::show("PSPA : Delete element", WString("Delete '")+WString(getAbstractElement()->getLabel())+"' ?", Ok | Cancel);
     86  StandardButton result = WMessageBox::show("PSPA : Delete element", WString("Delete '")+WString(getAbstractElement()->getLabel())+"' ?", Ok | Cancel);
     87 
     88  if (result == Cancel) {
     89    return;
     90  }
     91  // get LigneFaiseau widget and add new elementLigneFaiseau
     92  GWt_LigneFaisceau* ligneFaisceau = NULL;
     93  if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     94    ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     95  } else {
     96    return;
     97  }
     98 
     99  ligneFaisceau->removeElement(this);
     100}
    97101
    98     if (result == Cancel ) {
    99         return;
    100     }
    101     // get LigneFaiseau widget and add new elementLigneFaiseau
    102     GWt_LigneFaisceau* ligneFaisceau = NULL;
    103     if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
    104         ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
    105     } else {
    106         return;
    107     }
    108    
    109     ligneFaisceau->removeElement(this);
     102void GWt_abstractElement::createDragImage(WContainerWidget* w)
     103{
     104  GWt_draggableImage *result= new GWt_draggableImage(getBigImageURL(),w);
     105 
     106  /*
     107   * Set the image to be draggable, showing the other image (dragImage)
     108   * to be used as the widget that is visually dragged.
     109   */
     110  result->setDraggable(getMimeType(),new WImage(getSmallImageURL(),w),true);
     111  result->setToolTip(getName());
     112}
     113
     114void GWt_abstractElement::FileInput(ifstream& ifs)
     115{
     116  getAbstractElement()->FileInput(ifs);
     117  initilializeDialog();
     118  updateLabelAndToolTipWidget();
     119 
     120  // update parameters
     121  GWt_LigneFaisceau* ligneFaisceau = NULL;
     122  if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     123    ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     124    ligneFaisceau->update();
     125  }
     126}
     127
     128abstractElement* GWt_abstractElement::getAbstractElement() {
     129  return abstractElement_;
    110130}
    111131
    112132WContainerWidget* GWt_abstractElement::getWidget() {
    113     return wc_;
    114 }
    115 
    116 abstractElement* GWt_abstractElement::getAbstractElement() {
    117     return abstractElement_;
    118 }
    119 
    120 
    121 void GWt_abstractElement::createDragImage(WContainerWidget* w){
    122 
    123     GWt_draggableImage *result = new GWt_draggableImage(getBigImageURL(),w);
    124 
    125     /*
    126      * Set the image to be draggable, showing the other image (dragImage)
    127      * to be used as the widget that is visually dragged.
    128      */
    129     result->setDraggable(getMimeType(),new WImage(getSmallImageURL(),w),true);
    130     result->setToolTip(getName());
    131 
     133  return wc_;
    132134}
    133135
    134136WImage* GWt_abstractElement::getImage() {
    135     return image_;
     137  return image_;
    136138}
    137139
    138 
    139 void GWt_abstractElement::FileInput(ifstream& ifs){
    140     getAbstractElement()->FileInput(ifs);
    141     initilializeDialog();
    142     updateLabelAndToolTipWidget();
    143 
    144 // update parameters
    145     GWt_LigneFaisceau* ligneFaisceau = NULL;
    146     if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
    147         ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
    148         ligneFaisceau->update();
     140variant<int, string, bool, float, NullType> GWt_abstractElement::getParamValue(string elem)
     141{
     142  if(parameterMapValue.find(elem) == parameterMapValue.end()) {
     143    return new NullType();
     144  }
     145 
     146  std::map<std::string, variant<int, string, bool, float, NullType> >::iterator it;
     147  it = parameterMapValue.find(elem);
     148  variant <int, string, bool, float, NullType> value = it->second;
     149 
     150  try {
     151    int pi = boost::get<int>(value);
     152    printf("%s Type is int\n",elem.c_str());
     153    return pi;
     154  }
     155  catch (boost::bad_get v) {
     156    try {
     157      string si = boost::get<string>(value);
     158      printf("%s Type is string\n",elem.c_str());
     159      return si;
    149160    }
     161    catch (boost::bad_get v) {
     162      try {
     163        bool bi = boost::get<bool>(value);
     164        printf("%s Type is bool\n",elem.c_str());
     165        return bi;
     166      }
     167      catch (boost::bad_get v) {
     168        printf("%s Type is NULL\n",elem.c_str());
     169        return new NullType();
     170      }
     171    }
     172  }
     173  printf("%s Type is NULL NULL\n",elem.c_str());
     174  return new NullType();
    150175}
    151176
    152 
    153 
    154 variant<int, string, bool, float, NullType> GWt_abstractElement::getParamValue(string elem) {
    155 
    156     if (parameterMapValue.find(elem) == parameterMapValue.end() )
    157     {
    158         return new NullType();
    159     }
    160 
    161     std::map<std::string, variant<int, string, bool, float, NullType> >::iterator it;
    162     it = parameterMapValue.find(elem);
    163    
    164     variant <int, string, bool, float, NullType> value = it->second;
    165    
    166     try {
    167         int pi = boost::get<int>(value);
    168         printf("%s Type is int\n",elem.c_str());
    169         return pi;
    170     }
    171     catch (boost::bad_get v) {
    172         try {
    173             string si = boost::get<string>(value);
    174             printf("%s Type is string\n",elem.c_str());
    175             return si;
    176         }
    177         catch (boost::bad_get v) {
    178             try {
    179                 bool bi = boost::get<bool>(value);
    180                 printf("%s Type is bool\n",elem.c_str());
    181                 return bi;
    182             }
    183             catch (boost::bad_get v) {
    184                 printf("%s Type is NULL\n",elem.c_str());
    185                 return new NullType();
    186             }
    187         }
    188     }
    189     printf("%s Type is NULL NULL\n",elem.c_str());
    190     return new NullType();
     177string GWt_abstractElement::getParamDescription(string elem)
     178{   
     179  if(parameterMapDescription.find(elem) == parameterMapDescription.end() ) {
     180    printf("%s Descr is NULL NULL\n",elem.c_str());
     181    return "";
     182  } else {
     183    printf("%s Descr is %s\n",elem.c_str(),parameterMapDescription.find(elem)->second.c_str());
     184    return parameterMapDescription.find(elem)->second;
     185  }
    191186}
    192 
    193 
    194 string GWt_abstractElement::getParamDescription(string elem) {
    195    
    196     if (parameterMapDescription.find(elem) == parameterMapDescription.end() )
    197     {
    198         printf("%s Descr is NULL NULL\n",elem.c_str());
    199         return "";
    200     } else {
    201         printf("%s Descr is %s\n",elem.c_str(),parameterMapDescription.find(elem)->second.c_str());
    202         return parameterMapDescription.find(elem)->second;
    203     }
    204 }
    205 
    206 
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElementFactory.cc

    r401 r431  
    1717  isBeamElementEnable(false),
    1818  isFitElementEnable(false),
    19   isSnapshotElementEnable(false)
     19  isSnapshotElementEnable(false),
     20  isMPoleElementEnable(false)
    2021{}
    2122
     
    3031  isFitElementEnable = false;
    3132  isSnapshotElementEnable = false;
     33  isMPoleElementEnable = false;
    3234}
    3335
     
    9698}
    9799
     100GWt_mpole* GWt_abstractElementFactory::createMPoleElement()
     101{
     102  if (isMPoleElementEnable) {
     103    return new GWt_mpole();
     104  }
     105  return NULL;
     106}
     107
    98108vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements()
    99109{
     
    123133    elems.push_back(new GWt_snapshot());
    124134  }
     135  if (isMPoleElementEnable) {
     136    elems.push_back(new GWt_mpole());
     137  }
    125138
    126139  return elems;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r418 r431  
    1313#include "GWt_fit.h"
    1414#include "GWt_snapshot.h"
     15#include "GWt_mpole.h"
    1516
    1617
     
    5556void GWt_elementLigneFaisceau::initialize_ligneFaisceau(nomdElements::typedElement eType)
    5657{   
    57   cout<<"new GWt_elementLigneFaisceau : "<< this << endl;
     58  cout << " new GWt_elementLigneFaisceau : "<< nomdElements::getLabelFromType(eType) << endl;
    5859   
    5960  // set layout
     
    113114  case nomdElements::fit  :
    114115    GWt_abstractElement_ = new GWt_fit(this);
     116    break;
     117  case nomdElements::mpole  :
     118    GWt_abstractElement_ = new GWt_mpole(this);
    115119    break;
    116120  case nomdElements::snapshot :
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc

    r428 r431  
    1515}
    1616
    17 void GWt_globalParameters::setText(WContainerWidget* wt)
     17void GWt_globalParameters::setText(WText *st)
    1818{
    19   status_ = new WText("Go ahead...",wt);
     19  status_ = st;
    2020}
    2121
     
    105105void GWt_globalParameters::setStatus()
    106106{
    107   WString out= WString("<p>frequency="+envoi_[1]+"</p>"
    108                        "<p>step in phase="+envoi_[2]+"</p>"
    109                        "<p>max step number="+envoi_[3]+"</p>"
    110                        "<p>periodicity of s.c. computation="+envoi_[4]+"</p>");
     107  WString out= WString("<p>frequency = "+envoi_[1]+"</p>"
     108                       "<p>step in phase = "+envoi_[2]+"</p>"
     109                       "<p>max step number = "+envoi_[3]+"</p>"
     110                       "<p>periodicity of s.c. computation = "+envoi_[4]+"</p>");
    111111  status_->setText(out);
    112112}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r418 r431  
    5959
    6060  GWt_abstractElement* GWtAbstractElem = NULL; 
    61   cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl;
     61  cout << " addElement::element : " << nomdElements::getLabelFromType(eType) << endl;
    6262   
    6363  // 3 cases :
     
    288288
    289289
    290 void GWt_LigneFaisceau::initializeSoftwares(){
    291    
     290void GWt_LigneFaisceau::initializeSoftwares()
     291{   
    292292  vector <abstractElement*> elems = getAllAbstractElements();
    293     for (int a=0; a< elems.size(); a++) {
    294       //     elems[a]->setSoftware(nomDeLogiciel::unknownSoftware);
    295       elems[a]->setSoftware( NULL );
    296     }
    297 }
    298 
    299 
     293  cout << "GWt_LigneFaisceau::initializeSoftwares() " << elems.size() << endl;
     294
     295  for (int a = 0; a < elems.size(); a++) {
     296    elems[a]->setSoftware( NULL );
     297  }
     298}
     299
     300
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r428 r431  
    11#include <stdio.h>
    2 #include <string.h>
    3 #include <vector>
    42#include <ctime>
    53
    64#include "GWt_pspaApplication.h"
    7 #include "GWt_ligneFaisceau.h"
    8 #include "GWt_softwarePanel.h"
    9 #include "GWt_globalParameters.h"
    105#include "GWt_draggableImage.h"
     6#include "GWt_serverFileSelector.h"
    117#include "particleBeam.h"
    128#include "bareParticle.h"
     
    1511#include "nomdElements.h"
    1612#include "environmentVariables.h"
    17 #include "GWt_console.h"
    18 #include "GWt_serverFileSelector.h"
    1913#include "trivaluedBool.h"
    2014
     
    2620#include <Wt/WStackedWidget>
    2721#include <Wt/WBreak>
    28 #include <Wt/WDialog>
    2922#include <Wt/WStandardItemModel>
    3023#include <Wt/WFileUpload>
    3124#include <Wt/WPainter>
    32 #include <Wt/WPdfImage>
    3325#include <Wt/WScrollArea>
    34 #include <Wt/WLineEdit>
    3526#include <Wt/WRadioButton>
    36 
    37 #include <Wt/WPanel>
    3827#include <Wt/WMessageBox>
    3928
     
    7362  abstractElementFactory_->setFitEnable(true);
    7463  abstractElementFactory_->setSnapshotEnable(true);
    75  
    76   // include the styleSheet
     64  abstractElementFactory_->setMPoleEnable(true);
     65 
     66  // include the styleSheetcd
    7767  WContainerWidget *widroot = root();
    7868  useStyleSheet("htdocs/pspa.css");
     
    144134
    145135  globalParam_ = new GWt_globalParameters(dtmanage_);
     136  sectorParam_ = new GWt_sectorParameters(dtmanage_);
    146137  WWidget* dboard = createDashBoard();
    147138  dboard->setMinimumSize(300,100);
     
    171162}
    172163
    173 // WWidget* PspaApplication::createGlobalParamWidget()
    174 // {
    175 //   WContainerWidget* globalParam = new GWt_globalParameters(this);
    176 //   globalParam->setMinimumSize(300,100);
    177 //   return globalParam;
    178 // }
    179 
    180164WWidget* PspaApplication::createDashBoard()
    181165{
    182   WContainerWidget *result = new WContainerWidget();
    183  
    184   WPanel *panel = new WPanel(result);
    185   panel->setTitle("dashboard");
    186  
    187   WContainerWidget *textdiv;
    188   textdiv = new WContainerWidget();
    189   textdiv->setStyleClass("text");
    190   globalParam_->setText(textdiv);
    191 
    192   WContainerWidget *cnt = new WContainerWidget();
     166  WContainerWidget *wt= new WContainerWidget();
     167  wt->setStyleClass("text");
     168  WText *st= new WText("Go ahead...",wt); 
     169
    193170  WContainerWidget *buttons = new WContainerWidget();
    194171  buttons->setStyleClass("buttons");
    195 
    196172  WPushButton *button;
    197   button = new WPushButton("globalParameters", buttons);
     173  button = new WPushButton("globalParameters",buttons);
    198174  button->clicked().connect(this, &PspaApplication::messageBox1);
    199  
    200   button = new WPushButton("fodoCells", buttons);
     175  button = new WPushButton("sectorParameters", buttons);
    201176  button->clicked().connect(this, &PspaApplication::messageBox2);
    202177 
     
    205180  styleSheet().addRule("body", "margin: 0px;");
    206181
     182  WContainerWidget *cnt = new WContainerWidget();
    207183  cnt->addWidget(buttons);
    208   cnt->addWidget(textdiv);
     184  cnt->addWidget(wt);
     185
     186  WContainerWidget *result = new WContainerWidget();
     187  WPanel *panel = new WPanel(result);
     188  panel->setTitle("dashboard");
    209189  panel->setCentralWidget(cnt);
     190
     191  globalParam_->setText(st);
     192  sectorParam_->setText(st);
    210193  return result;
    211194}
     
    219202void PspaApplication::messageBox2()
    220203{
     204  sectorParam_->execDialog();
    221205  return;
    222206}
     
    382366void PspaApplication::sauver()
    383367{
    384   cout << " on sauve " << endl;
    385   console_->addConsoleMessage("sauvegarde");
    386  
     368  cout << "***********************************" << endl;
     369  cout << " on sauve " << endl<<endl;
     370 
     371  console_->addConsoleMessage("sauvegarde \n"); 
    387372  dialogSave_ = new WDialog("save");
    388373  new WText("name of case : ",dialogSave_->contents());
     
    405390  dialogSave_ = NULL;
    406391
    407   globalParam_->updateGlobals();
     392  //globalParam_->updateGlobals();
    408393
    409394  //  dtmanage_->saveConfiguration(nameOfCase_);
     
    416401void PspaApplication::restaurer()
    417402{
     403  cout << "***********************************" << endl;
     404  cout << " on restaure " << endl<<endl;
     405
    418406  GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_);
    419407  string fileName = fs->exec();
     
    423411  }
    424412   
    425   removePathFromConfigName(nameOfCase_ );
     413  removePathFromConfigName(nameOfCase_);
    426414  cout << " nom sans path " << nameOfCase_ << endl;
    427415  removeExtensionFromConfigName(nameOfCase_);
    428416  cout << " nom sans extension " << nameOfCase_ << endl;
    429   if (nameOfCase_ == "")
    430     return;
    431   cout << " PspaApplication:: restaure le fichier " << fileName << endl;
     417  if (nameOfCase_ == "") return;
     418  cout << " PspaApplication::restaure le fichier   : " << fileName << endl;
    432419  dialogSave_ = NULL;
    433420 
     
    442429  }
    443430 
    444   globalParam_->renew(); 
     431  globalParam_->renew();
     432  sectorParam_->renew();
    445433  console_->addConsoleMessage(string("restauration terminee \n"));
    446434}
     
    448436void PspaApplication::openFileSelector()
    449437{
    450    
    451438  WContainerWidget *result = new WContainerWidget();
    452   WVBoxLayout* myLayout = new WVBoxLayout();
    453    
     439  WVBoxLayout* myLayout = new WVBoxLayout(); 
    454440  uploadFileSelectorWidget_ = new WFileUpload();
    455    
    456441  uploadFileSelectorWidget_->setFileTextSize(40);
    457    
    458442  myLayout->addWidget(new WText("Select the configuration file for pspa : "));
    459443  myLayout->addWidget(uploadFileSelectorWidget_);
    460    
    461444  result->setLayout (myLayout);
    462445   
     
    470453  uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge);
    471454 
    472  
    473455  GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false);
    474  
    475456  fileSelectorDialog->exec();
    476457}
     
    485466  cout << " fichier client sans extension : " << nomDuFichier << endl;
    486467 
    487   if ( test )
    488     {
    489       nameOfCase_ = nomDuFichier;
    490       console_->addConsoleMessage(string("restauration..."));
     468  if ( test ) {
     469    nameOfCase_ = nomDuFichier;
     470    console_->addConsoleMessage(string("restauration..."));
    491471     
    492       if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) {
    493         GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
    494         restoreWarning.exec();
    495       }
     472    if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) {
     473      GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
     474      restoreWarning.exec();
     475    }
    496476     
    497       GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
    498       bibi->renew();
    499      
    500       console_->addConsoleMessage(string("rechargement de config termine"));
    501       message->show();
    502     }
     477    globalParam_->renew();
     478    sectorParam_->renew();
     479    console_->addConsoleMessage(string("rechargement de la config termine"));
     480    message->show();
     481  }
    503482}
    504483
     
    513492  message += " bytes\n";
    514493   
    515   GWt_dialog*  messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true);
    516  
     494  GWt_dialog*  messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true);
    517495  messageBox->show();
    518496}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc

    r407 r431  
    1616softwarePanel(sPanel)
    1717{
    18     Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
    19     mainContainerLayout->setContentsMargins(0,0,0,0);
     18  Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
     19  mainContainerLayout->setContentsMargins(0,0,0,0);
    2020
    21     Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget();
    22     Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout();
    23     labelAndComboContainerLayout->setContentsMargins(0,0,0,0);
     21  Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget();
     22  Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout();
     23  labelAndComboContainerLayout->setContentsMargins(0,0,0,0);
    2424
    25     Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget();
    26     Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout();
    27     labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0);
    28    
    29     labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from&nbsp;:&nbsp;"));
    30     labelAndComboInsideContainerLayout->addWidget(first);
    31     labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to&nbsp;:&nbsp;"));
    32     labelAndComboInsideContainerLayout->addWidget(last);
    33     labelAndComboInsideContainerLayout->addWidget(soft);
     25  Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget();
     26  Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout();
     27  labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0);
     28 
     29  labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from&nbsp;:&nbsp;"));
     30  labelAndComboInsideContainerLayout->addWidget(first);
     31  labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to&nbsp;:&nbsp;"));
     32  labelAndComboInsideContainerLayout->addWidget(last);
     33  labelAndComboInsideContainerLayout->addWidget(soft);
     34 
     35    // add buttons
     36  labelAndComboInsideContainerLayout->addWidget(buttonPanel);
     37  labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
     38  labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
     39  labelAndComboContainerLayout->addStretch (10);
     40  labelAndComboContainer->setLayout(labelAndComboContainerLayout);
     41 
     42  // add errors and warning layout
     43  warningsContainer_ = new Wt::WContainerWidget();
     44  errorsContainer_ = new Wt::WContainerWidget();
     45 
     46  Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
     47  Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
     48 
     49  Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
     50  Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
     51 
     52 
     53  warningsLabel_ = new Wt::WText("",XHTMLText);
     54  errorsLabel_ = new Wt::WText("",XHTMLText);
     55  hLayoutContainerWarnings->addWidget(warningsLabel_);
     56  hLayoutContainerErrors->addWidget(errorsLabel_);
    3457
    35     // add buttons
    36     labelAndComboInsideContainerLayout->addWidget(buttonPanel);
    37 
    38     labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
    39 
    40     labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
    41     labelAndComboContainerLayout->addStretch (10);
    42    
    43     labelAndComboContainer->setLayout(labelAndComboContainerLayout);
    44    
    45            
    46     // add errors and warning layout
    47     warningsContainer_ = new Wt::WContainerWidget();
    48     errorsContainer_ = new Wt::WContainerWidget();
    49 
    50     Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
    51     Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
    52    
    53     Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
    54     Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
    55 
    56    
    57     warningsLabel_ = new Wt::WText("",XHTMLText);
    58     errorsLabel_ = new Wt::WText("",XHTMLText);
    59     hLayoutContainerWarnings->addWidget(warningsLabel_);
    60     hLayoutContainerErrors->addWidget(errorsLabel_);
    61 
    62     warningsAndErrorsContainer->addWidget(warningsLabel_);
    63     warningsAndErrorsContainer->addWidget(errorsLabel_);
    64    
    65    
    66     // set Layouts
    67     warningsContainer_->setLayout(hLayoutContainerWarnings);
    68     errorsContainer_->setLayout(hLayoutContainerErrors);
    69    
    70     vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
    71     vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
    72     vWarningsAndErrorsLayoutContainer->addStretch (100);
    73 
    74     warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
    75 
    76     // add label and Combo containers
    77     mainContainerLayout->addWidget(labelAndComboContainer,0,0);
    78     // add warnings and errors containers
    79     mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
    80 
    81     // manage margins
    82     vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
    83     hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
    84     hLayoutContainerErrors->setContentsMargins(0,0,0,0);
    85 
    86     setLayout(mainContainerLayout);
    87     warningsContainer_->setStyleClass("warningsContainer");
    88     errorsContainer_->setStyleClass("errorsContainer");
    89 
    90     // resize combo
    91     firstElement->setMinimumSize(80,12);
    92     lastElement->setMinimumSize(80,12);
    93     software->setMinimumSize(80,12);
    94        
    95     firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    96     lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    97     software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
    98 
    99     manageWarningsAndErrors();
     58  warningsAndErrorsContainer->addWidget(warningsLabel_);
     59  warningsAndErrorsContainer->addWidget(errorsLabel_);
     60 
     61 
     62  // set Layouts
     63  warningsContainer_->setLayout(hLayoutContainerWarnings);
     64  errorsContainer_->setLayout(hLayoutContainerErrors);
     65 
     66  vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
     67  vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
     68  vWarningsAndErrorsLayoutContainer->addStretch (100);
     69 
     70  warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
     71 
     72  // add label and Combo containers
     73  mainContainerLayout->addWidget(labelAndComboContainer,0,0);
     74  // add warnings and errors containers
     75  mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
     76 
     77  // manage margins
     78  vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
     79  hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
     80  hLayoutContainerErrors->setContentsMargins(0,0,0,0);
     81 
     82  setLayout(mainContainerLayout);
     83  warningsContainer_->setStyleClass("warningsContainer");
     84  errorsContainer_->setStyleClass("errorsContainer");
     85 
     86  // resize combo
     87  firstElement->setMinimumSize(80,12);
     88  lastElement->setMinimumSize(80,12);
     89  software->setMinimumSize(80,12);
     90 
     91  firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     92  lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     93  software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
     94 
     95  manageWarningsAndErrors();
    10096}
    10197
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r427 r431  
    2121#include "GWt_pspaApplication.h"
    2222
     23#define BAVARD 0
     24
    2325GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa)
    2426  : WContainerWidget()
     
    4951void GWt_softwarePanel::addSectionToExecuteW()
    5052{     
     53#if BAVARD > 0
     54  cout << "***********************************" << endl;
     55  cout << " GWt_softwarePanel::addSectionToExecuteW() " << endl<<endl;
     56#endif
     57
    5158  abstractElement* premierElement;
    5259  abstractElement* dernierElement;
     
    5562  int dernierIndex = 0;
    5663 
     64  cout << "sections_.size() = " << sections_.size() << endl;
     65
    5766  // if there is no section
    5867  if(sections_.size() == 0) {
     
    7685  dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1);
    7786  dernierIndex = pspa_->getBeamLine()->getBeamLineSize()-1;
    78   //  cout << "PspaApplication::addSectionToExecute() : " << premierText << " à  " << dernierText << endl;
    79  
    80   //  abstractSoftware* soft = NULL;
    81   //  dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, soft);
    82   dtmanage_->addSectionToExecute(premierElement,premierIndex, dernierElement, dernierIndex, nomDeLogiciel());
     87 
     88  dtmanage_->addSectionToExecute(premierElement,premierIndex,dernierElement,dernierIndex,nomDeLogiciel());
    8389
    8490  std::string premierElementLabel = "";
     
    8793    premierElementLabel = premierElement->getLabel();
    8894  }
    89 
    9095  if (dernierElement) {
    9196    dernierElementLabel = dernierElement->getLabel();
     
    104109  fillComboWithSoftwares(softCombo);
    105110
    106   GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo, lineToCombo, softCombo,createAddDeletePushButtons(sections_.size()),this);
     111  GWt_sectionToExecute* newSection = new GWt_sectionToExecute(lineFromCombo,lineToCombo,softCombo,createAddDeletePushButtons(sections_.size()),this);
    107112
    108113  stringstream st;
     
    118123}
    119124
     125void GWt_softwarePanel::updateSections()
     126{
     127#if BAVARD > 0
     128  cout << "***********************************" << endl;
     129  cout << " GWt_softwarePanel::updateSections() " << endl<<endl;
     130#endif
     131
     132  // update all sections in order to manage new/deleted items
     133  for (int a = 0; a < sections_.size(); a++) {
     134    fillComboWithElements(sections_[a]->getFirstElement());
     135    fillComboWithElements(sections_[a]->getLastElement());
     136    sections_[a]->getFirstElement()->setEnabled (true);
     137    sections_[a]->getLastElement()->setEnabled (true);
     138  }
     139 
     140  if (sections_.size() == 0) {
     141    return;
     142  }
     143 
     144  // the first element will always be the first element of the beamLine
     145  sections_[0]->getFirstElement()->setCurrentIndex(0);
     146  sections_[0]->getFirstElement()->setEnabled (false);
     147
     148  // the last element will always be the last element of the beamLine
     149  sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count());
     150  sections_[sections_.size()-1]->getLastElement()->setEnabled(false);
     151
     152  // set default values
     153  updateSectionSelection();
     154}
     155
    120156bool GWt_softwarePanel::updateSectionSelection()
    121157{
     158#if BAVARD > 0
     159  cout << "***********************************" << endl;
     160  cout << " GWt_softwarePanel::updateSectionSelection() " << endl<<endl;
     161#endif
     162
    122163  if ( dtmanage_->getJobListSize() == 0 ) return false;
    123164 
     
    134175  // si la fin est mal definie on prend toute la config par defaut
    135176  if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
    136   {
    137     current = dtmanage_->getBeamLineSize();
    138     currentString =  dtmanage_->getLabelFromElementNumero(current);
    139     if (sections_.size() > 0) {
    140       sections_[0]->setLastElementCurrentSelection(currentString);
    141 //...
     177    {
     178      current = dtmanage_->getBeamLineSize();
     179      currentString =  dtmanage_->getLabelFromElementNumero(current);
     180      if (sections_.size() > 0) {
     181        sections_[0]->setLastElementCurrentSelection(currentString);
     182        //...
     183      }
    142184    }
    143   }
    144185  current++;
    145186  currentString = dtmanage_->getLabelFromElementNumero(current);
     
    184225
    185226  if (!areDataCoherent()) {
     227#if BAVARD > 0
     228    cout << " GWt_softwarePanel::addSectionToExecuteW() DISABLE" << endl;
     229#endif
    186230    exec_go_->disable();
    187231  } else {
     232#if BAVARD > 0
     233    cout << " GWt_softwarePanel::addSectionToExecuteW() ENABLE" << endl;
     234#endif
    188235    exec_go_->enable();
    189236  }
     
    192239}
    193240
    194 
    195241bool GWt_softwarePanel::areDataCoherent()
    196242{
     243#if BAVARD > 0
     244  cout << "***********************************" << endl;
     245  cout << " GWt_softwarePanel::areDataCoherent() " << endl<<endl;
     246#endif
     247
    197248  bool caMarche = true;
    198249
     
    204255    pspa_->getBeamLine()->initializeSoftwares();
    205256  }
    206  
     257       
    207258  string diagnosticErrors;
    208259  string diagnosticWarnings;
    209  
    210   for (int a = 0; a< sections_.size(); a++)
     260  for (int a = 0; a < sections_.size(); a++)
    211261    {
    212       string debString = sections_[a]->getFirstElementCurrentText().toUTF8();
    213       string finString = sections_[a]->getLastElementCurrentText().toUTF8();
    214    
    215       // int debut = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(debString)+1; // FIXME : Should NOT be +1
    216       // int fin = pspa_->getBeamLine()->getAbstractElementIndexFromLabel(finString)+1; // FIXME : Should NOT be +1
    217 
     262      string debString= sections_[a]->getFirstElementCurrentText().toUTF8();
     263      string finString= sections_[a]->getLastElementCurrentText().toUTF8();
    218264      int debut = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(debString);
    219265      int fin = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(finString);
    220    
    221       nomDeLogiciel prog = nomDeLogiciel ( sections_[a]->getSoftwareCurrentText().toUTF8());
    222       //      abstractSoftware* softToExec = dtmanage_->createSoftwareConnexion(prog);
    223       sectionToExecute* sectToExec = dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),
    224                                      debut,
    225                                      pspa_->getBeamLine()->getAbstractElement(fin),
    226                                      fin,
    227                                      prog);
     266
     267      string currentSoft= sections_[a]->getSoftwareCurrentText().toUTF8();
     268      nomDeLogiciel prog = nomDeLogiciel(currentSoft);
     269      sectionToExecute* sectToExec = dtmanage_->addSectionToExecute(pspa_->getBeamLine()->getAbstractElement(debut),debut,pspa_->getBeamLine()->getAbstractElement(fin),fin,prog);
    228270
    229271      abstractSoftware* softToExec = sectToExec->getSoftware();
    230272      diagnosticErrors = "";
    231273      diagnosticWarnings = "";
    232 
    233       // check sections
    234       for (int i=debut-1; i<fin; i++) {
    235         if (pspa_->getBeamLine()) {
    236           if (pspa_->getBeamLine()->getAbstractElement(i)) {
    237             //         trivaluedBool tb = pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(prog.getString());
    238 
    239 
    240             trivaluedBool tb = softToExec->doAcceptElement(pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getElementType() );
    241 
    242             if (tb  == TBoolOk ) {
    243               pspa_->getBeamLine()->getAbstractElement(i)->setSoftware(softToExec);
     274      for(int i = debut-1; i < fin; i++) // check sections
     275        {
     276          if (!pspa_->getBeamLine()) continue;
     277          abstractElement* elPtr= pspa_->getBeamLine()->getAbstractElement(i);   
     278          if (!elPtr) continue;
     279
     280          trivaluedBool tb = softToExec->doAcceptElement(elPtr->getNomdElement().getElementType());
     281          if (tb  == TBoolOk ) {
     282            elPtr->setSoftware(softToExec);
     283          } else {
     284            elPtr->setSoftware(NULL);
     285            if (tb == TBoolIgnore) {
     286              if(prog.getString() != "unknownSoftware") diagnosticWarnings += elPtr->getLabel() + " will be ignored by  "+ prog.getString() + "<br /> ";           
    244287            } else {
    245               pspa_->getBeamLine()->getAbstractElement(i)->setSoftware( NULL );
    246 
    247               if ( tb == TBoolIgnore ) {
    248                 diagnosticWarnings += pspa_->getBeamLine()->getAbstractElement(i)->getLabel() + " will be ignored by  "+ prog.getString()+"<br /> ";           
    249               } else {
    250                 // j'insiste pour remettre le nom generique de l'element refuse (glm / 30/03/2013)
    251                 diagnosticErrors += pspa_->getBeamLine()->getAbstractElement(i)->getNomdElement().getExpandedName() + " is not allowed with "+ prog.getString()+"<br /> ";
    252                 caMarche = false;
    253               }
     288              // j'insiste pour remettre le nom generique de l'element refuse (glm / 30/03/2013)
     289              diagnosticErrors += elPtr->getNomdElement().getExpandedName() + " is not allowed with " + prog.getString() + "<br /> ";
     290              caMarche = false;
    254291            }
    255             pspa_->getBeamLine()->update(i);
    256292          }
    257         }
    258       }
     293          pspa_->getBeamLine()->update(i);
     294        } //i
     295     
    259296      // set errors and warnings
    260297      sections_[a]->setErrors(diagnosticErrors);
    261298      sections_[a]->setWarnings(diagnosticWarnings);
    262     }
     299    }//a
    263300   
    264301  return caMarche;
     
    286323}
    287324
    288 
    289 void GWt_softwarePanel::updateSections()
    290 {
    291   // update all sections in order to manage new/deleted items
    292   for (int a = 0; a< sections_.size(); a++) {
    293     fillComboWithElements(sections_[a]->getFirstElement());
    294     fillComboWithElements(sections_[a]->getLastElement());
    295 
    296     sections_[a]->getFirstElement()->setEnabled (true);
    297     sections_[a]->getLastElement()->setEnabled (true);
    298   }
    299   if (sections_.size() == 0) {
    300     return;
    301   }
    302   // the first element will always be the first element of the beamLine
    303   sections_[0]->getFirstElement()->setCurrentIndex(0);
    304   sections_[0]->getFirstElement()->setEnabled (false);
    305 
    306   // the last element will always be the last element of the beamLine
    307   sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count());
    308   sections_[sections_.size()-1]->getLastElement()->setEnabled (false);
    309 
    310   // set default values
    311 
    312   // update
    313   updateSectionSelection();
    314 }
    315 
    316325void GWt_softwarePanel::executer()
    317326{
    318  
     327  cout << "***********************************" << endl;
     328  cout << " GWt_softwarePanel::executer() " << endl<<endl;
     329
    319330  if (!areDataCoherent()) {
    320331    return;
    321332  } 
    322333 
    323   static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();
     334  //static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();
    324335 
    325336  GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false);
     
    329340 
    330341  if (!dtmanage_->executeAll()) {
    331     GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exÈcution !", GWt_dialog::Error, true,true);
     342    GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true);
    332343    warningDialog.exec();
    333344  }
     
    338349}
    339350
    340 
    341 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) {
     351void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox)
     352{
    342353  if (cBox == NULL) return;
    343354
    344355  // get the last item selected
    345   WString selectedString = cBox->currentText ();
     356  WString selectedString = cBox->currentText();
    346357  cBox->clear();
    347358
    348   for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) {
     359  for(int a = 0; a < pspa_->getBeamLine()->getBeamLineSize(); a++) {
    349360    abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a);
    350     if (abs != NULL){
     361    if (abs != NULL) {
    351362      cBox->addItem(abs->getLabel());
    352363    }
    353364  }
    354365 
    355   for (int a=0; a<cBox->count(); a++) {
     366  for(int a = 0; a < cBox->count(); a++) {
    356367    if (cBox->itemText (a) == selectedString) {
    357368      cBox->setCurrentIndex(a);
     
    361372}
    362373
    363 
    364 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) {
     374void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox)
     375{
     376#if BAVARD > 0
     377  cout << "***********************************" << endl;
     378  cout << " GWt_softwarePanel::fillComboWithSoftwares " << endl<<endl;
     379#endif
     380
    365381  if (cBox == NULL) return;
    366382  cBox->clear();
     
    368384  unsigned nb = nomDeLogiciel::getNumberOfSoftwares();
    369385  unsigned k;
    370   for(k = 0; k < nb; k++) {
     386  for(k = 0; k <= nb; k++) { //xx
    371387    cBox->addItem(nomDeLogiciel(k).getString());
    372388  }
     389  cBox->setCurrentIndex(nb); // xx
    373390  cBox->refresh();
    374391}
    375392
    376 
    377 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) {
    378 
     393Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber)
     394{
    379395  WContainerWidget* buttonContainer= new WContainerWidget();
    380396 
     
    399415  buttonContainerLayout->addWidget(exec_add);
    400416  buttonContainerLayout->addWidget(exec_delete);
    401 
    402417  buttonContainer->setLayout(buttonContainerLayout);
    403418
Note: See TracChangeset for help on using the changeset viewer.