User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
recipes [2018/11/28 14:42]
itkachenko
recipes [2020/06/01 15:14] (current)
emozolyak [Using recipes in scripts]
Line 1: Line 1:
 ======Recipes====== ======Recipes======
-The recipe allows you to initialize a set of values ​​to a certain group of registers. There are several options for using recipes: 
  
-  * placing ​list of recipes ​on a dashboard ​in the form of a drop-down ​or full list. After choosing a recipe, there are two options - immediately apply it, or use a script ​that will track the selection of new recipe ​and perform some additional actions. +The recipe allows you to initialize ​set of registers with pre-defined values. There are several options for using recipes
-  * activation of the recipe ​inside ​the scriptwhich can be initiated, ​for example, by the scheduler (you can apply several recipes at the same time, implementing script management, ​for example control of lighting zones, etc.).+  * Recipes can be applied either by selecting an entry in the recipe ​drop-down list or by calling ​a script 
 +  * Recipes can be edited right on the dashboard with quick edit method (not going back to the main recipe ​menu) 
 +  * Recipes can be visible or not for different users. Some recipes can be '​locked'​ (i.e. viewed w/o possibility to change ​recipe ​data for users except ​the admin) to protect importantor base recipes from changing.  
 +  * Recipe list can be used as a handy tool for analysing user choice from different options. In this case recipe names in the list or category serve as a placeholders ​for the selection listboxThe selected id is returned to the lua script which then can process the selection
  
-Recipes ​are created in the Configuration/​Recipes menu.+===== Recipes ​page=====
  
-{{ :​recipes1.png?​direct |Configuration/​Recipes ​menu}}+The recipe management ​menu resides in a '​logic'​ section of the Setup menu:
  
-Recipes can have sub-categories,​ i.e. the list of recipes on a dashboard can be displayed completely, or only from a certain category.+{{ ::​recipes_entry.png?​direct&​600 |}} 
  
-{{ :recipes2.png?direct |category}}+The main spots of the recipe management page are: 
 +  - Import/​Export buttonsThe recipe can be exported to a JSON file. After importing such recipe file, it will create a new entry in the list with a new id.  
 +  - Add recipe button 
 +  - Recipe ​category. use them to divide the list, then the dropdown lists on dashboard can show only specific category you set for them 
 +  - '​Locked'​ recipe colored light gray. This recipe can only be edited by admin, but still viewed by the users with respective rights 
 +  - Checkbox for selecting export candidates 
 +  - Common (non-locked) recipe list.  
 +  - Edit/​Delete/​Clone buttons
  
-And also be available to specific users.+{{ ::​recipe_list_inum.png?​direct&​600 |}}
  
-{{ :​recipes3.png?​direct |users}}+===== Recipe setup=====
  
-When placing a list of recipes ​on dashboard, you must specify:+The //Basic// tab: 
 +  ***Title** - this title will be seen in the selection lists and setup page 
 +  ***Description** - user comments for the recipe  
 +  ***Disable** checkbox - hides this recipe from the list 
 +  ***Lock** - prevent the recipe from editing by non-admin users 
 +  ***Registers 1..4 / Value / Description** - this set of the registers will be initialized with the respective values upon invoking recipe. The description given here will be used to show the comments in the quick edit window (right ​on the dashboard
 +  ***Delete** button deletes the register //n// from the list 
 +  ***Add register to recipe** button expands the list with a new entry 
  
-  * Category of recipes, or a complete list of all categories +{{ ::​recipe_basic_tab.png?​direct&​600 |}}
-  * Drop-down or multiline list +
-  * Number of the register where the recipe number will change(changing this register can be monitored in scripts when you need to perform some actions associated with this recipe) +
-  * Whether to apply the recipe immediately or not (in the second case, only the register number will change where the current recipe number is stored)+
  
-{{ :recipe4.png?direct |dashboard}}+The //​Permission//​ tab lists the users who can view or edit recipes.  
 +{{ ::​recipe_permissions.png?direct&​600 ​|}}
  
-To apply recipes within scripts, the **ApplyRecipe (recipeId, userId)** function is used. [[http://​docs.webhmi.com.ua/​scripts|See here]]. ​After it is executed, if a list is displayed on one of the dashboards, the contents of the recipe from the ApplyRecipe ​function, ​you must also write the recipe ​number in the register tied to the list - to synchronize the display of the list.+===== Using recipe on the dashboard ===== 
 + 
 +When placing a recipes selection listbox on a dashboard, there are some specific attributes you must specify: 
 + 
 +  * //​Category//​ of recipes, or a full list.  
 +  * The //​register//​ accosiated with the dropdown list which will keep the //id// of the selected recipe.  
 +  * '//​Allow change value//'​ checkbox. If you want the user be able to expand the list, check it, otherwise the user won't be able to select and expand the list. With unchecked option, the recipes can be itereated with the lua script and extra buttons which return next/​previous selection event (register value coding the action)  
 +  * '//​Apply immediately//'​ checkbox. The values from the set will be written at once after selection, or you can check register change in a lua script and first do some steps before applying a recipe.  
 + 
 + 
 +{{ ::​recipe_on_the_dashboard.png?​direct&​600 |}} 
 + 
 +If the user has right to edit the recipe, he can do this right in the selectoin box: 
 + 
 +{{ quick_rcp_apply_edit.gif |}} 
 + 
 +===== Using recipes in scripts ===== 
 + 
 +To apply recipes within scripts, the **ApplyRecipe (recipeId, userId)** function is used. [[working_with_recipes|See here]]. ​The example ​of such script: 
 + 
 +<code lua> 
 +function ​main (userId) 
 +    local id = GetReg("​rcpSelector"​) 
 +    ApplyRecipe(iduserId) 
 +    AddInfoMessage("​The ​recipe ​with id = " ​.. id .. " was applied!"​) 
 +end 
 +</​code>​ 
 + 
 +{{ recipe_in_scripts.gif |}}

Page Tools