<commit_before>package org.firebears.subsystems;

import org.firebears.Robot;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.networktables.NetworkTable;

/**
 * Subsystem interface to the lights running on the Raspberry Pi. Communicates
 * to the pi through the Network Tables.
 */
public class Lights extends Subsystem {

	double range;

	static NetworkTable table;
	boolean isCelebrateMode = false;

	public Lights() {
		table = NetworkTable.getTable("lights");
		setStrip(STRIP_CHASSIS_FRONT, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_BACK, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_BOTTOM, ANIM_FIRE);
		setStrip(STRIP_SIGNAL, ANIM_FIRE);
	}

	public void initDefaultCommand() {
	}

	public static void setStrip(String stripName, String animationName) {
		table.putString(stripName, animationName);
	}

	public void setValue(String stripName, double value) {
		table.putNumber(stripName + ".value", value);
	}

	public void teleopMode() {

		String allianceColor = getAllianceColor();

		range = Robot.gearChute.getRangeFinderDistance();

		if (isCelebrateMode) {
			setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_BACK, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_FRONT, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_BOTTOM, Lights.ANIM_EXPLODE);
			return;
		}
		setValue(STRIP_SIGNAL, range);

		if (Robot.climber.isRunning()) {
			setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_BACK, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_FRONT, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_BOTTOM, Lights.ANIM_EXPLODING_R_W_B);
		} else {
			if (Robot.vision.isLightRingOn()) {
				if (Robot.vision.isTargetVisible()) {
					if (range <= 60) {
						setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_RANGE);
					}
				} else {
					setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_FAIL);
				}
			}
			if (Robot.gearChute.isGearInChute()) {
				setStrip(Lights.STRIP_CHASSIS_BACK, Lights.ANIM_SUCCESS);
			} else {
				setStrip(Lights.STRIP_CHASSIS_BACK, Lights.ANIM_FAIL);
			}
			if (!Robot.acquisition.isNotRunning()) {
				if (Robot.acquisition.isRunningForward()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT, Lights.ANIM_SWEEPERFORWARDS);
				}
				if (Robot.acquisition.isRunningBackward()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT, Lights.ANIM_SWEEPERBACKWARDS);
				}
			} else {
				if (Robot.hopper.isFloorHigh()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT, Lights.ANIM_HIGH);
				}
				if (Robot.hopper.isFloorLow()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT, Lights.ANIM_LOW);
				}
				if (Robot.hopper.isGoingDown()) {

				}
				if (Robot.hopper.isGoingUp()) {

				}
			}
		}
	}

	public void autonomousMode() {
		setStrip(STRIP_CHASSIS_BOTTOM, ANIM_IGNITE);
	}

	public void disabledMode() {
		String anim = getAllianceColor();
		setStrip(Lights.STRIP_SIGNAL, anim);
		setStrip(Lights.STRIP_CHASSIS_BACK, anim);
		setStrip(Lights.STRIP_CHASSIS_FRONT, anim);
		setStrip(Lights.STRIP_CHASSIS_BOTTOM, anim);
	}

	public void celebrateMode(boolean celebrate) {
		isCelebrateMode = celebrate;
	}

	protected String getAllianceColor() {
		if (DriverStation.getInstance().getAlliance() == DriverStation.Alliance.Blue) {
			return Lights.ANIM_PULSING_BLUE;
		} else {
			return Lights.ANIM_PULSING_RED;
		}
	}

	// Constants for pixel strips
	public static final String STRIP_CHASSIS_FRONT = "strip_chassis_front";
	public static final String STRIP_CHASSIS_BACK = "strip_chassis_back";
	public static final String STRIP_CHASSIS_BOTTOM = "strip_chassis_bottom";
	public static final String STRIP_SIGNAL = "strip_signal";

	// Constants for animations
	public static final String ANIM_PULSING_GREEN = "ANIM_PULSING_GREEN";
	public static final String ANIM_PULSING_RED = "ANIM_PULSING_RED";
	public static final String ANIM_PULSING_BLUE = "ANIM_PULSING_BLUE";
	public static final String ANIM_MOVING_BLUE = "ANIM_MOVING_BLUE";
	public static final String ANIM_EXPLODING_R_W_B = "ANIM_EXPLODING_R_W_B";
	public static final String ANIM_FIRE = "ANIM_FIRE";
	public static final String ANIM_CRAZY = "ANIM_CRAZY";
	public static final String ANIM_BINARY = "ANIM_BINARY";
	public static final String ANIM_BULB = "ANIM_BULB";
	public static final String ANIM_CATERPILLAR = "ANIM_CATERPILLAR";<commit_msg>Added 3 new light strips<commit_after>package org.firebears.subsystems;

import org.firebears.Robot;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.networktables.NetworkTable;

/**
 * Subsystem interface to the lights running on the Raspberry Pi. Communicates
 * to the pi through the Network Tables.
 */
public class Lights extends Subsystem {

	double range;

	static NetworkTable table;
	boolean isCelebrateMode = false;

	public Lights() {
		table = NetworkTable.getTable("lights");
		setStrip(STRIP_CHASSIS_FRONT1, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_BACK1, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_BOTTOM1, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_FRONT2, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_BACK2, ANIM_FIRE);
		setStrip(STRIP_CHASSIS_BOTTOM2, ANIM_FIRE);
		setStrip(STRIP_SIGNAL, ANIM_FIRE);
	}

	public void initDefaultCommand() {
	}

	public static void setStrip(String stripName, String animationName) {
		table.putString(stripName, animationName);
	}

	public void setValue(String stripName, double value) {
		table.putNumber(stripName + ".value", value);
	}

	public void teleopMode() {

		String allianceColor = getAllianceColor();

		range = Robot.gearChute.getRangeFinderDistance();

		if (isCelebrateMode) {
			setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_BACK1, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_FRONT1, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_BOTTOM1, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_BACK2, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_FRONT2, Lights.ANIM_EXPLODE);
			setStrip(Lights.STRIP_CHASSIS_BOTTOM2, Lights.ANIM_EXPLODE);
			return;
		}
		setValue(STRIP_SIGNAL, range);

		if (Robot.climber.isRunning()) {
			setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_BACK1, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_FRONT1, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_BOTTOM1, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_BACK2, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_FRONT2, Lights.ANIM_EXPLODING_R_W_B);
			setStrip(Lights.STRIP_CHASSIS_BOTTOM2, Lights.ANIM_EXPLODING_R_W_B);
		} else {
			if (Robot.vision.isLightRingOn()) {
				if (Robot.vision.isTargetVisible()) {
					if (range <= 60) {
						setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_RANGE);
					}
				} else {
					setStrip(Lights.STRIP_SIGNAL, Lights.ANIM_FAIL);
				}
			}
			if (Robot.gearChute.isGearInChute()) {
				setStrip(Lights.STRIP_CHASSIS_BACK1, Lights.ANIM_SUCCESS);
				setStrip(Lights.STRIP_CHASSIS_BACK2, Lights.ANIM_SUCCESS);
			} else {
				setStrip(Lights.STRIP_CHASSIS_BACK1, Lights.ANIM_FAIL);
				setStrip(Lights.STRIP_CHASSIS_BACK2, Lights.ANIM_FAIL);
			}
			if (!Robot.acquisition.isNotRunning()) {
				if (Robot.acquisition.isRunningForward()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT1, Lights.ANIM_SWEEPERFORWARDS);
					setStrip(Lights.STRIP_CHASSIS_FRONT2, Lights.ANIM_SWEEPERFORWARDS);
				}
				if (Robot.acquisition.isRunningBackward()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT1, Lights.ANIM_SWEEPERBACKWARDS);
					setStrip(Lights.STRIP_CHASSIS_FRONT2, Lights.ANIM_SWEEPERBACKWARDS);
				}
			} else {
				if (Robot.hopper.isFloorHigh()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT1, Lights.ANIM_HIGH);
					setStrip(Lights.STRIP_CHASSIS_FRONT2, Lights.ANIM_HIGH);
				}
				if (Robot.hopper.isFloorLow()) {
					setStrip(Lights.STRIP_CHASSIS_FRONT1, Lights.ANIM_LOW);
					setStrip(Lights.STRIP_CHASSIS_FRONT2, Lights.ANIM_LOW);
				}
				if (Robot.hopper.isGoingDown()) {

				}
				if (Robot.hopper.isGoingUp()) {

				}
			}
		}
	}

	public void autonomousMode() {
		setStrip(STRIP_CHASSIS_BOTTOM1, ANIM_IGNITE);
		setStrip(STRIP_CHASSIS_BOTTOM2, ANIM_IGNITE);
	}

	public void disabledMode() {
		String anim = getAllianceColor();
		setStrip(Lights.STRIP_SIGNAL, anim);
		setStrip(Lights.STRIP_CHASSIS_BACK1, anim);
		setStrip(Lights.STRIP_CHASSIS_FRONT1, anim);
		setStrip(Lights.STRIP_CHASSIS_BOTTOM1, anim);
		setStrip(Lights.STRIP_CHASSIS_BACK2, anim);
		setStrip(Lights.STRIP_CHASSIS_FRONT2, anim);
		setStrip(Lights.STRIP_CHASSIS_BOTTOM2, anim);
	}

	public void celebrateMode(boolean celebrate) {
		isCelebrateMode = celebrate;
	}

	protected String getAllianceColor() {
		if (DriverStation.getInstance().getAlliance() == DriverStation.Alliance.Blue) {
			return Lights.ANIM_PULSING_BLUE;
		} else {
			return Lights.ANIM_PULSING_RED;
		}
	}

	// Constants for pixel strips
	public static final String STRIP_CHASSIS_FRONT1 = "strip_chassis_front1";
	public static final String STRIP_CHASSIS_FRONT2 = "strip_chassis_front2";
	public static final String STRIP_CHASSIS_BACK1 = "strip_chassis_back1";
	public static final String STRIP_CHASSIS_BACK2 = "strip_chassis_back2";
	public static final String STRIP_CHASSIS_BOTTOM1 = "strip_chassis_bottom1";
	public static final String STRIP_CHASSIS_BOTTOM2 = "strip_chassis_bottom2";
	public static final String STRIP_SIGNAL = "strip_signal";

	// Constants for animations
	public static final String ANIM_PULSING_GREEN = "ANIM_PULSING_GREEN";
	public static final String ANIM_PULSING_RED = "ANIM_PULSING_RED";
	public static final String ANIM_PULSING_BLUE = "ANIM_PULSING_BLUE";
	public static final String ANIM_MOVING_BLUE = "ANIM_MOVING_BLUE";
	public static final String ANIM_EXPLODING_R_W_B = "ANIM_EXPLODING_R_W_B";
	public static final String ANIM_FIRE = "ANIM_FIRE";
	public static final String ANIM_CRAZY = "ANIM_CRAZY";
	public static final String ANIM_BINARY = "ANIM_BINARY";
	public static final String ANIM_BULB = "ANIM_BULB";
	public static final String ANIM_CATERPILLAR = "ANIM_CATERPILLAR";
{'fraction_non_alphanumeric': 0.0984267453294002, 'fraction_numerical': 0.005408062930186824, 'mean_word_length': 5.270653514180025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2259761', 'n_tokens_mistral': 4389, 'n_tokens_neox': 3988, 'n_words': 609}