How to create a new recipe from standard switch or XBT GK function key



Goals and Symptoms

In Vijeo-Designer, the recommended solution to create new recipes during Runtime is to use the toolchest object CreateNew. However, this object cannot be associated to XBT GK function keys. Hereafter is explained how to create new recipes in standard switches or in XBT GK function keys without using the toolchest object CreateNew.

Causes and Fixes

Principle: inside a recipe group, a new recipe is created when a Save operation is performed while the Recipe Number variable is set to an unexisting value. For example: consider a recipe group with 3 recipes: recipe 1, recipe 2 and recipe 3: if the Recipe Number is set to 4 and a Save operation is performed, then a new recipe is created. This principle can be used to create new recipes from a switch or an XBT GK function key.

In attachment you can find a simple demo project where the method described above is used in the F1 function key of an XBT GK and in a switch.

Project configuration:
1/ Create a recipe group containing for example 3 recipes of 3 ingredients.
2/ Create an integer internal variable NumberOfRecipes_Group1: it will be used to know how many recipes already exist in recipe group
3/ Set the initial value of NumberOfRecipes_Group1 to the initial number of recipes in Recip Group = 3

When F1 key or switch is pressed, the number of recipes inside the recipe group is incremented, in order to set the number of recipes inside the group to an unexisting value. Then a Save operation is performed.

Sequence used in F1 key and in switch:
1/ Set Recipe group number:
Set 1 to _RecipeControlDefault.RecipeGroupNumber
2/ Increment the counter of recipes inside this group:
Add 1 to NumberOfRecipes_Group1
3/ Set Recipe number with the incremented value:
Set NumberOfRecipes_Group1 to _RecipeControlDefault.RecipeNumber
4/ Save recipe:
Set 8 to _RecipeControlDefault.Operation

In this project, the number of recipes inside the Recipe Group is simply incremented. This makes the process work But when user deletes a recipe, the index of this recipe is never reassigned. As an evolution, it is possible to have a more precise control of the variable NumberOfRecipes_Group1, allowing to reassign any available Recipe index.


(Removed File URL: 201626_E50A/Demo_Customized_CreateNew.zip)(Removed Image URL: /PubResEXPORT.nsf/2b87ee90be777fc085257c28006ee4ef/422889e5658b6d1ac12576e300421fb7/fl_block_5/0.578?OpenElement&FieldElemFormat=gif)

Legacy KB System (APS) Data: RESL201626 V1.0, Originally authored by ArGr on 03/11/2010, Last Edited by ArGr on 03/11/2010
Related ranges: Magelis XBT GT, Magelis XBT GK, Vijeo Designer