Instrument Control Lib
Framework to control Oscilloscopes, SMUs, Function Generators and DC Powersupplies via Ethernet.
KST3000 Class Reference

Mixed Single Oscilloscope(Oscillator) Commend operations of a single generator are defined. KST3000 is the model of the device(keysight 3000 series). More...

#include <KST3000.h>

Inheritance diagram for KST3000:
Inheritance graph
Collaboration diagram for KST3000:
Collaboration graph

Public Member Functions

 KST3000 (const char *ip, int timeoutInMS)
 Constructor. More...
 
 KST3000 (const char *ip, int timeoutInMs, PIL::Logging *logger)
 
PIL_ERROR_CODE run () override
 Start to run. Equivalent to press the Run/Stop button when the device is not running. More...
 
PIL_ERROR_CODE stop () override
 Stop to run. Equivalent to press the Run/Stop button when the device is not stopping. More...
 
PIL_ERROR_CODE single () override
 Equivalent to press the Single button. More...
 
PIL_ERROR_CODE autoScale () override
 Equivalent to press the "Auto Scale" button. More...
 
PIL_ERROR_CODE setTimeRange (double value) override
 Set timebase(horizontal) range; Equivalent to adjust the "Horizontal" knob. More...
 
PIL_ERROR_CODE setChannelOffset (OSC_CHANNEL channel, double offset) override
 Set vertical offset. Equivalent to adjust the knob below channel number button. More...
 
PIL_ERROR_CODE setChannelScale (OSC_CHANNEL channel, double value) override
 Equivalent to adjust the knob above channel numbers. e.g. CHANnel3:SCALe 5. More...
 
PIL_ERROR_CODE setChannelRange (OSC_CHANNEL channel, double value, VOLTAGE_UNIT voltageUnit) override
 Similar to setChannelScale, but set the whole voltage range. More...
 
PIL_ERROR_CODE setTriggerEdge (TRIGGER_EDGE edge) override
 Set trigger slope. More...
 
PIL_ERROR_CODE setTriggerSource (OSC_CHANNEL channel) override
 Set trigger channel. More...
 
PIL_ERROR_CODE setTimeDelay (double delay)
 Set timebase(horizontal) delay; Equivalent to adjust the delay knob in Horizontal controls. e.g. TIMebase:DElay 5. More...
 
PIL_ERROR_CODE setWaveformSource (OSC_CHANNEL channel)
 set waveform source More...
 
PIL_ERROR_CODE getWaveformPreamble (std::string *result)
 Query the preamble of waveform data, e.g. WAVeform:PREamble? More...
 
PIL_ERROR_CODE getWaveformPoints (int *nrWaveFormPoints)
 Query the number of waveform points to be transferred. More...
 
PIL_ERROR_CODE setWaveformPoints (int num_points)
 set number of waveform points More...
 
PIL_ERROR_CODE setWaveformPointsMode (std::string &mode)
 set waveform points mode More...
 
PIL_ERROR_CODE setWaveformFormat (FILE_FORMAT format)
 set format of waveform data(default "BYTE") More...
 
PIL_ERROR_CODE saveWaveformData (std::string &file_path)
 save waveform data to the target file More...
 
PIL_ERROR_CODE getWaveformData (std::string *data)
 get the sampled data points More...
 
PIL_ERROR_CODE getRealData (double **result)
 convert a measurement data array to a 2d array: time array & voltage array More...
 
std::vector< std::vector< double > > getRealDataPy ()
 convert a measurement data array to a 2d array: time array & voltage array More...
 
PIL_ERROR_CODE digitize (OSC_CHANNEL channel)
 capture data More...
 
PIL_ERROR_CODE getSystemSetup (std::string *result)
 get system setup More...
 
PIL_ERROR_CODE setDisplayMode (DISPLAY_MODES displayMode)
 set timebase mode More...
 
PIL_ERROR_CODE displayConnection ()
 Display a line of text: Connected Successfully. Returning... The message will disappear after 2 seconds. Can be used to make sure the connection is working. More...
 
PIL_ERROR_CODE setChannelDisplay (OSC_CHANNEL channel, int on)
 Show or hide channel display. Equivalent to press channel number button. More...
 
PIL_ERROR_CODE Exec2 (const std::string &command, ExecArgs *args, std::string *result, bool br)
 
- Public Member Functions inherited from Oscilloscope
 Oscilloscope (const char *ip, int timeoutInMs, PIL::Logging *logger)
 
- Public Member Functions inherited from Device
 Device (std::string ipAddress, int timeoutInMs, SEND_METHOD mode=DIRECT_SEND, bool throwException=true)
 Constructor for the Device without passing a logging object. More...
 
 Device (std::string ipAddress, int timeoutInMs, PIL::Logging *logger, SEND_METHOD mode=DIRECT_SEND, bool throwException=true)
 Constructor of Device generates a socket handle without connecting to it. More...
 
 Device (std::string ipAddress, uint16_t srcPort, uint16_t destPort, int timeoutInMs, PIL::Logging *logger, SEND_METHOD mode=DIRECT_SEND, bool throwException=true)
 Base class containing the base functionality of all devices. And parameters to store the name connection type, etc. More...
 
 ~Device ()
 
PIL_ERROR_CODE Connect ()
 Establish a connection to the device. More...
 
PIL_ERROR_CODE Disconnect ()
 Disconnect from the device. More...
 
bool isOpen () const
 Checks if the connection to the device is established. More...
 
bool isBuffered () const
 Checks if the commands sent to the device get buffered. More...
 
std::string getDeviceIdentifier ()
 Gets the name of the currently connected device. More...
 
PIL_ERROR_CODE Exec (const std::string &command, ExecArgs *args=nullptr, char *result=nullptr, bool br=true, int size=1024)
 execute a (SCPI) command More...
 
PIL_ERROR_CODE Exec (const std::string &command, ExecArgs *args, std::string *result, bool br)
 
PIL_ERROR_CODE ExecCommands (std::string &commands)
 
std::string ReturnErrorMessage ()
 
std::string getBufferedScript ()
 Transforms the current buffered script into a string and returns it. More...
 
void changeSendMode (SEND_METHOD mode)
 Changes the send mode of this device, i.e. whether the commands get buffered or sent directly to the device. More...
 
PIL_ERROR_CODE delay (double delayTime)
 Stops the execution for the specified amount of time in seconds. If buffering is enabled, the delay is included in the buffered script. Otherwise this thread sleeps for the given time. More...
 

Additional Inherited Members

- Public Types inherited from Oscilloscope
enum  OSC_CHANNEL { CHANNEL_1 = 0 , CHANNEL_2 = 1 , CHANNEL_3 = 2 , CHANNEL_4 = 3 }
 
enum  TRIGGER_EDGE { POS_EDGE = 0 , NEG_EDGE = 1 , EITHER = 2 , ALTERNATING = 3 }
 
enum  DISPLAY_MODES { MAIN = 0 , WIND = 1 , XY = 2 , ROLL = 3 }
 
enum  FILE_FORMAT { ASCII = 0 , WORD = 1 , BYTE = 2 }
 
enum  VOLTAGE_UNIT { VOLT , MILLI_VOLT }
 
- Public Types inherited from Device
enum  SEND_METHOD { DIRECT_SEND = 0 , BUFFER_ENABLED = 1 }
 
- Protected Member Functions inherited from Device
PIL_ERROR_CODE handleErrorsAndLogging (PIL_ERROR_CODE errorCode, bool throwException, PIL::Level logLevel, const std::string &fileName, int line, std::string formatStr,...)
 Handle logging messages, logs it based on the previously passed logging object. If exceptions are enabled throw an exception otherwise return the error code. More...
 
- Static Protected Member Functions inherited from Device
static bool errorOccured (PIL_ERROR_CODE errorCode)
 Checks if a error occured given the error code. More...
 
static PIL_ERROR_CODE postRequest (const std::string &url, std::string &payload)
 Sends a post request to the given url with the given payload. More...
 
static std::string vectorToStringNL (std::vector< std::string > vector)
 Transforms the given vector into a string. Each vector entry will be a line in the resulting string. More...
 
static std::string replaceAllSubstrings (std::string str, const std::string &from, const std::string &to)
 Replaces all substrings in the string with the given replacement string. More...
 
static std::vector< std::string > splitString (const std::string &toSplit, const std::string &delimiter)
 Splits a string by the given delimiter. More...
 
- Protected Attributes inherited from Device
std::string m_IPAddr
 
PIL_ErrorHandle m_ErrorHandle
 
std::string m_DeviceName {}
 
PIL::Socket * m_SocketHandle
 
PIL::Logging * m_Logger
 
int m_destPort = 5025
 
int m_srcPort = 5025
 
bool m_EnableExceptions
 
SEND_METHOD m_SendMode
 
std::vector< std::string > m_BufferedScript
 

Detailed Description

Mixed Single Oscilloscope(Oscillator) Commend operations of a single generator are defined. KST3000 is the model of the device(keysight 3000 series).

Constructor & Destructor Documentation

◆ KST3000() [1/2]

KST3000::KST3000 ( const char *  ip,
int  timeoutInMS 
)
explicit

Constructor.

Parameters
ipIP address of kst3000
Note
Get oscillator's m_IPAddr: Press "Utility" key; Press I/O;

◆ KST3000() [2/2]

KST3000::KST3000 ( const char *  ip,
int  timeoutInMs,
PIL::Logging *  logger 
)

Member Function Documentation

◆ autoScale()

PIL_ERROR_CODE KST3000::autoScale ( )
overridevirtual

Equivalent to press the "Auto Scale" button.

Implements Oscilloscope.

Here is the call graph for this function:

◆ digitize()

PIL_ERROR_CODE KST3000::digitize ( OSC_CHANNEL  channel)

capture data

Here is the call graph for this function:

◆ displayConnection()

PIL_ERROR_CODE KST3000::displayConnection ( )

Display a line of text: Connected Successfully. Returning... The message will disappear after 2 seconds. Can be used to make sure the connection is working.

Here is the call graph for this function:

◆ Exec2()

PIL_ERROR_CODE KST3000::Exec2 ( const std::string &  command,
ExecArgs args,
std::string *  result,
bool  br 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRealData()

PIL_ERROR_CODE KST3000::getRealData ( double **  result)

convert a measurement data array to a 2d array: time array & voltage array

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRealDataPy()

std::vector< std::vector< double > > KST3000::getRealDataPy ( )

convert a measurement data array to a 2d array: time array & voltage array

Here is the call graph for this function:

◆ getSystemSetup()

PIL_ERROR_CODE KST3000::getSystemSetup ( std::string *  result)

get system setup

Here is the call graph for this function:

◆ getWaveformData()

PIL_ERROR_CODE KST3000::getWaveformData ( std::string *  data)

get the sampled data points

READ_WAVE_DATA - The wave data consists of two parts: the header, and the actual waveform data followed by a new line (NL) character.
The query data has the following format:
<header><waveform_data><NL>
Where:
<header> = #800001000 (This is an example header)
The "#8" may be stripped off of the header and the remaining numbers are the size, in bytes, of the waveform data block. The size can vary depending on the number of points acquired for the waveform.(In the example, 1000 points) You can then read that number of bytes from the oscilloscope and the terminating NL character.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWaveformPoints()

PIL_ERROR_CODE KST3000::getWaveformPoints ( int *  nrWaveformPoints)

Query the number of waveform points to be transferred.

Returns
the number of waveform points to be transferred
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getWaveformPreamble()

PIL_ERROR_CODE KST3000::getWaveformPreamble ( std::string *  result)

Query the preamble of waveform data, e.g. WAVeform:PREamble?

Returns
a array containing preamble [Waveform format, Acquire type, Waveform points desired, Waveform average count, Waveform X increment, Waveform X origin, Waveform X reference, Waveform Y increment, Waveform Y origin, Waveform Y reference]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

PIL_ERROR_CODE KST3000::run ( )
overridevirtual

Start to run. Equivalent to press the Run/Stop button when the device is not running.

Implements Oscilloscope.

Here is the call graph for this function:

◆ saveWaveformData()

PIL_ERROR_CODE KST3000::saveWaveformData ( std::string &  file_path)

save waveform data to the target file

The file can be plotted, for example using python.

import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv("buffer")
plt.xlabel('time(ms)')
plt.ylabel('voltage(V)')
plt.plot(data['time(ms)'], data['voltage(V)'])
Here is the call graph for this function:

◆ setChannelDisplay()

PIL_ERROR_CODE KST3000::setChannelDisplay ( OSC_CHANNEL  channel,
int  on 
)

Show or hide channel display. Equivalent to press channel number button.

Parameters
on1 or 0. 1: show channel single. 0: hide channel single.
channelchannel number, default 1
Here is the call graph for this function:

◆ setChannelOffset()

PIL_ERROR_CODE KST3000::setChannelOffset ( OSC_CHANNEL  channel,
double  offset 
)
overridevirtual

Set vertical offset. Equivalent to adjust the knob below channel number button.

Parameters
offsetvertical offset, unit: V
channelchannel number, default 1

Implements Oscilloscope.

Here is the call graph for this function:

◆ setChannelRange()

PIL_ERROR_CODE KST3000::setChannelRange ( OSC_CHANNEL  channel,
double  range,
VOLTAGE_UNIT  voltageUnit 
)
overridevirtual

Similar to setChannelScale, but set the whole voltage range.

Parameters
rangevoltage range(vertical)
targetchannel: default 1
is_vvoltage unit:
  • true: use V as unit, default
  • false: use mV as unit

Implements Oscilloscope.

Here is the call graph for this function:

◆ setChannelScale()

PIL_ERROR_CODE KST3000::setChannelScale ( OSC_CHANNEL  channel,
double  value 
)
overridevirtual

Equivalent to adjust the knob above channel numbers. e.g. CHANnel3:SCALe 5.

Parameters
scaleunits(voltage) per division(grid)
channeltarget channel: default 1

Implements Oscilloscope.

Here is the call graph for this function:

◆ setDisplayMode()

PIL_ERROR_CODE KST3000::setDisplayMode ( DISPLAY_MODES  mode)

set timebase mode

Parameters
mode{MAIN | WIND | XY | ROLL} must be MAIN before executing digitize
Here is the call graph for this function:

◆ setTimeDelay()

PIL_ERROR_CODE KST3000::setTimeDelay ( double  delay)

Set timebase(horizontal) delay; Equivalent to adjust the delay knob in Horizontal controls. e.g. TIMebase:DElay 5.

Parameters
delaytime delay, unit seconds
Here is the call graph for this function:

◆ setTimeRange()

PIL_ERROR_CODE KST3000::setTimeRange ( double  range)
overridevirtual

Set timebase(horizontal) range; Equivalent to adjust the "Horizontal" knob.

Parameters
rangetime range to set, unit: second

Implements Oscilloscope.

Here is the call graph for this function:

◆ setTriggerEdge()

PIL_ERROR_CODE KST3000::setTriggerEdge ( TRIGGER_EDGE  edge)
overridevirtual

Set trigger slope.

Parameters
edge{POS | NEG | EITH | ALT} (Rising | Falling | Either | Alternating)

Implements Oscilloscope.

Here is the call graph for this function:

◆ setTriggerSource()

PIL_ERROR_CODE KST3000::setTriggerSource ( OSC_CHANNEL  channel)
overridevirtual

Set trigger channel.

Parameters
channel{1(default) | 2 | 3 | 4}

Implements Oscilloscope.

Here is the call graph for this function:

◆ setWaveformFormat()

PIL_ERROR_CODE KST3000::setWaveformFormat ( FILE_FORMAT  format)

set format of waveform data(default "BYTE")

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setWaveformPoints()

PIL_ERROR_CODE KST3000::setWaveformPoints ( int  num_points)

set number of waveform points

Here is the call graph for this function:

◆ setWaveformPointsMode()

PIL_ERROR_CODE KST3000::setWaveformPointsMode ( std::string &  mode)

set waveform points mode

Parameters
mode
  • NORMal
  • MAXimum
  • RAW
Here is the call graph for this function:

◆ setWaveformSource()

PIL_ERROR_CODE KST3000::setWaveformSource ( OSC_CHANNEL  channel)

set waveform source

Here is the call graph for this function:

◆ single()

PIL_ERROR_CODE KST3000::single ( )
overridevirtual

Equivalent to press the Single button.

Implements Oscilloscope.

Here is the call graph for this function:

◆ stop()

PIL_ERROR_CODE KST3000::stop ( )
overridevirtual

Stop to run. Equivalent to press the Run/Stop button when the device is not stopping.

Implements Oscilloscope.

Here is the call graph for this function:

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