GetAlarmInfo

This function gets information about an active alarm.

Function Group Execution Windows Embedded Thin Client Mobile Access
GetAlarmInfo Tags Database Synchronous Supported Supported Not supported (see “Notes” below) Not supported (see “Notes” below)

Syntax

  GetAlarmInfo(numIndex,numInfo)  
Web Studio Help nctions tagsdb getalarminfo.xml d428165e112 GetAlarmInfo
numIndex
The index number of the alarm about which you want to get information.

The index number must be between 0 and the total number of alarms minus 1. To get the total number of alarms, use the function GetAlarmCount. For example, if GetAlarmCount returns 6, then numIndex must be between 0 and 5.

The list of alarms is sorted by the times when the alarms first became active, so that the oldest alarm is index 0. When an alarm is both normalized and acknowledged, it is removed from the list and the remaining alarms are shifted accordingly. For example, when the alarm at index 3 is removed, the alarm at index 4 is shifted to index 3, the alarm at index 5 is shifted to index 4, and so on.

Note: It is possible for an alarm to be normalized (i.e., become inactive) and then become active again without being acknowledged. That alarm will remain on the list of alarms throughout, and its Activation Time — that is, time when the alarm first became active — will not be updated.
numInfo
The information or alarm property that you want to get:
Value Alarm Property
0 Alarm Group
1 Tag Name
2 Alarm Message
3 Alarm Type
4 Tag value when the alarm became active
5 Activation Time
6 Norm Time
7 Ack Time
8 Alarm Priority
9 Alarm Selection
10 to 19 Custom Field 1 to Custom Field 10
Tip: You can create custom fields in the Alarms worksheet.

Returned value

This function returns the current value of the specified property (numInfo) of the specified alarm (numIndex). For the property Alarm Type (i.e., numInfo is 3), this function returns one of the following possible values:
Value Alarm Type
1 HiHi
2 Hi
4 Lo
8 LoLo
16 Rate of change
32 Deviation+
64 Deviation-

For all other properties, this function returns the actual value of the property. As such, the project tag or VBScript variable that you configure to receive the returned value should be of the appropriate data type. For example, you may configure an Integer tag to receive the value of Alarm Group or Alarm Type, but you should configure a String tag to receive the value of Tag Name or Ack Time. It is safest to always configure a String tag to receive the value, because a String tag can hold any value as a string, but that might make it more difficult to process the value after it is received. Please keep this in mind as you design and develop your project.

If the specified alarm has not yet been normalized or acknowledged, this function returns no values at all for the properties Norm Time and Ack Time, respectively.

If the function is not executed successfully, it returns one of the following error codes:
Value Description
-1 Function was called by a Graphics Script, Screen Script, or Command animation on a project client. (See “Notes” below.)
-2 Invalid alarm index (numIndex).
-3 Invalid alarm property (numInfo).

Notes

This function can only be executed on the project server — it cannot be called by a Graphics Script, Screen Script, or Command animation running on a thin client. For more information, see Edit the tags database during run time.

Also, this function is similar to the function TagsDBGetAlarm, except that it gets information about a specified alarm in the list of active alarms rather than about an alarm on a specified tag.

Examples

Get the type (e.g., 2, meaning Hi) of the first alarm:
  GetAlarmInfo(0,3)  
Get the name of the project tag (e.g., MyTag) that the second alarm is on:
  GetAlarmInfo(1,1)  
Get the date and time (e.g., 12/05/2013 14:11:29) when the newest alarm became active, and then use the function DateTime2UTC to convert that from the current time zone to Coordinated Universal Time (UTC):
  DateTime2UTC(GetAlarmInfo(GetAlarmCount()-1,5))  

GetAlarmInfo