-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from ad101-lab/ad-left-awp-left
Left AWP Left
- Loading branch information
Showing
13 changed files
with
408 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
|
||
namespace Pronounce { | ||
|
||
typedef int (*AutonFunction)(); | ||
|
||
int nullAutonFunc(); | ||
|
||
class Auton { | ||
private: | ||
std::string name; | ||
AutonFunction func; | ||
public: | ||
Auton(); | ||
Auton(std::string name, AutonFunction func); | ||
|
||
int run(); | ||
|
||
std::string getName() { | ||
return name; | ||
} | ||
|
||
void setName(std::string name) { | ||
this->name = name; | ||
} | ||
|
||
AutonFunction getFunc() { | ||
return func; | ||
} | ||
|
||
void setFunc(AutonFunction func) { | ||
this->func = func; | ||
} | ||
|
||
~Auton(); | ||
}; | ||
} // namespace Pronounce | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#pragma once | ||
|
||
#include "api.h" | ||
#include "auton.hpp" | ||
#include "driver/controller.hpp" | ||
#include <vector> | ||
|
||
namespace Pronounce { | ||
class AutonSelector { | ||
private: | ||
std::vector<Auton> autons; | ||
Auton defaultAuton; | ||
|
||
Auton preAuton; | ||
Auton postAuton; | ||
|
||
Pronounce::Controller* controller; | ||
|
||
int autonIndex = 0; | ||
public: | ||
AutonSelector(); | ||
AutonSelector(std::vector<Auton> autons, Auton defaultAuton); | ||
AutonSelector(std::vector<Auton> autons, Auton defaultAuton, Pronounce::Controller* controller); | ||
|
||
void choose(); | ||
|
||
int addAuton(Auton auton) { | ||
autons.push_back(auton); | ||
return autons.size() - 1; | ||
} | ||
|
||
int run() { | ||
preAuton.run(); | ||
int result = 0; | ||
if (autonIndex >= autons.size()) { | ||
result = defaultAuton.run(); | ||
} | ||
result = autons[autonIndex].run(); | ||
postAuton.run(); | ||
return result; | ||
} | ||
|
||
Auton getAuton(int index) { | ||
int result = 0; | ||
if (index < 0 || index >= autons.size()) { | ||
return defaultAuton; | ||
} | ||
return autons[index]; | ||
} | ||
|
||
std::vector<Auton> getAutons() { | ||
return autons; | ||
} | ||
|
||
void setAutons(std::vector<Auton> autons) { | ||
this->autons = autons; | ||
} | ||
|
||
Auton getDefaultAuton() { | ||
return defaultAuton; | ||
} | ||
|
||
void setDefaultAuton(Auton defaultAuton) { | ||
this->defaultAuton = defaultAuton; | ||
} | ||
|
||
Auton getPreAuton() { | ||
return preAuton; | ||
} | ||
|
||
void setPreAuton(Auton preAuton) { | ||
this->preAuton = preAuton; | ||
} | ||
|
||
Auton getPostAuton() { | ||
return postAuton; | ||
} | ||
|
||
void setPostAuton(Auton postAuton) { | ||
this->postAuton = postAuton; | ||
} | ||
|
||
void setController(Pronounce::Controller* controller) { | ||
this->controller = controller; | ||
} | ||
|
||
int getAutonIndex() { | ||
return autonIndex; | ||
} | ||
|
||
void setAutonIndex(int autonIndex) { | ||
this->autonIndex = autonIndex; | ||
} | ||
|
||
~AutonSelector(); | ||
}; | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
|
||
#define AUTON_SELECTOR_COUNT 3 | ||
#define AUTON_SELECTOR_COUNT 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "auton.hpp" | ||
|
||
namespace Pronounce { | ||
int nullAutonFunc() { | ||
return 0; | ||
} | ||
|
||
Auton::Auton(/* args */) { | ||
this->name = ""; | ||
this->func = nullAutonFunc; | ||
} | ||
|
||
Auton::Auton(std::string name, AutonFunction func) { | ||
this->name = name; | ||
this->func = func; | ||
} | ||
|
||
int Auton::run() { | ||
return func(); | ||
} | ||
|
||
Auton::~Auton() { | ||
} | ||
} // namespace Pronounce |
Oops, something went wrong.