From 7b722c5ce0b77f8d6843aba83413ac776640674c Mon Sep 17 00:00:00 2001 From: Xavier Elattaoui <xavier.elattaoui@synchrotron-soleil.fr> Date: Wed, 13 Feb 2008 15:51:44 +0000 Subject: [PATCH] xavier : - Integration Mode available for DDC/SCPI devices - tests done with a K617 (DDC) and a K6485 (SCPI) --- include/AbstractElectrometerClass.h | 28 +++++--- include/CommunicationLink.h | 28 +++++++- include/ElectrometerProtocol.h | 13 +++- include/KeithleyDDCProtocol.h | 3 + include/KeithleySCPIProtocol.h | 9 ++- include/Keithley_6485.h | 12 +++- include/Keithley_6487.h | 13 +++- include/Keithley_6514.h | 14 +++- include/TangoGpibLink.h | 14 ++++ include/TangoSerialLink.h | 7 +- src/AbstractElectrometerClass.cpp | 27 +++++--- src/CommunicationLink.cpp | 38 ++++++++++- src/ElectrometerProtocol.cpp | 9 +++ src/KeithleyDDCProtocol.cpp | 88 ++++++++++++++++++++++-- src/KeithleySCPIProtocol.cpp | 23 +++++++ src/Keithley_486.cpp | 9 ++- src/Keithley_487.cpp | 13 +++- src/Keithley_617.cpp | 15 +++-- src/Keithley_6485.cpp | 100 ++++++++++++++++++++++++++- src/Keithley_6487.cpp | 97 +++++++++++++++++++++++++- src/Keithley_6512.cpp | 15 +++-- src/Keithley_6514.cpp | 101 ++++++++++++++++++++++++++-- src/TangoGpibLink.cpp | 56 +++++++++++++++ src/TangoSerialLink.cpp | 11 --- 24 files changed, 672 insertions(+), 71 deletions(-) diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h index 8e96db9..2e20027 100644 --- a/include/AbstractElectrometerClass.h +++ b/include/AbstractElectrometerClass.h @@ -9,9 +9,18 @@ // // $Author: xavela $ // -// $Revision: 1.5 $ +// $Revision: 1.6 $ // // $Log: not supported by cvs2svn $ +// Revision 1.5 2008/02/11 16:55:04 xavela +// xavier : for DDC part +// - integration mode OK (tests done with K_486) +// +// - TODO: DDC/SCPI +// integration time for ScanServer compatibility. +// report config for all DDC +// add configuration in SCPI start command +// // Revision 1.4 2008/02/08 17:24:32 xavela // xavier : for DDC part // - trigger mode and buffer size management added. @@ -100,8 +109,8 @@ public: void clear_registers (void); void averageStateON (void); void averageStateOFF (void); - void set_knplc (std::string nPLC); - void set_triggercount (std::string trigcounts); + 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_averagecount (std::string avercounts); @@ -112,9 +121,9 @@ public: std::string get_triggerdelayAuto(void); std::string get_averagecount (void); std::string get_averagecontrol(void); - void clear_buffer (void); - void store_raw_input (void); - void start_storing (void); + virtual void clear_buffer (void); + virtual void store_raw_input (void); + virtual void start_storing (void); void enable_SRQBufferFull (void); void disable_SRQBufferFull (void); virtual bool readStatusByteRegister (void); //- used to know if the integration cycle is done! @@ -165,9 +174,10 @@ protected : */ enum ElectroState { - ON = 0, - FAULT = 8, - ALARM = 11, + ON = 0, + FAULT = 8, + RUNNING = 10, + ALARM = 11, UNKNOWN = 13 }; diff --git a/include/CommunicationLink.h b/include/CommunicationLink.h index 8962a6b..75eba2b 100644 --- a/include/CommunicationLink.h +++ b/include/CommunicationLink.h @@ -12,9 +12,18 @@ // // $Author: xavela $ // -// $Revision: 1.2 $ +// $Revision: 1.3 $ // // $Log: not supported by cvs2svn $ +// Revision 1.2 2008/02/11 16:55:04 xavela +// xavier : for DDC part +// - integration mode OK (tests done with K_486) +// +// - TODO: DDC/SCPI +// integration time for ScanServer compatibility. +// report config for all DDC +// add configuration in SCPI start command +// // Revision 1.1 2007/07/09 13:20:35 stephle // initial import // @@ -84,7 +93,22 @@ public : * * \throws Tango::DevFailed */ - virtual bool isSRQLineUp(void)=0; + virtual bool isSRQLineUp(void); + + /** + * \brief Clear a specific device (same as reset *RST). + * + * \throws Tango::DevFailed + */ + virtual void clear(void); + + /** + * \brief Trigg device on the gpib bus. + * + * \throws Tango::DevFailed + */ + virtual void trigger(void); + protected : std::string _communication_Device_name; diff --git a/include/ElectrometerProtocol.h b/include/ElectrometerProtocol.h index 49f0d10..68b1802 100644 --- a/include/ElectrometerProtocol.h +++ b/include/ElectrometerProtocol.h @@ -12,9 +12,18 @@ // // $Author: xavela $ // -// $Revision: 1.4 $ +// $Revision: 1.5 $ // // $Log: not supported by cvs2svn $ +// Revision 1.4 2008/02/11 16:55:04 xavela +// xavier : for DDC part +// - integration mode OK (tests done with K_486) +// +// - TODO: DDC/SCPI +// integration time for ScanServer compatibility. +// report config for all DDC +// add configuration in SCPI start command +// // Revision 1.3 2008/02/08 17:24:32 xavela // xavier : for DDC part // - trigger mode and buffer size management added. @@ -139,6 +148,8 @@ public: virtual void enable_ReadingsFromElectrometer (void); virtual void enable_readingsFromBuffer_K617_6512(void); virtual void enable_readingsFromBuffer_K486_487 (void); + virtual void read_data_with_no_timestamp (void); + //- only for K_486 and K_487 devices virtual void enable_integrationPeriod (void); diff --git a/include/KeithleyDDCProtocol.h b/include/KeithleyDDCProtocol.h index 23b19b8..9a43a6b 100644 --- a/include/KeithleyDDCProtocol.h +++ b/include/KeithleyDDCProtocol.h @@ -69,6 +69,8 @@ public: * \brief Electrometer : cmd to get electrometer data. */ std::string get_value(void); + std::vector<double> get_integratedValue (void); + std::vector<double> get_fetchValue (void); /** * \brief Electrometer Mode. @@ -124,6 +126,7 @@ public: virtual void baseline_suppression_OFF(void); */ protected : + std::vector<double> buildDataList (std::string listToParse); private : diff --git a/include/KeithleySCPIProtocol.h b/include/KeithleySCPIProtocol.h index 3d4b2dd..6f4ea1c 100644 --- a/include/KeithleySCPIProtocol.h +++ b/include/KeithleySCPIProtocol.h @@ -73,10 +73,14 @@ public: /** * \brief Electrometer : cmd to get electrometer data. */ - std::string get_value (void); + std::string get_value (void); std::vector<double> get_integratedValue (void); std::vector<double> get_fetchValue (void); - bool readStatusByteRegister (void); //- used to know if the integration cycle is done! + + /** + * \brief Electrometer : cmd used to know if the integration cycle is done! + */ + bool readStatusByteRegister (void); void init_keithley (void); /** @@ -96,6 +100,7 @@ public: std::string get_triggerdelayAuto(void); std::string get_averagecount (void); std::string get_averagecontrol (void); + void read_data_with_no_timestamp(void); /** * \brief Electrometer : Buffer config */ diff --git a/include/Keithley_6485.h b/include/Keithley_6485.h index 9f2ae99..8456b93 100644 --- a/include/Keithley_6485.h +++ b/include/Keithley_6485.h @@ -47,13 +47,23 @@ public: /** * \brief Device dependent commands. */ - void range_up (void); + void range_up (void); void range_down (void); + /** + * \brief Methods to configure the integration mode. + */ + void set_knplc (float); + void set_triggercount (short); + void set_buffer_size (short); + void init_keithley (void); + private: //- method to obtain the range index void update_range (void); + float _numPLC; + short _trigCounts; }; /** @} */ //- end addtogroup diff --git a/include/Keithley_6487.h b/include/Keithley_6487.h index a564877..a134038 100644 --- a/include/Keithley_6487.h +++ b/include/Keithley_6487.h @@ -55,13 +55,20 @@ public: */ void setAmperMeterMode (void); - //- TODO : - // SCPI_Filters* _ddcFilters; - // SCPI_Triggers* _ddcTriggers; + /** + * \brief Methods to configure the integration mode. + */ + void set_knplc (float); + void set_triggercount (short); + void set_buffer_size (short); + void init_keithley (void); + private: //- method to obtain the range index void update_range (void); + float _numPLC; + short _trigCounts; }; /** @} */ //- end addtogroup diff --git a/include/Keithley_6514.h b/include/Keithley_6514.h index d844e27..9155249 100644 --- a/include/Keithley_6514.h +++ b/include/Keithley_6514.h @@ -58,14 +58,22 @@ public: void setOhmMeterMode (void); void setCoulombMeterMode (void); - //- TODO : - // SCPI_Filters* _ddcFilters; - // SCPI_Triggers* _ddcTriggers; + /** + * \brief Methods to configure the integration mode. + */ + void set_knplc (float); + void set_triggercount (short); + void set_buffer_size (short); + void init_keithley (void); + private: //- method to obtain the range index void update_range (void); std::string _kmode; + float _numPLC; + short _trigCounts; + }; /** @} */ //- end addtogroup diff --git a/include/TangoGpibLink.h b/include/TangoGpibLink.h index 22422d7..37066ed 100644 --- a/include/TangoGpibLink.h +++ b/include/TangoGpibLink.h @@ -76,6 +76,20 @@ public : */ bool isSRQLineUp(void) throw (Tango::DevFailed); + /** + * \brief Clear a specific device (same as reset *RST). + * + * \throws Tango::DevFailed + */ + void clear(void) throw (Tango::DevFailed); + + /** + * \brief Trigg device on the gpib bus. + * + * \throws Tango::DevFailed + */ + void trigger(void) throw (Tango::DevFailed); + private : /** diff --git a/include/TangoSerialLink.h b/include/TangoSerialLink.h index 9cf2bf7..07733b8 100644 --- a/include/TangoSerialLink.h +++ b/include/TangoSerialLink.h @@ -69,13 +69,12 @@ public : std::string write_read(std::string cmd) throw (Tango::DevFailed); /** - * \brief Returns the Gpib SRQ line state : used here to know if Keithley - * device is ready after an integration cycle. + * \brief Returns the Gpib SRQ line state : Not used HERR * * \throws Tango::DevFailed - */ - bool isSRQLineUp(void) throw (Tango::DevFailed); + bool isSRQLineUp(void) throw (Tango::DevFailed); + */ private : /** * Creates a proxy on the specified Serial Device. diff --git a/src/AbstractElectrometerClass.cpp b/src/AbstractElectrometerClass.cpp index b600a9a..2f25c41 100644 --- a/src/AbstractElectrometerClass.cpp +++ b/src/AbstractElectrometerClass.cpp @@ -11,9 +11,18 @@ // // $Author: xavela $ // -// $Revision: 1.6 $ +// $Revision: 1.7 $ // // $Log: not supported by cvs2svn $ +// Revision 1.6 2008/02/11 16:55:04 xavela +// xavier : for DDC part +// - integration mode OK (tests done with K_486) +// +// - TODO: DDC/SCPI +// integration time for ScanServer compatibility. +// report config for all DDC +// add configuration in SCPI start command +// // Revision 1.5 2008/02/08 17:24:33 xavela // xavier : for DDC part // - trigger mode and buffer size management added. @@ -163,9 +172,11 @@ void AbstractElectrometerClass::init_keithley (void) // ============================================================================ // AbstractElectrometerClass::set_knplc // ============================================================================ -void AbstractElectrometerClass::set_knplc (std::string nplcValueStr) +void AbstractElectrometerClass::set_knplc (float nplcValueStr) { - _electrometerProtocol->set_knplc(nplcValueStr); + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "This Electrometer does not support this command.", + "AbstractElectrometerClass::set_knplc( )."); } // ============================================================================ @@ -189,9 +200,11 @@ void AbstractElectrometerClass::set_triggerMode (short) // ============================================================================ // AbstractElectrometerClass::set_triggercount // ============================================================================ -void AbstractElectrometerClass::set_triggercount (std::string trigCountStr) +void AbstractElectrometerClass::set_triggercount (short trigCountStr) { - _electrometerProtocol->set_triggercount(trigCountStr); + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "This Electrometer does not support this command.", + "AbstractElectrometerClass::set_triggercount( )."); } // ============================================================================ @@ -379,9 +392,7 @@ std::string AbstractElectrometerClass::electrometer_status (void) { argout = _electrometerProtocol->get_raw_status( ); //- if no error the error code is 0 - if( XString<short>::convertFromString(&argout[0]) == ON) - set_electroState(ON); - else + if( XString<short>::convertFromString(&argout[0]) != ON) set_electroState(ALARM); } catch(...) diff --git a/src/CommunicationLink.cpp b/src/CommunicationLink.cpp index db2c7bf..526bb6c 100644 --- a/src/CommunicationLink.cpp +++ b/src/CommunicationLink.cpp @@ -12,9 +12,14 @@ // // $Author: xavela $ // -// $Revision: 1.2 $ +// $Revision: 1.3 $ // // $Log: not supported by cvs2svn $ +// Revision 1.2 2007/11/27 15:23:02 xavela +// xavier : +// - modif done on Novelec part : +// bug fix +// // Revision 1.1 2007/07/09 13:20:37 stephle // initial import // @@ -26,6 +31,7 @@ // ============================================================================ #include <iostream> #include "CommunicationLink.h" +#include "ElectrometerException.h" // ============================================================================ // CommunicationLink::CommunicationLink @@ -51,3 +57,33 @@ CommunicationLink::~CommunicationLink (void) //std::cout << "CommunicationLink::~CommunicationLink ->" << std::endl; } +// ============================================================================ +// CommunicationLink::isSRQLineUp +// ============================================================================ +bool CommunicationLink::isSRQLineUp (void) +{ + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "This protocol cannot check the SRQ line state.", + "CommunicationLink::isSRQLineUp( )."); +} + +// ============================================================================ +// CommunicationLink::clear +// ============================================================================ +void CommunicationLink::clear (void) +{ + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "This protocol cannot send interface clear command.", + "CommunicationLink::clear( )."); +} + +// ============================================================================ +// CommunicationLink::trigger +// ============================================================================ +void CommunicationLink::trigger (void) +{ + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "This protocol cannot send a trigger command.", + "CommunicationLink::trigger( )."); +} + diff --git a/src/ElectrometerProtocol.cpp b/src/ElectrometerProtocol.cpp index 1dd1cb6..074172d 100644 --- a/src/ElectrometerProtocol.cpp +++ b/src/ElectrometerProtocol.cpp @@ -670,3 +670,12 @@ void ElectrometerProtocol::enable_integrationPeriod (void) "ElectrometerProtocol::enable_integrationPeriod( )."); } +// ============================================================================ +// ElectrometerProtocol::read_data_with_no_timestamp +// ============================================================================ +void ElectrometerProtocol::read_data_with_no_timestamp (void) +{ + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "This Electrometer does not support this command.", + "ElectrometerProtocol::read_data_with_no_timestamp( )."); +} diff --git a/src/KeithleyDDCProtocol.cpp b/src/KeithleyDDCProtocol.cpp index 9562737..1673162 100644 --- a/src/KeithleyDDCProtocol.cpp +++ b/src/KeithleyDDCProtocol.cpp @@ -17,6 +17,7 @@ #include <iostream> #include <sstream> #include <string> +#include <Xstring.h> #include "KeithleyDDCProtocol.h" #include "TangoGpibLink.h" @@ -299,16 +300,93 @@ std::string argout("no data"); return argout; } +// ============================================================================ +// KeithleyDDCProtocol::get_integratedValue +// ============================================================================ +std::vector<double> KeithleyDDCProtocol::get_integratedValue (void) +{ +std::string tmp(""); + + //- This command queries the bufferised values after an integration + tmp = _communication_link->read(); + + //- extract all data + return buildDataList(tmp); +} + +// ============================================================================ +// KeithleyDDCProtocol::get_fetchValue +// ============================================================================ +std::vector<double> KeithleyDDCProtocol::get_fetchValue (void) +{ +std::string tmp(""); + + //- This command queries the last bufferised value(s) + tmp = _communication_link->read(); + + //- extract all data + return buildDataList(tmp); + +} + +// ============================================================================ +// KeithleyDDCProtocol::buildDataList +// +// This method extract and convert data from the received string +// ============================================================================ +std::vector<double> KeithleyDDCProtocol::buildDataList(std::string datalist) +{ +std::string dataStr(""); +std::vector<double> argout; +std::string::size_type posBeg; +std::string::size_type posEnd; +short numberOfData = 0; + //- + posBeg = 0; + posEnd = datalist.find(',', posBeg); +//-DEBUG std::cout << "\t*****::buildDataList -> argin :\n$" << datalist << "$" << std::endl; + //- there is just one value + if(posEnd == std::string::npos) + { + argout.push_back( XString<double>::convertFromString(datalist) ); +//-DEBUG std::cout << "\t*****::buildDataList -> JUST ONE DATA :$" << datalist << "$" << std::endl; + } + else + { +// int i = 0; + //std::string tmp = get_triggercount(); +// numberOfData = XString<short>::convertFromString(get_triggercount()); + + for(; posEnd != std::string::npos; ) + { + dataStr = datalist.substr(posBeg,posEnd); + argout.push_back( XString<double>::convertFromString(dataStr) ); +//-DEBUG std::cout << "\t*****::buildDataList -> FULL OF DATA : " << i << " -> $" << argout[i] << "$" << std::endl; + posBeg = posEnd+1; + posEnd = datalist.find(',', posBeg); + + //- end of string reached so latest data is here + if(posEnd == std::string::npos) + { + dataStr = datalist.substr(posBeg); + argout.push_back( XString<double>::convertFromString(dataStr) ); + break; + } + + } + } + + return argout; +} + // ============================================================================ // KeithleyDDCProtocol::reset // ============================================================================ void KeithleyDDCProtocol::reset (void) { -std::stringstream cmd_to_send; - //- send command to return to default conditions !! - cmd_to_send << "SDC" << std::ends; - _communication_link->write(cmd_to_send.str()); +// cmd_to_send << "*RST" << std::ends; + _communication_link->clear(); } // ============================================================================ @@ -431,7 +509,7 @@ std::string cmd_to_send("G1X"); } // ============================================================================ -// KeithleySCPIProtocol::enable_ReadingsFromElectrometer() +// KeithleyDDCProtocol::enable_ReadingsFromElectrometer() -> disable storing mode // ============================================================================ void KeithleyDDCProtocol::enable_ReadingsFromElectrometer (void) { diff --git a/src/KeithleySCPIProtocol.cpp b/src/KeithleySCPIProtocol.cpp index 9e404cc..7906ad7 100644 --- a/src/KeithleySCPIProtocol.cpp +++ b/src/KeithleySCPIProtocol.cpp @@ -18,6 +18,11 @@ #include <sstream> #include <string> #include <Xstring.h> +#ifndef WIN32 +# include <unistd.h> +#endif +//# include +//#endif #include "KeithleySCPIProtocol.h" #include "TangoGpibLink.h" @@ -433,6 +438,12 @@ void KeithleySCPIProtocol::init_keithley (void) { std::string cmd_to_send("INIT"); +#ifdef WIN32 + Sleep( 10 ); //- sleep just a few +#else + usleep(10000); +#endif + //- send command : INIT to trigg readings ! _communication_link->write(cmd_to_send); } @@ -798,6 +809,18 @@ bool KeithleySCPIProtocol::readStatusByteRegister (void) //- Chapter : Status Structure } +// ============================================================================ +// KeithleySCPIProtocol::read_data_with_no_timestamp +// ============================================================================ +void KeithleySCPIProtocol::read_data_with_no_timestamp (void) +{ +std::stringstream cmd_to_send; + + cmd_to_send << "FORM:ELEM READ" << std::endl; + _communication_link->write(cmd_to_send.str()); +} + + diff --git a/src/Keithley_486.cpp b/src/Keithley_486.cpp index 49e6374..289cce9 100644 --- a/src/Keithley_486.cpp +++ b/src/Keithley_486.cpp @@ -140,9 +140,14 @@ void Keithley_486::set_buffer_size (short size) { std::stringstream cmd_to_send; + //- check if size is valid + if(size<0 || size>512) + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Buffer size value invalid. Please enter a value in the range 0 - 512.", + "Keithley_487::set_buffer_size( )."); + //- just for internal use _size = size; - //- send command : size = number of triggers cmd_to_send << "N" << size << "X" << std::endl; _electrometerProtocol->set_buffer_size(cmd_to_send.str()); @@ -181,6 +186,8 @@ void Keithley_486::init_keithley (void) // _electrometerProtocol->enable_integrationPeriod( ); //- set trigger mode this->set_triggerMode(_trigMod); + //- default conversion rate + _electrometerProtocol->set_conversionRate( ); //- set buffer size this->set_buffer_size(_size); //- enable readings from device buffer diff --git a/src/Keithley_487.cpp b/src/Keithley_487.cpp index 941e80a..0c66e55 100644 --- a/src/Keithley_487.cpp +++ b/src/Keithley_487.cpp @@ -147,6 +147,8 @@ std::stringstream cmd_to_send; "Buffer size value invalid. Please enter a value in the range 0 - 512.", "Keithley_487::set_buffer_size( )."); + //- just for internal use + _size = size; //- send command : size = number of triggers cmd_to_send << "N" << size << "X" << std::endl; _electrometerProtocol->set_buffer_size(cmd_to_send.str()); @@ -165,7 +167,10 @@ void Keithley_487::set_triggerMode (short trigMod) std::stringstream cmd_to_send; - cmd_to_send << trigMod << std::endl; + //- just for internal use + _trigMod = trigMod; + + cmd_to_send << "T" << trigMod << "X" << std::endl; _electrometerProtocol->set_triggerMode(cmd_to_send.str()); @@ -203,10 +208,12 @@ void Keithley_487::setAmperMeterMode (void) // ============================================================================ void Keithley_487::init_keithley (void) { + //- set trigger mode + this->set_triggerMode(_trigMod); //- default conversion rate _electrometerProtocol->set_conversionRate( ); - //- set default integration period - _electrometerProtocol->enable_integrationPeriod( ); + //- set buffer size + this->set_buffer_size(_size); //- enable readings from device buffer _electrometerProtocol->enable_readingsFromBuffer_K486_487( ); //- force readings with no prefix diff --git a/src/Keithley_617.cpp b/src/Keithley_617.cpp index b2fbcbb..2050d01 100644 --- a/src/Keithley_617.cpp +++ b/src/Keithley_617.cpp @@ -144,11 +144,11 @@ std::string Keithley_617::get_ElectroMeterRange (void) // ============================================================================ void Keithley_617::set_buffer_size (short cmd) { -std::string cmd_to_send(""); +//std::string cmd_to_send(""); - //- send command : K_617 can store up to 100 points !!! - cmd_to_send = "Q0X"; - _electrometerProtocol->set_buffer_size(cmd_to_send); + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "The 617 Keithley device buffer size cannot be set (it stores up to 100 points internally.)", + "Keithley_617::set_triggerMode( )."); } @@ -164,7 +164,10 @@ void Keithley_617::set_triggerMode (short trigMod) std::stringstream cmd_to_send; - cmd_to_send << trigMod << std::endl; + //- just for internal use + _trigMod = trigMod; + + cmd_to_send << "T" << trigMod << "X" << std::endl; _electrometerProtocol->set_triggerMode(cmd_to_send.str()); } @@ -217,6 +220,8 @@ void Keithley_617::setCoulombMeterMode (void) // ============================================================================ void Keithley_617::init_keithley (void) { + //- set trigger mode + this->set_triggerMode(_trigMod); //- default conversion rate _electrometerProtocol->set_conversionRate( ); //- force readings with no prefix diff --git a/src/Keithley_6485.cpp b/src/Keithley_6485.cpp index 6b46658..691d6a1 100644 --- a/src/Keithley_6485.cpp +++ b/src/Keithley_6485.cpp @@ -33,13 +33,17 @@ static const short K6485_rangeLimit = 7; // ============================================================================ // Keithley_6485::Keithley_6485 // ============================================================================ -Keithley_6485::Keithley_6485 (std::string& comLink_device_name):AbstractElectrometerClass(comLink_device_name) +Keithley_6485::Keithley_6485 (std::string& comLink_device_name) +: AbstractElectrometerClass(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) @@ -178,3 +182,97 @@ std::vector<double> Keithley_6485::get_fetchValue (void) return _kscpi->get_fetchValue( ); } +// ============================================================================ +// Keithley_6485::set_knplc +// ============================================================================ +void Keithley_6485::set_knplc (float numPLC) +{ +std::stringstream cmd_to_send; + + if(numPLC <= 0 || numPLC > 5.0) + { + std::cout << "Keithley_6485::set_knplc -> " << numPLC << std::endl; + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid number of PLC.\n Please enter a value in the range 0.01 to 5.0.", + "Keithley_6485::set_knplc( )."); + } + //- just for internal use + _numPLC = numPLC; + + cmd_to_send << numPLC << std::endl; + //- default conversion rate + _electrometerProtocol->set_knplc(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6485::set_triggercount +// ============================================================================ +void Keithley_6485::set_triggercount (short trigCounts) +{ +std::stringstream cmd_to_send; + + if(trigCounts == 0 || trigCounts > 2500) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid trigger count.\n Please enter a value in the range 1 to 2500 or set -1 for INFinite.", + "Keithley_6485::set_triggercount( )."); + } + if(trigCounts < 0) + cmd_to_send << "INF" << std::endl; + else + cmd_to_send << trigCounts << std::endl; + + //- just for internal use + _trigCounts = trigCounts; + //- default conversion rate + _electrometerProtocol->set_triggercount(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6485::set_buffer_size +// ============================================================================ +void Keithley_6485::set_buffer_size (short size) +{ +std::stringstream cmd_to_send; + + if(size < 1 || size > 2500) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid buffer size. \nPlease enter a value in the range 1 to 2500.", + "Keithley_6485::set_buffer_size( )."); + } + //- just for internal use + _size = size; + + cmd_to_send << size << std::endl; + //- default conversion rate + _electrometerProtocol->set_buffer_size(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6485::init_keithley : command to perform an integration cycle +// ============================================================================ +void Keithley_6485::init_keithley (void) +{ + //- clear all registers + _electrometerProtocol->clear_registers(); + //- get data only (no timestamp info ... wanted!) + _electrometerProtocol->read_data_with_no_timestamp(); + //- Set integration rate in line cycles + this->set_knplc(_numPLC); + //- Set trigger model to take to N readings + this->set_triggercount(_trigCounts); + //- Set buffer size + this->set_buffer_size(_size); + //- clear previous data + _electrometerProtocol->clear_buffer(); + //- Store raw input + _electrometerProtocol->store_raw_input(); + //- Start storing on next reading + _electrometerProtocol->start_storing(); + //- Enable SRQ on buffer full + _electrometerProtocol->enable_SRQBufferFull(); + //- Trigger readings + _electrometerProtocol->init_keithley(); +} + diff --git a/src/Keithley_6487.cpp b/src/Keithley_6487.cpp index dace9e3..45ad5e5 100644 --- a/src/Keithley_6487.cpp +++ b/src/Keithley_6487.cpp @@ -33,13 +33,17 @@ static const short K6487_rangeLimit = 7; // ============================================================================ // Keithley_6487::Keithley_6487 // ============================================================================ -Keithley_6487::Keithley_6487 (std::string& comLink_device_name):AbstractElectrometerClass(comLink_device_name) +Keithley_6487::Keithley_6487 (std::string& comLink_device_name) +: AbstractElectrometerClass(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) @@ -182,5 +186,94 @@ double delta = 0; //- update range with the index found this->_range = idx; - } + +// ============================================================================ +// Keithley_6487::set_knplc +// ============================================================================ +void Keithley_6487::set_knplc (float numPLC) +{ +std::stringstream cmd_to_send; + + if(numPLC < 0.01 || numPLC > 5.0) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid number of PLC.\n Please enter a value in the range 0.01 to 5.0.", + "Keithley_6487::set_knplc( )."); + } + //- just for internal use + _numPLC = numPLC; + + cmd_to_send << numPLC << std::endl; + //- default conversion rate + _electrometerProtocol->set_knplc(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6487::set_triggercount +// ============================================================================ +void Keithley_6487::set_triggercount (short trigCounts) +{ +std::stringstream cmd_to_send; + + if(trigCounts == 0 || trigCounts > 2048) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid trigger count.\n Please enter a value in the range 1 to 2048 or set -1 for INFinite.", + "Keithley_6487::set_triggercount( )."); + } + if(trigCounts < 0) + cmd_to_send << "INF" << std::endl; + else + cmd_to_send << trigCounts << std::endl; + + //- just for internal use + _trigCounts = trigCounts; + //- default conversion rate + _electrometerProtocol->set_triggercount(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6487::set_buffer_size +// ============================================================================ +void Keithley_6487::set_buffer_size (short size) +{ +std::stringstream cmd_to_send; + + if(size < 1 || size > 3000) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid buffer size. \nPlease enter a value in the range 1 to 3000.", + "Keithley_6487::set_buffer_size( )."); + } + //- just for internal use + _size = size; + + cmd_to_send << size << std::endl; + //- default conversion rate + _electrometerProtocol->set_buffer_size(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6487::init_keithley : command to perform an integration cycle +// ============================================================================ +void Keithley_6487::init_keithley (void) +{ + //- get data only (no timestamp info ... wanted!) + _electrometerProtocol->read_data_with_no_timestamp(); + //- Set integration rate in line cycles + this->set_knplc(_numPLC); + //- Set trigger model to take to N readings + this->set_triggercount(_trigCounts); + //- Set buffer size + this->set_buffer_size(_size); + //- clear previous data + _electrometerProtocol->clear_buffer(); + //- Store raw input + _electrometerProtocol->store_raw_input(); + //- Start storing readings + _electrometerProtocol->start_storing(); + //- Trigger readings + _electrometerProtocol->init_keithley(); +} + diff --git a/src/Keithley_6512.cpp b/src/Keithley_6512.cpp index 87564b6..b541dd5 100644 --- a/src/Keithley_6512.cpp +++ b/src/Keithley_6512.cpp @@ -143,11 +143,11 @@ std::string Keithley_6512::get_ElectroMeterRange (void) // ============================================================================ void Keithley_6512::set_buffer_size (short ) { -std::string cmd_to_send(""); +//std::string cmd_to_send(""); - //- send command : Keithley_6512 can store up to 100 points !!! - cmd_to_send = "Q0X"; - _electrometerProtocol->set_buffer_size(cmd_to_send); + throw electrometer::ElectrometerException("COMMAND_NOT_SUPPORTED", + "The 6512 Keithley device buffer size cannot be set (it stores up to 100 points internally.)", + "Keithley_6512::set_triggerMode( )."); } @@ -163,7 +163,10 @@ void Keithley_6512::set_triggerMode (short trigMod) std::stringstream cmd_to_send; - cmd_to_send << trigMod << std::endl; + //- just for internal use + _trigMod = trigMod; + + cmd_to_send << "T" << trigMod << "X" << std::endl; _electrometerProtocol->set_triggerMode(cmd_to_send.str()); @@ -217,6 +220,8 @@ void Keithley_6512::setCoulombMeterMode (void) // ============================================================================ void Keithley_6512::init_keithley (void) { + //- set trigger mode + this->set_triggerMode(_trigMod); //- default conversion rate _electrometerProtocol->set_conversionRate( ); //- force readings with no prefix diff --git a/src/Keithley_6514.cpp b/src/Keithley_6514.cpp index fc32817..3a9b7af 100644 --- a/src/Keithley_6514.cpp +++ b/src/Keithley_6514.cpp @@ -39,15 +39,18 @@ static const short K6514_COU_rangeLimit = 3; // ============================================================================ // Keithley_6514::Keithley_6514 // ============================================================================ -Keithley_6514::Keithley_6514 (std::string& comLink_device_name): -AbstractElectrometerClass(comLink_device_name), -_kmode("") +Keithley_6514::Keithley_6514 (std::string& comLink_device_name) +: AbstractElectrometerClass(comLink_device_name), + _kmode("") { 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) @@ -236,7 +239,7 @@ void Keithley_6514::setCoulombMeterMode (void) } // ============================================================================ -// Keithley_6487::update_range +// Keithley_6514::update_range // ============================================================================ void Keithley_6514::update_range (void) { @@ -317,3 +320,93 @@ double delta = 0; //- update the range with the index found this->_range = idx; } + +// ============================================================================ +// Keithley_6514::set_knplc +// ============================================================================ +void Keithley_6514::set_knplc (float numPLC) +{ +std::stringstream cmd_to_send; + + if(numPLC < 0.01 || numPLC > 10.0) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid number of PLC.\n Please enter a value in the range 0.01 to 10.0.", + "Keithley_6514::set_knplc( )."); + } + //- just for internal use + _numPLC = numPLC; + + cmd_to_send << numPLC << std::endl; + //- default conversion rate + _electrometerProtocol->set_knplc(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6514::set_triggercount +// ============================================================================ +void Keithley_6514::set_triggercount (short trigCounts) +{ +std::stringstream cmd_to_send; + + if(trigCounts == 0 || trigCounts > 2500) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid trigger count.\n Please enter a value in the range 1 to 2500 or set -1 for INFinite.", + "Keithley_6514::set_triggercount( )."); + } + if(trigCounts < 0) + cmd_to_send << "INF" << std::endl; + else + cmd_to_send << trigCounts << std::endl; + + //- just for internal use + _trigCounts = trigCounts; + //- default conversion rate + _electrometerProtocol->set_triggercount(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6514::set_buffer_size +// ============================================================================ +void Keithley_6514::set_buffer_size (short size) +{ +std::stringstream cmd_to_send; + + if(size < 1 || size > 2500) + { + throw electrometer::ElectrometerException("OUT_OF_RANGE", + "Invalid buffer size. \nPlease enter a value in the range 1 to 2500.", + "Keithley_6514::set_buffer_size( )."); + } + //- just for internal use + _size = size; + + cmd_to_send << size << std::endl; + //- default conversion rate + _electrometerProtocol->set_buffer_size(cmd_to_send.str()); +} + +// ============================================================================ +// Keithley_6514::init_keithley : command to perform an integration cycle +// ============================================================================ +void Keithley_6514::init_keithley (void) +{ + //- get data only (no timestamp info ... wanted!) + _electrometerProtocol->read_data_with_no_timestamp(); + //- Set integration rate in line cycles + this->set_knplc(_numPLC); + //- Set trigger model to take to N readings + this->set_triggercount(_trigCounts); + //- Set buffer size + this->set_buffer_size(_size); + //- clear previous data + _electrometerProtocol->clear_buffer(); + //- Store raw input + _electrometerProtocol->store_raw_input(); + //- Start storing readings + _electrometerProtocol->start_storing(); + //- Trigger readings + _electrometerProtocol->init_keithley(); +} + diff --git a/src/TangoGpibLink.cpp b/src/TangoGpibLink.cpp index c50bbdc..eae8ff6 100644 --- a/src/TangoGpibLink.cpp +++ b/src/TangoGpibLink.cpp @@ -194,3 +194,59 @@ bool TangoGpibLink::isSRQLineUp (void) throw (Tango::DevFailed) } +// ============================================================================ +// TangoGpibLink::clear +// ============================================================================ +void TangoGpibLink::clear (void) throw (Tango::DevFailed) +{ + TangoSys_OMemStream description; + + if(!_is_gpib_proxy_created) + create_gpib_proxy(); + + try + { + //- try + this->_gpib_proxy->command("Clear"); + } + catch(Tango::DevFailed& df ) + { + description << "Unable send Clear Device command." << ends; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.str(), + (const char*)"TangoGpibLink::clear"); + + } + +} + +// ============================================================================ +// TangoGpibLink::trigger +// ============================================================================ +void TangoGpibLink::trigger (void) throw (Tango::DevFailed) +{ + TangoSys_OMemStream description; + + if(!_is_gpib_proxy_created) + create_gpib_proxy(); + + try + { + //- try + this->_gpib_proxy->command("Trigger"); + } + catch(Tango::DevFailed& df ) + { + description << "Unable send Trigger command." << ends; + + Tango::Except::re_throw_exception (df, + (const char*)"COMMUNICATION_ERROR", + description.str(), + (const char*)"TangoGpibLink::clear"); + + } + +} + diff --git a/src/TangoSerialLink.cpp b/src/TangoSerialLink.cpp index 75b4ab8..e87c01b 100644 --- a/src/TangoSerialLink.cpp +++ b/src/TangoSerialLink.cpp @@ -154,14 +154,3 @@ std::string TangoSerialLink::write_read (std::string command_to_send) throw (Tan return respTmp; } -// ============================================================================ -// TangoSerialLink::isSRQLineUp -// ============================================================================ -bool TangoSerialLink::isSRQLineUp (void) throw (Tango::DevFailed) -{ - Tango::Except::throw_exception ( - (const char*)"COMMAND_NOT_SUPPORTED", - (const char*)"This protocol does not support this command.", - (const char*)"TangoSerialLink::isSRQLineUp"); - return false; -} -- GitLab