001/**
002 * Copyright 2024 The Space Cookies : Girl Scout Troop #62868 and FRC Team #1868
003 * Open Source Software; you may modify and/or share it under the terms of
004 * the 3-Clause BSD License found in the root directory of this project.
005 */
006
007package tagalong.subsystems;
008
009import edu.wpi.first.wpilibj2.command.SubsystemBase;
010
011/**
012 * Base class for all Tagalong Subsystems containing multiple microsystems
013 */
014public class TagalongSubsystemBase extends SubsystemBase {
015  /**
016   * True if the subsystem is disabled in the config files
017   */
018  public boolean _configuredDisable;
019  /* -------- Subsystem specific disablement -------- */
020  /**
021   * Disablement state, for dynamic disablement configured on the fly by robot code
022   */
023  protected boolean _isSubsystemDisabled = true;
024
025  /**
026   * Constructs a generic subsystem with universal features
027   *
028   * @param conf Subsystem configuration containing all microsystem confs and any other necessary
029   *     configs
030   */
031  public TagalongSubsystemBase(Object conf) {
032    // In the future we need a more discrete function configuring this
033    _configuredDisable = conf == null;
034    _isSubsystemDisabled = _configuredDisable;
035
036    // FUTURE DEV: Inject this here rather than robot builder
037    // configShuffleboard();
038  }
039
040  /**
041   * @param disable
042   *                Sets the subsystemDisabled and configuredDisable variables to
043   *                disable.
044   */
045  public void setDisabled(boolean disable) {
046    _isSubsystemDisabled = disable;
047    _configuredDisable = disable;
048  }
049
050  /**
051   * @return True if the subsystem is disabled
052   */
053  public boolean isSubsystemDisabled() {
054    return _isSubsystemDisabled;
055  }
056
057  /* -------- IO and config functions -------- */
058  /**
059   * Updates shuffleboard
060   */
061  protected void updateShuffleboard() {}
062
063  // FUTURE DEV: Remove, or at the very least do not require as a registered function that
064  // incorporates microsystem config shuffleboard values configShuffleboard();
065  /**
066   * Called once on robot start to configure all shuffleboard entries.
067   */
068  protected void configShuffleboard() {}
069
070  /**
071   * Triggers whenever the robot is autonomous or teleop enabled.
072   * Calls all the onEnable functions of the contained Tagalong Microsystems and
073   * takes any subsystem
074   * specific actions.
075   */
076  public void onEnable() {}
077
078  /**
079   * Triggers whenever the robot is disabled.
080   * Calls all the onDisable functions of the contained Tagalong Microsystems and
081   * takes any subsystem
082   * specific actions.
083   */
084  public void onDisable() {}
085
086  /**
087   * Called once on robot boot to initialize simulations.
088   * Calls all the simulationInit functions of the contained Tagalong Microsystems
089   * and takes any subsystem specific actions.
090   */
091  public void simulationInit() {}
092
093  /**
094   *
095   * Called periodically on robot to update simulations.
096   * Calls all the simulationInit functions of the contained Tagalong Microsystems
097   * and takes any
098   * subsystem specific actions.
099   */
100  public void simulationPeriodic() {}
101
102  /**
103   * Called once on robot to configure motors.
104   * Calls all the configMotor() functions of the contained Tagalong Microsystems
105   * and takes any
106   * subsystem specific actions.
107   */
108  public void configMotor() {}
109
110  /**
111   * @return Subsystem status -- True if subsystem is not disabled
112   */
113  public boolean checkInitStatus() {
114    return !_isSubsystemDisabled;
115  }
116}