source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc @ 496

Last change on this file since 496 was 488, checked in by lemeur, 10 years ago

lecture fichier sauvegarde AML

File size: 4.3 KB
Line 
1
2#include <iostream>
3#include "elementSnapshot.h"
4#include "mixedTools.h"
5
6elementSnapshot::elementSnapshot(int num) : 
7  abstractElement(),
8  incr_(num)
9{
10  setDefaultValues();
11  setDefaults();
12  elementName_ = nomdElements("snapshot");
13  nbParam_ = elementName_.getElementNbParameters();
14  parametersString_ = new string[nbParam_+1];
15}
16
17void elementSnapshot::setDefaultValues()
18{
19  defaultSpecificName_ = "snapshot";
20}
21
22void elementSnapshot::setDefaults()
23{
24  specificName_ = defaultSpecificName_;
25
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  // }
33}
34
35string* elementSnapshot::getParametersString() const 
36{
37  int compteur = -1;
38  parametersString_[++compteur] = mixedTools::intToString(nbParam_);
39  parametersString_[++compteur] = specificName_;
40  parametersString_[++compteur] = programFile_;
41  parametersString_[++compteur] = inputBeamFile_;
42  parametersString_[++compteur] = outputBeamFile_;
43 
44  if ( compteur != nbParam_ ) {
45    cerr << "ERROR::elementSnapshot::getParametersString() : " << nbParam_ << endl;
46    return NULL;
47  }
48  return parametersString_;
49}
50
51void elementSnapshot::setParametersString(string* param)
52{
53  if ( param == NULL )
54    {
55      cerr << " elementSnaphot::setParametersString parameters empty parameter set";
56      return;
57    }
58 
59  int compteur = -1;
60  int nbparam = atoi(param[++compteur].c_str());
61  if ( nbparam != nbParam_ )  {
62    cerr << " elementSnaphot:: setParametersString parameters do not match for a SNAPSHOT";
63    return;
64  }
65 
66  specificName_ = param[++compteur];
67  programFile_  = param[++compteur];
68  inputBeamFile_  = param[++compteur];
69  outputBeamFile_  = param[++compteur];
70}
71
72// string elementSnapshot::parmelaOutputFlow() const
73// {
74//     // ostringstream sortie;
75//     // return sortie.str();
76//   return string("");
77// }
78
79// string elementSnapshot::transportOutputFlow() const
80// {
81//   return string("");
82// }
83
84// string elementSnapshot::FileOutputFlow() const
85// {
86//   ostringstream sortie;
87//   sortie << elementName_.getGenericLabel() << endl;
88//   sortie  << specificName_ << endl;
89//   sortie << programFile_ << endl;
90//   sortie << inputBeamFile_ << endl;
91//   sortie << outputBeamFile_ << endl;
92//   return sortie.str();
93// }
94
95vector< pair<string, vector<string> > > elementSnapshot::parametersToSoftware () const {
96  vector< pair<string, vector<string> > >  sortie;
97  sortie.push_back( pair<string, vector<string> >("labelsGenericSpecific",  vector<string>() ) );
98  sortie.back().second.push_back(elementName_.getGenericLabel());
99  sortie.back().second.push_back(specificName_);
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_);
104  return sortie;
105}
106
107// void elementSnapshot::FileInput(ifstream& ifs)
108// {
109//   ifs >> specificName_;
110//   ifs >> programFile_;
111//   ifs >> inputBeamFile_;
112//   ifs >> outputBeamFile_;;
113// }
114
115string elementSnapshot::print() 
116{
117  string txt = ""; 
118  txt += specificName_;
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_;
125  return txt;
126}
127
128void elementSnapshot::InputRep(UAPNode* root)
129{
130  // UAPNode* node= root->addChild("snapshot");
131  // node->addAttribute("name",specificName_);
132  UAPNode* ele = setAMLelementHeader(root);
133
134  UAPNode* fichiers = ele->addChild("names_of_files");
135  fichiers->addAttribute("program",programFile_);
136  fichiers->addAttribute("inputf",inputBeamFile_);
137  fichiers->addAttribute("outputf",outputBeamFile_);
138}
139
140void elementSnapshot::FileAMLInput(UAPNode* entree) 
141{
142  if ( !checkAMLelementGenericName(entree) ) return;
143  AMLtools::readAMLParameterAttribut(entree, "names_of_files", "program", programFile_);
144  AMLtools::readAMLParameterAttribut(entree, "names_of_files", "inputf", inputBeamFile_);
145  AMLtools::readAMLParameterAttribut(entree, "names_of_files", "outputf", outputBeamFile_);
146}
Note: See TracBrowser for help on using the repository browser.