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

Class that manages the CAN bus communication. QObject. More...

#include <CanBusManager.hpp>

Signals

void speedUpdated (float newSpeed)
 Signal emitted when the speed is updated.
 
void rpmUpdated (int newRpm)
 Signal emitted when the RPM is updated.
 

Public Member Functions

 CanBusManager (const std::string &spi_device, QObject *parent=nullptr)
 Construct a new CanBusManager::CanBusManager object.
 
 CanBusManager (IMCP2515Controller *controller, QObject *parent=nullptr)
 Construct a new CanBusManager::CanBusManager object.
 
 ~CanBusManager ()
 Destroy the CanBusManager::CanBusManager object.
 
bool initialize ()
 Initializes the CanBusManager.
 
QThread * getThread () const
 

Private Member Functions

void connectSignals ()
 Method to connect signals.
 

Private Attributes

IMCP2515Controllerm_controller = nullptr
 Pointer to the IMCP2515Controller object.
 
QThread * m_thread = nullptr
 Pointer to the QThread object.
 
bool ownsMCP2515Controller = false
 Flag to indicate if the MCP2515 controller is owned by the CanBusManager.
 

Detailed Description

Class that manages the CAN bus communication. QObject.

Definition at line 28 of file CanBusManager.hpp.

Constructor & Destructor Documentation

◆ CanBusManager() [1/2]

CanBusManager::CanBusManager ( const std::string & spi_device,
QObject * parent = nullptr )
explicit

Construct a new CanBusManager::CanBusManager object.

Parameters
spi_deviceThe SPI device to use for communication.
parentThe parent QObject.

This constructor initializes the CanBusManager with a specified SPI device and sets up the MCP2515 controller.

Definition at line 36 of file CanBusManager.cpp.

Here is the call graph for this function:

◆ CanBusManager() [2/2]

CanBusManager::CanBusManager ( IMCP2515Controller * controller,
QObject * parent = nullptr )

Construct a new CanBusManager::CanBusManager object.

Parameters
controllerThe MCP2515 controller to use.
parentThe parent QObject.

This constructor initializes the CanBusManager with an existing MCP2515 controller.

Definition at line 53 of file CanBusManager.cpp.

Here is the call graph for this function:

◆ ~CanBusManager()

CanBusManager::~CanBusManager ( )

Destroy the CanBusManager::CanBusManager object.

Cleans up the resources used by the CanBusManager, including stopping the reading thread and deleting the controller if owned.

Definition at line 67 of file CanBusManager.cpp.

Member Function Documentation

◆ connectSignals()

void CanBusManager::connectSignals ( )
private

Method to connect signals.

Connects the signals from the MCP2515 controller to the CanBusManager slots.

This method sets up the connections between the signals emitted by the MCP2515 controller and the corresponding slots in the CanBusManager.

Definition at line 91 of file CanBusManager.cpp.

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

◆ getThread()

QThread * CanBusManager::getThread ( ) const
inline

Definition at line 37 of file CanBusManager.hpp.

Here is the caller graph for this function:

◆ initialize()

bool CanBusManager::initialize ( )

Initializes the CanBusManager.

Initializes the MCP2515 controller and starts the reading thread.

Returns
true if initialization is successful, false otherwise.

Definition at line 104 of file CanBusManager.cpp.

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

◆ rpmUpdated

void CanBusManager::rpmUpdated ( int newRpm)
signal

Signal emitted when the RPM is updated.

Parameters
newRpmThe new RPM value.
Here is the caller graph for this function:

◆ speedUpdated

void CanBusManager::speedUpdated ( float newSpeed)
signal

Signal emitted when the speed is updated.

Parameters
newSpeedThe new speed value.
Here is the caller graph for this function:

Field Documentation

◆ m_controller

IMCP2515Controller* CanBusManager::m_controller = nullptr
private

Pointer to the IMCP2515Controller object.

Definition at line 53 of file CanBusManager.hpp.

◆ m_thread

QThread* CanBusManager::m_thread = nullptr
private

Pointer to the QThread object.

Definition at line 55 of file CanBusManager.hpp.

◆ ownsMCP2515Controller

bool CanBusManager::ownsMCP2515Controller = false
private

Flag to indicate if the MCP2515 controller is owned by the CanBusManager.

Definition at line 58 of file CanBusManager.hpp.


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