diff --git a/include/AbstractElectrometerClass.h b/include/AbstractElectrometerClass.h index 8e96db92f08b59967b37cb526be7a3748ddad44b..2e200278aa226fb8424fd5d35c45519fee101689 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 8962a6bd59a1a53bc7174d728ebc771063a6a52c..75eba2bdd3319451223730cf638a5a4e64452529 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 49f0d1035d8a327005f22918bc13f3f428f944ab..68b180264df9763b34ab08cb8bd484ce87d3ac8b 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 23b19b84cb8fe7ae82d0fb5105ca79530923fc75..9a43a6bebf0f909d1a733f29f24ef5c671c6c2da 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 3d4b2ddd6ceaf14f1bacb325107c52fafb392ccf..6f4ea1c71f686b9c99700eebac1af478df4dbf20 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 9f2ae99b45390b40221d23a1fcc406ef5b428522..8456b933158c77de0569242f8004a9c8edf1e815 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 a56487786d2ce80f371ada36f67e8c6e631d75de..a1340380fe156fbbadd75e594456ef376c2d5567 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 d844e2712b9fa423a7582ec808f60751efb40da4..91552491915b05d040e7f0f343d0837ab1599301 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 22422d768a22c4267eefa6c08873ed08e2917ff5..37066ed8a7f87aeaabbb0c3b39c121e0e6a19422 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 9cf2bf77b66c6f882fa3f48e0878743512decb95..07733b86b3b70ab339da6dd73bdc868afc4a5374 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 b600a9a225f561ea57f69eb889016108325784e4..2f25c41bc350ac0cad5ab9724974e9fc35002258 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 db2c7bf9226b14f1ff0574213e1ba049794e439e..526bb6c285df55d2585c5b192203210fe5ed1324 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 1dd1cb680038858cc576db490931909fd0a478f7..074172d5fc58f5a8a44530c98ba3fda9b9e54edc 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 9562737cce2d7437a695dc03f148be6ff44219fb..1673162a653a6216dc9bb1aed08794e03990a264 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 9e404cc9bcddd698380f346a897c1feda9b9bdef..7906ad72a8a488dc7ca567405865d59b6ab159eb 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 49e6374c9a4a43ccff34830aa5977051a17e9734..289cce925636d48db37bdb9b33f68d32a7a57734 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 941e80a238240f490fa87a3ae3d7b297b68a1ed3..0c66e55e97efaa863ba643046545478b4564c3c2 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 b2fbcbb086c5092d1ee0a54b99825a941024ff86..2050d0145e57b0598245919a9ddfa37cfa2c1b4c 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 6b46658d389f4836700288b02feeb2fb63940d03..691d6a16d540a9a28893ebb01ce08ec90ded24c6 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 dace9e33520f30049e3ada77185e5b9382428e4f..45ad5e51bafb390b71ab844d91c0cf57e126f207 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 87564b6c93759d54a9d6cf29207c663c475b9a55..b541dd51dd21bd89703e3b3b4661b474f58e4976 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 fc328172b06777c092c48cea25dd48f170993508..3a9b7af00cb88921d59f5011a9b94566b1e2fcd7 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 c50bbdc7d8e75ef76fb496c70a80065a6572a751..eae8ff6d553b598b60287257bac19b17c42fe891 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 75b4ab861e523dd27844bb9992ddab0afd288327..e87c01b2f8c0f07b5f725498f47da443713515c2 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; -}