hmi.elckerlyc.scheduler
Class BMLScheduler

java.lang.Object
  extended by hmi.elckerlyc.scheduler.BMLScheduler

public final class BMLScheduler
extends Object

BMLScheduler, handles BML block states, feedback listeners and maintains planners and anticipators. A scheduling strategy needs to be provided to hand off the actual scheduling to.

Author:
Herwin van Welbergen

Field Summary
private  Map<String,Anticipator> anticipators
           
private  BMLBlockManager bmlBlocksManager
           
private  List<BMLExceptionListener> exceptionListeners
           
private  List<BMLFeedbackListener> feedbackListeners
           
private  org.slf4j.Logger logger
           
private  BMLParser parser
           
private  PegBoard pegBoard
           
private  List<BMLTPlanningListener> planningListeners
           
private  Map<Class<? extends Behaviour>,Planner> planSelector
           
private  SchedulingClock schedulingClock
           
private  SchedulingStrategy schedulingStrategy
           
private  List<BMLWarningListener> warningListeners
           
 
Constructor Summary
BMLScheduler(BMLParser s, SchedulingClock c, SchedulingStrategy ss)
           
 
Method Summary
 void addAnticipator(String id, Anticipator ap)
          Adds an anticipator
 void addExceptionListener(BMLExceptionListener e)
          Adds an exception listener.
 void addFeedbackListener(BMLFeedbackListener e)
           
 void addPlanner(Class<? extends Behaviour> c, Planner p)
          Adds a planner that can plan Behaviour class c
 void addPlanningListener(BMLTPlanningListener p)
           
 void addWarningListener(BMLWarningListener ws)
          Adds an warning listener.
 void blockStartFeedback(String bmlId)
           
 void blockStopFeedback(String bmlId)
          Sends feedback to all feedback listeners
 void clear()
          Clear all scheduled behavior from the scheduler
 void exception(BMLExceptionFeedback e)
          Sends the exception to all exception listeners
 Anticipator getAnticipator(String a)
           
 Set<String> getBehaviours(String bmlId)
           
 double getEndTime(String behId, String bmlId)
           
 int getNumberOfAnticipators()
          Get the number of registered anticipators
 BMLParser getParser()
           
 PegBoard getPegBoard()
           
 Planner getPlanner(Class<? extends Behaviour> c)
          Get the planner that can plan Behaviour class c
 List<Planner> getPlanners()
          Get the list of planners
 Set<BMLSyncPointProgressFeedback> getSyncProgress(String bmlId, String behaviorId)
          Get a copy of the set of progress messages send for a certain behavior
 Set<String> getSyncsPassed(String bmlId, String behaviorId)
          Get the set of syncs that are finished for a certain behavior
 Set<String> getTimedSyncs(String behId, String bmlId)
          Get the syncs of behavior id that have a TimePeg value !
 void interruptBehavior(String behaviourId, String bmlId)
           
 void interruptBlock(String bmlId)
          Stops and removes all behaviors of block bmlId
 void planningFinished(BMLTPlanningFinishedFeedback bpff)
           
 void planningFinished(String bmlId)
           
 void planningStart(BMLTPlanningStartFeedback bpsf)
           
 void planningStart(String bmlId)
           
 void removeAllExceptionListeners()
          Removes all exception listeners;
 void removeAllFeedbackListeners()
           
 void removeAllWarningListeners()
          Removes all warning listeners;
 void removeAnticipator(String aid)
          Removes an anticipator
 void removeBehaviour(String id, String bmlId)
           
 void removeExceptionListener(BMLExceptionListener e)
           
 void removeFeedbackListener(BMLFeedbackListener e)
           
 void removeWarningListener(BMLWarningListener ws)
           
 void reset()
          Resets all planners, that is: stops running behaviour and restores their players to the start state.
 void schedule()
          Schedules the behaviors provided to this scheduler (e.g. by grabbing them from the parser)
 void shutdown()
           
 void startBlock(String bmlId)
          Set the state of all behaviors in block with bmlId to LURKING
 void warn(BMLWarningFeedback w)
          Sends the warning to all warning listeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final org.slf4j.Logger logger

parser

private final BMLParser parser

bmlBlocksManager

private final BMLBlockManager bmlBlocksManager

planSelector

private final Map<Class<? extends Behaviour>,Planner> planSelector

warningListeners

private final List<BMLWarningListener> warningListeners

exceptionListeners

private final List<BMLExceptionListener> exceptionListeners

feedbackListeners

private final List<BMLFeedbackListener> feedbackListeners

planningListeners

private final List<BMLTPlanningListener> planningListeners

anticipators

private final Map<String,Anticipator> anticipators

pegBoard

private final PegBoard pegBoard

schedulingClock

private final SchedulingClock schedulingClock

schedulingStrategy

private final SchedulingStrategy schedulingStrategy
Constructor Detail

BMLScheduler

public BMLScheduler(BMLParser s,
                    SchedulingClock c,
                    SchedulingStrategy ss)
Method Detail

getTimedSyncs

public Set<String> getTimedSyncs(String behId,
                                 String bmlId)
Get the syncs of behavior id that have a TimePeg value != TimePeg.ValueUnknown


getPegBoard

public PegBoard getPegBoard()

getPlanners

public List<Planner> getPlanners()
Get the list of planners


reset

public void reset()
Resets all planners, that is: stops running behaviour and restores their players to the start state.


shutdown

public void shutdown()

clear

public void clear()
Clear all scheduled behavior from the scheduler


addPlanner

public void addPlanner(Class<? extends Behaviour> c,
                       Planner p)
Adds a planner that can plan Behaviour class c

Parameters:
c - behaviour class the planner can plan
p - the planner

addAnticipator

public void addAnticipator(String id,
                           Anticipator ap)
Adds an anticipator

Parameters:
id - anticipator id
ap - anticipator

removeAnticipator

public void removeAnticipator(String aid)
Removes an anticipator

Parameters:
aid - id of the anticipator to remove

getNumberOfAnticipators

public int getNumberOfAnticipators()
Get the number of registered anticipators


addWarningListener

public void addWarningListener(BMLWarningListener ws)
Adds an warning listener. All scheduling warnings are sent to this listener.


removeWarningListener

public void removeWarningListener(BMLWarningListener ws)

removeAllWarningListeners

public void removeAllWarningListeners()
Removes all warning listeners;


removeAllExceptionListeners

public void removeAllExceptionListeners()
Removes all exception listeners;


addExceptionListener

public void addExceptionListener(BMLExceptionListener e)
Adds an exception listener. All scheduling exceptions are sent to this listener.


removeExceptionListener

public void removeExceptionListener(BMLExceptionListener e)

addPlanningListener

public void addPlanningListener(BMLTPlanningListener p)

addFeedbackListener

public void addFeedbackListener(BMLFeedbackListener e)

removeFeedbackListener

public void removeFeedbackListener(BMLFeedbackListener e)

removeAllFeedbackListeners

public void removeAllFeedbackListeners()

warn

public void warn(BMLWarningFeedback w)
Sends the warning to all warning listeners

Parameters:
w - the warning

planningStart

public void planningStart(String bmlId)

planningFinished

public void planningFinished(String bmlId)

planningStart

public void planningStart(BMLTPlanningStartFeedback bpsf)

planningFinished

public void planningFinished(BMLTPlanningFinishedFeedback bpff)

exception

public void exception(BMLExceptionFeedback e)
Sends the exception to all exception listeners

Parameters:
e - exception

blockStopFeedback

public void blockStopFeedback(String bmlId)
Sends feedback to all feedback listeners

Parameters:
fb - the feedback

blockStartFeedback

public void blockStartFeedback(String bmlId)

getPlanner

public Planner getPlanner(Class<? extends Behaviour> c)
Get the planner that can plan Behaviour class c

Parameters:
c - behaviour class the planner can plan

removeBehaviour

public void removeBehaviour(String id,
                            String bmlId)

getEndTime

public double getEndTime(String behId,
                         String bmlId)

getBehaviours

public Set<String> getBehaviours(String bmlId)

schedule

public void schedule()
Schedules the behaviors provided to this scheduler (e.g. by grabbing them from the parser)


interruptBehavior

public void interruptBehavior(String behaviourId,
                              String bmlId)

interruptBlock

public void interruptBlock(String bmlId)
Stops and removes all behaviors of block bmlId


startBlock

public void startBlock(String bmlId)
Set the state of all behaviors in block with bmlId to LURKING

Parameters:
bmlId -

getAnticipator

public Anticipator getAnticipator(String a)

getParser

public BMLParser getParser()

getSyncProgress

public Set<BMLSyncPointProgressFeedback> getSyncProgress(String bmlId,
                                                         String behaviorId)
Get a copy of the set of progress messages send for a certain behavior

See Also:
BMLBlockManager.getSyncProgress(java.lang.String, java.lang.String)

getSyncsPassed

public Set<String> getSyncsPassed(String bmlId,
                                  String behaviorId)
Get the set of syncs that are finished for a certain behavior