edu.wpi.first.wpilibj
Class Relay

java.lang.Object
  extended by edu.wpi.first.wpilibj.SensorBase
      extended by edu.wpi.first.wpilibj.Relay
All Implemented Interfaces:
IDevice, IDeviceController, FrcBotSimComponent

public class Relay
extends SensorBase
implements IDeviceController

Class for Spike style relay outputs. Relays are intended to be connected to spikes or similar relays. The relay channels controls a pair of pins that are either both off, one on, the other on, or both on. This translates into two spike outputs at 0v, one at 12v and one at 0v, one at 0v and the other at 12v, or two spike outputs at 12V. This allows off, full forward, or full reverse control of motors without variable speed. It also allows the two channels (forward and reverse) to be used independently for something that does not care about voltage polatiry (like a solenoid).


Nested Class Summary
static class Relay.Direction
          The Direction(s) that a relay is configured to operate in.
 class Relay.InvalidValueException
          This class represents errors in trying to set realy values contradictory to the direction to which the relay is set.
static class Relay.Value
          The state to drive a Relay to.
 
Field Summary
 
Fields inherited from class edu.wpi.first.wpilibj.SensorBase
kAnalogChannels, kAnalogModules, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond, n_simProperties
 
Constructor Summary
Relay(int channel)
          Relay constructor given a channel only where the default digital module is used, allowing both directions.
Relay(int moduleNumber, int channel)
          Relay constructor given the module and the channel, allowing both directions.
Relay(int moduileNumber, int channel, Relay.Direction direction)
          Relay constructor given the module and the channel.
Relay(int channel, Relay.Direction direction)
          Relay constructor given a channel only where the default digital module is used.
 
Method Summary
 void free()
          Free the resources used by this object
 void set(Relay.Value value)
          Set the relay state.
 void setDirection(Relay.Direction direction)
          Set the Relay Direction Changes which values the relay can be set to depending on which direction is used Valid inputs are kBothDirections, kForwardOnly, and kReverseOnly
 
Methods inherited from class edu.wpi.first.wpilibj.SensorBase
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, getSimProperties, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Relay

public Relay(int moduileNumber,
             int channel,
             Relay.Direction direction)
Relay constructor given the module and the channel.

Parameters:
moduileNumber - The number of the digital module to use.
channel - The channel number within the module for this relay.
direction - The direction that the Relay object will control.

Relay

public Relay(int channel,
             Relay.Direction direction)
Relay constructor given a channel only where the default digital module is used.

Parameters:
channel - The channel number within the default module for this relay.
direction - The direction that the Relay object will control.

Relay

public Relay(int moduleNumber,
             int channel)
Relay constructor given the module and the channel, allowing both directions.

Parameters:
moduleNumber - The number of the digital module to use.
channel - The channel number within the module for this relay.

Relay

public Relay(int channel)
Relay constructor given a channel only where the default digital module is used, allowing both directions.

Parameters:
channel - The channel number within the default module for this relay.
Method Detail

free

public void free()
Description copied from class: SensorBase
Free the resources used by this object

Overrides:
free in class SensorBase

set

public void set(Relay.Value value)
Set the relay state. Valid values depend on which directions of the relay are controlled by the object. When set to kBothDirections, the relay can be set to any of the four states: 0v-0v, 12v-0v, 0v-12v, 12v-12v When set to kForwardOnly or kReverseOnly, you can specify the constant for the direction or you can simply specify kOff_val and kOn_val. Using only kOff_val and kOn_val is recommended.

Parameters:
value - The state to set the relay.

setDirection

public void setDirection(Relay.Direction direction)
Set the Relay Direction Changes which values the relay can be set to depending on which direction is used Valid inputs are kBothDirections, kForwardOnly, and kReverseOnly

Parameters:
direction - The direction for the relay to operate in