The example shows a visualization with 3 screens. A menu controls the navigation of the screens. The menu is hidden until it moves into view by means of a hamburger button. During the movement, the transparency of the menu is changed. After the screen is selected, the menu moves back out of view. The animation is computed entirely on the target system. The CODESYS visualization only defines the target values (positions, transparency).
Create a new standard project with the CODESYS Control Win V3 controller.
Add a Visualization object below the Application. Choose the name Visu_Main
.
Remove the TargetVisu object below the Visualization Manager.
Open the Visualization Manager in the editor and select the Preview: Support client animations and overlay of native elements option.
See also
The program checks whether the menu button has been pressed. If the menu bar is not visible (position –300), then the position is moved to the visible area (0). If the menu bar is already visible (position 0), then the position is moved to the hidden area.
Open the PLC_PRG program in the editor.
Input the following code into the declaration editor:
PROGRAM PLC_PRG VAR iSelection : INT; // to switch the referenced visualization page xVisible: BOOL; // auxiliary variable to toggle the menu bar iMenuPos : INT := -300; // position of the menu bar xToggle: BOOL; // button variable to toggle the menu bar END_VAR
Input the following code into the implementation:
IF xToggle THEN xToggle := FALSE; IF xVisible THEN xVisible := FALSE; iMenuPos := -300; ELSE xVisible := TRUE; iMenuPos := 0; END_IF END_IF
Insert the "Visu1" visualization below the application.
Open the object properties. In the Visualization tab, set the Visualization size to a Width of 800 and a Height of 600.
Change the background color of the screen (for example, light gray).
Insert a Label object into the visualization screen and name the element (example: "Visu 1").
Insert two more visualizations "Visu2" and "Visu3" below the application. Edit the properties in the same way as for "Visu1".
On this screen, you can see the menu bar and a button to show or hide the menu bar. The different visualization screens are navigated in a Frame visualization element.
Open the properties of the Visu_Main visualization. In the Visualization tab, set the Visualization size to a Width of 800 and a Height of 600.
Open the visualization in the editor.
Insert a Frame element into the visualization.
⇒ The Frame Configuration dialog opens.
Add the Visu1 (Index 0), Visu2 (Index 1), and Visu3 (Index 2) visualizations.
Set the property values of Position as follows: X = 0
, Y = 0
, Width = 800
, and Height = 600
.
Set the property value of PLC_PRG.iSelection
.
Insert a Button element into the visualization.
Set the property values of Position as follows: X = 0
, Y = 0
, Width = 60
, and Height = 60
.
Set the property value of =
.
Set the property value of Arial; 36
.
Open the
property.Select the Execute ST-Code action.
Input the following ST code:
PLC_PRG.xToggle := TRUE;
Set the property value of PLC_PRG.xVisible
.
Insert the Visu_Menu visualization element from the Current Project category into the visualization.
Set the property values of Position as follows: X = 0
, Y = 0
, Width = 300
, and Height = 180
.
Set the property value PLC_PRG.iMenuPos
.
Set the property value of not(PLC_PRG.xVisible)
.
Set the property value of Animation duration to 2000
.
⇒ Result:
See also
Build the project and download it to the PLC.
Start the project.
In the browser, connect to the visualization (http://localhost:8080
).
⇒ The WebVisu connects to the controller and the visualization opens.
In the visualization, click the menu button.
⇒ The menu moves into view.
Select a menu item.
⇒ The visualization screen is selected and the menu moves back out of view.
See also