rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
main.cpp
Go to the documentation of this file.
1 
11 // rohdeschwarz
14 #include "rohdeschwarz/helpers.hpp"
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
Object-oriented R&S Instrument control.
Definition: instrument.hpp:53
std::string id()
Queries instrument ID string.
Definition: instrument.cpp:256
bool openTcp(std::string host, unsigned int timeout_ms=2000)
Open tcp socket connection to an instrument.
Definition: instrument.cpp:57
void main()
Definition: main.cpp:19
rohdeschwarz helper function definition
rohdeschwarz::instruments::Instrument definition
boost::system::system_error system_error
System error exception.
Definition: socket.hpp:32
std::string trim(const std::string &text)
Trims whitespace beginning and end of string.
Definition: helpers.cpp:56
rohdeschwarz::busses::socket::Socket class definition
rohdeschwarz::busses::socket::system_error system_error
Definition: main.cpp:15
rohdeschwarz::instruments::Instrument Instrument
Definition: main.cpp:16