The ControlsManager class.
More...
#include <ControlsManager.hpp>
The ControlsManager class.
Class that manages the car's controls. QObject.
This class is responsible for managing the controls of the car.
Definition at line 30 of file ControlsManager.hpp.
◆ ControlsManager() [1/2]
ControlsManager::ControlsManager |
( |
int | argc, |
|
|
char ** | argv, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
Constructs a ControlsManager object.
Construct a new ControlsManager object.
- Parameters
-
argc | The number of command-line arguments. |
argv | The array of command-line arguments. |
parent | The parent QObject for this ControlsManager. |
Initializes the engine controller, joystick controller, and various worker threads for managing car controls. Sets up joystick control with callbacks for steering and speed adjustments, manages server and client middleware threads, monitors processes, and handles joystick enable status through dedicated threads.
- Parameters
-
parent | The parent QObject. |
This constructor initializes the ControlsManager object.
Definition at line 35 of file ControlsManager.cpp.
◆ ~ControlsManager() [1/2]
ControlsManager::~ControlsManager |
( |
| ) |
|
Destructor for the ControlsManager class.
Destroy the ControlsManager object.
Safely stops and cleans up all threads and resources associated with the ControlsManager. This includes stopping the client, shared memory, process monitoring, joystick control, and manual controller threads. It also deletes associated objects such as m_carDataObject, m_clientObject, and m_manualController.
This destructor stops the joystick controller and waits for the thread to finish.
Definition at line 132 of file ControlsManager.cpp.
◆ ControlsManager() [2/2]
ControlsManager::ControlsManager |
( |
int | argc, |
|
|
char ** | argv, |
|
|
QObject * | parent = nullptr ) |
|
explicit |
◆ ~ControlsManager() [2/2]
ControlsManager::~ControlsManager |
( |
| ) |
|
◆ directionChanged
void ControlsManager::directionChanged |
( |
CarDirection | newDirection | ) |
|
|
signal |
◆ drivingModeUpdated
void ControlsManager::drivingModeUpdated |
( |
DrivingMode | newMode | ) |
|
|
slot |
Update the driving mode of the vehicle.
- Parameters
-
newMode | The new driving mode of the vehicle. |
This slot is called when the driving mode of the vehicle is changed. It updates the current driving mode by calling the setMode() method.
Definition at line 67 of file ControlsManager.cpp.
◆ isProcessRunning()
bool ControlsManager::isProcessRunning |
( |
const QString & | processName | ) |
|
Check if a process is running.
- Parameters
-
processName | The name of the process to check. |
- Returns
- True if the process is running, false otherwise.
Uses the pgrep
command to determine if a given process is active.
Definition at line 189 of file ControlsManager.cpp.
◆ readJoystickEnable()
void ControlsManager::readJoystickEnable |
( |
| ) |
|
Reads joystick enable status.
Checks if joystick control is enabled through the client middleware and updates the driving mode accordingly.
Definition at line 203 of file ControlsManager.cpp.
◆ setMode()
Sets the driving mode.
- Parameters
-
mode | The new driving mode. |
Updates the current driving mode if it has changed.
Definition at line 221 of file ControlsManager.cpp.
◆ steeringChanged
void ControlsManager::steeringChanged |
( |
int | newAngle | ) |
|
|
signal |
◆ m_carDataObject
◆ m_carDataThread
QThread* ControlsManager::m_carDataThread |
|
private |
◆ m_clientObject
◆ m_clientThread
QThread * ControlsManager::m_clientThread |
|
private |
◆ m_currentMode
◆ m_engineController
◆ m_joystickControlThread
QThread* ControlsManager::m_joystickControlThread |
|
private |
◆ m_manualController
◆ m_manualControllerThread
QThread* ControlsManager::m_manualControllerThread |
|
private |
◆ m_processMonitorThread
QThread* ControlsManager::m_processMonitorThread |
|
private |
◆ m_threadRunning
std::atomic<bool> ControlsManager::m_threadRunning |
|
private |
The documentation for this class was generated from the following files: