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 | |
IMCP2515Controller * | m_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. | |
Class that manages the CAN bus communication. QObject.
Definition at line 28 of file CanBusManager.hpp.
|
explicit |
Construct a new CanBusManager::CanBusManager object.
spi_device | The SPI device to use for communication. |
parent | The 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.
CanBusManager::CanBusManager | ( | IMCP2515Controller * | controller, |
QObject * | parent = nullptr ) |
Construct a new CanBusManager::CanBusManager object.
controller | The MCP2515 controller to use. |
parent | The parent QObject. |
This constructor initializes the CanBusManager with an existing MCP2515 controller.
Definition at line 53 of file CanBusManager.cpp.
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.
|
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.
|
inline |
bool CanBusManager::initialize | ( | ) |
Initializes the CanBusManager.
Initializes the MCP2515 controller and starts the reading thread.
Definition at line 104 of file CanBusManager.cpp.
|
signal |
Signal emitted when the RPM is updated.
newRpm | The new RPM value. |
|
signal |
Signal emitted when the speed is updated.
newSpeed | The new speed value. |
|
private |
Pointer to the IMCP2515Controller object.
Definition at line 53 of file CanBusManager.hpp.
|
private |
Pointer to the QThread object.
Definition at line 55 of file CanBusManager.hpp.
|
private |
Flag to indicate if the MCP2515 controller is owned by the CanBusManager.
Definition at line 58 of file CanBusManager.hpp.