refactore

This commit is contained in:
2023-09-03 12:36:16 +02:00
parent faaa3603a7
commit 5f650982a7
30 changed files with 578 additions and 430 deletions
+23 -28
View File
@@ -11,33 +11,22 @@
#include "driveModi/driveManager.h"
Modi& operator++(Modi& m, int) {
return m = (m == Modi::TestMode) ? Modi::Off : static_cast<Modi>(static_cast<int>(m)+1);
DriveManager::DriveManager(MoveControl *moveControl, SensorData* sensorData, ControlPadInput *input, bool wifi) {
this->driveModiParams.input = input;
this->driveModiParams.moveControl = moveControl;
this->driveModiParams.sensorData = sensorData;
this->init(wifi);
}
DriveManager::DriveManager(MoveControl *moveControl, SPIClass *spiPort, const ControlPadInput *input, bool wifi) {
this->moveControl = moveControl;
this->input = input;
this->spiPort = spiPort;
this->navigation = new Navigation(spiPort, PinNumbers::gnssSpiCs);
if (wifi)
this->navigation->initNtrip(NTRIP_HOST, NTRIP_PORT, NTRIP_MOUNT_POINT, NTRIP_USER, NTRIP_PASSWORD);
DriveManager::DriveManager(DriveModiParams params, bool wifi){
this->driveModiParams = params;
this->addChildComponent(this->moveControl);
this->addChildComponent(this->navigation);
this->activateOnlyChilds();
this->init(wifi);
}
DriveManager::~DriveManager() {
delete this->navigation;
delete this->spiPort;
}
void DriveManager::run() {}
void DriveManager::nextModus() {
changeModus(this->currentModus++);
}
void DriveManager::changeModus(Modi modus) {
@@ -56,26 +45,22 @@ void DriveManager::changeModus(Modi modus) {
break;
case Modi::ManualControl: {
this->currentModusPtr = new ManualControl(this->moveControl, this->input);
this->currentModusPtr = new ManualControl(this->driveModiParams);
}
break;
case Modi::CaptureRoute: {
this->currentModusPtr = new CaptureRoute(this->moveControl, this->input, this->navigation);
this->currentModusPtr = new CaptureRoute(this->driveModiParams, this->navigation);
}
break;
case Modi::Autopilot: {
this->currentModusPtr = new Autopilot(this->moveControl, this->input, this->navigation);
this->currentModusPtr = new Autopilot(this->driveModiParams, this->navigation);
}
break;
case Modi::ConsolControl:
this->currentModusPtr = nullptr;
break;
case Modi::TestMode: {
this->currentModusPtr = new TestMode(this->moveControl, this->navigation);
this->currentModusPtr = new TestMode(driveModiParams, this->navigation);
}
break;
@@ -88,3 +73,13 @@ void DriveManager::changeModus(Modi modus) {
this->addChildComponent(this->currentModusPtr);
}
void DriveManager::init(bool wifi) {
this->navigation = new Navigation();
if (wifi)
this->navigation->initNtrip(NTRIP_HOST, NTRIP_PORT, NTRIP_MOUNT_POINT, NTRIP_USER, NTRIP_PASSWORD);
this->addChildComponent(this->driveModiParams.moveControl);
this->addChildComponent(this->navigation);
this->activateOnlyChilds();
}