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 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 Full mode.

In the tutorial, you will learn why it is necessary to manage Autogen manually and what the benefits are.

Patron
Neuron
Gate
Unipi 1.1
Axon

The subsequent tutorial follows: First project with a Unipi unit. Be sure to complete this guide before proceeding.

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 cases and only for very experienced users.

There are two variants of how Autogen can be used, and each variant has its advantages and disadvantages.

  1. Creating variables for all device data points and then turning off autogen for data points you don't use
  2. Creating only 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:


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 Communication attributes.

Now click on OK.

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.


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.

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.


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.


You have two options:

  1. Right-click on the data point, select Set autogen and confirm the dialog
  2. 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

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.


You have two options:

  1. Right-click on the data point, select Set autogen, but in the following dialog now select “Operation: Reset Autogen” and confirm the dialog
  2. 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

The deleted variable is no longer available among other 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.

For these and other reasons, it is advisable to name the variables, e.g.: OK_panel1, Off_bedroom, etc.


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.


You have two options:

  1. 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
  2. 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

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.


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 .


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.

A PLCs window with task mapping will open, where you switch to IO Mapping at the bottom.

A table with a quick overview of all data points is now displayed.


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.


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.