You can manage and use the recipes created in CODESYS by means of a visualization.
For this purpose, the input configuration of a visualization element provides the capability of using the “Execute Command” input action to execute the following commands:
-
“Read Recipe”
-
“Write Recipe”
-
“Load Recipe from File”
-
“Save Recipe in File”
-
“Create Recipe”
-
“Delete Recipe”
For more information, see: ⮫ Dialog:Input Configuration
Example: Loading recipes by means of visualization elements
Requirement: The “Visualization” object is added to the project.
-
Create a recipe according to the instructions in the "Changing Values with Recipes – Creating Recipes" chapter.
Assign the following names:
-
Recipe definition: "Recipes"
-
Recipes: "Recipe1" and "Recipe2"
-
Variables:
iValue1
andiValue2
Type in different variable values of both recipes.
-
-
Open the “Visualization” object in the editor.
-
Drag a “Button” element to the visualization. Label it "Load Recipe 1". You can specify the text by double-clicking the element or in the “Texts Text” property.
-
Click the value field of the “Input configuration”: “OnMouseDown” property.
The “Input Configuration” dialog opens.
-
Select “Execute command” in the left of the left side and click the
button.
The configuration of the “Internal command” opens on the right side of the dialog.
-
Select the “Write Recipe” command from the list box.
-
Click the
button.
The “WriteRecipe” command is added to the list.
-
Specify the first parameter as
Recipes
and the second parameter asRecipe1
. -
Click “OK” to exit the dialog.
-
Drag a second button to the visualization, name it "Load Recipe 2", and repeat steps 4 to 8. For Step 7, specify
Recipe2
as the second parameter. -
Load the program to the controller and start it. Click the “Load Recipe 1” and “Load Recipe 2”, and monitor the variables
iValue1
andiValue2
.
The other recipe commands are assigned to visualization elements in the same way as this example. For a description of the internal commands, see the ⮫ help page of the input configuration.