Promotic
WikipediaLinkedInYoutubeTwitterFacebook

What is an object

To better understand the object oriented language, we must explain in a more precisely way what the "object" word means. In the previous sections you have already met the term of an object several times:
 
- At first you've created the following Pma objects in the tree of Pma objects ("BoilerPlant", "Boiler1", "Data", "Panel", etc.)
- Next you have created folowing variables in the "Data" object (of the PmaData type) "Power", "Temperature" and "Status" (these are the PmVar type objects)
- Then you have created the Pmg objects (Slider, Number, etc.) in the panel.
 
The object concept can be explained several ways. For the following explanation, we can use a simple example.

We will explain the basic concepts by using the imaginary object that represents some (non-existing) window of OS Windows (this object is not real, it is used only for this explanation).

In the following examples, the variable that contains reference to this object, will be named oWindow.

 

1) Object has PROPERTIES

The "window" object can hold for example the following properties:
 
- X .. X position of the left upper angle
- Dy .. window size in the Y direction
- BackgroundColor .. background color, etc.
 
Each property has its name (X, Dy, BackgroundColor) and its value.
 
Two operations can be made with properties:
 
1) It is possible to find out the value of an property (we say that we can read the property):
JavaScriptVBScriptSelect and copy to clipboard

var nDy = oWindow.Dy;
 
2) It is possible to set the value of an property (we say that we can write into the property):
JavaScriptVBScriptSelect and copy to clipboard

oWindow.Dy = 1024;
 
Note: The previous examples (like the following ones) are only schematic and they will be explained later on. It is important to keep in mind that it is always necessary to state both the object and the property name and these two terms are separated by a period.
 
Some of the properties are intended for read and write, some of the properties are intended read only.

2) Object Holds METHODS

The "window" object can hold for example the following methods:
 
- Print .. print the window content to a printer
- SaveToFile .. save the window content into the file of the .jpg or .png type.
 
It is possible to perform only one action with the method: we can call the method. By calling a method an appropriate operation performs, for example printing to a printer.
 
The method can return a value. For example it is often returned a flag with the operation result, it can return the result of a complex calculation, etc.
 
The method can hold parameters (and it mostly does) that closer define how the operation have to be performed. For example, at the SaveToFile method it can be said by the parameter into which file the content has to be saved.
 
Examples of method calling:
JavaScriptVBScriptSelect and copy to clipboard

var Result;

//Method without parameters:
oWindow.Print();  //There is no return values
Result = oWindow.Print();  //Value is returned

//Method with parametres:
oWindow.SaveToFile("C:\\Data\\Picture.jpg");  //There is no return values
Result = oWindow.SaveToFile("C:\\Data\\Picture.jpg");  //Value is returned

3) Object holds EVENTS

The "window" object can hold for example the following events:
 
- onOpen .. opening a window was performed
- onClose .. closing a window was performed
- onMouseClick .. the mouse clicked on a window
 
Using properties and methods allows you to perform operations over object(s). But an event works exactly the opposite way – the object uses its event to tell you that something has happened to it. The event is not read, written or called – the event is triggered.
 
The event can hold parameters as well. But these parameters are not set by you (like in case of properties and methods) - by the parameters the object itself closer specifies what happened to it. For example, in case of the onMouseClick event the information would be in event parameters if the click was made by the left or by the right mouse button.
 
Each event may trigger a script that is executed once the event happens. In the PROMOTIC system each script is attached to some event therefore we call this concept event-based programming.
PROMOTIC 9.0.12 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice