Package frclib.output

Class FrcRelay

java.lang.Object
edu.wpi.first.wpilibj.MotorSafety
edu.wpi.first.wpilibj.Relay
frclib.output.FrcRelay
All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable, AutoCloseable, TrcExclusiveSubsystem

public class FrcRelay extends edu.wpi.first.wpilibj.Relay implements TrcExclusiveSubsystem
This class implements an FRC relay object extending Relay. It adds the capability of delay firing the relay and also allows firing with a duration at which time, it will automatically turns it off.
  • Nested Class Summary

    Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.Relay

    edu.wpi.first.wpilibj.Relay.Direction, edu.wpi.first.wpilibj.Relay.InvalidValueException, edu.wpi.first.wpilibj.Relay.Value

    Nested classes/interfaces inherited from interface trclib.robotcore.TrcExclusiveSubsystem

    TrcExclusiveSubsystem.OwnershipParams
  • Constructor Summary

    Constructors
    Constructor
    Description
    FrcRelay(String instanceName, int channel, edu.wpi.first.wpilibj.Relay.Direction direction)
    Constructor: Creates an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method cancels a pending operation if any.
    void
    cancel(String owner)
    This method cancels a pending operation if any.
    edu.wpi.first.wpilibj.Relay.Value
    get()
    This method overrides the get method in the Relay class.
    boolean
    This method checks if the relay is in inverted mode.
    void
    set(double delay, edu.wpi.first.wpilibj.Relay.Value value, double duration)
    This method sets the relay to the specified value mode with optional delay and duration.
    void
    set(double delay, edu.wpi.first.wpilibj.Relay.Value value, double duration, TrcEvent completionEvent)
    This method sets the relay to the specified value mode with optional delay and duration.
    void
    set(edu.wpi.first.wpilibj.Relay.Value value)
    This method overrides the set method in the Relay class.
    void
    set(edu.wpi.first.wpilibj.Relay.Value value, double duration)
    This method sets the relay to the specified value mode with optional delay and duration.
    void
    set(edu.wpi.first.wpilibj.Relay.Value value, double duration, TrcEvent completionEvent)
    This method sets the relay to the specified value mode with optional delay and duration.
    void
    set(String owner, double delay, edu.wpi.first.wpilibj.Relay.Value value, double duration, TrcEvent completionEvent)
    This method sets the relay to the specified value mode with optional delay and duration.
    void
    setInverted(boolean inverted)
    This methods sets the relay to inverted mode.
    This method returns the instance name.

    Methods inherited from class edu.wpi.first.wpilibj.Relay

    close, getChannel, getDescription, initSendable, setDirection, stopMotor

    Methods inherited from class edu.wpi.first.wpilibj.MotorSafety

    check, checkMotors, feed, getExpiration, isAlive, isSafetyEnabled, setExpiration, setSafetyEnabled

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FrcRelay

      public FrcRelay(String instanceName, int channel, edu.wpi.first.wpilibj.Relay.Direction direction)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      channel - specifies the relay channel.
      direction - specifies the relay direction modes.
  • Method Details

    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • setInverted

      public void setInverted(boolean inverted)
      This methods sets the relay to inverted mode. When the relay is inverted, setting it OFF will set it to the previous ON mode (could be kOn, kForward or kReverse) and setting it to any ON mode will set it to OFF.
      Parameters:
      inverted - specifies true to invert the channels, false otherwise.
    • isInverted

      public boolean isInverted()
      This method checks if the relay is in inverted mode.
      Returns:
      true if relay is inverted, false otherwise.
    • set

      public void set(edu.wpi.first.wpilibj.Relay.Value value)
      This method overrides the set method in the Relay class. It will observe if the relay is in inverted mode and will act accordingly.
      Overrides:
      set in class edu.wpi.first.wpilibj.Relay
      Parameters:
      value - specifies the value to be set. This will check if the relay is inverted and will change the value accordingly (kOff -> previous ON mode, any ON mode -> kOff).
    • get

      public edu.wpi.first.wpilibj.Relay.Value get()
      This method overrides the get method in the Relay class. It will observe if the relay is in inverted mode and will return the appropriate value accordingly.
      Overrides:
      get in class edu.wpi.first.wpilibj.Relay
    • cancel

      public void cancel(String owner)
      This method cancels a pending operation if any.
      Parameters:
      owner - specifies the ID string of the caller for checking ownership, can be null if caller is not ownership aware.
    • cancel

      public void cancel()
      This method cancels a pending operation if any.
    • set

      public void set(String owner, double delay, edu.wpi.first.wpilibj.Relay.Value value, double duration, TrcEvent completionEvent)
      This method sets the relay to the specified value mode with optional delay and duration.
      Parameters:
      owner - specifies the ID string of the caller for checking ownership, can be null if caller is not ownership aware.
      delay - specifies delay time in seconds, zero if no delay.
      value - specifies the relay value mode to set it to.
      duration - specifies the duration in seconds, zero if no duration. If specified, it will turn the relay to kOff after duration has expired.
      completionEvent - specifies the event to signal when duration has expired, can be null if not provided. If duration is zero, the event will be signaled immediately after setting the value.
    • set

      public void set(double delay, edu.wpi.first.wpilibj.Relay.Value value, double duration, TrcEvent completionEvent)
      This method sets the relay to the specified value mode with optional delay and duration.
      Parameters:
      delay - specifies delay time in seconds, zero if no delay.
      value - specifies the relay value mode to set it to.
      duration - specifies the duration in seconds, zero if no duration. If specified, it will turn the relay to kOff after duration has expired.
      completionEvent - specifies the event to signal when duration has expired, can be null if not provided. If duration is zero, the event will be signaled immediately after setting the value.
    • set

      public void set(edu.wpi.first.wpilibj.Relay.Value value, double duration, TrcEvent completionEvent)
      This method sets the relay to the specified value mode with optional delay and duration.
      Parameters:
      value - specifies the relay value mode to set it to.
      duration - specifies the duration in seconds, zero if no duration. If specified, it will turn the relay to kOff after duration has expired.
      completionEvent - specifies the event to signal when duration has expired, can be null if not provided. If duration is zero, the event will be signaled immediately after setting the value.
    • set

      public void set(double delay, edu.wpi.first.wpilibj.Relay.Value value, double duration)
      This method sets the relay to the specified value mode with optional delay and duration.
      Parameters:
      delay - specifies delay time in seconds, zero if no delay.
      value - specifies the relay value mode to set it to.
      duration - specifies the duration in seconds, zero if no duration. If specified, it will turn the relay to kOff after duration has expired.
    • set

      public void set(edu.wpi.first.wpilibj.Relay.Value value, double duration)
      This method sets the relay to the specified value mode with optional delay and duration.
      Parameters:
      value - specifies the relay value mode to set it to.
      duration - specifies the duration in seconds, zero if no duration. If specified, it will turn the relay to kOff after duration has expired.