From 180c8a807b3a02b023a300241cab1f61e2cdd62a Mon Sep 17 00:00:00 2001 From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr> Date: Wed, 14 Oct 2009 15:26:17 +0000 Subject: [PATCH] KeithleyMemory leak fixed. Novelec part updated --- include/AbstractElectrometerClass.h | 66 ++++++++++++++++------------- include/ElectrometerProtocol.h | 53 ++++++++++++++--------- include/KeithleyDDCProtocol.h | 5 +++ include/KeithleySCPIProtocol.h | 5 +++ include/Keithley_485.h | 5 +++ include/Keithley_486.h | 19 ++++++--- include/Keithley_487.h | 5 +++ include/Keithley_617.h | 5 +++ include/Keithley_6485.h | 5 +++ include/Keithley_6487.h | 5 +++ include/Keithley_6512.h | 5 +++ include/Keithley_6514.h | 5 +++ include/Keithley_6517.h | 5 +++ include/NovelecProtocol.h | 7 ++- include/Novelec_MCCE2.h | 9 ++-- src/AbstractElectrometerClass.cpp | 6 ++- src/KeithleyDDCProtocol.cpp | 20 ++++++++- src/KeithleySCPIProtocol.cpp | 41 ++++++++++++------ src/Keithley_485.cpp | 38 ++++++++++++++++- src/Keithley_486.cpp | 39 ++++++++++++++++- src/Keithley_487.cpp | 37 ++++++++++++++++ src/Keithley_617.cpp | 40 +++++++++++++++-- src/Keithley_6485.cpp | 51 +++++++++++++++++++--- src/Keithley_6487.cpp | 51 +++++++++++++++++++--- src/Keithley_6512.cpp | 40 +++++++++++++++-- src/Keithley_6514.cpp | 51 +++++++++++++++++++--- src/Keithley_6517.cpp | 52 +++++++++++++++++++---- src/NovelecProtocol.cpp | 41 ++++++++++++------ src/Novelec_MCCE2.cpp | 42 ++++++++++++++++-- 29 files changed, 619 insertions(+), 134 deletions(-) diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h index dea993a..95beda0 100644 --- a/include/AbstractElectrometerClass.h +++ b/include/AbstractElectrometerClass.h @@ -9,9 +9,13 @@ // // $Author: xavela $ // -// $Revision: 1.16 $ +// $Revision: 1.17 $ // // $Log: not supported by cvs2svn $ +// Revision 1.16 2009/03/12 09:29:00 xavela +// xavier: +// Keithley part : support for 6517. +// // Revision 1.15 2009/03/10 10:29:14 xavela // xavier: // range values ordered @@ -97,6 +101,7 @@ #ifndef _ABSTRACT_ELECTROMETER_CLASS_H_ #define _ABSTRACT_ELECTROMETER_CLASS_H_ +#include <tango.h> //- Tango exceptions #include "ElectrometerProtocol.h" /** @@ -122,31 +127,32 @@ public: /** * \brief Electrometer common functions. */ - virtual void range_up (void) = 0; - virtual void range_down (void) = 0; - virtual void reset (void); - virtual void local (void); - virtual void remote (void); + virtual bool init_protocol (void) = 0; + virtual void range_up (void) = 0; + virtual void range_down (void) = 0; + virtual void reset (void); + virtual void local (void); + virtual void remote (void); /** * \brief Electrometer : cmd to get electrometer data. */ - std::string get_value (void); + std::string get_value (void); virtual std::vector<double> get_integratedValue (void); virtual std::vector<double> get_fetchValue (void); /** * \brief Keithley Electrometer methods */ - void autoRange_on (void); + void autoRange_on (void); void zero_check_on (void); void zero_check_off (void); void zero_correct_on (void); void zero_correct_off (void); - virtual void auto_zero_on (void); + virtual void auto_zero_on (void); virtual void auto_zero_off (void); virtual void autoRange_off (void); - virtual void setAmperMeterMode (void); + virtual void setAmperMeterMode(void); virtual void setVoltMeterMode (void); virtual void setOhmMeterMode (void); virtual void setCoulombMeterMode(void); @@ -155,34 +161,34 @@ public: * \brief Following functions are only supported for SCPI protocol * */ - void abort (void); + void abort (void); virtual void init_keithley (void); - void clear_registers (void); + void clear_registers (void); virtual void averageStateON (void); virtual void averageStateOFF (void); - virtual void set_knplc (float nPLC); + virtual void set_knplc (float nPLC); virtual void set_triggercount (short trigcounts); - void set_triggerdelay (std::string trigdelay); - void set_triggerdelayAuto (std::string trigdelAuto); + void set_triggerdelay (std::string trigdelay); + void set_triggerdelayAuto (std::string trigdelAuto); virtual void set_averagecount (std::string avercounts); virtual void set_averagecontrol (std::string averctrl); - std::string get_knplc (void); + std::string get_knplc (void); std::string get_triggercount (void); std::string get_triggerdelay (void); std::string get_triggerdelayAuto(void); virtual std::string get_averagecount (void); - virtual std::string get_averagecontrol (void); + virtual std::string get_averagecontrol(void); virtual void clear_buffer (void); - virtual void store_raw_input (void); - virtual void start_storing (void); + virtual void store_raw_input (void); + virtual void start_storing (void); void enable_SRQBufferFull (void); - void disable_SRQBufferFull (void); + void disable_SRQBufferFull (void); virtual bool SRQLineState (void); //- used to know if the integration cycle is done! virtual short readStatusByteRegister (void); //- device status byte register value on SRQ! bool get_overloadRangeState (void); //- used to know if the device range is overloaded (DDC Keithley ONLY)! virtual void set_buffer_size (short); virtual void set_triggerMode (short); - virtual void set_integrationTime (double); + virtual void set_integrationTime (double); virtual short get_buffer_size (void); virtual short get_triggerMode (void) { return _trigMod;}; @@ -192,8 +198,8 @@ public: * Following functions are only supported for Novelec Protocol */ virtual void set_Zero_VonF_function (void); - virtual void set_Offset_ZeroV1_function (void); - virtual void set_Leakage_ZeroV2_function (void); + virtual void set_Offset_ZeroV1_function (void); + virtual void set_Leakage_ZeroV2_function(void); virtual void set_Test_function (void); virtual void set_Measure_function (void); virtual void mcce_on (void); @@ -205,10 +211,10 @@ public: virtual std::string get_ElectroMeterPolarity (void); virtual std::string get_ElectroMeterFrequency (void); virtual std::string get_ElectroMeterGain (void); - virtual unsigned short get_ElectroChannel (void); - virtual void set_ElectroMeterRange (std::string rang); - virtual void set_ElectroMeterPolarity (std::string pola); - virtual void set_ElectroMeterFrequency (std::string freq); + virtual unsigned short get_ElectroChannel (void); + virtual void set_ElectroMeterRange (std::string rang); + virtual void set_ElectroMeterPolarity (std::string pola); + virtual void set_ElectroMeterFrequency (std::string freq); virtual void set_ElectroMeterGain (std::string gain); virtual void set_ElectroChannel (unsigned short address); @@ -249,9 +255,9 @@ protected : void set_electroState(ElectroState newState) { electrometerState = newState; }; short _range; - std::string _rangeStr; - std::string _mode; - std::string _device_proxy_name; + std::string _rangeStr; + std::string _mode; + std::string _device_proxy_name; ElectrometerProtocol* _electrometerProtocol; //- for internal use -> to configure the Integration mode diff --git a/include/ElectrometerProtocol.h b/include/ElectrometerProtocol.h index b539a9b..5240db5 100644 --- a/include/ElectrometerProtocol.h +++ b/include/ElectrometerProtocol.h @@ -12,9 +12,13 @@ // // $Author: xavela $ // -// $Revision: 1.11 $ +// $Revision: 1.12 $ // // $Log: not supported by cvs2svn $ +// Revision 1.11 2009/01/19 12:00:25 xavela +// xavier : +// - MCCE2 (Novelec part) : methods to change the active channel to communicate with. +// // Revision 1.10 2008/06/20 14:36:24 xavela // xavier : // - DDC status show only errors if any @@ -102,6 +106,12 @@ public: */ virtual ~ElectrometerProtocol (); + + /** + * \brief create the communication device proxy. + */ + virtual bool build_communicationLink() = 0; + /** * \brief Common Electrometer Functions. */ @@ -138,10 +148,10 @@ public: */ virtual void init_keithley (void); virtual void abort (void); - virtual void set_knplc (std::string nPLC); + virtual void set_knplc (std::string nPLC); virtual void set_triggercount (std::string trigcounts); virtual void set_triggerdelay (std::string trigdelay); - virtual void set_triggerMode (std::string); + virtual void set_triggerMode (std::string); virtual void set_triggerdelayAuto (std::string trigdelAuto); virtual void set_averagecount (std::string avercounts); virtual void set_averagecontrol (std::string averctrl); @@ -149,23 +159,23 @@ public: virtual std::string get_triggercount (void); virtual std::string get_triggerdelay (void); virtual std::string get_triggerdelayAuto(void); - virtual std::string get_averagecount (void); + virtual std::string get_averagecount (void); virtual std::string get_averagecontrol (void); virtual void clear_registers (void); virtual void averageStateON (void); virtual void averageStateOFF (void); - virtual void setAmperMeterMode (void); + virtual void setAmperMeterMode(void); virtual void setVoltMeterMode (void); virtual void setOhmMeterMode (void); virtual void setCoulombMeterMode(void); - virtual void autoRange_on (void); + virtual void autoRange_on (void); virtual void autoRange_off (void); virtual void zero_check_on (void); virtual void zero_check_off (void); virtual void zero_correct_on (void); virtual void zero_correct_off (void); - virtual void auto_zero_on (void); + virtual void auto_zero_on (void); virtual void auto_zero_off (void); /** @@ -186,37 +196,38 @@ public: virtual void enable_readingsFromBuffer_K486_487 (void); virtual void read_data_with_no_timestamp (void); - virtual std::string get_buffer_size (void); + virtual std::string get_buffer_size (void); //- only for K_486 and K_487 devices - virtual void enable_integrationPeriod (void); + virtual void enable_integrationPeriod(void); /** * \brief Electrometer : Novelec protocol dependent commands. */ - virtual void switch_MCCE2_ON (void); - virtual void switch_MCCE2_OFF (void); - virtual void init_MCCE2_for_communication (void); - virtual void unable_zeroVF_func (void); + virtual void switch_MCCE2_ON (void); + virtual void switch_MCCE2_OFF (void); + virtual void init_MCCE2_for_communication(void); + virtual void unable_zeroVF_func (void); virtual void unable_offset_zeroV1_func (void); virtual void unable_leakage_zeroV2_func (void); - virtual void unable_test_func (void); + virtual void unable_test_func (void); virtual void unable_measure_func (void); - virtual std::string get_polarity (void); - virtual std::string get_frequency (void); - virtual std::string get_gain (void); + virtual std::string get_polarity (void); + virtual std::string get_frequency (void); + virtual std::string get_gain(void); virtual void set_polarity (std::string pola); - virtual void set_frequency (std::string freq); - virtual void set_gain (std::string gain); + virtual void set_frequency (std::string freq); + virtual void set_gain (std::string gain); virtual unsigned short get_electrometer_active_channel(void); - virtual void set_electrometer_active_channel (unsigned short address); + virtual void set_electrometer_active_channel(unsigned short address); protected : short _range; - std::string _mode; + std::string _mode; + std::string _commDevName; //- communication device proxy name CommunicationLink* _communication_link; private : diff --git a/include/KeithleyDDCProtocol.h b/include/KeithleyDDCProtocol.h index 1e4939c..34cc954 100644 --- a/include/KeithleyDDCProtocol.h +++ b/include/KeithleyDDCProtocol.h @@ -44,6 +44,11 @@ public: virtual ~KeithleyDDCProtocol (void); /** + * \brief create the communication device proxy. + */ + bool build_communicationLink(); + + /** * \brief Electrometer Functions. */ void set_range (std::string value); diff --git a/include/KeithleySCPIProtocol.h b/include/KeithleySCPIProtocol.h index acb7ae7..d8c7b4c 100644 --- a/include/KeithleySCPIProtocol.h +++ b/include/KeithleySCPIProtocol.h @@ -44,6 +44,11 @@ public: */ virtual ~KeithleySCPIProtocol (void); + /** + * \brief create the communication device proxy. + */ + bool build_communicationLink(); + /** * \brief Electrometer Functions. */ diff --git a/include/Keithley_485.h b/include/Keithley_485.h index 7623bf5..90ce6bb 100644 --- a/include/Keithley_485.h +++ b/include/Keithley_485.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_485 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ diff --git a/include/Keithley_486.h b/include/Keithley_486.h index 53d060a..1f74840 100644 --- a/include/Keithley_486.h +++ b/include/Keithley_486.h @@ -42,16 +42,21 @@ public: */ virtual ~Keithley_486 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ - void range_up (void); - void range_down (void); - void autoRange_off (void); - void set_buffer_size (short); - void set_triggerMode (short); - void init_keithley (void); - short get_buffer_size (void) { return _size; }; + void range_up (void); + void range_down (void); + void autoRange_off (void); + 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). diff --git a/include/Keithley_487.h b/include/Keithley_487.h index ca4bd7d..33baa33 100644 --- a/include/Keithley_487.h +++ b/include/Keithley_487.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_487 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Electrometer methods. */ diff --git a/include/Keithley_617.h b/include/Keithley_617.h index d4a11f9..d90bf9f 100644 --- a/include/Keithley_617.h +++ b/include/Keithley_617.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_617 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ diff --git a/include/Keithley_6485.h b/include/Keithley_6485.h index a42829a..a8c9de0 100644 --- a/include/Keithley_6485.h +++ b/include/Keithley_6485.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_6485 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + 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 7b4c13d..67cf108 100644 --- a/include/Keithley_6487.h +++ b/include/Keithley_6487.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_6487 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ diff --git a/include/Keithley_6512.h b/include/Keithley_6512.h index 11b7749..e834aa2 100644 --- a/include/Keithley_6512.h +++ b/include/Keithley_6512.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_6512 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ diff --git a/include/Keithley_6514.h b/include/Keithley_6514.h index 1b2c73b..f234640 100644 --- a/include/Keithley_6514.h +++ b/include/Keithley_6514.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_6514 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ diff --git a/include/Keithley_6517.h b/include/Keithley_6517.h index fcccd5a..cffe442 100644 --- a/include/Keithley_6517.h +++ b/include/Keithley_6517.h @@ -42,6 +42,11 @@ public: */ virtual ~Keithley_6517 (void); + /** + * \brief protocole initailisation. + */ + bool init_protocol (void); + /** * \brief Device dependent commands. */ diff --git a/include/NovelecProtocol.h b/include/NovelecProtocol.h index 1d4c12c..9f89837 100644 --- a/include/NovelecProtocol.h +++ b/include/NovelecProtocol.h @@ -36,7 +36,7 @@ public: /** * \brief Initialization. */ - NovelecProtocol (std::string& gpib_device_name, short channel_address, short electroTypeNumber); + NovelecProtocol (std::string& gpib_device_name, unsigned short channel_address, unsigned short electroTypeNumber); /** * \brief Release resources. @@ -44,6 +44,11 @@ public: virtual ~NovelecProtocol(void); /** + * \brief create the communication device proxy. + */ + bool build_communicationLink(); + + /** * \brief Electrometer Functions. */ void set_range (std::string value); diff --git a/include/Novelec_MCCE2.h b/include/Novelec_MCCE2.h index 16c01dd..95b8c3b 100644 --- a/include/Novelec_MCCE2.h +++ b/include/Novelec_MCCE2.h @@ -35,13 +35,15 @@ public: /** * \brief Initialization. */ - Novelec_MCCE2 (std::string& comLink_device_name, short channel_address, short electroType); + Novelec_MCCE2 (std::string& comLink_device_name, unsigned short channel_address, unsigned short electroType); /** * \brief Release resources. */ virtual ~Novelec_MCCE2 (void); + bool init_protocol(void); + std::string get_ElectroMeterPolarity(void); void set_ElectroMeterPolarity (std::string); @@ -75,8 +77,9 @@ public: std::string electrometer_status (void); protected : - unsigned short _rangeLimit; //- define the range limit for each novelec type - unsigned short _MCCE2electroTypeNumber; //- the mcce2 electrometer type number (to check rang value) + unsigned short _rangeLimit; //- define the range limit for each novelec type + unsigned short _address; //- a DAIP manages 2 "channels" (or address) + unsigned short _MCCE2electroTypeNumber; //- the mcce2 electrometer type number (to check range value) /** * \brief Checks the new range value diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp index 44e36c8..b418761 100644 --- a/src/AbstractElectrometerClass.cpp +++ b/src/AbstractElectrometerClass.cpp @@ -11,9 +11,12 @@ // // $Author: xavela $ // -// $Revision: 1.18 $ +// $Revision: 1.19 $ // // $Log: not supported by cvs2svn $ +// Revision 1.18 2009/10/12 08:50:41 xavela +// minor change : cmd reset (*RST) added for DDCs. +// // Revision 1.17 2009/03/18 10:25:29 xavela // xavier : // - Novelec part updated and tested ! @@ -151,7 +154,6 @@ AbstractElectrometerClass::~AbstractElectrometerClass (void) // std::cout << "AbstractElectrometerClass::~AbstractElectrometerClass ->" << std::endl; } - // ============================================================================ // AbstractElectrometerClass::zero_check_on // ============================================================================ diff --git a/src/KeithleyDDCProtocol.cpp b/src/KeithleyDDCProtocol.cpp index 46836e0..399fcf7 100644 --- a/src/KeithleyDDCProtocol.cpp +++ b/src/KeithleyDDCProtocol.cpp @@ -26,11 +26,11 @@ // ============================================================================ KeithleyDDCProtocol::KeithleyDDCProtocol (std::string& gpib_device_name) : ElectrometerProtocol(), -_is_overloaded(false) + _is_overloaded(false) { std::cout << "KeithleyDDCProtocol::KeithleyDDCProtocol <-" << std::endl; - _communication_link = new TangoGpibLink (gpib_device_name); + _commDevName = gpib_device_name; std::cout << "KeithleyDDCProtocol::KeithleyDDCProtocol ->" << std::endl; } @@ -45,6 +45,22 @@ KeithleyDDCProtocol::~KeithleyDDCProtocol (void) std::cout << "KeithleyDDCProtocol::~KeithleyDDCProtocol ->" << std::endl; } +// ============================================================================ +// KeithleyDDCProtocol::build_communicationLink +// ============================================================================ +bool KeithleyDDCProtocol::build_communicationLink() +{ + if (_commDevName.empty()) + return false; + + _communication_link = new TangoGpibLink (_commDevName); + + if (!_communication_link) + return false; + + return true; +} + // ============================================================================ // KeithleyDDCProtocol::set_range // ============================================================================ diff --git a/src/KeithleySCPIProtocol.cpp b/src/KeithleySCPIProtocol.cpp index 3389d14..b9f1cb3 100644 --- a/src/KeithleySCPIProtocol.cpp +++ b/src/KeithleySCPIProtocol.cpp @@ -36,18 +36,7 @@ KeithleySCPIProtocol::KeithleySCPIProtocol (std::string& gpib_device_name) { std::cout << "KeithleySCPIProtocol::KeithleySCPIProtocol <-" << std::endl; - _communication_link = new TangoGpibLink (gpib_device_name); - -std::string cmd_to_send(""); - //- Select reading only - cmd_to_send = "FORM:ELEM READ"; - _communication_link->write(cmd_to_send); - //- Select control source : IMMediate - cmd_to_send = "ARM:SOUR IMM"; - _communication_link->write(cmd_to_send); - //- Set measure count - cmd_to_send = "ARM:COUNT 1"; - _communication_link->write(cmd_to_send); + _commDevName = gpib_device_name; std::cout << "KeithleySCPIProtocol::KeithleySCPIProtocol ->" << std::endl; } @@ -62,6 +51,34 @@ KeithleySCPIProtocol::~KeithleySCPIProtocol (void) std::cout << "KeithleySCPIProtocol::~KeithleySCPIProtocol ->" << std::endl; } +// ============================================================================ +// KeithleySCPIProtocol::build_communicationLink +// ============================================================================ +bool KeithleySCPIProtocol::build_communicationLink() +{ + if (_commDevName.empty()) + return false; + + _communication_link = new TangoGpibLink (_commDevName); + + if (!_communication_link) + return false; + + //- configure tthe SCPI Keithley device + std::string cmd_to_send(""); + //- Select reading only + cmd_to_send = "FORM:ELEM READ"; + _communication_link->write(cmd_to_send); + //- Select control source : IMMediate + cmd_to_send = "ARM:SOUR IMM"; + _communication_link->write(cmd_to_send); + //- Set measure count + cmd_to_send = "ARM:COUNT 1"; + _communication_link->write(cmd_to_send); + + return true; +} + // ============================================================================ // KeithleySCPIProtocol::set_range // ============================================================================ diff --git a/src/Keithley_485.cpp b/src/Keithley_485.cpp index 6d53f39..015081d 100644 --- a/src/Keithley_485.cpp +++ b/src/Keithley_485.cpp @@ -43,8 +43,6 @@ Keithley_485::Keithley_485 (std::string& comLink_device_name):AbstractElectromet { std::cout << "Keithley_485::Keithley_485 <-" << std::endl; - - _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); std::cout << "Keithley_485::Keithley_485 ->" << std::endl; } @@ -59,6 +57,42 @@ Keithley_485::~Keithley_485 (void) std::cout << "Keithley_485::~Keithley_485 ->" << std::endl; } +// ============================================================================ +// Keithley_485::init_protocol +// ============================================================================ +bool Keithley_485::init_protocol (void) +{ + std::string description(""); + bool success = false; + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); + + if(_electrometerProtocol) + success = _electrometerProtocol->build_communicationLink(); + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_485::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_485::init_protocol"); + } + return success; +} + // ============================================================================ // Keithley_485::range_up // ============================================================================ diff --git a/src/Keithley_486.cpp b/src/Keithley_486.cpp index f7a6831..a42bb3a 100644 --- a/src/Keithley_486.cpp +++ b/src/Keithley_486.cpp @@ -48,8 +48,6 @@ Keithley_486::Keithley_486 (std::string& comLink_device_name):AbstractElectromet { std::cout << "Keithley_486::Keithley_486 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleyDDCProtocol(_device_proxy_name); _size = -1; _trigMod = -1; @@ -66,6 +64,43 @@ Keithley_486::~Keithley_486 (void) std::cout << "Keithley_486::~Keithley_486 ->" << std::endl; } +// ============================================================================ +// Keithley_486::init_protocol +// ============================================================================ +bool Keithley_486::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); + + if(_electrometerProtocol) + success = _electrometerProtocol->build_communicationLink(); + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_486::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_486::init_protocol"); + } + return success; +} + // ============================================================================ // Keithley_486::autoRange_off // ============================================================================ diff --git a/src/Keithley_487.cpp b/src/Keithley_487.cpp index 7e7f1fd..248b679 100644 --- a/src/Keithley_487.cpp +++ b/src/Keithley_487.cpp @@ -64,6 +64,43 @@ Keithley_487::~Keithley_487 (void) std::cout << "Keithley_487::~Keithley_487 ->" << std::endl; } +// ============================================================================ +// Keithley_487::init_protocol +// ============================================================================ +bool Keithley_487::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); + + if(_electrometerProtocol) + success = _electrometerProtocol->build_communicationLink(); + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_487::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_487::init_protocol"); + } + return success; +} + // ============================================================================ // Keithley_487::autoRange_off // ============================================================================ diff --git a/src/Keithley_617.cpp b/src/Keithley_617.cpp index 8ee8b25..4647207 100644 --- a/src/Keithley_617.cpp +++ b/src/Keithley_617.cpp @@ -47,9 +47,6 @@ Keithley_617::Keithley_617 (std::string& comLink_device_name):AbstractElectromet { std::cout << "Keithley_617::Keithley_617 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); - std::cout << "Keithley_617::Keithley_617 ->" << std::endl; } @@ -63,6 +60,43 @@ Keithley_617::~Keithley_617 (void) std::cout << "Keithley_617::~Keithley_617 ->" << std::endl; } +// ============================================================================ +// Keithley_617::init_protocol +// ============================================================================ +bool Keithley_617::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); + + if(_electrometerProtocol) + success = _electrometerProtocol->build_communicationLink(); + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_617::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_617::init_protocol"); + } + return success; +} + // ============================================================================ // Keithley_617::autoRange_off // ============================================================================ diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp index 6c4331d..9174d00 100644 --- a/src/Keithley_6485.cpp +++ b/src/Keithley_6485.cpp @@ -38,16 +38,9 @@ Keithley_6485::Keithley_6485 (std::string& comLink_device_name) { std::cout << "Keithley_6485::Keithley_6485 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleySCPIProtocol (_device_proxy_name); - _numPLC = 0; _trigCounts = 0; _size = 0; - //- this model does not support different mode (OhmMeter, VoltMeter and so on ) - KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); - if(_kscpi) - _kscpi->set_isDiffSuportedMode(false); std::cout << "Keithley_6485::Keithley_6485 ->" << std::endl; } @@ -62,6 +55,50 @@ Keithley_6485::~Keithley_6485 (void) std::cout << "Keithley_6485::~Keithley_6485 ->" << std::endl; } +// ============================================================================ +// Keithley_6485::init_protocol +// ============================================================================ +bool Keithley_6485::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleySCPIProtocol(_device_proxy_name); + + if (_electrometerProtocol) + { + //- this model supports different mode (OhmMeter, VoltMeter and so on ) + KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); + if(_kscpi) + _kscpi->set_isDiffSuportedMode(false); + + success = _electrometerProtocol->build_communicationLink(); + } + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6485::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6485::init_protocol"); + } + return success; +} + // ============================================================================ // Keithley_6485::range_up // ============================================================================ diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp index b9ee2b9..9c5998f 100644 --- a/src/Keithley_6487.cpp +++ b/src/Keithley_6487.cpp @@ -38,16 +38,9 @@ Keithley_6487::Keithley_6487 (std::string& comLink_device_name) { std::cout << "Keithley_6487::Keithley_6487 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleySCPIProtocol (_device_proxy_name); - _numPLC = 0; _trigCounts = 0; _size = 0; - //- this model does not support different mode (OhmMeter, VoltMeter and so on ) - KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); - if(_kscpi) - _kscpi->set_isDiffSuportedMode(false); std::cout << "Keithley_6487::Keithley_6487 ->" << std::endl; } @@ -62,6 +55,50 @@ Keithley_6487::~Keithley_6487 (void) std::cout << "Keithley_6487::~Keithley_6487 ->" << std::endl; } +// ============================================================================ +// Keithley_6487::init_protocol +// ============================================================================ +bool Keithley_6487::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleySCPIProtocol(_device_proxy_name); + + if (_electrometerProtocol) + { + //- this model supports different mode (OhmMeter, VoltMeter and so on ) + KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); + if(_kscpi) + _kscpi->set_isDiffSuportedMode(true); + + success = _electrometerProtocol->build_communicationLink(); + } + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6487::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6487::init_protocol"); + } + return success; +} + // ============================================================================ // Keithley_6487::range_up // ============================================================================ diff --git a/src/Keithley_6512.cpp b/src/Keithley_6512.cpp index 8307f0d..e923dc8 100644 --- a/src/Keithley_6512.cpp +++ b/src/Keithley_6512.cpp @@ -48,9 +48,6 @@ Keithley_6512::Keithley_6512 (std::string& comLink_device_name) { std::cout << "Keithley_6512::Keithley_6512 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); - std::cout << "Keithley_6512::Keithley_6512 ->" << std::endl; } @@ -65,6 +62,43 @@ Keithley_6512::~Keithley_6512 (void) } // ============================================================================ +// Keithley_6512::init_protocol +// ============================================================================ +bool Keithley_6512::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleyDDCProtocol (_device_proxy_name); + + if(_electrometerProtocol) + success = _electrometerProtocol->build_communicationLink(); + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6512::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6512::init_protocol"); + } + return success; +} + + // ============================================================================ // Keithley_6512::autoRange_off // ============================================================================ void Keithley_6512::autoRange_off (void) diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp index 19dc4b7..b8dae17 100644 --- a/src/Keithley_6514.cpp +++ b/src/Keithley_6514.cpp @@ -19,6 +19,7 @@ #include <string> #include <math.h> //- for ceil #include <Xstring.h> +#include <tango.h> //- Tango exceptions #include "Keithley_6514.h" #include "KeithleySCPIProtocol.h" /* @@ -50,16 +51,9 @@ Keithley_6514::Keithley_6514 (std::string& comLink_device_name) { std::cout << "Keithley_6514::Keithley_6514 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleySCPIProtocol(_device_proxy_name); - _numPLC = 0; _trigCounts = 0; _size = 0; - //- this model supports different mode (OhmMeter, VoltMeter and so on ) - KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); - if(_kscpi) - _kscpi->set_isDiffSuportedMode(true); std::cout << "Keithley_6514::Keithley_6514 ->" << std::endl; } @@ -74,6 +68,49 @@ Keithley_6514::~Keithley_6514 (void) std::cout << "Keithley_6514::~Keithley_6514 ->" << std::endl; } +// ============================================================================ +// Keithley_6514::init_protocol +// ============================================================================ +bool Keithley_6514::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleySCPIProtocol(_device_proxy_name); + + if (_electrometerProtocol) + { + //- this model supports different mode (OhmMeter, VoltMeter and so on ) + KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); + if(_kscpi) + _kscpi->set_isDiffSuportedMode(true); + + success = _electrometerProtocol->build_communicationLink(); + } + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6514::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6514::init_protocol"); + } + return success; +} // ============================================================================ // Keithley_6514::range_up diff --git a/src/Keithley_6517.cpp b/src/Keithley_6517.cpp index 3e012c5..16ce41f 100644 --- a/src/Keithley_6517.cpp +++ b/src/Keithley_6517.cpp @@ -45,14 +45,6 @@ _kmode("") { std::cout << "Keithley_6517::Keithley_6517 <-" << std::endl; - //- build the keithley Electrometer obj - _electrometerProtocol = new KeithleySCPIProtocol(_device_proxy_name); - - //- this model supports different mode (OhmMeter, VoltMeter and so on ) - KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); - if(_kscpi) - _kscpi->set_isDiffSuportedMode(true); - std::cout << "Keithley_6517::Keithley_6517 ->" << std::endl; } @@ -66,6 +58,50 @@ Keithley_6517::~Keithley_6517 (void) std::cout << "Keithley_6517::~Keithley_6517 ->" << std::endl; } +// ============================================================================ +// Keithley_6517::init_protocol +// ============================================================================ +bool Keithley_6517::init_protocol (void) +{ + std::string description(""); + bool success = false; + + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new KeithleySCPIProtocol(_device_proxy_name); + + if (_electrometerProtocol) + { + //- this model supports different mode (OhmMeter, VoltMeter and so on ) + KeithleySCPIProtocol* _kscpi = dynamic_cast<KeithleySCPIProtocol*>(_electrometerProtocol); + if(_kscpi) + _kscpi->set_isDiffSuportedMode(true); + + success = _electrometerProtocol->build_communicationLink(); + } + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6517::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Keithley_6517::init_protocol"); + } + + return success; +} // ============================================================================ // Keithley_6517::range_up diff --git a/src/NovelecProtocol.cpp b/src/NovelecProtocol.cpp index ddd3898..9557076 100644 --- a/src/NovelecProtocol.cpp +++ b/src/NovelecProtocol.cpp @@ -49,19 +49,44 @@ static const std::string gain_str[] = {"1","10","100"}; // ============================================================================ // NovelecProtocol::NovelecProtocol // ============================================================================ -NovelecProtocol::NovelecProtocol (std::string& serial_device_name, short devAddress, short novelecType) +NovelecProtocol::NovelecProtocol (std::string& serial_device_name, unsigned short devAddress, unsigned short novelecType) : ElectrometerProtocol(), _devAdd(devAddress), _novType(novelecType) { - - _communication_link = new TangoSerialLink (serial_device_name); + _commDevName = serial_device_name; _rangeParameterNum = _novType + 2; _function = "Not updated"; _is_measure_mode_on = false; _is_explicite_resp_enabled = false; } +// ============================================================================ +// NovelecProtocol::~NovelecProtocol +// ============================================================================ +NovelecProtocol::~NovelecProtocol (void) +{ +// std::cout << "NovelecProtocol::~NovelecProtocol <-" << std::endl; + +// std::cout << "NovelecProtocol::~NovelecProtocol ->" << std::endl; +} + +// ============================================================================ +// NovelecProtocol::build_communicationLink +// ============================================================================ +bool NovelecProtocol::build_communicationLink() +{ + if (_commDevName.empty()) + return false; + + _communication_link = new TangoSerialLink (_commDevName); + + if (!_communication_link) + return false; + + return true; +} + // ============================================================================ // NovelecProtocol::NovelecProtocol // ============================================================================ @@ -87,16 +112,6 @@ std::string tmp("no data"); _is_explicite_resp_enabled = true; } -// ============================================================================ -// NovelecProtocol::~NovelecProtocol -// ============================================================================ -NovelecProtocol::~NovelecProtocol (void) -{ -// std::cout << "NovelecProtocol::~NovelecProtocol <-" << std::endl; - -// std::cout << "NovelecProtocol::~NovelecProtocol ->" << std::endl; -} - // ============================================================================ // NovelecProtocol::switch_MCCE2_ON // ============================================================================ diff --git a/src/Novelec_MCCE2.cpp b/src/Novelec_MCCE2.cpp index e180960..15dffff 100644 --- a/src/Novelec_MCCE2.cpp +++ b/src/Novelec_MCCE2.cpp @@ -25,16 +25,14 @@ // ============================================================================ // Novelec_MCCE2::Novelec_MCCE2 // ============================================================================ -Novelec_MCCE2::Novelec_MCCE2 (std::string& comLink_device_name, short address, short novTypeNumber) +Novelec_MCCE2::Novelec_MCCE2 (std::string& comLink_device_name, unsigned short address, unsigned short novTypeNumber) : AbstractElectrometerClass(comLink_device_name), _rangeLimit(0), + _address(address), _MCCE2electroTypeNumber(novTypeNumber) { //std::cout << "Novelec_MCCE2::Novelec_MCCE2 <-" << std::endl; - //- build the Novelec Electrometer obj - _electrometerProtocol = new NovelecProtocol(_device_proxy_name, address, novTypeNumber); - //std::cout << "Novelec_MCCE2::Novelec_MCCE2 ->" << std::endl; } @@ -48,6 +46,42 @@ Novelec_MCCE2::~Novelec_MCCE2 (void) //std::cout << "Novelec_MCCE2::~Novelec_MCCE2 ->" << std::endl; } +// ============================================================================ +// Novelec_MCCE2::init_protocol +// ============================================================================ +bool Novelec_MCCE2::init_protocol (void) +{ + std::string description(""); + bool success = false; + try + { + //- build the keithley Electrometer protocol obj + _electrometerProtocol = new NovelecProtocol(_device_proxy_name, _address, _MCCE2electroTypeNumber); + + if(_electrometerProtocol) + success = _electrometerProtocol->build_communicationLink(); + } + catch(Tango::DevFailed& df) + { + description = "FAILED to create proxy on : " + _device_proxy_name; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Novelec_MCCE2::init_protocol"); + } + catch(...) + { + description = "FAILED to create proxy on : " + _device_proxy_name + ". Caught [...]."; + + Tango::Except::throw_exception ( + (const char*)"COMMUNICATION_ERROR", + description.c_str(), + (const char*)"Novelec_MCCE2::init_protocol"); + } + return success; +} + // ============================================================================ // Novelec_MCCE2::get_ElectroMeterPolarity // ============================================================================ -- GitLab