public class HardwareInterface
extends java.lang.Object
implements java.lang.Runnable
Constructor and Description |
---|
HardwareInterface()
Construct a hardware interface with no debugging messages.
|
HardwareInterface(boolean debug)
Construct a hardware interface with the indicated debugging flag.
|
Modifier and Type | Method and Description |
---|---|
void |
analogInputChanged(Event event)
Callback for a change event in one of the analog inputs.
|
void |
digitalInputChanged(Event event)
Callback for a change event in one of the digital inputs.
|
void |
digitalOutputChanged(Event event)
Callback for a change event in one of the digital outputs.
|
InterfaceKitPhidget |
getInterfaceBoard()
Capture the interface board if present.
|
boolean |
getOutputState(int id)
Determine the state of a digital output.
|
RFIDPhidget |
getRFIDBoard()
Capture the RFID board if present.
|
double |
getServoAcceleration(int index)
Determine the acceleration of a given servo motor.
|
double |
getServoAccelerationMax(int index)
Determine the maximum acceleration that a servo will accept.
|
double |
getServoAccelerationMin(int index)
Determine the minimum acceleration that a servo will accept.
|
AdvancedServoPhidget |
getServoBoard()
Capture the servo motor board if present.
|
double |
getServoCurrent(int index)
Determine the current usage of a given servo motor in Amps.
|
double |
getServoPosition(int index)
Set the position of a servo motor.
|
double |
getServoPositionMax(int index)
Determine the maximum position that a servo will accept.
|
double |
getServoPositionMin(int index)
Determine the minimum position that a servo will accept.
|
double |
getServoVelocity(int index)
Determine the velocity of a given servo motor in Amps.
|
void |
rfidOutputChanged(Event event)
Callback for a change event in the RFID output.
|
void |
run()
The timer thread.
|
void |
servoCurrentChanged(Event event)
Callback for a change event in a servo current.
|
void |
servoPositionChanged(Event event)
Callback for a change event in a servo position.
|
void |
servoVelocityChanged(Event event)
Callback for a change event in a servo velocity.
|
void |
setAntennaOn(boolean state)
Set the state of the antenna of the RFID board.
|
void |
setLED(boolean state)
Set the state of the LED on the RFID board.
|
void |
setOutputState(int id,
boolean value)
Set the state of a digital output.
|
void |
setServoAcceleration(int index,
double acceleration)
Set the acceleration of a servo motor.
|
void |
setServoEngageState(int index,
boolean state)
Engage or disengage a servo motor.
|
void |
setServoPosition(int index,
double position)
Set the position of a servo motor.
|
void |
setTimer(long delay)
Set the timer to fire an event, thereby calling
timerCallback() ,
after the indicated delay. |
void |
startMonitoring()
Start listening to the attached hardware and trigger corresponding events.
|
void |
stopMonitoring()
Stop listening to the attached hardware.
|
void |
tagGained(Event event)
Callback for an RFID tag gain event.
|
void |
tagLost(Event event)
Callback for an RFID tag loss event.
|
void |
timerCallback()
Callback for the timer event.
|
public HardwareInterface()
public HardwareInterface(boolean debug)
debug
- turn debugging messages on (true) or off (false)public final void setOutputState(int id, boolean value)
id
- the index number of the digit output to set.value
- true to activate the output, false otherwise.public final boolean getOutputState(int id)
id
- the index number of the digit output to get.value
- true to activate the output, false otherwise.public final void setAntennaOn(boolean state)
state
- true to activate the antenna, false otherwise.public final void setLED(boolean state)
state
- true to turn the LED on, false otherwise.public final void setServoPosition(int index, double position)
index
- the motor index.position
- the desired position in the range allowed by the motor, see
getServoPositionMin(int)
and
getServoPositionMax(int)
.public final double getServoPosition(int index)
index
- the motor index.public final double getServoPositionMin(int index)
index
- the motor index.public final double getServoPositionMax(int index)
index
- the motor index.public final void setServoAcceleration(int index, double acceleration)
index
- the motor index.acceleration
- the desired acceleration in the range allowed by the motor, see
getServoAccelerationMin(int)
and
getServoAccelerationMax(int)
.public final double getServoAccelerationMin(int index)
index
- the motor index.public final double getServoAccelerationMax(int index)
index
- the motor index.public final double getServoAcceleration(int index)
index
- the motor index.public final double getServoCurrent(int index)
index
- the motor index.public final double getServoVelocity(int index)
index
- the motor index.public final void setServoEngageState(int index, boolean state)
setServoPosition(int, double)
). Hence, this method is intended
for changing the engage state without changing the position.index
- the motor index.state
- true to engage, false to disengage.public void digitalOutputChanged(Event event)
event
- the event that occurredpublic void analogInputChanged(Event event)
event
- the event that occurredpublic void digitalInputChanged(Event event)
event
- the event that occurredpublic void servoPositionChanged(Event event)
event
- the event that occurredpublic void servoVelocityChanged(Event event)
event
- the event that occurredpublic void servoCurrentChanged(Event event)
event
- the event that occurredpublic void tagGained(Event event)
event
- the event that occurredpublic void tagLost(Event event)
event
- the event that occurredpublic void rfidOutputChanged(Event event)
event
- the event that occurredpublic void timerCallback()
public final InterfaceKitPhidget getInterfaceBoard()
public final AdvancedServoPhidget getServoBoard()
public final RFIDPhidget getRFIDBoard()
public final void setTimer(long delay)
timerCallback()
,
after the indicated delay. The event will be fired only once, so if
periodic firing is needed then call this method in the callback handler.
Note that if this method is re-invoked before the indicated delay
passes then the previous invocation is cancelled.delay
- the number of milliseconds between now and the firing
of the timer event.java.lang.RuntimeException
- if the delay is not positive.public final void run()
run
in interface java.lang.Runnable
public final void startMonitoring()
stopMonitoring()
method is called.public final void stopMonitoring()