stella.parameter
Class Twilight

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractValue
                      extended by stella.parameter.Twilight
All Implemented Interfaces:
Cloneable, Parameter, Decreasing<Number>, Increasing<Number>, ParameterDepending, Value, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying

public class Twilight
extends AbstractValue
implements ParameterDepending, Increasing<Number>, Decreasing<Number>, Reloadable

A twilight parameter measures the time prior and after roof opening/closing. As an example, consider opening/closing of the roof at an solar height of -6 deg (see KEY_RISETWILIGHT). If the current solar height is above this value, this parameter gives the time it will require the sun to either reach this height or the time that has passed since the sun was at this height, whatever time is smaller. If the solar height is below the target value of KEY_RISETWILIGHT, a negative time is returned.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFLATITUDE
          The default name of the latitude parameter to use.
static String DEFNAME
          The defautl name of this parameter.
private static double DEFRISESETWILIGHT
          The default opening/closing solar height.
private static String DEFSIDEREAL
          The default name of the sidereal parameter to use.
private static double DEFSOLARSET
          The default opening/closing solar height.
private static String DEFSOLDEC
          The default name of the solar declination to use.
private static String DEFSOLRA
          The default name of the solar right ascension to use.
static String KEY_LATITUDE
          The name of the latitude to use.
static String KEY_RISETWILIGHT
          The target hight at which the roof opens/closes.
static String KEY_SETTWILIGHT
          The target hight at which the roof opens/closes.
static String KEY_SIDEREAL
          The name of the sidereal time to use.
static String KEY_SOLDEC
          The name of the solar declination to use.
static String KEY_SOLRA
          The name of the solar right ascension to use.
private  Value latitude
          The latitude parameter to use.
private  Value sidereal
          The sidereal time parameter to use.
private  Value soldec
          The solar declination parameter to use.
private  Value solra
          The solar right ascension parameter to use.
 
Fields inherited from class stella.parameter.AbstractParameter
KEY_FORMAT, KEY_NAME, KEY_PRESERVE, UNKNOWN
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
Twilight(Map prop)
          Constructs a new twilight parameter.
 
Method Summary
 Double getAscendTime(Number until)
          Returns the time until the twilight reaches the given value from below.
 Double getDescendTime(Number until)
          Returns the time until the twilight reaches the given value from above.
 String getFormatted()
          Returns the remaining twilight time as a formatted string.
 Number getValue()
          Returns the twilight time in ms.
 void registerParameter(Parameter what)
          Registers the required additional globals for the twilight time.
 double rescanned(String key, String old, String newval)
          As any parameter depending instance we fail if the parameter we depend on is now a different one.
 Number setValue(Number val)
          Sets the twilight time.
 
Methods inherited from class stella.parameter.AbstractValue
get, set
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getName, getPreserveFile, getString, getString, init, register, setName, toString
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, setObject, setProperties, setProperty, stringProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.Reloadable
reload
 
Methods inherited from interface stella.Parameter
getName, getString
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.Initializable
init
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_SIDEREAL

public static final String KEY_SIDEREAL
The name of the sidereal time to use.

See Also:
Constant Field Values

KEY_LATITUDE

public static final String KEY_LATITUDE
The name of the latitude to use.

See Also:
Constant Field Values

KEY_SOLRA

public static final String KEY_SOLRA
The name of the solar right ascension to use.

See Also:
Constant Field Values

KEY_SOLDEC

public static final String KEY_SOLDEC
The name of the solar declination to use.

See Also:
Constant Field Values

KEY_RISETWILIGHT

public static final String KEY_RISETWILIGHT
The target hight at which the roof opens/closes.

See Also:
Constant Field Values

KEY_SETTWILIGHT

public static final String KEY_SETTWILIGHT
The target hight at which the roof opens/closes.

See Also:
Constant Field Values

DEFNAME

public static final String DEFNAME
The defautl name of this parameter.

See Also:
Constant Field Values

DEFSIDEREAL

private static final String DEFSIDEREAL
The default name of the sidereal parameter to use.

See Also:
Constant Field Values

DEFLATITUDE

private static final String DEFLATITUDE
The default name of the latitude parameter to use.

See Also:
Constant Field Values

DEFSOLRA

private static final String DEFSOLRA
The default name of the solar right ascension to use.

See Also:
Constant Field Values

DEFSOLDEC

private static final String DEFSOLDEC
The default name of the solar declination to use.

See Also:
Constant Field Values

DEFRISESETWILIGHT

private static final double DEFRISESETWILIGHT
The default opening/closing solar height.

See Also:
Constant Field Values

DEFSOLARSET

private static final double DEFSOLARSET
The default opening/closing solar height.

See Also:
Constant Field Values

sidereal

private Value sidereal
The sidereal time parameter to use.


latitude

private Value latitude
The latitude parameter to use.


solra

private Value solra
The solar right ascension parameter to use.


soldec

private Value soldec
The solar declination parameter to use.

Constructor Detail

Twilight

public Twilight(Map prop)
Constructs a new twilight parameter. Defaults its name, the solar-z parameter name and the opening/closing height.

Method Detail

rescanned

public double rescanned(String key,
                        String old,
                        String newval)
As any parameter depending instance we fail if the parameter we depend on is now a different one.

Specified by:
rescanned in interface Reloadable
Overrides:
rescanned in class AbstractParameter

setValue

public Number setValue(Number val)
                throws UnsupportedOperationException
Sets the twilight time. The twilight time is a read-only variable, therefore this method throws an UnsupportedOperationException.

Specified by:
setValue in interface Value
Throws:
UnsupportedOperationException

getValue

public Number getValue()
Returns the twilight time in ms. The twilight time is the time remaining/passed to the next/last opening/closing of the roof. During night time, a negative value is returned. Null is returned if no solar height has been registered to this parameter.

Specified by:
getValue in interface Value

registerParameter

public void registerParameter(Parameter what)
Registers the required additional globals for the twilight time. For this particular object, a solarz parameter is needed. Both, type and name are checked.

Specified by:
registerParameter in interface ParameterDepending

getDescendTime

public Double getDescendTime(Number until)
Returns the time until the twilight reaches the given value from above. If the current value is higher than the target value, the simple difference is returned, otherwise the agumention to one day is returned.

Specified by:
getDescendTime in interface Decreasing<Number>
Parameters:
until - The value in the future.
Returns:
A double carrying the remaining time or null if the time cannot be calculated.

getAscendTime

public Double getAscendTime(Number until)
Returns the time until the twilight reaches the given value from below. If the current value is lower than the target value, the simple difference is returned, otherwise the agumention to one day is returned.

Specified by:
getAscendTime in interface Increasing<Number>
Parameters:
until - The value in the future.
Returns:
A double carrying the remaining time or null if the time cannot be calculated.

getFormatted

public String getFormatted()
Returns the remaining twilight time as a formatted string. The twilight time returned is the time rounded to seconds, not ms.

Specified by:
getFormatted in interface Parameter
Overrides:
getFormatted in class AbstractParameter