Changeset 316 in PSPA


Ignore:
Timestamp:
Feb 9, 2013, 12:03:49 PM (11 years ago)
Author:
lemeur
Message:

introduction softwareTest

Location:
Interface_Web/trunk/pspaWT
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/cmt/requirements

    r307 r316  
    3232 ../sources/controler/src/softwareTransport.cc \
    3333 ../sources/controler/src/softwareGenerator.cc \
     34 ../sources/controler/src/softwareTest.cc \
    3435 ../sources/userInterface/src/GWt_cell.cc \
    3536 ../sources/userInterface/src/GWt_rfgun.cc \
  • Interface_Web/trunk/pspaWT/sources/controler/include/abstractSoftware.h

    r313 r316  
    1919  globalParameters* globParamPtr_;
    2020  dataManager* dataManager_;
    21 
     21  string inputFileName_;
    2222
    2323  abstractSoftware();
     
    2727 public :
    2828
    29   abstractSoftware(globalParameters* globals, dataManager* dt);
     29  abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt);
    3030  ~abstractSoftware() {;}
    3131
    32   virtual bool createInputFile(string inputFileName, particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir) = 0;
     32  virtual bool createInputFile(particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir) = 0;
    3333
    3434
    35   virtual bool  execute(string inputFileName, unsigned int numeroDeb,unsigned int numeroFin,string workingDir) = 0;
     35  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) = 0;
    3636
    3737 virtual bool buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) = 0;
  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r313 r316  
    33
    44#include "abstractElement.h"
     5#include "abstractSoftware.h"
    56#include "globalParameters.h"
    67#include "nomdElements.h"
     
    1617class dataManager
    1718{
    18    
     19  abstractSoftware* createSoftwareConnexion(nomDeLogiciel logi);
    1920public:
    2021   
  • Interface_Web/trunk/pspaWT/sources/controler/include/nomDeLogiciel.h

    r304 r316  
    55
    66using namespace std;
     7
     8
    79
    810class nomDeLogiciel
     
    1416  enum Logiciel
    1517  {
    16     parmela, transport, generator, unknownSoftware
    17   }; 
     18    parmela, transport, generator, test, unknownSoftware
     19  };
    1820
    1921
     
    2224  Logiciel program_;
    2325  std::string progString_;
    24   int value_;
    25 
     26  //  int value_;
     27 
    2628  static Logiciel fromString( std::string s);
    2729  static std::string toString( Logiciel lg); 
    28   static Logiciel fromValue( int v); 
    29   static int toValue( Logiciel lg);
     30  //  static Logiciel fromValue( int v); 
     31  //  static int toValue( Logiciel lg);
    3032 
    3133 public :
     
    3537  nomDeLogiciel(const string& s); 
    3638  nomDeLogiciel(int val);
    37  
    3839  static int getNumberOfSoftwares();
    3940 
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareGenerator.h

    r313 r316  
    44
    55#include "abstractSoftware.h"
     6#include "dataManager.h"
    67
    78class softwareGenerator : public abstractSoftware
     
    1920
    2021
    21  softwareGenerator(globalParameters* globals, dataManager* );
     22 softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt);
    2223
    2324  virtual ~softwareGenerator() {;}
    2425
    2526
    26   virtual bool createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
     27  virtual bool createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    2728
    2829
    29   virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir);
     30  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir);
    3031
    3132
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareParmela.h

    r313 r316  
    99 protected :
    1010
     11  //    les elements de parmela sont indexes à partir du premier, il faut
     12  // donc prevoir un offset pour le raccord a pspa
     13  unsigned offsetNumElem_;
     14
     15
    1116  softwareParmela();
    1217
     
    1621
    1722 public :
    18   softwareParmela(globalParameters* globals, dataManager* beamLine);
     23  softwareParmela(string inputFileName, globalParameters* globals, dataManager* beamLine);
    1924
    2025  virtual ~softwareParmela() {;}
    2126
    2227
    23   virtual bool createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
     28  virtual bool createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    2429
    25   virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir);
     30  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir);
    2631
    2732
  • Interface_Web/trunk/pspaWT/sources/controler/include/softwareTransport.h

    r313 r316  
    1414
    1515 public :
    16   softwareTransport(globalParameters* globals, dataManager* beamLine);
     16  softwareTransport(string inputFileName, globalParameters* globals, dataManager* beamLine);
    1717
    1818  virtual ~softwareTransport() {;}
    19   virtual bool createInputFile(string inputFileName, particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
     19  virtual bool createInputFile( particleBeam* beamBefore,unsigned int numeroDeb, unsigned int numeroFin, string workingDir);
    2020
    21   virtual bool  execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir);
     21  virtual bool  execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir);
    2222
    2323
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc

    r305 r316  
    44abstractSoftware::abstractSoftware()
    55{
    6   ;
     6  globParamPtr_ = NULL;
     7  dataManager_ = NULL;
     8
    79}
    810
    9 abstractSoftware::abstractSoftware(globalParameters* globals, dataManager* dt) {
     11abstractSoftware::abstractSoftware(string inputFileName, globalParameters* globals, dataManager* dt) {
     12  inputFileName_ = inputFileName;
    1013  globParamPtr_ = globals;
    1114  dataManager_ = dt;
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r314 r316  
    77#include "GWt_console.h"
    88#include "softwareGenerator.h"
     9#include "softwareTest.h"
    910
    1011#include <stdio.h>
     
    149150    removeFile(workingDir_ + "parmdesz");
    150151    removeFile(workingDir_ + "parmin");
     152    removeFile(workingDir_ + "parin.input0");
    151153    removeFile(workingDir_ + "transport.input");
    152154    removeFile(workingDir_ + "transport.output");
     155    removeFile(workingDir_ + "generator.in");
     156    removeFile(workingDir_ + "faisceau.ini");
     157    removeFile(workingDir_ + "generator.output");
    153158    diagnosticBeam_.clear();
    154159    currentBeam_ = NULL;
     
    178183      int debut = jobList_[k]->firstElement;
    179184      int fin = jobList_[k]->lastElement;
    180       //      resultatPartiel.clear();
    181185      cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->software).getString() << endl;
    182186
    183       string inputFileName;
    184       if(jobList_[k]->software == nomDeLogiciel::parmela) {
    185         softw = new softwareParmela(&globParam_, this);
    186         inputFileName = "parmin";
    187       } else if (jobList_[k]->software == nomDeLogiciel::transport) {
    188         softw = new softwareTransport(&globParam_, this);
    189         inputFileName = "transport.input";
    190       } else if (jobList_[k]->software == nomDeLogiciel::generator) {
    191         softw = new softwareGenerator(&globParam_, this);
    192         inputFileName = "generator.in";
    193       } else {
     187      softw = createSoftwareConnexion(jobList_[k]->software );
     188
     189      if ( softw == NULL ) {
    194190        success = false;
    195191        consoleMessage("dataManager::executeAll : unknown software");
     
    198194      }
    199195
    200       success = softw->createInputFile(inputFileName,currentBeam_, debut, fin, workingDir_);
    201       // if ( !success ) {
    202       //        resultatPartiel += " error creating input file \n";
    203       // } else {
     196      success = softw->createInputFile(currentBeam_, debut, fin, workingDir_);
    204197      if ( success ) {
    205         success = softw->execute(inputFileName, debut,fin,workingDir_);
     198        success = softw->execute(debut,fin,workingDir_);
    206199        if ( success ) {
    207200          success = softw->buildBeamAfterElements(debut, fin, diagnosticBeam_, workingDir_);
    208           // if ( !success ) {
    209           //   resultatPartiel += " reading results failed \n";
    210           // }
    211201        }
    212202      }
     
    219209        cout << " execute termine en ECHEC " << endl;
    220210      }
    221       //      resul += resultatPartiel;
    222211      if ( !success ) break;
    223212    }
     
    345334    return pspa_->getBeamLine()->getBeamLineSize();
    346335}
     336
     337abstractSoftware* dataManager::createSoftwareConnexion(nomDeLogiciel logi) {
     338
     339      string inputFileName;
     340      if(logi == nomDeLogiciel::parmela) {
     341        inputFileName = "parmin";
     342        return new softwareParmela(inputFileName, &globParam_, this);
     343      } else if (logi == nomDeLogiciel::transport) {
     344        inputFileName = "transport.input";
     345        return new softwareTransport(inputFileName, &globParam_, this);
     346      } else if (logi == nomDeLogiciel::generator) {
     347        inputFileName = "generator.in";
     348        return new softwareGenerator(inputFileName, &globParam_, this);
     349      } else if (logi == nomDeLogiciel::test) {
     350        return new softwareTest(inputFileName, &globParam_, this);
     351      } else {
     352        return NULL;
     353      }
     354
     355}
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementDrift.cc

    r288 r316  
    2828  if ( soft == nomDeLogiciel::transport  ) return ok;
    2929  else if ( soft == nomDeLogiciel::parmela ) return ok;
     30  else if ( soft == nomDeLogiciel::test ) return ok;
    3031  else return error;
    3132}
  • Interface_Web/trunk/pspaWT/sources/controler/src/nomDeLogiciel.cc

    r304 r316  
    77    else if ( s == "transport" ) return transport;
    88    else if ( s == "generator" ) return generator;
     9    else if ( s == "test" ) return test;
    910    return unknownSoftware;
    1011  }
     
    1718      case transport : { return "transport"; }
    1819      case generator : { return "generator"; }
     20      case test : { return "test"; }
    1921      case unknownSoftware : { return "unknownSoftware"; }
    2022      }
    2123    return "unknownSoftware";
    22   }
    23 
    24   nomDeLogiciel::Logiciel nomDeLogiciel::fromValue( int v)
    25   {
    26     switch (v)
    27       {
    28       case 0 : { return parmela; }
    29       case 1 : { return transport; }
    30       case 2 : { return generator; }
    31       }
    32     return unknownSoftware;
    33   }
    34 
    35  int nomDeLogiciel::toValue( nomDeLogiciel::Logiciel lg)
    36   {
    37     switch (lg)
    38       {
    39       case parmela : { return 0; }
    40       case transport : { return 1; }
    41       case generator : { return 2; }
    42       case unknownSoftware :  { return 3; }
    43       }
    44     return -1;
    4524  }
    4625
     
    4928    program_ = transport;
    5029    progString_ = toString(program_);
    51     value_ = toValue(program_);
     30    //    value_ = toValue(program_);
    5231  }
    5332
     
    5635      program_ = fromString(s);
    5736      progString_ = toString(program_);
    58       value_ = toValue(program_);
     37      //      value_ = toValue(program_);
    5938    }
    6039
    6140  nomDeLogiciel::nomDeLogiciel(int val)
    6241    { 
    63       program_ = fromValue(val);
     42      program_ = (Logiciel)val;
    6443      progString_ = toString(program_);
    65       value_ = toValue(program_);
     44      //      program_ = fromValue(val);
     45      //      value_ = toValue(program_);
    6646    }
     47
     48
    6749
    6850int nomDeLogiciel::getNumberOfSoftwares()
    6951{
    70   return toValue(unknownSoftware);
     52  //  return toValue(unknownSoftware);
     53  return unknownSoftware;
    7154}
    7255
     
    7760      program_ = nl.program_;
    7861      progString_ = nl.progString_;
    79       value_ = nl.value_;
     62      //      value_ = nl.value_;
    8063      return *this;
    8164    }
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc

    r313 r316  
    44#include "mathematicalConstants.h"
    55#include "PhysicalConstants.h"
    6 #include "dataManager.h"
     6//#include "dataManager.h"
    77
    88
     
    1515
    1616
    17 softwareGenerator::softwareGenerator(globalParameters* globals, dataManager* dt) : abstractSoftware(globals, dt)
     17softwareGenerator::softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt)
    1818{
    1919  ;
     
    2121
    2222
    23 bool softwareGenerator::createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
     23bool softwareGenerator::createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    2424{
    2525  if ( numeroDeb != numeroFin ) return false;
     
    3434  }
    3535  ofstream outfile;
    36   string name = workingDir + inputFileName;
     36  string name = workingDir + inputFileName_;
    3737  outfile.open(name.c_str(), ios::out);
    3838  if (!outfile) {
     
    5454
    5555
    56 bool  softwareGenerator::execute(string inputFileName, unsigned int numeroDeb,unsigned int numeroFin,string workingDir) {
     56bool  softwareGenerator::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir) {
    5757  ostringstream sortie;
    5858  bool ExecuteStatus = true;
     
    6363  string generatorJob = workingDir + "generator";
    6464  generatorJob += string("   ");
    65   generatorJob += workingDir + inputFileName;
     65  generatorJob += workingDir + inputFileName_;
    6666
    6767
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc

    r314 r316  
    55#include "PhysicalConstants.h"
    66#include "dataManager.h"
    7 
     7#include "mixedTools.h"
    88
    99softwareParmela::softwareParmela() : abstractSoftware()
     
    1212}
    1313
    14 softwareParmela::softwareParmela(globalParameters* globals, dataManager* dt) : abstractSoftware(globals, dt)
     14softwareParmela::softwareParmela(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt)
    1515{
    1616  ;
    1717}
    1818
    19 bool softwareParmela::createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
     19bool softwareParmela::createInputFile( particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    2020{
    2121  unsigned int k;
     
    2929
    3030  ofstream outfile;
    31   string name = workingDir + inputFileName;
     31  string name = workingDir + inputFileName_;
    3232  outfile.open(name.c_str(), ios::out);
    3333  if (!outfile) {
     
    4444    if ( !beamToParmela(workingDir, beamBefore ) ) return false;
    4545    initalKineticEnergy = beamBefore->referenceKineticEnergyMeV();
     46        // les elements de parmela sont indexes de 1 à max, s'in n'y a pas de rfgun
     47    offsetNumElem_ = numeroDeb -1;
    4648  }
    4749  else {
    4850    elPtr->setPhaseStep( globParamPtr_->getIntegrationStep() );
    4951    initalKineticEnergy = elPtr->getInitialKineticEnergy();
     52        // les elements de parmela sont indexes de 0 à max, s'il y a un rfgun
     53    offsetNumElem_ = numeroDeb;
    5054  }
    5155
     
    7781
    7882
    79 bool  softwareParmela::execute(string inputFileName,unsigned int numeroDeb,unsigned int numeroFin,string workingDir)
     83bool  softwareParmela::execute(unsigned int numeroDeb,unsigned int numeroFin,string workingDir)
    8084{
    8185  ostringstream sortie;
     
    118122  bool result = true;
    119123        unsigned k;
     124
    120125        for ( k= numeroDeb; k <= numeroFin; k++)
    121126          {
     
    124129            bareParticle refPart;
    125130            vector<bareParticle> particles;
    126             if (!beamFromParmela(workingDir,k, globParamPtr_->getFrequency(), centroid, refPart,particles ))
     131            if (!beamFromParmela(workingDir,k - offsetNumElem_ , globParamPtr_->getFrequency(), centroid, refPart,particles ))
    127132              {
    128133                abstractElement* elem = dataManager_->getElementPointerFromNumero(k);
     
    147152
    148153
    149 bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroElement, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ) {
     154bool softwareParmela::beamFromParmela(string workingDir,unsigned numeroParmel, double referencefrequency, vector<double>& centroid, bareParticle& refPart,vector<bareParticle>& particles ) {
    150155  unsigned  k;
    151156  FILE* filefais;
     
    164169  std::vector<parmelaParticle> faisceau;
    165170
    166   cout << " beamFromParmela : numeroElement = " << numeroElement << endl;
    167   unsigned indexElement = numeroElement-1;
     171  //  unsigned indexElement = numeroElement-1;
    168172 
    169173
     
    174178
    175179  while( partic.readFromParmelaFile(filefais) > 0 ) {
    176     if ( partic.ne == (int)indexElement )
     180    if ( partic.ne == (int)numeroParmel )
    177181      {
    178182        faisceau.push_back(partic);
     
    190194          testNombrePartRef++;
    191195          if ( testNombrePartRef != 1 ) {
     196            dataManager_->consoleMessage(" beamFromParmela : nombre de part. de ref different de 1 :");
    192197            cerr << " nombre de part. de ref different de 1 : " << testNombrePartRef << " !! " << endl;
    193198            return false;
     
    199204  if ( faisceau.size() == 0)
    200205    {
    201       cerr << " beamFromParmela echec lecture  element " << numeroElement << endl;
     206      string stringNum = mixedTools::intToString( (int)numeroParmel );
     207      dataManager_->consoleMessage("beamFromParmela echec lecture  element numero relatif  parmela : " + stringNum);
     208      cerr << " beamFromParmela echec lecture  element numero relatif  parmela " << numeroParmel << endl;
    202209      return false;
    203210    }
     
    267274  unsigned k;
    268275  double weight = 1.0;
     276  cout << " ICI sortie des particules " << endl;
     277  double xx,yy,zz;
     278  double begamx, begamy, begamz;
    269279  for ( k=0; k < partic.size(); k++) {
    270     outfile << partic.at(k).getPosition().output_flow() << partic.at(k).getBetaGamma().output_flow()<< weight << endl;
    271   }
    272     return true;
    273 }
    274 
    275 
     280    partic.at(k).getPosition().getComponents(xx,yy,zz);
     281    partic.at(k).getBetaGamma().getComponents(begamx, begamy, begamz);
     282    outfile << xx << " " << begamx << " " <<  yy << " " << begamy << " " << zz << " " << begamz  << " " << weight << endl;
     283  }
     284  outfile.close();
     285  return true;
     286}
     287
     288
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareTransport.cc

    r313 r316  
    1111}
    1212
    13 softwareTransport::softwareTransport(globalParameters* globals, dataManager* dt) : abstractSoftware(globals, dt)
     13softwareTransport::softwareTransport(string inputFileName,globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt)
    1414{
    1515  ;
     
    1717
    1818
    19 bool softwareTransport::createInputFile(string inputFileName, particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
     19bool softwareTransport::createInputFile(particleBeam* beamBefore, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    2020{
    2121  unsigned int k;
     
    3636
    3737  ofstream outfile;
    38   string name = workingDir + inputFileName;
     38  string name = workingDir + inputFileName_;
    3939  outfile.open(name.c_str(), ios::out);
    4040  if (!outfile)
     
    105105
    106106
    107 bool softwareTransport::execute(string inputFileName, unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
     107bool softwareTransport::execute( unsigned int numeroDeb, unsigned int numeroFin, string workingDir)
    108108{
    109109  ostringstream sortie;
     
    116116  string transportJob = workingDir + "transport";
    117117  transportJob += string(" <  ");
    118   transportJob += workingDir + inputFileName;
     118  transportJob += workingDir + inputFileName_;
    119119  cout << " job transport= " << transportJob << endl;
    120120
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r313 r316  
    141141    int current = dtmanage_->getNumeroFromElementLabel( currentString);
    142142   
    143     cout << " numero " << current << endl;
    144143    // si la fin est mal definie on prend toute la config par defaut
    145144    if ( current <= 0 || current > dtmanage_->getBeamLineSize() )
     
    159158    {
    160159        // debut
    161         if ( current >= dtmanage_->getBeamLineSize() )
     160        if ( current > dtmanage_->getBeamLineSize() )
    162161        {
    163             //    GWt_tools::addConsoleMessage(" bad section definition !  \n ");
    164162            GWt_dialog warningDialog("PSPA : VÈrification des sections", " bad section definition !", GWt_dialog::Error,true,true);
    165163            warningDialog.exec();
     
    173171        int numeroFin = dtmanage_->getNumeroFromElementLabel( finString);
    174172       
    175         if ( numeroFin <= current || numeroFin > dtmanage_->getBeamLineSize())
     173        if ( numeroFin < current || numeroFin > dtmanage_->getBeamLineSize())
    176174        {
    177             //    GWt_tools::addConsoleMessage(" bad section definition !  \n ");
    178             GWt_dialog warningDialog("PSPA : VÈrification des sections", " bad section definition !", GWt_dialog::Error, true,true);
     175            GWt_dialog warningDialog("PSPA : Checking of sections", " bad section definition !", GWt_dialog::Error, true,true);
    179176            warningDialog.exec();
    180177            return;
     
    217214    string diagnostic;
    218215    trivaluedBool essai = dtmanage_->checkExecute(diagnostic);
    219     cout << " retour verif , essai = " << essai << endl;
    220216    if ( essai == error ) {
    221         cout << " appli : erreur " << endl;
    222217        caMarche = false;
    223218        GWt_dialog calculDialog("PSPA check execute : ERROR", diagnostic , GWt_dialog::Error,true,true);
    224219        calculDialog.exec();
    225220    } else if ( essai == warning )  {
    226         cout << " appli : warnig " << endl;
    227221        caMarche = true;
    228222        GWt_dialog calculDialog("PSPA check execute : warning ", diagnostic , GWt_dialog::Warning, false,true);
Note: See TracChangeset for help on using the changeset viewer.