Examples of Alarm and Event Calculations

Important: You do not have the latest version of Historian! You are missing out on the newest capabilities and enhanced security. For information on all the latest features, see the Historian product page. For more information on upgrades, contact your GE Digital sales agent or e-mail GE Digital Sales Support. For the most up-to-date documentation, go here.

Check the Value of a Tag and Issue an Alarm

This example checks the current value of tag D2R9R41D3.Simulation00001. If it is above 5000, an alarm is issued using the source Simulation00001_ALM. The tag name is recorded, the condition Simulated is created, a subcondition of HI and a severity of 750 is assigned.

Example Code

If CurrentValue("D2R9R41D3.Simulation00001") > 5000 Then
   Set AlarmObj = new Alarm 
   AlarmObj.SubConditionName = "HI" 
   AlarmObj.Severity = 750
   AlarmObj.NewAlarm "Simulation00001_ALM", "Simulated", "D2R9R41D3.Simulation00001", "Now" 
End If

Set Calculation to Severity of Previous Alarm

This example sets the result of the calculation to the severity of the previous alarm for source Simulation00001_ALM with a condition of Simulated.

Code Example

Set AlarmObj = PreviousAlarm("Simulation00001_ALM", "Simulated", "Now")
If Not(AlarmObj Is Nothing) Then
   Result = AlarmObj.Severity
Else
   Result = 0
End If

Get Previous Alarm for a Specific Tag

This example checks the last alarm for the tag D2R9R41D3.Simulation0001 with a condition of Simulated. If the alarm is open, it sets the alarm to return to normal.

Example Code

Set AlarmObj = PreviousAlarmForTag("D2R9R41D3.Simulation00001", "Simulated", "Now") 
If Not(AlarmObj Is Nothing) Then
   If AlarmObj.EndTime < AlarmObj.StartTime Then
      AlarmObj.ReturnToNormal "Now" 
    End If
End If

Count all Alarms for a Specific Tag

This example counts all the alarms for a specific tag through the use of a while loop.

Example Code

count = 0
Set AlarmObj = PreviousAlarmForTag("Simulation00001", "Simulated", 
"Now 1Second") While Not(AlarmObj Is Nothing)
  count = count + 1
  Set AlarmObj = PreviousAlarmForTag(AlarmObj.Tag, AlarmObj.ConditionName, DateAdd("s", -1, AlarmObj.StartTime)) Wend

result = count