Method Tags
NOTE: Tags do not apply to Template expressions, instead you use Template Parameters.
To call one of a database item's methods, use the following syntax:
"<Item>.<Method>(<Argument 1>,<Argument 2>, ...)"
"<Item>.<Database Aggregate>.<Method>(<Argument 1>,<Argument 2>, ...)"
Where:
<Item>
is the name and location of the database item that has the method that you want to call (see Relative and Absolute References)<Method>
is the name of the method<Argument 1>
is the value passed as the first argument to the method<Argument 2>
is the value passed as the second argument to the method<Database Aggregate>
is the name of the aggregate that contains the required method.
You can use the Database Schema to find out which database aggregates are available for a database item (see Working with the Database Schema in the Geo SCADA Expert Guide to the Database).
You can only call methods that return a value.
Example 1 - Calling a Method with no Arguments
A text box on a Mimic is to be animated so that it displays the number of forecasts that have been calculated for a forecast item. The forecast item is named 'R1 FCast'.
To achieve this, the expression for the animation calls the GetForecastCount method of the 'R1 FCast' forecast item.
The following expression is used to animate the Value property of the text box:
".R1 FCast.GetForecastCount()"
Example 2 - Calling a Method with Arguments
A text box on a Mimic is to be animated so that it displays the forecast value for a forecast item at a specific time. The forecast item is named 'R1 FCast'.
To achieve this, the expression for the animation calls the GetForecastValueAtTime method of the 'R1 FCast' forecast item.
The following expression is used to animate the Value property of the text box:
".R1 FCast.GetForecastValueAtTime (1, #22 Sep 2010#)"
Each forecast can have up to 8 sets of forecast data. The first argument defines which set of forecast data is to be used in the expression (in this case, it is 1, which is the latest set of forecast data). The second argument defines the time stamp for the value. So the text box on the Mimic shows the predicted value for 22 September 2010 from the latest forecast.
Example 3 - Calling an Aggregate's Method with Arguments
A text box on a Mimic is to be animated so that it displays today's average value for a point named 'AI'. To achieve this, the expression for the animation calls the ProcessedValue method of the Historic database aggregate for the point.
The following expression is used to animate the Value property of the text box:
".AI.Historic.ProcessedValue ('D', 'D+1D', 'Average')"
Where:
.AI
is the location and name of the point
Historic
is the name of the database aggregate that contains the data to be used by the expression
ProcessedValue
is the name of the method of the aggregate being called.
('D', 'D+1D', 'Average')
are the arguments of the method. This method has 3 arguments:
- The start time—Start of today (D)
- The end time—End of the current day (D+1D)
- The type of aggregate applied to the data—Average.
The same effect can be achieved by selecting a Historic tag on the OPC Historic Tag window (see Selecting an OPC Historic Tag).
Example 4 - Calling a Method that Returns Values
Some methods return a value that can be displayed or used as an input elsewhere in your expression. One such method is CheckAccess, which returns a True or False value depending on whether the logged on user has a specified permission for the object with which the CheckAccess method is associated. This method is often used on systems where there is a need to check which permissions are available to the logged on user.
In this example, a Mimic contains a text box and a button. When selected by the user, the button causes the CheckAccess method to be called. The CheckAccess method detects whether the user has a specific permission for a specific item, in this case, the Override permission for a point named ‘ValveAPoint’.
If the user does have the Override permission for the ‘ValveAPoint’, the text box displays ‘ ‘Override Available’; if the user does not have the Override permission, the text box displays ‘Override Unavailable - Permission Restricted’.
To make this possible, a text box is added to a Mimic. The Text animation property of the text box is configured to have this expression:
IIF(".ValveAPoint.CheckAccess ('OVR')", 'Override Available', 'Override Unavailable - Permission Restricted')"
This instructs the text box to display ‘Override Available’ if the ".ValveAPoint.CheckAccess (‘OVR’)" method returns a True value or ‘Override Unavailable - Permission Restricted’) if it returns a False value.
A button is added to the Mimic. The button’s Visible animation property is configured to have the following expression:
".ValveAPoint.CheckAccess (‘OVR’)"
This sets the button to execute the ValveAPoint’s CheckAccess method when the button is selected. The (‘OVR’) part of the expression instructs the CheckAccess method to detect if the user has the Override permission. If the user has the Override permission, the CheckAccess method returns True; if the user does not have the Override permission, the CheckAccess method returns False. The value returned affects the text that is shown in the text box.
Further Information
For information on the abbreviations for the security permissions, please see ServerObject.CheckAccess in the Geo SCADA Expert Guide to Scripting. The same abbreviations can be used when calling the CheckAccess method.