Logic in the background
The example extends the "Activate", "Teach" and "TeachAsNew" functions available in the Action and Conditions Editor by further user-specific functions that call the Framework API of the recipe management in the background. These functions can also be reused in other projects if they are imported accordingly.
The functions can be found in the HMI project in the RecipeFunctions folder.
Since all functions are called asynchronously, they are additionally given a context object as a parameter value. This provides information about the success or failure of the function.
ConvertDatagridToRecipe
The ConvertDatagridToRecipe function reads the current contents of the data grid and saves them in the transferred recipe. This function is executed by clicking on the Update selected recipe button.
Parameter:
Name | Type | Description |
---|---|---|
datagridControl | tchmi:framework#/definitions/Control | The TcHmiDatagrid, in which the recipe members are to be displayed. |
recipeReference | tchmi:framework#/definitions/RecipeReference | The reference to the recipe that is to be described. |
Return value:
Type | Description |
---|---|
void | No return value. |
ConvertRecipeToDatagrid
The ConvertRecipeToDatagrid function displays all members of the transferred recipe in a data grid. The function is transferred to the SrcData attribute of the data grid when changing the selection in the combo box in order to load the newly selected recipe.
Parameter:
Name | Type | Description |
---|---|---|
recipeReference | tchmi:framework#/definitions/RecipeReference | The reference to the recipe that is to be displayed. |
Return value:
Type | Description |
---|---|
void | No return value. |
The data set for the data grid is transferred to the context object.
DeleteRecipe
The DeleteRecipe function deletes a transferred recipe.
Parameter:
Name | Type | Description |
---|---|---|
recipeReference | tchmi:framework#/definitions/RecipeReference | The reference to the recipe that is to be deleted. |
Return value:
Type | Description |
---|---|
void | No return value. |
DownloadRecipe
The Download function enables the download of a transferred recipe as a JSON file. This can then be imported using the UploadRecipe function.
Parameter:
Name | Type | Description |
---|---|---|
recipeReference | tchmi:framework#/definitions/RecipeReference | The reference to the recipe that is to be downloaded. |
Return value:
Type | Description |
---|---|
void | No return value. |
The upload and download functions are not available in the LiveView in Visual Studio. |
ListRecipeAsReferenceArray
The ListRecipeAsReferenceArray function creates an array of all available recipes that is needed for the selection in the combo box. The function is used on the SrcData attribute of the combo box.
Parameter:
Name | Type | Description |
---|---|---|
recipeList | tchmi:server#/definitions/folderRecipe | The reference to all recipes. The list of all recipes is the "recipeList" symbol in the RecipeManagement extension. |
Return value:
Type | Description |
---|---|
void | No return value. |
The data set for the combo box is transferred to the context object.
UpdateDatagridFromTarget
The UpdateDatagridFromTarget function lists the current online values of the recipe members of the transferred recipe in the "New value" column in the data grid. The function is executed by clicking on the Read values from target button.
Parameter:
Name | Type | Description |
---|---|---|
datagridControl | tchmi:framework#/definitions/Control | The TcHmiDatagrid, in which the online values are to be displayed in the "New value" column. |
recipeReference | tchmi:framework#/definitions/RecipeReference | The reference to the recipe that is to be displayed in the data grid. |
Return value:
Type | Description |
---|---|
void | No return value. |
UploadRecipe
The UploadRecipe function loads a recipe from a JSON file into the recipe management. Recipes that were exported using the DownloadRecipe function can be imported with this function.
Parameter:
Name | Type | Description |
---|---|---|
- | - | - |
The recipe in the form of the JSON file is selected directly via the file browser in the browser.
Return value:
Type | Description |
---|---|
void | No return value. |
The upload and download functions are not available in the LiveView in Visual Studio. |