public class Relay extends SensorBase implements MotorSafety, LiveWindowSendable
| Modifier and Type | Class and Description | 
|---|---|
| static class  | Relay.DirectionThe Direction(s) that a relay is configured to operate in. | 
| class  | Relay.InvalidValueExceptionThis class represents errors in trying to set relay values contradictory to the direction to
 which the relay is set. | 
| static class  | Relay.ValueThe state to drive a Relay to. | 
kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPCMModules, kPDPChannels, kPDPModules, kPwmChannels, kRelayChannels, kSolenoidChannels, kSystemClockTicksPerMicrosecondDEFAULT_SAFETY_EXPIRATION| Constructor and Description | 
|---|
| Relay(int channel)Relay constructor given a channel, allowing both directions. | 
| Relay(int channel,
     Relay.Direction direction)Relay constructor given a channel. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | free()Free the resources used by this object. | 
| Relay.Value | get()Get the Relay State. | 
| int | getChannel()Get the channel number. | 
| java.lang.String | getDescription() | 
| double | getExpiration() | 
| java.lang.String | getSmartDashboardType()The string representation of the named data type that will be used by the smart dashboard for
 this  Sendable. | 
| ITable | getTable()The table that is associated with this  Sendable. | 
| void | initTable(ITable subtable)Initializes a table for this  Sendableobject. | 
| boolean | isAlive() | 
| boolean | isSafetyEnabled() | 
| void | set(Relay.Value value)Set the relay state. | 
| void | setDirection(Relay.Direction direction)Set the Relay Direction. | 
| void | setExpiration(double timeout) | 
| void | setSafetyEnabled(boolean enabled) | 
| 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 | stopMotor() | 
| void | updateTable()Update the table for this sendable object with the latest values. | 
checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPDPModule, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModulepublic Relay(int channel, Relay.Direction direction)
channel - The channel number for this relay (0 - 3).direction - The direction that the Relay object will control.public Relay(int channel)
channel - The channel number for this relay (0 - 3).public void free()
SensorBasefree in class SensorBasepublic void set(Relay.Value value)
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.
value - The state to set the relay.public Relay.Value get()
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)
public int getChannel()
public void setExpiration(double timeout)
setExpiration in interface MotorSafetypublic double getExpiration()
getExpiration in interface MotorSafetypublic boolean isAlive()
isAlive in interface MotorSafetypublic void stopMotor()
stopMotor in interface MotorSafetypublic boolean isSafetyEnabled()
isSafetyEnabled in interface MotorSafetypublic void setSafetyEnabled(boolean enabled)
setSafetyEnabled in interface MotorSafetypublic java.lang.String getDescription()
getDescription in interface MotorSafetypublic void setDirection(Relay.Direction direction)
Changes which values the relay can be set to depending on which direction is used
Valid inputs are kBothDirections, kForwardOnly, and kReverseOnly
direction - The direction for the relay to operate inpublic java.lang.String getSmartDashboardType()
SendableSendable.getSmartDashboardType in interface SendableSendable.public void initTable(ITable subtable)
SendableSendable object.public ITable getTable()
SendableSendable.public void updateTable()
LiveWindowSendableupdateTable in interface LiveWindowSendablepublic void startLiveWindowMode()
LiveWindowSendablestartLiveWindowMode in interface LiveWindowSendablepublic void stopLiveWindowMode()
LiveWindowSendablestopLiveWindowMode in interface LiveWindowSendable