stella.parameter
Class MomentsTrigger

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.parameter.AbstractParameter
                  extended by stella.parameter.AbstractTrigger
                      extended by stella.parameter.SimpleTrigger
                          extended by stella.parameter.MomentsTrigger
All Implemented Interfaces:
Cloneable, Parameter, ParameterDepending, Trigger, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, Reloadable, ResourceSupplying

public class MomentsTrigger
extends SimpleTrigger
implements ParameterDepending

A moment trigger changes its value depending on a fits moments list provided to it. The general action is that for each moment (one for average, two for standard deviation, from three on central normalized moment), an allowed range is given, stating central value and half-width of allowed range. A negative half-range means that this moment should be ignored, comparison stops when there are no more moments or all required moments have been checked. This parameter is fail-fast: As soon as a criterion is violated, false is returned without checking further.


Nested Class Summary
static class MomentsTrigger.Test
          As a test, we provide a fits file, a moment trigger properties file and a fits moment parameter properties.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFFITSMOMENTS
          The default lux value name.
static String KEY_FITSMOMENTS
          This key links to the name of the fitsmoments parameter.
static String KEY_MOMENTSLIST
          This key links to the name of the fitsmoments parameter.
private  FitsMoments moments
          The parameter that holds the fits central moments, local.
(package private)  List<Vector2D[]> range
          For convenience, we parse the ranges on init.
 
Fields inherited from class stella.parameter.SimpleTrigger
KEY_INITBOOLEAN
 
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
MomentsTrigger(Map<String,String> prop)
          Defaults the fits moment parameter name, but spares the moments ranges.
 
Method Summary
private  Boolean checkMoments(List<CentralMoments> cm)
          We scan our properties for moment ranges and return true, if we are in the correct range or false if we are not.
 Boolean getTrigger()
          We get the trigger by scanning the list of central moments.
 void init()
          On init, we create the table for calculating the times.
private static List<Vector2D[]> parseRange(String dt)
          We parse a double tokenized list into a list of vector2D arrays.
private static Boolean rangeCheck(List<CentralMoments> cm, List<Vector2D[]> edge)
          We check if the central moments of all extensions are within the desired range as specified in the properties.
 void registerParameter(Parameter p)
          We register a parameter that delivers sky brightness.
 
Methods inherited from class stella.parameter.SimpleTrigger
getLastToggleTime, rescanned, setTrigger
 
Methods inherited from class stella.parameter.AbstractTrigger
get, getElapsedToggleTime, isTrue, set, toggleTrigger
 
Methods inherited from class stella.parameter.AbstractParameter
createParameter, delivers, exit, getFormatted, getFormatted, getName, getPreserveFile, getString, getString, 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
getFormatted, 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.ResourceSupplying
getResource, getResourceAsStream, getResources
 

Field Detail

KEY_FITSMOMENTS

public static final String KEY_FITSMOMENTS
This key links to the name of the fitsmoments parameter.

See Also:
Constant Field Values

KEY_MOMENTSLIST

public static final String KEY_MOMENTSLIST
This key links to the name of the fitsmoments parameter.

See Also:
Constant Field Values

DEFFITSMOMENTS

private static final String DEFFITSMOMENTS
The default lux value name.

See Also:
Constant Field Values

moments

private FitsMoments moments
The parameter that holds the fits central moments, local.


range

List<Vector2D[]> range
For convenience, we parse the ranges on init.

Constructor Detail

MomentsTrigger

public MomentsTrigger(Map<String,String> prop)
Defaults the fits moment parameter name, but spares the moments ranges.

Method Detail

init

public void init()
On init, we create the table for calculating the times.

Specified by:
init in interface Initializable
Overrides:
init in class SimpleTrigger

registerParameter

public void registerParameter(Parameter p)
We register a parameter that delivers sky brightness. Preferrably it links directly to a brightness sensor, if none is present, a solz-dependancy can be used.

Specified by:
registerParameter in interface ParameterDepending

getTrigger

public Boolean getTrigger()
We get the trigger by scanning the list of central moments. If a change has been noted, we set the super trigger.

Specified by:
getTrigger in interface Trigger
Overrides:
getTrigger in class SimpleTrigger

checkMoments

private Boolean checkMoments(List<CentralMoments> cm)
We scan our properties for moment ranges and return true, if we are in the correct range or false if we are not. Never returns null, may not be called with null.


parseRange

private static List<Vector2D[]> parseRange(String dt)
We parse a double tokenized list into a list of vector2D arrays. The size of the inner, comma-separated list defines the dimension of the array, the length of the list returned is the length of the outer, semi-solon tokenizable list. The inner list represents the number of extension (1 in the standard case), while the out list enumerates the moments order, starting with average, followed by standard deviation


rangeCheck

private static Boolean rangeCheck(List<CentralMoments> cm,
                                  List<Vector2D[]> edge)
We check if the central moments of all extensions are within the desired range as specified in the properties.