rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
vna.cpp
Go to the documentation of this file.
1 
7 // rohdeschwarz
10 #include "rohdeschwarz/helpers.hpp"
11 using namespace rohdeschwarz::instruments::vna;
12 using namespace rohdeschwarz::scpi;
13 using namespace rohdeschwarz;
14 
15 
16 // std lib
17 #include <algorithm>
18 
19 
21 {
22  return Display(this);
23 }
24 
25 
27 {
28  return DataFormat(this);
29 }
30 
31 
32 bool Vna::isChannel(unsigned int index)
33 {
34  const std::vector<unsigned int> channels = this->channels();
35  auto i = std::find(channels.begin(), channels.end(), index);
36  return i != channels.end();
37 }
38 
39 
40 Channel Vna::createChannel(unsigned int index)
41 {
42  write(":CONF:CHAN%1% 1", index);
43  return channel(index);
44 }
45 
46 
47 Channel Vna::channel(unsigned int index)
48 {
49  return Channel(this, index);
50 }
51 
52 
53 std::vector<unsigned int> Vna::channels()
54 {
55  // CONF:CHAN:CAT?
56  const std::string response = query(":CONF:CHAN:CAT?");
57  const std::string csvList = unquote(rightTrim(response));
58  const std::vector<IndexName> index_names = IndexName::parse(csvList);
59  return IndexName::indexesFrom(index_names);
60 }
61 
62 
63 bool Vna::isTrace(const char* name)
64 {
65  const std::string name_str(name);
66  return isTrace(name_str);
67 }
68 
69 
70 bool Vna::isTrace(const std::string& name)
71 {
72  const std::vector<std::string> traces = this->traces();
73  auto i = std::find(traces.begin(), traces.end(), name);
74  return i != traces.end();
75 }
76 
77 
78 Trace Vna::createTrace(const char* name, unsigned int channel)
79 {
80  const std::string name_str(name);
81  return createTrace(name_str, channel);
82 }
83 
84 
85 Trace Vna::createTrace(const std::string& name, unsigned int channel)
86 {
87  write(":CALC%1%:PAR:SDEF \'%2%\',\'S21\'", channel, name);
88  return trace(name);
89 }
90 
91 
92 Trace Vna::trace(const char* name)
93 {
94  const std::string name_str(name);
95  return trace(name_str);
96 }
97 
98 
99 Trace Vna::trace(const std::string& name)
100 {
101  return Trace(this, name);
102 }
103 
104 
105 std::vector<std::string> Vna::traces()
106 {
107  // CONF:TRAC:CAT?
108  const std::string response = query(":CONF:TRAC:CAT?");
109  const std::string csvList = unquote(rightTrim(response));
110  const std::vector<IndexName> index_names = IndexName::parse(csvList);
111  return IndexName::namesFrom(index_names);
112 }
Object-oriented measurement channel control.
Definition: channel.hpp:29
Object-oriented control of the data transfer format and byte order.
Definition: data_format.hpp:36
Object-oriented display control.
Definition: display.hpp:32
Object-oriented trace control.
Definition: trace.hpp:31
Trace trace(const char *name)
Object-oriented control of a trace.
Definition: vna.cpp:92
bool isChannel(unsigned int index)
Checks for existence of channel index
Definition: vna.cpp:32
Channel createChannel(unsigned int index)
Create new channel with specified index.
Definition: vna.cpp:40
std::vector< unsigned int > channels()
Query existing channels, by indexes.
Definition: vna.cpp:53
bool isTrace(const char *name)
Checks for existence of a trace by name.
Definition: vna.cpp:63
DataFormat dataFormat()
Object-oriented control of the data transfer format.
Definition: vna.cpp:26
std::vector< std::string > traces()
Query existing traces by name.
Definition: vna.cpp:105
Display display()
Object-oriented control of the display.
Definition: vna.cpp:20
Channel channel(unsigned int index)
Object-oriented control of a measurement channel.
Definition: vna.cpp:47
Trace createTrace(const char *name, unsigned int channel=1)
Creates a new trace.
Definition: vna.cpp:78
rohdeschwarz helper function definition
std::string unquote(const char *text)
Removes quotes from beginning and end of string.
Definition: helpers.cpp:121
std::string rightTrim(std::string text)
Trims whitespace from right (end) of string.
Definition: helpers.cpp:47
rohdeschwarz::instruments::vna::Vna definition