From f7a4f1aeab62d9a1f6bdb6c155b21f930460ac2d Mon Sep 17 00:00:00 2001
From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr>
Date: Mon, 14 Mar 2011 14:42:22 +0000
Subject: [PATCH] SaveRestoreConfiguration command added. (Available only for
 SCPI Keithley devices)

---
 include/AbstractElectrometerClass.h | 12 +++++++++++-
 include/ElectrometerProtocol.h      | 12 +++++++++++-
 include/KeithleySCPIProtocol.h      |  7 +++++++
 include/Keithley_6485.h             |  6 ++++++
 include/Keithley_6487.h             |  6 ++++++
 include/Keithley_6514.h             |  6 ++++++
 include/Keithley_6517.h             |  6 ++++++
 pom.xml                             |  2 +-
 src/AbstractElectrometerClass.cpp   | 21 ++++++++++++++++++++-
 src/ElectrometerProtocol.cpp        | 20 ++++++++++++++++++++
 src/KeithleySCPIProtocol.cpp        | 23 +++++++++++++++++++++++
 src/Keithley_6485.cpp               | 29 +++++++++++++++++++++++++++++
 src/Keithley_6487.cpp               | 29 +++++++++++++++++++++++++++++
 src/Keithley_6514.cpp               | 29 +++++++++++++++++++++++++++++
 src/Keithley_6517.cpp               | 28 ++++++++++++++++++++++++++++
 15 files changed, 232 insertions(+), 4 deletions(-)

diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h
index dd148e8..7d3ca01 100644
--- a/include/AbstractElectrometerClass.h
+++ b/include/AbstractElectrometerClass.h
@@ -9,9 +9,12 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.20 $
+// $Revision: 1.21 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.20  2010/06/10 14:36:15  xavela
+// cmd switch_off called before any parameters modifications and then locked with switch_on.
+//
 // Revision 1.19  2010/03/17 11:57:04  xavela
 // VSource control added !
 //
@@ -144,6 +147,13 @@ public:
   virtual void local		(void);
   virtual void remote		(void);
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*		NOTE : only available fro SCPI devices
+	*/
+	virtual void save_configuration(unsigned short memoryIdx);
+	virtual void restore_configuration(unsigned short memoryIdx);
+
 	/**
 	*  \brief Electrometer : cmd to get electrometer data.
 	*/
diff --git a/include/ElectrometerProtocol.h b/include/ElectrometerProtocol.h
index ed90be3..663ef37 100644
--- a/include/ElectrometerProtocol.h
+++ b/include/ElectrometerProtocol.h
@@ -12,9 +12,12 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.13 $
+// $Revision: 1.14 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.13  2010/06/10 14:36:15  xavela
+// cmd switch_off called before any parameters modifications and then locked with switch_on.
+//
 // Revision 1.12  2009/10/14 15:26:17  xavela
 // KeithleyMemory leak fixed.
 // Novelec part updated
@@ -116,6 +119,13 @@ public:
   */
   virtual bool build_communicationLink() = 0;
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*		NOTE : only available fro SCPI devices
+	*/
+	virtual void save_configuration(unsigned short memoryIdx);
+	virtual void restore_configuration(unsigned short memoryIdx);
+
 	/**
 	*  \brief Common Electrometer Functions.
 	*/
diff --git a/include/KeithleySCPIProtocol.h b/include/KeithleySCPIProtocol.h
index 3f36f9a..3ccc5f5 100644
--- a/include/KeithleySCPIProtocol.h
+++ b/include/KeithleySCPIProtocol.h
@@ -49,6 +49,13 @@ public:
 	*/
   bool build_communicationLink();
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*		NOTE : only available fro SCPI devices
+	*/
+	void save_configuration(unsigned short memoryIdx);
+	void restore_configuration(unsigned short memoryIdx);
+
 	/**
 	*  \brief Electrometer Functions.
 	*/
diff --git a/include/Keithley_6485.h b/include/Keithley_6485.h
index a02dfeb..6bc5be6 100644
--- a/include/Keithley_6485.h
+++ b/include/Keithley_6485.h
@@ -47,6 +47,12 @@ public:
 	*/
   bool init_protocol (void);
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*/
+	void save_configuration(unsigned short memoryIdx);
+	void restore_configuration(unsigned short memoryIdx);
+
   std::vector<double> get_integratedValue (void);
 	std::vector<double> get_fetchValue      (void);
 	/**
diff --git a/include/Keithley_6487.h b/include/Keithley_6487.h
index 255aa49..6713834 100644
--- a/include/Keithley_6487.h
+++ b/include/Keithley_6487.h
@@ -47,6 +47,12 @@ public:
 	*/
   bool init_protocol (void);
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*/
+	void save_configuration(unsigned short memoryIdx);
+	void restore_configuration(unsigned short memoryIdx);
+
 	/**
 	*  \brief Device dependent commands.
 	*/
diff --git a/include/Keithley_6514.h b/include/Keithley_6514.h
index 6211165..b86225e 100644
--- a/include/Keithley_6514.h
+++ b/include/Keithley_6514.h
@@ -47,6 +47,12 @@ public:
 	*/
   bool init_protocol (void);
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*/
+	void save_configuration(unsigned short memoryIdx);
+	void restore_configuration(unsigned short memoryIdx);
+
 	/**
 	*  \brief Device dependent commands.
 	*/
diff --git a/include/Keithley_6517.h b/include/Keithley_6517.h
index 0c8d22a..3fcb861 100644
--- a/include/Keithley_6517.h
+++ b/include/Keithley_6517.h
@@ -47,6 +47,12 @@ public:
 	*/
   bool init_protocol (void);
 
+	/**
+	*  \brief Functions to save/restore specifics configuration.
+	*/
+	void save_configuration(unsigned short memoryIdx);
+	void restore_configuration(unsigned short memoryIdx);
+
 	/**
 	*  \brief Device dependent commands.
 	*/
diff --git a/pom.xml b/pom.xml
index 9e7dc57..fd7bbb7 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.2-SNAPSHOT</version>
+   <version>2.5.2</version>
    <packaging>nar</packaging>
    <name>Electrometers library</name>
    <description>Electrometers library</description>
diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp
index 518722a..4542651 100644
--- a/src/AbstractElectrometerClass.cpp
+++ b/src/AbstractElectrometerClass.cpp
@@ -11,9 +11,12 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.22 $
+// $Revision: 1.23 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.22  2010/06/10 14:36:15  xavela
+// cmd switch_off called before any parameters modifications and then locked with switch_on.
+//
 // Revision 1.21  2010/03/17 11:57:03  xavela
 // VSource control added !
 //
@@ -811,3 +814,19 @@ unsigned short AbstractElectrometerClass::get_ElectroChannel (void)
 	return _electrometerProtocol->get_electrometer_active_channel();
 }
 
+// ============================================================================
+// AbstractElectrometerClass::save_configuration
+// ============================================================================
+void AbstractElectrometerClass::save_configuration (unsigned short memoryIdx) 
+{
+	_electrometerProtocol->save_configuration(memoryIdx);
+}
+
+// ============================================================================
+// AbstractElectrometerClass::restore_configuration
+// ============================================================================
+void AbstractElectrometerClass::restore_configuration (unsigned short memoryIdx) 
+{
+	_electrometerProtocol->restore_configuration(memoryIdx);
+}
+
diff --git a/src/ElectrometerProtocol.cpp b/src/ElectrometerProtocol.cpp
index 63e9ac3..6ab7355 100644
--- a/src/ElectrometerProtocol.cpp
+++ b/src/ElectrometerProtocol.cpp
@@ -740,3 +740,23 @@ unsigned short ElectrometerProtocol::get_electrometer_active_channel (void)
 											"ElectrometerProtocol::get_electrometer_active_channel( ).");
 }
 
+// ============================================================================
+// ElectrometerProtocol::save_configuration
+// ============================================================================
+void ElectrometerProtocol::save_configuration (unsigned short) 
+{
+	throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
+											"This Electrometer does not support this command.",
+											"ElectrometerProtocol::save_configuration( ).");
+}
+
+// ============================================================================
+// ElectrometerProtocol::restore_configuration
+// ============================================================================
+void ElectrometerProtocol::restore_configuration (unsigned short) 
+{
+	throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
+											"This Electrometer does not support this command.",
+											"ElectrometerProtocol::restore_configuration( ).");
+}
+
diff --git a/src/KeithleySCPIProtocol.cpp b/src/KeithleySCPIProtocol.cpp
index 6b3be01..a9e3a31 100644
--- a/src/KeithleySCPIProtocol.cpp
+++ b/src/KeithleySCPIProtocol.cpp
@@ -950,7 +950,30 @@ std::string cmd_to_send("TRAC:FEED:CONT NEXT");
 
 	//- send command : Start storing readings
 	_communication_link->write(cmd_to_send);
+}
 
+// ============================================================================
+// KeithleySCPIProtocol::save_configuration
+// ============================================================================
+void KeithleySCPIProtocol::save_configuration (unsigned short memoryIdx) 
+{
+std::stringstream cmd_to_send;
+
+	//- send command
+  cmd_to_send << "*SAV " << memoryIdx << std::endl;
+	_communication_link->write(cmd_to_send.str());
+}
+
+// ============================================================================
+// KeithleySCPIProtocol::restore_configuration
+// ============================================================================
+void KeithleySCPIProtocol::restore_configuration (unsigned short memoryIdx) 
+{
+std::stringstream cmd_to_send;
+
+	//- send command
+  cmd_to_send << "*RCL " << memoryIdx << std::endl;
+	_communication_link->write(cmd_to_send.str());
 }
 
 // ============================================================================
diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp
index e379ec1..1ad4069 100644
--- a/src/Keithley_6485.cpp
+++ b/src/Keithley_6485.cpp
@@ -30,6 +30,8 @@ static const std::string K6485_rangeValue[] = {"2E-9","2E-8","2E-7","2E-6","2E-5
 */
 static const short K6485_rangeLimit = 7;
 
+static const unsigned short MAX_SAVED_CONFIG = 2;
+
 // ============================================================================
 // Keithley_6485::Keithley_6485
 // ============================================================================
@@ -324,3 +326,30 @@ void Keithley_6485::init_keithley (void)
   _electrometerProtocol->init_keithley();
 }
 
+// ============================================================================
+// Keithley_6485::save_configuration
+// ============================================================================
+void Keithley_6485::save_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6485::save_configuration( ).");
+	}
+	_electrometerProtocol->save_configuration(memoryIdx);
+}
+
+// ============================================================================
+// Keithley_6485::restore_configuration
+// ============================================================================
+void Keithley_6485::restore_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6485::restore_configuration( ).");
+	}
+	_electrometerProtocol->restore_configuration(memoryIdx);
+}
diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp
index 2d99965..f1fe59c 100644
--- a/src/Keithley_6487.cpp
+++ b/src/Keithley_6487.cpp
@@ -30,6 +30,8 @@ static const std::string K6487_rangeValue[8] = {"2E-2","2E-3","2E-4","2E-5","2E-
 */
 static const short K6487_rangeLimit = 7;
 
+static const unsigned short MAX_SAVED_CONFIG = 2;
+
 // ============================================================================
 // Keithley_6487::Keithley_6487
 // ============================================================================
@@ -326,3 +328,30 @@ void Keithley_6487::init_keithley (void)
   _electrometerProtocol->init_keithley();
 }
 
+// ============================================================================
+// Keithley_6487::save_configuration
+// ============================================================================
+void Keithley_6487::save_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6487::save_configuration( ).");
+	}
+	_electrometerProtocol->save_configuration(memoryIdx);
+}
+
+// ============================================================================
+// Keithley_6487::restore_configuration
+// ============================================================================
+void Keithley_6487::restore_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6487::restore_configuration( ).");
+	}
+	_electrometerProtocol->restore_configuration(memoryIdx);
+}
diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp
index f5b4363..87fd2b2 100644
--- a/src/Keithley_6514.cpp
+++ b/src/Keithley_6514.cpp
@@ -37,6 +37,8 @@ static const short K6514_VOLT_rangeLimit= 2;
 static const short K6514_OHM_rangeLimit = 8;
 static const short K6514_COU_rangeLimit = 3;
 
+static const unsigned short MAX_SAVED_CONFIG = 2;
+
 /*
 * Trigger Mode limit (millisec)
 */
@@ -452,3 +454,30 @@ void Keithley_6514::init_keithley (void)
   _electrometerProtocol->init_keithley();
 }
 
+// ============================================================================
+// Keithley_6514::save_configuration
+// ============================================================================
+void Keithley_6514::save_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6514::save_configuration( ).");
+	}
+	_electrometerProtocol->save_configuration(memoryIdx);
+}
+
+// ============================================================================
+// Keithley_6514::restore_configuration
+// ============================================================================
+void Keithley_6514::restore_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6514::restore_configuration( ).");
+	}
+	_electrometerProtocol->restore_configuration(memoryIdx);
+}
diff --git a/src/Keithley_6517.cpp b/src/Keithley_6517.cpp
index aa2f2bc..d0abba2 100644
--- a/src/Keithley_6517.cpp
+++ b/src/Keithley_6517.cpp
@@ -36,6 +36,8 @@ static const short K6517_VOLT_rangeLimit= 2;
 static const short K6517_OHM_rangeLimit = 9;
 static const short K6517_COU_rangeLimit = 3;
 
+static const unsigned short MAX_SAVED_CONFIG = 9;
+
 // ============================================================================
 // Keithley_6517::Keithley_6517
 // ============================================================================
@@ -595,4 +597,30 @@ void Keithley_6517::auto_zero_off (void)
 		"Keithley_6517::auto_zero_off( ).");
 }
 
+// ============================================================================
+// Keithley_6517::save_configuration
+// ============================================================================
+void Keithley_6517::save_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-2].",
+												"Keithley_6487::save_configuration( ).");
+	}
+	_electrometerProtocol->save_configuration(memoryIdx);
+}
 
+// ============================================================================
+// Keithley_6517::restore_configuration
+// ============================================================================
+void Keithley_6517::restore_configuration (unsigned short memoryIdx) 
+{
+  if( memoryIdx > MAX_SAVED_CONFIG )
+	{
+		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
+												"Index of saved configuration must be in the range [0-9].",
+												"Keithley_6517::restore_configuration( ).");
+	}
+	_electrometerProtocol->restore_configuration(memoryIdx);
+}
-- 
GitLab