Configuring Rotation and Movement¶
You can animate a visualization element so that is moves or rotates in runtime mode. To do this, you assign variables in its property
and program the animation in the application code.Configuring movement
You can configure the movement of an element by programming the variable in
.Open the visualization and added a Rectangle element.
- ⇒
The Properties view shows the configuration of the element.
In the application, declare variables with matching types in the
PLC_PRG
POU:diOffsetX : DINT;
anddiOffsetY : DINT;
Configure the property
withPLC_PRG.diOffsetX
and Y withPLC_PRG.diOffsetY
.Implement a movement of the element, for example by a modulo division of the value:
diOffsetX := diOffsetX MOD 100;
diOffsetY := diOffsetY MOD 100;
Compile, download, and start the application.
- ⇒
The application runs. The visualization opens. The rectangle moves.
Configuring a rotating element
When an element rotates, the midpoint of the element rotates precisely on its center. The center is defined in the property
. The midpoint of an element is calculated internally. When the midpoint and the center come together, there is no rotation.You can configure a clockwise rotation of the element by increasing the value of the variable
.Open the visualization and added a Rectangle element.
- ⇒
The Properties view shows the configuration of the element.
In the application, declare a variable with matching type in the
PLC_PRG
POU:rValue : REAL;
.Configure the property
withPLC_PRG.rValue
.Implement the clockwise rotation of the element by increasing the value of the variable:
rValue := rValue + 0.1;
Compile, download, and start the application.
- ⇒
The application runs. The visualization opens. The rectangle rotates about the center. The alignment of the element is fixed according to the coordinate system.
Configuring a rotating element
When an element executes an internal rotation and rotates, the midpoint of the element rotates precisely on its center. That is the point defined in the
property. Then the alignment of the element also rotates with respect to the coordinate system. If the midpoint of the element and center come together, then a rotation at that position results.If the visualization is in runtime mode, then you can see that the element rotates (also in relation to the coordinate system of the visualization).
Open the visualization and add a Polygon element that you shape into a pointer.
- ⇒
The Properties view shows the configuration of the element.
Specify a static angle of rotation also in the property
.⇒
Drag the center point of the element to the base of the pointer.
In the application, declare a variable with matching type in the
PLC_PRG
POU.rValue : REAL;
Configure the property
withPLC_PRG.rValue
.Implement the clockwise rotation of the element by increasing the value of the variable.
rValue := rValue + 0.1;
Compile, download, and start the application.
- ⇒
The application runs. The visualization opens. The pointer rotates about its base. The angle of rotation increases continuously starting at the position that determines the static angle of rotation, because the static angle of rotation is added to the angle of rotation. The static angle of rotation acts as an offset.
See also