diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h
index a8fac2ce28313815715be72e49dcef5de4d26c12..134b7f30a441e9d40e778718e177e90391e1e35f 100644
--- a/include/AbstractElectrometerClass.h
+++ b/include/AbstractElectrometerClass.h
@@ -9,9 +9,15 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.10 $
+// $Revision: 1.11 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.10  2008/04/15 12:51:59  xavela
+// xavier :
+// - SRQ management changed :
+// * ReadStatusByteRegister method added
+// * IsSrqLineUP added
+//
 // Revision 1.9  2008/02/15 10:17:55  xavela
 // xavier :
 // - command abort added for SCPI Keithleys
@@ -131,14 +137,14 @@ public:
 	virtual void set_triggercount	(short trigcounts);
 	void set_triggerdelay	(std::string trigdelay);
 	void set_triggerdelayAuto	(std::string trigdelAuto);
-	void set_averagecount	    (std::string avercounts);
-	void set_averagecontrol	  (std::string averctrl);
+	virtual void set_averagecount	    (std::string avercounts);
+	virtual void set_averagecontrol	  (std::string averctrl);
 	std::string get_knplc			    (void);
 	std::string get_triggercount	(void);
 	std::string get_triggerdelay	(void);
 	std::string get_triggerdelayAuto(void);
-	std::string get_averagecount	(void);
-	std::string get_averagecontrol(void);
+	virtual std::string get_averagecount	(void);
+	virtual std::string get_averagecontrol(void);
 	virtual void clear_buffer				      (void);
 	virtual void store_raw_input			    (void);
 	virtual void start_storing				    (void);
diff --git a/include/KeithleySCPIProtocol.h b/include/KeithleySCPIProtocol.h
index 46e6a7cbbe0b163da66f368d679c6ee72d1dd21c..acb7ae77dd93018bcaeb899abba63739f6843d1a 100644
--- a/include/KeithleySCPIProtocol.h
+++ b/include/KeithleySCPIProtocol.h
@@ -103,6 +103,15 @@ public:
 	std::string get_averagecount	  (void);
 	std::string get_averagecontrol	(void);
   void read_data_with_no_timestamp(void);
+	/**
+	*  \brief K_6517 specifics commands
+	*/
+  std::string get_averagecount_K6517  (void);
+  void set_averagecount_K6517         (std::string averageCountStr);
+  std::string get_averagecontrol_K6517(void);
+  void set_averagecontrol_K6517       (std::string nbAverTCtrl);
+	void averageStateON_K6517			      (void);
+	void averageStateOFF_K6517		      (void);
 	/**
 	*  \brief Electrometer : Buffer config
 	*/
diff --git a/include/Keithley_6485.h b/include/Keithley_6485.h
index 23a1b5ea04a7ee5cc9ff477a1bd949cc9bfb01f4..a42829aaef05d144f9d4b78b080ee8030eaecebb 100644
--- a/include/Keithley_6485.h
+++ b/include/Keithley_6485.h
@@ -67,8 +67,8 @@ private:
 	//- method to obtain the range index
 	void update_range (void);
 	
-  float  _numPLC;
-  short  _trigCounts;
+  double  _numPLC;
+  int  _trigCounts;
 };
 
 /** @} */	//- end addtogroup
diff --git a/include/Keithley_6487.h b/include/Keithley_6487.h
index 1e5f09481c765790c5ad05e30807be0ff5c0f802..7b4c13de7f6fece6ebc33edfbb4958ff2e5f917b 100644
--- a/include/Keithley_6487.h
+++ b/include/Keithley_6487.h
@@ -72,8 +72,8 @@ private:
 	//- method to obtain the range index
 	void update_range (void);
 	
-  float  _numPLC;
-  short  _trigCounts;
+  double  _numPLC;
+  int  _trigCounts;
 };
 
 /** @} */	//- end addtogroup
diff --git a/include/Keithley_6514.h b/include/Keithley_6514.h
index 3c74d9dce103924cc301c92de368a362da1b38f5..1b2c73b7d3c02ddf2a85c55cd0d67c212ee3f6a1 100644
--- a/include/Keithley_6514.h
+++ b/include/Keithley_6514.h
@@ -76,8 +76,8 @@ private:
 	void update_range (void);
 	std::string _kmode;
 	
-  float  _numPLC;
-  short  _trigCounts;
+  double  _numPLC;
+  int  _trigCounts;
 	
 };
 
diff --git a/include/Keithley_6517.h b/include/Keithley_6517.h
index 833a99278227529f6fdf8b278ef35781534c1b25..c2610cdb7f6e2f2469ec04aee11e1cb153b11a7c 100644
--- a/include/Keithley_6517.h
+++ b/include/Keithley_6517.h
@@ -45,7 +45,7 @@ public:
 	/**
 	*  \brief Device dependent commands.
 	*/
-	void range_up (void);
+	void range_up   (void);
 	void range_down (void);
 	
 	std::vector<double> get_integratedValue (void);
@@ -53,11 +53,31 @@ public:
 	/**
 	*  \brief Electrometer Mode.
 	*/
-	void setAmperMeterMode (void);
-	void setVoltMeterMode (void);
-	void setOhmMeterMode (void);
-	void setCoulombMeterMode (void);
+	void setAmperMeterMode  (void);
+	void setVoltMeterMode   (void);
+	void setOhmMeterMode    (void);
+	void setCoulombMeterMode(void);
 
+	/**
+	*  \brief Specifics commands.
+	*/
+  std::string get_averagecount  (void);
+  void set_averagecount         (std::string nbAvCntStr);
+  std::string get_averagecontrol(void);
+  void set_averagecontrol       (std::string nbAverTCtrl);
+  void averageStateON           (void);
+  void averageStateOFF          (void);
+	/**
+	*  \brief Methods to configure the integration mode.
+	*/
+  void set_knplc        (float);
+  void set_triggercount (short);
+  void set_buffer_size  (short);
+	void init_keithley		(void); 
+	/**
+	*  \brief The integration time (sec).
+	*/
+	void set_integrationTime			(double);
 	//-	TODO :
 	//	SCPI_Filters*	_ddcFilters;
 	//	SCPI_Triggers*	_ddcTriggers;
@@ -65,6 +85,8 @@ private:
 	//- method to obtain the range index
 	void update_range (void);
 	std::string _kmode;
+  double  _numPLC;
+  int  _trigCounts;
 	
 };
 
diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp
index 978449206450569a5ed088ec9e112fd43eca28bb..b00792d7a8ada55133d13d5f8692c055d9afcfbe 100644
--- a/src/AbstractElectrometerClass.cpp
+++ b/src/AbstractElectrometerClass.cpp
@@ -11,9 +11,15 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.11 $
+// $Revision: 1.12 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.11  2008/04/15 12:52:14  xavela
+// xavier :
+// - SRQ management changed :
+// * ReadStatusByteRegister method added
+// * IsSrqLineUP added
+//
 // Revision 1.10  2008/02/15 10:17:57  xavela
 // xavier :
 // - command abort added for SCPI Keithleys
@@ -419,6 +425,8 @@ std::string AbstractElectrometerClass::electrometer_status (void)
 		//- if no error the error code is 0
 		if( XString<short>::convertFromString(&argout[0]) != ON)
 			set_electroState(ALARM);
+    else
+      set_electroState(ON);
 	}
 	catch(...)
 	{
diff --git a/src/KeithleySCPIProtocol.cpp b/src/KeithleySCPIProtocol.cpp
index 0ed5eb565ec752e6edf89c9286be4a53e0b801f6..a661f496c128af13639e8304ea6c63f319a542e0 100644
--- a/src/KeithleySCPIProtocol.cpp
+++ b/src/KeithleySCPIProtocol.cpp
@@ -590,16 +590,27 @@ std::string cmd_to_send("");
 void KeithleySCPIProtocol::set_averagecount (std::string nbAverageCount) 
 {
 std::string cmd_to_send("");
-std::string tmpMode;
+	
+	//- send command
+	cmd_to_send = "AVER:COUN " + nbAverageCount;
+	_communication_link->write(cmd_to_send);
+}
+
+// ============================================================================
+// KeithleySCPIProtocol::set_averagecount
+// ============================================================================
+void KeithleySCPIProtocol::set_averagecount_K6517 (std::string cmd_to_send) 
+{
+std::string tmpMode("");
 	
 	//- get electrometer mode
-//	tmpMode = get_mode( );
+	tmpMode = get_mode( );
 
 	//- erase bad caracters
-//	tmpMode.erase(tmpMode.find("\n") );
+	tmpMode.erase(tmpMode.find("\n") );
 	
 	//- send command
-	cmd_to_send = "AVER:COUN " + nbAverageCount;
+	cmd_to_send = tmpMode + ":AVER:COUN " + cmd_to_send ;
 	_communication_link->write(cmd_to_send);
 }
 
@@ -608,17 +619,29 @@ std::string tmpMode;
 // ============================================================================
 std::string KeithleySCPIProtocol::get_averagecount (void) 
 {
+std::string cmd_to_send("");
+	
+	//- send command
+	cmd_to_send = "AVER:COUNt?" ;
+	return _communication_link->write_read(cmd_to_send);
+}
+
+// ============================================================================
+// KeithleySCPIProtocol::get_averagecount
+// ============================================================================
+std::string KeithleySCPIProtocol::get_averagecount_K6517 (void) 
+{
 std::string cmd_to_send("");
 std::string tmpMode;
 	
 	//- get electrometer mode
-//	tmpMode = get_mode( );
+	tmpMode = get_mode( );
 
 	//- erase bad caracters
-//	tmpMode.erase(tmpMode.find("\n") );
+	tmpMode.erase(tmpMode.find("\n") );
 	
 	//- send command
-	cmd_to_send = "AVER:COUNt?" ;
+	cmd_to_send = tmpMode + ":AVER:COUNt?" ;
 	return _communication_link->write_read(cmd_to_send);
 }
 
@@ -628,7 +651,7 @@ std::string tmpMode;
 void KeithleySCPIProtocol::set_averagecontrol (std::string nbAverageControl) 
 {
 std::string cmd_to_send("");
-std::string tmpMode;
+std::string tmpMode("");
 	
 	//- get electrometer mode
 //	tmpMode = get_mode( );
@@ -638,13 +661,32 @@ std::string tmpMode;
 	_communication_link->write(cmd_to_send);
 }
 
+// ============================================================================
+// KeithleySCPIProtocol::set_averagecontrol
+// ============================================================================
+void KeithleySCPIProtocol::set_averagecontrol_K6517 (std::string nbAverageControl) 
+{
+std::string cmd_to_send("");
+std::string tmpMode("");
+	
+	//- get electrometer mode
+	tmpMode = get_mode( );
+
+	//- erase bad caracters
+	tmpMode.erase(tmpMode.find("\n") );
+	
+	//- send command
+	cmd_to_send = tmpMode + ":AVER:TCON " + nbAverageControl;
+	_communication_link->write(cmd_to_send);
+}
+
 // ============================================================================
 // KeithleySCPIProtocol::get_averagecontrol
 // ============================================================================
 std::string KeithleySCPIProtocol::get_averagecontrol (void) 
 {
 std::string cmd_to_send("");
-std::string tmpMode;
+std::string tmpMode("");
 	
 	//- get electrometer mode
 //	tmpMode = get_mode( );
@@ -654,6 +696,25 @@ std::string tmpMode;
 	return _communication_link->write_read(cmd_to_send);
 }
 
+// ============================================================================
+// KeithleySCPIProtocol::get_averagecount
+// ============================================================================
+std::string KeithleySCPIProtocol::get_averagecontrol_K6517 (void) 
+{
+std::string cmd_to_send("");
+std::string tmpMode("");
+	
+	//- get electrometer mode
+	tmpMode = get_mode( );
+
+	//- erase bad caracters
+	tmpMode.erase(tmpMode.find("\n") );
+	
+	//- send command
+	cmd_to_send = tmpMode + ":AVER:TCONtrol?" ;
+	return _communication_link->write_read(cmd_to_send);
+}
+
 // ============================================================================
 // KeithleySCPIProtocol::clear_registers
 // ============================================================================
@@ -679,6 +740,25 @@ std::string cmd_to_send("");
 	_communication_link->write(cmd_to_send);
 }
 
+// ============================================================================
+// KeithleySCPIProtocol::averageStateON_K6517
+// ============================================================================
+void KeithleySCPIProtocol::averageStateON_K6517 (void) 
+{
+std::string cmd_to_send("");
+std::string tmpMode("");
+	
+	//- get electrometer mode
+	tmpMode = get_mode( );
+
+	//- erase bad caracters
+	tmpMode.erase(tmpMode.find("\n") );
+	
+	//- send command
+	cmd_to_send = tmpMode + ":AVER ON" ;
+	_communication_link->write(cmd_to_send);
+}
+
 // ============================================================================
 // KeithleySCPIProtocol::averageStateOFF
 // ============================================================================
@@ -691,6 +771,25 @@ std::string cmd_to_send("");
 	_communication_link->write(cmd_to_send);
 }
 
+// ============================================================================
+// KeithleySCPIProtocol::averageStateOFF_K6517
+// ============================================================================
+void KeithleySCPIProtocol::averageStateOFF_K6517 (void) 
+{
+std::string cmd_to_send("");
+std::string tmpMode("");
+	
+	//- get electrometer mode
+	tmpMode = get_mode( );
+
+	//- erase bad caracters
+	tmpMode.erase(tmpMode.find("\n") );
+	
+	//- send command
+	cmd_to_send = tmpMode + ":AVER OFF" ;
+	_communication_link->write(cmd_to_send);
+}
+
 // ============================================================================
 // KeithleySCPIProtocol::reset
 // ============================================================================
diff --git a/src/Keithley_6517.cpp b/src/Keithley_6517.cpp
index 87016394d25c772c8f8fdcba9b4130edc9bb71e3..502999bdd8aa12a4e13bd9d5dbba949b43e11c76 100644
--- a/src/Keithley_6517.cpp
+++ b/src/Keithley_6517.cpp
@@ -18,6 +18,7 @@ static long KEITHLEY_MODEL = 6517;
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <math.h>   //- for ceil
 #include <Xstring.h>
 #include "Keithley_6517.h"
 #include "KeithleySCPIProtocol.h"
@@ -236,7 +237,7 @@ void Keithley_6517::setCoulombMeterMode (void)
 }
 
 // ============================================================================
-// Keithley_6487::update_range
+// Keithley_6517::update_range
 // ============================================================================
 void Keithley_6517::update_range (void) 
 {
@@ -317,3 +318,188 @@ double delta = 0;
 	//- update the range with the index found
 	this->_range = idx;
 }
+
+// ============================================================================
+// Keithley_6517::get_averagecount
+// ============================================================================
+std::string Keithley_6517::get_averagecount (void) 
+{
+  std::string averCountStr("");
+
+	//- this model needs to prefix this command with the current mode
+	KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol);
+	if(_kscpi)
+		averCountStr = _kscpi->get_averagecount_K6517();
+
+  return averCountStr;
+}
+
+// ============================================================================
+// Keithley_6517::set_averagecount
+// ============================================================================
+void Keithley_6517::set_averagecount (std::string nbAverCountStr) 
+{
+	//- this model needs to prefix this command with the current mode
+	KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol);
+	if(_kscpi)
+		_kscpi->set_averagecount_K6517(nbAverCountStr);
+
+}
+
+// ============================================================================
+// Keithley_6517::get_averagecontrol
+// ============================================================================
+std::string Keithley_6517::get_averagecontrol (void) 
+{
+  std::string nbAverCtrlStr("");
+
+	//- this model needs to prefix this command with the current mode
+	KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol);
+	if(_kscpi)
+		nbAverCtrlStr = _kscpi->get_averagecontrol_K6517();
+
+  return nbAverCtrlStr;
+}
+
+// ============================================================================
+// Keithley_6517::set_averagecontrol
+// ============================================================================
+void Keithley_6517::set_averagecontrol (std::string nbAverCtrlStr) 
+{
+	//- this model needs to prefix this command with the current mode
+	KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol);
+	if(_kscpi)
+		_kscpi->set_averagecontrol_K6517(nbAverCtrlStr);
+}
+
+// ============================================================================
+// Keithley_6517::averageStateON
+// ============================================================================
+void Keithley_6517::averageStateON (void) 
+{
+	//- this model needs to prefix this command with the current mode
+	KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol);
+	if(_kscpi)
+		_kscpi->averageStateON_K6517();
+}
+
+// ============================================================================
+// Keithley_6517::averageStateOFF
+// ============================================================================
+void Keithley_6517::averageStateOFF (void) 
+{
+	//- this model needs to prefix this command with the current mode
+	KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol);
+	if(_kscpi)
+		_kscpi->averageStateOFF_K6517();
+}
+
+// ============================================================================
+// Keithley_6517::set_knplc
+// ============================================================================
+void Keithley_6517::set_knplc (float numPLC) 
+{
+std::stringstream cmd_to_send;
+
+  if(numPLC <= 0 || numPLC > 10.0)
+	{
+//    std::cout << "Keithley_6517::set_knplc -> " << numPLC << std::endl;
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Invalid number of PLC.\n Please enter a value in the range 0.01 to 10.0.",
+												"Keithley_6517::set_knplc( ).");
+	}
+  //- just for internal use
+  _numPLC = numPLC;
+
+  cmd_to_send << numPLC << std::endl;
+  //- default conversion rate
+  _electrometerProtocol->set_knplc(cmd_to_send.str());
+}  
+
+// ============================================================================
+// Keithley_6517::set_triggercount
+// ============================================================================
+void Keithley_6517::set_triggercount (short trigCounts) 
+{
+std::stringstream cmd_to_send;
+
+  if(trigCounts == 0 || trigCounts > 99999)
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Invalid trigger count.\n Please enter a value in the range 1 to 99999 or set -1 for INFinite.",
+												"Keithley_6517::set_triggercount( ).");
+	}
+  if(trigCounts < 0)
+    cmd_to_send << "INF" << std::endl;
+  else
+    cmd_to_send << trigCounts << std::endl;
+
+  //- just for internal use
+  _trigCounts = trigCounts;
+  //- default conversion rate
+  _electrometerProtocol->set_triggercount(cmd_to_send.str());
+}  
+
+// ============================================================================
+// Keithley_6517::set_buffer_size
+// ============================================================================
+void Keithley_6517::set_buffer_size (short size) 
+{
+std::stringstream cmd_to_send;
+
+  if(size < 1 || size > 10000)
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Invalid buffer size. \nPlease enter a value in the range 1 to 10000.",
+												"Keithley_6517::set_buffer_size( ).");
+	}
+  //- just for internal use
+  _size = size;
+
+  cmd_to_send << size << std::endl;
+  //- default conversion rate
+  _electrometerProtocol->set_buffer_size(cmd_to_send.str());
+}  
+
+// ============================================================================
+// Keithley_6517::set_integrationTime
+// ============================================================================
+void Keithley_6517::set_integrationTime (double seconds) 
+{
+  //- set the number of Power Line Cycle(s) -> Fast integration
+  _numPLC = 0.05;
+  //- set the number of trigger(s) ~ buffer size
+  _trigCounts = (short)ceil(seconds / _numPLC);
+
+  if(_trigCounts > 99999)
+    _trigCounts = 99999;
+}
+
+// ============================================================================
+// Keithley_6517::init_keithley : command to perform an integration cycle
+// ============================================================================
+void Keithley_6517::init_keithley (void) 
+{
+  //- clear all registers
+  _electrometerProtocol->clear_registers();
+  //- get data only (no timestamp info ... wanted!)
+  _electrometerProtocol->read_data_with_no_timestamp();
+  //- Set integration rate in line cycles
+  this->set_knplc(_numPLC);
+  //- Set trigger model to take to N readings
+  this->set_triggercount(_trigCounts);
+  //- Set buffer size
+  this->set_buffer_size(_size);
+  //- clear previous data
+  _electrometerProtocol->clear_buffer();
+  //- Store raw input
+//  _electrometerProtocol->store_raw_input();
+  //- Start storing on next reading
+  _electrometerProtocol->start_storing();
+  //- Enable SRQ on buffer full
+  _electrometerProtocol->enable_SRQBufferFull();
+  //- Trigger readings
+  _electrometerProtocol->init_keithley();
+}
+
+