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
en:sw:01-mervis:autogen-hidden [2018/11/15 08:42]
jan_kozak
en:sw:01-mervis:autogen-hidden [2023/09/12 12:04] (current)
avsetula
Line 1: Line 1:
 ====== Working with Autogen ====== ====== Working with Autogen ======
-One of the most important things you need to know about MervisIDE is what is Autogen and how to work with it. In [[en:​sw:​01-mervis:​creating-new-project-hidden|previous tutorial]], we learned that Autogen ​is for accessing HW inputs and outputs from the program. We also discovered, how to Set Autogen on the whole device ​(PLC, Extension, Modbus device, 1-Wire sensor,...). Let's discuss it a bit more.+<WRAP group> 
 +<WRAP half column 81%> 
 +In the Simple mode of the solution, it is not necessary ​to know the autogen, as it is activated by default ​(automaticallyand always creates variables for all available data pointsThis approach /*FIXME možná v tomto případě tedz approach? */ is optimal if you are starting with Mervis.
  
-===== Why not to Set Autogen ​on the device ===== +However, if you want to work on a specific project, **knowledge of working with the Autogen ​function ​is essential** ​and it is, thereforenecessary to have the solution in [[creating-new-project-hidden#​switching_to_full_mode|Full mode]].
-Setting ​Autogen ​on the whole device ​is a nice feature for debugging. You tell the Mervis Runtime to poll all the inputs ​and outputs and you have them immediately accessible in your program and in the debugging mode. The downside of this is a hit on the performance of your program. The PLC contains a lot of informationwhich are needed in special cases and you don't need them for normal operation. Alsopolling unnecessary information from the [[en:hw:04-extensions|Extensions]] over slow RS485 bus will have a significant impact on the performance.+
  
-The other downside ​is that the Set Autogen ​will automatically generate the name of the variable. As you can check, the generated name consists of the UniPi unit name and the name of the input/​output. In our project, we have attached the Neuron L503 and we want to use the digital input 3.7. The generated name is "​Neuron L503_DI_3.07"​+In the tutorial, you will learn [[#​how_does_autogen_affect_program_speed|why it is necessary to manage ​Autogen ​manually]] ​and what the benefits are.
  
-{{ :en:sw:01-mervis:​working-with-autogen-01-insert-existing-variable.png?direct |}}+</​WRAP>​ 
 +<WRAP half column 15%> 
 +;;# 
 +<​html><​span class="​dev-tag dev-patron">​Patron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-neuron">​Neuron</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-gate">​Gate</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-unipi11">​Unipi&​nbsp1.1</​span></​html>​ \\ 
 +<​html><​span class="​dev-tag dev-axon">​Axon</​span></​html>​ 
 +;;# 
 +</​WRAP>​ 
 +</​WRAP>​
  
-You can quite happily use this variable in your program, even multiple times (the button can control many aspects of your project ​at once)One of the problems with this naming is that it is not descriptiveWhen you are working on the project, you will remember that DI 3.7 is connected to the "​OK"​ button on the operator'​s panel, or to the wall switch in your bedroomIn half a year, you wouldn'​t have toOr the project will be handed over to somebody else who will not have that knowledge and the project will be hard to read+<WRAP center round info 95%> 
 +The subsequent tutorial follows: [[creating-new-project-hidden|]]Be sure to complete ​this guide before proceeding. 
 +/* FIXME doslovný překlad by byl The following tutorial follows ​... ale tam je dvakrát follows*/  
 +</​WRAP>​
  
-Another problem is the automatic inclusion of the PLC name into the name of the variable, in our instance the prefix "​Neuron L503_"​. If you have only one PLC in your solution, that may be OK. It can get unreadable, when you have more PLCs and even more unreadable when you have more PLCs of the same type. It is a good idea to rename them according to some rule. Typically, the name is based on the physical location - boiler_room,​ 1st_floor or operator_panel. 
  
-<WRAP center round tip 60%> +===== What is Autogen? ===== 
-We advise naming ​the variables and PLCs using lowercase alphanumeric characters (a-z,0-9) and underscore ​(_as word delimiter: boiler_roombedroom_blinds1st_floor_temperature,...+Autogen is a tool in the Mervis IDE that is used to create ​variables ​for data points, respectively inputs, ​and outputs of the whole solution. These are not only inputs and outputs directly on the unit, but also devices connected ​using various protocols: Modbus, 1-WireM-bus, BACnet, etc. The devices can be units or Unipi Extension modules, sensors, electricity meters, etc. 
 + 
 +It also allows the custom naming of generated variables. 
 + 
 +---- 
 + 
 +<​html><​span class="​kbBlueText">​What is a data point?</​span></​html>​ \\ 
 +A data point is a definition of communication for a specific input or output. The data type (bool, byte, int, ...and possibly other parameters specific to the selected communication type are defined directly on the data point. 
 + 
 +To use the data point, it is necessary to create ​variable for itwhich can already be used in the program. 
 + 
 +---- 
 + 
 +<WRAP center round important 95%> 
 +The most important part of Autogen is the file **generated.Mixed.st**which is automatically generated by this functionand any manual intervention in this file can cause unavailability of inputs and outputs or unexpected behaviorTherefore, **never manually edit, delete, or move this file**. 
 + 
 +Interference with this file is possible only in exceptional /*FIXME možná významově lepší extreme cases?*/ cases and only for **very experienced users**.
 </​WRAP>​ </​WRAP>​
  
-For making fast and readable projects, the Mervis includes functionality for renaming the inputs/​outputs and PLCs to your liking. Let's create a simple project where we will demonstrate it. Our project will need one digital input (DI1.1) which will be used for reading a state of a button. And we will need one digital output which will be wired to a LED indicator. 
  
-Let's start with renaming the PLC. Select the PLC in the **Left Panel** and head over to the **Properties**. Change the property "​Name"​ to "​operator_panel"​ and confirm by clicking on ''​V''​. 
  
-{{ :​en:​sw:​01-mervis:​working-with-autogen-02-rename-plc.png?direct |}}+===== How is Autogen used===== 
 +There are two variants of how Autogen can be used, and each variant has its advantages and disadvantages.
  
-Next, we will rename the inputs ​and outputs. Double click on the prototype in the **Left panel** and head over to the list of IOs which will appear in the **Main Window** and search for the name "DI_1.01":+   - Creating variables [[#​for_the_whole_device_channel|for all device data points]] ​and then turning off autogen for data points you don't use 
 +   - Creating only variables [[#​for_specific_variables|for specific data points]] that you want to use.
  
-{{ :​en:​sw:​01-mervis:​working-with-autogen-03-look-for-di.png?​direct |}} 
  
-To rename ​the input, fill the value in the column "​Autogen Name" and confirm by clicking on ''​V''​. The DI_1.01 is for a button, so let's rename it to "​button"​.+\\ 
 +==== 1. For the whole device/​channel ====
  
-{{ :​en:​sw:​01-mervis:​working-with-autogen-04-rename-and-set-autogen.png?direct |}}+=== Creating varibales === 
 +Can be used if you do not know which inputs ​and outputs you will use, or if you want to have access to every I/O, e.g. for testing/​debugging new devices or the entire solution (switchboard). Use the following procedure to access all inputs and outputs for one or more devices at once.
  
-Now set the autogen for this data point. Right click on the data point and in the context menu click on the "Set Autogen"​ and confirm the dialogue by clicking on **OK**.+----
  
-Repeat this process for the digital output. The DO_1.01 will be called a "​led"​.+First, open your project with the assigned unit in Full mode.
  
-<WRAP center round info 60%> +Then right-click on a specific device and select **Set Autogen**:​ 
-As you will find out, the digital outputs (DOs) have two data points available: DO_X.Y_w ​and DO_X.Y_r. For now, use the DO_X.Y_w and we will explain the difference ​in future tutorials.+ 
 +{{ :​en:​sw:​01-mervis:​01_autogen.png?​direct |}} 
 + 
 +---- 
 + 
 +A dialog will open, where it is necessary to select in which project the variables will be generated. You can also select the "​Include Attributes"​ option. 
 + 
 +<WRAP center round info 95%> 
 +What attributes are and what they can be used for is described in detail ​in article [[comm-attributes-hidden|]].
 </​WRAP>​ </​WRAP>​
  
-By setting autogen ​on two data points ​we created two global ​variables. ​One of the placeswhere you can check it is the **Variable Browser** tab of the **Main Window**.+Now click on **OK**. 
 + 
 +{{ :​en:​sw:​01-mervis:​02_autogen.png?​nolink |}} 
 + 
 +This generates variables for all available ​data points ​and can be searched for (after compiling the solution) among the available variables. 
 + 
 +---- 
 + 
 +This procedure can also be applied to all devices in the channel by right-clicking and selecting **Set Autogen** and confirming the dialog. 
 + 
 +{{ :​en:​sw:​01-mervis:​03_autogen.png?​direct |}} 
 + 
 + 
 +\\ 
 +=== Deleting variables === 
 +The procedure is almost identical. 
 + 
 +---- 
 + 
 +First, right-click on the device/​channel and select **Set Autogen**, but in the following dialog now select **Operation:​ Reset Autogen** and confirm by clicking **OK**. 
 + 
 +{{ :​en:​sw:​01-mervis:​04_autogen.png?​nolink |}} 
 + 
 +This will delete all variables for the selected device/​channel and will no longer be available. 
 + 
 +---- 
 + 
 +If you have created ​variables for attributes as well and want to remove them, also select the **Include attributes** option. 
 + 
 +\\ 
 +==== 2. For specific variables ==== 
 + 
 +=== Creating variables === 
 +To create only selected variables, you must first open the device editor. To open, double-click on the device, in this case, **Patron S207**. 
 + 
 +A (modbus) table opens with the groups and their data points. 
 + 
 +{{ :​en:​sw:​01-mervis:​05_autogen.png?​direct |}} 
 + 
 +---- 
 + 
 +Now we look for the data point for which we want to create a variable. In our case, we will search for **DI_1.01**. Find it using the filter at the top of the window. 
 + 
 +{{ :​en:​sw:​01-mervis:​06_autogen.png?​direct |}} 
 + 
 +---- 
 + 
 +<​html><​span class="​kbBlueText">​You have two options:</​span></​html>​ 
 +   - Right-click on the data point, select **Set autogen** and confirm the dialog 
 +   - Click on the data point with the left button, its properties will be displayed in the right panel, here click on **Enable SWAutogen** and then under it (next line) select the project for which the variable will be generated /*FIXME v obrázku je Enable SWAutogen, nevím jak v CZ ale v textu je jenom Povolit Autogen, nemá tam být také SW? Stejně tak níže */ 
 + 
 +{{ :​en:​sw:​01-mervis:​07_autogen.png?​direct |}} 
 + 
 +Now a variable has been generated only for the selected data point. Variable will be available after compilation. 
 + 
 + 
 +\\ 
 +=== Deleting ​variables ​=== 
 +The procedure is almost identical to creating a specific variable. 
 + 
 +---- 
 + 
 +To delete the selected variables, open the device editor. To open, double-click on the device, in this case, **Patron S207**. 
 + 
 +In the open table, use the filter at the top of the window to find the data point you want to delete. 
 + 
 +{{ :​en:​sw:​01-mervis:​08_autogen.png?​direct |}} 
 + 
 +---- 
 + 
 +<​html><​span class="​kbBlueText">​You have two options:</​span></​html>​ 
 +   - Right-click on the data pointselect **Set autogen**, but in the following dialog now select **"​Operation:​ Reset Autogen"​** and confirm the dialog /* FIXME tady jsou uvozovky v předchozím případě u mazání proměnných nejsou*/ 
 +   - Click on the data point with the left button, its properties will be displayed in the right panel, here click on **Enable SWAutogen** to change the value to **False** 
 + 
 +{{ :​en:​sw:​01-mervis:​09_autogen.png?​direct |}} 
 + 
 +The deleted variable is no longer available among other variables. 
 + 
 + 
 + 
 +\\ 
 +===== Change the name of the generated variables ===== 
 +When you create a project, you will easily remember that DI_1.01 is connected to the “OK” button on the operator panel, or to the wall switch in your bedroom. But you don't have to remember it after half a year. It may also be necessary to hand over the project to someone else who has never worked on the project before and your labeling will be confusing for them. /* FIXME v češtině je něj ale asi by mělo být ně? */ 
 + 
 +For these and other reasons, it is advisable to name the variables, e.g.: OK_panel1, Off_bedroom,​ etc. /*FIXME v češtině dvě tečky na konci věty*/ 
 + 
 + 
 +---- 
 + 
 +To set your own variable name, you need to open the device editor. To open, double-click on the device, in this case, **Patron S207**. 
 + 
 +In the open table, find the data point you want to rename. You can use the search at the top of the window. /* FIXME rename? v CZ je smazat, ale snažíme se ho přejmenovat?​*/​ 
 + 
 +{{ :​en:​sw:​01-mervis:​10_autogen.png?​direct |}} 
 + 
 +---- 
 + 
 +<​html><​span class="​kbBlueText">​You have two options:</​span></​html>​ 
 +  - Left-click on the data point, and enter your own name in the **Autogen name** column and confirm by pressing ENTER or by clicking on {{:​files:​dialog-confirm_button.png?​nolink|}} 
 +  - Left-click on a data point to display its properties in the right panel, click on **Generated variable Name (SWAutogen)**,​ enter your own name and confirm by pressing ENTER or by clicking on {{:​files:​dialog-confirm_button.png?​nolink|}} /*FIXME vypsala jsem celý název proměnné v pravém sloupci podle screenshot, v cz není závorka? */ 
 +   
 +{{ :​en:​sw:​01-mervis:​11_autogen.png?​direct |}} 
 + 
 +The renamed variable will be available under a new name after compilation. 
 + 
 +\\ 
 +==== Change the device name ==== 
 + 
 +Since each variable always has a device name before its own name (here: Patron S207), ​it is advisable to set this device name to make the project clearer. The most intuitive are names based on physical location: BoilerRoom, Cellar, RZV1, Hall3, etc. /*FIXME na konci věty v CZ dvě tečky ​*
 + 
 +---- 
 +To change the name, click on a specific device and set a new name in the right column of the properties. Then confirm by pressing the ENTER key or clicking the button {{:​files:​dialog-confirm_button.png?​nolink|}}. 
 + 
 +{{ :​en:​sw:​01-mervis:​12_autogen.png?​direct |}} 
 + 
 + 
 + 
 +\\ 
 +===== A quick overview of I/O mapping ===== 
 +There is also an overview of all data points, their data types, custom naming, or the resulting declaration of the variable. This quick overview is available for each PLC separately and includes data points and channels of all connected technologies of the selected PLC. 
 + 
 +---- 
 + 
 +To view the I/O mapping overview, double-click the controller (**PLC**) in the left panel. 
 + 
 +{{ :​en:​sw:​01-mervis:​13_autogen.png?​direct |}} 
 + 
 +A PLCs window with task mapping will open, where you switch to **IO Mapping** at the bottom. /*FIXME - na screenu není lomítko uvádět? */ 
 + 
 +{{ :​en:​sw:​01-mervis:​14_autogen.png?​direct |}} 
 + 
 +A table with a quick overview ​of all data points is now displayed. 
 + 
 +{{ :​en:​sw:​01-mervis:​15_autogen.png?​direct |}} 
 + 
 + 
 + 
 +\\ 
 +===== How does Autogen affect program speed? ===== 
 +It can simply be said that data points are not communicated (read/​written) unless they have created a variable. But this is not always ​the case. 
 + 
 +The following example is therefore explained on the most used communication protocol Modbus, which is currently communicated in groups, not in individual points. 
 + 
 +---- 
 + 
 +Open the (modbus) table of your unit. Here you have many groups with even more data points. 
 + 
 +{{ :​en:​sw:​01-mervis:​16_autogen.png?​direct |}} 
 + 
 +---- 
 + 
 +As already mentioned, Modbus communicates in groups and each group means one separate message consisting of **address, function, data, and CRC**. Thus, each Modbus message means a certain delay depending on the speed of the communication interface, which can further increase when the message is lost or damaged. 
 + 
 +---- 
 +E.g. for function F03, each Modbus register (2 bytes) extends the response message by exactly 2 bytes. 
 + 
 +Therefore, if you read 1 register within one group, the query consists of 8 bytes and the answer consists of 7 bytes. If you read 10 registers within one group, the query is still composed of 8 bytes, but the answer is now composed of 25 bytes.
  
-{{ :​en:​sw:​01-mervis:​working-with-autogen-05-variable-browser.png?direct |}}+If you do not read any register within the group no data point within the group has a variable ​created, the whole message is skipped. If you apply this procedure to all data points/​groups,​ you can significantly speed up the reading/​writing of other groups and thus speed up the overall system response.