LLExec Recipes
Overview
The recipe management feature allows you to save in permanent memory, and from there reload, the values of a set of variables previously defined in a recipe structure, or RecipeDef. Once defined one or more RecipeDefs, you can iterate between them, than save or load a set of values with a name.
Configuration
On the resources tab, right click on "Recipes" node and select Add Recipe to add a new RecipeDef.
Then, on the tree, give it a name.
Press on the new node, then in the main window a table of variables will appear.
In the main window click on "Add" and "Remove" buttons to add a row in the table.
Select a row and press "Assign" button to select a variable to add to the set.
Iterating and saving values
You can use a IEC code like the one below to save a set of values.
This kind of code cannot be called from inside a timed task,
if you want to call it from a timed task you must use the functions QueueLoadRequest; or QueueSaveRequest instead.
if DoSaveRic1 then DoSaveRic1 := false; RecipesDefs_First(0); while RecipesDefs_Current(0) do DefHandle := RecipesDefs_GetHandle(0); if Recipes_GetName(DefHandle) = 'RecipeDef1' then Recipes_Save(DefHandle, 'MyInstance'); end_if; RecipesDefs_Next(0); end_while; end_if;
With this code you iterate into the RecipesDefs until you find the one named RecipeDef1.
When the function Recipes_Save is called, all the values of all the variables included in the RecipeDef1 are saved with the name MyInstance.
You can also get a RECIPE_DEFINITION_HANDLE by name using Recipes_GetDefinition.
Iterating and loading values
You can restore a saved set of values using the code below:
if DoLoadRic1 then DoLoadRic1 := false; RecipesDefs_First(0); while RecipesDefs_Current(0) do DefHandle := RecipesDefs_GetHandle(0); if Recipes_GetName(DefHandle) = 'RecipeDef1' then Recipes_Load(DefHandle, 'MyInstance'); end_if; RecipesDefs_Next(0); end_while; end_if;
All the values previously saved with the name MyInstance will be restored.
You can also get a RECIPE_DEFINITION_HANDLE by name using Recipes_GetDefinition.
Other features
Please right click on the other functions in the library, and select Object Properties to see more functions, ie iterate on instances.
If you want to use Recipes in HMI, you have to define the structures and variables in the PLC code with LogicLab.
All the functions to iterate, save and load structures and instances are available under PageLab too,
the will impact on the LogicLab PLC's variables.
If the variable have to be shared with PageLab too, you must map it on a user data block,
then, in LogicLab compile the project with the option Generate EXP file.
In PageLab you have to link the EXP file in order to see the variables defined in the LogicLab environment.