Add periodic method to subsystems (#528)

Fixes #526.
This commit is contained in:
Austin Shalit
2017-07-02 23:02:41 -07:00
committed by Peter Johnson
parent 2da26c0579
commit aa0a874ad0
5 changed files with 27 additions and 0 deletions

View File

@@ -198,6 +198,13 @@ public class Scheduler implements NamedSendable {
((ButtonScheduler) m_buttons.elementAt(i)).execute();
}
}
// Call every subsystem's periodic method
Enumeration subsystems = m_subsystems.getElements();
while (subsystems.hasMoreElements()) {
((Subsystem) subsystems.nextElement()).periodic();
}
// Loop through the commands
LinkedListElement element = m_firstCommand;
while (element != null) {

View File

@@ -73,6 +73,13 @@ public abstract class Subsystem implements NamedSendable {
*/
protected abstract void initDefaultCommand();
/**
* When the run method of the scheduler is called this method will be called.
*/
public void periodic() {
// Override me!
}
/**
* Sets the default command. If this is not called or is called with null, then there will be no
* default command for the subsystem.