Skip to content

Commit

Permalink
Release 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
SMEZ1234 committed Feb 18, 2020
1 parent 60edd1f commit 797e862
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Arachne 3
=================
RELEASE VERSION: Arachne 3.0.1 (2020)
RELEASE VERSION: Arachne 3.0.2 (2020)
16 changes: 9 additions & 7 deletions src/main/java/arachne/lib/AutoManager.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
package arachne.lib;

import java.util.function.Function;

import arachne.lib.scheduler.Schedulable;
import arachne.lib.sequences.ActionConductor;
import arachne.lib.sequences.Actionable;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;

public class AutoManager<AutoT extends Enum<?> & Actionable> implements Schedulable
public class AutoManager<RobotT, AutoT extends Enum<?> & Function<RobotT, Actionable>> implements Schedulable
{
protected static final String DASHBOARD_TAB = "Autonomous";
protected static final String SELECTION_KEY = "Auto selection";

protected final ActionConductor conductor;
protected final SendableChooser<AutoT> autoChooser;
protected final SendableChooser<Actionable> autoChooser;

public AutoManager(AutoT defaultAuto, AutoT[] autos) {
public AutoManager(RobotT robot, AutoT defaultAuto, AutoT[] autos) {
this.conductor = new ActionConductor();

this.autoChooser = new SendableChooser<AutoT>();
this.autoChooser.setDefaultOption(defaultAuto.toString(), defaultAuto);
this.autoChooser = new SendableChooser<Actionable>();
this.autoChooser.setDefaultOption(defaultAuto.toString(), defaultAuto.apply(robot));

for(AutoT auto : autos) {
if(auto != defaultAuto) autoChooser.addOption(auto.toString(), auto);
if(auto != defaultAuto) autoChooser.addOption(auto.toString(), auto.apply(robot));
}

Shuffleboard.getTab(DASHBOARD_TAB).add(SELECTION_KEY, autoChooser);
Expand All @@ -31,7 +33,7 @@ public void startAuto() {
startAuto(autoChooser.getSelected());
}

public void startAuto(AutoT auto) {
public void startAuto(Actionable auto) {
stopAuto();
conductor.add(auto);
}
Expand Down

0 comments on commit 797e862

Please sign in to comment.