Changeset 431 in PSPA
- Timestamp:
- Nov 15, 2013, 3:30:50 PM (11 years ago)
- 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 7 7 8 8 #include "nomdElements.h" 9 //#include "nomDeLogiciel.h"10 //#include "trivaluedBool.h"11 9 #include "abstractSoftware.h" 12 /* #include "softwareGenerator.h" */13 /* #include "softwareParmela.h" */14 /* #include "softwareTest.h" */15 /* #include "softwareTransport.h" */16 10 17 11 #include "UAP/UAPNode.hpp" 18 19 12 using namespace std; 20 13 … … 26 19 int nbParam_; 27 20 string* parametersString_; 28 double phaseStepMax_; 21 22 string defaultSpecificName_; 23 string specificName_; 24 nomdElements elementName_; 29 25 30 26 double defaultLength_; 31 27 double defaultAperture_; 32 string defaultSpecificName_; 33 34 string specificName_; 35 nomdElements elementName_; 28 double phaseStepMax_; 36 29 37 30 double lenghtElem_; // cm 38 31 double aperture_; // cm 39 40 32 double stepmaxcm_; 41 // bool curvedTrajectory_;42 33 43 34 void setDefaultValues(); … … 51 42 52 43 void setParameters(double ll,double aper); 44 45 nomdElements getNomdElement() const; 46 int getNbParams() const; 47 53 48 void setLabel(string lab); 54 49 string getLabel() const; 55 nomdElements getNomdElement() const; 56 50 57 51 double getLenghtOfElement() const; 58 int getNbParams() const;59 52 60 53 virtual void setPhaseStep(double); … … 67 60 virtual void FileInput(ifstream& ifs) = 0; 68 61 virtual string print() = 0; 69 70 62 virtual void InputRep(UAPNode* root) = 0; 71 63 -
Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h
r418 r431 3 3 4 4 #include "globalParameters.h" 5 #include "sectorParameters.h" 5 6 #include "particleBeam.h" 6 7 #include "nomDeLogiciel.h" … … 19 20 20 21 protected : 21 22 22 23 unsigned numeroDeb_, numeroFin_; 23 24 globalParameters* globParamPtr_; 25 sectorParameters* sectParamPtr_; //xx 24 26 dataManager* dataManager_; 25 27 string inputFileName_; 26 28 nomDeLogiciel nameOfSoftware_; 27 29 28 30 /** 29 31 Accepted elements list for this software 30 32 */ 31 33 std::vector <nomdElements::typedElement> acceptedElements_; 32 34 33 35 /** 34 36 Ignore software list for this element 35 37 */ 36 38 std::vector <nomdElements::typedElement> ignoredElements_; 37 39 38 40 abstractSoftware(); 39 41 … … 42 44 bool ComputationLimitsOk() const; 43 45 44 45 46 void registerElement(nomdElements::typedElement nomdel,trivaluedBool b); 46 47 47 48 public : 48 49 49 abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt); 50 abstractSoftware(string,globalParameters*,dataManager*); 51 abstractSoftware(string,sectorParameters*,dataManager*); 50 52 ~abstractSoftware() {;} 51 53 52 54 inline const nomDeLogiciel* getNomDeLogiciel() const { 53 55 return &nameOfSoftware_; 54 }56 } 55 57 56 58 trivaluedBool doAcceptElement(nomdElements::typedElement typdel); 57 59 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; 58 63 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 } 77 74 }; 78 75 #endif -
Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h
r424 r431 14 14 #include "nomDeLogiciel.h" 15 15 16 #include "sectorParameters.h" //xx 17 16 18 class PspaApplication; 17 19 … … 21 23 public: 22 24 25 dataManager() {;} 23 26 dataManager(PspaApplication*); 24 27 virtual ~dataManager(); … … 27 30 inline globalParameters* getGlobalParameters() {return &globParam_;} 28 31 inline particleBeam* getCurrentBeam() {return currentBeam_;} 32 33 // xx 34 inline sectorParameters* getSectorParameters() {return §orParam_;} 29 35 30 36 particleBeam* getDiagnosticBeam(unsigned index); … … 50 56 51 57 void initializeExecution(); 52 // trivaluedBool checkExecute(string& diagnostic); 53 // trivaluedBool checkElementsForExec(nomDeLogiciel logiciel, unsigned indexDeb, unsigned indexFin, string& diagnostic); 58 54 59 bool executeAll(); 55 60 … … 81 86 return &diagnosticBeam_.back(); 82 87 } 83 84 /** return a specific jobList index85 return NULL if the index does not exist86 */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 /* } */101 88 102 89 /** Clear a specific jobList */ 103 90 void clearSectionToExecute(int a); 104 91 … … 106 93 107 94 globalParameters globParam_; 95 sectorParameters sectorParam_; //xx 108 96 particleBeam* currentBeam_; 109 97 PspaApplication* pspa_; … … 113 101 vector<particleBeam> diagnosticBeam_; 114 102 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 k117 118 103 vector<sectionToExecute*> jobList_; 119 104 -
Interface_Web/trunk/pspaWT/sources/controler/include/nomDeLogiciel.h
r418 r431 6 6 using namespace std; 7 7 8 9 10 8 class nomDeLogiciel 11 9 { 12 10 13 public: 14 15 11 public : 12 16 13 enum Logiciel 17 14 { 18 parmela, transport, generator, useraction, test, unknownSoftware15 parmela, transport, generator, useraction, test, madx, unknownSoftware 19 16 }; 20 17 21 18 22 private :19 private : 23 20 24 21 Logiciel program_; 25 22 std::string progString_; 26 // int value_; 27 23 28 24 static Logiciel fromString( std::string s); 29 25 static std::string toString( Logiciel lg); … … 31 27 32 28 public : 33 // constructors 34 29 35 30 nomDeLogiciel(); 36 31 nomDeLogiciel(const string& s); … … 39 34 40 35 inline std::string getString() const {return progString_;} 36 inline nomDeLogiciel::Logiciel getLogiciel() const {return program_;} 41 37 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 */ 47 41 inline std::string getColor() const {return getWtColor(program_);} 48 42 // operators 49 50 43 nomDeLogiciel& operator= (const nomDeLogiciel& nl); 51 44 bool operator== (const nomDeLogiciel& nl); 52 45 bool operator!= (const nomDeLogiciel& nl); 53 54 46 }; 55 56 57 58 59 47 #endif -
Interface_Web/trunk/pspaWT/sources/controler/include/nomdElements.h
r418 r431 13 13 public : 14 14 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}; 16 16 17 17 private : -
Interface_Web/trunk/pspaWT/sources/controler/include/sectionToExecute.h
r419 r431 8 8 class sectionToExecute 9 9 { 10 public : 11 sectionToExecute(abstractElement*, abstractElement*, abstractSoftware*); 10 public : 12 11 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*); 15 16 16 17 ~sectionToExecute() {;} 17 18 18 19 20 19 inline abstractElement* getFirstElement() { 20 return firstElement; 21 } 21 22 22 23 24 23 inline abstractElement* getLastElement() { 24 return lastElement; 25 } 25 26 26 27 28 29 27 /** Deprecated : To be removed ! */ 28 inline int getElementNumberInSection() const { 29 return firstElementNumberInBeamLine; 30 } 30 31 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 } 42 36 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; 47 49 }; 48 49 50 #endif -
Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h
r418 r431 7 7 class softwareGenerator : public abstractSoftware 8 8 { 9 protected : 10 11 bool beamFromGenerator(string beamFileName, string workingDir, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles, vector<bareParticle>& passiveParticles ); 9 12 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; 20 16 21 17 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); 27 21 28 22 virtual ~softwareGenerator() {;} 29 23 30 31 24 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); 37 26 virtual bool buildBeamAfterElements(string workingDir); 38 27 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 } 46 31 }; 47 48 32 #endif -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractElement.cc
r418 r431 5 5 #include "abstractElement.h" 6 6 7 abstractElement::abstractElement() 8 //: nameOfSoftware_(NULL) 9 : abstractSoftware_(NULL) 7 abstractElement::abstractElement() : abstractSoftware_(NULL) 10 8 { 11 9 setDefaultValues(); … … 14 12 } 15 13 16 abstractElement::abstractElement(string lab) 17 //: nameOfSoftware_(NULL) 18 : abstractSoftware_(NULL) 14 abstractElement::abstractElement(string lab) : abstractSoftware_(NULL) 19 15 { 20 16 specificName_ = lab; … … 27 23 { 28 24 if (parametersString_ != NULL) delete [] parametersString_ ; 29 // if ( nameOfSoftware_ != NULL ) delete nameOfSoftware_;30 25 } 31 26 … … 62 57 } 63 58 64 string abstractElement::getLabel() const 65 { 59 string abstractElement::getLabel() const { 66 60 return specificName_; 67 61 } 68 62 69 70 nomdElements abstractElement::getNomdElement() const 71 { 63 nomdElements abstractElement::getNomdElement() const { 72 64 return elementName_; 73 65 } 74 75 76 66 77 67 double abstractElement::getLenghtOfElement() const { … … 83 73 } 84 74 85 86 75 double abstractElement::getInitialKineticEnergy() const { 87 76 return 0.0; 88 77 } 89 90 91 -
Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc
r419 r431 2 2 #include "dataManager.h" 3 3 #include <algorithm> 4 4 5 abstractSoftware::abstractSoftware() 5 6 { 6 7 globParamPtr_ = NULL; 8 sectParamPtr_ = NULL; //xx 7 9 dataManager_ = NULL; 8 10 nameOfSoftware_ = nomDeLogiciel("unknownSoftware"); 9 11 } 10 12 11 abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt) { 13 abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt) 14 { 12 15 inputFileName_ = inputFileName; 13 16 globParamPtr_ = globals; 17 sectParamPtr_ = NULL; //xx 14 18 dataManager_ = dt; 15 19 numeroDeb_ = 0; … … 18 22 } 19 23 20 bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin) { 24 abstractSoftware::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 35 bool abstractSoftware::initComputationLimits(unsigned int numeroDeb,unsigned int numeroFin) 36 { 21 37 numeroDeb_ = numeroDeb; 22 38 numeroFin_ = numeroFin; … … 24 40 } 25 41 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() ); 42 bool 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() ); 29 46 return false; 30 47 } else { … … 33 50 } 34 51 35 36 void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b){52 void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b) 53 { 37 54 if (b == TBoolIgnore) { 38 55 ignoredElements_.push_back(nomdel); … … 42 59 } 43 60 44 trivaluedBool abstractSoftware::doAcceptElement(nomdElements::typedElement typdel) { 45 if (acceptedElements_.size() == 0) { 61 trivaluedBool abstractSoftware::doAcceptElement(nomdElements::typedElement typdel) 62 { 63 64 //xx 65 if (acceptedElements_.size() == 0 && nameOfSoftware_ != nomDeLogiciel::unknownSoftware) { 46 66 return TBoolError; 47 67 } 48 if ( std::find(acceptedElements_.begin(), acceptedElements_.end(), typdel) != acceptedElements_.end()) { 68 69 if (std::find(acceptedElements_.begin(),acceptedElements_.end(),typdel) != acceptedElements_.end()) { 49 70 return TBoolOk; 50 71 } 72 51 73 if (ignoredElements_.size() == 0) { 52 74 return TBoolError; 53 75 } 54 if ( std::find(ignoredElements_.begin(), ignoredElements_.end(), typdel) != ignoredElements_.end()) { 76 77 if (std::find(ignoredElements_.begin(),ignoredElements_.end(),typdel) != ignoredElements_.end()) { 55 78 return TBoolIgnore; 56 79 } 80 57 81 return TBoolOk; 58 82 } 59 60 83 61 84 bool abstractSoftware::launchJob(string commandLine, string& resul) … … 66 89 ostringstream sortie; 67 90 if (pp == NULL) { 68 sortie << " launching 91 sortie << " launching failed : " << commandLine << endl; 69 92 ExecuteStatus = false; 70 93 } else { 71 cout << " executing command : " << commandLine << endl;72 94 // on copie la sortie dans le fichier assigne 73 95 char buf[132]; -
Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
r424 r431 1 #include <stdio.h> 2 #include <fstream> 3 1 4 #include "dataManager.h" 2 5 #include "mathematicalConstants.h" 3 6 #include "PhysicalConstants.h" 7 8 #include "GWt_pspaApplication.h" 9 #include "GWt_console.h" 10 4 11 #include "softwareParmela.h" 5 12 #include "softwareTransport.h" 6 #include "GWt_pspaApplication.h"7 #include "GWt_console.h"8 13 #include "softwareGenerator.h" 9 14 #include "softwareTest.h" 15 #include "softwareMadx.h" //xx 16 #include "softwareUnknown.h" //xx 10 17 11 18 #include <boost/filesystem.hpp> 12 #include <stdio.h>13 #include <fstream>14 19 15 20 #include "UAP/UAPUtilities.hpp" 16 21 #include "AML/AMLReader.hpp" 22 23 #define BAVARD 0 17 24 18 25 dataManager::dataManager(PspaApplication* pspa) : … … 23 30 dataManager::~dataManager() 24 31 { 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 39 void 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(); 36 44 } 37 45 38 46 string dataManager::getLabelFromElementNumero(int numero) 39 47 { 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 } 45 52 46 53 int dataManager::getNumeroFromElementLabel(string label) 47 54 { 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 } 63 67 64 68 abstractElement* dataManager::getElementPointerFromNumero(int k) … … 67 71 } 68 72 69 sectionToExecute* dataManager::addSectionToExecute(abstractElement* debut,int debutIndex, abstractElement* fin, int finIndex, nomDeLogiciel logiciel) 70 { 73 sectionToExecute* 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 71 80 abstractSoftware* prog; 72 81 string inputFileName; … … 82 91 } else if (logiciel == nomDeLogiciel::test) { 83 92 prog = new softwareTest(inputFileName, &globParam_, this); 93 } else if (logiciel == nomDeLogiciel::madx) { 94 inputFileName = "madx.input"; 95 prog = new softwareMadx(inputFileName,§orParam_,this); 84 96 } 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)); 91 101 return jobList_.back(); 92 102 } … … 94 104 void dataManager::clearSectionToExecute() 95 105 { 96 97 106 unsigned k; 107 for(k = 0; k < jobList_.size(); k++) 98 108 { 99 100 } 101 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 114 void dataManager::clearSectionToExecute(int a) 115 { 116 cout << " dataManager::clearSectionToExecute : effacement de la section d'index = " << a << endl; 107 117 if (a < 0) return; 108 118 if (a >= (int)jobList_.size()) return; 109 119 110 120 // lors de la creation de la section on a fait un 'new' d'un 111 121 // softwareXXXX : on fait ici le 'delete' 112 122 113 123 const abstractSoftware* soft = jobList_.at(a)->getSoftware(); 114 124 if ( soft != NULL ) delete soft; 115 125 jobList_.erase (jobList_.begin()+a); 116 126 } 117 118 127 119 128 void dataManager::initializeExecution() … … 141 150 void dataManager::removeFile(string nameOfFile) 142 151 { 143 144 145 146 147 148 152 ifstream fileExists; 153 fileExists.open(nameOfFile.c_str(), ios::in); 154 if (fileExists) { 155 fileExists.close(); 156 remove(nameOfFile.c_str()); 157 } 149 158 } 150 159 151 160 bool dataManager::executeAll() 152 161 { 162 cout << "***********************************" << endl; 163 cout << " dataManager::executeAll() " << endl << endl; 164 153 165 bool success = true; 154 166 abstractSoftware* softw = NULL; 155 167 string workingDir = pspa_->getWorkingDir(); 156 168 157 169 // on verifie la consecution des sections 158 170 int lastel = 0; … … 165 177 } 166 178 } 167 179 168 180 unsigned debut; 169 181 unsigned fin; 170 182 for(unsigned k = 0; k < jobList_.size(); k++) { 183 171 184 cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl; 172 185 173 186 debut = jobList_[k]->getElementNumberInSection(); 174 187 fin = jobList_[k]->getLastElementNumberInSection(); 175 188 softw = jobList_[k]->getSoftware(); 176 189 190 //cout << "k= " << k << ", de " << jobList_[k]->getFirstElement()->getLabel() << " à " << jobList_[k]->getLastElement()->getLabel() << " avec " << softw->getName() << endl; 191 177 192 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); 181 203 } 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 } 210 225 } //k 211 226 … … 216 231 void dataManager::saveConfiguration(string folder, string nameOfFile) 217 232 { 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++) 236 252 { 237 253 elPtr = pspa_->getBeamLine()->getAbstractElement(k); 238 254 outfile << elPtr->FileOutputFlow(); 239 255 } 240 256 outfile.close(); 241 257 } 242 258 … … 247 263 uap_root = new UAPNode("UAP_root"); 248 264 UAPNode* rep = uap_root->addChild("AML_representation"); 249 265 250 266 // root node in the hierarchy 251 267 UAPNode* lab = rep->addChild("laboratory"); 252 268 lab->addAttribute("name","PSPA lab"); 253 269 254 270 // general global parameters 255 271 globParam_.InputRep(lab); 256 272 257 273 // accelerator or section of accelerator 258 274 //UAPNode* acc = lab->addChild("machine"); 259 275 //acc->addAttribute("name",fileName); 276 277 sectorParam_.InputRep(lab); 260 278 261 279 // sequence of elements … … 275 293 } 276 294 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 } 295 bool 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); 298 314 } 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; 327 355 } 328 356 … … 386 414 abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) 387 415 { 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 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; 403 431 return new softwareTest(inputFileName, &globParam_, this); 404 405 406 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 29 29 { 30 30 int compteur = -1; 31 parametersString_[++compteur] 32 parametersString_[++compteur] 33 parametersString_[++compteur] 34 parametersString_[++compteur] 31 parametersString_[++compteur]= mixedTools::intToString(nbParam_); 32 parametersString_[++compteur]= specificName_; 33 parametersString_[++compteur]= mixedTools::doubleToString(lenghtElem_); 34 parametersString_[++compteur]= mixedTools::doubleToString(aperture_); 35 35 if ( compteur != nbParam_ ) { 36 36 cerr << " elementDrift::getParametersString() : ERROR nr pf parameters dosnt match " << endl; -
Interface_Web/trunk/pspaWT/sources/controler/src/nomDeLogiciel.cc
r418 r431 1 1 #include "nomDeLogiciel.h" 2 3 2 4 3 nomDeLogiciel::Logiciel nomDeLogiciel::fromString( std::string s) … … 9 8 else if ( s == "useraction" ) return useraction; 10 9 else if ( s == "test" ) return test; 10 else if ( s == "madx" ) return madx; 11 11 return unknownSoftware; 12 12 } 13 13 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 } 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 madx : { return "madx"; } 24 case unknownSoftware : { return "unknownSoftware"; } 25 } 26 return "unknownSoftware"; 27 } 27 28 28 29 30 31 32 33 34 35 36 37 38 39 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 */ 32 std::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 } 45 46 46 47 nomDeLogiciel::nomDeLogiciel() 47 { 48 program_ = unknownSoftware; 49 progString_ = toString(program_); 50 // value_ = toValue(program_); 51 } 48 { 49 program_ = unknownSoftware; 50 progString_ = toString(program_); 51 } 52 52 53 nomDeLogiciel::nomDeLogiciel(const string& s) 54 { 55 program_ = fromString(s); 56 progString_ = toString(program_); 57 // value_ = toValue(program_); 58 } 53 nomDeLogiciel::nomDeLogiciel(const string& s) 54 { 55 program_ = fromString(s); 56 progString_ = toString(program_); 57 } 59 58 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 59 nomDeLogiciel::nomDeLogiciel(int val) 60 { 61 program_ = (Logiciel)val; 62 progString_ = toString(program_); 63 } 69 64 70 65 int nomDeLogiciel::getNumberOfSoftwares() 71 66 { 72 // return toValue(unknownSoftware);73 67 return unknownSoftware; 74 68 } 75 69 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 71 nomDeLogiciel& nomDeLogiciel::operator= (const nomDeLogiciel& nl) 72 { 73 program_ = nl.program_; 74 progString_ = nl.progString_; 75 return *this; 76 } 85 77 86 87 88 89 78 bool nomDeLogiciel::operator== (const nomDeLogiciel& nl) 79 { 80 return ( program_ == nl.program_); 81 } 90 82 91 92 93 94 83 bool nomDeLogiciel::operator!= (const nomDeLogiciel& nl) 84 { 85 return ( program_ != nl.program_); 86 } -
Interface_Web/trunk/pspaWT/sources/controler/src/nomdElements.cc
r418 r431 14 14 else if( strstr(s.c_str(),"fit") ) return fit; 15 15 else if( strstr(s.c_str(),"snapshot") ) return snapshot; 16 else if( strstr(s.c_str(),"mpole") ) return mpole; 16 17 return inconnu; 17 18 } … … 27 28 else if( s == "fit" ) return fit; 28 29 else if( s == "snapshot" ) return snapshot; 30 else if( s == "mpole" ) return mpole; 29 31 return inconnu; 30 32 } … … 41 43 case fit : return "FIT"; break; 42 44 case snapshot : return "SNAPSHOT"; break; 45 case mpole : return "MPOLE"; break; 43 46 default : return "UNKNOWN"; 44 47 } … … 56 59 case fit : return "fit"; 57 60 case snapshot : return "snapshot"; 61 case mpole : return "mpole"; 58 62 default : return string(""); 59 63 } … … 71 75 case fit : return 4; 72 76 case snapshot : return 2; 77 case mpole : return 3; 73 78 default : return 0; 74 79 } -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h
r365 r431 3 3 4 4 #include "GWt_draggableImage.h" 5 #include "GWt_console.h" 6 5 7 #include "abstractElement.h" 6 #include "GWt_console.h"7 8 #include "elementDrift.h" 8 9 #include "elementRfgun.h" … … 13 14 #include "elementFit.h" 14 15 #include "elementSnapshot.h" 16 #include "elementMultipole.h" 15 17 16 18 #include <Wt/WDialog> … … 33 35 class GWt_abstractElement : public WContainerWidget 34 36 { 35 37 protected : 36 38 37 39 abstractElement* abstractElement_; 38 40 39 40 41 42 43 41 WDialog* dialog_; 42 GWt_draggableImage* dropped_; 43 WContainerWidget* wc_; 44 WText* wc_item_; 45 WLineEdit* labelEdit_; 44 46 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(); 55 63 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 80 80 WImage* image_; 81 81 GWt_elementLigneFaisceau* elementLigneFaiseauContainer_; … … 86 86 87 87 inline void registerParam(string name, variant<int, string, bool, float, NullType> value, string desc) { 88 89 88 parameterMapValue[name] = value; 89 parameterMapDescription[name] = desc; 90 90 } 91 91 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); 94 94 }; 95 95 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElementFactory.h
r343 r431 18 18 #include "GWt_fit.h" 19 19 #include "GWt_snapshot.h" 20 #include "GWt_mpole.h" 20 21 21 22 using namespace Wt; … … 62 63 inline void setSnapshotEnable(bool a) { isSnapshotElementEnable = a;}; 63 64 65 /* Enable the mpole element creation 66 */ 67 inline void setMPoleEnable(bool a) { isMPoleElementEnable = a;}; 68 64 69 GWt_drift* createDriftElement(); 65 70 GWt_rfgun* createRFGunElement(); … … 70 75 GWt_fit* createFitElement(); 71 76 GWt_snapshot* createSnapshotElement(); 77 GWt_mpole* createMPoleElement(); 72 78 vector <GWt_abstractElement*> getAllElements(); 73 79 … … 82 88 bool isFitElementEnable; 83 89 bool isSnapshotElementEnable; 90 bool isMPoleElementEnable; 84 91 }; 85 92 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_globalParameters.h
r428 r431 39 39 void updateGlobals(); 40 40 void renew(); 41 void setText(W ContainerWidget*);41 void setText(WText*); 42 42 }; 43 43 #endif -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r426 r431 3 3 4 4 #include <cstdlib> 5 #include <list> 5 #include <string.h> 6 #include <vector> 6 7 7 8 #include <Wt/WApplication> … … 9 10 #include <Wt/WContainerWidget> 10 11 #include <Wt/WText> 12 #include <Wt/WLineEdit> 11 13 #include <Wt/WPanel> 12 14 #include <Wt/WComboBox> … … 24 26 #include "GWt_ligneFaisceau.h" 25 27 #include "GWt_globalParameters.h" 28 #include "GWt_sectorParameters.h" 26 29 27 30 #include "dataManager.h" … … 43 46 GWt_LigneFaisceau* beamLine_; 44 47 45 // WWidget* globalParam_;46 GWt_ globalParameters* globalParam_; // xx48 GWt_globalParameters* globalParam_; 49 GWt_sectorParameters* sectorParam_; 47 50 48 51 GWt_dialog* graphicsDialog_; … … 73 76 WContainerWidget* createDrawingWidget(); 74 77 75 //WWidget* createGlobalParamWidget(); 76 WWidget* createDashBoard(); // xx 77 void messageBox1(); // xx 78 void messageBox2(); // xx 78 WWidget* createDashBoard(); 79 void messageBox1(); 80 void messageBox2(); 79 81 80 82 // extensions (.001, .002,...) pour les fichiers "snapshot" … … 119 121 } 120 122 121 122 /* inline WWidget* getGlobalParam() { */123 /* return globalParam_; */124 /* } */125 126 123 inline GWt_softwarePanel* getExecuteWidget() { 127 124 return executeWidget_; -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_softwarePanel.h
r407 r431 23 23 class GWt_softwarePanel : public WContainerWidget 24 24 { 25 public : 26 GWt_softwarePanel(dataManager*, PspaApplication*); 27 virtual ~GWt_softwarePanel(); 25 public : 26 27 GWt_softwarePanel(dataManager*, PspaApplication*); 28 virtual ~GWt_softwarePanel(); 28 29 29 30 30 void addSectionToExecuteW(); 31 void updateSections(); 31 32 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); 43 43 44 45 46 47 44 dataManager* dtmanage_; 45 WPushButton *exec_go_; 46 WContainerWidget* contenuSections_; 47 PspaApplication* pspa_; 48 48 49 49 std::vector <GWt_sectionToExecute*> sections_; 50 50 }; 51 52 51 #endif /* defined(__PSPA__GWt_softwarePanel__) */ -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc
r418 r431 14 14 #include "GWt_beam.h" 15 15 #include "GWt_fit.h" 16 #include "GWt_snapshot.h" 16 //#include "GWt_snapshot.h" 17 17 18 #include "GWt_draggableImage.h" 18 19 #include "GWt_ligneFaisceau.h" … … 29 30 30 31 GWt_abstractElement::GWt_abstractElement(abstractElement* elem) 31 : WContainerWidget()32 : WContainerWidget() 32 33 { 33 34 abstractElement_ = elem; 34 35 } 35 36 36 37 37 void GWt_abstractElement::initialize() 38 38 { 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(); 44 42 } 45 46 43 47 44 string* GWt_abstractElement::beginDialog() 48 45 { 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()); 57 52 } 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 } 59 62 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; 77 68 } 78 69 79 70 void GWt_abstractElement::updateLabelAndToolTipWidget() 80 71 { 81 72 if (abstractElement_ != NULL) { 82 73 elementLigneFaiseauContainer_->setElementLabel(abstractElement_->getLabel()); 83 74 setToolTip(print()); 84 75 } 85 76 } 86 77 … … 91 82 } 92 83 93 94 84 void GWt_abstractElement::deleteElement() 95 85 { 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 } 97 101 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); 102 void 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 114 void 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 128 abstractElement* GWt_abstractElement::getAbstractElement() { 129 return abstractElement_; 110 130 } 111 131 112 132 WContainerWidget* 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_; 132 134 } 133 135 134 136 WImage* GWt_abstractElement::getImage() { 135 137 return image_; 136 138 } 137 139 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(); 140 variant<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; 149 160 } 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(); 150 175 } 151 176 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(); 177 string 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 } 191 186 } 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 17 17 isBeamElementEnable(false), 18 18 isFitElementEnable(false), 19 isSnapshotElementEnable(false) 19 isSnapshotElementEnable(false), 20 isMPoleElementEnable(false) 20 21 {} 21 22 … … 30 31 isFitElementEnable = false; 31 32 isSnapshotElementEnable = false; 33 isMPoleElementEnable = false; 32 34 } 33 35 … … 96 98 } 97 99 100 GWt_mpole* GWt_abstractElementFactory::createMPoleElement() 101 { 102 if (isMPoleElementEnable) { 103 return new GWt_mpole(); 104 } 105 return NULL; 106 } 107 98 108 vector <GWt_abstractElement*> GWt_abstractElementFactory::getAllElements() 99 109 { … … 123 133 elems.push_back(new GWt_snapshot()); 124 134 } 135 if (isMPoleElementEnable) { 136 elems.push_back(new GWt_mpole()); 137 } 125 138 126 139 return elems; -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r418 r431 13 13 #include "GWt_fit.h" 14 14 #include "GWt_snapshot.h" 15 #include "GWt_mpole.h" 15 16 16 17 … … 55 56 void GWt_elementLigneFaisceau::initialize_ligneFaisceau(nomdElements::typedElement eType) 56 57 { 57 cout <<"new GWt_elementLigneFaisceau : "<< this<< endl;58 cout << " new GWt_elementLigneFaisceau : "<< nomdElements::getLabelFromType(eType) << endl; 58 59 59 60 // set layout … … 113 114 case nomdElements::fit : 114 115 GWt_abstractElement_ = new GWt_fit(this); 116 break; 117 case nomdElements::mpole : 118 GWt_abstractElement_ = new GWt_mpole(this); 115 119 break; 116 120 case nomdElements::snapshot : -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_globalParameters.cc
r428 r431 15 15 } 16 16 17 void GWt_globalParameters::setText(W ContainerWidget* wt)17 void GWt_globalParameters::setText(WText *st) 18 18 { 19 status_ = new WText("Go ahead...",wt);19 status_ = st; 20 20 } 21 21 … … 105 105 void GWt_globalParameters::setStatus() 106 106 { 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>"); 111 111 status_->setText(out); 112 112 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r418 r431 59 59 60 60 GWt_abstractElement* GWtAbstractElem = NULL; 61 cout << " Entree addElement element" << nomdElements::getLabelFromType(eType) << endl;61 cout << " addElement::element : " << nomdElements::getLabelFromType(eType) << endl; 62 62 63 63 // 3 cases : … … 288 288 289 289 290 void GWt_LigneFaisceau::initializeSoftwares() {291 290 void GWt_LigneFaisceau::initializeSoftwares() 291 { 292 292 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 1 1 #include <stdio.h> 2 #include <string.h>3 #include <vector>4 2 #include <ctime> 5 3 6 4 #include "GWt_pspaApplication.h" 7 #include "GWt_ligneFaisceau.h"8 #include "GWt_softwarePanel.h"9 #include "GWt_globalParameters.h"10 5 #include "GWt_draggableImage.h" 6 #include "GWt_serverFileSelector.h" 11 7 #include "particleBeam.h" 12 8 #include "bareParticle.h" … … 15 11 #include "nomdElements.h" 16 12 #include "environmentVariables.h" 17 #include "GWt_console.h"18 #include "GWt_serverFileSelector.h"19 13 #include "trivaluedBool.h" 20 14 … … 26 20 #include <Wt/WStackedWidget> 27 21 #include <Wt/WBreak> 28 #include <Wt/WDialog>29 22 #include <Wt/WStandardItemModel> 30 23 #include <Wt/WFileUpload> 31 24 #include <Wt/WPainter> 32 #include <Wt/WPdfImage>33 25 #include <Wt/WScrollArea> 34 #include <Wt/WLineEdit>35 26 #include <Wt/WRadioButton> 36 37 #include <Wt/WPanel>38 27 #include <Wt/WMessageBox> 39 28 … … 73 62 abstractElementFactory_->setFitEnable(true); 74 63 abstractElementFactory_->setSnapshotEnable(true); 75 76 // include the styleSheet 64 abstractElementFactory_->setMPoleEnable(true); 65 66 // include the styleSheetcd 77 67 WContainerWidget *widroot = root(); 78 68 useStyleSheet("htdocs/pspa.css"); … … 144 134 145 135 globalParam_ = new GWt_globalParameters(dtmanage_); 136 sectorParam_ = new GWt_sectorParameters(dtmanage_); 146 137 WWidget* dboard = createDashBoard(); 147 138 dboard->setMinimumSize(300,100); … … 171 162 } 172 163 173 // WWidget* PspaApplication::createGlobalParamWidget()174 // {175 // WContainerWidget* globalParam = new GWt_globalParameters(this);176 // globalParam->setMinimumSize(300,100);177 // return globalParam;178 // }179 180 164 WWidget* PspaApplication::createDashBoard() 181 165 { 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 193 170 WContainerWidget *buttons = new WContainerWidget(); 194 171 buttons->setStyleClass("buttons"); 195 196 172 WPushButton *button; 197 button = new WPushButton("globalParameters", 173 button = new WPushButton("globalParameters",buttons); 198 174 button->clicked().connect(this, &PspaApplication::messageBox1); 199 200 button = new WPushButton("fodoCells", buttons); 175 button = new WPushButton("sectorParameters", buttons); 201 176 button->clicked().connect(this, &PspaApplication::messageBox2); 202 177 … … 205 180 styleSheet().addRule("body", "margin: 0px;"); 206 181 182 WContainerWidget *cnt = new WContainerWidget(); 207 183 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"); 209 189 panel->setCentralWidget(cnt); 190 191 globalParam_->setText(st); 192 sectorParam_->setText(st); 210 193 return result; 211 194 } … … 219 202 void PspaApplication::messageBox2() 220 203 { 204 sectorParam_->execDialog(); 221 205 return; 222 206 } … … 382 366 void PspaApplication::sauver() 383 367 { 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"); 387 372 dialogSave_ = new WDialog("save"); 388 373 new WText("name of case : ",dialogSave_->contents()); … … 405 390 dialogSave_ = NULL; 406 391 407 globalParam_->updateGlobals();392 //globalParam_->updateGlobals(); 408 393 409 394 // dtmanage_->saveConfiguration(nameOfCase_); … … 416 401 void PspaApplication::restaurer() 417 402 { 403 cout << "***********************************" << endl; 404 cout << " on restaure " << endl<<endl; 405 418 406 GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_); 419 407 string fileName = fs->exec(); … … 423 411 } 424 412 425 removePathFromConfigName(nameOfCase_ 413 removePathFromConfigName(nameOfCase_); 426 414 cout << " nom sans path " << nameOfCase_ << endl; 427 415 removeExtensionFromConfigName(nameOfCase_); 428 416 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; 432 419 dialogSave_ = NULL; 433 420 … … 442 429 } 443 430 444 globalParam_->renew(); 431 globalParam_->renew(); 432 sectorParam_->renew(); 445 433 console_->addConsoleMessage(string("restauration terminee \n")); 446 434 } … … 448 436 void PspaApplication::openFileSelector() 449 437 { 450 451 438 WContainerWidget *result = new WContainerWidget(); 452 WVBoxLayout* myLayout = new WVBoxLayout(); 453 439 WVBoxLayout* myLayout = new WVBoxLayout(); 454 440 uploadFileSelectorWidget_ = new WFileUpload(); 455 456 441 uploadFileSelectorWidget_->setFileTextSize(40); 457 458 442 myLayout->addWidget(new WText("Select the configuration file for pspa : ")); 459 443 myLayout->addWidget(uploadFileSelectorWidget_); 460 461 444 result->setLayout (myLayout); 462 445 … … 470 453 uploadFileSelectorWidget_->fileTooLarge().connect(this, &PspaApplication::fileTooLarge); 471 454 472 473 455 GWt_dialog* fileSelectorDialog = new GWt_dialog("Load a file",result,false); 474 475 456 fileSelectorDialog->exec(); 476 457 } … … 485 466 cout << " fichier client sans extension : " << nomDuFichier << endl; 486 467 487 if ( test ) 488 { 489 nameOfCase_ = nomDuFichier; 490 console_->addConsoleMessage(string("restauration...")); 468 if ( test ) { 469 nameOfCase_ = nomDuFichier; 470 console_->addConsoleMessage(string("restauration...")); 491 471 492 493 494 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 } 496 476 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 } 503 482 } 504 483 … … 513 492 message += " bytes\n"; 514 493 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); 517 495 messageBox->show(); 518 496 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc
r407 r431 16 16 softwarePanel(sPanel) 17 17 { 18 19 18 Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout(); 19 mainContainerLayout->setContentsMargins(0,0,0,0); 20 20 21 22 23 21 Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget(); 22 Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout(); 23 labelAndComboContainerLayout->setContentsMargins(0,0,0,0); 24 24 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 : ")); 30 labelAndComboInsideContainerLayout->addWidget(first); 31 labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to : ")); 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 : ")); 30 labelAndComboInsideContainerLayout->addWidget(first); 31 labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to : ")); 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_); 34 57 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(); 100 96 } 101 97 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc
r427 r431 21 21 #include "GWt_pspaApplication.h" 22 22 23 #define BAVARD 0 24 23 25 GWt_softwarePanel::GWt_softwarePanel(dataManager* dataManager,PspaApplication* pspa) 24 26 : WContainerWidget() … … 49 51 void GWt_softwarePanel::addSectionToExecuteW() 50 52 { 53 #if BAVARD > 0 54 cout << "***********************************" << endl; 55 cout << " GWt_softwarePanel::addSectionToExecuteW() " << endl<<endl; 56 #endif 57 51 58 abstractElement* premierElement; 52 59 abstractElement* dernierElement; … … 55 62 int dernierIndex = 0; 56 63 64 cout << "sections_.size() = " << sections_.size() << endl; 65 57 66 // if there is no section 58 67 if(sections_.size() == 0) { … … 76 85 dernierElement = pspa_->getBeamLine()->getAbstractElement(pspa_->getBeamLine()->getBeamLineSize()-1); 77 86 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()); 83 89 84 90 std::string premierElementLabel = ""; … … 87 93 premierElementLabel = premierElement->getLabel(); 88 94 } 89 90 95 if (dernierElement) { 91 96 dernierElementLabel = dernierElement->getLabel(); … … 104 109 fillComboWithSoftwares(softCombo); 105 110 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); 107 112 108 113 stringstream st; … … 118 123 } 119 124 125 void 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 120 156 bool GWt_softwarePanel::updateSectionSelection() 121 157 { 158 #if BAVARD > 0 159 cout << "***********************************" << endl; 160 cout << " GWt_softwarePanel::updateSectionSelection() " << endl<<endl; 161 #endif 162 122 163 if ( dtmanage_->getJobListSize() == 0 ) return false; 123 164 … … 134 175 // si la fin est mal definie on prend toute la config par defaut 135 176 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 } 142 184 } 143 }144 185 current++; 145 186 currentString = dtmanage_->getLabelFromElementNumero(current); … … 184 225 185 226 if (!areDataCoherent()) { 227 #if BAVARD > 0 228 cout << " GWt_softwarePanel::addSectionToExecuteW() DISABLE" << endl; 229 #endif 186 230 exec_go_->disable(); 187 231 } else { 232 #if BAVARD > 0 233 cout << " GWt_softwarePanel::addSectionToExecuteW() ENABLE" << endl; 234 #endif 188 235 exec_go_->enable(); 189 236 } … … 192 239 } 193 240 194 195 241 bool GWt_softwarePanel::areDataCoherent() 196 242 { 243 #if BAVARD > 0 244 cout << "***********************************" << endl; 245 cout << " GWt_softwarePanel::areDataCoherent() " << endl<<endl; 246 #endif 247 197 248 bool caMarche = true; 198 249 … … 204 255 pspa_->getBeamLine()->initializeSoftwares(); 205 256 } 206 257 207 258 string diagnosticErrors; 208 259 string diagnosticWarnings; 209 210 for (int a = 0; a< sections_.size(); a++) 260 for (int a = 0; a < sections_.size(); a++) 211 261 { 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(); 218 264 int debut = pspa_->getBeamLine()->getAbstractElementNumeroFromLabel(debString); 219 265 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); 228 270 229 271 abstractSoftware* softToExec = sectToExec->getSoftware(); 230 272 diagnosticErrors = ""; 231 273 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 /> "; 244 287 } 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; 254 291 } 255 pspa_->getBeamLine()->update(i);256 292 } 257 } 258 } 293 pspa_->getBeamLine()->update(i); 294 } //i 295 259 296 // set errors and warnings 260 297 sections_[a]->setErrors(diagnosticErrors); 261 298 sections_[a]->setWarnings(diagnosticWarnings); 262 } 299 }//a 263 300 264 301 return caMarche; … … 286 323 } 287 324 288 289 void GWt_softwarePanel::updateSections()290 {291 // update all sections in order to manage new/deleted items292 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 beamLine303 sections_[0]->getFirstElement()->setCurrentIndex(0);304 sections_[0]->getFirstElement()->setEnabled (false);305 306 // the last element will always be the last element of the beamLine307 sections_[sections_.size()-1]->getLastElement()->setCurrentIndex(sections_[sections_.size()-1]->getLastElement()->count());308 sections_[sections_.size()-1]->getLastElement()->setEnabled (false);309 310 // set default values311 312 // update313 updateSectionSelection();314 }315 316 325 void GWt_softwarePanel::executer() 317 326 { 318 327 cout << "***********************************" << endl; 328 cout << " GWt_softwarePanel::executer() " << endl<<endl; 329 319 330 if (!areDataCoherent()) { 320 331 return; 321 332 } 322 333 323 static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals();334 //static_cast<GWt_globalParameters*>(pspa_->getGlobalParam())->updateGlobals(); 324 335 325 336 GWt_dialog calculDialog("Calcul en cours", "Veuillez patienter...", GWt_dialog::Wait, true,false); … … 329 340 330 341 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); 332 343 warningDialog.exec(); 333 344 } … … 338 349 } 339 350 340 341 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox){351 void GWt_softwarePanel::fillComboWithElements(Wt::WComboBox* cBox) 352 { 342 353 if (cBox == NULL) return; 343 354 344 355 // get the last item selected 345 WString selectedString = cBox->currentText 356 WString selectedString = cBox->currentText(); 346 357 cBox->clear(); 347 358 348 for (int a=0; a< pspa_->getBeamLine()->getBeamLineSize(); a++) {359 for(int a = 0; a < pspa_->getBeamLine()->getBeamLineSize(); a++) { 349 360 abstractElement* abs = pspa_->getBeamLine()->getAbstractElement(a); 350 if (abs != NULL) {361 if (abs != NULL) { 351 362 cBox->addItem(abs->getLabel()); 352 363 } 353 364 } 354 365 355 for (int a=0; a<cBox->count(); a++) {366 for(int a = 0; a < cBox->count(); a++) { 356 367 if (cBox->itemText (a) == selectedString) { 357 368 cBox->setCurrentIndex(a); … … 361 372 } 362 373 363 364 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) { 374 void GWt_softwarePanel::fillComboWithSoftwares(Wt::WComboBox* cBox) 375 { 376 #if BAVARD > 0 377 cout << "***********************************" << endl; 378 cout << " GWt_softwarePanel::fillComboWithSoftwares " << endl<<endl; 379 #endif 380 365 381 if (cBox == NULL) return; 366 382 cBox->clear(); … … 368 384 unsigned nb = nomDeLogiciel::getNumberOfSoftwares(); 369 385 unsigned k; 370 for(k = 0; k < nb; k++) {386 for(k = 0; k <= nb; k++) { //xx 371 387 cBox->addItem(nomDeLogiciel(k).getString()); 372 388 } 389 cBox->setCurrentIndex(nb); // xx 373 390 cBox->refresh(); 374 391 } 375 392 376 377 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) { 378 393 Wt::WContainerWidget* GWt_softwarePanel::createAddDeletePushButtons(int sectionNumber) 394 { 379 395 WContainerWidget* buttonContainer= new WContainerWidget(); 380 396 … … 399 415 buttonContainerLayout->addWidget(exec_add); 400 416 buttonContainerLayout->addWidget(exec_delete); 401 402 417 buttonContainer->setLayout(buttonContainerLayout); 403 418
Note: See TracChangeset
for help on using the changeset viewer.