From c50519e6e44cf1c9717375387b0a475631cd9e4f Mon Sep 17 00:00:00 2001 From: Liam Fruzyna Date: Sun, 10 Mar 2024 09:43:26 -0500 Subject: [PATCH] Created a function that fetches and stores the FMS alliance, then returns the stored version. Plus, two helper functions that return booleans --- .../org/wildstang/framework/core/Core.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/org/wildstang/framework/core/Core.java b/src/main/java/org/wildstang/framework/core/Core.java index de73339a..e4976db7 100644 --- a/src/main/java/org/wildstang/framework/core/Core.java +++ b/src/main/java/org/wildstang/framework/core/Core.java @@ -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. */ @@ -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; @@ -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); + } }