rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
Public Member Functions | List of all members
rohdeschwarz::instruments::Instrument Class Reference

Object-oriented R&S Instrument control. More...

#include <instrument.hpp>

Inheritance diagram for rohdeschwarz::instruments::Instrument:
rohdeschwarz::instruments::vna::Vna

Public Member Functions

bool isOpen () const
 Check for an open connection to an instrument. More...
 
bool openVisa (std::string resource, unsigned int timeout_ms=2000)
 Open VISA connection to instrument. More...
 
bool openTcp (std::string host, unsigned int timeout_ms=2000)
 Open tcp socket connection to an instrument. More...
 
void close ()
 Close the connection to the instrument. More...
 
std::size_t bufferSize_B () const
 
void setBufferSize (std::size_t size_bytes)
 
std::vector< unsigned char > * buffer ()
 
const std::vector< unsigned char > * buffer () const
 
std::vector< unsigned char > takeData ()
 
int timeout_ms ()
 Query IO timeout time, in milliseconds. More...
 
bool setTimeout (int timeout_ms)
 Set IO timeout time. More...
 
bool readData (unsigned char *buffer, std::size_t bufferSize, std::size_t *readSize=nullptr)
 
bool writeData (const unsigned char *data, std::size_t dataSize, std::size_t *writeSize=nullptr)
 
bool readData (std::size_t *readSize=nullptr)
 
std::string read ()
 
template<class... Args>
bool write (std::string scpi_command, Args &&... args)
 
template<class... Args>
std::string query (std::string scpi_command, Args &&... args)
 
template<class OutputType >
OutputType readValue ()
 
template<class OutputType , class... Args>
OutputType queryValue (std::string scpi_command, Args &&... args)
 
bool readScpiBool ()
 
template<class... Args>
bool queryScpiBool (std::string scpi_command, Args &&... args)
 
std::vector< double > readAsciiVector ()
 reads ascii data and parses it into vector <double> More...
 
std::vector< std::complex< double > > readAsciiComplexVector ()
 reads ascii data and parses it into vector <complex <double>> More...
 
scpi::BlockData readBlockData ()
 Read Block Data. More...
 
std::vector< double > read64BitVector ()
 Reads block data and parses it into vector <double> More...
 
std::vector< std::complex< double > > read64BitComplexVector ()
 Reads block data and parses it into vector <complex <double>> More...
 
bool isBusError () const
 Checks the bus status for an error. More...
 
std::string busStatus () const
 Gets the bus status as a human-readable string. More...
 
std::string id ()
 Queries instrument ID string. More...
 
std::string options ()
 Queries instrument options string. More...
 
void clearErrors ()
 Clears SCPI errors. More...
 
void preset ()
 Perform instrument preset. More...
 
void wait ()
 Instructs instrument to perform previous SCPI commands before proceeding. More...
 
bool blockUntilOperationComplete (unsigned int timeout_ms=2000)
 Queries *OPC? - block until operation complete. More...
 

Detailed Description

Object-oriented R&S Instrument control.

rohdeschwarz::instruments::Instrument is a class for controlling any general purpose instrument with VISA and SCPI. It manages the VISA connection to the instrument. It also contains methods that wrap common SCPI commands that apply to all general purpose instruments.

Here is an example which demonstrates basic use:

Definition at line 52 of file instrument.hpp.

Member Function Documentation

◆ blockUntilOperationComplete()

bool Instrument::blockUntilOperationComplete ( unsigned int  timeout_ms = 2000)

Queries *OPC? - block until operation complete.

Definition at line 286 of file instrument.cpp.

◆ buffer() [1/2]

std::vector< unsigned char > * Instrument::buffer ( )

Definition at line 95 of file instrument.cpp.

◆ buffer() [2/2]

const std::vector< unsigned char > * Instrument::buffer ( ) const

Definition at line 100 of file instrument.cpp.

◆ bufferSize_B()

std::size_t Instrument::bufferSize_B ( ) const

Definition at line 83 of file instrument.cpp.

◆ busStatus()

std::string Instrument::busStatus ( ) const

Gets the bus status as a human-readable string.

Definition at line 250 of file instrument.cpp.

◆ clearErrors()

void Instrument::clearErrors ( )

Clears SCPI errors.

clearErrors sends SCPI command *CLS

Definition at line 268 of file instrument.cpp.

◆ close()

void Instrument::close ( )

Close the connection to the instrument.

Definition at line 77 of file instrument.cpp.

◆ id()

std::string Instrument::id ( )

Queries instrument ID string.

id uses SCPI query *IDN?

Definition at line 256 of file instrument.cpp.

◆ isBusError()

bool Instrument::isBusError ( ) const

Checks the bus status for an error.

Definition at line 244 of file instrument.cpp.

◆ isOpen()

bool Instrument::isOpen ( ) const

Check for an open connection to an instrument.

Definition at line 31 of file instrument.cpp.

◆ openTcp()

bool Instrument::openTcp ( std::string  host,
unsigned int  timeout_ms = 2000 
)

Open tcp socket connection to an instrument.

Attempts to connect to the instrument at host with a TCP socket on port 5025.

Parameters
[in]hosthost name or ip address
[in]timeout_msopen timeout time, in milliseconds
Returns
true on success; false otherwise

Definition at line 57 of file instrument.cpp.

◆ openVisa()

bool Instrument::openVisa ( std::string  resource,
unsigned int  timeout_ms = 2000 
)

Open VISA connection to instrument.

Parameters
[in]resourceVISA resource string as a C++ style string
[in]timeout_msopen timeout time, in milliseconds
Returns
true on success; false otherwise

Definition at line 37 of file instrument.cpp.

◆ options()

std::string Instrument::options ( )

Queries instrument options string.

options uses SCPI query *OPT?

Definition at line 262 of file instrument.cpp.

◆ preset()

void Instrument::preset ( )

Perform instrument preset.

reset sends SCPI command *RST

Definition at line 274 of file instrument.cpp.

◆ query()

template<class... Args>
std::string rohdeschwarz::instruments::Instrument::query ( std::string  scpi_command,
Args &&...  args 
)
inline

Definition at line 173 of file instrument.hpp.

◆ queryScpiBool()

template<class... Args>
bool rohdeschwarz::instruments::Instrument::queryScpiBool ( std::string  scpi_command,
Args &&...  args 
)
inline

Definition at line 207 of file instrument.hpp.

◆ queryValue()

template<class OutputType , class... Args>
OutputType rohdeschwarz::instruments::Instrument::queryValue ( std::string  scpi_command,
Args &&...  args 
)
inline

Definition at line 197 of file instrument.hpp.

◆ read()

std::string Instrument::read ( )

Definition at line 141 of file instrument.cpp.

◆ read64BitComplexVector()

std::vector< std::complex< double > > Instrument::read64BitComplexVector ( )

Reads block data and parses it into vector <complex <double>>

Definition at line 229 of file instrument.cpp.

◆ read64BitVector()

std::vector< double > Instrument::read64BitVector ( )

Reads block data and parses it into vector <double>

Definition at line 214 of file instrument.cpp.

◆ readAsciiComplexVector()

std::vector< std::complex< double > > Instrument::readAsciiComplexVector ( )

reads ascii data and parses it into vector <complex <double>>

Definition at line 164 of file instrument.cpp.

◆ readAsciiVector()

std::vector< double > Instrument::readAsciiVector ( )

reads ascii data and parses it into vector <double>

Definition at line 157 of file instrument.cpp.

◆ readBlockData()

scpi::BlockData Instrument::readBlockData ( )

Read Block Data.

readBlockData reads data in IEEE 488.2 Block Data format.

Definition at line 171 of file instrument.cpp.

◆ readData() [1/2]

bool Instrument::readData ( std::size_t *  readSize = nullptr)

Definition at line 135 of file instrument.cpp.

◆ readData() [2/2]

bool Instrument::readData ( unsigned char *  buffer,
std::size_t  bufferSize,
std::size_t *  readSize = nullptr 
)

Definition at line 123 of file instrument.cpp.

◆ readScpiBool()

bool rohdeschwarz::instruments::Instrument::readScpiBool ( )

◆ readValue()

template<class OutputType >
OutputType rohdeschwarz::instruments::Instrument::readValue ( )
inline

Definition at line 190 of file instrument.hpp.

◆ setBufferSize()

void Instrument::setBufferSize ( std::size_t  size_bytes)

Definition at line 89 of file instrument.cpp.

◆ setTimeout()

bool Instrument::setTimeout ( int  timeout_ms)

Set IO timeout time.

Parameters
[in]timeout_mstimeout, in milliseconds

Definition at line 117 of file instrument.cpp.

◆ takeData()

std::vector< unsigned char > Instrument::takeData ( )

Definition at line 105 of file instrument.cpp.

◆ timeout_ms()

int Instrument::timeout_ms ( )

Query IO timeout time, in milliseconds.

Definition at line 111 of file instrument.cpp.

◆ wait()

void Instrument::wait ( )

Instructs instrument to perform previous SCPI commands before proceeding.

wait sends SCPI command *WAI

Definition at line 280 of file instrument.cpp.

◆ write()

template<class... Args>
bool rohdeschwarz::instruments::Instrument::write ( std::string  scpi_command,
Args &&...  args 
)
inline

Definition at line 142 of file instrument.hpp.

◆ writeData()

bool Instrument::writeData ( const unsigned char *  data,
std::size_t  dataSize,
std::size_t *  writeSize = nullptr 
)

Definition at line 129 of file instrument.cpp.


The documentation for this class was generated from the following files: