rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
channel.cpp
Go to the documentation of this file.
1 
7 // rohdeschwarz
12 using namespace rohdeschwarz;
13 using namespace rohdeschwarz::instruments::vna;
14 
15 
16 Channel::Channel(Vna *znx, unsigned int index) :
17  _vna(znx),
18  _index(index)
19 {
20  // no operations
21 }
22 
23 
24 unsigned int Channel::index() const
25 {
26  return _index;
27 }
28 
29 
30 unsigned int Channel::points()
31 {
32  // :SENS<ch>:SWE:POIN?
33  return std::stoi(_vna->query(":SENS%1%:SWE:POIN?", index()));
34 }
35 
36 
37 void Channel::setPoints(unsigned int points)
38 {
39  _vna->write(":SENS%1%:SWE:POIN %2%", index(), points);
40 }
41 
42 
44 {
45  return std::stod(_vna->query(":SENS%1%:FREQ:STAR?", _index));
46 }
47 
48 
49 void Channel::setStartFrequency(double frequency_Hz)
50 {
51  _vna->write(":SENS%1%:FREQ:STAR %2%", _index, frequency_Hz);
52 }
53 
54 
56 {
57  return std::stod(_vna->query(":SENS%1%:FREQ:STOP?", _index));
58 }
59 
60 
61 void Channel::setStopFrequency(double frequency_Hz)
62 {
63  _vna->write(":SENS%1%:FREQ:STOP %2%", _index, frequency_Hz);
64 }
65 
66 
67 std::vector<double> Channel::frequencies_Hz()
68 {
69  // set data format to binary 64-bit, little-endian
70  PreserveDataFormat preserve_data_format(_vna);
71  DataFormat format = _vna->dataFormat();
72  format.setBinary64Bit();
73  format.setLittleEndian();
74 
75  // write
76  if (!_vna->write(":CALC%1%:DATA:STIM?", _index))
77  {
78  // error
79  return std::vector<double>();
80  }
81 
82  // read
83  return _vna->read64BitVector();
84 }
rohdeschwarz::instruments::vna::Channel definition
std::string query(std::string scpi_command, Args &&... args)
Definition: instrument.hpp:173
bool write(std::string scpi_command, Args &&... args)
Definition: instrument.hpp:142
std::vector< double > read64BitVector()
Reads block data and parses it into vector <double>
Definition: instrument.cpp:214
Channel(Vna *vna, unsigned int index)
Constructor.
Definition: channel.cpp:16
void setStopFrequency(double frequency_Hz)
sets the stop frequency of the measurement
Definition: channel.cpp:61
double startFrequency_Hz()
queries the start frequency of measurement, in Hz
Definition: channel.cpp:43
void setPoints(unsigned int points)
sets number of measurement points
Definition: channel.cpp:37
std::vector< double > frequencies_Hz()
queries the measurement frequencies, in Hz
Definition: channel.cpp:67
void setStartFrequency(double frequency_Hz)
sets the start frequency of the measurement
Definition: channel.cpp:49
double stopFrequency_Hz()
queries the stop frequency of the measurement, in Hz
Definition: channel.cpp:55
unsigned int points()
queries the number of measurement points
Definition: channel.cpp:30
unsigned int index() const
channel index
Definition: channel.cpp:24
Object-oriented control of the data transfer format and byte order.
Definition: data_format.hpp:36
void setLittleEndian()
Sets the byte order for float data transfer to little-endian.
Definition: data_format.cpp:76
void setBinary64Bit()
Sets data transfer format to 64-bit float.
Definition: data_format.cpp:52
Class for preserving data format and byte order in a particular scope.
Object-oriented R&S ZNX-series VNA control.
Definition: vna.hpp:34
DataFormat dataFormat()
Object-oriented control of the data transfer format.
Definition: vna.cpp:26
rohdeschwarz::instruments::vna::PreserveDataFormat definition
rohdeschwarz::to_vector(), rohdeschwarz::to_vector_complex_double() definitions and implementations
rohdeschwarz::instruments::vna::Vna definition