50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
/**
|
|
* @file driveManager.cpp
|
|
* @author Alexander Klein (alex@kleiax.de)
|
|
* @brief Implementation of the class DriveManager
|
|
* @version 0.1
|
|
* @date 2021-12-14
|
|
*
|
|
* @copyright Copyright (c) 2021
|
|
*
|
|
*/
|
|
|
|
#include "driveModi/driveManager.h"
|
|
|
|
DriveManager::DriveManager(MoveControl *moveControl, const SensorData *sensorData, const ControlPadInput *input)
|
|
: driveModiParams{moveControl, input, sensorData}
|
|
{
|
|
this->init();
|
|
}
|
|
|
|
DriveManager::DriveManager(DriveModiParams params)
|
|
: driveModiParams{params}
|
|
{
|
|
this->init();
|
|
}
|
|
|
|
void DriveManager::changeModus(DriveModi *modus)
|
|
{
|
|
if (static_cast<bool>(this->currentModusPtr))
|
|
{
|
|
this->removeChildComponent(this->currentModusPtr);
|
|
delete this->currentModusPtr;
|
|
this->currentModusPtr = nullptr;
|
|
}
|
|
|
|
this->currentModusPtr = modus;
|
|
|
|
if (static_cast<bool>(this->currentModusPtr))
|
|
{
|
|
this->currentModusPtr->activate(this->driveModiParams);
|
|
this->currentModusPtr->setSpeeds(this->drivingSpeeds);
|
|
this->addChildComponent(this->currentModusPtr);
|
|
}
|
|
}
|
|
|
|
void DriveManager::init()
|
|
{
|
|
this->addChildComponent(this->driveModiParams.moveControl);
|
|
this->activateOnlyChilds();
|
|
}
|