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/09/21 13:02]
mkudlacek
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 thing 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, therefore, necessary ​to have the solution ​in [[creating-new-project-hidden#​switching_to_full_mode|Full mode]].
-Setting ​Autogen ​on whole device ​is a nice feature for debugging. You tell the Mervis Runtime ​to poll all the inputs and outputs and you have them immediatelly 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 informations,​ which are needed ​in special cases and you don't need them for normal operation. Also polling unnecessary information from the [[en:hw:04-extensions|Extensions]] over slow RS485 bus will have 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 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 to. Or the project will be handed over to somebody else who will not have that knowledge and the project will be hard to readYou can now probably understand, that using the default, generated names is not a good practice.+<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>​
  
-For making fast and readable projects, the Mervis includes functionality for renaming the inputs/​outputs to your liking. Let's create a simple project where we want to: 
  
-  * read current state of button connected ​to the DI 1.1 +===== What is Autogen? ===== 
-  * copy the state of the button to the DO 1.+Autogen is tool in the Mervis IDE that is used to create variables for data points, respectively inputs, and outputs ​of the whole solutionThese are not only inputs ​and outputs directly on the unit, but also devices connected using various protocols: Modbus1-Wire, M-bus, BACnet, etc. The devices can be units or Unipi Extension modules, sensors, electricity meters, etc.
-  * count the number of presses ​and save it to the variable "​number_of_presses"​ +
-  * if the number of presses are larger then 20light up a LED X1+
  
-It is a good practice to start with the inputs and outputs, especially with the HW IOs. So 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":+It also allows ​the custom naming ​of generated variables.
  
-To rename the input, fill the value in the column "​Autogen Name". The DI_1.01 is for button, so let's rename it to "​button"​.+----
  
-Now set the autogen ​for this variableRight click on the variable ​and in the context menu click on the "Set Autogen"​ and confirm the dialog by clickin on **OK**.+<​html><​span class="​kbBlueText">​What is a data point?</​span></​html>​ \\ 
 +A data point is a definition of communication ​for a specific input or outputThe data type (bool, byte, int, ...) and possibly other parameters specific to the selected communication type are defined directly ​on the data point.
  
-Repeat this process ​for other two IOs. The DO_1.01 will be called a "​button_indicator"​ and ULED_1.01_w will be called "​button_error"​. +To use the data point, it is necessary to create a variable ​for it, which can already ​be used in the program.
-Now we can switch to the programming window and start placing the IOs to their respective columns. Right click on the input column and in the context menu click on "​Global Variables"​ -> "​Insert Existing Variable"​. The list should be very small and apart from some global constants you should see the three variables you have created.+
  
 +----
  
 +<WRAP center round important 95%>
 +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**.
 +</​WRAP>​
 +
 +
 +
 +===== 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.
 +
 +<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>​
 +
 +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 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 |}}
 +
 +----
 +
 +<​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.
 +
 +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.