From 1174b201dc85f8f6201e0cc96b8bdfad2efd16de Mon Sep 17 00:00:00 2001
From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr>
Date: Fri, 20 Nov 2009 12:28:12 +0000
Subject: [PATCH] xavier : Keithley DDC part -> no more data with prefix TODO :
 change all DDC files.

---
 pom.xml                     |  2 +-
 src/KeithleyDDCProtocol.cpp | 39 +++++++++++++++++++++----------------
 src/Keithley_485.cpp        | 35 ++++++++++++++++++++-------------
 3 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/pom.xml b/pom.xml
index cf82a1d..2cc1bf6 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.2.1</version>
+   <version>2.2.2</version>
    <packaging>nar</packaging>
    <name>Electrometers library</name>
    <description>Electrometers library</description>
diff --git a/src/KeithleyDDCProtocol.cpp b/src/KeithleyDDCProtocol.cpp
index 399fcf7..02fd809 100644
--- a/src/KeithleyDDCProtocol.cpp
+++ b/src/KeithleyDDCProtocol.cpp
@@ -58,6 +58,9 @@ bool KeithleyDDCProtocol::build_communicationLink()
   if (!_communication_link)
     return false;
 
+  //- Read data with no prefix
+  this->disable_readingWithPrefix();
+
   return true;
 }
 
@@ -294,25 +297,27 @@ 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;
-//	_communication_link->write(cmd_to_send.str());
-  this->enable_readingWithPrefix();
-	//- get data value
-//	cmd_to_send << "X" << std::ends;
-	argout = _communication_link->read();
+  //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());
-  this->disable_readingWithPrefix();
 
   //- check if device range is overloaded
-  if(argout[0] == 'O')
-    _is_overloaded = true;
-  else
-    _is_overloaded = false;
+  //if(argout[0] == 'O')
+  //  _is_overloaded = true;
+  //else
+  //  _is_overloaded = false;
 
   //- return value : data begin at idx 4
-  argout = argout.substr(4);
+  //argout = argout.substr(4);
 	return argout;
 }
 
@@ -409,15 +414,15 @@ std::stringstream cmd_to_send;
 std::string argout("no data");
 
 	//- send command : G0X -> show prefix ( = keithley type )
-    this->enable_readingWithPrefix();
+    //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 << "\n\nKeithleyDDCProtocol::get_raw_status returns *" << argout << "*" << std::ends;
-    this->disable_readingWithPrefix();
+	std::cout << "KeithleyDDCProtocol::get_raw_status returns *" << argout << "*" << std::ends;
+//    this->disable_readingWithPrefix();
 
 	return argout;
 }
@@ -431,15 +436,15 @@ std::stringstream cmd_to_send;
 std::string argout("no data");
 
 	//- send command : G0X -> show prefix ( = keithley type )
-    this->enable_readingWithPrefix();
+    //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 << "\n\nKeithleyDDCProtocol::get_DDC_configuration returns *" << argout << "*" << std::ends;
-    this->disable_readingWithPrefix();
+	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 015081d..80ae599 100644
--- a/src/Keithley_485.cpp
+++ b/src/Keithley_485.cpp
@@ -178,7 +178,8 @@ std::stringstream cmd_to_send;
 std::string Keithley_485::electrometer_status (void)
 { 
 	std::string _kstatus("undefined status");
-	std::string argout("undefined status");
+	std::string defaultStatus("0000000000");
+	std::string argout("");
 	std::string tmp("");
 
 	//- read keithley status from HW	
@@ -188,46 +189,52 @@ std::string Keithley_485::electrometer_status (void)
 	try
 	{
 		//- model number :
-		std::string modelNum = _kstatus.substr(0,3);
-		//- if not expected data (here model number)
-		if(modelNum.find("485") == std::string::npos)
+		//std::string modelNum = _kstatus.substr(0,3);
+		////- if not expected data (here model number)
+		//if(modelNum.find("485") == std::string::npos)
+		//{
+		//	set_electroState(ALARM);
+		//	argout = "Invalid status string received";
+		//	return argout;
+		//}
+		//argout = "Keithley Type : " + modelNum + "\n";
+		if ( _kstatus.size() < defaultStatus.size() )
 		{
+			argout = _kstatus;
 			set_electroState(ALARM);
-			argout = "Invalid status string received";
 			return argout;
 		}
-		argout = "Keithley Type : " + modelNum + "\n";
 		//- Zero check state
-		tmp = _kstatus.substr(3,1);
+		tmp = _kstatus.substr(0,1);
 		if(XString<short>::convertFromString(tmp))
 			argout += "Zero Check : ON\n";
 		else
 			argout += "Zero Check : OFF\n";
 		//- Log state
-		tmp = _kstatus.substr(4,1);
+		tmp = _kstatus.substr(1,1);
 		if(XString<short>::convertFromString(tmp))
 			argout += "Log : ON\n";
 		else
 			argout += "Log : OFF\n";
 		//- Range
-		tmp = _kstatus.substr(5,1);
+		tmp = _kstatus.substr(2,1);
 		 _range = XString<short>::convertFromString(tmp);
 		_rangeStr = K485_rangeValue[_range];
 		argout   += _rangeStr + "\n";
 		//- Relative (baseline suppress)
-		tmp = _kstatus.substr(6,1);
+		tmp = _kstatus.substr(3,1);
 		if(XString<short>::convertFromString(tmp))
 			argout += "Relative ON\n";
 		else
 			argout += "Relative OFF\n";
 		//- Relative (baseline suppress)
-		tmp = _kstatus.substr(7,1);
+		tmp = _kstatus.substr(4,1);
 		if(XString<short>::convertFromString(tmp))
 			argout += "EOI : Send\n";
 		else
 			argout += "EOI : Do Not Send\n";
 		//- Trigger
-		tmp = _kstatus.substr(8,1);
+		tmp = _kstatus.substr(5,1);
     short trigg = XString<short>::convertFromString(tmp);
 		if(!trigg)
 			argout += "Trigger : Continuous on Talk\n";
@@ -247,7 +254,7 @@ std::string Keithley_485::electrometer_status (void)
 			if(trigg == 5)
 				argout += "Trigger :One-Shot on \"X\"\n";
 		//- SRQ Data Mask
-		tmp = _kstatus.substr(9,2);
+		tmp = _kstatus.substr(6,2);
     short srqInfo = XString<short>::convertFromString(tmp);
 		if(!srqInfo)
 			argout += "SRQ Data Mask : SRQ Disabled\n";
@@ -273,7 +280,7 @@ std::string Keithley_485::electrometer_status (void)
 			if(srqInfo == 25)
 				argout += "SRQ Data Mask : Busy, Reading Done or Reading Overflow\n";
 		//- SRQ Error Mask
-		tmp = _kstatus.substr(9,2);
+		tmp = _kstatus.substr(6,2);
     short srqMaskErr = XString<short>::convertFromString(tmp);
 		if(!srqMaskErr)
 			argout += "SRQ Error Mask : SRQ Disabled\n";
-- 
GitLab