The method of a new plug-in is created in a library component or a command.
- Methods that are created in a command are usually executed at a specific time by the project engineer.
- Methods that are created in a library component are executed after the end of the instantiation.
Creating a method in a command
For the example the method is created in the Mechatronic.Actions.IncrementValueCommand command. This name was specified during the registration of the native Java method. If the name is to be changed, the new name must be specified for the registration (see Registering the plug-in method).
This is how the command is created (the library and unit is required):
- Mark the unit in which the new SequenceSelectionAction is created (here Actions).
- Select New > Object... from the popup menu.
- Navigate the selection dialog to Object > Command.
- Confirm with [Finish].
- Enter a name for the new command (here IncrementValueCommand).
- Open the Method tab.
- By clicking Add, add a new method to the list of methods..
- Specify the name of the method (here execute, this name has been specified for the registration of the method, see Registering the plug-in method).
- Select the Native language type.
- If applicable, mark the Static option.
- Add the arguments that are to be passed to the method and assign the respective type (here obj with the type Engineering.Object. This type has been specified for the registration, see Registering the plug-in method).
Creating SequenceSelectionAction for starting the command
An action is required, for example SequenceSelectionAction, to be able to execute the new command. This can be started from the popup menu of a component.
This is how the SequenceSelectionAction is created:
- Mark the unit in which the new SequenceSelectionAction is created (here Actions).
- Select New > Object... from the popup menu.
- Navigate the selection dialog to Object > Action > SelectionAction > SequenceSelectionAction.
- Confirm with [Finish].
- Enter a name for the new SequenceSelectionAction (here IncrementValueSelectionAction).
- In the Selected object field, select the project component that owns the length parameter (here Station).
- Select the Visible in projects check box.
- In the Displayed Name field specify a name for the SequenceSelectionAction that is shown in the popup menu of the station (here Increment Value).
- Open the Methods editor page.
- Click .
- To insert the commands in the list, select the following commands one by one:
Object > Command > FrameworkCommand > StartFormulaCacheCommand
Object > Command > IncrementValueCommand
Object > Command > FrameworkCommand > StopFormulaCacheCommand
Object > Command > FrameworkCommand > SaveObjectCommand
- Save the editor.
Subsequently the method can be started by calling up Increment Value from the popup menu of the station.