
public class CommandHelper extends Object
@Command(type = Command.CommandType.ACTION, description = "Perform a clear operation", level=Command.NORMAL, autoAck=false)
public void clear(int nClears) {
helper()
.precondition(nClears > 0 && nClears <= 15, "Invalid nClears: %d", nClears)
.precondition(FocalPlaneState.QUIESCENT , FocalPlaneState.NEEDS_CLEAR)
.enterFaultOnException(true)
.action(()-> { subsys.getSequencers().clear(nClears); });
}
Agent.helper()| Modifier and Type | Class and Description |
|---|---|
static class |
CommandHelper.CommandFailedException
Exception thrown if the target of the action method throws an exception.
|
static interface |
CommandHelper.RunnableWithException
An interface similar to Runnable but which allows exceptions to be generated and handled.
|
| Constructor and Description |
|---|
CommandHelper(Agent agent)
Create a new CommandHelper.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
action(Callable<T> callable)
Executes the specified callable if all preconditions were me.
|
void |
action(CommandHelper.RunnableWithException runnable)
Execure the specified runnable if all preconditions were met.Designed to be the last method on the
method chain.
|
CommandHelper |
duration(Duration duration)
Set the duration for the command
|
CommandHelper |
enterFaultOnException(boolean enterFault)
Controls whether exceptions should be thrown back to caller, or whether
the should cause the subsystem to entry fault state
|
CommandHelper |
precondition(boolean ok)
A simple precondition.
|
CommandHelper |
precondition(boolean ok,
String reason,
Object... args)
A precondition with a reason.
|
CommandHelper |
precondition(Enum... states)
A precondition with one of more states.
|
public CommandHelper(Agent agent)
Agent.helper().agent - The agent associated with this command helper.public CommandHelper precondition(boolean ok)
ok - If false command will not proceedpublic CommandHelper precondition(boolean ok, String reason, Object... args)
ok - If false command will not proceedreason - The reason to use if precondition is not metargs - If present then reason is interpreted as a format string, and
args are substituted into the formatpublic CommandHelper precondition(Enum... states)
states - The states to testpublic CommandHelper duration(Duration duration)
duration - The duration for the command, overrides the default
duration provided by any annotation.public CommandHelper enterFaultOnException(boolean enterFault)
enterFault - If true then any exceptions during command
execution will be caught, and the subsystem will be put into fault state.public <T> T action(Callable<T> callable)
T - The return type of the callablecallable - The callable to callpublic void action(CommandHelper.RunnableWithException runnable)
runnable - The runnable to runCopyright © 2020 LSST. All rights reserved.