From d8c411da26757c000e3727a599bcef586d2ec716 Mon Sep 17 00:00:00 2001
From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr>
Date: Tue, 3 Jul 2012 06:15:53 +0000
Subject: [PATCH] Novelec part : bug at init fixed.

---
 include/AbstractElectrometerClass.h |  15 ++--
 include/CommunicationLink.h         |  13 +++-
 include/TangoSerialLink.h           |  25 +++----
 pom.xml                             |   2 +-
 src/AbstractElectrometerClass.cpp   |  26 ++++++-
 src/ElectrometerProtocol.cpp        |   4 +-
 src/NovelecProtocol.cpp             | 103 ++++++++++++++++++----------
 src/TangoSerialLink.cpp             |  12 ++--
 8 files changed, 133 insertions(+), 67 deletions(-)

diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h
index 7d3ca01..44005f6 100644
--- a/include/AbstractElectrometerClass.h
+++ b/include/AbstractElectrometerClass.h
@@ -9,9 +9,12 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.21 $
+// $Revision: 1.22 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.21  2011/03/14 14:42:22  xavela
+// SaveRestoreConfiguration command added. (Available only for SCPI Keithley devices)
+//
 // Revision 1.20  2010/06/10 14:36:15  xavela
 // cmd switch_off called before any parameters modifications and then locked with switch_on.
 //
@@ -137,6 +140,8 @@ public:
 	*/
 	virtual ~AbstractElectrometerClass (void);
 
+	AbstractElectrometerClass& operator= (const AbstractElectrometerClass& src);
+
 	/**
 	*  \brief Electrometer common functions.
 	*/
@@ -210,7 +215,7 @@ public:
 	virtual void set_triggerMode			(short);
 	virtual void set_integrationTime	(double);
 	virtual short get_buffer_size			(void);
-	virtual short get_triggerMode			(void) { return _trigMod;};
+	virtual short get_triggerMode			(void) { return _trigMod;}
 
 	/**
 	*  \brief  VSource operations (only for K_6517)
@@ -281,9 +286,9 @@ protected :
 	
 	ElectroState electrometerState;
 	
-	void set_electroState(ElectroState newState) { electrometerState = newState; };
+	void set_electroState(ElectroState newState) { electrometerState = newState; }
 
-	short					_range;
+	short			_range;
 	std::string		_rangeStr;
 	std::string		_mode;
 	std::string		_device_proxy_name;
@@ -295,7 +300,7 @@ protected :
 private :
 
 public :
-	ElectroState electrometer_state	(void) { return electrometerState; };
+	ElectroState electrometer_state	(void) { return electrometerState; }
 
 };
 
diff --git a/include/CommunicationLink.h b/include/CommunicationLink.h
index 3378330..76b06ec 100644
--- a/include/CommunicationLink.h
+++ b/include/CommunicationLink.h
@@ -12,9 +12,12 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.6 $
+// $Revision: 1.7 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.6  2010/06/10 14:36:15  xavela
+// cmd switch_off called before any parameters modifications and then locked with switch_on.
+//
 // Revision 1.5  2008/04/15 12:51:59  xavela
 // xavier :
 // - SRQ management changed :
@@ -102,6 +105,14 @@ public :
 	*/
 	virtual std::string write_read(std::string cmd_to_send) = 0;
 
+	/**
+	*  \brief Performs a write read operation as string.
+	*
+	*  \throws Tango::DevFailed
+	*/
+	virtual std::string write_read (std::string command_to_send, long nbChar) {};
+
+
 	/**
 	*  \brief Returns the Gpib SRQ line state : used here to know if Keithley 
   *           device is ready after an integration cycle.
diff --git a/include/TangoSerialLink.h b/include/TangoSerialLink.h
index 59a5f8c..d7c998f 100644
--- a/include/TangoSerialLink.h
+++ b/include/TangoSerialLink.h
@@ -37,14 +37,24 @@ class TangoSerialLink : public CommunicationLink
 {
 	
 public :
+ 	/**
+	* \brief Initialization. 
+	*/
+	TangoSerialLink (std::string& serial_device_name);
+	
+	/**	
+	* \brief Release resources.
+	*/
+	~TangoSerialLink ();
+
   /**
   * \brief One MCCE-2 can manage two differents electrometers
   *   through only one serial line !
   *
   */
-  static TangoSerialLink* get_instance(std::string& serial_device_name);
+  //static TangoSerialLink* get_instance(std::string& serial_device_name);
 
-  static void delete_instance(CommunicationLink*);
+  //static void delete_instance(CommunicationLink*);
 	
 	/**
 	*  \brief Send command (data) as string to hardware.
@@ -82,20 +92,11 @@ public :
 	std::string write_read(std::string cmd, long nbChar)  throw (Tango::DevFailed);
 
 private :
- 	/**
-	* \brief Initialization. 
-	*/
-	TangoSerialLink (std::string& serial_device_name);
-	
-	/**	
-	* \brief Release resources.
-	*/
-	~TangoSerialLink ();
 
 	/**	
 	* \brief Tango Serial Link instance.
 	*/
-  static TangoSerialLink* tsl_Instance;
+  //static TangoSerialLink* tsl_Instance;
 
   /**
 	* Creates a proxy on the specified Serial Device.
diff --git a/pom.xml b/pom.xml
index 45c9c7d..412d274 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
    </parent>
    <groupId>fr.soleil.lib</groupId>
    <artifactId>Electrometers-${aol}-${library}-${mode}</artifactId>
-   <version>2.5.5</version>
+   <version>2.5.6</version>
    <packaging>nar</packaging>
    <name>Electrometers library</name>
    <description>Electrometers library</description>
diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp
index 4542651..bd807ff 100644
--- a/src/AbstractElectrometerClass.cpp
+++ b/src/AbstractElectrometerClass.cpp
@@ -11,9 +11,12 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.23 $
+// $Revision: 1.24 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.23  2011/03/14 14:42:22  xavela
+// SaveRestoreConfiguration command added. (Available only for SCPI Keithley devices)
+//
 // Revision 1.22  2010/06/10 14:36:15  xavela
 // cmd switch_off called before any parameters modifications and then locked with switch_on.
 //
@@ -156,7 +159,7 @@ AbstractElectrometerClass::AbstractElectrometerClass (std::string comLink_device
 // ============================================================================
 AbstractElectrometerClass::~AbstractElectrometerClass (void)
 {
-//	std::cout << "AbstractElectrometerClass::~AbstractElectrometerClass <-" << std::endl;
+	std::cout << "AbstractElectrometerClass::~AbstractElectrometerClass <-" << std::endl;
 
 	if(_electrometerProtocol)
 	{
@@ -164,9 +167,26 @@ AbstractElectrometerClass::~AbstractElectrometerClass (void)
 		_electrometerProtocol = 0;
 	}
 
-//	std::cout << "AbstractElectrometerClass::~AbstractElectrometerClass ->" << std::endl;
+	std::cout << "AbstractElectrometerClass::~AbstractElectrometerClass ->" << std::endl;
 }
 
+// ============================================================================
+// AbstractElectrometerClass::operator=
+// ============================================================================
+AbstractElectrometerClass& AbstractElectrometerClass::operator= (const AbstractElectrometerClass& src) 
+{
+  //- no self assign
+  if (this == &src) {
+    return *this;
+  }
+
+  this->_device_proxy_name	  = src._device_proxy_name;
+  this->_electrometerProtocol = src._electrometerProtocol;
+
+  return *this;
+}
+
+
 // ============================================================================
 // AbstractElectrometerClass::zero_check_on
 // ============================================================================
diff --git a/src/ElectrometerProtocol.cpp b/src/ElectrometerProtocol.cpp
index 6ab7355..de748c3 100644
--- a/src/ElectrometerProtocol.cpp
+++ b/src/ElectrometerProtocol.cpp
@@ -37,7 +37,7 @@ ElectrometerProtocol::ElectrometerProtocol () :
 // ============================================================================
 ElectrometerProtocol::~ElectrometerProtocol (void)
 {
-	//std::cout << "ElectrometerProtocol::~ElectrometerProtocol <-" << std::endl;
+	std::cout << "ElectrometerProtocol::~ElectrometerProtocol <-" << std::endl;
 
 	if(_communication_link)
 	{
@@ -45,7 +45,7 @@ ElectrometerProtocol::~ElectrometerProtocol (void)
 		_communication_link = 0;
 	}
 
-	//std::cout << "ElectrometerProtocol::~ElectrometerProtocol ->" << std::endl;
+	std::cout << "ElectrometerProtocol::~ElectrometerProtocol ->" << std::endl;
 }
 
 // ============================================================================
diff --git a/src/NovelecProtocol.cpp b/src/NovelecProtocol.cpp
index 62a7c47..572cea9 100644
--- a/src/NovelecProtocol.cpp
+++ b/src/NovelecProtocol.cpp
@@ -42,7 +42,7 @@ static const short	CLEAR_ERRORS_CMD_NUM  = 18;
 static const long	PILOTAGE_AND_PROG_RESP_LGTH = 10;
 static const long	READ_DATA_RESP_LGTH = 24;
 //- the specific new line character
-static const string	END_OF_LINE = "\r\n";
+static const char	END_OF_LINE[] = "\r\n";
 //- modes allowed
 static const std::string mode_str[]		= {"ERR : UNKNOWN MODE","ZERO V/F","OFFSET","LEAKAGE","TEST","MEASURE"};
 static const std::string range_str[5][8]= {	{"1e-11AcC","3e-11AcC","1e-10AcC","3e-10AcC", "OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"},
@@ -76,9 +76,13 @@ NovelecProtocol::NovelecProtocol (std::string& serial_device_name, unsigned shor
 // ============================================================================
 NovelecProtocol::~NovelecProtocol (void)
 {
-//	std::cout << "NovelecProtocol::~NovelecProtocol <-" << std::endl;
-  TangoSerialLink::delete_instance(_communication_link);
-//	std::cout << "NovelecProtocol::~NovelecProtocol ->" << std::endl;
+	std::cout << "NovelecProtocol::~NovelecProtocol <-" << std::endl;
+if ( this->_communication_link )
+{
+  delete _communication_link;
+  this->_communication_link = 0;
+}
+	std::cout << "NovelecProtocol::~NovelecProtocol ->" << std::endl;
 }
 
 // ============================================================================
@@ -89,14 +93,15 @@ bool NovelecProtocol::build_communicationLink()
   if (_commDevName.empty())
     return false;
 
-  _communication_link = TangoSerialLink::get_instance(_commDevName);
+  _communication_link = new TangoSerialLink(_commDevName);
 
   if (!_communication_link)
     return false;
+std::cout << "NovelecProtocol::build_communicationLink => " << _communication_link << std::endl;
 
-  this->_tgSerLk = dynamic_cast<TangoSerialLink*>(_communication_link);
-  if ( !_tgSerLk )
-	  return false;
+//  this->_tgSerLk = dynamic_cast<TangoSerialLink*>(_communication_link);
+//  if ( !_tgSerLk )
+//	  return false;
 
   return true;
 }
@@ -109,22 +114,23 @@ void NovelecProtocol::init_MCCE2_for_communication(void)
 std::stringstream explicite_resp;
 std::string tmp("no data");
 
-//std::cout << "NovelecProtocol::init_MCCE2_for_communication -> _devAdd = " << _devAdd << std::endl;
+std::cout << "NovelecProtocol::init_MCCE2_for_communication -> _devAdd = " << _devAdd << std::endl;
 	//- CMD to enable PROG cmds
 	this->switch_MCCE2_OFF();  //- this command is now called in the MCCE2 device !
-//std::cout << "NovelecProtocol::init_MCCE2_for_communication -> switch_MCCE2_OFF" << std::endl;
+std::cout << "NovelecProtocol::init_MCCE2_for_communication -> switch_MCCE2_OFF" << std::endl;
 	//- Clear error registers
 	this->clear_registers();
-//std::cout << "NovelecProtocol::init_MCCE2_for_communication -> clear_registers" << std::endl;
+std::cout << "NovelecProtocol::init_MCCE2_for_communication -> clear_registers" << std::endl;
 
 	//- send cmd to have an explicite response :
 	explicite_resp << _devAdd << " PROG " << RESPONSE_LGTH_CMD_NUM << " 1" << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(explicite_resp.str(), PILOTAGE_AND_PROG_RESP_LGTH);
-//std::cout << "NovelecProtocol::init_MCCE2_for_communication -> write_read" /* << std::endl */;
+//	tmp = this->_tgSerLk->write_read(explicite_resp.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(explicite_resp.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+std::cout << "NovelecProtocol::init_MCCE2_for_communication -> write_read" << std::endl;
 
 	//- check only the command response
 	check_command(tmp);
-//std::cout << "NovelecProtocol::init_MCCE2_for_communication -> check_command" /* << std::endl */;
+std::cout << "NovelecProtocol::init_MCCE2_for_communication -> check_command" << std::endl;
 
 	//- if no error
 	_is_explicite_resp_enabled = true;
@@ -140,7 +146,8 @@ std::string tmp("no data");
 
 	//- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " MEASURE 1 " << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	
   //- check only the command response
 	check_command(tmp);
@@ -159,7 +166,8 @@ std::string tmp("no data");
 	//- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " MEASURE 0 " << END_OF_LINE /* << std::endl */;
 
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 
   //- check only the command response
 	check_command(tmp);
@@ -178,7 +186,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << MODE_CMD_NUM << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, MODE_CMD_NUM);
@@ -218,7 +227,8 @@ short cmd_num = 13;				//- default value for DEBUG !!!
 			std::cout << "\t\t***WARN : Current mode : \"" << get_mode() << "\" has no value available." << std::endl;
 
 	cmd_to_send << _devAdd << " READ " << cmd_num << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 	//- check only the command response
 	value = check_and_extract_data(tmp, cmd_num);
 
@@ -241,7 +251,8 @@ std::string tmp("no data");
 
   //- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- check only the command response
 	check_command(tmp);
 
@@ -265,7 +276,8 @@ std::string tmp("no data");
 	this->switch_MCCE2_OFF();
 	//- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- check only the command response
 	check_command(tmp);
 	//- lock parameters modification
@@ -288,7 +300,8 @@ std::string tmp("no data");
 	this->switch_MCCE2_OFF();
 	//- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- check only the command response
 	check_command(tmp);
 	
@@ -313,7 +326,8 @@ std::string tmp("no data");
 
 	//- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- check only the command response
 	check_command(tmp);
 	//- lock parameters modification
@@ -336,7 +350,8 @@ std::string tmp("no data");
 	this->switch_MCCE2_OFF();
 	//- send cmd to have a explicite response :
 	cmd_to_send << _devAdd << " PROG 1 " << cmdNumber << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- check only the command response
 	check_command(tmp);
 	//- lock parameters modification
@@ -354,7 +369,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << RANGE_CMD_NUM << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 //std::cout << "NovelecProtocol::get_range -> range brut : " << tmp /* << std::endl */;
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, RANGE_CMD_NUM);
@@ -387,7 +403,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " PROG " << _rangeParameterNum << " " << value << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- the novelec device send ACK/NAK response after a received command
 	check_command(tmp);
 	//- lock parameters modification
@@ -405,7 +422,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << POLARITY_CMD_NUM << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, POLARITY_CMD_NUM);
 
@@ -438,7 +456,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " PROG 2" << " " << newPolarity << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- the novelec device send ACK/NAK response after a received command
 	check_command(tmp);
 	
@@ -457,7 +476,8 @@ std::string tmp("");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << FREQUENCY_CMD_NUM << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 	
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, FREQUENCY_CMD_NUM);
@@ -488,7 +508,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " PROG 9" << " " << newFrequency << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	//- the novelec device send ACK/NAK response after a received command
 	check_command(tmp);
 	
@@ -507,7 +528,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << GAIN_CMD_NUM << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, GAIN_CMD_NUM);
 
@@ -539,7 +561,8 @@ std::string tmp("no data");
 	this->switch_MCCE2_OFF();
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " PROG 8" << " " << newGain << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 
 	//- the novelec device send ACK/NAK response after a received command
 	check_command(tmp);
@@ -559,7 +582,8 @@ std::string tmp("no data");
 //std::cout << "NovelecProtocol::get_errors ..." << std::endl;
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << ERRORS_CMD_NUM << END_OF_LINE /*<< std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 //std::cout << "NovelecProtocol::write_read -> \"" << tmp << "\"" << std::endl;
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, ERRORS_CMD_NUM);
@@ -579,7 +603,8 @@ std::string tmp("no data");
 
 	//- send command to Novelec device
 	cmd_to_send << _devAdd << " READ " << ELECTROTYPE_CMD_NUM << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 	//- check and extract the response
 	argout = check_and_extract_data(tmp, ELECTROTYPE_CMD_NUM);
 
@@ -618,7 +643,8 @@ std::string tmp("no data");
 	this->switch_MCCE2_OFF();
 	//- send command
 	cmd_to_send << _devAdd << " LOCAL" << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	
 	//- check the response
 	check_command(tmp);
@@ -641,7 +667,8 @@ std::string tmp("no data");
 	this->switch_MCCE2_OFF();
 	//- send command
 	cmd_to_send << _devAdd << " REMOTE" << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	
 	//- check the response
 	check_command(tmp);
@@ -664,7 +691,8 @@ std::string tmp("no data");
 //std::cout << "NovelecProtocol::cmd_to_send -> \"" << cmd_to_send.str() << "\"" << std::endl;
 try
 {
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), READ_DATA_RESP_LGTH);
 }
 catch(Tango::DevFailed& df)
 {
@@ -695,7 +723,8 @@ std::string tmp("no data");
 	
 	//- send command
 	cmd_to_send << _devAdd << " PROG " << CLEAR_ERRORS_CMD_NUM << " 1 " << END_OF_LINE /* << std::endl */;
-	tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	//tmp = this->_tgSerLk->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
+	tmp = this->_communication_link->write_read(cmd_to_send.str(), PILOTAGE_AND_PROG_RESP_LGTH);
 	
 	//- check the response
 	check_command(tmp);
diff --git a/src/TangoSerialLink.cpp b/src/TangoSerialLink.cpp
index 70a64ef..094b760 100644
--- a/src/TangoSerialLink.cpp
+++ b/src/TangoSerialLink.cpp
@@ -22,12 +22,12 @@
 
 static const long MODE_LINE = 2;
 //- init of the static instance
-TangoSerialLink* TangoSerialLink::tsl_Instance = 0;	//- ptr on the TangoSerialLink instance
+//TangoSerialLink* TangoSerialLink::tsl_Instance = 0;	//- ptr on the TangoSerialLink instance
 
 // ============================================================================
 // TangoSerialLink::get_instance
 // ============================================================================
-TangoSerialLink* TangoSerialLink::get_instance(std::string & serial_dev_name)
+/*TangoSerialLink* TangoSerialLink::get_instance(std::string & serial_dev_name)
 {
 	if( !tsl_Instance )
 		tsl_Instance = new TangoSerialLink(serial_dev_name);
@@ -45,7 +45,7 @@ void TangoSerialLink::delete_instance(CommunicationLink* tsl_Instance)
 		delete tsl_Instance ;
 		tsl_Instance = 0;
 	}
-}
+}*/
 
 // ============================================================================
 // TangoSerialLink::TangoSerialLink
@@ -67,7 +67,7 @@ TangoSerialLink::TangoSerialLink (std::string& serial_device_name)
 // ============================================================================
 TangoSerialLink::~TangoSerialLink (void)
 {
-	//std::cout << "TangoSerialLink::~TangoSerialLink <-" << std::endl;
+	std::cout << "TangoSerialLink::~TangoSerialLink <-" << std::endl;
 
 	if(_serial_proxy)
 	{
@@ -76,7 +76,7 @@ TangoSerialLink::~TangoSerialLink (void)
 		_is_serial_proxy_created = false;
 	}
 
-	//std::cout << "TangoSerialLink::~TangoSerialLink ->" << std::endl;
+	std::cout << "TangoSerialLink::~TangoSerialLink ->" << std::endl;
 }
 
 
@@ -317,7 +317,7 @@ std::string TangoSerialLink::write_read (std::string command_to_send, long nbCha
 	write(command_to_send);
 
 	//- sleep a little bit to let the adapter(RS232/485) to switch mode
-	//omni_thread::sleep(0, 100000000); //100 milliseconds
+	omni_thread::sleep(0, 100000000); //100 milliseconds
 
 	//- wait till characters are available in the input buffer (max 30 retries !)
 	size_t nbRetries = 0;
-- 
GitLab