Declaring a Method that is Associated with an Aggregate
When you declare a method for an aggregate, you need to use a slightly different format to that which is required for database item methods. The difference is that you have to include the aggregate name in the path of the database item.
So, the format for entering an aggregate method is:
METHOD
<Method name in program> AT %M(<path of database item>.<aggregate class>.<method name in database>): <value type>;
END_METHOD
Example:
- METHOD
- PromoteOS AT %M(PSTNOutstation.PSTN.PromoteDialOut): DINT, DINT, BOOL;
- END_METHOD
where METHOD defines the start of the method declaration.
PromoteOS is the name of the method in the ST program (the name you will use to refer to the method later in the program).
AT %M instructs the program to use a method associated with a database item (in this case, it will use an aggregate for the item).
(PSTNOutstation.PSTN.PromoteDialOut) defines the path of the database item upon which the method will be used. In this case, PSTNOutstation is the name of the database item. PSTN is the name of the aggregate class and PromoteDialOut is a reference to the name of the method that is to be performed. The name has to be identical to the name of the method as it appears in the ClearSCADA database schema.
DINT, DINT, BOOL; sets the value types that will be used by the method.
In this case, the method will use two DINT values and a BOOL value, for example, an interval, a duration, and an immediate start state. The method could then be used to promote the outstation at a set interval (defined by the first DINT value), for a set duration (defined by the second DINT value), and could start immediately or be delayed depending on the state of the BOOL value.
END_METHOD defines the end of the declaration.
For example, in the program the method could be used like this:
- IF Input.CurrentValueFormatted <50 THEN
- Override (80.5);
- AccAlarm();
- END_IF;
- PromoteOS (900, 3600, TRUE);
This code works by setting the program to override the input current value to 80.5 if the current value is reported as less than 50. If the override has to be used, an alarm is raised (AccAlarm) and the outstation is promoted every 15 minutes (900 seconds) for a total of 1 hour (3600 seconds) and starts immediately (TRUE).