Defining commands for creating a scenario instance
To add the Create function to a dashboard, you need to add control objects such as text fields and check boxes to the dashboard to prompt the user for the values of scenario input variables. You need to then create dashboard variables to hold the values of the control objects and the objects bound to the variables via their varToSet property.
You next need to add a control object, such as a push button, to the dashboard to perform the command. In the Define Apama Command dialog, select the command Create scenario instance and use the dashboard variables as the values for the scenario variables.
1. Open the file tutorial-create.rtv by selecting Create Instance in the tutorial main page.
2. Double click on the object labeled Test to display the dashboard in a new window such that the control objects are enabled.. This dashboard displays a summary table of all instances of the tutorial scenario and a form for creating new instances.
3. In the form enter APPL for the Instrument and 100 for the Clip Size and click on the Create button. This will create a new instance of the scenario.. This dashboard has the dashboard variables $instrument and $clipSize defined. The text fields are bound to these such that the variables are set when text is entered in the fields. The actionCommand property for the Create button is set to perform the Create command and use the value of the variables as command parameters.
4. Select the Create button and in the properties panel double click on the actionCommand property.
If the test window is displayed, you need to first close it so that you can select Create button in the Dashboard Builder main window.
Here the command is defined to create an instance of the tutorial scenario on the default correlator. You can see that the values for the scenario input variables Instrument and Clip Size are set to the value of the dashboard variables $instrument and $clipSize.
When creating a scenario instance you must specify a value for each of the scenario input variables. If you do not, you will receive an error when you try to perform the command.