Revision 1.1
WebSwitch™ Users Manual
Event Variables
Actions can be configured to occur at specified days and times. Five events may be configured for the
unit. This is done by setting the day and time of the event and then comparing it to the current date and
time. Note that the current date and time must be set in the
Date/Time
setup tab. The event date
variables are designated ed1 to ed5. They are set using the LET command and setting the desired event
date variable equal to the date the event should occur in the format mm/dd/yyyy. The event time
variables are designated et1 to et5. They are likewise set using the LET command and setting the
corresponding event time variable equal to the event time in the format hh:mm:ss in 24-hour time. The
event date variables store the number of days that have passed since January 1, 1970. The event time
variables store the number of seconds from the beginning of the day. If the event time variable is
incremented more than the number of seconds in a day (86400 seconds), the counter is reset to 0 and
the event date variable is incremented by one. The variables 'time' and 'date' are predefined variables
that store the current date and time and can only be read. They can then be used to compare the event
date and times. The following example demonstrates defining the event variables and comparing it to
the current date and time. Assume current time is April 10, 2009 at 1:30 AM and the event should occur
in one hour and every hour thereafter.
Example:
Let a = 1
Let ed1 = 04/10/2009
'sets the event date to April 10,
'2009.
Let et1 = 02:30:00
'sets the event time to 2:30
Do While a <> 0
If ed1 >= date Then
'Tests event date versus current date.
If et1 >= time Then
'Tests event time versus current time.
Let et1 = et1 + 3600 'Increments the event time by one hour
'(in seconds).
Print "Event"
'Event to occur
End If
End If
Loop
End
External Variables
There are five external variables, extvar0 through extvar4. External variables are similar to general
purpose variables and can be used in the same manner. The difference between general purpose
variables and external variables is that external variables can be accessed by the user through a web
browser and modified while the script is running. Scripts can use external variables as a method of
retrieving user input. The following example demonstrates this by creating a script that will turn Outlet 1
on if extvar1 equals 1 and turn Outlet 1 off if extvar1 equals 0.
Example:
Do
If extvar1 = 1 Then
Let relay1 = 1
Else
Let relay1 = 0
End If
Loop
End
Xytronix Research & Design, Inc.
103