Interface editor
The interface editor is used to define interfaces in visualizations. The interfaces are intended for referencing in a frame on another visualization page. The editor is part of the visualization editor and appears in the upper part of the editor as a separate tab next to the editor for the hotkeys configuration and the element list.
Interface declaration
Since a visualization is treated as a function block, the interface editor appears as a normal declaration editor in the upper part of the visualization editor. Input variables, such as frame parameters, can be found here.
Parameter declarations
- VAR_INPUT
- VAR_INPUT with attribute 'parameterstringof': A variable with this attribute is given as its value the name of the variable that is set to a to-be-defined input variable when called in a frame element.
VAR_INPUT
{attribute 'parameterstringof' := 'bInput'}
sVarName : STRING;
bInput : BOOL;
END_VAR
- VAR_IN_OUT: If a data structure is transferred, it has to be defined as VAR_IN_OUT. Without pragma, the parameter values are copied when the visualization is opened. Entries are written to the copied data structure. When the visualization is closed, the values are written back to the parameters.
- VAR_IN_OUT with VAR_IN_OUT_AS_POINTER attribute: Objects are allowed to be transferred as references to visualizations. This can be useful in situations where information is to be transferred to a visualization without actually copying the information, or for updating information from outside, while the dialog is open. This attribute is only permitted for visualizations that are set and used as dialogs.
Example
The ViewData visualization uses the interface stUserData of type ST_UserData. The visualization element GenElemInst_1 of the ViewData visualization is user-based and shows the variable value of stUserData.sName, as programmed in the View properties of GenElemInst_1.
Programming of frame
To program a frame element, proceed as follows:
- Add a frame element in your main visualization.
- Set the reference to a visualization with interface, which can be stored in a library.
- Assign a variable to each frame parameter.
Example
The Frame visualization element references the ViewData visualization. In Properties view, the assignment is listed together with all frame parameters. Click in the value field of a such variable to assign a variable of the same type. MAIN.stHansData is also assigned here.
Updating the frame parameters
If the interface of a visualization that was added to a frame is modified, the dialog shown in the example is opened automatically when the project is saved or compiled, or when an affected object is opened. You can then adjust the frame parameters in this dialog. If the interface of a visualization that originated from a library was modified, the parameters in your project also have to be updated.
Parameter | This column shows the modified parameters in a tree view. First, the visualization is listed, then the corresponding frame with the reference to the modified visualization. Below this, the currently valid parameters are listed, followed by the previous parameters. |
Type | This column shows the parameter type. |
Value | The value field contains the variable that was assigned to the parameter. Note the color of the field:
|
Edit values
To edit values, select the value field with a mouse click. Click in the field or press the space bar to open a line editor. Or simply start typing, once you have selected the field. To assign a different variable, type its name or select a variable using the input wizard.
An existing value entry can be copied to another field. Select the entry to be copied, use "Copy" and select the field in which you want to insert the entry, then use "Paste".
Confirm the setting in the dialog with "OK". The dialog closes, and the new parameter assignments can be displayed in the References category under Properties view and the corresponding frame element.
Using instance names in the visualization To use an instance name of a transferred variable within the referenced visualization function block, use the pragma attribute 'parameterstringof', which provides a corresponding string. |
Example
The interface of the ViewData visualization has been extended with the variable bLoggedIn:
VAR_IN_OUT
stUserData : ST_UserData;
bLoggedIn : BOOL;
END_VAR
The following dialog for configuring the new parameter appears when a project is compiled or saved:
It contains a comparison between the current and the previous parameters. bLoggedIn was assigned the new value TRUE. Once the dialog has been closed with OK, the new parameters can also be reproduced in the properties of the frame element.
Pragmas
The following two parameters can be used in the interface editor.
- Attribute "VAR_IN_OUT_AS_POINTER"
- Attribute 'parameterstringof'