Changeset 227 in PSPA


Ignore:
Timestamp:
Dec 30, 2012, 12:11:42 PM (11 years ago)
Author:
lemeur
Message:

usage de WApplication::appRoot() pour WORKINGAREA

Location:
Interface_Web/trunk/pspaWT
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/include/GWt_pspaApplication.h

    r226 r227  
    3838 dataManager* dtmanage_;
    3939 string nameOfCase_;
    40 
     40 string workingDir_;
    4141 WDialog* dialogSave_;
    4242 WDialog* dialogOpen_;
  • Interface_Web/trunk/pspaWT/include/dataManager.h

    r226 r227  
    2121  vector<sectionToExecute*> jobList_;
    2222
    23   bool createInputFileParmela( unsigned int numeroDeb, unsigned int numerpFin);
    24   bool createInputFileTransport( unsigned int numeroDeb, unsigned int numeroFin);
     23  bool createInputFileParmela( unsigned int numeroDeb, unsigned int numerpFin, string workingDir);
     24  bool createInputFileTransport( unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    2525  void removeFile(string nameOfFile);
    2626  void clearSectionToExecute();
     
    4848  abstractElement* addElement(typedElement elemType);
    4949  string getLabelFromElementNumero(int numero);
    50   void initializeExecution();
     50  void initializeExecution(string workingDir);
    5151  string checkExecute();
    52   bool executeTransport( unsigned int indexDeb, unsigned int indexFin, string& resul);
    53   bool executeParmela( unsigned int indexDeb, unsigned int indexFin, string& resul);
    54   bool executeAll(string& resul);
    55   void saveConfiguration(string nameOfFile);
    56   bool restoreElements(string inputFileName);
     52  bool executeTransport( unsigned int indexDeb, unsigned int indexFin, string workingDir,  string& resul);
     53  bool executeParmela( unsigned int indexDeb, unsigned int indexFin, string workingDir, string& resul);
     54  bool executeAll(string workingDir, string& resul);
     55  void saveConfiguration(string workingDir, string nameOfFile);
     56  bool restoreElements(string workingDir, string inputFileName);
    5757  void donneesRmsEnveloppe( string type, unsigned int numeroDeb, unsigned int numeroFin, vector<double>& xcor, vector<double>& ycor);
    5858};
  • Interface_Web/trunk/pspaWT/include/environmentVariables.h

    r121 r227  
    44#include <stdlib.h>
    55#include <stdio.h>
    6 static string WHERE_WE_ARE = string(getenv("PWD"));
    7 static string WORKINGAREA =  WHERE_WE_ARE.append("/workingArea/");
    8 
     6//static string WHERE_WE_ARE = string(getenv("PWD"));
     7//static string WORKINGAREA =  WHERE_WE_ARE.append("/workingArea/");
     8static string WORKINGAREA = "../workingArea/";
    99#endif
    1010
  • Interface_Web/trunk/pspaWT/include/particleBeam.h

    r226 r227  
    6363  virtual ~particleBeam() {;}
    6464
    65   bool setFromParmela(unsigned numeroElement,double referencefrequency);
     65  bool setFromParmela(string workingDir,unsigned numeroElement,double referencefrequency);
    6666  void buildMomentRepresentation();
    6767
    68   bool  setFromTransport(string elementLabel, const nomdElements elem);
     68  bool  setFromTransport(string workingDir, string elementLabel, const nomdElements elem);
    6969
    7070  //  void setFromBeamParameters(double x, double xp, double y, double yp, double dl, double del, double P0);
  • Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc

    r226 r227  
    4242PspaApplication::PspaApplication(const WEnvironment& env) : WApplication(env)
    4343{
     44
     45  workingDir_ = WApplication::appRoot()+ WORKINGAREA;
    4446  nameOfCase_ = "pspa"; // default
    4547
     
    403405{
    404406  bool caMarche = true;
    405   dtmanage_->initializeExecution();
     407  dtmanage_->initializeExecution(workingDir_);
    406408 
    407409  list<GWt_sectionToExecute*>::iterator itr;
     
    450452
    451453  string resultat;
    452   if ( !dtmanage_->executeAll(resultat)) {
     454  if ( !dtmanage_->executeAll(workingDir_, resultat)) {
    453455    GWt_dialog warningDialog("PSPA : Echec", " echec lors de l'exécution !", GWt_dialog::Error, true,true);
    454456    warningDialog.exec();
     
    484486{
    485487  if ( code != Wt::WDialog::Accepted ) { GWt_tools::addConsoleMessage(" pas de sauvegarde"); return;}
    486   else { GWt_tools::addConsoleMessage("sauvegarde sur repertoire : " + WORKINGAREA);}
     488  else { GWt_tools::addConsoleMessage("sauvegarde sur repertoire : " + workingDir_);}
    487489  nameOfCase_ = saveNameEdit_->text().toUTF8();
    488490  cout << " PspaApplication::dialogSaveDone() nameOfCase_= " << nameOfCase_ << endl;
     
    491493  GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_);
    492494  bibi->updateGlobals();
    493   dtmanage_->saveConfiguration(nameOfCase_);
     495  //  dtmanage_->saveConfiguration(nameOfCase_);
     496  dtmanage_->saveConfiguration(workingDir_ ,  nameOfCase_);
    494497}
    495498
     
    514517
    515518  if ( code != Wt::WDialog::Accepted ) { GWt_tools::addConsoleMessage(" pas de restauration"); return;}
    516   else { GWt_tools::addConsoleMessage("restauration depuis le repertoire " + WORKINGAREA);}
     519  else { GWt_tools::addConsoleMessage("restauration depuis le repertoire " + workingDir_ );}
    517520
    518521  nameOfCase_ = openNameEdit_->text().toUTF8();
     
    521524  dialogSave_ = NULL;
    522525
    523   bool test = dtmanage_->restoreElements(WORKINGAREA +  nameOfCase_ +".save");
     526  bool test = dtmanage_->restoreElements(workingDir_,  nameOfCase_);
    524527  if ( !test ) {
    525528        GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
     
    582585      GWt_tools::addConsoleMessage(string("restauration..."));
    583586
    584       if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) {
     587      if ( !dtmanage_->restoreElements(workingDir_, uploadFileSelectorWidget_->spoolFileName()) ) {
    585588        GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true);
    586589        restoreWarning.exec();
     
    748751 chart->paint(p);
    749752 std::string name;
    750  name = WORKINGAREA+"/chart-"+sessionId ()+".png";
     753 name = workingDir_ + "/chart-"+sessionId ()+".png";
    751754 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);
    752755 pngImage.write(f);
     
    830833 chart->paint(p);
    831834 std::string name;
    832  name = WORKINGAREA+"/chart-"+sessionId ()+".png";
     835 name = workingDir_ + "/chart-"+sessionId ()+".png";
    833836 std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary);
    834837 pngImage.write(f);
  • Interface_Web/trunk/pspaWT/src/GWt_tools.cc

    r226 r227  
    55
    66WContainerWidget* GWt_tools::console_ = new WContainerWidget();
     7
    78void GWt_tools::addConsoleMessage(WString msg) {
    89  WText *w = new WText(console_);
  • Interface_Web/trunk/pspaWT/src/dataManager.cc

    r226 r227  
    11#include "dataManager.h"
    2 #include "environmentVariables.h"
     2//#include "environmentVariables.h"
    33#include "transportMoments.h"
    44
     
    9090}
    9191
    92 bool dataManager::executeTransport( unsigned int indexDeb, unsigned int indexFin, string& resul)
     92bool dataManager::executeTransport( unsigned int indexDeb, unsigned int indexFin, string workingDir, string& resul)
    9393{
    9494  ostringstream sortie;
    9595  resul.clear();
    9696  sortie << " EXECUTION DE TRANSPORT DE " << indexDeb << " a " << indexFin << endl;
    97   if ( !createInputFileTransport( indexDeb, indexFin) )
     97  if ( !createInputFileTransport( indexDeb, indexFin, workingDir) )
    9898    {
    9999      sortie << " error creating transport input file "  << endl;
     
    105105  string bufString;
    106106  char buf[132];
    107   string transportJob = WORKINGAREA + "transport";
     107  string transportJob = workingDir + "transport";
    108108  transportJob += string(" <  ");
    109   transportJob += WORKINGAREA + "transport.input";
     109  transportJob += workingDir + "transport.input";
    110110  //  transportJob += string(" >  ");
    111111  //  transportJob += WORKINGAREA + "transport.output";
     
    113113
    114114  ofstream outfile;
    115   string nameOut = WORKINGAREA + "transport.output";
     115  string nameOut = workingDir + "transport.output";
    116116
    117117
     
    148148            string elemLabel = getLabelFromElementNumero (k);
    149149            abstractElement* ptr = elementsGallery_.getElementPointerFromNumero(k);
    150             if (!diagnosticBeam_.back().setFromTransport(elemLabel, ptr->getNomdElement() )  )
     150            if (!diagnosticBeam_.back().setFromTransport(workingDir, elemLabel, ptr->getNomdElement() )  )
    151151              {
    152152                sortie << " reading transport output  failed " << endl;
     
    164164}
    165165
    166 bool  dataManager::executeParmela(unsigned int indexDeb,unsigned int indexFin,string& resul)
     166bool  dataManager::executeParmela(unsigned int indexDeb,unsigned int indexFin,string workingDir,string& resul)
    167167{
    168168  ostringstream sortie;
    169169  bool ExecuteStatus = true;
    170170  resul.clear();
    171   if ( !createInputFileParmela(indexDeb,indexFin) )
     171  if ( !createInputFileParmela(indexDeb,indexFin, workingDir) )
    172172    {
    173173      sortie << " error creating parmela input file "  << endl;
     
    179179
    180180  char buf[132];
    181   string parmelaJob = WORKINGAREA + "parmela";
     181  string parmelaJob = workingDir + "parmela";
    182182  parmelaJob += string("   ");
    183   parmelaJob += WORKINGAREA;
     183  parmelaJob += workingDir;
    184184  cout << " job parmela= " << parmelaJob << endl;
    185185  FILE* pp = popen(parmelaJob.c_str(), "r");
     
    207207          {
    208208            diagnosticBeam_.push_back(particleBeam());
    209             if (! diagnosticBeam_.back().setFromParmela(k, globParam_.getFrequency()) )
     209            if (! diagnosticBeam_.back().setFromParmela(workingDir, k, globParam_.getFrequency()) )
    210210              {
    211211                sortie << " reading parmdesz  failed " << endl;
     
    224224}
    225225
    226 bool dataManager::createInputFileTransport( unsigned int numeroDeb, unsigned int numeroFin)
     226bool dataManager::createInputFileTransport( unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    227227{
    228228  unsigned int k;
     
    246246
    247247  ofstream outfile;
    248   string name = WORKINGAREA + "transport.input";
     248  string name = workingDir + "transport.input";
    249249  outfile.open(name.c_str(), ios::out);
    250250  if (!outfile)
     
    309309}
    310310
    311 bool dataManager::createInputFileParmela( unsigned int numeroDeb, unsigned int numeroFin)
     311bool dataManager::createInputFileParmela( unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    312312{
    313313  unsigned int k;
     
    323323
    324324  ofstream outfile;
    325   string name = WORKINGAREA + "parmin";
     325  string name = workingDir + "parmin";
    326326  outfile.open(name.c_str(), ios::out);
    327327  if (!outfile) {
     
    361361}
    362362
    363 void dataManager::initializeExecution()
    364 {
    365   removeFile("parmdesz");
    366   removeFile("parmin");
    367   removeFile("transport.input");
    368   removeFile("transport.output");
     363void dataManager::initializeExecution(string workingDir)
     364{
     365  removeFile(workingDir + "parmdesz");
     366  removeFile(workingDir + "parmin");
     367  removeFile(workingDir + "transport.input");
     368  removeFile(workingDir + "transport.output");
    369369  diagnosticBeam_.clear();
    370370  currentBeam_ = NULL;
     
    375375{
    376376  ifstream fileExists;
    377   string completeName = WORKINGAREA + nameOfFile;
    378   fileExists.open(completeName.c_str(), ios::in);
     377  fileExists.open(nameOfFile.c_str(), ios::in);
    379378  if (fileExists) {
    380379    fileExists.close();
    381     remove(completeName.c_str());
    382   }
    383 }
    384 
    385 bool dataManager::executeAll(string &resul)
     380    remove(nameOfFile.c_str());
     381  }
     382}
     383
     384bool dataManager::executeAll(string workingDir, string &resul)
    386385{
    387386  bool success = true;
     
    397396
    398397      if(jobList_[k]->software == nomDeLogiciel::parmela) {
    399         success = executeParmela( debut, fin, resultatPartiel);
     398        success = executeParmela( debut, fin, workingDir, resultatPartiel);
    400399      } else if (jobList_[k]->software == nomDeLogiciel::transport) {
    401         success = executeTransport( debut, fin, resultatPartiel);
     400        success = executeTransport( debut, fin, workingDir, resultatPartiel);
    402401      } else {
    403402        success = false;
     
    411410}
    412411
    413 void dataManager::saveConfiguration(string nameOfFile)
     412void dataManager::saveConfiguration(string workingDir, string nameOfFile)
    414413{
    415414  ofstream outfile;
    416   string name = WORKINGAREA + nameOfFile + ".save";
     415  string name = workingDir + nameOfFile + ".save";
    417416  outfile.open(name.c_str(), ios::out);
    418417  if (!outfile) {
     
    431430}
    432431
    433 bool dataManager::restoreElements(string inputFileName)
     432bool dataManager::restoreElements(string workingDir, string inputFileName)
    434433{
    435434  cout << "dataManager::restoreElements() fichier " << inputFileName << endl;
    436435  ifstream infile;
    437   //  string name = WORKINGAREA + "pspa.save";
    438   infile.open(inputFileName.c_str(), ios::in);
     436   string name = workingDir + inputFileName + ".save";
     437  infile.open(name.c_str(), ios::in);
    439438  if (!infile) {
    440     cerr << " error opening input stream " << inputFileName << endl;
    441     return false;
    442   }
    443   else cout << " successful opening input stream " << inputFileName << endl;
     439    cerr << " error opening input stream " << name << endl;
     440    return false;
     441  }
     442  else cout << " successful opening input stream " << name << endl;
    444443
    445444  string globalTitle;
  • Interface_Web/trunk/pspaWT/src/particleBeam.cc

    r226 r227  
    66#include <algorithm>
    77
    8 #include "environmentVariables.h"
     8//#include "environmentVariables.h"
     9#include <Wt/WApplication>
    910
    1011
     
    9495
    9596
    96 bool  particleBeam::setFromTransport(string elLab, const nomdElements elem)
     97bool  particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem)
    9798{
    9899  string elementLabel = elLab;
     
    104105  string buf;
    105106  ifstream infile;
    106   string nameIn = WORKINGAREA + "transport.output";
     107  //  string nameIn = WORKINGAREA + "transport.output";
     108  string nameIn = workingDir + "transport.output";
    107109  infile.open(nameIn.c_str(), ios::in);
    108110  if (!infile) {
     
    139141
    140142
    141 bool particleBeam::setFromParmela(unsigned numeroElement, double referencefrequency) {
     143bool particleBeam::setFromParmela(string workingDir,unsigned numeroElement, double referencefrequency) {
    142144  unsigned  k;
    143145  FILE* filefais;
    144   string nomfilefais = WORKINGAREA + "parmdesz";
     146  string nomfilefais = workingDir + "parmdesz";
    145147  cout << " nom fichier desz : " << nomfilefais << endl;
    146148  filefais = fopen(nomfilefais.c_str(), "r");
Note: See TracChangeset for help on using the changeset viewer.