-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar_controller.cpp
48 lines (36 loc) · 1.01 KB
/
car_controller.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "car_controller.h"
#include <unistd.h>
#include <csignal>
namespace {
int signal_shutdown = 0;
void SignalHandler(int signal) {
if (signal == SIGINT)
signal_shutdown = 1;
}
}
void CarController::Start() {
std::string ip = "0.0.0.0";
int port = 5000;
std::cout << "Initializarea pornita" << std::endl;
std::cout << "IP: " << ip << std::endl;;
std::cout << "Port: " << port << std::endl;;
state = std::unique_ptr<CarState>(new CarState());
connection = std::unique_ptr<CarConnection>(new CarConnection(state.get(), make_pair(ip, port)));
motor = std::unique_ptr<CarMotor>(new CarMotor(state.get()));
rf = std::unique_ptr<CarRF>(new CarRF(state.get()));
std::signal(SIGINT, SignalHandler);
connection->Connect();
connection->Start();
std::cout<<"Car Program is ONLINE"<<std::endl;
motor->Start();
rf->Start();
while(true) {
if (signal_shutdown) {
state->shut_down();
}
if(state->is_shutting_down()) {
break;
}
//state->get_state();
}
}