11#ifndef KPIROVERECU_H
22#define KPIROVERECU_H
33
4- #include " TCPTransport.h"
5- // #include "config.h"
6- #include " protocolHandler.h"
74#include < atomic>
8- #include < condition_variable>
9- #include < csignal>
10- #include < cstring>
11- #include < iostream>
12- #include < mutex>
13- #include < queue>
5+ #include < cstdint>
146#include < thread>
15- #include < vector>
16- #include < unistd.h>
177
18- #define TIMERPRECISION 100000 // 100 miliseconds in microsecond (for timer)
19- #define ONESECONDMICRO 1000000 // 1 s in microseconds
20- #define ONESECONDMILI 1000
21- #define TIMESTOP 1 // 1 second befre stopping all motors. If no new command is received over TCP for 1 second, all motors must stop.
8+ #include " TCPTransport.h"
9+ #include " protocolHandler.h"
2210
23- using namespace std ;
11+ // Constants for timing control
12+ static constexpr std::uint32_t kTimerPrecision = 100000 ; // 100 milliseconds in microsecond (for timer)
13+ static constexpr std::uint32_t kOneSecondMicro = 1000000 ; // 1 s in microseconds
14+ static constexpr std::uint32_t kOneSecondMilli = 1000 ; // 1 s in milliseconds
15+ static constexpr std::uint32_t kTimeStop = 5 ; // 5 seconds
2416
2517class KPIRoverECU {
2618 public:
27-
2819 void TimerThreadFuction (ProtocolHanlder *workClass);
2920 void ProcessingThreadFunction ();
3021
@@ -35,12 +26,13 @@ class KPIRoverECU {
3526 private:
3627 ProtocolHanlder *protocol_handler_;
3728 TCPTransport *tcp_transport_;
38- thread timerThread_, processingThread_;
39- atomic<bool > runningProcess_;
40- atomic<bool > runningState_;
41- atomic<int > counter_;
29+ std::thread timerThread_;
30+ std::thread processingThread_;
31+ std::atomic<bool > runningProcess_;
32+ std::atomic<bool > runningState_;
33+ std::atomic<int > counter_;
4234
43- int GetCounter ();
35+ static int GetCounter ();
4436};
4537
4638#endif
0 commit comments