Object Orientation
Object orientation is a paradigm of system software analysis, project, and programming based on the composition and interaction among several software units called objects.
In object-oriented programming, you implement a set of classes which define the existing objects in the software system. Each class determines the behavior (defined on methods) and possible states (attributes) of its objects, as well as the relationship with other objects.
The Class represents a set of objects with common features. A class defines the behavior of objects through its methods, and which states it is capable of keeping through its attributes. For example, Dog is a class, and a certain dog named Rex is an object belonging to that class.
The Attributes are the features of an object, that is, the data structure representing the class. For example, the attributes of a Dog object are name, breed, age, color, etc. Each one of these attributes can be filled in with any value, as Rex for the dog name or brown as its hair color.
E3 Objects
A Demonstration Tag is a class (DemoTag) which has several attributes:
Figure 1
When inserting a Demo Tag in the application, you instantiate an object of type DemoTag, and each Tag may have a different value for each property.
Figure 2
When creating a link to a Demo Tag or writing a script which uses the Demo Tag, you choose the Demo Tag object and which one of its properties you want to access. For example, if you want to watch a Demo Tag value in a Display, you get the Tag and the Value property using the AppBrowser. If you want to view the maximum value the Tag can reach, you get the Tag and the Maximum property. So, all Links have the path ObjectName.PropertyName
. For example:
Figure 3
Properties of XControls and XObjects
When creating an XControl or an XObject, you can create properties for these objects. These properties can be of type String, Integer, Boolean, etc., and also can be a class: DemoTag, InternalTag, IOTag, etc.
As an example, let’s make settings in order to change the configurations of a Demo Tag at run time. So, we are going to develop an XControl (DemoTagConfig
) which can change the Minimum, Maximum, and Enabled properties of the Tag, and which displays its name and value.
Figure 4
Instead of creating five properties (Name, Value, Maximum, Minimum, and Enabled) in the XControl, create a property of type DemoTag. Then, you have access to all Demo Tag properties:
Figure 5
To link every property with its respective screen object (Display, SetPoint, Button, etc.), you must follow these steps:
- Access the Links tab of the screen object.
- Using the AppBrowser, get the XControl or the XObject.
- Select the property created, of type Class
Figure 6
- In the lower field of the AppBrowser, type
.PropertyName
.
Figure 7
The path of the link is ElipseXName.CreatedPropertyName.PropertyName
. For the other objects of this XControl, you have:
- DemoTagConfig.Tag.Name
- DemoTagConfig.Tag.Enabled
- DemoTagConfig.Tag.Maximum
- DemoTagConfig.Tag.Minimum
Accessing objects inserted into XControls and XObjects
Sometimes, you must access an object inserted into an XControl or an XObject using an application. For examplo:
Figure 8
How to access a Counter Tag using a screen object?
To do so, the easiest way is to create a property with the object type (in this case, CounterTag) and link it to the object. To link an ElipseX property (XControl or XObject) to one of the objects inserted into itself, drag the object to the Initial Value field.
Figure 9
Any information from the Counter Tag can be obtained using the Tag property just created (remember using the syntax Property.Property
). For examplo:
Figure 10
To view the value of a Counter Tag which exists in the XObject Cronometer1
on Screen, create the following Link on Screen Display: Data.Cronometer1.Tag.Value
.
Exercises
- Create an XControl named
DemoTagSum
with the following settings:
- It must display values from two Demo Tags in Displays.
- In case the value of the Demo Tag is 70% of the maximum value, the Display text must be in red.
- A third Display must show the sum of values from two Tags.