RTXI  3.0.0
The Real-Time eXperiment Interface Reference Manual
main.cpp
Go to the documentation of this file.
1 #include <QApplication>
2 #include <iostream>
3 
4 #include <boost/stacktrace.hpp>
5 #include <signal.h>
6 #include <string.h>
7 
8 #include "debug.hpp"
9 #include "main_window.hpp"
10 #include "rt.hpp"
11 #include "rtxiConfig.h"
12 #include "widgets.hpp"
13 #include "workspace.hpp"
14 
15 namespace
16 {
17 void signal_handler(int signum)
18 {
19  // NOLINTNEXTLINE
20  ERROR_MSG("signal_handler : signal type {} received\n", ::strsignal(signum));
21  std::cerr << boost::stacktrace::stacktrace();
22  exit(-1); // NOLINT
23 }
24 } // namespace
25 
26 int main(int argc, char* argv[])
27 {
28  if (signal(SIGINT, signal_handler) == SIG_ERR) {
29  ERROR_MSG("MAIN: Unable to set SIGINT signal handler");
30  return -1;
31  }
32  if (signal(SIGABRT, signal_handler) == SIG_ERR) {
33  ERROR_MSG("MAIN: Unable to set SIGABRT signal handler");
34  return -1;
35  }
36  if (signal(SIGSEGV, signal_handler) == SIG_ERR) {
37  ERROR_MSG("MAIN: Unable to set SIGSEGV signal handler");
38  return -1;
39  }
40 
41  std::cout << "Welcome to RTXI Version ";
42  std::cout << RTXI_VERSION_MAJOR << ".";
43  std::cout << RTXI_VERSION_MINOR << ".";
44  std::cout << RTXI_VERSION_PATCH << "\n";
45 
46  // Initializing core classes
47  auto event_manager = std::make_unique<Event::Manager>();
48  auto rt_connector = std::make_unique<RT::Connector>();
49  auto rt_system =
50  std::make_unique<RT::System>(event_manager.get(), rt_connector.get());
51  rt_system->createTelemitryProcessor();
52  // Initializing GUI
53  // QApplication::setDesktopSettingsAware(false);
54  auto* app = new QApplication(argc, argv);
55  QApplication::connect(app, SIGNAL(lastWindowClosed()), app, SLOT(quit()));
56 
57  auto* rtxi_window = new MainWindow(event_manager.get());
58  auto mod_manager = std::make_unique<Workspace::Manager>(event_manager.get());
59  rtxi_window->loadWindow();
60  const int retval = QApplication::exec();
61  delete rtxi_window;
62  delete app;
63  return retval;
64 }
void ERROR_MSG(const std::string &errmsg, Args... args)
Definition: debug.hpp:36
int main(int argc, char *argv[])
Definition: main.cpp:26