From d4800cd3fef7a002e05fac1cce01c8b23fb99204 Mon Sep 17 00:00:00 2001
From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr>
Date: Mon, 23 Nov 2009 14:40:03 +0000
Subject: [PATCH] DDC part : no more data with prefix, this slow down the
 communication.

---
 src/KeithleyDDCProtocol.cpp | 40 ++++++++++------------------------
 src/Keithley_485.cpp        | 43 +++++++++++++++++++------------------
 2 files changed, 33 insertions(+), 50 deletions(-)

diff --git a/src/KeithleyDDCProtocol.cpp b/src/KeithleyDDCProtocol.cpp
index 02fd809..3d2b0e7 100644
--- a/src/KeithleyDDCProtocol.cpp
+++ b/src/KeithleyDDCProtocol.cpp
@@ -32,7 +32,7 @@ KeithleyDDCProtocol::KeithleyDDCProtocol (std::string& gpib_device_name)
 
   _commDevName = gpib_device_name;
 
-	std::cout << "KeithleyDDCProtocol::KeithleyDDCProtocol ->" << std::endl;
+	std::cout << "KeithleyDDCProtocol::KeithleyDDCProtocol -> " << _commDevName << std::endl;
 }
 
 // ============================================================================
@@ -58,7 +58,8 @@ bool KeithleyDDCProtocol::build_communicationLink()
   if (!_communication_link)
     return false;
 
-  //- Read data with no prefix
+  //- For DDC models are very slow devices, so communication with
+  //-   prefix is disabled !
   this->disable_readingWithPrefix();
 
   return true;
@@ -203,7 +204,6 @@ std::stringstream cmd_to_send;
 	//- send command
 	cmd_to_send << "R12X" << std::ends;
 	_communication_link->write(cmd_to_send.str());
-
 }
 
 // ============================================================================
@@ -222,7 +222,6 @@ std::stringstream cmd_to_send;
 	//- send command
 	cmd_to_send << "F1X" << std::ends;
 	_communication_link->write(cmd_to_send.str());
-
 }
 
 // ============================================================================
@@ -295,28 +294,19 @@ std::string KeithleyDDCProtocol::get_value (void)
 std::stringstream cmd_to_send;
 std::string argout("no data");
 
-	//- send command : G0X -> prefix (to check if device overload !) and second X to get data
-//	cmd_to_send << "G0" << std::ends;
-  //this->disable_readingWithPrefix();
-
-//- get data value
-cmd_to_send << "X" << std::ends;
-_communication_link->write(cmd_to_send.str());
-argout = _communication_link->read();
-std::cout << "KeithleyDDCProtocol::get_value = " << argout << std::endl;
-	
-//  this->enable_readingWithPrefix();
-  //- send command : G1X -> no prefix and second X to get data
-//	cmd_to_send << "G1X" << std::ends;
-//	_communication_link->write(cmd_to_send.str());
-
-  //- check if device range is overloaded
+  //- get data value
+  cmd_to_send << "X" << std::ends;
+  _communication_link->write_read(cmd_to_send.str());
+  argout = _communication_link->read();
+  std::cout << "KeithleyDDCProtocol::get_value = " << argout << std::endl;
+ 
+  //- check if device range is overloaded : First char of the prefix !
   //if(argout[0] == 'O')
   //  _is_overloaded = true;
   //else
   //  _is_overloaded = false;
 
-  //- return value : data begin at idx 4
+  ////- return value : data begin at idx 4
   //argout = argout.substr(4);
 	return argout;
 }
@@ -413,16 +403,12 @@ std::string KeithleyDDCProtocol::get_raw_status (void)
 std::stringstream cmd_to_send;
 std::string argout("no data");
 
-	//- send command : G0X -> show prefix ( = keithley type )
-    //this->enable_readingWithPrefix();
-
 	cmd_to_send.str("");
 	//- get status word
 	cmd_to_send << "U1X" << std::endl;
 	argout = _communication_link->write_read(cmd_to_send.str());
 
 	std::cout << "KeithleyDDCProtocol::get_raw_status returns *" << argout << "*" << std::ends;
-//    this->disable_readingWithPrefix();
 
 	return argout;
 }
@@ -435,16 +421,12 @@ std::string KeithleyDDCProtocol::get_DDC_configuration (void)
 std::stringstream cmd_to_send;
 std::string argout("no data");
 
-	//- send command : G0X -> show prefix ( = keithley type )
-    //this->enable_readingWithPrefix();
-
 	cmd_to_send.str("");
 	//- get status word
 	cmd_to_send << "U0X" << std::endl;
 	argout = _communication_link->write_read(cmd_to_send.str());
 
 	std::cout << "KeithleyDDCProtocol::get_DDC_configuration returns *" << argout << "*" << std::ends;
-    //this->disable_readingWithPrefix();
 
 	return argout;
 }
diff --git a/src/Keithley_485.cpp b/src/Keithley_485.cpp
index 80ae599..739f36c 100644
--- a/src/Keithley_485.cpp
+++ b/src/Keithley_485.cpp
@@ -22,6 +22,10 @@
 #include "KeithleyDDCProtocol.h"
 #include "Keithley_485.h"
 /*
+* model number
+*/
+static std::string MODEL_NUMBER = "485";
+/*
 * Valid Range values for a K_485
 */
 static const std::string K485_rangeValue[] = {"AUTO ON","2E-9","2E-8","2E-7","2E-6","2E-5","2E-4","2E-3"};
@@ -98,7 +102,7 @@ bool Keithley_485::init_protocol (void)
 // ============================================================================
 void Keithley_485::range_up (void) 
 {
-std::stringstream cmd_to_send;
+std::stringstream cmd_to_send("");
 
 	// force read of range on instrument to update _range variable 
 	electrometer_status();
@@ -123,8 +127,7 @@ std::stringstream cmd_to_send;
 // ============================================================================
 void Keithley_485::range_down (void) 
 {
-
-std::stringstream cmd_to_send;
+  std::stringstream cmd_to_send("");
 
 	// force read of range on instrument to update _range variable
 	electrometer_status();
@@ -159,7 +162,7 @@ std::string Keithley_485::get_ElectroMeterRange (void)
 // ============================================================================
 void Keithley_485::set_triggerMode (short trigMod) 
 {
-std::stringstream cmd_to_send;
+std::stringstream cmd_to_send("");
 
   if(trigMod<0 || trigMod>K485_triggerModeLimit)
 		throw electrometer::ElectrometerException("OUT_OF_RANGE", 
@@ -178,7 +181,7 @@ std::stringstream cmd_to_send;
 std::string Keithley_485::electrometer_status (void)
 { 
 	std::string _kstatus("undefined status");
-	std::string defaultStatus("0000000000");
+	std::string defaultStatus("4850000000000");
 	std::string argout("");
 	std::string tmp("");
 
@@ -197,7 +200,7 @@ std::string Keithley_485::electrometer_status (void)
 		//	argout = "Invalid status string received";
 		//	return argout;
 		//}
-		//argout = "Keithley Type : " + modelNum + "\n";
+		argout = "Keithley Type : " + MODEL_NUMBER + "\n";
 		if ( _kstatus.size() < defaultStatus.size() )
 		{
 			argout = _kstatus;
@@ -220,7 +223,7 @@ std::string Keithley_485::electrometer_status (void)
 		tmp = _kstatus.substr(2,1);
 		 _range = XString<short>::convertFromString(tmp);
 		_rangeStr = K485_rangeValue[_range];
-		argout   += _rangeStr + "\n";
+    argout   += "Range : " + _rangeStr + "\n";
 		//- Relative (baseline suppress)
 		tmp = _kstatus.substr(3,1);
 		if(XString<short>::convertFromString(tmp))
@@ -279,31 +282,29 @@ std::string Keithley_485::electrometer_status (void)
 		else
 			if(srqInfo == 25)
 				argout += "SRQ Data Mask : Busy, Reading Done or Reading Overflow\n";
-		//- SRQ Error Mask
-		tmp = _kstatus.substr(6,2);
-    short srqMaskErr = XString<short>::convertFromString(tmp);
-		if(!srqMaskErr)
-			argout += "SRQ Error Mask : SRQ Disabled\n";
 		else
-			if(srqMaskErr == 1)
-				argout += "SRQ Error Mask : IDDCO\n";
+			if(srqInfo == 32)
+				argout += "SRQ Error Mask : Clear SRQ Errol mask\n";
+		else
+			if(srqInfo == 33)
+				argout += "SRQ Error Mask : IDDCQ\n";
 		else
-			if(srqMaskErr == 2)
+			if(srqInfo == 34)
 				argout += "SRQ Error Mask : IDDC\n";
 		else
-			if(srqMaskErr == 3)
-				argout += "SRQ Error Mask : IDDCO or IDDC\n";
+			if(srqInfo == 35)
+				argout += "SRQ Error Mask : IDDC or IDDCO\n";
 		else
-			if(srqMaskErr == 4)
+			if(srqInfo == 36)
 				argout += "SRQ Error Mask : Not in Remote\n";
 		else
-			if(srqMaskErr == 5)
+			if(srqInfo == 37)
 				argout += "SRQ Error Mask : Not in Remote or IDDCO\n";
 		else
-			if(srqMaskErr == 6)
+			if(srqInfo == 38)
 				argout += "SRQ Error Mask : Not in Remote or IDDC\n";
 		else
-			if(srqMaskErr == 7)
+			if(srqInfo == 39)
 				argout += "SRQ Error Mask : Not in Remote, IDDCO or IDDC\n";
 	}
 	catch(std::out_of_range)
-- 
GitLab