RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
Mechanism.java
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5package org.wpilib.command3;
6
7import java.util.List;
8import java.util.function.Consumer;
9import org.wpilib.annotation.NoDiscard;
10import org.wpilib.units.measure.Time;
11
21public interface Mechanism {
31
42 default boolean controllableDuringDisabled() {
43 return false;
44 }
45
52 default String getName() {
53 return getClass().getSimpleName();
54 }
55
68 default void setDefaultCommand(Command defaultCommand) {
69 getRegisteredScheduler().setDefaultCommand(this, defaultCommand);
70 }
71
81
88 default NeedsNameBuilderStage run(Consumer<Coroutine> commandBody) {
89 return new StagedCommandBuilder().requiring(this).executing(commandBody);
90 }
91
100 default NeedsNameBuilderStage runRepeatedly(Runnable loopBody) {
101 return run(
102 coroutine -> {
103 while (true) {
104 loopBody.run();
105 coroutine.yield();
106 }
107 });
108 }
109
120 default Command idle() {
122 }
123
130 default Command idleFor(Time duration) {
131 return idle().withTimeout(duration);
132 }
133
142 @NoDiscard
143 default List<Command> getRunningCommands() {
145 }
146}
static Scheduler getDefault()
Command getDefaultCommandFor(Mechanism mechanism)
List< Command > getRunningCommandsFor(Mechanism mechanism)
void setDefaultCommand(Mechanism mechanism, Command defaultCommand)
default Command withTimeout(Time timeout)
Definition Command.java:228
default NeedsNameBuilderStage run(Consumer< Coroutine > commandBody)
default Command getDefaultCommand()
default NeedsNameBuilderStage runRepeatedly(Runnable loopBody)
default void setDefaultCommand(Command defaultCommand)
default Scheduler getRegisteredScheduler()
default boolean controllableDuringDisabled()
default Command idleFor(Time duration)
default List< Command > getRunningCommands()
NeedsNameBuilderStage withPriority(int priority)