Native Alarms and Events Functions
About Native Alarms and Events Functions
In addition to using the calculation wizard to create calculation formulas within your calculation tag, you can enter functions manually. The following sections list the functions available, along with their usage.
Retrieving and Setting Alarm Properties Manually
About this task
Procedure
Insert Calculation Functions Manually
In addition to using the Calculation Wizard to create your alarms and events calculations, you can also enter them manually. The following functions are available:
- NextAlarm
-
The
NextAlarm
function returns the next alarm for a tag or source on or after a given time stamp.Syntaxset AlarmObj = NextAlarm (source, condition, timestamp)
Example Code
The following example will get the next alarm based on the properties of the current alarm object.Set AlarmObj = NextAlarm (AlarmObj.Source, AlarmObj.ConditionName, DateAdd("s", 1, AlarmObj.Timestamp))
- NextAlarmForTag
-
The
NextAlarmForTag
function is identical to theNextAlarm
function, but takes a tag name as its input instead of a source.SyntaxSet AlarmObj = NextAlarmForTag (tag name, condition, timestamp)
Example Code
The following example will get the next alarm for the tagSYN4450_Flow
with aLevelAlarm
condition on or after the current alarm's timestamp.Set AlarmObj = NextAlarmForTag ("SYN4450_Flow", "LevelAlarm", AlarmObj.Timestamp)
- PreviousAlarm
-
The
PreviousAlarm
function returns the previous alarm for a tag or source on or before a given timestamp.Syntaxset AlarmObj = PreviousAlarm (source, condition, timestamp)
Example Code
The following example will get the previous alarm based on the properties of the current alarm object.Set AlarmObj = NextAlarm (AlarmObj.Source, AlarmObj.ConditionName, AlarmObj.Timestamp)
- PreviousAlarmForTag
-
The
PreviousAlarmForTag
function is identical to thePreviousAlarm
function, but takes a tag name as its input instead of a source.SyntaxSet AlarmObj = PreviousAlarmForTag (tag name, condition, timestamp)
Example Code
The following example will get the previous alarm for the tagSYN4450_Flow
with aLevelAlarm
condition on or before the current time.Set AlarmObj = PreviousAlarmForTag ("SYN4450_Flow", "LevelAlarm", "Now")
- AddEvent
-
The
AddEvent
method will create a new event with the current alarm properties.SyntaxAlarmObj.NewAlarm source, tag, time stamp
Example Code
The following example creates a new event for theSimulation00001
tag onSimulation
source with a severity of50
, a message ofTest Message
, and the current time.Set AlarmObj = new Alarm AlarmObj.Severity = 50 AlarmObj.Message = "Test Message" AlarmObj.AddEvent "Simulation", "Simulation00001", "Now"
- NewAlarm
-
The
NewAlarm
method will create a new alarm, based on the current alarm object properties.SyntaxAlarmObj.NewAlarm source, condition, tag, time stamp
Example Code
The following example creates a new alarm for theSimulation00001
tag onSimulation
source with a severity of50
, a condition ofLow Fluid Levels
, and the current time.Set AlarmObj = new Alarm AlarmObj.Severity = 50 AlarmObj.Message = "SomeMsg" AlarmObj.NewAlarm "Simulation", "Low Fluid Levels", "Simulation00001", "Now"
- NextAlarm
-
The
NextAlarm
function returns the next alarm for a tag or source on or after a given time stamp.Syntaxset AlarmObj = NextAlarm (source, condition, timestamp)
Example Code
The following example will get the next alarm based on the properties of the current alarm object.Set AlarmObj = NextAlarm (AlarmObj.Source, AlarmObj.ConditionName, DateAdd("s", 1, AlarmObj.Timestamp))
- GetVendorAttribute
-
The
GetVendorAttribute
method will get the value of the given vendor attribute on the current alarm object and place it into a supplied variable.Syntaxvariable = AlarmObj.GetVendorAttribute (Vendor_Attribute)
Example Code
The following example retrieves a vendor attribute calledCause_Comment
from the alarm object, and places it into theALM_Cause_Comment
variable.ALM_Cause_Comment = AlarmObj.GetVendorAttribute ("Cause_Comment")
- SetVendorAttribute
-
The
SetVendorAttribute
method sets the value of the given vendor attribute on the current alarm object.SyntaxAlarmObj.SetVendorAttribute Vendor_Attribute, Value
Example Code
The following example sets values for the vendor attributesCause_Comment
andStatus_Code
, then updates the alarm in the Historian archive.AlarmObj.SetVendorAttribute "Cause_Comment", "This alarm was caused by..." AlarmObj.SetVendorAttribute "Status_Code", 5032 AlarmObj.UpdateAlarm "Now"
Important: TheSetVendorAttribute
method will not save changes to the alarm database. A call toUpdateAlarm
must be made after theSetVendorAttribute
method is set. - UpdateAlarm
-
The
UpdateAlarm
function updates the current alarm with whatever changes have been made to an alarm's properties.SyntaxAlarmObj.UpdateAlarm timestamp
Example CodeAlarmObj.UpdateAlarm "Now"
- ReturnToNormal
-
The
ReturnToNormal
method sets the end time for the current alarm.SyntaxAlarmObj.ReturnToNormal timestamp
Example Code
The following example sets the end time for the alarm to the current time.AlarmObj.ReturnToNormal "Now"