driveManager gets now the object

This commit is contained in:
2023-09-04 15:25:56 +02:00
parent 6a76470f45
commit befbd898cc
23 changed files with 63 additions and 156 deletions
+4 -42
View File
@@ -25,59 +25,21 @@ DriveManager::DriveManager(DriveModiParams params){
this->init();
}
DriveManager::~DriveManager() {
delete this->navigation;
}
void DriveManager::changeModus(Modi modus) {
this->currentModus = modus;
void DriveManager::changeModus(DriveModi* modus) {
if (this->currentModusPtr) {
this->removeChildComponent(this->currentModusPtr);
delete this->currentModusPtr;
this->currentModusPtr = nullptr;
}
//Reset Route to first point
this->navigation->startNavigation();
switch (modus) {
case Modi::Off:
this->currentModusPtr = nullptr;
break;
case Modi::ManualControl: {
this->currentModusPtr = new ManualControl(this->driveModiParams);
}
break;
case Modi::CaptureRoute: {
this->currentModusPtr = new CaptureRoute(this->driveModiParams, this->navigation);
}
break;
case Modi::Autopilot: {
this->currentModusPtr = new Autopilot(this->driveModiParams, this->navigation);
}
break;
case Modi::TestMode: {
this->currentModusPtr = new TestMode(driveModiParams, this->navigation);
}
break;
default:
this->currentModusPtr = nullptr;
break;
}
this->currentModusPtr = modus;
if (this->currentModusPtr)
this->currentModusPtr->activate(this->driveModiParams);
this->addChildComponent(this->currentModusPtr);
}
void DriveManager::init() {
this->navigation = new Navigation(this->driveModiParams.sensorData);
this->addChildComponent(this->driveModiParams.moveControl);
this->addChildComponent(this->navigation);
this->activateOnlyChilds();
}