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.

Syntax
set 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 the NextAlarm function, but takes a tag name as its input instead of a source.

Syntax
Set AlarmObj = NextAlarmForTag (tag name, condition, timestamp)

Example Code

The following example will get the next alarm for the tag SYN4450_Flow with a LevelAlarm 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.

Syntax
set 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 the PreviousAlarm function, but takes a tag name as its input instead of a source.

Syntax
Set AlarmObj = PreviousAlarmForTag (tag name, condition, timestamp)

Example Code

The following example will get the previous alarm for the tag SYN4450_Flow with a LevelAlarm 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.

Syntax
AlarmObj.NewAlarm source, tag, time stamp

Example Code

The following example creates a new event for the Simulation00001 tag on Simulation source with a severity of 50, a message of Test 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.

Syntax
AlarmObj.NewAlarm source, condition, tag, time stamp

Example Code

The following example creates a new alarm for the Simulation00001 tag on Simulation source with a severity of 50, a condition of Low 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.

Syntax
set 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.

Syntax
variable = AlarmObj.GetVendorAttribute (Vendor_Attribute)

Example Code

The following example retrieves a vendor attribute called Cause_Comment from the alarm object, and places it into the ALM_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.

Syntax
AlarmObj.SetVendorAttribute Vendor_Attribute, Value

Example Code

The following example sets values for the vendor attributes Cause_Comment and Status_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: The SetVendorAttribute method will not save changes to the alarm database. A call to UpdateAlarm must be made after the SetVendorAttribute method is set.
UpdateAlarm

The UpdateAlarm function updates the current alarm with whatever changes have been made to an alarm's properties.

Syntax
AlarmObj.UpdateAlarm timestamp
Example Code
AlarmObj.UpdateAlarm "Now"
ReturnToNormal

The ReturnToNormal method sets the end time for the current alarm.

Syntax
AlarmObj.ReturnToNormal timestamp

Example Code

The following example sets the end time for the alarm to the current time.
AlarmObj.ReturnToNormal "Now"