Skip to content

Commit

Permalink
Created a function that fetches and stores the FMS alliance, then ret…
Browse files Browse the repository at this point in the history
…urns the stored version. Plus, two helper functions that return booleans
  • Loading branch information
fruzyna committed Mar 10, 2024
1 parent 90d1245 commit c50519e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/org/wildstang/framework/core/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.wildstang.framework.subsystems.Subsystem;
import org.wildstang.framework.subsystems.SubsystemManager;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.DriverStation.Alliance;

/**
* Core of robot framework.
*/
Expand All @@ -26,6 +29,7 @@ public class Core {
private static InputFactory s_inputFactory;
private static OutputFactory s_outputFactory;
private static AutoManager s_autoManager;
private static Alliance alliance;

private Class<?> m_inputFactoryClass;
private Class<?> m_outputFactoryClass;
Expand Down Expand Up @@ -220,4 +224,32 @@ public void executeUpdate() {
s_outputManager.update();
}

/**
* Returns the stored FMS alliance. If nothing is stored, fetch and store the alliance.
* @return Stored Alliance value.
*/
public Alliance getAlliance() {
if (alliance == null) {
alliance = DriverStation.getAlliance();
}
return alliance;
}

/**
* Determines if the stored FMS alliance is the blue alliance.
* @return True if blue alliance.
*/
public boolean isBlueAlliance() {
Alliance alliance = getAlliance();
return alliance.equals(Alliance.Blue);
}

/**
* Determines if the stored FMS alliance is the red alliance.
* @return True if red alliance.
*/
public boolean isRedAlliance() {
Alliance alliance = getAlliance();
return alliance.equals(Alliance.Red);
}
}

0 comments on commit c50519e

Please sign in to comment.