stella.xml
Class XMLScheduler

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by stella.AbstractScheduler
                  extended by stella.xml.XMLScheduler
All Implemented Interfaces:
Cloneable, Scheduling, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying
Direct Known Subclasses:
AssistantScheduler, PointingScheduler

public class XMLScheduler
extends AbstractScheduler

An implementation of the Scheduling interface. An xml scheduler uses TargetDefinitions coming in the flavor of DOMTargets. The scheduler is responsible for selecting the next observation. This scheduler is a simple dispatch scheduler. The calculation of the individual observation's merits is deferred to the target itself, see ParsedTarget and the special subclasses of Meriting for further details.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  Collection<Meriting> globalmerit
          A list of global merits like user merits.
static String KEY_GLOBALCONSTRAINT
          The key linked to the properties of the global constraints.
static String KEY_GLOBALMERIT
          The key linked to the properties of the global timeslot.
static String KEY_GLOBALWATCH
          The key to the objects watched during night for their merit.
private static int level
          For debugging purpose we record the re-entrant level.
private  List<String> meritinfo
          A list of targets whose merit is matched during night.
 
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
XMLScheduler(Map<String,String> sprop)
          Constructs a new xml-scheduler.
 
Method Summary
 boolean addMeritTrace(Appointable app)
          We add the name of the appointable target to the merit info list, which means we will produce a log entry stating the current merit on any instance the target was observable.
private static double getApparentMerit(ParameterClustering set, Appointable dom, Collection<TargetDefinition> targets, long within, Collection<Meriting> globalmerit)
          Calculates the apparent merit a target has, which includes global timeslots in addition to the target's own merit.
 TargetDefinition getHighestTarget(ParameterClustering set, Collection<TargetDefinition> targets)
          Gets the target with the highest priority.
protected static Appointable highestFromAll(ParameterClustering set, Collection<TargetDefinition> all, Collection<TargetDefinition> within, Collection<Meriting> globalmerit)
          A re-entrant method to find the highest target.
private static Appointable highestWithin(ParameterClustering set, Collection<TargetDefinition> targets, Collection<TargetDefinition> observe, long within, Collection<Meriting> globalmerit)
          Returns the target with the highest merit within the stated time.
 void init()
          Initializes the scheduler.
 boolean removeMeritTrace(Appointable app)
          We remove the name of the target from the list of merit tracing.
private static Collection<TargetDefinition> retainTargets(ParameterClustering set, Collection<TargetDefinition> observable, long maxdur)
          Retains all targets in the returned collection whose observing time is less then the stated threshold.
 
Methods inherited from class stella.AbstractScheduler
addGlobalConstraint, checkGlobalConstraints, createScheduler, getGlobalConstraints, getObservableTargets, registerMonitor, removeAllGlobalConstraints, removeGlobalConstraint, wakeUp
 
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, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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_GLOBALCONSTRAINT

public static final String KEY_GLOBALCONSTRAINT
The key linked to the properties of the global constraints.

See Also:
Constant Field Values

KEY_GLOBALMERIT

public static final String KEY_GLOBALMERIT
The key linked to the properties of the global timeslot.

See Also:
Constant Field Values

KEY_GLOBALWATCH

public static final String KEY_GLOBALWATCH
The key to the objects watched during night for their merit.

See Also:
Constant Field Values

level

private static int level
For debugging purpose we record the re-entrant level.


globalmerit

private Collection<Meriting> globalmerit
A list of global merits like user merits.


meritinfo

private List<String> meritinfo
A list of targets whose merit is matched during night.

Constructor Detail

XMLScheduler

public XMLScheduler(Map<String,String> sprop)
Constructs a new xml-scheduler. Initialization is deferred to the init() method.

Method Detail

init

public void init()
Initializes the scheduler. If global constraints are specified in the properties, they are constructed and added here.

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

addMeritTrace

public boolean addMeritTrace(Appointable app)
We add the name of the appointable target to the merit info list, which means we will produce a log entry stating the current merit on any instance the target was observable.


removeMeritTrace

public boolean removeMeritTrace(Appointable app)
We remove the name of the target from the list of merit tracing.


retainTargets

private static Collection<TargetDefinition> retainTargets(ParameterClustering set,
                                                          Collection<TargetDefinition> observable,
                                                          long maxdur)
Retains all targets in the returned collection whose observing time is less then the stated threshold.

Returns:
A collection of Appointables

highestWithin

private static Appointable highestWithin(ParameterClustering set,
                                         Collection<TargetDefinition> targets,
                                         Collection<TargetDefinition> observe,
                                         long within,
                                         Collection<Meriting> globalmerit)
Returns the target with the highest merit within the stated time.

Parameters:
set - The parameters.
targets - All targets, observable or not.
observe - A collection of Appointables currently observable
within - The proposed time span, zero for target observing time

getApparentMerit

private static double getApparentMerit(ParameterClustering set,
                                       Appointable dom,
                                       Collection<TargetDefinition> targets,
                                       long within,
                                       Collection<Meriting> globalmerit)
Calculates the apparent merit a target has, which includes global timeslots in addition to the target's own merit.


getHighestTarget

public TargetDefinition getHighestTarget(ParameterClustering set,
                                         Collection<TargetDefinition> targets)
Gets the target with the highest priority. The scheduler roams through the list of targets, sorting out those that are currently not observable. From the remaining targets, it scans for the target with the currently highest merit. Only targets with a positive merit may be selected. Note that the merit calculation is deferred to the target itself, therefore the implementation of this method is straightforward.


highestFromAll

protected static final Appointable highestFromAll(ParameterClustering set,
                                                  Collection<TargetDefinition> all,
                                                  Collection<TargetDefinition> within,
                                                  Collection<Meriting> globalmerit)
A re-entrant method to find the highest target.