mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
committed by
Peter Johnson
parent
2da26c0579
commit
aa0a874ad0
@@ -28,6 +28,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
|
||||
Command* GetDefaultCommand();
|
||||
void SetCurrentCommand(Command* command);
|
||||
Command* GetCurrentCommand() const;
|
||||
virtual void Periodic();
|
||||
virtual void InitDefaultCommand();
|
||||
|
||||
private:
|
||||
|
||||
@@ -121,6 +121,13 @@ void Scheduler::Run() {
|
||||
}
|
||||
}
|
||||
|
||||
// Call every subsystem's periodic method
|
||||
for (auto subsystemIter = m_subsystems.begin();
|
||||
subsystemIter != m_subsystems.end(); subsystemIter++) {
|
||||
Subsystem* subsystem = *subsystemIter;
|
||||
subsystem->Periodic();
|
||||
}
|
||||
|
||||
m_runningCommandsChanged = false;
|
||||
|
||||
// Loop through the commands
|
||||
|
||||
@@ -104,6 +104,11 @@ void Subsystem::SetCurrentCommand(Command* command) {
|
||||
*/
|
||||
Command* Subsystem::GetCurrentCommand() const { return m_currentCommand; }
|
||||
|
||||
/**
|
||||
* When the run method of the scheduler is called this method will be called.
|
||||
*/
|
||||
void Subsystem::Periodic() {}
|
||||
|
||||
/**
|
||||
* Call this to alert Subsystem that the current command is actually the
|
||||
* command.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user