"

2013 FRC Java API

"

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:
LiveWindowSendable, IDevice, IDeviceController, Sendable

public class Relay
extends SensorBase
implements IDeviceController, LiveWindowSendable

Class for VEX Robotics 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 polarity (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 relay 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
 
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 moduleNumber, 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
 Relay.Value get()
          Get the Relay State Gets the current state of the relay.
 String getSmartDashboardType()
           
 ITable getTable()
          
 void initTable(ITable subtable)
          Initializes a table for this sendable 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
 void startLiveWindowMode()
          Start having this sendable object automatically respond to value changes reflect the value on the table.
 void stopLiveWindowMode()
          Stop having this sendable object automatically respond to value changes.
 void updateTable()
          Update the table for this sendable object with the latest values.
 
Methods inherited from class edu.wpi.first.wpilibj.SensorBase
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Relay

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

Parameters:
moduleNumber - 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.

get

public Relay.Value get()
Get the Relay State Gets the current state of the relay. When set to kForwardOnly or kReverseOnly, value is returned as kOn/kOff not kForward/kReverse (per the recommendation in Set)

Returns:
The current state of the relay as a Relay::Value

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

getSmartDashboardType

public String getSmartDashboardType()
Specified by:
getSmartDashboardType in interface Sendable
Returns:
the string representation of the named data type that will be used by the smart dashboard for this sendable

initTable

public void initTable(ITable subtable)
Initializes a table for this sendable object.

Specified by:
initTable in interface Sendable
Parameters:
subtable - The table to put the values in.

getTable

public ITable getTable()

Specified by:
getTable in interface Sendable
Returns:
the table that is currently associated with the sendable

updateTable

public void updateTable()
Update the table for this sendable object with the latest values.

Specified by:
updateTable in interface LiveWindowSendable

startLiveWindowMode

public void startLiveWindowMode()
Start having this sendable object automatically respond to value changes reflect the value on the table.

Specified by:
startLiveWindowMode in interface LiveWindowSendable

stopLiveWindowMode

public void stopLiveWindowMode()
Stop having this sendable object automatically respond to value changes.

Specified by:
stopLiveWindowMode in interface LiveWindowSendable

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"