Periods

Periods are intended to represent different portions of the day. By default, xPLHal comes configured with two periods: Day and night.
Detection of day and night can be via a number of methods, some of which are listed below.

To set the period

The following code sample demonstrates setting the period to one of the values defined in the scripts \headers\XPLHAL_SETTINGS.XPL script:
sys.setting("Period") = SYS_PERIOD_NIGHT

To determine the current period

The following code sample demonstrates how to determine the current period, and take action accordingly:
Dim CurrentPeriod
CurrentPeriod = sys.setting("Period")
If CurrentPeriod = SYS_PERIOD_NIGHT Then
  call X10.Send("A1","ON",0)
End If
The above code will cause the X10 device A1 to be switched on only if the Period is currently night.

Specifying actions to occur when a period changes

You can create sub-routines that will be executed whenever a particular period becomes active. By default, in the scripts\headers\periods.xpl file, you will find the following code:
Sub Period_Day()
End Sub

Sub Period_Night()
End Sub
Any code you place in these sub-routines will be executed whenever the period is set to the appropriate value.
For example, suppose you have a light outside your house which you wish to come on at dusk, and switch off at dawn. You could modify the above scripts as follows:
Sub Period_Night()
  call X10.Send("A1","ON",0)
End Sub

Sub Period_Day()
  call X10.Send("A1","OFF",0)
End Sub
You can use the Period in combination with the Mode setting to achieve a high level of conditional logic in your scripts.