Detailed information on recipes

Two internal data point types are provided for the Recipes facility. New recipe types are created as data points of type _Rct. New recipes are created as data points of type _Rcp. The two tables below explain the meaning of each of the data point elements:

Data point type _Rct

Element Data type Meaning
recipeType string Name of the recipe type
description langString Description of the recipe type
lastActivated time Time when last activated
lastActivatedOfThisType string Last recipe of this type to be activated
lastModified time Time when last modified
valid bool Status of the recipe type
elements dyn_string The data point elements belonging to the recipe type
elementTypes dyn_string Data types of the DPEs
elementUnits dyn_int Units of the data point elements
elementIndex dyn_int Indexes of the elements for sorting into their original order
recipes dyn_string All the recipes that belong to a type
lastActivatedUser string User who last activated the recipe

Data point type _Rcp

Element Data type Meaning
recipeType string Name of the recipe type it belongs to
author string User name of the person who created the recipe
description langString Description of the recipe
lastUsage time Time when last activated
lastModified time Time when last modified
valid bool Status of the recipe
elementValues dyn_string Values to be passed to the data point elements.
user string Current user

CTRL functions

You need not necessarily use the panels provided to access the functions included in the Recipes tool. All essential operations are also available as CTRL functions, and can even be used in customized panels. All the CTRL functions are held in a library called rcp.ctc.

The table below lists the CTRL functions in the order in which they would logically be used.

Function + Syntax Description
bool rcpCheckLicence() Checks you have a license for the tool
void rcp_createRecipeType(string typename, int &err)

Creates a recipe type

Parameters:

string typename = Name of the data point type

int &err = Possible error that will be returned.

Possible error codes:

0 OK

-1 Common error

-2 DP exists

-3 illegal characters

-4 Permission NOK

void rcp_changeRecipeType(string typename, dyn_int element_index, dyn_string elements_new, dyn_string comment, string &err)

Saves all recipe type data

Parameters:

string typename = Name of the data point type

dyn_int element_index = Index of the data point elements

dyn_string elements_new = New data point elements

dyn_string comment = Comment for the recipe type

string &err = Possible error that will be returned:

Possible error codes:

"error_dpe_doesnotexist"

"error_invalid_type"

"error_address_conflict"

"error_mp_"

void rcp_checkRecipeType(string typename, dyn_dyn_string &err)

Checks the recipe type

string typename = Name of the recipe type

dyn_dyn_string &err = Possible error that will be returned.

Possible Error codes:

"error_dpe_doesnotexist"

"error_invalid_type"

"error_address_conflict"

"error_mp_"

void rcp_checkDPE(string dpe, string &errorMsg)

Checks the data point element

string dpe = The data point element

string &errorMsg = Possible error that will be returned.

Possible Error codes:

"error_dpe_doesnotexist"

"error_invalid_type"

"error_address_conflict"

"error_mp_"

void rcp_createRecipe(string recipename, string typename, int &err)

Creates a recipe

string recipename = The name of the recipe to be created

string typename = The type name of the recipe

int &err = Possible error that will be returned.

possible error codes:

0 OK

-1 Could not be created

-2 Type does not exist

-4 Permission NOK

void rcp_checkRecipe(string rcp, string &err)

Checks the validity of the recipe

string rcp = Name of the recipe that will be checked

string &err = Possible error that will be returned.

0 OK

-1 rct invalid

-2 Value invalid

-3 Value empty

void rcp_changeRecipe(string rcp, dyn_string comment, dyn_anytype ds_elementValues, string &err)

Saves all recipe data

string rcp = Name of the recipe that should be changed

dyn_string comment = The new comment

dyn_anytype ds_elementValues = New DPE values

string &err = Possible error that will be returned.

0 OK

-1 rct invalid

-2 Value invalid

-3 rcp check NOK

-4 Permission NOK

void rcp_activateRecipe(string recipeName, string rtc, string &err)

Transfers the setpoint values of the recipe to the DPEs

string recipeName = Name of the recipe

string rtc = Recipe type

string &err = Possible error that will be returned.

1 rct invalid

-2 rcp invalid

-3 no of rcp != no of values

-4 Permission NOK

void rcp_readRecipeTypeFromFile(string filenameString, bool overwrite, string &err)

Reads recipe types from an ASCII file.

Possible error codes:

0 OK

-1 common file error

void rcp_readRecipesFromFile(string filenameString, string &err, bool overwrite)

Reads recipes from an ASCII file into WinCC OA.

Possible error codes:

0 OK

-1 File Error

-2 DP already exists

void rcp_writeRecipeTypeToFile(string recipeType, bool overwrite, bool all, string fileNameString, string &err)

Writes recipe types into an ASCII file.

Possible error codes:

0 OK

-1 File error

-2 File exists

void rcp_writeRecipeToFile(dyn_string recipe, bool overwrite , bool all, string fileNameString, string &err)

Saves recipes of a selected recipe type in an ASCII file.

Possible error codes:

0 OK

-1 File Error

int rcp_deleteRecipe(string recipename)

Deletes the specified recipe

string recipename = recipe name

Possible error codes:

-1 dpNotExists

void rcp_deleteRecipeType(string recipeType) Deletes the specified recipe type
void rcp_getAllRecipes(string recipeType, dyn_string &recipeNames) Return all recipes of a recipe type in a dyn_string. If the type does not exist, nothing is returned.
void rcp_getAllRecipeTypes(dyn_string &recipeTypes) Returns all existing recipe types in a dyn_string.

EXAMPLE

In the following you find an example of how to use the recipe functions. Note that the used data point type and data point must exist.

main()
{
  //Corresponding DPs like 'MetalProcessing_Alu' must already exist or have to be created in order to be used for the recipes
  int err;
  string errMsg;
  dyn_dyn_string
  dserrMsg;
  dyn_int element_index;
  dyn_string elements_new;
  dyn_string comment;
  dyn_anytype ds_elementValues;
  DebugN("License check: ",rcpCheckLicence());
  if(!dpExists("MetalProcessing_Alu"))
  {
    rcp_createRecipeType("MetalProcessing_Alu",err);
    DebugN("New recipe type 'MetalProcessing_Alu' created: ",err);
  } 
  element_index[1] = 1;
  element_index[2] = 2;
  element_index[3] = 3;
  elements_new[1] = "alu.soll.state:_original.._value";
  elements_new[2] = "alu.soll.val:_original.._value";
  elements_new[3] = "alu.soll.cmd:_original.._value";
  comment[1] = "MetalProcessing";
  rcp_changeRecipeType("MetalProcessing_Alu", element_index,elements_new,comment,errMsg);
  DebugN("Recipe type data 'MetalProcessing_Alu' saved: ",errMsg);
  rcp_checkRecipeType("MetalProcessing_Alu",dserrMsg);
  DebugN("Recipe type 'MetalProcessing Alu' checked: ",dserrMsg);
  rcp_createRecipe("Alu","MetalProcessing_Alu",err);
  DebugN("Recipe 'Alu' created: ",err);
  ds_elementValues[1] = 222;
  ds_elementValues[2] = 22.222;
  ds_elementValues[3] = 1;
  rcp_changeRecipe("Alu",makeDynString("Alu"),ds_elementValues,errMsg);
  DebugN("Recipe data saved: ",errMsg);
  rcp_activateRecipe("Alu","MetalProcessing_Alu",errMsg);
  DebugN("Recipe activated: ",errMsg); 
}