From 36e5eeacc950d44d85b9594da333aa8ca9123849 Mon Sep 17 00:00:00 2001
From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr>
Date: Fri, 15 Feb 2008 08:49:51 +0000
Subject: [PATCH] xavier : - minor change for integration time

---
 include/AbstractElectrometerClass.h |  8 +++++++-
 include/ElectrometerProtocol.h      | 11 +++++++++--
 include/KeithleyDDCProtocol.h       |  1 +
 include/KeithleySCPIProtocol.h      |  1 +
 include/Keithley_486.h              |  6 ++++++
 include/Keithley_487.h              |  6 ++++++
 include/Keithley_6485.h             |  5 +++++
 include/Keithley_6487.h             |  5 +++++
 include/Keithley_6514.h             |  5 +++++
 src/AbstractElectrometerClass.cpp   | 17 ++++++++++++++++-
 src/ElectrometerProtocol.cpp        | 10 ++++++++++
 src/KeithleySCPIProtocol.cpp        | 12 ++++++++++++
 src/Keithley_486.cpp                | 17 +++++++++++++++++
 src/Keithley_487.cpp                | 16 ++++++++++++++++
 src/Keithley_6485.cpp               | 15 +++++++++++++++
 src/Keithley_6487.cpp               | 15 +++++++++++++++
 src/Keithley_6514.cpp               | 20 ++++++++++++++++++++
 17 files changed, 166 insertions(+), 4 deletions(-)

diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h
index 2e20027..e4d946c 100644
--- a/include/AbstractElectrometerClass.h
+++ b/include/AbstractElectrometerClass.h
@@ -9,9 +9,14 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.6 $
+// $Revision: 1.7 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.6  2008/02/13 15:51:44  xavela
+// xavier :
+// - Integration Mode available for DDC/SCPI devices
+// - tests done with a K617 (DDC) and a K6485 (SCPI)
+//
 // Revision 1.5  2008/02/11 16:55:04  xavela
 // xavier : for DDC part
 // - integration mode OK (tests done with K_486)
@@ -131,6 +136,7 @@ public:
 	virtual void set_buffer_size			    (short);
 	virtual void set_triggerMode			    (short);
 	virtual void set_integrationTime			(double);
+	virtual short get_buffer_size			    (void);
 
 	/**
 	*  \brief Novelec Electrometer methods
diff --git a/include/ElectrometerProtocol.h b/include/ElectrometerProtocol.h
index 68b1802..98414a6 100644
--- a/include/ElectrometerProtocol.h
+++ b/include/ElectrometerProtocol.h
@@ -12,9 +12,14 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.5 $
+// $Revision: 1.6 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.5  2008/02/13 15:51:44  xavela
+// xavier :
+// - Integration Mode available for DDC/SCPI devices
+// - tests done with a K617 (DDC) and a K6485 (SCPI)
+//
 // Revision 1.4  2008/02/11 16:55:04  xavela
 // xavier : for DDC part
 // - integration mode OK (tests done with K_486)
@@ -138,7 +143,7 @@ public:
   virtual void set_buffer_size		(std::string size);
   virtual void clear_buffer		    (void);
   virtual void store_raw_input		(void);
-  virtual void start_storing		(void);
+  virtual void start_storing		  (void);
   virtual void enable_SRQBufferFull	(void);
   virtual void disable_SRQBufferFull(void);
 
@@ -150,6 +155,8 @@ public:
   virtual void enable_readingsFromBuffer_K486_487 (void);
   virtual void read_data_with_no_timestamp        (void);
 
+	virtual std::string get_buffer_size			        (void);
+
   //- only for K_486 and K_487 devices
   virtual void enable_integrationPeriod           (void);
 
diff --git a/include/KeithleyDDCProtocol.h b/include/KeithleyDDCProtocol.h
index 9a43a6b..2c7777c 100644
--- a/include/KeithleyDDCProtocol.h
+++ b/include/KeithleyDDCProtocol.h
@@ -109,6 +109,7 @@ public:
   void enable_readingsFromBuffer_K486_487 (void);
   //- only for K_486 and K_487 devices
   void enable_integrationPeriod           (void);
+
 	
   
   
diff --git a/include/KeithleySCPIProtocol.h b/include/KeithleySCPIProtocol.h
index 6f4ea1c..5158fdd 100644
--- a/include/KeithleySCPIProtocol.h
+++ b/include/KeithleySCPIProtocol.h
@@ -111,6 +111,7 @@ public:
   void enable_SRQBufferFull		(void);
   void disable_SRQBufferFull	(void);
 
+  std::string get_buffer_size	(void);
 
 	/**
 	*  \brief Get Raw Electrometer Status.
diff --git a/include/Keithley_486.h b/include/Keithley_486.h
index e2719a6..6bdc48f 100644
--- a/include/Keithley_486.h
+++ b/include/Keithley_486.h
@@ -51,7 +51,13 @@ public:
   void set_buffer_size(short);
   void set_triggerMode(short);
 	void init_keithley		(void); 
+  short get_buffer_size (void) { return _size; };
 	
+	/**
+	*  \brief The integration time (sec).
+	*/
+	void set_integrationTime			(double);
+
 	/**
 	*  \brief getter(s) & setter(s)	
 	*/
diff --git a/include/Keithley_487.h b/include/Keithley_487.h
index b27ca3e..75ec182 100644
--- a/include/Keithley_487.h
+++ b/include/Keithley_487.h
@@ -51,6 +51,7 @@ public:
   void set_buffer_size(short);
   void set_triggerMode(short);
 	void init_keithley		(void); 
+  short get_buffer_size (void) { return _size; };
 
   /**
 	*  \brief Electrometer Function(s).
@@ -63,6 +64,11 @@ public:
 	std::string get_ElectroMeterMode(void);
 	std::string get_ElectroMeterRange(void);
 	
+	/**
+	*  \brief The integration time (sec).
+	*/
+	void set_integrationTime			(double);
+
 	/**
 	*  \brief Electrometer status.
 	*/
diff --git a/include/Keithley_6485.h b/include/Keithley_6485.h
index 8456b93..23a1b5e 100644
--- a/include/Keithley_6485.h
+++ b/include/Keithley_6485.h
@@ -44,6 +44,11 @@ public:
 
   std::vector<double> get_integratedValue (void);
 	std::vector<double> get_fetchValue      (void);
+	/**
+	*  \brief The integration time (sec).
+	*/
+	void set_integrationTime			(double);
+
 	/**
 	*  \brief Device dependent commands.
 	*/
diff --git a/include/Keithley_6487.h b/include/Keithley_6487.h
index a134038..1e5f094 100644
--- a/include/Keithley_6487.h
+++ b/include/Keithley_6487.h
@@ -50,6 +50,11 @@ public:
 	
   std::vector<double> get_integratedValue (void);
 	std::vector<double> get_fetchValue      (void);
+	/**
+	*  \brief The integration time (sec).
+	*/
+	void set_integrationTime			(double);
+
 	/**
 	*  \brief Electrometer Mode.
 	*/
diff --git a/include/Keithley_6514.h b/include/Keithley_6514.h
index 9155249..3c74d9d 100644
--- a/include/Keithley_6514.h
+++ b/include/Keithley_6514.h
@@ -50,6 +50,11 @@ public:
 	
 	std::vector<double> get_integratedValue (void);
 	std::vector<double> get_fetchValue      (void);
+	/**
+	*  \brief The integration time (sec).
+	*/
+	void set_integrationTime			(double);
+
 	/**
 	*  \brief Electrometer Mode.
 	*/
diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp
index 2f25c41..19bd750 100644
--- a/src/AbstractElectrometerClass.cpp
+++ b/src/AbstractElectrometerClass.cpp
@@ -11,9 +11,14 @@
 //
 // $Author: xavela $
 //
-// $Revision: 1.7 $
+// $Revision: 1.8 $
 //
 // $Log: not supported by cvs2svn $
+// Revision 1.7  2008/02/13 15:51:43  xavela
+// xavier :
+// - Integration Mode available for DDC/SCPI devices
+// - tests done with a K617 (DDC) and a K6485 (SCPI)
+//
 // Revision 1.6  2008/02/11 16:55:04  xavela
 // xavier : for DDC part
 // - integration mode OK (tests done with K_486)
@@ -416,6 +421,16 @@ void AbstractElectrometerClass::set_buffer_size (short size)
 
 }
 
+// ============================================================================
+// AbstractElectrometerClass::get_buffer_size
+// ============================================================================
+short AbstractElectrometerClass::get_buffer_size () 
+{
+  std::string size = _electrometerProtocol->get_buffer_size();
+  
+  return XString<short>::convertFromString(size);
+}
+
 // ============================================================================
 // AbstractElectrometerClass::set_integrationTime
 // ============================================================================
diff --git a/src/ElectrometerProtocol.cpp b/src/ElectrometerProtocol.cpp
index 074172d..4e52171 100644
--- a/src/ElectrometerProtocol.cpp
+++ b/src/ElectrometerProtocol.cpp
@@ -530,6 +530,16 @@ void ElectrometerProtocol::set_buffer_size (std::string)
 											"ElectrometerProtocol::set_buffer_size( ).");
 }
 
+// ============================================================================
+// ElectrometerProtocol::get_buffer_size
+// ============================================================================
+std::string ElectrometerProtocol::get_buffer_size () 
+{
+	throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", 
+											"This Electrometer does not support this command.",
+											"ElectrometerProtocol::get_buffer_size( ).");
+}
+
 // ============================================================================
 // ElectrometerProtocol::clear_buffer
 // ============================================================================
diff --git a/src/KeithleySCPIProtocol.cpp b/src/KeithleySCPIProtocol.cpp
index 7906ad7..d2c3c17 100644
--- a/src/KeithleySCPIProtocol.cpp
+++ b/src/KeithleySCPIProtocol.cpp
@@ -722,6 +722,18 @@ std::string cmd_to_send("");
 
 }
 
+// ============================================================================
+// KeithleySCPIProtocol::get_buffer_size()
+// ============================================================================
+std::string KeithleySCPIProtocol::get_buffer_size ( ) 
+{
+std::string cmd_to_send("TRAC:POIN:ACTual?");
+
+	//- send command :
+	return _communication_link->write_read(cmd_to_send);
+
+}
+
 // ============================================================================
 // KeithleySCPIProtocol::clear_buffer()
 // ============================================================================
diff --git a/src/Keithley_486.cpp b/src/Keithley_486.cpp
index 289cce9..979a572 100644
--- a/src/Keithley_486.cpp
+++ b/src/Keithley_486.cpp
@@ -19,6 +19,7 @@ static long KEITHLEY_MODEL = 486;
 #include <stdexcept>
 #include <sstream>
 #include <string>
+#include <math.h>   //- for ceil
 #include <Xstring.h>
 #include "Keithley_486.h"
 #include "KeithleyDDCProtocol.h"
@@ -36,6 +37,11 @@ static short K486_rangeLimit = 8;
 */
 static short K486_triggerModeLimit = 7;
 
+/*
+* Trigger Mode limit (millisec)
+*/
+static int K486_conversionRate = 360;
+
 // ============================================================================
 // Keithley_486::Keithley_486
 // ============================================================================
@@ -175,6 +181,17 @@ void Keithley_486::set_triggerMode (short trigMod)
 
 }
 
+// ============================================================================
+// Keithley_487::set_integrationTime
+// ============================================================================
+void Keithley_486::set_integrationTime (double seconds) 
+{
+  double msSeconds = seconds / 1000;
+
+  //- _size set in init_keithley()
+  _size = (int)ceil(msSeconds / K486_conversionRate);
+}
+
 // ============================================================================
 // Keithley_486::init_keithley : command to perform an integration cycle
 // ============================================================================
diff --git a/src/Keithley_487.cpp b/src/Keithley_487.cpp
index 0c66e55..e577dad 100644
--- a/src/Keithley_487.cpp
+++ b/src/Keithley_487.cpp
@@ -19,6 +19,7 @@ static long KEITHLEY_MODEL = 487;
 #include <stdexcept>
 #include <sstream>
 #include <string>
+#include <math.h>   //- for ceil
 #include <Xstring.h>
 #include "Keithley_487.h"
 #include "KeithleyDDCProtocol.h"
@@ -36,6 +37,10 @@ static short K487_rangeLimit = 8;
 */
 static short K487_triggerModeLimit = 9;
 
+/*
+* Trigger Mode limit (millisec)
+*/
+static int K487_conversionRate = 360;
 
 // ============================================================================
 // Keithley_487::Keithley_487
@@ -155,6 +160,17 @@ std::stringstream cmd_to_send;
 
 }
 
+// ============================================================================
+// Keithley_487::set_integrationTime
+// ============================================================================
+void Keithley_487::set_integrationTime (double seconds) 
+{
+  double msSeconds = seconds / 1000;
+
+  //- _size set in init_keithley()
+  _size = (int)ceil(msSeconds / K487_conversionRate);
+}
+
 // ============================================================================
 // Keithley_487::set_triggerMode
 // ============================================================================
diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp
index 691d6a1..48bfdd4 100644
--- a/src/Keithley_6485.cpp
+++ b/src/Keithley_6485.cpp
@@ -18,6 +18,7 @@ static long KEITHLEY_MODEL = 6485;
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <math.h>   //- for ceil
 #include <Xstring.h>
 #include "Keithley_6485.h"
 #include "KeithleySCPIProtocol.h"
@@ -249,6 +250,20 @@ std::stringstream cmd_to_send;
   _electrometerProtocol->set_buffer_size(cmd_to_send.str());
 }  
 
+// ============================================================================
+// Keithley_6485::set_integrationTime
+// ============================================================================
+void Keithley_6485::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 > 2500)
+    _trigCounts = 2500;
+}
+
 // ============================================================================
 // Keithley_6485::init_keithley : command to perform an integration cycle
 // ============================================================================
diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp
index 45ad5e5..656f226 100644
--- a/src/Keithley_6487.cpp
+++ b/src/Keithley_6487.cpp
@@ -18,6 +18,7 @@ static long KEITHLEY_MODEL = 6487;
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <math.h>   //- for ceil
 #include <Xstring.h>
 #include "Keithley_6487.h"
 #include "KeithleySCPIProtocol.h"
@@ -254,6 +255,20 @@ std::stringstream cmd_to_send;
   _electrometerProtocol->set_buffer_size(cmd_to_send.str());
 }  
 
+// ============================================================================
+// Keithley_6487::set_integrationTime
+// ============================================================================
+void Keithley_6487::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 > 3000)
+    _trigCounts = 3000;
+}
+
 // ============================================================================
 // Keithley_6487::init_keithley : command to perform an integration cycle
 // ============================================================================
diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp
index 3a9b7af..fd17f29 100644
--- a/src/Keithley_6514.cpp
+++ b/src/Keithley_6514.cpp
@@ -18,6 +18,7 @@ static long KEITHLEY_MODEL = 6514;
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <math.h>   //- for ceil
 #include <Xstring.h>
 #include "Keithley_6514.h"
 #include "KeithleySCPIProtocol.h"
@@ -36,6 +37,11 @@ static const short K6514_VOLT_rangeLimit= 2;
 static const short K6514_OHM_rangeLimit = 8;
 static const short K6514_COU_rangeLimit = 3;
 
+/*
+* Trigger Mode limit (millisec)
+*/
+static const int K6514_conversionRate = 175;
+
 // ============================================================================
 // Keithley_6514::Keithley_6514
 // ============================================================================
@@ -387,6 +393,20 @@ std::stringstream cmd_to_send;
   _electrometerProtocol->set_buffer_size(cmd_to_send.str());
 }  
 
+// ============================================================================
+// Keithley_6514::set_integrationTime
+// ============================================================================
+void Keithley_6514::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 > 2500)
+    _trigCounts = 2500;
+}
+
 // ============================================================================
 // Keithley_6514::init_keithley : command to perform an integration cycle
 // ============================================================================
-- 
GitLab