diff --git a/scripts/load_sine_chan4.py b/scripts/load_sine_chan4.py
index 19447a9d856358217b4b2dbde770fc83f0bdc8e1..b1dbf12e116759f78e850a94490fc8ba073d6942 100644
--- a/scripts/load_sine_chan4.py
+++ b/scripts/load_sine_chan4.py
@@ -28,7 +28,7 @@ try:
 	print ao_data
 
 	#put ao_data in the argin of the command contAO with the channel number
-	argin =(ao_data,["4"])
+	argin =(ao_data,["3"])
 	
 	#load the waveform on the device
 	contAO.SetAOScaledData(argin)
diff --git a/src/RetrigAO.cpp b/src/RetrigAO.cpp
index 86d0475258bdbdc91dc24065bc0547b1419ce30d..f9aebe6f7c2f5c78bd814a83bff161f846363403 100644
--- a/src/RetrigAO.cpp
+++ b/src/RetrigAO.cpp
@@ -1,4 +1,4 @@
-static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/InputOutput/ADLINK/RetrigAO/src/RetrigAO.cpp,v 1.13 2009-09-16 08:10:54 anoureddine Exp $";
+static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/InputOutput/ADLINK/RetrigAO/src/RetrigAO.cpp,v 1.14 2009-09-17 06:59:03 anoureddine Exp $";
 //+=============================================================================
 //
 // file :	  RetrigAO.cpp
@@ -13,9 +13,13 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/InputOutput/AD
 //
 // $Author: anoureddine $
 //
-// $Revision: 1.13 $
+// $Revision: 1.14 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.13  2009/09/16 08:10:54  anoureddine
+// - Transform bufferDepth property into attribute.
+// - Generate code with pogo 5.2.10
+//
 // Revision 1.12  2009/07/31 06:53:51  flanglois
 // - support external sampling (conversionSource)
 //
@@ -192,11 +196,16 @@ void RetrigAO::init_device()
   ch5 = 0;
   ch6 = 0;
   ch7 = 0;
-  bufferDepth = 4096;  
   // Initialise variables to default values
   //--------------------------------------------
   get_device_property();
   
+  //- get the memorized value of bufferDepth (property) and put it into bufferDepth (attribute)
+  Tango::WAttribute &attr_bufferDepth = dev_attr->get_w_attr_by_name("bufferDepth");
+  INFO_STREAM<<"bufferDepth = "<<bufferDepth<<std::endl;
+  attr_bufferDepth.set_write_value(bufferDepth);
+  write_bufferDepth(attr_bufferDepth);
+  
   this->init_board();  
   
 }
@@ -215,6 +224,7 @@ void RetrigAO::get_device_property()
   //------------------------------------------
   boardNum =  0;
   frequency = 50000.0; //50 kHz
+  bufferDepth = 4096;
   
   string default_trig_mode = "POST";
   triggerMode = adl::ao_post;
@@ -279,6 +289,7 @@ void RetrigAO::get_device_property()
 	dev_prop.push_back(Tango::DbDatum("Channel6Enable"));
 	dev_prop.push_back(Tango::DbDatum("Channel7Enable"));
 	dev_prop.push_back(Tango::DbDatum("Delay"));
+	dev_prop.push_back(Tango::DbDatum("BufferDepth"));
 	dev_prop.push_back(Tango::DbDatum("Channel0Waveform"));
 	dev_prop.push_back(Tango::DbDatum("Channel1Waveform"));
 	dev_prop.push_back(Tango::DbDatum("Channel2Waveform"));
@@ -519,6 +530,17 @@ void RetrigAO::get_device_property()
 	//	And try to extract Delay value from database
 	if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  delay;
 
+	//	Try to initialize BufferDepth from class property
+	cl_prop = ds_class->get_class_property(dev_prop[++i].name);
+	if (cl_prop.is_empty()==false)	cl_prop  >>  bufferDepth;
+	else {
+		//	Try to initialize BufferDepth from default device value
+		def_prop = ds_class->get_default_device_property(dev_prop[i].name);
+		if (def_prop.is_empty()==false)	def_prop  >>  bufferDepth;
+	}
+	//	And try to extract BufferDepth value from database
+	if (dev_prop[i].is_empty()==false)	dev_prop[i]  >>  bufferDepth;
+
 	//	Try to initialize Channel0Waveform from class property
 	cl_prop = ds_class->get_class_property(dev_prop[++i].name);
 	if (cl_prop.is_empty()==false)	cl_prop  >>  channel0Waveform;
@@ -980,16 +1002,29 @@ void RetrigAO::get_device_property()
       <<default_delay<<endl;
   }
   //-------------------------------------------------------------
-	if (dev_prop[28].is_empty()==false)
+  if (dev_prop[20].is_empty()==false)
   {
-    dev_prop[28]  >>  filePath;
+    dev_prop[20]  >>  bufferDepth;   
   }
-  
+  else
+  {
+    Tango::DbDatum  property("BufferDepth");
+    property << bufferDepth;
+    data_put.push_back(property);
+    WARN_STREAM<<"BufferDepth property is not set in database, loading default value in database:"
+      <<bufferDepth<<endl;
+  }  
   //-------------------------------------------------------------
 	if (dev_prop[29].is_empty()==false)
+  {
+    dev_prop[29]  >>  filePath;
+  }
+  
+  //-------------------------------------------------------------
+	if (dev_prop[30].is_empty()==false)
     {	
       string conv; 	
-      dev_prop[29]  >>  conv;
+      dev_prop[30]  >>  conv;
         if(conv == "INTERNAL")
             conversionSource = adl::ao_internal_timer;
         else if(conv == "EXTSAMPLING")
@@ -1006,14 +1041,14 @@ void RetrigAO::get_device_property()
         WARN_STREAM<<"ConversionSource property is not set in database, loading default value in database:"<<default_conv_src<<endl;
     }
   //-----------------------attribute persistancy------------------
- /* if (data[21].is_empty()==false)	data[20]  >>  channel0Waveform;
-	if (data[22].is_empty()==false) data[21]  >>  channel1Waveform;
-	if (data[23].is_empty()==false) data[22]  >>  channel2Waveform;
-	if (data[24].is_empty()==false) data[23]  >>  channel3Waveform;
-	if (data[25].is_empty()==false) data[24]  >>  channel4Waveform;
-	if (data[26].is_empty()==false) data[25]  >>  channel5Waveform;
-	if (data[27].is_empty()==false) data[26]  >>  channel6Waveform;
-	if (data[28].is_empty()==false) data[27]  >>  channel7Waveform;*/
+ /* if (data[21].is_empty()==false)	data[21]  >>  channel0Waveform;
+	if (data[22].is_empty()==false) data[22]  >>  channel1Waveform;
+	if (data[23].is_empty()==false) data[23]  >>  channel2Waveform;
+	if (data[24].is_empty()==false) data[24]  >>  channel3Waveform;
+	if (data[25].is_empty()==false) data[25]  >>  channel4Waveform;
+	if (data[26].is_empty()==false) data[26]  >>  channel5Waveform;
+	if (data[27].is_empty()==false) data[27]  >>  channel6Waveform;
+	if (data[28].is_empty()==false) data[28]  >>  channel7Waveform;*/
   
   //update database for not initiliazed properties
   get_db_device()->put_property(data_put);
@@ -1075,6 +1110,7 @@ void RetrigAO::write_bufferDepth(Tango::WAttribute &attr)
 {
 	DEBUG_STREAM << "RetrigAO::write_bufferDepth(Tango::WAttribute &attr) entering... "<< endl;
 	attr.get_write_value(bufferDepth);
+	store_value_as_property(bufferDepth, "BufferDepth");	
 	this->init_board();	
 }
 
@@ -1482,6 +1518,9 @@ void RetrigAO::stop_with_zero_forcing()
     "RetrigAO::stop_with_zero_forcing",
     this->set_internal_state()
     );
+	
+	//correction bug: aftera stop, start doesn't work !!
+	this->init_board();
 }
 
 //+------------------------------------------------------------------
@@ -2271,6 +2310,73 @@ void RetrigAO::load_waveform(double* waveform, string wfm_channel)
   INFO_STREAM << "Data retrieved"<<wfm_channel<<" in file "<<file_name<< endl;
 }
 
+/*-------------------------------------------------------------------------
+/       store_value_as_property : template
+/-------------------------------------------------------------------------*/
+template <class T>
+void RetrigAO::store_value_as_property (T value, string property_name)
+{
+	Tango::DbDatum current_value(property_name);
+	current_value << value;
+	Tango::DbData db_data;
+	db_data.push_back(current_value);
+	try
+	{
+		get_db_device()->put_property(db_data);
+	}
+	catch(Tango::DevFailed &e)
+	{
+		string message= "Error in storing " + property_name + " in Configuration DataBase ";
+		LOG_ERROR((message));
+		Tango::Except::print_exception(e);
+	}
+}
+
+////////////////////////////////////////////////////////////////////////////
+///       create_property_if_empty : DbData
+///////////////////////////////////////////////////////////////////////////
+template <class T>
+void RetrigAO::create_property_if_empty(Tango::DbData& dev_prop,T value,string property_name)
+{
+	int iPropertyIndex = FindIndexFromPropertyName(dev_prop,property_name);
+	if (iPropertyIndex == -1) return;
+	if (dev_prop[iPropertyIndex].is_empty())
+	{
+		Tango::DbDatum current_value(dev_prop[iPropertyIndex].name);
+		current_value << value;
+		Tango::DbData db_data;
+		db_data.push_back(current_value);
+		
+		try
+		{
+			get_db_device()->put_property(db_data);
+		}
+		catch(Tango::DevFailed &e)
+		{
+			string message= "Error in storing " + property_name + " in Configuration DataBase ";
+			LOG_ERROR((message));
+			Tango::Except::print_exception(e);
+		}
+	}
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+///       FindIndexFromPropertyName : used in create_property_if_empty
+///////////////////////////////////////////////////////////////////////////
+int RetrigAO::FindIndexFromPropertyName(Tango::DbData& dev_prop, string property_name)
+{
+	size_t iNbProperties = dev_prop.size();
+	unsigned int i;
+	for (i=0;i<iNbProperties;i++)
+	{
+		std::string sPropertyName(dev_prop[i].name);
+		if (sPropertyName == property_name) return i;
+	}
+	if (i == iNbProperties) return -1;
+	return i;
+}
+