Files
Bachelorarbeit-Rover/src/driveModi/driveManager.h
T

121 lines
2.8 KiB
C++

/**
* @file driveManager.h
* @author Alexander Klein (alex@kleiax.de)
* @brief Contains a class to switch the DriveModi
* @version 0.1
* @date 2021-12-14
*
* @copyright Copyright (c) 2021
*
*/
#ifndef DRIVE_MANAGER_H
#define DRIVE_MANAGER_H
#include <Arduino.h>
#include <SPI.h>
#include "moveControl.h"
#include "driveModi/driveModi.h"
#include "navigation.h"
#include "config.h"
#include "networkConfig.h"
#include "debugTimes.h"
#include "controlPadInput.h"
#include "component.h"
// All Drive Modi
#include "driveModi/Modi/ManualControl/manualControl.h"
#include "driveModi/Modi/CaptureRoute/captureRoute.h"
#include "driveModi/Modi/Autopilot/autopilot.h"
#include "driveModi/Modi/ConsolControl/consolControl.h"
#include "driveModi/Modi/TestMode/testMode.h"
/**
* @brief An enum to choose the DriveMode
*
*/
enum class Modi {
Off,
ManualControl,
CaptureRoute,
Autopilot,
ConsolControl,
TestMode
};
class DriveManager : public Component {
public:
/**
* @brief Construct a new Drive Manager object
*
* Creates a Navigation object
*
* @param moveControl
*/
DriveManager(MoveControl *moveControl, SPIClass *spiPort, const ControlPadInput *input, bool wifi = false);
/**
* @brief Destroy the Drive Manager object
*
*/
~DriveManager();
/**
* @brief Increment the DriveModi enum
* Than calls changeModus
*
* @see Modi
*/
void nextModus();
/**
* @brief Change the DriveModi to a specific value
*
* Sets MoveControl to a safe state, delete the last
* DriveModi and than set the new DriveModi
*
* @param modus
*/
void changeModus(Modi modus);
/**
* @brief Get the Navigation object
*
* @return Navigation*
*/
Navigation* getNavigation() const {return this->navigation;}
/**
* @brief Get the DriveModi Ptr object
*
* This is a pointer to the Object of the current DriveMode.
* If you know which DriveMode is active, you can cast this
* pointer to it.
*
* @see getDriveModi
* @return DriveModi*
*/
DriveModi* getDriveModiPtr() const { return this->currentModusPtr; }
/**
* @brief Get the DriveModi enum
*
* @return Modi
*/
Modi getDriveModi() const { return this->currentModus; }
private:
void run() override;
Modi currentModus = Modi::Off;
MoveControl *moveControl;
const ControlPadInput* input;
DriveModi *currentModusPtr = nullptr;
Navigation* navigation;
SPIClass* spiPort;
};
#endif // DRIVE_MANAGER_H