In the main visualization, the “Frame” element displays one of the referenced frame visualizations at runtime. The user can select the “Radio Buttons” element which is displayed in the frame.
Connecting frame visualizations with a radio buttons element
-
Create a new standard project in CODESYS.
-
Select the application in the device tree and click “Add Object Visualization”.
-
In the “Add Visualization” dialog, specify the name
VisuMain
and click “Add” to close the dialog. -
Select the application in the device tree and click “Add Object Visualization”.
-
In the “Add Visualization” dialog, specify the name
Visu1
and click “Add” to close the dialog. -
Select the application in the device tree and click “Add Object Visualization”.
-
In the “Add Visualization” dialog, specify the name
Visu2
and click “Add” to close the dialog. -
Select the application in the device tree and click “Add Object Visualization”.
-
In the “Add Visualization” dialog, specify the name
Visu3
and click “Add” to close the dialog.In addition to the main visualization, there are three more visualization objects.
-
Open the
Visu1
object. -
In the “Visualization ToolBox”, in the “Basic” category, select and drag the “Radio Buttons” element to the visualization editor.
The “Properties” view of the element opens.
-
Configure the properties of the rectangle as follows:
-
“Texts”, “Text” property:
Visu1
-
“Text properties”, “Font” property: “Title”
-
“Colors”, “Normal state”, “Fill color” property: “Light gray”
-
-
Program the object
Visu2
accordingly.Properties of the rectangle:
-
“Texts”, “Text” property:
Visu2
-
“Text properties”, “Font” property: “Title”
-
“Colors”, “Normal state”, “Fill color” property: “Gray”
-
-
Program the object
Visu3
accordingly.Properties of the rectangle:
-
“Texts”, “Text” property:
Visu3
-
“Text properties”, “Font” property: “Title”
-
“Colors”, “Normal state”, “Fill color” property: “Dark gray”
-
-
Open the
VisuMain
object. -
In the “Visualization ToolBox”, in the “Basic” category, select and drag the “Frame” element to the visualization editor.
The “Frame Configuration” dialog opens.
-
In the “Available Visualizations” window area, on the “By Visualization Name” tab, select the object
Visu1
. In “Selected Visualizations”, click “Add”. -
Then select the object
Visu2
and click “Add” in “Selected Visualizations”. -
Then select the object
Visu3
and click “Add” in “Selected Visualizations”. -
Click “OK” to exit the dialog.
Now the “Frame” element references the three selected visualizations. The references (1) are listed in the “References” property in the element properties of the “Frame” element. In addition to the visualization name, the corresponding index value (2) is also displayed.
Note: You can open the dialog when you click the “Configure” button in the value field of the “References” property. See (3). You can influence the index by means of the visualization order in the “Selected Visualizations” list.
-
In the “Visualization ToolBox”, in the “Common Controls” category, drag the “Radio Buttons” element to the visualization editor.
The “Properties” view of the element opens.
-
In the “Radio button settings”, “Radio button”, click the “Create new” button.
This element has three switches to select from.
-
Configure the properties of the radio button as follows:
-
“Radio button settings”, “Areas”, “[0]”, “Text” property:
Visu1
-
“Radio button settings”, “Areas”, “[1]”, “Text” property:
Visu2
-
“Radio button settings”, “Areas”, “[2]”, “Text” property:
Visu3
-
-
In the
PLC_PRG
program, declare a local variable for the number of the visualization that is active.VAR iActiveVisu : INT; // Index of visu activated by the user END_VAR
-
Select the “Radio Buttons” element and in the value field of the “Variable” property, click the
button.
-
In the “Input Assistant” dialog, select the recently declared variable. Then exit the dialog.
Property of the “Radio Buttons” element:
-
“Variable”:
PLC_PRG.iActiveVisu
-
-
Select the “Frame” element. Click in the value field of the “Switch frame variable”, “Variable” property. Specify the recently declared variable here as well.
Property of the “Frame” element:
-
“Switch frame variable ”, “Variable” property:
PLC_PRG.iActiveVisu
The control variable of the “Radio Buttons” element is also the switch frame variable of the “Frame” element. User input for the “Radio Buttons”element switches the frame visualization.
-
-
Click “Build Generate Code”.
-
Click “Online Login” and start the application.
The visualization starts. One of the referenced visualizations is running in the frame. When you click an unselected option of the “Radio Buttons” element, the visualization switches the contents in the frame to the desired visualization.
In the example, the switch frame variable is connected to an input variable. Instead, you can also set the switch frame variable programmatically in the IEC code.