Skip to content
Snippets Groups Projects
Select Git revision
  • a72343e16b07fa291e4c0b14dd289ec6357d3039
  • main default protected
  • develop
  • release_2_8_3
  • release_2_8_2
  • release_2_8_1
  • release_2_8_0
  • release_2_7_1
  • release_2_7_0
  • release_2_6_0
  • release_2_5_29
  • release_2_5_28
  • release_2_5_27
  • release_2_5_26
  • release_2_5_25
  • release_2_5_24
  • release_2_5_23
  • release_2_5_22
  • release_2_5_21
  • release_2_5_20
  • release_2_5_18
  • release_2_5_17
  • release_2_5_16
23 results

Keithley_486.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    KeithleySCPIProtocol.cpp 31.98 KiB
    // ============================================================================
    //
    // = CONTEXT
    //    TANGO Project - SCPI KeithleySCPIProtocol Support Library
    //
    // = FILENAME
    //    KeithleySCPIProtocol.cpp
    //
    // = AUTHOR
    //    X. Elattaoui
    //
    // ============================================================================
    
    // ============================================================================
    // DEPENDENCIES
    // ============================================================================
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <Xstring.h>
    #ifndef WIN32
    # include <unistd.h>
    #endif
    //# include 
    //#endif
    #include "KeithleySCPIProtocol.h"
    #include "TangoGpibLink.h"
    
    // ============================================================================
    // KeithleySCPIProtocol::KeithleySCPIProtocol
    // ============================================================================
    KeithleySCPIProtocol::KeithleySCPIProtocol (std::string& gpib_device_name)
    :	ElectrometerProtocol(),
    	isDiffSuportedMode(false),
    	trigCountStr("")
    {
    	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);
    
    	std::cout << "KeithleySCPIProtocol::KeithleySCPIProtocol ->" << std::endl;
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::~KeithleySCPIProtocol
    // ============================================================================
    KeithleySCPIProtocol::~KeithleySCPIProtocol (void)
    {
    	std::cout << "KeithleySCPIProtocol::~KeithleySCPIProtocol <-" << std::endl;
    
    	std::cout << "KeithleySCPIProtocol::~KeithleySCPIProtocol ->" << std::endl;
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_range
    // ============================================================================
    void KeithleySCPIProtocol::set_range (std::string value) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command to Keithley device
    	cmd_to_send = tmpMode + ":RANGe " + value ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::zero_check_on
    // ============================================================================
    void KeithleySCPIProtocol::zero_check_on (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:ZCH ON" ;
    	_communication_link->write(cmd_to_send);
    
    }
    // ============================================================================
    // KeithleySCPIProtocol::zero_check_off
    // ============================================================================
    void KeithleySCPIProtocol::zero_check_off (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:ZCH OFF";
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::zero_correct_on
    // ============================================================================
    void KeithleySCPIProtocol::zero_correct_on (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:ZCOR ON" ;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::zero_correct_off
    // ============================================================================
    void KeithleySCPIProtocol::zero_correct_off (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:ZCOR OFF" ;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::zero_correct_state_on
    // ============================================================================
    void KeithleySCPIProtocol::zero_correct_state_on (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:ZCOR:STAT ON" ;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::zero_correct_state_off
    // ============================================================================
    void KeithleySCPIProtocol::zero_correct_state_off (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:ZCOR:STAT OFF" ;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::autoRange_ON
    // ============================================================================
    void KeithleySCPIProtocol::autoRange_on (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    
    	cmd_to_send = tmpMode + ":RANGe:AUTO ON" ;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::autoRange_OFF
    // ============================================================================
    void KeithleySCPIProtocol::autoRange_off (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    
    	//- send command
    	cmd_to_send = tmpMode + ":RANGe:AUTO OFF";
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::auto_zero_on
    // ============================================================================
    void KeithleySCPIProtocol::auto_zero_on (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:AZER ON" ;
    	_communication_link->write(cmd_to_send);
    
    }
    // ============================================================================
    // KeithleySCPIProtocol::auto_zero_off
    // ============================================================================
    void KeithleySCPIProtocol::auto_zero_off (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "SYST:AZER OFF" ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::MODE -> Ampere, Volt, Ohm, Coulomb and V on I meters
    // ============================================================================
    // ============================================================================
    // KeithleySCPIProtocol::setAmperMeterMode
    // ============================================================================
    void KeithleySCPIProtocol::setAmperMeterMode (void) 
    {
    std::stringstream cmd_to_send;
    std::string mode_ ("");
    
    	//- mode current (send CURR)
    	mode_ = "CURRent";
    
    	//- send command
    	cmd_to_send << "FUNC \'" << mode_ << "\'" << std::endl;
    	_communication_link->write(cmd_to_send.str());
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::setVoltMeterMode
    // ============================================================================
    void KeithleySCPIProtocol::setVoltMeterMode (void) 
    {
    std::stringstream cmd_to_send;
    std::string mode_ ("");
    
    	//- mode volt
    	mode_ = "VOLTage";
    
    	//- send command
    	cmd_to_send << "FUNC \'" << mode_ << "\'" << std::endl;
    	_communication_link->write(cmd_to_send.str());
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::setOhmMeterMode
    // ============================================================================
    void KeithleySCPIProtocol::setOhmMeterMode (void) 
    {
    std::stringstream cmd_to_send;
    std::string mode_ ("");
    
    	//- mode ohm
    	mode_ = "RESistance";
    
    	//- send command
    	cmd_to_send << "FUNC \'" << mode_ << "\'" << std::endl;
    	_communication_link->write(cmd_to_send.str());
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::setCoulombMeterMode
    // ============================================================================
    void KeithleySCPIProtocol::setCoulombMeterMode (void) 
    {
    std::stringstream cmd_to_send;
    std::string mode_ ("");
    
    	//- mode coulomb
    	mode_ = "CHARge";
    
    	//- send command
    	cmd_to_send << "FUNC \'" << mode_ << "\'" << std::endl;
    	_communication_link->write(cmd_to_send.str());
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_mode
    // ============================================================================
    std::string KeithleySCPIProtocol::get_mode (void) 
    {
    std::string cmd_to_send("");
    	
    	//- get electrometer mode
    	if(isDiffSuportedMode)
    	{
    		//- send command
    		cmd_to_send = "FUNC?" ;
    		_mode =  _communication_link->write_read(cmd_to_send);
    		//- _mode returned is as this "RES" so, erase " caracters
    		_mode.erase(_mode.find("\""), 1);
    		_mode.erase(_mode.find("\""), 1);
    	}
    	else
    		_mode = "CURR\n";
    
    	return _mode;
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_range
    // ============================================================================
    std::string KeithleySCPIProtocol::get_range (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":RANGe?" ;
    	std::string _rangeStr = _communication_link->write_read(cmd_to_send);
    	
    	return _rangeStr;
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_value
    // ============================================================================
    std::string KeithleySCPIProtocol::get_value (void) 
    {
    std::string cmd_to_send("");
    std::string tmp("");
    
    	////- This command performs a CONFIGURE and a READ?
    	//cmd_to_send = "MEAS?" ;
    	
    	//- This command performs an INIT and then query the updated value
        cmd_to_send = "READ?" ;
    
    	tmp = _communication_link->write_read(cmd_to_send);
    
      //- extract all data
      return tmp;
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_integratedValue
    // ============================================================================
    std::vector<double> KeithleySCPIProtocol::get_integratedValue (void) 
    {
    std::string cmd_to_send("");
    std::string tmp("");
    
    	//- This command performs an INIT and then query the bufferised values
    	cmd_to_send = "TRAC:DATA?" ;
    	tmp = _communication_link->write_read(cmd_to_send);
    
      //- extract all data
      return buildDataList(tmp);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_fetchValue
    // ============================================================================
    std::vector<double> KeithleySCPIProtocol::get_fetchValue (void) 
    {
    std::string cmd_to_send("");
    std::string tmp("");
    
    	//- This command queries the last value(s)
    	cmd_to_send = "FETCh?" ;
    	tmp = _communication_link->write_read(cmd_to_send);
    
      //- extract all data
      return buildDataList(tmp);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::buildDataList
    //
    //  This method extract and convert data from the received string
    // ============================================================================
    std::vector<double> KeithleySCPIProtocol::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(i=0; i < numberOfData; i++)
        {
    		  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;
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::init_keithley to perform reading(s) data
    // ============================================================================
    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);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::abort -> cancel all operations started by INIT command
    // ============================================================================
    void KeithleySCPIProtocol::abort (void) 
    {
    std::string cmd_to_send("ABORt");
    
    	//- send command : ABORt to cancel all operations
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_knplc : specify the integration rate
    // ============================================================================
    void KeithleySCPIProtocol::set_knplc (std::string nbNPLC) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":NPLC " + nbNPLC ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_knplc : get the integration rate
    // ============================================================================
    std::string KeithleySCPIProtocol::get_knplc (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":NPLCycles?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_triggercount
    // ============================================================================
    void KeithleySCPIProtocol::set_triggercount (std::string nbTrigCount) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "TRIG:COUN " + nbTrigCount ;
    	//- for internal use ( = keithley device buffer size)
    	trigCountStr = nbTrigCount;
    
    	_communication_link->write(cmd_to_send);
    
    	//- set buffer size ( = number of triggers )
    //	set_buffer_size(nbTrigCount);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_triggercount
    // ============================================================================
    std::string KeithleySCPIProtocol::get_triggercount (void) 
    {
    std::string cmd_to_send("");
    std::string response("");
    
    	//- send command
    	cmd_to_send = "TRIG:COUNt?" ;
    	response  = _communication_link->write_read(cmd_to_send);
    
      return response;
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_triggerdelay
    // ============================================================================
    void KeithleySCPIProtocol::set_triggerdelay (std::string trigDelay) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "TRIG:DEL " + trigDelay ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_triggerdelay
    // ============================================================================
    std::string KeithleySCPIProtocol::get_triggerdelay (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "TRIG:DEL?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_triggerdelayAuto
    // ============================================================================
    void KeithleySCPIProtocol::set_triggerdelayAuto (std::string trigDelayAuto) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "TRIG:DEL:" + trigDelayAuto ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_triggerdelayAuto
    // ============================================================================
    std::string KeithleySCPIProtocol::get_triggerdelayAuto (void) 
    {
    std::string cmd_to_send("");
    
    	//- send command
    	cmd_to_send = "TRIG:DEL:AUTO?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_averagecount
    // ============================================================================
    void KeithleySCPIProtocol::set_averagecount (std::string nbAverageCount) 
    {
    std::string cmd_to_send("");
    	
    	//- send command
    	cmd_to_send = "AVER:COUN " + nbAverageCount;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_averagecount
    // ============================================================================
    void KeithleySCPIProtocol::set_averagecount_K6517 (std::string cmd_to_send) 
    {
    std::string tmpMode("");
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":AVER:COUN " + cmd_to_send ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_averagecount
    // ============================================================================
    std::string KeithleySCPIProtocol::get_averagecount (void) 
    {
    std::string cmd_to_send("");
    	
    	//- send command
    	cmd_to_send = "AVER:COUNt?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_averagecount
    // ============================================================================
    std::string KeithleySCPIProtocol::get_averagecount_K6517 (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode;
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":AVER:COUNt?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_averagecontrol
    // ============================================================================
    void KeithleySCPIProtocol::set_averagecontrol (std::string nbAverageControl) 
    {
    std::string cmd_to_send("");
    std::string tmpMode("");
    	
    	//- get electrometer mode
    //	tmpMode = get_mode( );
    
    	//- send command
    	cmd_to_send = "AVER:TCON " + nbAverageControl;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_averagecontrol
    // ============================================================================
    void KeithleySCPIProtocol::set_averagecontrol_K6517 (std::string nbAverageControl) 
    {
    std::string cmd_to_send("");
    std::string tmpMode("");
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":AVER:TCON " + nbAverageControl;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_averagecontrol
    // ============================================================================
    std::string KeithleySCPIProtocol::get_averagecontrol (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode("");
    	
    	//- get electrometer mode
    //	tmpMode = get_mode( );
    
    	//- send command
    	cmd_to_send = "AVER:TCONtrol?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_averagecount
    // ============================================================================
    std::string KeithleySCPIProtocol::get_averagecontrol_K6517 (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode("");
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":AVER:TCONtrol?" ;
    	return _communication_link->write_read(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::clear_registers
    // ============================================================================
    void KeithleySCPIProtocol::clear_registers (void) 
    {
    std::string cmd_to_send("");
    	
    	//- send command
    	cmd_to_send = "*CLS" ;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::averageStateON
    // ============================================================================
    void KeithleySCPIProtocol::averageStateON (void) 
    {
    std::string cmd_to_send("");
    	
    	//- send command
    	cmd_to_send = "AVER ON" ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::averageStateON_K6517
    // ============================================================================
    void KeithleySCPIProtocol::averageStateON_K6517 (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode("");
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":AVER ON" ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::averageStateOFF
    // ============================================================================
    void KeithleySCPIProtocol::averageStateOFF (void) 
    {
    std::string cmd_to_send("");
    	
    	//- send command
    	cmd_to_send = "AVER OFF";
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::averageStateOFF_K6517
    // ============================================================================
    void KeithleySCPIProtocol::averageStateOFF_K6517 (void) 
    {
    std::string cmd_to_send("");
    std::string tmpMode("");
    	
    	//- get electrometer mode
    	tmpMode = get_mode( );
    
    	//- erase bad caracters
    	tmpMode.erase(tmpMode.find("\n") );
    	
    	//- send command
    	cmd_to_send = tmpMode + ":AVER OFF" ;
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::reset
    // ============================================================================
    void KeithleySCPIProtocol::reset (void) 
    {
    std::string cmd_to_send("");
    	
    	//- send command
    	cmd_to_send = "*RST" ;
    	_communication_link->write(cmd_to_send);
    
      //- Select reading only
      cmd_to_send = "FORM:ELEM READ";
    
    	//- send command
    	_communication_link->write(cmd_to_send);
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_raw_status
    // ============================================================================
    std::string KeithleySCPIProtocol::get_raw_status (void) 
    {
    std::string cmd_to_send("");
    std::string argout("no data");
    
    	//- send command : read error queue only
    	cmd_to_send = "STAT:QUE?";
    	argout = _communication_link->write_read(cmd_to_send);
    
    
    	return argout;
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::set_buffer_size()
    // ============================================================================
    void KeithleySCPIProtocol::set_buffer_size (std::string size) 
    {
    std::string cmd_to_send("");
    
    	//- send command : size = number of triggers
    	cmd_to_send = "TRAC:POIN " + size;
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::get_buffer_size()
    // ============================================================================
    std::string KeithleySCPIProtocol::get_buffer_size ( ) 
    {
    std::string cmd_to_send("TRAC:POIN:ACTual?");
    
    	//- send command :
    	return _communication_link->write_read(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::clear_buffer()
    // ============================================================================
    void KeithleySCPIProtocol::clear_buffer (void) 
    {
    std::string cmd_to_send("TRAC:CLEAR");
    
    	//- send command : clear previous data
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::store_raw_input()
    // ============================================================================
    void KeithleySCPIProtocol::store_raw_input (void) 
    {
    std::string cmd_to_send("TRAC:FEED SENS");
    
    	//- send command : Store raw input readings
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::start_storing()
    // ============================================================================
    void KeithleySCPIProtocol::start_storing (void) 
    {
    std::string cmd_to_send("TRAC:FEED:CONT NEXT");
    
    	//- send command : Start storing readings
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::enable_SRQBufferFull()
    // ============================================================================
    void KeithleySCPIProtocol::enable_SRQBufferFull (void) 
    {
    /**********************************************************/
    /*  NOTE :                                                */
    /* 512 is the 10th bit in the MESUREMENT EVENT REGISTERS  */
    /* which the BUFFER FULL bit that can be enabled          */
    /**********************************************************/
      
      std::string cmd_to_send("STAT:MEAS:ENAB 512");
    
    	//- send command : enable buffer full in the Measurement event enable register
    	_communication_link->write(cmd_to_send);
    
      //- Program the service request enable register: to send SRQ on Buffer Full !
      cmd_to_send = "*SRE 1";
    
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::disable_SRQBufferFull()
    // ============================================================================
    void KeithleySCPIProtocol::disable_SRQBufferFull (void) 
    {
    std::string cmd_to_send("STAT:MEAS?");
    
    	//- send command : disable buffer full event
    	_communication_link->write_read(cmd_to_send);
    
      //- Disable the service request enable register
      cmd_to_send = "*SRE 0";
    	_communication_link->write(cmd_to_send);
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::SRQLineState()
    // ============================================================================
    bool KeithleySCPIProtocol::SRQLineState (void) 
    {
    	//- if asserted -> the programmed event occurs : the device can be asked !
    	return _communication_link->SRQLineState();
    
      //- Cf Keithley doc to know how the to get the wanted event 
      //-   Chapter : Status Structure
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::readStatusByteRegister()
    // ============================================================================
    short KeithleySCPIProtocol::readStatusByteRegister (void) 
    {
    	//- if SRQ line UP -> the programmed event(s) occurs : the value is available !
    	return _communication_link->readStatusByteRegister();
    
      //- Cf Keithley doc to know how the to get the wanted event 
      //-   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());
    }
    
    
    
    
    
    // Following functions are part of commands supported via the SCPI protocol. 
    // We may have to implement them after first tests on beamlines
    
    /*
    // ============================================================================
    // KeithleySCPIProtocol::setExternalFeedbackMeterMode
    // ============================================================================
    void KeithleySCPIProtocol::setExternalFeedbackMeterMode (void) 
    {
    std::stringstream cmd_to_send;
    
    		cmd_to_send << "F4X" << std::endl;
    		_communication_link->write(cmd_to_send());
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::setVonIMeterMode
    // ============================================================================
    void KeithleySCPIProtocol::setVonIMeterMode (void) 
    {
    std::stringstream cmd_to_send;
    
    	//- send command
    	try
    	{
    		cmd_to_send << "F5X" << std::endl;
    		_communication_link->write(cmd_to_send.str());
    	}
    	catch(Tango::DevFailed& df)
    	{
    		Tango::Except::re_throw_exception (df,
    										(const char*)"COMMUNICATION_ERROR",
    										(const char*)"Unable to perform a write operation",
    										(const char*)"KeithleySCPIProtocol::setVonIMeterMode");
    	}
    	catch(...)
    	{
    		throw ;
    	}
    
    }
    */
    
    /* TO BE IMPLEMENTED !!!!! 
    
    // ============================================================================
    // KeithleySCPIProtocol::reading_source
    // ============================================================================
    void KeithleySCPIProtocol::reading_source (void) 
    {
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::reading_source
    // ============================================================================
    void KeithleySCPIProtocol::data_store (void) 
    {
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::reading_source
    // ============================================================================
    void KeithleySCPIProtocol::data_format (void) 
    {
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::reading_source
    // ============================================================================
    void KeithleySCPIProtocol::baseline_suppression_ON (void) 
    {
    
    }
    
    // ============================================================================
    // KeithleySCPIProtocol::reading_source
    // ============================================================================
    void KeithleySCPIProtocol::baseline_suppression_OFF (void) 
    {
    
    }
    // ============================================================================
    // KeithleySCPIProtocol::reading_source
    // ============================================================================
    void KeithleySCPIProtocol::keithley_status (void) 
    {
    
    }
    */