Index: Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc
===================================================================
--- Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc	(revision 419)
+++ Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc	(revision 424)
@@ -5,5 +5,5 @@
 #include "softwareTransport.h"
 #include "GWt_pspaApplication.h"
-#include "GWt_console.h"Ã
+#include "GWt_console.h"
 #include "softwareGenerator.h"
 #include "softwareTest.h"
@@ -12,4 +12,7 @@
 #include <stdio.h>
 #include <fstream>
+
+#include "UAP/UAPUtilities.hpp"
+#include "AML/AMLReader.hpp"
 
 dataManager::dataManager(PspaApplication* pspa) :
@@ -102,12 +105,12 @@
 void dataManager::clearSectionToExecute(int a) {
   cout << " dataManager::clearSectionToExecute efaacement section d'index : " << a << endl;
-  if (a<0) return;
-  if (a>= jobList_.size()) return;
-
-  // lors de la creation de la section on a fait un 'new' d'un softwareXXXX
-  // on fait ici le 'delete'
+  if (a < 0) return;
+  if (a >= (int)jobList_.size()) return;
+
+  // lors de la creation de la section on a fait un 'new' d'un 
+  // softwareXXXX : on fait ici le 'delete'
 
   const abstractSoftware* soft = jobList_.at(a)->getSoftware();
-    if ( soft != NULL ) delete soft;
+  if ( soft != NULL ) delete soft;
   jobList_.erase (jobList_.begin()+a);
 }
@@ -151,27 +154,26 @@
   abstractSoftware* softw = NULL;
   string workingDir = pspa_->getWorkingDir();
-  int debut;
-  int fin;
+ 
   // on verifie la consecution des sections
   int lastel = 0;
-  for(unsigned k = 0; k < jobList_.size(); k++)
-    {
-      if ( jobList_[k]->getElementNumberInSection() != lastel +1 ) {
-        consoleMessage("dataManager::executeAll ERROR : sections should be consecutive ");
-	return false;
-      } else {
-	lastel = jobList_[k]->getLastElementNumberInSection();
-      }
-    }
-
-  for(unsigned k = 0; k < jobList_.size(); k++)
-    {
-      cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
+  for(unsigned k = 0; k < jobList_.size(); k++) {
+    if ( jobList_[k]->getElementNumberInSection() != lastel +1 ) {
+      consoleMessage("dataManager::executeAll ERROR : sections should be consecutive ");
+      return false;
+    } else {
+      lastel = jobList_[k]->getLastElementNumberInSection();
+    }
+  }
+
+  unsigned debut;
+  unsigned fin;
+  for(unsigned k = 0; k < jobList_.size(); k++) {
+    cout << " dataManager::executeAll je m'apprete a executer : " << (jobList_[k]->getSoftware()->getName()) << endl;
       
-      debut = jobList_[k]->getElementNumberInSection();
-      fin = jobList_[k]->getLastElementNumberInSection();
-      softw = jobList_[k]->getSoftware();
-      
-      if (softw == NULL) {
+    debut = jobList_[k]->getElementNumberInSection();
+    fin = jobList_[k]->getLastElementNumberInSection();
+    softw = jobList_[k]->getSoftware();
+    
+    if (softw == NULL) {
         success = false;
         consoleMessage("dataManager::executeAll : unknown software");
@@ -196,5 +198,4 @@
       if ( !success ) break;
       
-      
       if ( debut < firstComputedElemNumero_ ) firstComputedElemNumero_ = debut;
       if ( fin > lastComputedElemNumero_ ) lastComputedElemNumero_ = fin;
@@ -203,12 +204,11 @@
       cout << "dataManager::executeAll #diagnosticBeam= " << diagnosticBeam_.size() << endl;
       cout << "dataManager::executeAll #getBeamLineSize()= " << getBeamLineSize() << endl;
-      for (int j = debut; j <= fin; j++) {
+      for (unsigned j = debut; j <= fin; j++) {
 	abstractElement* elPtr= getElementPointerFromNumero(j);
 	cout << "[" << j << "] " << elPtr->getNomdElement().getExpandedName() << endl;
       }
-    } //k
+  } //k
   
   cout << " dataManager::executeAll premier element : " << firstComputedElemNumero_ << " dernier : " << lastComputedElemNumero_ << endl;
-  
   return success;
 }
@@ -233,10 +233,44 @@
     outfile << globParam_.FileOutputFlow();
     abstractElement* elPtr;
-    for(unsigned k = 0; k < getBeamLineSize() ; k++)
+    for(int k = 0; k < getBeamLineSize() ; k++)
     {
-        elPtr = pspa_->getBeamLine()->getAbstractElement(k);
-        outfile << elPtr->FileOutputFlow();
+      elPtr = pspa_->getBeamLine()->getAbstractElement(k);
+      outfile << elPtr->FileOutputFlow();
     }
     outfile.close();
+}
+
+// ecriture sur fichier AML
+void dataManager::writeToAMLFile(string fileName)
+{
+  UAPNode* uap_root = NULL;
+  uap_root = new UAPNode("UAP_root");
+  UAPNode* rep = uap_root->addChild("AML_representation");
+
+  // root node in the hierarchy
+  UAPNode* lab = rep->addChild("laboratory");
+  lab->addAttribute("name","PSPA lab");
+
+  // general global parameters
+  globParam_.InputRep(lab);
+
+  // accelerator or section of accelerator
+  //UAPNode* acc = lab->addChild("machine");
+  //acc->addAttribute("name",fileName);
+
+  // sequence of elements
+  UAPNode* sect = lab->addChild("sector");
+  sect->addAttribute("name","a_sect");
+
+  abstractElement* elPtr;
+  for(int k = 0; k < getBeamLineSize() ; k++) {
+    elPtr = pspa_->getBeamLine()->getAbstractElement(k);
+    elPtr->InputRep(sect);
+  }
+  
+  cout << "!Create the AML file ---------------------------" << endl;
+  AMLReader reader;
+  string aml_file = pspa_->getWorkingDir() + "/" + fileName + ".aml";
+  reader.AMLRepToAMLFile (uap_root, aml_file);
 }
 
