cleaning
refactore all components now have a base class compnent for loop functions
This commit is contained in:
@@ -23,8 +23,10 @@ DriveManager::DriveManager(MoveControl *moveControl, SPIClass *spiPort, const Co
|
||||
this->navigation = new Navigation(spiPort, UBLOX_GNSS_SPI_CS);
|
||||
if (wifi)
|
||||
this->navigation->initNtrip(NTRIP_HOST, NTRIP_PORT, NTRIP_MOUNT_POINT, NTRIP_USER, NTRIP_PASSWORD);
|
||||
// if (wifi)
|
||||
// std::cout << "Wifi is true" << std::endl;
|
||||
|
||||
this->addChildComponent(this->moveControl);
|
||||
this->addChildComponent(this->navigation);
|
||||
this->activateOnlyChilds();
|
||||
}
|
||||
|
||||
DriveManager::~DriveManager() {
|
||||
@@ -32,18 +34,7 @@ DriveManager::~DriveManager() {
|
||||
delete this->spiPort;
|
||||
}
|
||||
|
||||
void DriveManager::loop() {
|
||||
DebugTimes moveControlTime;
|
||||
this->moveControl->loop();
|
||||
moveControlTime.stopConsol("MoveControlTime", 5);
|
||||
|
||||
DebugTimes navigationTime;
|
||||
this->navigation->loop();
|
||||
navigationTime.stopConsol("NavigationTime", 20);
|
||||
|
||||
if (currentModusPtr)
|
||||
this->currentModusPtr->loop();
|
||||
}
|
||||
void DriveManager::run() {}
|
||||
|
||||
void DriveManager::nextModus() {
|
||||
changeModus(this->currentModus++);
|
||||
@@ -52,14 +43,12 @@ void DriveManager::nextModus() {
|
||||
void DriveManager::changeModus(Modi modus) {
|
||||
this->currentModus = modus;
|
||||
|
||||
delete this->currentModusPtr;
|
||||
if (this->currentModusPtr) {
|
||||
this->removeChildComponent(this->currentModusPtr);
|
||||
delete this->currentModusPtr;
|
||||
}
|
||||
//Reset Route to first point
|
||||
this->navigation->startNavigation();
|
||||
|
||||
//Set moveControl to a safe state
|
||||
this->moveControl->setSpeed(0);
|
||||
this->moveControl->setRotationSpeed(0);
|
||||
this->moveControl->setDrivingStatus(MoveControl::Status::Stop);
|
||||
|
||||
switch (modus) {
|
||||
case Modi::Off:
|
||||
@@ -94,5 +83,8 @@ void DriveManager::changeModus(Modi modus) {
|
||||
this->currentModusPtr = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->currentModusPtr)
|
||||
this->addChildComponent(this->currentModusPtr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user