Overview
This article explains how to work with NA recipes at runtime.
To learn about NA recipe basics, please read ‘Introduction to Recipes on NA’ and ‘Creating and Using Recipes and Templates on NA’ articles
Recipe Viewer
The NA Series includes a dedicated ‘Recipe Viewer’ object that is able to be used to easily display recipe templates & instances during the runtime. It allows the user to interact with the system recipes in runtime.
There are three available areas within the Recipe Viewer object (all of which can be configured in the property area of Sysmac Studio):
Templates: Shows all appropriate recipe templates (recipe types), configured in Sysmac Studio. The user can select the required recipe template by touching on it in the list.
Recipes: Shows all recipe instances configured for the item selected in the ‘Recipe Template List’. The user can select the required recipe instance by touching on it in the list.
Recipe Data: Shows a list of all ingredients associated with the item selected in the ‘Recipe Instance List’. This includes the name of the ingredient and the value for that ingredient. The user can select a specific ingredient and edit its value using a popup keyboard.
Recipe Viewer Properties
It is possible to customize the appearance of the Recipe Viewer in order to work well on a touch screen. These can all be configured using the properties area of Sysmac Studio:
It is possible to change the default layout of the viewer as well as choose which areas of Recipe Viewer object will be shown. These can all be configured using the properties area of Sysmac Studio:
Other recipe viewer object properties allow to change you things like background colours, column sizes, headlines and many more.
There are no Recipe Viewer properties that include recipe actions (e.g.: ‘transfer to controller’ button). All of these have to be done using basic objects like buttons, and correct VB.NET functions.
Working With Recipes in VB
Besides using the recipe viewer, it is also possible to interact fully with the recipe system using code. The following diagram shows methods/functions keywords, and area of NA recipe system that they affect:
The following functions are available for the user to use within VB:
GetRecipeTemplateNames |
Returns a list of all the recipe template names defined for the current HMI application. |
GetRecipeNames |
Returns a list of all the recipe instance names for the specified recipe template. |
GetRecipeIngredientNames |
Returns a list of all the recipe ingredient names for the specified recipe template. |
SaveRecipe |
Saves the specified recipe instance (in memory) to the specified recipe database file. The database filename is determined by the recipe template name passed. |
SaveRecipeAs |
Copies the specified recipe instance (in memory) and appends it to the end of the recipe database file, using the new recipe instance name specified. The new recipe instance name will be validated to confirm it is unique. An error will be raised if the recipe instance name is not unique and a new recipe instance will not be created. |
SaveAllRecipes |
Saves all recipe instances (in memory) to the specified recipe database file. The database filename is determined by the recipe template name passed. |
AddRecipe |
Appends a new recipe instance to the end of the recipe instance list (in memory) using the specified instance name. The ingredient values will be set to their default values (originally defined when the recipe template was created). The new recipe instance name will be validated to confirm it is unique. An error will be raised if the recipe instance name is not unique and a new recipe instance will not be added. |
DeleteRecipe |
Deletes the specified recipe instance from the specified recipe database file. |
ImportRecipes |
Imports all of the recipe instances, held in the specified file, into the list of recipe instances in memory. Validation on the ingredients names will be performed to ensure they match - if they do not match then no data will be imported and an error will be raised. |
ReadRecipeFromController |
Reads the recipe ingredient values, from the controller variables that are associated with the specified recipe template, and tranfers them to the specified recipe instance in memory. |
WriteRecipeToController |
Writes the recipe ingredient values, from the specified recipe instance (in memory), to the controller variables associated with the specified recipe template. |
GetRecipeIngredients |
Gets a list of the ingredient names, and their associated values, from memory, for the specified recipe template, and writes them into the array variables passed in. |
SetRecipeIngredients |
Using the ingredient names (and associated values) passed in, this function sets the specified recipe instance (in memory), for the specified recipe template, to those values. |
GetRecipeIngredientValue |
Gets the value associated with the specified ingredient name, from memory, for the specified recipe template. |
SetRecipeIngredientValue |
Sets the value associated with the specified ingredient name (in memory) for the specified recipe template. |
GetSelectedRecipeTemplate |
Returns the currently selected recipe template from the specified recipe viewer |
GetSelectedRecipeInstance |
Returns the currently selected recipe instance from the specified recipe viewer |
Note: None of the functions listed above can be called directly from the Action Editor. They can only be used within VB.net code. In addition there are several object methods that can be used to get the selected recipe template/instance e.g. RecipeViewer1.SelectedTemplate