AbsTime

(Engine-Level Function)

Description: Absolute time. This function returns true when a multiple of a fixed time has been reached.
Returns: Boolean
Usage: Steady State only.
Function Groups: Time and Date
Related to: DateNum | Day | Month | Now | RTimeOut | Seconds | SetClock | TimeOut | TimeArrived | Today | Year
Format: AbsTime(Enable, Interval, Offset)
Parameters:  

Enable

Required Boolean. Any expression giving the condition that allows the timer to operate.

When this parameter is true (i.e. not 0), the timer is "running". When this parameter is false (i.e. 0), the timer stops and the function has a value of false.

Interval

Required. Any numeric expression giving the time in seconds between the absolute time periods. This parameter must be strictly greater than 0, otherwise the function value will be invalid.
Offset
Required. Offset is any numeric expression giving the time in seconds to shift the absolute time from multiples of the Interval time.
Comments:

The AbsTime function is designed to allow events to be scheduled at regular time intervals in real time. It is reset automatically when it appears in a true action trigger (IF), or when it appears in a function that resets its parameters.

The parameters are relative to local time. If attempting to schedule an event for the same time across servers in multiple time zones, the offset should be an expression relative to each time zone.

Note that the behavior will differ depending on whether you use this function in a script code module or in a tag expression. In script code, the function will be reset as described, and will wait for the next trigger to occur.
In a tag expression, this function will not be reset after triggering.

Because AbsTime is ultimately based on midnight January 1st, 1970 (a Thursday), it is possible in theory to use it for a weekly time interval, with an appropriate offset for the day of the week starting from Thursday. In practice, TimeArrived may be more appropriate for a weekly trigger.

VTScada includes an application property at the \Code level named SecondFlasher. The value of this property changes from 0 to 1 once a second, as near as possible to the change of the second. In most cases, it is better to watch for the change of \SecondFlasher than to burden the system with an additional function to calculate one-second intervals.

Example:

  If AbsTime(1, 86400 { 24 hrs }, 28800 { shifted 8 hrs });
  [
    ...
  ]

In the example above, the script will be executed every 86400 seconds (24 hours), offset by 28800 seconds (8 hours) from midnight. This means that the trigger will become true at 8:00 AM every morning when the script executes. The function will then be reset to wait until 8:00 AM the following day to execute again.

  If AbsTime(1, 3600 { 1 hr }, 0 { not shifted });
  [
    ...
  ]

The example displayed above enables a user to schedule an event to run on the hour, every hour.

Expression Example:

Latch(AbsTime(1, 10, 0), AbsTime(1, 10, 5))

In steady state, this expression will toggle between TRUE and FALSE every five seconds. If used for the opacity parameter of an object in the Idea Studio, this will make the object blink on a five-second cycle.

Latching and Resetting Functions