Command
class Command
Commands are typically used to trigger transitions between states. Each controller has a command interface through which actions can be triggered on the controller. Commands are defined globally. However, a controller only knows the commands to which it should respond. The parent-child relationship in the controller tree automatically establishes a command channel for top-down commands.
Create a Command:
- Select the package where the command should be hold
- Open resource assist
- A Command is created by selecting the command element
- In the Wizard, the command name must be set
The command constant is given automatically. It can be changed if necessary.
NOTE: Best practice
Standard commands for all controllers
If it is necessary to assign the same commands to several controllers, it is recommended to define a separate controller interface which contains these shared commands.
This interface can then be integrated (implemented) in the individual controller interfaces.
state = command
In many cases it makes sense that the final state has the same name as the underlying command. This makes it easier to evaluate whether a child controller has reached the desired state. The command can be directly compared with the state of the child controller.
Example:
Parent → Child, Command = EOFF
Child → Parent, State = EOFF
UP implicitly supports this approach. As soon as a command has the same name as a state, both are given the same constant value. In this way, the state of a child controller can be compared directly with the set command.