From efe25edc8f1502f2150596c406773410439203a9 Mon Sep 17 00:00:00 2001 From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr> Date: Wed, 11 Jul 2012 08:21:54 +0000 Subject: [PATCH] for test purpose only ! --- include/CommunicationLink.h | 7 +- include/Keithley_6485.h | 1 + include/Keithley_6487.h | 1 + include/Keithley_6514.h | 1 + include/Keithley_6517.h | 1 + include/N_PhotoConducteur.h | 3 +- include/N_PhotoVoltaique.h | 3 +- include/Novelec_MCCE2.h | 2 +- include/TangoGpibLink.h | 2 +- include/TangoSerialLink.h | 4 +- pom.xml | 2 +- src/AbstractElectrometerClass.cpp | 8 +- src/Keithley_486.cpp | 6 +- src/Keithley_487.cpp | 12 +-- src/Keithley_617.cpp | 85 +++++++++-------- src/Keithley_6485.cpp | 11 ++- src/Keithley_6487.cpp | 11 ++- src/Keithley_6512.cpp | 78 +++++++-------- src/Keithley_6514.cpp | 35 +++---- src/Keithley_6517.cpp | 27 +++--- src/N_PhotoConducteur.cpp | 96 ++++++++++++++----- src/N_PhotoVoltaique.cpp | 98 ++++++++++++++----- src/NovelecProtocol.cpp | 48 +++++++--- src/Novelec_MCCE2.cpp | 154 ++++++++++++++++++++---------- src/TangoGpibLink.cpp | 2 +- src/TangoSerialLink.cpp | 46 ++++----- 26 files changed, 472 insertions(+), 272 deletions(-) diff --git a/include/CommunicationLink.h b/include/CommunicationLink.h index 865d21a..84ed171 100644 --- a/include/CommunicationLink.h +++ b/include/CommunicationLink.h @@ -12,9 +12,12 @@ // // $Author: xavela $ // -// $Revision: 1.8 $ +// $Revision: 1.9 $ // // $Log: not supported by cvs2svn $ +// Revision 1.8 2012/07/09 13:15:59 xavela +// Novelec part : bug at init fixed. +// // Revision 1.7 2012/07/03 06:15:53 xavela // Novelec part : bug at init fixed. // @@ -106,7 +109,7 @@ public : * * \throws Tango::DevFailed */ - virtual std::string write_read(std::string cmd_to_send) = 0; + virtual std::string write_read(std::string cmd_to_send, size_t readLength=0) = 0; /** * \brief Performs a write read operation as string. (for Serialline ) diff --git a/include/Keithley_6485.h b/include/Keithley_6485.h index 6bc5be6..b32b9d6 100644 --- a/include/Keithley_6485.h +++ b/include/Keithley_6485.h @@ -65,6 +65,7 @@ public: */ void range_up (void); void range_down (void); + std::string get_ElectroMeterRange (void); /** * \brief Methods to configure the integration mode. diff --git a/include/Keithley_6487.h b/include/Keithley_6487.h index 6713834..3823bd6 100644 --- a/include/Keithley_6487.h +++ b/include/Keithley_6487.h @@ -58,6 +58,7 @@ public: */ void range_up (void); void range_down (void); + std::string get_ElectroMeterRange (void); std::vector<double> get_integratedValue (void); std::vector<double> get_fetchValue (void); diff --git a/include/Keithley_6514.h b/include/Keithley_6514.h index b86225e..14384f9 100644 --- a/include/Keithley_6514.h +++ b/include/Keithley_6514.h @@ -58,6 +58,7 @@ public: */ void range_up (void); void range_down (void); + std::string get_ElectroMeterRange (void) ; std::vector<double> get_integratedValue (void); std::vector<double> get_fetchValue (void); diff --git a/include/Keithley_6517.h b/include/Keithley_6517.h index 3fcb861..7eb5f62 100644 --- a/include/Keithley_6517.h +++ b/include/Keithley_6517.h @@ -58,6 +58,7 @@ public: */ void range_up (void); void range_down (void); + std::string get_ElectroMeterRange (void); std::vector<double> get_integratedValue (void); std::vector<double> get_fetchValue (void); diff --git a/include/N_PhotoConducteur.h b/include/N_PhotoConducteur.h index 80d8e2c..9d3a3be 100644 --- a/include/N_PhotoConducteur.h +++ b/include/N_PhotoConducteur.h @@ -51,7 +51,8 @@ public: /** * \brief Checks and Sets the new range value. */ - void set_range(std::string range_str); + void set_ElectroMeterRange(std::string range_str); + std::string get_ElectroMeterRange(); /** * \brief getters and setters. diff --git a/include/N_PhotoVoltaique.h b/include/N_PhotoVoltaique.h index 746fbc1..d5eb77e 100644 --- a/include/N_PhotoVoltaique.h +++ b/include/N_PhotoVoltaique.h @@ -51,7 +51,8 @@ public: /** * \brief Checks and Sets the new range value. */ - void set_range(std::string range_str); + void set_ElectroMeterRange(std::string range_str); + std::string get_ElectroMeterRange(); /** * \brief getters and setters. diff --git a/include/Novelec_MCCE2.h b/include/Novelec_MCCE2.h index 95b8c3b..e732d91 100644 --- a/include/Novelec_MCCE2.h +++ b/include/Novelec_MCCE2.h @@ -59,7 +59,7 @@ public: /** * \brief Sets the new range value */ - virtual void set_range(std::string range_str) = 0; + //virtual void set_ElectroMeterRange(std::string range_str) = 0; /** * \brief Commands to start/stop the data acquisition diff --git a/include/TangoGpibLink.h b/include/TangoGpibLink.h index 0e601d6..56b87f5 100644 --- a/include/TangoGpibLink.h +++ b/include/TangoGpibLink.h @@ -66,7 +66,7 @@ public : * * \throws Tango::DevFailed */ - std::string write_read(std::string cmd) throw (Tango::DevFailed); + std::string write_read(std::string cmd, size_t readLength=0) throw (Tango::DevFailed); /** * \brief Returns the Gpib SRQ line state : used here to know if Keithley diff --git a/include/TangoSerialLink.h b/include/TangoSerialLink.h index d7c998f..4371d23 100644 --- a/include/TangoSerialLink.h +++ b/include/TangoSerialLink.h @@ -82,14 +82,14 @@ public : * * \throws Tango::DevFailed */ - std::string write_read(std::string cmd) throw (Tango::DevFailed); + //std::string write_read(std::string cmd) throw (Tango::DevFailed); /** * \brief Performs a write read operation as string. (read nb char) * * \throws Tango::DevFailed */ - std::string write_read(std::string cmd, long nbChar) throw (Tango::DevFailed); + std::string write_read(std::string cmd, size_t nbChar) throw (Tango::DevFailed); private : diff --git a/pom.xml b/pom.xml index 0771ebc..efde46e 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.7</version> + <version>2.5.8-SNAPSHOT</version> <packaging>nar</packaging> <name>Electrometers library</name> <description>Electrometers library</description> diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp index bd807ff..ed43de0 100644 --- a/src/AbstractElectrometerClass.cpp +++ b/src/AbstractElectrometerClass.cpp @@ -11,9 +11,12 @@ // // $Author: xavela $ // -// $Revision: 1.24 $ +// $Revision: 1.25 $ // // $Log: not supported by cvs2svn $ +// Revision 1.24 2012/07/03 06:15:53 xavela +// Novelec part : bug at init fixed. +// // Revision 1.23 2011/03/14 14:42:22 xavela // SaveRestoreConfiguration command added. (Available only for SCPI Keithley devices) // @@ -474,7 +477,7 @@ std::string AbstractElectrometerClass::get_ElectroMeterRange (void) } // ============================================================================ -// AbstractElectrometerClass::get_ElectroMeterRange +// AbstractElectrometerClass::get_overloadRangeState // ============================================================================ bool AbstractElectrometerClass::get_overloadRangeState (void) { @@ -728,6 +731,7 @@ std::string AbstractElectrometerClass::get_ElectroMeterGain (void) void AbstractElectrometerClass::set_ElectroMeterRange (std::string rang) { _electrometerProtocol->set_range(rang); + std::cout << "\t AbstractElectrometerClass::set_ElectroMeterRange val = " << rang << std::endl; } // ============================================================================ diff --git a/src/Keithley_486.cpp b/src/Keithley_486.cpp index cde777c..ee52f30 100644 --- a/src/Keithley_486.cpp +++ b/src/Keithley_486.cpp @@ -121,7 +121,7 @@ void Keithley_486::range_up (void) std::stringstream cmd_to_send(""); // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); _range += 1; @@ -146,7 +146,7 @@ void Keithley_486::range_down (void) std::stringstream cmd_to_send(""); // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); _range -= 1; @@ -168,7 +168,7 @@ std::stringstream cmd_to_send(""); std::string Keithley_486::get_ElectroMeterRange (void) { // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); return _rangeStr; } diff --git a/src/Keithley_487.cpp b/src/Keithley_487.cpp index 1ee3c52..92b44ed 100644 --- a/src/Keithley_487.cpp +++ b/src/Keithley_487.cpp @@ -118,7 +118,7 @@ void Keithley_487::range_up (void) std::stringstream cmd_to_send; // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); _range += 1; @@ -144,7 +144,7 @@ void Keithley_487::range_down (void) std::stringstream cmd_to_send; // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); _range -= 1; @@ -166,8 +166,8 @@ std::stringstream cmd_to_send; // ============================================================================ std::string Keithley_487::get_ElectroMeterRange (void) { - // force read of range on instrument to update _range variable - electrometer_status(); + // get config from instrument to update _range variable + this->get_configuration(); return _rangeStr; } @@ -239,8 +239,8 @@ void Keithley_487::set_triggerMode (short trigMod) // ============================================================================ std::string Keithley_487::get_ElectroMeterMode (void) { - // force read of range on instrument to update _range variable - electrometer_status(); + // get config from instrument to update _mode variable + this->get_configuration(); return _mode; } diff --git a/src/Keithley_617.cpp b/src/Keithley_617.cpp index 2c4a8d5..ef84324 100644 --- a/src/Keithley_617.cpp +++ b/src/Keithley_617.cpp @@ -117,7 +117,9 @@ void Keithley_617::range_up (void) std::stringstream cmd_to_send; // force read of range on instrument to update _range variable - _range += 1; + this->get_configuration(); + + _range += 1; if(_range > K617_rangeLimit) { @@ -140,7 +142,9 @@ void Keithley_617::range_down (void) std::stringstream cmd_to_send; // force read of range on instrument to update _range variable - _range -= 1; + this->get_configuration(); + + _range -= 1; if(_range < 0) { @@ -160,8 +164,10 @@ std::stringstream cmd_to_send; // ============================================================================ std::string Keithley_617::get_ElectroMeterRange (void) { - // force read of range on instrument to update _range variable - return _rangeStr; + // get config from instrument to update _range variable + this->get_configuration(); + + return _rangeStr; } // ============================================================================ @@ -198,8 +204,10 @@ void Keithley_617::set_triggerMode (short trigMod) // ============================================================================ std::string Keithley_617::get_ElectroMeterMode (void) { - // force read of mode on instrument to update _mode variable - return _mode; + // get config from instrument to update _mode variable + this->get_configuration(); + + return _mode; } // ============================================================================ @@ -357,41 +365,36 @@ std::string Keithley_617::get_configuration (void) tmp = _kstatus.substr(4,2); _range = XString<short>::convertFromString(tmp); _rangeStr = K617_VoltRangeValue[_range]; - if(!func) - { - _mode = "Function : VOLTS"; - argout += _mode + "\n"; - } - else - if(func == 1) - { - _mode = "Function : AMPS"; - argout += _mode + "\n"; - } - else - if(func == 2) - { - _mode = "Function : OHMS"; - argout += _mode + "\n"; - } - else - if(func == 3) - { - _mode = "Function : COULOMBS"; - argout += _mode + "\n"; - } - else - if(func == 4) - { - _mode = "Function : XFDBK"; - argout += _mode + "\n"; - } - else - if(func == 5) - { - _mode = "Function : V/I"; - argout += _mode + "\n"; - } + if(!func) + { + _mode = "Function : VOLTS"; + argout += _mode + "\n"; + } + else if(func == 1) + { + _mode = "Function : AMPS"; + argout += _mode + "\n"; + } + else if(func == 2) + { + _mode = "Function : OHMS"; + argout += _mode + "\n"; + } + else if(func == 3) + { + _mode = "Function : COULOMBS"; + argout += _mode + "\n"; + } + else if(func == 4) + { + _mode = "Function : XFDBK"; + argout += _mode + "\n"; + } + else if(func == 5) + { + _mode = "Function : V/I"; + argout += _mode + "\n"; + } //- Range : argout += "RANGE : " + _rangeStr + "\n"; //- Zero check state diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp index 1ad4069..529f088 100644 --- a/src/Keithley_6485.cpp +++ b/src/Keithley_6485.cpp @@ -109,7 +109,7 @@ void Keithley_6485::range_up (void) std::stringstream cmd_to_send; //- update range index from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range += 1; @@ -135,7 +135,7 @@ void Keithley_6485::range_down (void) std::stringstream cmd_to_send; //- update range index from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range -= 1; @@ -156,7 +156,8 @@ std::stringstream cmd_to_send; // ============================================================================ // Keithley_6485::update_range // ============================================================================ -void Keithley_6485::update_range (void) +//void Keithley_6485::update_range (void) +std::string Keithley_6485::get_ElectroMeterRange (void) { std::string range_str(""); double rangeValueReturned = 0; @@ -185,10 +186,12 @@ double delta = 0; if(idx == K6485_rangeLimit) throw electrometer::ElectrometerException("INTERNAL_ERROR", "Failed to get range index.", - "Keithley_6485::update_range( )."); + "Keithley_6485::get_ElectroMeterRange( )."); //- update range with index found this->_range = idx; + + return range_str; } // ============================================================================ diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp index f1fe59c..56e6aa5 100644 --- a/src/Keithley_6487.cpp +++ b/src/Keithley_6487.cpp @@ -109,7 +109,7 @@ void Keithley_6487::range_up (void) std::stringstream cmd_to_send; //- update range index from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range += 1; @@ -135,7 +135,7 @@ void Keithley_6487::range_down (void) std::stringstream cmd_to_send; //- update range index from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range -= 1; @@ -190,7 +190,8 @@ std::vector<double> Keithley_6487::get_fetchValue (void) // ============================================================================ // Keithley_6487::update_range // ============================================================================ -void Keithley_6487::update_range (void) +//void Keithley_6487::update_range (void) +std::string Keithley_6487::get_ElectroMeterRange (void) { std::string range_str(""); double rangeValueReturned = 0; @@ -219,10 +220,12 @@ double delta = 0; if(idx == K6487_rangeLimit) throw electrometer::ElectrometerException("INTERNAL_ERROR", "Failed to get range index.", - "Keithley_6487::update_range( )."); + "Keithley_6487::get_ElectroMeterRange( )."); //- update range with the index found this->_range = idx; + + return range_str; } // ============================================================================ diff --git a/src/Keithley_6512.cpp b/src/Keithley_6512.cpp index adc0b2a..375111d 100644 --- a/src/Keithley_6512.cpp +++ b/src/Keithley_6512.cpp @@ -116,7 +116,7 @@ void Keithley_6512::range_up (void) std::stringstream cmd_to_send; // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); _range += 1; @@ -141,7 +141,7 @@ void Keithley_6512::range_down (void) std::stringstream cmd_to_send; // force read of range on instrument to update _range variable - electrometer_status(); + this->get_configuration(); _range -= 1; @@ -163,8 +163,8 @@ std::stringstream cmd_to_send; // ============================================================================ std::string Keithley_6512::get_ElectroMeterRange (void) { - // force read of range on instrument to update _range variable - electrometer_status(); + // get config from instrument to update _range variable + this->get_configuration(); return _rangeStr; } @@ -203,8 +203,8 @@ void Keithley_6512::set_triggerMode (short trigMod) // ============================================================================ std::string Keithley_6512::get_ElectroMeterMode (void) { - // force read of mode on instrument to update _mode variable - electrometer_status(); + // get config from instrument to update _mode variable + this->get_configuration(); return _mode; } @@ -364,41 +364,37 @@ std::string Keithley_6512::get_configuration (void) //- Range : tmp = _kstatus.substr(5,2); _range = XString<short>::convertFromString(tmp); - if(!func) - { - _mode = "Function : VOLTS"; - argout += _mode + "\n"; - _rangeStr = K6512_VoltRangeValue[_range]; - } - else - if(func == 1) - { - _mode = "Function : AMPS"; - argout += _mode + "\n"; - _rangeStr = K6512_AmpRangeValue[_range]; - argout += _rangeStr + "\n"; - } - else - if(func == 2) - { - _mode = "Function : OHMS"; - argout += _mode + "\n"; - _rangeStr = K6512_OhmRangeValue[_range]; - } - else - if(func == 3) - { - _mode = "Function : COULOMBS"; - argout += _mode + "\n"; - _rangeStr = K6512_CouRangeValue[_range]; - } - else - if(func == 4) - { - _mode = "Function : XFDBK"; - argout += _mode + "\n"; - _rangeStr = K6512_XfdbRangeValue[_range]; - } + if(!func) + { + _mode = "Function : VOLTS"; + argout += _mode + "\n"; + _rangeStr = K6512_VoltRangeValue[_range]; + } + else if(func == 1) + { + _mode = "Function : AMPS"; + argout += _mode + "\n"; + _rangeStr = K6512_AmpRangeValue[_range]; + argout += _rangeStr + "\n"; + } + else if(func == 2) + { + _mode = "Function : OHMS"; + argout += _mode + "\n"; + _rangeStr = K6512_OhmRangeValue[_range]; + } + else if(func == 3) + { + _mode = "Function : COULOMBS"; + argout += _mode + "\n"; + _rangeStr = K6512_CouRangeValue[_range]; + } + else if(func == 4) + { + _mode = "Function : XFDBK"; + argout += _mode + "\n"; + _rangeStr = K6512_XfdbRangeValue[_range]; + } //- Range : argout += "RANGE : " + _rangeStr + "\n"; //- Zero check state diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp index 87fd2b2..7ff9c69 100644 --- a/src/Keithley_6514.cpp +++ b/src/Keithley_6514.cpp @@ -122,7 +122,7 @@ void Keithley_6514::range_up (void) std::stringstream cmd_to_send; //- update range value from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range += 1; @@ -191,7 +191,7 @@ void Keithley_6514::range_down (void) std::stringstream cmd_to_send; //- update range value from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range -= 1; @@ -273,7 +273,8 @@ void Keithley_6514::setCoulombMeterMode (void) // ============================================================================ // Keithley_6514::update_range // ============================================================================ -void Keithley_6514::update_range (void) +//void Keithley_6514::update_range (void) +std::string Keithley_6514::get_ElectroMeterRange (void) { std::string range_str(""); double rangeValueReturned = 0; @@ -284,7 +285,7 @@ double delta = 0; * NOTE : SCPI models return a range value +/- 5% */ //- get device mode - _kmode = get_ElectroMeterMode(); + _kmode = AbstractElectrometerClass::get_ElectroMeterMode(); //- get range from hardware range_str = _electrometerProtocol->get_range( ); @@ -295,44 +296,44 @@ double delta = 0; short idx = 0; short idx_limit = 0; - if(_kmode.find("CURR") != std::string::npos) + if( _kmode.find("CURR") != std::string::npos ) idx_limit = K6514_AMP_rangeLimit; - else if (_kmode.find("VOLT") != std::string::npos) + else if ( _kmode.find("VOLT") != std::string::npos ) idx_limit = K6514_VOLT_rangeLimit; - else if (_kmode.find("RES") != std::string::npos) + else if ( _kmode.find("RES") != std::string::npos ) idx_limit = K6514_OHM_rangeLimit; - else if (_kmode.find("CHAR") != std::string::npos) + else if ( _kmode.find("CHAR") != std::string::npos ) idx_limit = K6514_COU_rangeLimit; else throw electrometer::ElectrometerException("UNKNOWN_MODE", "Unable to find the electrometer mode used.", - "Keithley_6514::update_range( )."); + "Keithley_6514::get_ElectroMeterRange( )."); //- find the range index - for(idx=0; idx<idx_limit ; idx++) + for( idx = 0; idx < idx_limit ; idx++) { - if(_kmode.find("CURR") != std::string::npos) + if( _kmode.find("CURR") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6514_AMP_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } - else if (_kmode.find("VOLT") != std::string::npos) + else if ( _kmode.find("VOLT") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6514_VOLT_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } - else if (_kmode.find("RES") != std::string::npos) + else if ( _kmode.find("RES") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6514_OHM_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } - else if (_kmode.find("CHAR") != std::string::npos) + else if ( _kmode.find("CHAR") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6514_COU_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; @@ -342,13 +343,15 @@ double delta = 0; } //- throw if index not found - if(idx == idx_limit) + if( idx == idx_limit ) throw electrometer::ElectrometerException("INTERNAL_ERROR", "Failed to get range index.", - "Keithley_6514::update_range( )."); + "Keithley_6514::get_ElectroMeterRange( )."); //- update the range with the index found this->_range = idx; + + return range_str; } // ============================================================================ diff --git a/src/Keithley_6517.cpp b/src/Keithley_6517.cpp index c506a0d..5a92b00 100644 --- a/src/Keithley_6517.cpp +++ b/src/Keithley_6517.cpp @@ -114,7 +114,7 @@ void Keithley_6517::range_up (void) std::stringstream cmd_to_send; //- update range value from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range += 1; @@ -184,7 +184,7 @@ void Keithley_6517::range_down (void) std::stringstream cmd_to_send; //- update range value from hardware - update_range( ); + this->get_ElectroMeterRange( ); _range -= 1; @@ -314,7 +314,8 @@ double Keithley_6517::get_VSourceValue (void) // ============================================================================ // Keithley_6517::update_range // ============================================================================ -void Keithley_6517::update_range (void) +//void Keithley_6517::update_range (void) +std::string Keithley_6517::get_ElectroMeterRange (void) { std::string range_str(""); double rangeValueReturned = 0; @@ -325,7 +326,7 @@ double delta = 0; * NOTE : SCPI models return a range value +/- 5% */ //- get device mode - _kmode = get_ElectroMeterMode(); + _kmode = AbstractElectrometerClass::get_ElectroMeterMode(); //- get range from hardware range_str = _electrometerProtocol->get_range( ); @@ -347,34 +348,34 @@ double delta = 0; else throw electrometer::ElectrometerException("UNKNOWN_MODE", "Unable to find the electrometer mode used.", - "Keithley_6517::update_range( )."); + "Keithley_6517::get_ElectroMeterRange( )."); //- find the range index - for(idx=0; idx<idx_limit ; idx++) + for ( idx = 0; idx < idx_limit ; idx++ ) { - if(_kmode.find("CURR") != std::string::npos) + if( _kmode.find("CURR") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6517_AMP_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } - else if (_kmode.find("VOLT") != std::string::npos) + else if ( _kmode.find("VOLT") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6517_VOLT_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } - else if (_kmode.find("RES") != std::string::npos) + else if ( _kmode.find("RES") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6517_OHM_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; if( (rangeValueCalculated + delta) >= rangeValueReturned && (rangeValueCalculated - delta) <= rangeValueReturned) break; } - else if (_kmode.find("CHAR") != std::string::npos) + else if ( _kmode.find("CHAR") != std::string::npos ) { rangeValueCalculated = XString<double>::convertFromString(K6517_COU_rangeStr[idx]); delta = rangeValueCalculated * 5 / 100; @@ -384,13 +385,15 @@ double delta = 0; } //- throw if index not found - if(idx == idx_limit) + if( idx == idx_limit ) throw electrometer::ElectrometerException("INTERNAL_ERROR", "Failed to get range index.", - "Keithley_6517::update_range( )."); + "Keithley_6517::get_ElectroMeterRange( )."); //- update the range with the index found this->_range = idx; + + return range_str; } // ============================================================================ diff --git a/src/N_PhotoConducteur.cpp b/src/N_PhotoConducteur.cpp index f843917..f66efbd 100644 --- a/src/N_PhotoConducteur.cpp +++ b/src/N_PhotoConducteur.cpp @@ -24,8 +24,8 @@ /* * Valid Range values for a N_PhotoConducteur */ -static const std::string NType4_rangeValue[] = {"3","10","30","100"}; //- MOhms -static const std::string NType5_rangeValue[] = {"30","100","300","1000"}; //- KOhms +static const std::string NType4_rangeValue[] = {"100","30","10","3"}; //- MOhms +static const std::string NType5_rangeValue[] = {"1000","300","100","30"}; //- KOhms // ============================================================================ @@ -56,6 +56,10 @@ N_PhotoConducteur::~N_PhotoConducteur (void) // ============================================================================ void N_PhotoConducteur::range_up (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoConducteur::range_up( )."); std::stringstream cmd_to_send; @@ -70,7 +74,8 @@ std::stringstream cmd_to_send; } //- build and send the command - cmd_to_send << _range << std::endl; + cmd_to_send << _range; + std::cout << "\t N_PhotoConducteur::range_up cmd2send = " << cmd_to_send.str() << std::endl; _electrometerProtocol->set_range(cmd_to_send.str()); } @@ -79,6 +84,10 @@ std::stringstream cmd_to_send; // ============================================================================ void N_PhotoConducteur::range_down (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoConducteur::range_down( )."); std::stringstream cmd_to_send; @@ -94,7 +103,8 @@ std::stringstream cmd_to_send; //- build and send the command // _rangeStr = NType1_rangeValue[_range]; - cmd_to_send << _range << std::endl; + cmd_to_send << _range; + std::cout << "\t N_PhotoConducteur::range_up cmd2send = " << cmd_to_send.str() << std::endl; _electrometerProtocol->set_range(cmd_to_send.str()); } @@ -103,12 +113,12 @@ std::stringstream cmd_to_send; // ============================================================================ std::string N_PhotoConducteur::get_ElectroMeterGain (void) { - NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); - if(!_nproto) - throw electrometer::ElectrometerException("BAD_CAST", - "Unable to query the electrmometer gain.", + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", "N_PhotoConducteur::get_ElectroMeterGain( )."); - return _nproto->get_gain(); + + return _electrometerProtocol->get_gain(); } // ============================================================================ @@ -116,36 +126,76 @@ std::string N_PhotoConducteur::get_ElectroMeterGain (void) // ============================================================================ void N_PhotoConducteur::set_ElectroMeterGain (std::string gain) { - NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); - if(!_nproto) - throw electrometer::ElectrometerException("BAD_CAST", - "INTERNAL ERROR : Unable to change the electrmometer function.", + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", "N_PhotoConducteur::set_ElectroMeterGain( )."); - _nproto->set_gain(gain); + + _electrometerProtocol->set_gain(gain); } // ============================================================================ -// N_PhotoConducteur::set_range +// N_PhotoConducteur::set_ElectroMeterRange // ============================================================================ -void N_PhotoConducteur::set_range (std::string rgStr) +void N_PhotoConducteur::set_ElectroMeterRange (std::string rgStr) { -short range_idx = -1; std::stringstream range_cmd_to_send; - //- switch the novelec type : + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoConducteur::set_ElectroMeterRange( )."); + + std::cout << "\t N_PhotoConducteur::set_ElectroMeterRange val2set = " << rgStr << std::endl; + //- switch the novelec type : switch(_MCCE2electroTypeNumber) { - case 4 : range_idx = Novelec_MCCE2::check_range_value(rgStr, NType4_rangeValue); + case 4 : _range = Novelec_MCCE2::check_range_value(rgStr, NType4_rangeValue); break; - case 5 : range_idx = Novelec_MCCE2::check_range_value(rgStr, NType5_rangeValue); + case 5 : _range = Novelec_MCCE2::check_range_value(rgStr, NType5_rangeValue); break; } + std::cout << "\t N_PhotoConducteur::set_ElectroMeterRange idx found = " << _range << std::endl; - if (range_idx < 0) + if (_range < 0) throw electrometer::ElectrometerException("INVALID_PARAMETER", "This electrometer does not support this range value.", - "N_PhotoConducteur::set_range( )."); + "N_PhotoConducteur::set_ElectroMeterRange( )."); //- it is OK - range_cmd_to_send << range_idx << std::endl; + range_cmd_to_send << _range; + std::cout << "\t N_PhotoConducteur::set_ElectroMeterRange cmd2send = " << range_cmd_to_send.str() << std::endl; _electrometerProtocol->set_range(range_cmd_to_send.str()); } + +// ============================================================================ +// N_PhotoConducteur::get_ElectroMeterRange +// ============================================================================ +std::string N_PhotoConducteur::get_ElectroMeterRange() +{ +std::string rangeStr(""); + + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoConducteur::get_ElectroMeterRange( )."); + + rangeStr = this->_electrometerProtocol->get_range(); + + std::cout << "\t N_PhotoConducteur::get_ElectroMeterRange rgVal = $" << rangeStr << "$" << std::endl; + //- switch the novelec type : + switch(_MCCE2electroTypeNumber) + { + case 4 : _range = Novelec_MCCE2::check_range_value(rangeStr, NType4_rangeValue); + break; + case 5 : _range = Novelec_MCCE2::check_range_value(rangeStr, NType5_rangeValue); + break; + } + std::cout << "\t N_PhotoConducteur::get_ElectroMeterRange idx found = " << _range << std::endl; + + if (_range < 0) + throw electrometer::ElectrometerException("INVALID_PARAMETER", + "Cannot find the applied range value.", + "N_PhotoConducteur::get_ElectroMeterRange( )."); + + return rangeStr; +} diff --git a/src/N_PhotoVoltaique.cpp b/src/N_PhotoVoltaique.cpp index 7c65820..ff66745 100644 --- a/src/N_PhotoVoltaique.cpp +++ b/src/N_PhotoVoltaique.cpp @@ -24,9 +24,9 @@ /* * Valid Range values for a N_PhotoVoltaique */ -static const std::string NType1_rangeValue[] = {"3e-11","1e-11","3e-10","1e-10"}; -static const std::string NType2_rangeValue[] = {"3e-10","1e-10","3e-9","1e-9","3e-8","1e-8","3e-7","1e-7"}; -static const std::string NType3_rangeValue[] = {"3e-8","1e-8","3e-7","1e-7","3e-6","1e-6","3e-5","1e-5"}; +static const std::string NType1_rangeValue[] = {"1E-11AcC","3E-11AcC","1E-10AcC","3E-10AcC"}; +static const std::string NType2_rangeValue[] = {"1E-10AcC","3E-10AcC","1E-09AcC","3E-09AcC","1E-08AcC","3E-08AcC","1E-07AcC","3E-07AcC"}; +static const std::string NType3_rangeValue[] = {"1E-08AcC","3E-08AcC","1E-07AcC","3E-07AcC","1E-06AcC","3E-06AcC","1E-05AcC","3E-05AcC"}; // ============================================================================ @@ -65,6 +65,10 @@ N_PhotoVoltaique::~N_PhotoVoltaique (void) // ============================================================================ void N_PhotoVoltaique::range_up (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoVoltaique::range_up( )."); std::stringstream cmd_to_send; @@ -79,7 +83,8 @@ std::stringstream cmd_to_send; } //- build and send the command - cmd_to_send << _range << std::endl; + cmd_to_send << _range; + std::cout << "\t N_PhotoVoltaique::range_up cmd2send = " << cmd_to_send.str() << std::endl; _electrometerProtocol->set_range(cmd_to_send.str()); } @@ -88,6 +93,10 @@ std::stringstream cmd_to_send; // ============================================================================ void N_PhotoVoltaique::range_down (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoVoltaique::range_down( )."); std::stringstream cmd_to_send; @@ -103,7 +112,8 @@ std::stringstream cmd_to_send; //- build and send the command // _rangeStr = NType1_rangeValue[_range]; - cmd_to_send << _range << std::endl; + cmd_to_send << _range; + std::cout << "\t N_PhotoVoltaique::range_down cmd2send = " << cmd_to_send.str() << std::endl; _electrometerProtocol->set_range(cmd_to_send.str()); } @@ -112,13 +122,12 @@ std::stringstream cmd_to_send; // ============================================================================ std::string N_PhotoVoltaique::get_ElectroMeterFrequency (void) { - NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); - if(!_nproto) - throw electrometer::ElectrometerException("BAD_CAST", - "Unable to query the electrmometer frequency.", + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", "N_PhotoVoltaique::get_ElectroMeterFrequency( )."); - return _nproto->get_frequency(); + return _electrometerProtocol->get_frequency(); } // ============================================================================ @@ -126,39 +135,80 @@ std::string N_PhotoVoltaique::get_ElectroMeterFrequency (void) // ============================================================================ void N_PhotoVoltaique::set_ElectroMeterFrequency (std::string freqFilter) { - NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); - if(!_nproto) - throw electrometer::ElectrometerException("BAD_CAST", - "Unable to query the electrmometer frequency.", + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", "N_PhotoVoltaique::set_ElectroMeterFrequency( )."); - _nproto->set_frequency(freqFilter); + + _electrometerProtocol->set_frequency(freqFilter); } // ============================================================================ -// N_PhotoVoltaique::set_range +// N_PhotoVoltaique::set_ElectroMeterRange // ============================================================================ -void N_PhotoVoltaique::set_range (std::string rgStr) +void N_PhotoVoltaique::set_ElectroMeterRange (std::string rgStr) { -short range_idx = -1; std::stringstream range_cmd_to_send; + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoVoltaique::set_ElectroMeterRange( )."); + + std::cout << "\t N_PhotoVoltaique::set_ElectroMeterRange val2set = " << rgStr << std::endl; //- switch the novelec type : switch(_MCCE2electroTypeNumber) { - case 1 : range_idx = Novelec_MCCE2::check_range_value(rgStr, NType1_rangeValue); + case 1 : _range = Novelec_MCCE2::check_range_value(rgStr, NType1_rangeValue); break; - case 2 : range_idx = Novelec_MCCE2::check_range_value(rgStr, NType2_rangeValue); + case 2 : _range = Novelec_MCCE2::check_range_value(rgStr, NType2_rangeValue); break; - case 3 : range_idx = Novelec_MCCE2::check_range_value(rgStr, NType3_rangeValue); + case 3 : _range = Novelec_MCCE2::check_range_value(rgStr, NType3_rangeValue); break; } + std::cout << "\t N_PhotoVoltaique::set_ElectroMeterRange idx found = " << _range << std::endl; - if (range_idx < 0) + if (_range < 0) throw electrometer::ElectrometerException("INVALID_PARAMETER", "This electrometer does not support this range value.", - "N_PhotoVoltaique::set_range( )."); + "N_PhotoVoltaique::set_ElectroMeterRange( )."); //- it is OK - range_cmd_to_send << range_idx << std::endl; + range_cmd_to_send << _range; + std::cout << "\t N_PhotoVoltaique::set_ElectroMeterRange cmd2send = " << range_cmd_to_send.str() << std::endl; _electrometerProtocol->set_range(range_cmd_to_send.str()); } +// ============================================================================ +// N_PhotoVoltaique::get_ElectroMeterRange +// ============================================================================ +std::string N_PhotoVoltaique::get_ElectroMeterRange() +{ +std::string rangeStr(""); + + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "N_PhotoVoltaique::get_ElectroMeterRange( )."); + + rangeStr = this->_electrometerProtocol->get_range(); + + std::cout << "\t N_PhotoVoltaique::get_ElectroMeterRange rgVal = $" << rangeStr << "$" << std::endl; + //- switch the novelec type : + switch(_MCCE2electroTypeNumber) + { + case 1 : _range = Novelec_MCCE2::check_range_value(rangeStr, NType1_rangeValue); + break; + case 2 : _range = Novelec_MCCE2::check_range_value(rangeStr, NType2_rangeValue); + break; + case 3 : _range = Novelec_MCCE2::check_range_value(rangeStr, NType3_rangeValue); + break; + } + std::cout << "\t N_PhotoVoltaique::get_ElectroMeterRange idx found = " << _range << std::endl; + + if (_range < 0) + throw electrometer::ElectrometerException("INVALID_PARAMETER", + "Cannot find the applied range value.", + "N_PhotoVoltaique::get_ElectroMeterRange( )."); + + return rangeStr; +} \ No newline at end of file diff --git a/src/NovelecProtocol.cpp b/src/NovelecProtocol.cpp index 572cea9..2be3272 100644 --- a/src/NovelecProtocol.cpp +++ b/src/NovelecProtocol.cpp @@ -45,12 +45,13 @@ static const long READ_DATA_RESP_LGTH = 24; static const char END_OF_LINE[] = "\r\n"; //- modes allowed static const std::string mode_str[] = {"ERR : UNKNOWN MODE","ZERO V/F","OFFSET","LEAKAGE","TEST","MEASURE"}; -static const std::string range_str[5][8]= { {"1e-11AcC","3e-11AcC","1e-10AcC","3e-10AcC", "OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"}, - {"1e-10AcC","3e-10AcC","1e-9AcC","3e-9AcC","1e-8AcC","3e-8AcC","1e-7AcC","3e-7AcC"}, - {"1e-8AcC","3e-8AcC","1e-7AcC","3e-7AcC","1e-6AcC","3e-6AcC","1e-5AcC","3e-5AcC"}, - {"1000MOhm","300MOhm","100MOhm","30MOhm","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"}, - {"1000KOhm","300KOhm","100KOhm","30KOhm","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE",} - }; +static const std::string range_str[5][8]= { + {"1E-11AcC","3E-11AcC","1E-10AcC","3E-10AcC", "OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"}, + {"1E-10AcC","3E-10AcC","1E-9AcC","3E-9AcC","1E-8AcC","3E-8AcC","1E-7AcC","3E-7AcC"}, + {"1E-8AcC","3E-8AcC","1E-7AcC","3E-7AcC","1E-6AcC","3E-6AcC","1E-5AcC","3E-5AcC"}, + {"1000MOhm","300MOhm","100MOhm","30MOhm","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"}, + {"1000KOhm","300KOhm","100KOhm","30KOhm","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE","OUT OF RANGE"} +}; static const std::string frequency_str[]= {"3 Hz","10 Hz","100 Hz","1000 Hz"}; static const std::string gain_str[] = {"1","10","100"}; @@ -193,7 +194,7 @@ std::string tmp("no data"); argout = check_and_extract_data(tmp, MODE_CMD_NUM); //- check what is the response mode type - if( _is_explicite_resp_enabled == false ) + if( !_is_explicite_resp_enabled ) { short idx = XString<short>::convertFromString(argout); _function = mode_str[idx]; @@ -344,7 +345,7 @@ std::string cmdNumber(" 5"); //- PROG 1 -> = PROG FUNCTION std::string tmp("no data"); //- check if the MCCE2 is not in MEASURE mode to get/change any settings - this->is_allowed(); + //this->is_allowed(); //- allow parameters modification this->switch_MCCE2_OFF(); @@ -374,7 +375,7 @@ std::string tmp("no data"); //std::cout << "NovelecProtocol::get_range -> range brut : " << tmp /* << std::endl */; //- check and extract the response argout = check_and_extract_data(tmp, RANGE_CMD_NUM); -//std::cout << "NovelecProtocol::get_range -> range extrait : " << argout /* << std::endl */; +std::cout << "\t\t NovelecProtocol::get_range -> range extrait : $" << argout << "$" << std::endl; //- check what is the response mode type short idx = -1; @@ -382,6 +383,7 @@ std::string tmp("no data"); { idx = XString<short>::convertFromString(argout); argout = range_str[_novType-1][idx]; +std::cout << "\t\t NovelecProtocol::get_range -> range idx : " << idx << std::endl; } return argout; @@ -447,11 +449,21 @@ void NovelecProtocol::set_polarity (std::string newPolarity) { std::stringstream cmd_to_send; std::string tmp("no data"); +unsigned short polarity = 0xFFFF; - // //- check if the MCCE2 is not in MEASURE mode to get/change any settings - //this->is_allowed(); + //- check if the MCCE2 is not in MEASURE mode to get/change any settings + if ( newPolarity.find("POSIT") == std::string::npos ) + polarity = 0; //- 0 : positive + else if ( newPolarity.find("NEGAT") == std::string::npos ) + polarity = 1; //- negative + else + { + throw electrometer::ElectrometerException("INVALID_PARAMETER", + "Expected POSITIVE or NEGATIVE in UPPER case.", + "NovelecProtocol::set_polarity( )."); + } - //- allow parameters modification + //- allow parameters modification this->switch_MCCE2_OFF(); //- send command to Novelec device @@ -819,9 +831,17 @@ std::string cmd_sentStr; else _is_explicite_resp_enabled = true; - //- erase first and last space char - data.erase(data.find_first_of(" "),1); + //- erase first and last space char(s) data.erase(data.find_last_of(" ")); + size_t pos = data.find(" "); + while ( pos != std::string::npos ) + { + data.erase(pos, 1); + pos = data.find(" "); + } + + /*data.erase(data.find_first_of(" "),1); + data.erase(data.find_last_of(" ")); */ } else throw electrometer::ElectrometerException("SYNCHRONISATION_LOST", diff --git a/src/Novelec_MCCE2.cpp b/src/Novelec_MCCE2.cpp index e45e6b0..ce95840 100644 --- a/src/Novelec_MCCE2.cpp +++ b/src/Novelec_MCCE2.cpp @@ -87,6 +87,11 @@ bool Novelec_MCCE2::init_protocol (void) // ============================================================================ std::string Novelec_MCCE2::get_ElectroMeterPolarity (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::get_ElectroMeterPolarity( )."); + return _electrometerProtocol->get_polarity(); } @@ -95,6 +100,11 @@ std::string Novelec_MCCE2::get_ElectroMeterPolarity (void) // ============================================================================ void Novelec_MCCE2::set_ElectroMeterPolarity (std::string polarity) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::set_ElectroMeterPolarity( )."); + _electrometerProtocol->set_polarity(polarity); } @@ -103,6 +113,11 @@ void Novelec_MCCE2::set_ElectroMeterPolarity (std::string polarity) // ============================================================================ void Novelec_MCCE2::set_Zero_VonF_function (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::set_Zero_VonF_function( )."); + _electrometerProtocol->unable_zeroVF_func(); } @@ -111,6 +126,11 @@ void Novelec_MCCE2::set_Zero_VonF_function (void) // ============================================================================ void Novelec_MCCE2::set_Offset_ZeroV1_function (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::set_Offset_ZeroV1_function( )."); + _electrometerProtocol->unable_offset_zeroV1_func(); } @@ -119,6 +139,11 @@ void Novelec_MCCE2::set_Offset_ZeroV1_function (void) // ============================================================================ void Novelec_MCCE2::set_Leakage_ZeroV2_function (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::set_Leakage_ZeroV2_function( )."); + _electrometerProtocol->unable_leakage_zeroV2_func(); } @@ -127,6 +152,11 @@ void Novelec_MCCE2::set_Leakage_ZeroV2_function (void) // ============================================================================ void Novelec_MCCE2::set_Test_function (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::set_Test_function( )."); + _electrometerProtocol->unable_test_func(); } @@ -135,6 +165,11 @@ void Novelec_MCCE2::set_Test_function (void) // ============================================================================ void Novelec_MCCE2::set_Measure_function (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::set_Measure_function( )."); + _electrometerProtocol->unable_measure_func(); } @@ -143,6 +178,11 @@ void Novelec_MCCE2::set_Measure_function (void) // ============================================================================ void Novelec_MCCE2::mcce_on (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::mcce_on( )."); + _electrometerProtocol->switch_MCCE2_ON(); } @@ -151,6 +191,11 @@ void Novelec_MCCE2::mcce_on (void) // ============================================================================ void Novelec_MCCE2::mcce_off (void) { + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::mcce_off( )."); + _electrometerProtocol->switch_MCCE2_OFF(); } @@ -166,53 +211,59 @@ std::string Novelec_MCCE2::electrometer_status (void) short _errors = 0; short _type = 0; - NovelecProtocol* _nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); - if(!_nproto) + if( !this->_electrometerProtocol ) + throw electrometer::ElectrometerException("INIT_ERROR", + "Novelec protocol initialization failed.", + "Novelec_MCCE2::electrometer_status( )."); + + NovelecProtocol* nproto = dynamic_cast<NovelecProtocol*>(_electrometerProtocol); + if( !nproto ) throw electrometer::ElectrometerException("BAD_ALLOC", "Memory allocation failed to query the electrmometer status.", "Novelec_MCCE2::electrometer_status( )."); /*********************************************************************** DISABLED PART TO INCREASE SERIAL PERFORMANCE + ***********************************************************************/ //- get Electrometer type : - //try - //{ - // tmp = _nproto->get_electrotype(); - // _type = XString<short>::convertFromString(tmp); - //} - //catch(...) - //{ - // set_electroState(FAULT); - // throw electrometer::ElectrometerException("INTERNAL_ERROR", - // "Unable to query the electrmometer type.", - // "Novelec_MCCE2::electrometer_status( )."); - //} - - //argout = "\n\nINFOS :\n"; - //argout += "----------\n"; - - //switch(_type) - //{ - //case 1 : typeStr = "Photovolta�que UHS"; - // break; - //case 2 : typeStr = "Photovolta�que HS"; - // break; - //case 3 : typeStr = "Photovolta�que MS"; - // break; - //case 4 : typeStr = "Photoconducteur HS"; - // break; - //case 5 : typeStr = "Photoconducteur MS"; - // break; - //default : set_electroState(FAULT); - // argout = "Invalid status string returned !"; - // return argout; - //} - //argout += "Novelec type : " + typeStr + "\n"; - - ////- get Electrometer mode : - //argout += "Novelec mode : " + _electrometerProtocol->get_mode() + "\n"; + try + { + tmp = nproto->get_electrotype(); + _type = XString<short>::convertFromString(tmp); + } + catch(...) + { + set_electroState(FAULT); + throw electrometer::ElectrometerException("INTERNAL_ERROR", + "Unable to query the electrmometer type.", + "Novelec_MCCE2::electrometer_status( )."); + } + + argout = "\n\nINFOS :\n"; + argout += "----------\n"; + + switch(_type) + { + case 1 : typeStr = "Photovolta�que UHS"; + break; + case 2 : typeStr = "Photovolta�que HS"; + break; + case 3 : typeStr = "Photovolta�que MS"; + break; + case 4 : typeStr = "Photoconducteur HS"; + break; + case 5 : typeStr = "Photoconducteur MS"; + break; + default : set_electroState(FAULT); + argout = "Invalid status string returned !"; + return argout; + } + argout += "Novelec type : " + typeStr + "\n"; + + //- get Electrometer mode : + argout += "Novelec mode : " + _electrometerProtocol->get_mode() + "\n"; - ***********************************************************************/ + /***********************************************************************/ try { @@ -225,13 +276,10 @@ std::string Novelec_MCCE2::electrometer_status (void) catch(...) { set_electroState(FAULT); - argout = "Unable to query the electrometer status."; - throw; - return argout; - //throw electrometer::ElectrometerException("COMMUNICATION_ERROR", - // "Unable to query the electrmometer status.", - // "Novelec_MCCE2::electrometer_status( )."); + throw electrometer::ElectrometerException("COMMUNICATION_ERROR", + "Unable to query the electrmometer status.", + "Novelec_MCCE2::electrometer_status( )."); } argout += "\nStatus detail :\n"; @@ -268,7 +316,7 @@ std::string Novelec_MCCE2::electrometer_status (void) { //- read novelec error(s) from HW //std::cout << "Novelec_MCCE2::get_errors ..." << std::endl; - tmp = _nproto->get_errors(); + tmp = nproto->get_errors(); //std::cout << "Novelec_MCCE2::convertFromString -> get_errors = \"" << tmp << "\"" << std::endl; _errors = XString<short>::convertFromString(tmp); //std::cout << "Novelec_MCCE2::convertFromString -> convertFromString = \"" << _errors << "\"" << std::endl; @@ -320,11 +368,19 @@ std::string Novelec_MCCE2::electrometer_status (void) // ============================================================================ short Novelec_MCCE2::check_range_value (const std::string& rgToCheck, const std::string* electroRangeList) { + std::string electroRg(""); for (unsigned int idx = 0; idx < _rangeLimit; idx++) { - if(electroRangeList[idx].find(rgToCheck) != std::string::npos) - //- value is in the list - return idx; + electroRg = electroRangeList[idx]; + std::cout << "\t Novelec_MCCE2::check_range_value idx = " << idx + << " rgToCheck = $" << rgToCheck << "$" + << " electroRg = $" << electroRg << "$" + << std::endl; + if( electroRg.find(rgToCheck) != std::string::npos ) + { + //- value is in the list + return idx; + } } //- new range value not found in the electrometer range list ! diff --git a/src/TangoGpibLink.cpp b/src/TangoGpibLink.cpp index df0be07..a7b7494 100644 --- a/src/TangoGpibLink.cpp +++ b/src/TangoGpibLink.cpp @@ -187,7 +187,7 @@ std::string TangoGpibLink::read (void) throw (Tango::DevFailed) // ============================================================================ // TangoGpibLink::write_read // ============================================================================ -std::string TangoGpibLink::write_read (std::string command_to_send) throw (Tango::DevFailed) +std::string TangoGpibLink::write_read (std::string command_to_send, size_t unusedLgth) throw (Tango::DevFailed) { std::string description(""); diff --git a/src/TangoSerialLink.cpp b/src/TangoSerialLink.cpp index 094b760..4c76d01 100644 --- a/src/TangoSerialLink.cpp +++ b/src/TangoSerialLink.cpp @@ -273,33 +273,33 @@ std::string TangoSerialLink::read (long nbCharToRead) throw (Tango::DevFailed) // ============================================================================ // TangoSerialLink::write_read // ============================================================================ -std::string TangoSerialLink::write_read (std::string command_to_send) throw (Tango::DevFailed) -{ - if(!_serial_proxy) - create_serial_proxy(); - Tango::DeviceData dd_in; - - std::string respTmp(""); - long flush_in_out = 2; - dd_in << flush_in_out; - - //- Flush buffers ( In & Out = 2 ) - this->_serial_proxy->command_inout("DevSerFlush", dd_in); - - omni_thread::sleep(0, 200000000); //200 milliseconds - write(command_to_send); - - //- sleep a little bit to let the adapter(RS232/485) to switch mode - omni_thread::sleep(0, 100000000); //100 milliseconds - - // now read response from HW - return this->read(); -} +//std::string TangoSerialLink::write_read (std::string command_to_send) throw (Tango::DevFailed) +//{ +// if(!_serial_proxy) +// create_serial_proxy(); +// Tango::DeviceData dd_in; +// +// std::string respTmp(""); +// long flush_in_out = 2; +// dd_in << flush_in_out; +// +// //- Flush buffers ( In & Out = 2 ) +// this->_serial_proxy->command_inout("DevSerFlush", dd_in); +// +// omni_thread::sleep(0, 200000000); //200 milliseconds +// write(command_to_send); +// +// //- sleep a little bit to let the adapter(RS232/485) to switch mode +// omni_thread::sleep(0, 100000000); //100 milliseconds +// +// // now read response from HW +// return this->read(); +//} // ============================================================================ // TangoSerialLink::write_read : read N char // ============================================================================ -std::string TangoSerialLink::write_read (std::string command_to_send, long nbChar) throw (Tango::DevFailed) +std::string TangoSerialLink::write_read (std::string command_to_send, size_t nbChar) throw (Tango::DevFailed) { if(!_serial_proxy) create_serial_proxy(); -- GitLab