stella.xml
Class SequenceTask

java.lang.Object
  extended by stella.xml.SequenceTask
All Implemented Interfaces:
DTDConstants

public class SequenceTask
extends Object
implements DTDConstants

Represents a special Element, namely a Task element in an xml-sequencer file. Once parsed, all elements of the task are available, which are

Task can run in parallel and are grouped together to form SequenceSteps.


Field Summary
private  String[] broadcast
          All broadcasts in this task, filled in at run-time.
private  Map<String,String> broadcastwith
          Lookup table of broadcast templates to their single activator.
private  Map<String,String> commandid
          Lookup table of command templates (keys) to their unique id.
private  Map<String,String> commandinit
          Lookup table of command templates to their single initializer.
private  Map<String,String> commandparameter
          Lookup table of command templates to their single parameter name.
private  Map<String,String> commandref
          Lookup table of command templates (keys) to their unique reference.
private  String[] commands
          All command templates in this task, filled in at run-time.
private  String complete
          The complete condition.
private  String condition
          The condition that must evaluate to true, for this task to commence.
private  String done
          The current status of the task, finished, sending, or new.
private  String id
          The unique id of the task, from the XML file.
private  String[] setfalse
          All variables that should be set to false on task start.
private  String[] settrue
          All variables that should be set to true on task start.
 
Fields inherited from interface stella.xml.DTDConstants
ABORT, ABOVE, ABSTRACT, ABSTRACTPROPOSAL, ADDRESS, BELOW, BLOCK, BROADCAST, BROADCASTWITH, BV, CHANGE, CLASS, COMMAND, COMMANDID, COMMANDINIT, COMMANDLAST, COMMANDPARAMETER, COMMANDREF, COMMENT, COMPLETE, CONDITION, CONSTANT, CONSTANTNAME, CONSTANTVALUE, CONSTRAINT, CONSTRAINTOVERDUE, CONSTRAINTRELAX, DATA, DAUGHTER, DEC, DELAY, DELAYMAX, DELAYTIME, DISABLED, DOCPATH, DURATION, ELAPSED, EMAIL, ENABLED, EPOCH, EQUINOX, EXCEPTION, EXCEPTIONDAUGHTER, EXCEPTIONFOR, EXCEPTIONSUCCESSOR, EXCEPTIONTHIS, FALSE, FIELDOFVIEW, FILE, FITSHEADER, FITSHEADERID, FORMATCLASS, FORMATPATTERN, FROM, GAIN, HISTORY, HISTORYCOMPLETE, HISTORYDB, HISTORYMAX, HISTORYREAD, IGNORE, IMAGETYPE, INIT, INSTITUTION, INSTRUMENT, INTERN, KEY, MAX, MERIT, MIN, NOTIFY, OBJECT, OBJECTID, OBJECTNAME, OBSERVSTART, PICK, PICKMERIT, PICKSUCCESS, PMDEC, PMRA, POSITION, RA, RATE, REC, REQUIRES, RETRY, RETRYMAX, SELECT, SENDING, SEQUENCE, SEQUENCETYPE, SET, SETNAME, SETUP, SETUPID, STEP, STEPCOUNTER, STEPWHILE, SUCCESSOR, TARGET, TARGETACCESS, TARGETDB, TARGETNAME, TARGETNAMEPROPOSAL, TARGETREAD, TARGETSUBMITTED, TARGETTYPE, TASK, TASKDONE, TASKID, TEAM, TIMESLOT, TITLE, TO, TRUE, USER, V, VARIABLE
 
Constructor Summary
SequenceTask(Element src)
          Constructs a new task element from an element and immediately parses it.
 
Method Summary
private static String[] extractAll(Element src, String tag)
          Returns a string array of all first child nodes of the nodes found in the list.
 String[] getBroadcasts()
          Returns all command templates tied to this task.
 String getBroadcastWith(String template)
          Returns the broadcast with-attribute linked to the broadcast with argumental template.
 String getCommandID(String template)
          Returns the command id-attribute linked to the command with argumental command template.
 String getCommandInit(String template)
          Returns the command initialization string.
 String getCommandParameter(String template)
          Returns all parameter names linked to the command element whose template name is equal to the argument.
 String getCommandRef(String template)
          Returns the command ref-attribute linked to the command with argumental command template.
 String[] getCommands()
          Returns all broadcast templates.
 String getComplete()
          Returns the complete condition tied to this task.
 String getCondition()
          Returns the condition of this task element.
 String[] getFalse()
          Returns all triggers by name that get false as tied to this task.
 String getID()
          Returns the value of the id attribute of this task element.
 String[] getTrue()
          Returns all triggers by name that get true as tied to this task.
 boolean isDone()
          Returns true if the value of the done attribute of this task element is true.
 boolean isSending()
          Returns true if the value of the done attribute of this task element is sending.
private  void parseTask(Element anchor)
          Parses a DOM elements into all parts of a valid sequence task.
 void setDone(boolean to)
          Sets the value of the done attribute.
 void setSending()
          Sets the value of the done attribute to DTDConstants.SENDING.
 String toString()
          String version of a task element is its ID plus info on done/sending status if applicable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

private String id
The unique id of the task, from the XML file.


done

private String done
The current status of the task, finished, sending, or new.


condition

private String condition
The condition that must evaluate to true, for this task to commence.


broadcast

private String[] broadcast
All broadcasts in this task, filled in at run-time.


commands

private String[] commands
All command templates in this task, filled in at run-time.


settrue

private String[] settrue
All variables that should be set to true on task start.


setfalse

private String[] setfalse
All variables that should be set to false on task start.


complete

private String complete
The complete condition.


commandid

private Map<String,String> commandid
Lookup table of command templates (keys) to their unique id.


commandref

private Map<String,String> commandref
Lookup table of command templates (keys) to their unique reference.


commandparameter

private Map<String,String> commandparameter
Lookup table of command templates to their single parameter name.


commandinit

private Map<String,String> commandinit
Lookup table of command templates to their single initializer.


broadcastwith

private Map<String,String> broadcastwith
Lookup table of broadcast templates to their single activator.

Constructor Detail

SequenceTask

public SequenceTask(Element src)
             throws ParseException
Constructs a new task element from an element and immediately parses it. Throws an ParseException, if parsing was not successful.

Throws:
ParseException
Method Detail

getID

public String getID()
Returns the value of the id attribute of this task element. This is a required attribute and therefore always present.


isDone

public boolean isDone()
Returns true if the value of the done attribute of this task element is true.


isSending

public boolean isSending()
Returns true if the value of the done attribute of this task element is sending.


setDone

public void setDone(boolean to)
Sets the value of the done attribute. This method sets the attribute in the underlying DOM element and therefore alters the structure of the DOM.


setSending

public void setSending()
Sets the value of the done attribute to DTDConstants.SENDING. This method should be called after a condition is met, all the command templates have been extracted and sent to the devices. After this method has been called, further calls to #getCommand return null to indicate that no more commands have to be sent for this task.


getCondition

public String getCondition()
Returns the condition of this task element. The condition is used to allow issuing the commands of this task, if fulfilled.


getComplete

public String getComplete()
Returns the complete condition tied to this task.


getCommands

public String[] getCommands()
Returns all broadcast templates.


getBroadcasts

public String[] getBroadcasts()
Returns all command templates tied to this task. If the status of the task element has been set to DTDConstants.SENDING (via the done attribute of the task), null is returned.


getBroadcastWith

public String getBroadcastWith(String template)
Returns the broadcast with-attribute linked to the broadcast with argumental template. If no id is present, null is returned.


getCommandInit

public String getCommandInit(String template)
Returns the command initialization string. Used for rendering templates.


getCommandParameter

public String getCommandParameter(String template)
Returns all parameter names linked to the command element whose template name is equal to the argument.


getCommandID

public String getCommandID(String template)
Returns the command id-attribute linked to the command with argumental command template. If no id is present, null is returned.


getCommandRef

public String getCommandRef(String template)
Returns the command ref-attribute linked to the command with argumental command template. If no ref attribute is present, the id-atrribute is returned.


getTrue

public String[] getTrue()
Returns all triggers by name that get true as tied to this task.


getFalse

public String[] getFalse()
Returns all triggers by name that get false as tied to this task.


toString

public String toString()
String version of a task element is its ID plus info on done/sending status if applicable.

Overrides:
toString in class Object

parseTask

private void parseTask(Element anchor)
                throws ParseException
Parses a DOM elements into all parts of a valid sequence task.

Throws:
ParseException

extractAll

private static String[] extractAll(Element src,
                                   String tag)
Returns a string array of all first child nodes of the nodes found in the list. This can only work if the node list consists of element nodes which have no attributes and a single text node as a child.