Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.wpi.cetask
Class TaskEngine

    java.lang.Object
      edu.wpi.cetask.TaskEngine

    public class TaskEngine

extends Object

Nested Class Summary
`static class` | `TaskEngine.AmbiguousIdException`
`static interface` | `TaskEngine.OnParsing` Interface for `setOnParsing(OnParsing)` callback.

Field Summary
`static boolean` | `COMPILABLE`
`static boolean` | `DEBUG`
`static boolean` | `INVOCABLE`
`static Object` | `NOT_FOUND`
`protected Properties` | `properties`
`static boolean` | `SCRIPTABLE`
`static Object` | `UNDEFINED`
`static boolean` | `VERBOSE`
`static String` | `VERSION`

Constructor Summary
`TaskEngine()`
`TaskEngine(String platform, String deviceType)` Create a new task engine with given default values for platform and deviceType.

Method Summary
`void` | `addTop(Plan plan)` Add given plan to current task tree at toplevel.
`void` | `clear()`
`void` | `clearLive()`
`CompiledScript` | `compile(String script, String where)`
`void` | `decomposeAll()` Call `Plan.decomposeAll()` on all plans in current tree.
`Plan` | `done(Task occurrence)` Method for notifying task engine that given primitive task has occurred.
`Object` | `eval(String script, Bindings bindings, String where)`
`Object` | `eval(String script, String where)`
`Plan` | `findMatch(Task task, boolean onlyLive)` Look for plan in task tree matching given task.
`List<Plan>` | `findMatches(Task task, boolean onlyLive)` Return list of plans in task tree with goal matching given task, searching in the following categories, in order: within current focus within current toplevel plan any toplevel plan If matching plans are found in one category, search does not continue to next category.
`String` | `getDeviceType(Task task)`
`Plan` | `getFocus()` Return the current focus in the task tree, or null if no focus. Note that this is not the discourse concept of focus (cf.
`TaskModel` | `getModel(String namespace)` Return task model for given namespace.
`String` | `getPlatform(Task task)`
`String` | `getProperty(String key)`
`ScriptEngine` | `getScriptEngine()`
`long` | `getStart()`
`TaskClass` | `getTaskClass(String id)` Return the unique task class, if any, in currently loaded task models which is identified by given id.
`long` | `getTick()`
`Plan` | `getTop(Plan plan)`
`Boolean` | `isLive(Plan plan)`
`Plan` | `newFocus(Plan plan)` Return first ancestor of given plan which is live or has live descendants, stopping at toplevel plan containing given plan, or null if none.
`TaskModel` | `parse(String from)` Load and return task model from specifiedXML document.
`void` | `removeTop(Plan plan)` Remove given toplevel plan from current tree.
`boolean` | `setFocus(Plan focus)` Shift focus to the given plan or null.
`void` | `setLive(Plan plan, boolean live)`
`void` | `setOnParsing(TaskEngine.OnParsing callback)` Set object to be called after new task model loaded.
`void` | `setStart(long start)` Set the start time to be used for 'when' slot in verbose version of `Instance.toString()`.
`void` | `tick()` This method must be called at appropriate times to clear liveness cache.
`Iterator<Plan>` | `tops()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### VERSION

    public static String VERSION

### VERBOSE

    public static boolean VERBOSE

### DEBUG

    public static boolean DEBUG

### COMPILABLE

    public static boolean COMPILABLE

### SCRIPTABLE

    public static boolean SCRIPTABLE

### INVOCABLE

    public static boolean INVOCABLE

### NOT_FOUND

    public static Object NOT_FOUND

### UNDEFINED

    public static Object UNDEFINED

### properties

    protected final Properties properties

Constructor Detail

### TaskEngine

    public TaskEngine(String platform,
                      String deviceType)

  Create a new task engine with given default values for platform and deviceType. Note that how platforms and deviceTypes are associated with tasks is outside the scope of the standard, and is not addressed by this implementation.

### TaskEngine

    public TaskEngine()

Method Detail

### getDeviceType

    public String getDeviceType(Task task)

### getPlatform

    public String getPlatform(Task task)

### getScriptEngine

    public ScriptEngine getScriptEngine()

### getTick

    public long getTick()

### tick

    public void tick()

  This method must be called at appropriate times to clear liveness cache.

### eval

    public Object eval(String script,
                       String where)

### eval

    public Object eval(String script,
                       Bindings bindings,
                       String where)

### compile

    public CompiledScript compile(String script,
                                  String where)

### getProperty

    public String getProperty(String key)

### parse

    public TaskModel parse(String from)

  Load and return task model from specifiedXML document. Loads the first toplevel element. NB: This implementation does not support forward or circular namespace references using prefixes. Thus task models must be loaded in order such that all external references to task model namespaces refer to already loaded models.

  Parameters:
    `from` - string identifying url, system resource or file containing XML document

### setOnParsing

    public void setOnParsing(TaskEngine.OnParsing callback)

  Set object to be called after new task model loaded.

### getModel

    public TaskModel getModel(String namespace)

  Return task model for given namespace. If such a model has not already been loaded, resolve namespace and load.

### getTaskClass

    public TaskClass getTaskClass(String id)

  Return the unique task class, if any, in currently loaded task models which is identified by given id.

  Parameters:
    `id` -
  Returns:
    task or decomposition class or null if none
  Throws:
    `TaskEngine.AmbiguousIdException`

### getStart

    public long getStart()

  See Also:
    `setStart(long)`

### setStart

    public void setStart(long start)

  Set the start time to be used for 'when' slot in verbose version of `Instance.toString()`. If start time is greater than zero, then shows 'when' in seconds since start time, rather than UTC in milliseconds.

  Parameters:
    `start` - - start time in milliseconds (e.g., `System.currentTimeMillis()`)
  See Also:
    `VERBOSE`

### clear

    public void clear()

### tops

    public Iterator<Plan> tops()

### addTop

    public void addTop(Plan plan)

  Add given plan to current task tree at toplevel. Shifts the focus to this plan if it is not done.

### removeTop

    public void removeTop(Plan plan)

  Remove given toplevel plan from current tree. Also sets focus to null, if given plan was focus.

### getTop

    public Plan getTop(Plan plan)

### decomposeAll

    public void decomposeAll()

  Call `Plan.decomposeAll()` on all plans in current tree.

### isLive

    public Boolean isLive(Plan plan)

### setLive

    public void setLive(Plan plan,
                        boolean live)

### clearLive

    public void clearLive()

### done

    public Plan done(Task occurrence)

  Method for notifying task engine that given primitive task has occurred.

  Returns:
    matching plan in current task tree or null if none

### findMatch

    public Plan findMatch(Task task,
                          boolean onlyLive)

  Look for plan in task tree matching given task.

  Returns:
    matching plan or null, if none
  See Also:
    `findMatches(Task,boolean)`

### findMatches

    public List<Plan> findMatches(Task task,
                                  boolean onlyLive)

  Return list of plans in task tree with goal matching given task, searching in the following categories, in order:
  1. within current focus
  2. within current toplevel plan
  3. any toplevel plan
  If matching plans are found in one category, search does not continue to next category.

  Parameters:
    `onlyLive` - only search live plans

### getFocus

    public Plan getFocus()

  Return the current focus in the task tree, or null if no focus.
  Note that this is not the discourse concept of focus (cf. Collagen), but rather a much simpler "execution" focus. For example, there is no focus stack. Also, the focus will not usually not be on a done plan. Management of the focus is the responsibility of the application using the engine (e.g., the Guide), with the exception of `addTop(Plan)` and `removeTop(Plan)`, as documented.
  Note also that this is not the same as the "next" live action, since in a partially ordered plan, there may be several next actions to choose from. The current focus will usually have the next live actions as its children.

  See Also:
    `setFocus(Plan)`

### setFocus

    public boolean setFocus(Plan focus)

  Shift focus to the given plan or null.

  Returns:
    true iff this is an "unexpected focus shift" in the sense of Lesh, Rich & Sidner's UM'01 paper, i.e., we are leaving the current focus when it is started but not done.
  See Also:
    `getFocus()`

### newFocus

    public Plan newFocus(Plan plan)

  Return first ancestor of given plan which is live or has live descendants, stopping at toplevel plan containing given plan, or null if none.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD