ChimeraTK-DeviceAccess  03.18.00
rebotManualTest.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #include "Device.h"
5 
6 #include <chrono>
7 #include <iostream>
8 #include <limits>
9 #include <string>
10 
11 int main() {
12  std::cout << "****************************************************************" << std::endl;
13  std::cout << "* Rebot Timeout Tests *" << std::endl;
14  std::cout << "****************************************************************" << std::endl;
15 
16  std::string sdm;
17  std::cout << "Enter Rebot device SDM: ";
18  std::getline(std::cin, sdm);
19 
20  std::cout << sdm << std::endl;
21 
22  std::cout << std::endl;
23  std::cout << std::endl;
24  auto begin = std::chrono::system_clock::now();
25  auto end = std::chrono::system_clock::now();
26  unsigned long duration;
27  std::string write_register;
28  std::string read_register;
29  /********************************************************************************************************************/
30  {
31  std::cout << "Starting Test: Connection Timeout" << std::endl;
32  std::cout << "Power down tmcb and press enter" << std::endl;
33  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
34  std::cout << "Trying to connect to TMCB..." << std::endl;
35  ChimeraTK::Device d{sdm};
37  try {
38  d.open();
39  }
40  catch(ChimeraTK::runtime_error& e) {
42  duration = std::chrono::duration_cast<std::chrono::seconds>(end - begin).count();
43  std::cout << "Test Succesful: connection timed out after " << duration << " s" << std::endl;
44  }
45  }
46  /********************************************************************************************************************/
47  std::cout << std::endl;
48  std::cout << std::endl;
49  std::cout << "Power on tmcb and press enter after it appears on the network" << std::endl;
50  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
51 
52  /********************************************************************************************************************/
53  {
54  std::cout << "Starting Test: Read Timeout" << std::endl;
55  std::cout << "Please enter register name on the tmcb to read from:" << std::endl;
56  std::getline(std::cin, read_register);
57  ChimeraTK::Device d{sdm};
58  d.open();
59  std::cout << "Please pull ethernet cable and press enter..." << std::endl;
60  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
62  try {
63  [[maybe_unused]] auto x = d.read<int>(read_register);
64  }
65  catch(ChimeraTK::runtime_error& e) {
67  duration = std::chrono::duration_cast<std::chrono::seconds>(end - begin).count();
68  std::cout << "Test Succesful: Read timed out after " << duration << " s" << std::endl;
69  }
70  }
71  /********************************************************************************************************************/
72 
73  std::cout << std::endl;
74  std::cout << std::endl;
75  std::cout << "Reconnect cable and powercycle tmcb; press enter after it appears on the network" << std::endl;
76  std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
77 
78  std::cout << std::endl;
79  std::cout << std::endl;
80  /********************************************************************************************************************/
81  {
82  std::cout << "Starting Test: Write Timeout" << std::endl;
83  std::cout << "Use same register as read for this test? Press enter if yes; else type new name" << std::endl;
84  std::getline(std::cin, write_register);
85 
86  if(write_register.empty()) {
87  write_register = read_register;
88  }
89 
90  std::cout << write_register << " will be used for testing" << std::endl;
91 
92  ChimeraTK::Device d{sdm};
93  d.open();
94  std::cout << "Please pull ethernet cable and press enter..." << std::endl;
95  std::getline(std::cin, read_register);
97  try {
98  d.write(write_register, 56);
99  }
100  catch(ChimeraTK::runtime_error& e) {
102  duration = std::chrono::duration_cast<std::chrono::seconds>(end - begin).count();
103  std::cout << "Test Succesful: Write timed out after " << duration << " s" << std::endl;
104  }
105  }
106  /********************************************************************************************************************/
107 
108  std::cout << "****************************************************************" << std::endl;
109  std::cout << "* Tests complete *" << std::endl;
110  std::cout << "****************************************************************" << std::endl;
111 }
ChimeraTK::testable_rebot_sleep::now
boost::chrono::steady_clock::time_point now()
Definition: testableRebotSleep.cc:7
ChimeraTK::runtime_error
Exception thrown when a runtime error has occured.
Definition: Exception.h:18
main
int main()
Definition: rebotManualTest.cpp:11
Device.h
ChimeraTK::Device
Class allows to read/write registers from device.
Definition: Device.h:39
ChimeraTK::Device::open
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
Definition: Device.cc:58