public final class Relay extends Interface implements Module
| Modifier and Type | Class and Description |
|---|---|
static class |
Relay.RelayChannel
Enum representation of Relay channels on the RIO
|
static class |
Relay.RelayDirection
Set the direction the relay can go in
|
static class |
Relay.RelayValue
Set the state of the relay
|
Interface.InterfaceType| Modifier and Type | Field and Description |
|---|---|
private Relay.RelayChannel |
m_channel
The Relay Channel this Relay is operating on.
|
protected java.lang.String |
m_description |
private Relay.RelayDirection |
m_direction
The Direction this Relay is allowed to operate in
|
private boolean |
m_disabled
The disabled state.
|
private java.nio.ByteBuffer |
m_port
The The RoboRIO port identifier.
|
private static byte |
RELAY_OFF |
private static byte |
RELAY_ON |
private static boolean[] |
USED_CHANNELS
Keep track of already used channels.
|
m_ifaceType, MAX_ANALOG_IN_CHANNELS, MAX_ANALOG_OUT_CHANNELS, MAX_DIGITAL_CHANNELS, MAX_PWM_CHANNELS, MAX_RELAY_CHANNELS| Constructor and Description |
|---|
Relay(Relay.RelayChannel channel)
Relay constructor given a channel, allowing both directions.
|
Relay(Relay.RelayChannel channel,
Relay.RelayDirection dir)
Relay constructor given a channel.
|
Relay(Relay.RelayChannel channel,
Relay.RelayDirection dir,
java.lang.String desc)
Relay constructor given a channel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
disableModule()
Disable the module
|
void |
enableModule()
Enable the module
|
void |
free()
Free the Relay channel.
|
Relay.RelayValue |
get()
Get the Relay State
Gets the current state of the relay.
|
Relay.RelayChannel |
getChannel()
The channel this Relay is operating on.
|
java.lang.String |
getChannelName()
The channel this Relay is operating on, in string form.
|
int |
getChannelNumber()
The channel this Relay is operating on, in integer form.
|
boolean |
getModuleEnabled() |
void |
set(boolean value) |
void |
set(Relay.RelayValue value)
Set the relay state.
|
void |
setDirection(Relay.RelayDirection dir)
Set the Relay Direction
Changes which values the relay can be set to depending on which direction
is used
Valid inputs are FORWARD, REVERSE, and BOTH
|
allocateMXPPin, checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPWMChannel, checkRelayChannel, freeMXPPin, getInterfaceTypeprivate static final byte RELAY_ON
private static final byte RELAY_OFF
protected final java.lang.String m_description
private final java.nio.ByteBuffer m_port
private Relay.RelayChannel m_channel
private Relay.RelayDirection m_direction
private boolean m_disabled
private static final boolean[] USED_CHANNELS
public Relay(Relay.RelayChannel channel)
channel - The Relay.RelayChannel for this relay.public Relay(Relay.RelayChannel channel, Relay.RelayDirection dir)
channel - The Relay.RelayChannel for this relay.dir - The direction that the Relay object will control.public Relay(Relay.RelayChannel channel, Relay.RelayDirection dir, java.lang.String desc)
channel - The Relay.RelayChannel for this relay.dir - The direction that the Relay object will control.desc - Description of this relay for debugging, dash-board,
and power monitoring purposespublic void free()
public void set(boolean value)
value - public void set(Relay.RelayValue value)
Relay.RelayDirection.BOTH, the relay can be set to any of the four
states: 0v-0v, 12v-0v, 0v-12v, 12v-12v
When set to FORWARD or REVERSE, you can specify the constant
for the direction or you can simply specify OFF and ON. Using
only OFF and ON is recommended.value - The state to set the relay.public Relay.RelayValue get()
Relay.RelayValuepublic void setDirection(Relay.RelayDirection dir)
dir - The direction for the relay to operate inpublic Relay.RelayChannel getChannel()
Relay.RelayChannel representation of the Relay channelpublic int getChannelNumber()
public java.lang.String getChannelName()
public void enableModule()
enableModule in interface Modulepublic void disableModule()
disableModule in interface Modulepublic boolean getModuleEnabled()
getModuleEnabled in interface Module