Changeset 442 in PSPA


Ignore:
Timestamp:
Dec 11, 2013, 9:33:35 AM (10 years ago)
Author:
lemeur
Message:

ajout traitement utilisateur

Location:
Interface_Web/trunk/pspaWT
Files:
2 added
17 edited
1 copied

Legend:

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

    r440 r442  
    3636 ../sources/controler/src/softwareTransport.cc \
    3737 ../sources/controler/src/softwareGenerator.cc \
     38 ../sources/controler/src/softwareUsersprogram.cc \
    3839 ../sources/controler/src/sectionToExecute.cc \
    3940 ../sources/controler/src/softwareTest.cc \
  • Interface_Web/trunk/pspaWT/sources/controler/include/elementSnapshot.h

    r424 r442  
    1010{
    1111  int incr_;
    12   string snapshotFile_;
     12  string programFile_;
     13  string inputBeamFile_;
     14  string outputBeamFile_;
    1315  void setDefaultValues();
    1416  void setDefaults();
  • Interface_Web/trunk/pspaWT/sources/controler/include/mathematicalTools.h

    r257 r442  
    150150inline double getComponent(int index ) const {return vec_[index];}
    151151
     152 inline double& component(int index ) {return vec_[index];}
     153
    152154 inline void setComponent(int index, double value )  {vec_[index] = value;}
    153155
  • Interface_Web/trunk/pspaWT/sources/controler/include/nomDeLogiciel.h

    r431 r442  
    1313  enum Logiciel
    1414  {
    15     parmela, transport, generator, useraction, test, madx, unknownSoftware
     15    parmela, transport, generator, test, madx, usersprogram, unknownSoftware
    1616  };
    1717 
  • Interface_Web/trunk/pspaWT/sources/controler/include/particleBeam.h

    r417 r442  
    138138  virtual string fileOutputFlow() const;
    139139  virtual bool FileInput(ifstream& ifs);
     140  virtual void writeToAMLFile(string fileName);
     141  virtual bool readFromAMLFile(string fileName);
    140142
    141143  void histogramme(unsigned int index,vector<double>&xcor,vector<int>& hist,vector<string>& legende);
  • Interface_Web/trunk/pspaWT/sources/controler/src/abstractSoftware.cc

    r431 r442  
    22#include "dataManager.h"
    33#include <algorithm>
     4#include <iostream>
     5
    46
    57abstractSoftware::abstractSoftware()
     
    5254void abstractSoftware::registerElement(nomdElements::typedElement nomdel,trivaluedBool b)
    5355{
     56  //  std::cout << " abstractSoftware::registerElement soft : " << nameOfSoftware_.getString() << std::endl;
    5457  if (b == TBoolIgnore) {
     58    //    std::cout << " abstractSoftware::registerElement j'enregistre element " <<  nomdel << "   ignore " << std::endl;
    5559    ignoredElements_.push_back(nomdel);
    5660  } else if (b == TBoolOk) {
     61    //    std::cout << " abstractSoftware::registerElement j'enregistre element " <<  nomdel << "  OK " << std::endl;
    5762    acceptedElements_.push_back(nomdel);
    5863  }
  • Interface_Web/trunk/pspaWT/sources/controler/src/bareParticle.cc

    r312 r442  
    119119
    120120
    121 
    122121bool bareParticle::FileInput( ifstream& ifs)
    123122 {
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r436 r442  
    1212#include "softwareTransport.h"
    1313#include "softwareGenerator.h"
     14#include "softwareGenerator.h"
     15#include "softwareUsersprogram.h"
    1416#include "softwareTest.h"
    1517#include "softwareMadx.h" //xx
     
    8991    inputFileName = "generator.in";
    9092    prog = new softwareGenerator(inputFileName, &globParam_, this);
    91   } else if (logiciel  == nomDeLogiciel::test) {
    92     prog = new softwareTest(inputFileName, &globParam_, this);
    9393  } else if (logiciel  == nomDeLogiciel::madx) {
    9494    inputFileName = "madx.input";
    9595    prog = new softwareMadx(inputFileName,&sectorParam_,this); 
     96  } else if (logiciel  == nomDeLogiciel::usersprogram) {
     97    inputFileName = "dummy";
     98    prog = new softwareUsersprogram(inputFileName, &globParam_, this);
     99  } else if (logiciel  == nomDeLogiciel::test) {
     100    prog = new softwareTest(inputFileName, &globParam_, this);
    96101  } else {
    97102    prog = new softwareUnknown(); // xx
     
    230235
    231236  } //k
    232  
     237  // if ( currentBeam_ ) {
     238  // string aml_file = workingDir + "/" + "faisceau_final" + ".aml";
     239  //   currentBeam_->writeToAMLFile(aml_file);
     240  //   // TESTS
     241  //   currentBeam_->readFromAMLFile(aml_file);
     242  // }
    233243  cout << " dataManager::executeAll() : premier element = " << firstComputedElemNumero_ << " dernier = " << lastComputedElemNumero_ << endl;
    234244
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementDrift.cc

    r431 r442  
    1313  nbParam_ = elementName_.getElementNbParameters();
    1414  parametersString_ = new string[nbParam_+1];
    15   // registerAcceptableSoftware(nomDeLogiciel::transport, TBoolOk);
    16   // registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolOk);
    17   // registerAcceptableSoftware(nomDeLogiciel::test, TBoolOk);
    1815}
    1916
  • Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc

    r424 r442  
    1313  nbParam_ = elementName_.getElementNbParameters();
    1414  parametersString_ = new string[nbParam_+1];
    15   // registerAcceptableSoftware(nomDeLogiciel::transport, TBoolIgnore);
    16   // registerAcceptableSoftware(nomDeLogiciel::parmela, TBoolIgnore);
    17   // registerAcceptableSoftware(nomDeLogiciel::generator, TBoolIgnore);
    18   // registerAcceptableSoftware(nomDeLogiciel::useraction,
    19   //                                           TBoolOk);
    20   // registerAcceptableSoftware(nomDeLogiciel::test, TBoolIgnore);
    2115}
    2216
     
    3024  specificName_ = defaultSpecificName_;
    3125
    32   if(incr_ < 10) {
    33     snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr_);
    34   } else if(incr_ >= 10 && incr_ < 100) {
    35     snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr_);
    36   } else {
    37     snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr_);
    38   }
     26  // if(incr_ < 10) {
     27  //   snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr_);
     28  // } else if(incr_ >= 10 && incr_ < 100) {
     29  //   snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr_);
     30  // } else {
     31  //   snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr_);
     32  // }
    3933}
    4034
     
    4438  parametersString_[++compteur] = mixedTools::intToString(nbParam_);
    4539  parametersString_[++compteur] = specificName_;
    46   parametersString_[++compteur] = snapshotFile_;
     40  parametersString_[++compteur] = programFile_;
     41  parametersString_[++compteur] = inputBeamFile_;
     42  parametersString_[++compteur] = outputBeamFile_;
    4743 
    4844  if ( compteur != nbParam_ ) {
     
    6460  int nbparam = atoi(param[++compteur].c_str());
    6561  if ( nbparam != nbParam_ )  {
    66     cerr << " elementSnaphot:: setParametersString parameters do not match for a DRIFT";
     62    cerr << " elementSnaphot:: setParametersString parameters do not match for a SNAPSHOT";
    6763    return;
    6864  }
    6965 
    7066  specificName_ = param[++compteur];
     67  programFile_  = param[++compteur];
     68  inputBeamFile_  = param[++compteur];
     69  outputBeamFile_  = param[++compteur];
    7170}
    7271
     
    8887  sortie << elementName_.getGenericLabel() << endl;
    8988  sortie  << specificName_ << endl;
    90   sortie << snapshotFile_ << endl;
     89  sortie << programFile_ << endl;
     90  sortie << inputBeamFile_ << endl;
     91  sortie << outputBeamFile_ << endl;
    9192  return sortie.str();
    9293}
     
    9798  sortie.back().second.push_back(elementName_.getGenericLabel());
    9899  sortie.back().second.push_back(specificName_);
    99   sortie.push_back( pair<string, vector<string> >("snapshotFile",  vector<string>() ) );
    100   sortie.back().second.push_back(snapshotFile_);
     100  sortie.push_back( pair<string, vector<string> >("nameOfFiles",  vector<string>() ) );
     101  sortie.back().second.push_back(programFile_);
     102  sortie.back().second.push_back(inputBeamFile_);
     103  sortie.back().second.push_back(outputBeamFile_);
    101104  return sortie;
    102105}
     
    105108{
    106109  ifs >> specificName_;
    107   ifs >> snapshotFile_;
     110  ifs >> programFile_;
     111  ifs >> inputBeamFile_;
     112  ifs >> outputBeamFile_;;
    108113}
    109114
     
    112117  string txt = ""; 
    113118  txt += specificName_;
    114   txt += "\nname of file for snapshot : ";
    115   txt += snapshotFile_;
     119  txt += "\nname of file for user's program : ";
     120  txt += programFile_;
     121  txt += "\nname of input beam file for user's program : ";
     122  txt += inputBeamFile_;
     123  txt += "\nname of output beam file for user's program : ";
     124  txt += outputBeamFile_;
    116125  return txt;
    117126}
     
    121130  UAPNode* node= root->addChild("snapshot");
    122131  node->addAttribute("name",specificName_);
     132
     133  UAPNode* fichiers = node->addChild("names_of_files");
     134  fichiers->addAttribute("program",programFile_);
     135  fichiers->addAttribute("inputf",inputBeamFile_);
     136  fichiers->addAttribute("outputf",outputBeamFile_);
    123137}
  • Interface_Web/trunk/pspaWT/sources/controler/src/nomDeLogiciel.cc

    r431 r442  
    66    else if ( s == "transport" ) return transport;
    77    else if ( s == "generator" ) return generator;
    8     else if ( s == "useraction" ) return useraction;
    98    else if ( s == "test" ) return test;
    109    else if ( s == "madx" ) return madx;
     10    else if ( s == "usersprogram" ) return usersprogram;
    1111    return unknownSoftware;
    1212  }
     
    1919    case transport : { return "transport"; }
    2020    case generator : { return "generator"; }
    21     case useraction : { return "useraction"; }
    2221    case test : { return "test"; }
    2322    case madx : { return "madx"; }
     23    case usersprogram : { return "usersprogram"; }
    2424    case unknownSoftware : { return "unknownSoftware"; }
    2525    }
     
    3737    case transport : { return "#c0ea8e"; }
    3838    case generator : { return "#a3c0ed"; }
    39     case useraction : { return "#FFFFFF"; }
    4039    case test : { return "#ecc38e"; }
    4140    case madx : { return "#ecc38e"; } //{ return "#FFFF00"; }
  • Interface_Web/trunk/pspaWT/sources/controler/src/nomdElements.cc

    r431 r442  
    7474  case soleno :   return 5;
    7575  case fit :   return 4;
    76   case snapshot : return 2;
     76  case snapshot : return 4;
    7777  case mpole :   return 3;
    7878  default : return 0;
  • Interface_Web/trunk/pspaWT/sources/controler/src/particleBeam.cc

    r435 r442  
    55#include "mathematicalTools.h"
    66#include "mixedTools.h"
     7
     8#include "UAP/UAPUtilities.hpp"
     9#include "AML/AMLReader.hpp"
    710
    811#include <stdio.h>
     
    203206  sortie << endl;
    204207  return sortie.str();
     208}
     209
     210
     211void particleBeam::writeToAMLFile(string fileName) {
     212  UAPNode* uap_root = new UAPNode("UAP_root");
     213  UAPNode* rep = uap_root->addChild("AML_representation");
     214
     215  // root node in the hierarchy
     216  UAPNode* lab = rep->addChild("laboratory");
     217  lab->addAttribute("name","PSPA lab");
     218
     219
     220
     221  // root node in the hierarchy
     222  UAPNode* par = lab->addChild("particles");
     223  par->addAttribute("name","PSPA particles");
     224
     225  unsigned int k;
     226  if ( particleRepresentationOk_ ) {
     227  for ( k = 0 ; k < relativePartic_.size(); k++)
     228    {
     229      TRIDVECTOR& position = relativePartic_.at(k).getReferenceToPosition();
     230      TRIDVECTOR& betgam = relativePartic_.at(k).getReferenceToBetaGamma();
     231      UAPNode* partic = par->addChild("particle");
     232      string txt;
     233      txt = mixedTools::doubleToString(position.getComponent(0));
     234      partic->addAttribute("x",txt);
     235      txt = mixedTools::doubleToString(position.getComponent(1));
     236      partic->addAttribute("y",txt);
     237      txt = mixedTools::doubleToString(position.getComponent(2));
     238      partic->addAttribute("cdeltat",txt);
     239      txt = mixedTools::doubleToString(betgam.getComponent(0));
     240      partic->addAttribute("betagamma_x",txt);
     241      txt = mixedTools::doubleToString(betgam.getComponent(1));
     242      partic->addAttribute("betagamma_y",txt);
     243      txt = mixedTools::doubleToString(betgam.getComponent(2));
     244      partic->addAttribute("betagamma_z",txt);
     245    }
     246
     247  } else {
     248    cout << " particleBeam::writeToAMLFile : representation 'particules' indisponible" << endl;
     249  }
     250
     251  cout << "!Create the AML particle file ---------------------------" << endl;
     252  AMLReader reader;
     253  reader.AMLRepToAMLFile (uap_root, fileName);
     254
     255}
     256
     257bool particleBeam::readFromAMLFile(string fileName) {
     258
     259  cout << "!read the AML particle file ---------------------------" << endl;
     260  AMLReader reader;
     261  UAPNode* uap_root = NULL;
     262  uap_root = reader.AMLFileToAMLRep (fileName);
     263  if ( !uap_root ) {
     264    cout << " particleBeam::readFromAMLFile ERREUR lecture fichier particules " << endl;
     265    return false;
     266  }
     267
     268
     269  NodeVec lesParticules = uap_root->getSubNodesByName(string("particles"));
     270
     271  NodeVec& listPart = (*lesParticules.begin())->getChildren();
     272
     273  if (  !listPart.size() ) {
     274    cout << " particleBeam::readFromAMLFile ERREUR lecture fichier : pas de particules ? " << endl;
     275    return false;
     276  }
     277
     278  vector<bareParticle> vecteurParticules;
     279  bareParticle reference;
     280  for (NodeVecIter iter = listPart.begin(); iter != listPart.end(); iter++) {
     281    TRIDVECTOR position, betagamma;
     282    UAPAttribute* att = NULL;
     283    att = (*iter)->getAttribute("x");
     284    if ( att ) att->getDouble(position.component(0));
     285    att = (*iter)->getAttribute("y");
     286    if ( att ) att->getDouble(position.component(1));
     287    att = (*iter)->getAttribute("cdeltat");
     288    if ( att ) att->getDouble(position.component(2));
     289
     290    att = (*iter)->getAttribute("betagamma_x");
     291    if ( att ) att->getDouble(betagamma.component(0));
     292    att = (*iter)->getAttribute("betagamma_y");
     293    if ( att ) att->getDouble(betagamma.component(1));
     294    att = (*iter)->getAttribute("betagamma_z");
     295    if ( att ) att->getDouble(betagamma.component(2));
     296   
     297    if ( fabs(position.component(0)) < PETIT &&  fabs(position.component(1)) < PETIT && fabs(position.component(2)) < PETIT ) {
     298      reference = bareParticle(position, betagamma);
     299    }
     300    vecteurParticules.push_back(bareParticle(position, betagamma));
     301  }
     302  vector<double> centroid(6,0.0);
     303  setWithParticles(centroid, reference, vecteurParticules);
     304  return true;
    205305}
    206306
  • Interface_Web/trunk/pspaWT/sources/controler/src/softwareGenerator.cc

    r434 r442  
    1414softwareGenerator::softwareGenerator(string inputFileName, globalParameters* globals, dataManager* dt) : abstractSoftware(inputFileName, globals, dt)
    1515{
     16  cout << " softwareUsersprogram::softwareGenerator ENREGISTREMENT " << endl;
    1617  nameOfSoftware_ = nomDeLogiciel("generator");
    1718  registerElement(nomdElements::RFgun,TBoolOk);
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementSnapshot.h

    r437 r442  
    1414class GWt_elementSnapshot : public GWt_abstractElement
    1515{
    16   WLineEdit* snapshotFile_;
    17    
     16   WLineEdit* programFile_;
     17  WLineEdit* inputBeamFile_;
     18  WLineEdit* outputBeamFile_;
     19 
    1820 public:
    1921   
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementSnapshot.cc

    r437 r442  
    1919  string* param = beginDialog();
    2020
    21   new WText("name of file for snapshot : ",dialog_->contents());
    22   snapshotFile_ = new WLineEdit(param->c_str(),dialog_->contents());
     21  new WText("name of user's program : ",dialog_->contents());
     22  programFile_ = new WLineEdit(param->c_str(),dialog_->contents());
     23  new WBreak(dialog_->contents());
     24
     25
     26  new WText("name of input beam file, output from pspa : ",dialog_->contents());
     27  inputBeamFile_ = new WLineEdit( (++param)->c_str(),dialog_->contents());
     28  new WBreak(dialog_->contents());
     29
     30  new WText("name of output beam file (input for pspa) : ",dialog_->contents());
     31  outputBeamFile_ = new WLineEdit( (++param)->c_str(),dialog_->contents());
    2332  new WBreak(dialog_->contents());
    2433
     
    4049  envoi[++compteur] = mixedTools::intToString(nbParam);
    4150  envoi[++compteur] = labelEdit_->text().toUTF8();
    42   envoi[++compteur] = snapshotFile_->text().toUTF8();
     51  envoi[++compteur] = programFile_->text().toUTF8();
     52  envoi[++compteur] = inputBeamFile_->text().toUTF8();
     53  envoi[++compteur] = outputBeamFile_->text().toUTF8();
     54
     55
    4356  if ( compteur !=  (int)nbParam ) {
    4457    cerr << " GWt_elementSnapshot::dialogDone() : pb dans le nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_snapshot.cc

    r434 r442  
    1919  string* param = beginDialog();
    2020
    21   new WText("name of file for snapshot : ",dialog_->contents());
    22   snapshotFile_ = new WLineEdit(param->c_str(),dialog_->contents());
     21  new WText("name of user's program : ",dialog_->contents());
     22  programFile_ = new WLineEdit(param->c_str(),dialog_->contents());
     23  new WBreak(dialog_->contents());
     24
     25
     26  new WText("name of input beam file, output from pspa : ",dialog_->contents());
     27  inputBeamFile_ = new WLineEdit( (++param)->c_str(),dialog_->contents());
     28  new WBreak(dialog_->contents());
     29
     30  new WText("name of output beam file (input for pspa) : ",dialog_->contents());
     31  outputBeamFile_ = new WLineEdit( (++param)->c_str(),dialog_->contents());
    2332  new WBreak(dialog_->contents());
    2433
     
    4049  envoi[++compteur] = mixedTools::intToString(nbParam);
    4150  envoi[++compteur] = labelEdit_->text().toUTF8();
    42   envoi[++compteur] = snapshotFile_->text().toUTF8();
     51  envoi[++compteur] = programFile_->text().toUTF8();
     52
     53  envoi[++compteur] = inputBeamFile_->text().toUTF8();
     54  envoi[++compteur] = outputBeamFile_->text().toUTF8();
     55
     56
    4357  if ( compteur !=  (int)nbParam ) {
    4458    cerr << " GWt_snapshot::dialogDone() : pb dans le nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_softwarePanel.cc

    r436 r442  
    279279
    280280          trivaluedBool tb = softToExec->doAcceptElement(elPtr->getNomdElement().getElementType());
     281          cout << " GWt_softwarePanel::areDataCoherent() el " << elPtr->getLabel() << " tb= " << tb << endl;
    281282          if (tb  == TBoolOk ) {
    282283            elPtr->setSoftware(softToExec);
Note: See TracChangeset for help on using the changeset viewer.