Library ‘Recipe Management’ - ‘RecipeManCommands’

The methods of the RecipeManCommands function block from the Recipe Management library allow for the programmatic management of recipes.

Attention

The application creates recipe files automatically on the PLC with the names <recipe>.<recipe definition>.txtrecipe. These are used as a buffer when reading and writing recipe variables. The Save recipe changes to recipe files automatically option in the Recipe Manager - General tab affects access to these files.

When the recipe command is called, the application accesses the recipe files internally. This can take a few milliseconds depending on the device type. The calls are not executed in a task with time monitoring or in a predefined time frame (real-time sensitive).

Attention

If the Save recipe changes files automatically option is activated, then the recipes of the definition in CODESYS and the implicit recipe files on the PLC are kept the same automatically. Changing recipes also leads to file access.

Deactivate this option if the application controls the saving of files programmatically.

See also

Method ‘CreateRecipe’

This method generates a new recipe in the given recipe definition. Then it reads the current PLC values to the new recipe and saves them as a recipe file with the default name. The default name is <recipe>.<recipe definition>.<recipe extension>.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
CreateRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_ALREADY_EXIST
  • ERR_RECIPE_NOMEMORY
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘CreateRecipeNoSave’

This method generates a new recipe in the given recipe definition. Then it reads the current values to the new recipe.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
CreateRecipeNoSave DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_ALREADY_EXIST
  • ERR_RECIPE_NOMEMORY
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘DeleteRecipe’

This method removes a recipe from the recipe definition.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
DeleteRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘DeleteRecipeFile’

This method removes the given recipe file of a recipe. The recipe file must be saved as the default name <recipe>.<recipe definition>.<recipe extension>.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
DeleteRecipeFile DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_FILE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘LoadAndWriteRecipe’

This method loads a recipe from the given recipe definition. The recipe file must be saved as the default name <recipe>.<recipe definition>.<recipe extension>. Then it writes the recipe to the PLC variables.

Note

Entries in the recipe file that do not include value assignments are not loaded and written. Refer to the description of the Load and write Recipe command.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName

STRING

STRING

Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
LoadAndWriteRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_FILE_NOT_FOUND
  • ERR_RECIPE_MISMATCH
  • ERR_RECIPE_NOT_ALL_VARIABLES_WERE_LOADED
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘LoadFromAndWriteRecipe’

This method loads the given recipe file to a recipe. Then it writes the recipe to the PLC variables.

Note

Entries in the recipe file that do not include value assignments are not loaded and written. Refer to the description of the Load and write Recipe command.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
FileName STRING (255) File name
Return value
Name Data type Description
LoadFromAndWriteRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_FILE_NOT_FOUND
  • ERR_RECIPE_MISMATCH
  • ERR_RECIPE_NOT_ALL_VARIABLES_WERE_LOADED
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘LoadRecipe’

This method loads a recipe from a recipe file. The recipe file must be saved as the default name <recipe>.<recipe definition>.<recipe extension>.

Note

Entries in the recipe file that do not include value assignments are not loaded and written. Refer to the description of the Load and write Recipe command.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
LoadRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_FILE_NOT_FOUND
  • ERR_RECIPE_MISMATCH
  • ERR_RECIPE_NOT_ALL_VARIABLES_WERE_LOADED
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘ReadAndSaveAs’

This method reads the current PLC values from the variables of the recipe definitions. Then it saves this data set to a recipe file without changing the existing standard recipe file <recipe.recipe definition.extension>.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition. The variables defined in the recipe definition are read.
FileName STRING(255) Name of the file. In the file, the current read data set is save as a recipe.
Return value
Name Data type Description
ReadAndSaveAs DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_SAVE_ERR
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘ReadAndSaveRecipe’

This method reads the current PLC values to a recipe. Then it saves the recipe with the default name to a recipe file. The default name is <recipe>.<recipe definition>.<recipe extension>. This overwrites the contents of any existing file.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
ReadAndSaveRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_SAVE_ERR
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘ReadAndSaveRecipeAs’

This method reads the current PLC values to a recipe. Then it saves the recipe to a given recipe file. This overwrites the contents of any existing file.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
FileName STRING File name
Return value
Name Data type Description
ReadAndSaveRecipeAs DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_SAVE_ERR
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘SaveRecipe’

This method saves the recipe with the default name to a recipe file. The default name is <recipe>.<recipe definition>.<recipe extension>. This overwrites the contents of any existing file.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
SaveRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_RECIPE_SAVE_ERR
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘ReadRecipe’

This method reads the current PLC values to a recipe.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
ReadRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘WriteRecipe’

This method writes the recipe to the PLC variables.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
Return value
Name Data type Description
WriteRecipe DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘ReloadRecipes’

This method loads the recipe list from the file system. Recipes are considered that have the default name <recipe>.<recipe definition>.<recipe extension> and are located in the path as defined in the recipe manager.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
Return value
Name Data type Description
ReloadRecipes DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘GetRecipeCount’

This method returns the number of recipes in a recipe definition.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
Return value
Name Data type Description
GetRecipeCount INT

Number of recipes

Possible errors

  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘GetRecipeNames’

This method detects the recipe names in a recipe definition.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
pStrings POINTER TO ARRAY [] OF STRING Pointer to the array that contains the recipe names.
iSize INT Number of elements in the STRING array
iStartIndex INT

Start index

Example: 1

Return value
Name Data type Description
GetRecipeNames DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

Example:

There are 50 recipes and you want to generate a table that displays 10 recipe names at the same time. Then you must define a STRING array:

strArr: ARRAY[0..9] OF STRING;

Then you receive the recipe names for the specified range corresponding to iStartIndex.

iStartIndex := 0; returns names 0..9
iStartIndex := 20; returns names 20..29

In this example:

iSize := 10;

See also

Method ‘GetRecipeValues’

This method detects the values of a recipe.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
pStrings POINTER TO ARRAY [] OF STRINGS pointer to strings where the recipe values are saved
iSize INT size of the string array
iStartIndex INT start index
iStringLength INT string lengths of string in the array
Return value
Name Data type Description
GetRecipeValues DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

Example:

There are 50 recipes and you want to generate a table that displays 10 recipe values at the same time. Then you must define a STRING array:

strArr: ARRAY[0..9] OF STRING;

Then you receive the recipe values for a specified range corresponding to iStartIndex.

iStartIndex := 0; returns values 0..9
iStartIndex := 20; returns names 20..29

In this example:

iStringLength := 80;
iSize := 10;

See also

Method ‘GetRecipeVariableNames’

This method detects the names of the recipe variables in a recipe.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName   Name of the recipe
pStrings POINTER TO ARRAY [] OF STRINGS Pointer to STRING data types where the names of recipe variables are saved
iSize INT size of the STRING array
iStartIndex INT start index
Return value
Name Data type Description
GetRecipeVariableNames DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

Example:

There are 50 recipes and you want to generate a table that displays 10 variable names of a recipe at the same time. Then you must define a STRING array:

strArr: ARRAY[0..9] OF STRING;

Then you receive the variable names of the recipe for the specified range corresponding to iStartIndex.

iStartIndex := 0; returns names 0..9
iStartIndex := 20; returns names 20..29

In this example:

iSize := 10;

See also

Method ‘SetRecipeValues’

This method returns the recipe values of a recipe.

Inputs (VAR_INPUT)
Name Data type Description
RecipeDefinitionName STRING Name of the recipe definition
RecipeName STRING Name of the recipe
pStrings POINTER TO ARRAY [] OF STRINGS Pointer to STRING data types where the names of recipe variables are saved
iSize INT size of the STRING array
iStartIndex INT start index
Return value
Name Data type Description
SetRecipeValues DWORD
  • ERR_OK
  • ERR_RECIPE_DEFINITION_NOT_FOUND
  • ERR_RECIPE_NOT_FOUND
  • ERR_NO_RECIPE_MANAGER_SET

Example:

There are 50 recipes and you want to generate a table that sets 10 recipe values at the same time. Then you must define a STRING array:

strArr: ARRAY[0..9] OF STRING;

Then you can define the recipe values for a specified range corresponding to iStartIndex.

iStartIndex := 0; sets values 0..9
iStartIndex := 20; sets values 20..29

In this example:

iStringLength := 80;
iSize := 10;

See also

Method ‘GetLastError’

This method returns the last error from the prior operation.

Return value
Name Data type Description
GetLastError DWORD See Library ‘Recipe Management’ - ‘RecipeManCommands’.

Method ‘ResetLastError’

This method returns the last error.

Return value
Name Data type Description
ResetLastError DWORD
  • ERR_OK
  • ERR_NO_RECIPE_MANAGER_SET

See also

Method ‘SetStoragePath’

This method is used for setting the save path of the recipe file. It overwrites the path definition in the Storage dialog of the recipe manager.

Inputs (VAR_INPUT)
Name Data type Description
stPath STRING

file path, example:

  • D:/recipefiles/
Return value
Name Data type Description
stPath BOOL
  • TRUE (path was set)
  • FALSE

Possible errors

  • ERR_OK
  • ERR_NO_RECIPE_MANAGER_SET

See also

Return values

The return values of the above functions are included in the GVL ReturnValues.

These are InOut constants of data type UDINT.

Name Initialization value Comment
ERR_OK 16#0 The operation was completed successfully.
ERR_FAILED 16#1 The operation failed.
ERR_PARAMETER 16#2 incorrect parameter
ERR_NOTINITIALIZED 16#3 The data server object has not been initialized. The data server is required when using the recipe manager with CODESYS HMI.
ERR_NOTIMPLEMENTED 16#C The data server does not implement the needed interface IDataServer4 when the recipe manager is used with CODESYS HMI.
ERR_NO_OBJECT 16#10 The data server cannot write all variables of a recipe definition. Only the valid variables are written.
ERR_NOMEMORY 16#11 The data server does not have enough memory.
ERR_RECIPE_FILE_NOT_FOUND 16#4000 The recipe file was not found.
ERR_RECIPE_MISMATCH 16#4001

The contents of the recipe file do not match the current recipe. This error is returned only for the storage type “Textual” (see dialog Recipe Manager, tab Storage, Storage Type) and only if a variable name in the file conflicts with the variable name in the recipe definition. The recipe file does not load when this error occurs.

Possible causes:

A variable was removed from the recipe definition in the project.

ERR_RECIPE_SAVE_ERR 16#4002

The save operation failed.

Possible causes

  • The file could not be created or opened because the disk is full.
  • The configured file path does not exist (see dialog Recipe Manager, tab Storage, File Path).
  • The configured file extension is not permitted by the runtime system (see dialog Recipe Manager, tab Storage, File Extension).
ERR_RECIPE_NOT_FOUND 16#4003 The recipe does not exist.
ERR_RECIPE_DEFINITION_NOT_FOUND 16#4004 The recipe definition does not exist.
ERR_RECIPE_ALREADY_EXIST 16#4005 The recipe already exists in the recipe definition. Create a new recipe with another name.
ERR_NO_RECIPE_MANAGER_SET 16#4006

The global recipe manager has not been created.

Possible causes

  • The option Recipe Management in the plc has not been set in the current application (see dialog Recipe Manager, tab General).
ERR_RECIPE_NOT_ALL_VARIABLES_WERE_LOADED 16#4007 The recipe definition includes more variables than the recipe file. In this case, the variable values of the recipe file are definitely written. This is simply informative, not an actual error.
ERR_RECIPE_NOMEMORY 16#4008

The recipe definition does not have any available memory to create a new recipe.

Possible causes

  • The option Save recipe changes to recipe files automatically has not been set in the current application (see dialog Recipe Manager, tab General).
  • In this case, only 50 recipes per recipe definition are possible. If the option Save recipe changes to recipe files automatically is set, then the error cannot occur. If the disk is full, then the error ERR_RECIPE_SAVE_ERR is returned.
ERR_RECIPE_MANAGER_LOCKED_DURING_ONLINE_CHANGE 16#4009

The recipe manager was blocked during the online change.

Possible causes:

Some of the RecipeMan commands that should be executed during an online change were not executed.

ERR_SOURCE_EXHAUSTED 16#40A0 used for UTF8 helper
ERR_TARGET_EXHAUSTED 16#40A1 used for UTF8 helper
ERR_SOURCE_ILLEGAL 16#40A2 used for UTF8 helper