Ignore:
Timestamp:
Sep 30, 2013, 5:03:21 PM (11 years ago)
Author:
touze
Message:

sauvgarde de la configuration sur fichier format AML

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r419 r424  
    55#include "softwareTransport.h"
    66#include "GWt_pspaApplication.h"
    7 #include "GWt_console.h"Ò
     7#include "GWt_console.h"
    88#include "softwareGenerator.h"
    99#include "softwareTest.h"
     
    1212#include <stdio.h>
    1313#include <fstream>
     14
     15#include "UAP/UAPUtilities.hpp"
     16#include "AML/AMLReader.hpp"
    1417
    1518dataManager::dataManager(PspaApplication* pspa) :
     
    102105void dataManager::clearSectionToExecute(int a) {
    103106  cout << " dataManager::clearSectionToExecute efaacement section d'index : " << a << endl;
    104   if (a<0) return;
    105   if (a>= jobList_.size()) return;
    106 
    107   // lors de la creation de la section on a fait un 'new' d'un softwareXXXX
    108   // on fait ici le 'delete'
     107  if (a < 0) return;
     108  if (a >= (int)jobList_.size()) return;
     109
     110  // lors de la creation de la section on a fait un 'new' d'un
     111  // softwareXXXX : on fait ici le 'delete'
    109112
    110113  const abstractSoftware* soft = jobList_.at(a)->getSoftware();
    111     if ( soft != NULL ) delete soft;
     114  if ( soft != NULL ) delete soft;
    112115  jobList_.erase (jobList_.begin()+a);
    113116}
     
    151154  abstractSoftware* softw = NULL;
    152155  string workingDir = pspa_->getWorkingDir();
    153   int debut;
    154   int fin;
     156 
    155157  // on verifie la consecution des sections
    156158  int lastel = 0;
    157   for(unsigned k = 0; k < jobList_.size(); k++)
    158     {
    159       if ( jobList_[k]->getElementNumberInSection() != lastel +1 ) {
    160         consoleMessage("dataManager::executeAll ERROR : sections should be consecutive ");
    161         return false;
    162       } else {
    163         lastel = jobList_[k]->getLastElementNumberInSection();
    164       }
    165     }
    166 
    167   for(unsigned k = 0; k < jobList_.size(); k++)
    168     {
    169       cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
     159  for(unsigned k = 0; k < jobList_.size(); k++) {
     160    if ( jobList_[k]->getElementNumberInSection() != lastel +1 ) {
     161      consoleMessage("dataManager::executeAll ERROR : sections should be consecutive ");
     162      return false;
     163    } else {
     164      lastel = jobList_[k]->getLastElementNumberInSection();
     165    }
     166  }
     167
     168  unsigned debut;
     169  unsigned fin;
     170  for(unsigned k = 0; k < jobList_.size(); k++) {
     171    cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
    170172     
    171       debut = jobList_[k]->getElementNumberInSection();
    172       fin = jobList_[k]->getLastElementNumberInSection();
    173       softw = jobList_[k]->getSoftware();
    174      
    175       if (softw == NULL) {
     173    debut = jobList_[k]->getElementNumberInSection();
     174    fin = jobList_[k]->getLastElementNumberInSection();
     175    softw = jobList_[k]->getSoftware();
     176   
     177    if (softw == NULL) {
    176178        success = false;
    177179        consoleMessage("dataManager::executeAll : unknown software");
     
    196198      if ( !success ) break;
    197199     
    198      
    199200      if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut;
    200201      if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin;
     
    203204      cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
    204205      cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
    205       for (int j = debut; j <= fin; j++) {
     206      for (unsigned j = debut; j <= fin; j++) {
    206207        abstractElement* elPtr= getElementPointerFromNumero(j);
    207208        cout << "[" << j << "] " << elPtr->getNomdElement().getExpandedName() << endl;
    208209      }
    209     } //k
     210  } //k
    210211 
    211212  cout << " dataManager::executeAll premier element : " << firstComputedElemNumero_ << " dernier : " << lastComputedElemNumero_ << endl;
    212  
    213213  return success;
    214214}
     
    233233    outfile << globParam_.FileOutputFlow();
    234234    abstractElement* elPtr;
    235     for(unsigned k = 0; k < getBeamLineSize() ; k++)
     235    for(int k = 0; k < getBeamLineSize() ; k++)
    236236    {
    237         elPtr = pspa_->getBeamLine()->getAbstractElement(k);
    238         outfile << elPtr->FileOutputFlow();
     237      elPtr = pspa_->getBeamLine()->getAbstractElement(k);
     238      outfile << elPtr->FileOutputFlow();
    239239    }
    240240    outfile.close();
     241}
     242
     243// ecriture sur fichier AML
     244void dataManager::writeToAMLFile(string fileName)
     245{
     246  UAPNode* uap_root = NULL;
     247  uap_root = new UAPNode("UAP_root");
     248  UAPNode* rep = uap_root->addChild("AML_representation");
     249
     250  // root node in the hierarchy
     251  UAPNode* lab = rep->addChild("laboratory");
     252  lab->addAttribute("name","PSPA lab");
     253
     254  // general global parameters
     255  globParam_.InputRep(lab);
     256
     257  // accelerator or section of accelerator
     258  //UAPNode* acc = lab->addChild("machine");
     259  //acc->addAttribute("name",fileName);
     260
     261  // sequence of elements
     262  UAPNode* sect = lab->addChild("sector");
     263  sect->addAttribute("name","a_sect");
     264
     265  abstractElement* elPtr;
     266  for(int k = 0; k < getBeamLineSize() ; k++) {
     267    elPtr = pspa_->getBeamLine()->getAbstractElement(k);
     268    elPtr->InputRep(sect);
     269  }
     270 
     271  cout << "!Create the AML file ---------------------------" << endl;
     272  AMLReader reader;
     273  string aml_file = pspa_->getWorkingDir() + "/" + fileName + ".aml";
     274  reader.AMLRepToAMLFile (uap_root, aml_file);
    241275}
    242276
Note: See TracChangeset for help on using the changeset viewer.