Previous Topic

Next Topic

Book Contents

Book Index

Astro Timer (Deprecated)

The Astro Timer Condition is triggered at a specific time relative to the setting or to the rising of the sun in a given geographical area. For example, such condition can be triggered ten minutes before/after the sunset/sunrise so that a command can be fired to switch on/off the street lamps every day.

The Condition Provider for the Astro Timer Condition uses by default the Astro Calculator implementation provided with the Astro Calculator for Sunriset Library bundle. It uses the SUNRISET.C calculator to compute the precise time the condition is triggered depending on the geographical area and the specific time the sun rises and sets.

In case you want to use a custom calculation library for the sunrise/sunset time, you need to do the following:

  1. Implement and register an instance of the com.prosyst.mbs.services.ham.condition.timer.AstroCalculator interface that uses your custom calculation library.
  2. Pack the library as a resource in the JAR file holding the Astro Calculator implementation.

The Astro Timer Condition will use the custom calculation library to define the exact time for triggering a specified condition.

Managing Astro Timer Conditions

Via Java API

After creating a condition as described in Managing Conditions you can configure it by using the following methods:

After you configure your condition, call the save method. The Condition Provider will save the condition in Config Tree.

Via Config Tree

All conditions are stored in the Config Tree, which allows you to import/export them and to add/edit them by simply creating and modifying XML files.

The following configuration XML file defines an Astro Timer Condition, which will be triggered 2 hours (set hour - "2", minute - "0" and seconds - "0") after (before - "false") the sun sets (sunset - "true") in London, England (the location is mapped by its latitude and longitude).

<config name="AstroTimerCondition">

<config name="AstroTimerCondition1">

<property key="before" value="true" type="boolean"/>

<property key="endTime" value="1342599071000" type="long"/>

<property key="hour" value="2" type="int"/>

<property key="latitude" value="51.517100" type="string"/>

<property key="longitude" value="0.106200" type="string"/>

<property key="minute" value="0" type="int"/>

<property key="repeatCount" value="-1" type="int"/>

<property key="seconds" value="0" type="int"/>

<property key="startTime" value="1342516339000" type="long"/>

<property key="sunset" value="true" type="boolean"/>

<config name="days"> <property key="0" value="true" type="boolean"/>

  <property key="1" value="true" type="boolean"/>

  <property key="2" value="true" type="boolean"/>

  <property key="3" value="true" type="boolean"/>

  <property key="4" value="true" type="boolean"/>`

  <property key="5" value="true" type="boolean"/>

  <property key="6" value="true" type="boolean"/>

</config>

</config>

</config>