Package trclib.subsystem
Class TrcPidConveyor
java.lang.Object
trclib.subsystem.TrcPidConveyor
- All Implemented Interfaces:
TrcExclusiveSubsystem
This class implements a platform independent conveyor subsystem. It contains a motor and optionally an entry
and an exit sensor that detects if the an object has entered or exited the conveyor. It also supports exclusive
subsystem access by implementing TrcExclusiveSubsystem. This enables the conveyor subsystem to be aware of multiple
callers' access to the subsystem. While one caller starts the conveyor for an operation, nobody can access it until
the previous caller is done with the operation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This class contains all the parameters related to the conveyor.Nested classes/interfaces inherited from interface trclib.robotcore.TrcExclusiveSubsystem
TrcExclusiveSubsystem.OwnershipParams
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TrcEvent
private final TrcDigitalInput
private final TrcTriggerDigitalInput
private TrcEvent
private final TrcDigitalInput
private final TrcTriggerDigitalInput
final TrcMotor
private int
private final TrcPidConveyor.Parameters
-
Constructor Summary
ConstructorsConstructorDescriptionTrcPidConveyor
(String instanceName, TrcMotor motor, TrcDigitalInput entrySensor, TrcDigitalInput exitSensor, TrcPidConveyor.Parameters params) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
advance()
This method advances the conveyor by the one object unit.void
backup()
This method backs up the conveyor by the one object unit.int
This method returns the number of objects in the conveyor.boolean
This method returns the sensor state read from the digital sensor.boolean
This method returns the sensor state read from the digital sensor.void
move
(int units) This method advances or backs up the conveyor by the number of object units.void
This method advances or backs up the conveyor by the number of object units.void
This method advances or backs up the conveyor by the number of object units.private void
onEntryEvent
(Object context) This method is called when the entry sensor is triggered.private void
onExitEvent
(Object context) This method is called when the exit sensor is triggered.void
registerEntryEvent
(TrcEvent event) This method registers an event to be signaled when the entry sensor is triggered.void
registerExitEvent
(TrcEvent event) This method registers an event to be signaled when the exit sensor is triggered.void
This methods sets the conveyor motor power.void
setPreloadedObjects
(int num) This method sets the number of preloaded objects in the conveyor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface trclib.robotcore.TrcExclusiveSubsystem
acquireExclusiveAccess, acquireOwnership, cancelExclusiveAccess, getCurrentOwner, hasOwnership, releaseExclusiveAccess, releaseOwnership, validateOwnership
-
Field Details
-
motor
-
entrySensor
-
exitSensor
-
params
-
entryTrigger
-
exitTrigger
-
entryEvent
-
exitEvent
-
numObjects
private int numObjects
-
-
Constructor Details
-
TrcPidConveyor
public TrcPidConveyor(String instanceName, TrcMotor motor, TrcDigitalInput entrySensor, TrcDigitalInput exitSensor, TrcPidConveyor.Parameters params) Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the hardware name.motor
- specifies the motor object.entrySensor
- specifies the sensor object for the conveyor entry.exitSensor
- specifies the sensor object for the conveyor exit.params
- specifies the parameters object.
-
-
Method Details
-
getNumObjects
public int getNumObjects()This method returns the number of objects in the conveyor. Note: Conveyor can only keep track of the number of objects if it has entry and exit sensors. Otherwise, the number of objects returned will not be correct.- Returns:
- number of objects in the conveyor.
-
setPreloadedObjects
public void setPreloadedObjects(int num) This method sets the number of preloaded objects in the conveyor.- Parameters:
num
- specifies the number of preloaded objects in the conveyor.
-
registerEntryEvent
This method registers an event to be signaled when the entry sensor is triggered.- Parameters:
event
- specifies event to signal when an object has entered the conveyor.
-
registerExitEvent
This method registers an event to be signaled when the exit sensor is triggered.- Parameters:
event
- specifies event to signal when an object has exited the conveyor.
-
isEntrySensorActive
public boolean isEntrySensorActive()This method returns the sensor state read from the digital sensor.- Returns:
- digital sensor state.
-
isExitSensorActive
public boolean isExitSensorActive()This method returns the sensor state read from the digital sensor.- Returns:
- digital sensor state.
-
setPower
This methods sets the conveyor motor power. This is useful if the entry sensor is positioned a little way back such that the conveyor motor needs to be ON and transport the object further in or out.- Parameters:
owner
- specifies the owner ID to check if the caller has ownership of the conveyor.power
- specifies the conveyor motor power.
-
move
This method advances or backs up the conveyor by the number of object units.- Parameters:
owner
- specifies the owner ID to check if the caller has ownership of the conveyor.units
- specifies the number of object units to advance or negative number to back up.event
- specifies the event to signal when done, can be null if not provided.
-
move
This method advances or backs up the conveyor by the number of object units.- Parameters:
units
- specifies the number of object units to advance or negative number to back up.event
- specifies the event to signal when done, can be null if not provided.
-
move
public void move(int units) This method advances or backs up the conveyor by the number of object units.- Parameters:
units
- specifies the number of object units to advance or negative number to back up.
-
advance
public void advance()This method advances the conveyor by the one object unit. -
backup
public void backup()This method backs up the conveyor by the one object unit. -
onEntryEvent
This method is called when the entry sensor is triggered.- Parameters:
context
- specifies true if an object has activated the sensor, false if the object has deactivated it.
-
onExitEvent
This method is called when the exit sensor is triggered.- Parameters:
context
- specifies true if an object has activated the sensor, false if the object has deactivated it.
-