rohdeschwarz
0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
test_package
src
main.cpp
Go to the documentation of this file.
1
11
// rohdeschwarz
12
#include "
rohdeschwarz/busses/socket/socket.hpp
"
13
#include "
rohdeschwarz/instruments/instrument.hpp
"
14
#include "
rohdeschwarz/helpers.hpp
"
15
using
system_error
=
rohdeschwarz::busses::socket::system_error
;
16
using
Instrument
=
rohdeschwarz::instruments::Instrument
;
17
18
19
// std lib
20
#include <iostream>
21
22
23
int
main
()
24
{
25
26
// connect to instrument
27
Instrument
instrument;
28
if
(instrument.
openTcp
(
"localhost"
))
29
{
30
// connected
31
32
// get id
33
const
auto
id
=
rohdeschwarz::trim
(instrument.
id
());
34
35
// print for debug
36
#ifndef NDEBUG
37
std::cout <<
"connected: "
<<
id
<< std::endl;
38
#endif
39
40
}
41
else
42
{
43
// connection failed
44
45
// print for debug
46
#ifndef NDEBUG
47
std::cout <<
"error: connection to localhost failed"
<< std::endl;
48
#endif
49
50
}
51
return
0;
52
53
54
}
// main
rohdeschwarz::instruments::Instrument
Object-oriented R&S Instrument control.
Definition:
instrument.hpp:53
rohdeschwarz::instruments::Instrument::id
std::string id()
Queries instrument ID string.
Definition:
instrument.cpp:256
rohdeschwarz::instruments::Instrument::openTcp
bool openTcp(std::string host, unsigned int timeout_ms=2000)
Open tcp socket connection to an instrument.
Definition:
instrument.cpp:57
main
void main()
Definition:
main.cpp:19
helpers.hpp
rohdeschwarz helper function definition
instrument.hpp
rohdeschwarz::instruments::Instrument definition
rohdeschwarz::busses::socket::system_error
boost::system::system_error system_error
System error exception.
Definition:
socket.hpp:32
rohdeschwarz::trim
std::string trim(const std::string &text)
Trims whitespace beginning and end of string.
Definition:
helpers.cpp:56
socket.hpp
rohdeschwarz::busses::socket::Socket class definition
system_error
rohdeschwarz::busses::socket::system_error system_error
Definition:
main.cpp:15
Instrument
rohdeschwarz::instruments::Instrument Instrument
Definition:
main.cpp:16
Generated by
1.9.1