Previous Topic: Link to Business Logic ModulesNext Topic: Business Logic Functions


Business Logic Procedures

In addition to known VBScript syntax, Business Logic formulas can contain special procedures as follows:

OnLoad(Time)

Called once at the start of calculations. Can be used for initializing global variables.

OnPeriodEnd(Time, IsCompleteRecord)

Called every time a period ends. IsCompleteRecord is True when the tracking period has ended and False when making an intermediate calculation.

OnPeriodStart(Time)

Called every time a new period starts.

OnRegistration(Dispatcher)

A mandatory procedure for associating events with user-defined procedures. OnRegistration is called once by the calculation engine at the beginning of the metric 's calculation.

Events are associated with procedures by using the methods of the Dispatcher object, as shown below:

Example 1

Sub OnRegistration(dispatcher)
   Dim MyResource
   MyResource = Context.ClusterItem
   Dispatcher.RegisterByResource "OnEvent", "My Event Type", MyResource
End Sub

Sub New
   Dim ThisResourceMap
   Set GlobalResourceVector= CreateObject("SlalomVector.Vector")
   Dim resource
   Set ThisResourceMap = Context.ResourcesOfResourceGroup(Context.ClusterItem)
   For Each resource In ThisResourceMap
      GlobalResourceVector.Add resource
   Next
End Sub

Example 2

Sub OnRegistration(dispatcher)
      Dispatcher.RegisterByResource “OnEvent”, ”my event type”, “my resource”
      Dim a
      For a = 1 to 1000000: next
End Sub

This code would have an adverse effect on the infrastructure processing stage of the calculations for no reason.

Instead, you can now use:

Sub OnRegistration(dispatcher)
      Dispatcher.RegisterByResource “OnEvent”, ”my event type”, “my resource”
      If (dispatcher.IsRuntimeMode) then
            Dim a
            For a = 1 to 1000000: next
      End If
End Sub

Note: "ProcedureName" = "MethodName" and "EventType=EventTypeName"

OnTimeSlotEnter(Time)

Called when entering a TimeSlot.

OnTimeSlotExit(Time)

Called when exiting a TimeSlot.