Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <iostream>
00031 #include <string>
00032 #include <thread>
00033 #include <chrono>
00034 #include <pepperl_fuchs_r2000/r2000_driver.h>
00035
00036 int main(int argc, char **argv)
00037 {
00038 std::cout << "Hello world!" << std::endl;
00039 std::string scanner_ip("192.168.1.71");
00040 pepperl_fuchs::R2000Driver driver;
00041
00042 for( int i=0; i<2; i++ )
00043 {
00044 std::cout << "Connecting to scanner at " << scanner_ip << " ... ";
00045 if (driver.connect(scanner_ip, 80))
00046 std::cout << "OK" << std::endl;
00047 else
00048 {
00049 std::cout << "FAILED!" << std::endl;
00050 std::cerr << "Connection to scanner at " << scanner_ip << " failed!" << std::endl;
00051 return 1;
00052 }
00053
00054 driver.setScanFrequency(35);
00055 driver.setSamplesPerScan(3600);
00056 auto params = driver.getParameters();
00057 std::cout << "Current scanner settings:" << std::endl;
00058 std::cout << "============================================================" << std::endl;
00059 for (const auto& p : params)
00060 std::cout << p.first << " : " << p.second << std::endl;
00061 std::cout << "============================================================" << std::endl;
00062
00063
00064
00065
00066 std::cout << "Starting capturing: ";
00067 if (driver.startCapturingUDP())
00068 std::cout << "OK" << std::endl;
00069 else
00070 {
00071 std::cout << "FAILED!" << std::endl;
00072 return 1;
00073 }
00074
00075 for (int s = 0; s < 5; s++)
00076 {
00077 std::this_thread::sleep_for(std::chrono::seconds(1));
00078 int scans_captured = 0;
00079 int scans_available = driver.getFullScansAvailable();
00080 for (int i = 0; i < scans_available; i++)
00081 {
00082 auto scandata = driver.getScan();
00083 scans_captured++;
00084 }
00085 std::cout << "Received " << scans_captured << " from scanner" << std::endl;
00086 }
00087
00088 std::cout << "Trying to stop capture" << std::endl;
00089
00090 std::cout << "Stopping capture: " << driver.stopCapturing() << std::endl;
00091
00092 }
00093
00094 std::cout << "Goodbye world!" << std::endl;
00095 return 0;
00096 }