====== Working with Autogen ====== In the Simple mode of the solution, it is not necessary to know the autogen, as it is activated by default (automatically) and always creates variables for all available data points. This approach /*FIXME možná v tomto případě tedz approach? */ is optimal if you are starting with Mervis. However, if you want to work on a specific project, **knowledge of working with the Autogen function is essential** and it is, therefore, necessary to have the solution in [[creating-new-project-hidden#switching_to_full_mode|Full mode]]. 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. ;;# Patron \\ Neuron \\ Gate \\ Unipi 1.1 \\ Axon ;;# 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. */ ===== What is Autogen? ===== 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-Wire, M-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. ---- What is a data point? \\ 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 a variable for it, which can already be used in the program. ---- The most important part of Autogen is the file **generated.Mixed.st**, which is automatically generated by this function, and any manual intervention in this file can cause unavailability of inputs and outputs or unexpected behavior. Therefore, **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**. ===== How is Autogen used? ===== There are two variants of how Autogen can be used, and each variant has its advantages and disadvantages. - 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. \\ ==== 1. For the whole device/channel ==== === 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. ---- First, open your project with the assigned unit in Full mode. Then right-click on a specific device and select **Set Autogen**: {{ :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. What attributes are and what they can be used for is described in detail in article [[comm-attributes-hidden|]]. 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 |}} ---- You have two options: - 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 |}} ---- You have two options: - Right-click on the data point, select **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 |}} ---- You have two options: - 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. 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.