Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
ControlsManager Class Reference

The ControlsManager class. More...

#include <ControlsManager.hpp>

Public Slots

void drivingModeUpdated (DrivingMode newMode)
 Update the driving mode of the vehicle.
 

Signals

void directionChanged (CarDirection newDirection)
 
void steeringChanged (int newAngle)
 

Public Member Functions

 ControlsManager (int argc, char **argv, QObject *parent=nullptr)
 Constructs a ControlsManager object.
 
 ~ControlsManager ()
 Destructor for the ControlsManager class.
 
void setMode (DrivingMode mode)
 Sets the driving mode.
 
void readJoystickEnable ()
 Reads joystick enable status.
 
bool isProcessRunning (const QString &processName)
 Check if a process is running.
 
 ControlsManager (int argc, char **argv, QObject *parent=nullptr)
 
 ~ControlsManager ()
 

Private Attributes

EngineController m_engineController
 
JoysticksControllerm_manualController
 
DrivingMode m_currentMode
 
ClientThreadm_clientObject
 
Data::CarDataIm_carDataObject
 
QThread * m_manualControllerThread
 
QThread * m_processMonitorThread
 
QThread * m_carDataThread
 
QThread * m_clientThread
 
QThread * m_joystickControlThread
 
std::atomic< bool > m_threadRunning
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ControlsManager() [1/2]

ControlsManager::ControlsManager ( int argc,
char ** argv,
QObject * parent = nullptr )
explicit

Constructs a ControlsManager object.

Construct a new ControlsManager object.

Parameters
argcThe number of command-line arguments.
argvThe array of command-line arguments.
parentThe 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
parentThe parent QObject.

This constructor initializes the ControlsManager object.

Definition at line 35 of file ControlsManager.cpp.

Here is the call graph for this function:

◆ ~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 ( )

Member Function Documentation

◆ directionChanged

void ControlsManager::directionChanged ( CarDirection newDirection)
signal
Here is the caller graph for this function:

◆ drivingModeUpdated

void ControlsManager::drivingModeUpdated ( DrivingMode newMode)
slot

Update the driving mode of the vehicle.

Parameters
newModeThe 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.

Here is the caller graph for this function:

◆ isProcessRunning()

bool ControlsManager::isProcessRunning ( const QString & processName)

Check if a process is running.

Parameters
processNameThe 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.

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMode()

void ControlsManager::setMode ( DrivingMode mode)

Sets the driving mode.

Parameters
modeThe new driving mode.

Updates the current driving mode if it has changed.

Definition at line 221 of file ControlsManager.cpp.

Here is the caller graph for this function:

◆ steeringChanged

void ControlsManager::steeringChanged ( int newAngle)
signal
Here is the caller graph for this function:

Field Documentation

◆ m_carDataObject

Data::CarDataI* ControlsManager::m_carDataObject
private

Definition at line 38 of file ControlsManager.hpp.

◆ m_carDataThread

QThread* ControlsManager::m_carDataThread
private

Definition at line 42 of file ControlsManager.hpp.

◆ m_clientObject

ClientThread * ControlsManager::m_clientObject
private

Definition at line 37 of file ControlsManager.hpp.

◆ m_clientThread

QThread * ControlsManager::m_clientThread
private

Definition at line 43 of file ControlsManager.hpp.

◆ m_currentMode

DrivingMode ControlsManager::m_currentMode
private

Definition at line 36 of file ControlsManager.hpp.

◆ m_engineController

EngineController ControlsManager::m_engineController
private

Definition at line 34 of file ControlsManager.hpp.

◆ m_joystickControlThread

QThread* ControlsManager::m_joystickControlThread
private

Definition at line 44 of file ControlsManager.hpp.

◆ m_manualController

JoysticksController* ControlsManager::m_manualController
private

Definition at line 35 of file ControlsManager.hpp.

◆ m_manualControllerThread

QThread* ControlsManager::m_manualControllerThread
private

Definition at line 40 of file ControlsManager.hpp.

◆ m_processMonitorThread

QThread* ControlsManager::m_processMonitorThread
private

Definition at line 41 of file ControlsManager.hpp.

◆ m_threadRunning

std::atomic<bool> ControlsManager::m_threadRunning
private

Definition at line 46 of file ControlsManager.hpp.


The documentation for this class was generated from the following files: