7 Parameterization option 2b - object oriented¶
In this section we will take a look at another way of object-oriented engineering in the atvise builder. We will create a dynamic object display for the light objects (L001,L002) in our structure as described in the previous section, but this time we will only create one display parameter for the object's base address. All data variables of the object will be addressed relatively to this base address.
Hint
Use this type of parameterization if you use multiple data variables in your object display that belong to an object type and have a clear object structure.
7.1 Adding a new object display
In the first step, we will add a new display named "Office_Light2" to the project.
Right-click on the Library ‣ PROJECT ‣ Object Displays ‣ MyObjectDisplays folder which we've created in section 6.2 and choose "Add Display".
Type in "Office_Light2" as name for the display and add it to the project by clicking OK.
Adding a second display to the MyDisplayObjects folder¶
7.2 Designing an object display
Open the "Office_Light2" display in the graphics editor.
Design an object display similar to section 6.3. You can also copy the elements from the display you have drawn in section 6.3 and remove the dynamizations afterwards.
The following steps illustrate how to remove the dynamizations from the copied elements:
Click on the circle to mark it.
Right-click on the color change entry in the dynamization area located at the lower right side of the atvise builder interface.
Choose the option from the menu which appears.
Remove the dynamization of the red border the same way.
Mark one of the three buttons by clicking on it. Delete the value of the "base" parameter in the "Attributes" area located at the middle right side of the atvise builder interface.
Delete the values of the base parameters of the remaining two buttons the same way.
Deleting dynamics¶
Deleting the value of the "base" parameter¶
7.3 Creating display parameters
In this step we will define a parameter for the object's base address.
Choose from the symbol bar.
Type in "mybase" as the name for the object base parameter.
Type in a description for the parameter.
Select "mandatory" in the "Behavior" column.
Apply the edit parameters dialog by clicking OK.
Save the display.
Adding a parameter for the object's base address to the display¶
7.4 Adding dynamization
In this section we want to use predefined controls and simple dynamics to add dynamization to our object display.
7.4.1 Parameterizing the three buttons
We want to set the value of LightIntensity, so we have to parameterize the three buttons for 0 %, 50 % and 100 % light intensity.
Mark one of the three buttons by clicking on it.
On the right side, you can see a list of all parameters of the referenced control. Set the text of the button by entering "0" in the "label" field.
3 To set its "base" parameter, click the
button to activate relative addressing.
Use the drop-down list to choose "mybase".
Enter ".LightIntensity" into the address field manually as the relative part. (Don't forget the ".")
Set the "value" parameter by entering "0". This value will be set to the base when the button is clicked.
Parameterize a button with the label "50" and value "50" the same way.
Parameterize a button with the label "100" and value "100" the same way.
Parameterizing the three buttons¶
7.4.2 Color change of the light bulb to display the light intensity
In this section, we want to add a simple dynamic to our bulb to display the light intensity.
Click on the circle of the bulb to mark it and open the "Simple Dynamics" dialog as described in section 5.3.1
Hint
The simple dynamics in this section will be similar to section 6.5. The only new thing is that we will address our data variables relatively with reference to the object's base address.
Choose
from the possibilities on the left.Click on the button
to activate relative addressing.Use the drop-down list to choose "mybase".
Enter ".LightIntensity" into the address field manually (Don't forget the "."). ".LightIntensity" is the relative part which is found in all base objects.
Choose "Number" as the value type.
We want to change the color of the circle, so we choose
to the left in the ACTION part.The range of our "LightIntensity" variable is from 0 - 100 so we choose "Value Range" as the type and then type in the minimum and maximum value.
We want to display the circle in a color range from gray to yellow, so we check the fill box and choose a gray color as the start fill and a yellow color as the stop fill by clicking on
.Hint
If the value of the data variable is 0, the start fill will be displayed, if it is 100, the stop fill will be displayed. Values in between are merged according to the gradient from the start fill to the stop fill.
We are now finished with the dynamization. Apply the dialog by clicking "OK".
"Simple Dynamics" dialog for the circle of our light bulb¶
7.4.3 The visibility of the malfunction border
Mark the red border and start the "Simple Dynamics" dialog.
Choose
from the possibilities on the left.We want to add a relative address, so click the
button.Use the drop-down list to choose "mybase".
Enter ".InternalMalfunction" into the address field manually as relative part (Don't forget the ".").
Choose "Boolean" as the value type.
We want to change the visibility of the border, so choose
in the ACTION part.If the value is true, we want the border to be visible, so choose "visible" for this condition. Add a second condition by clicking on
, changing the value column to "false" and choosing "invisible".Apply the "Simple Dynamics" dialog by clicking OK.
Changing the visibility of the border in dependence on a VariableBoolean¶
Now we have finished the engineering of our object display.
7.5 Adding objects to Light_Background
Open the "Light_Background" display (which we added in step 6.1).
Drag & drop the "Office_Light2" object display into the "Light_Background" display.
Make sure the "Office_Light2" object is marked. On the right of the atvise builder interface, you will see a list of all its parameters.
Select "L001" as the address for the "base address of the object" parameter using the
selector.Drag & drop the Objects ‣ L001 ‣ InternalMalfunction variable into the "Light_Background" display. A small button will appear which can be used to set the variable in the visualization.
Repeat steps 2 to 5, but now choose "L002" as the "base address of the object" and drag & drop Objects ‣ L002 ‣ InternalMalfunction into the display .
Position the 2 displays in 2 different rooms of the office plan.
Dragging & dropping the "Office_Light2" display into the "Light_Background" display and setting the base parameter¶
7.6 Generating and viewing the visualization
Save the display by clicking
and generate the visualization by choosing . Then start a web browser (as described in section 4) and view the "Light_Background" display in the visualization. Set the value of the light intensity of one of the objects using the three buttons and see how the color of the bulb changes. Also use the InternalMalfunction buttons to make the red border appear and disappear.