You are here: Core Reference > Coding > Scripting > Using a Script to Issue Two Controls from One Pick Action

Using a Script to Issue Two Controls from One Pick Action

You can use a script to allow a single pick action to issue two controls. This is useful when multiple responses are required to a specific occurrence.

Example:

In the following example, a script is used to allow a point override control and an acknowledge alarm control to be performed when a Mimic item is selected. When a user selects the Mimic item (in this case, a water tank), an alarm is acknowledged for a point named 'Water Control', and the same point is overridden to have its value set to 50. The script for the two controls is:

  • Public Function TankEmergency (sTankControl)
  • Dim oTankPoint
  • Set oTankPoint = Server.FindObject(sTankControl)
  • If Not (oTankPoint Is Nothing) Then
    • oTankPoint.Interface.AcceptWithComment "Alarm Acknowledged via Mimic"
    • oTankPoint.Interface.Override 50
    • Set oTankPoint = Nothing
  • End If
  • End Function

The start of the script defines the name of the script and its variables:

  • Public Function TankEmergency (sTankControl)
  • Dim oTankPoint

The script is named TankEmergency and it has a string value and one variable: sTankControl (the string value) and oTankPoint (the variable).

The script sets the oTankPoint variable to apply the control to the object that is defined by the sTankControl value. The sTankControl value is the database item that is specified on the Pick Action Wizard for the tank item on the Mimic. In this case, the sTankControl value is the 'Water Control' point.

When the tank item on the Mimic is selected, the Acknowledge With Comment control is applied to the 'Water Control' point. The alarm for the point is acknowledged, and the comment for the alarm is "Alarm Acknowledged via Mimic". This is defined by the following section:

  • oTankPoint.Interface.AcceptWithComment "Alarm Acknowledged via Mimic"

When the Acknowledge With Comment control has been performed, another control is performed—an Override is performed on the 'Water Control' point. The Override sets the value of the point to 50.

This is defined by the following line:

  • oTankPoint.Interface.Override 50

When the controls have been performed, the oTankPoint variable is set to nothing so that it is removed from memory. This is defined by the line:

  • Set oTankPoint = Nothing

The script has to be associated with a Script pick action for the water tank Mimic item. To do this, the Pick Action Wizard is displayed for the water tank item and the Script option is selected on the first 'page' of the Wizard. On the second 'page', the Mode is set to Call Specific Function (as the TankEmergency function is to run when the Mimic item is selected). The Function is set to TankEmergency and the Permission is set to Read (the pick action will be available to users with the Read permission, which is usually every user on the system).

On the third 'page' of the Wizard, the sTankControl argument values are edited. On the Expression window for the argument, the name of the database item that is represented by the sTankControl variable is defined. In this case, the argument is defined as:

".Water Control.FullName"

as the 'Water Control' point is located in the root of the system (as is the Mimic that contains the water tank item). The FullName property of the 'Water Control' point is returned. By using an OPC Tag rather than a constant reference, the pick action will still apply to the 'Water Control' point if the name of the point changes (the pick action is set to use the FullName property of the point).

NOTE: When referencing a database item for a script pick action, you can use a constant reference which requires single quotations (as shown in the example) or you can refer to an OPC tag which uses double quotations " ").

A pick action comment is set on the next 'page' of the Wizard, and then the pick action configuration is completed when the Finished button is selected on the final 'page'.

When the Mimic is displayed in Run mode, selecting the water tank item causes the script to run. This acknowledges an alarm for the 'Water Control' point (if there is an alarm) and sets the alarm comment for the acknowledge control to be 'Alarm Acknowledged via Mimic'. The script also causes the 'Water Control' point to be overridden with a value of 50.


ClearSCADA 2015 R2