Class Schedule
- java.lang.Object
- 
- ptolemy.actor.sched.ScheduleElement
- 
- ptolemy.actor.sched.Schedule
 
 
- 
- Direct Known Subclasses:
- SequenceSchedule
 
 public class Schedule extends ScheduleElement This class represents a static schedule of actor executions. An instance of this class is returned by the scheduler of a model to represent order of actor firings in the model. A schedule consists of a list of schedule elements and the number of times the schedule should repeat (called the iteration count).Each element of the schedule is represented by an instance of the ScheduleElement class. Each element may correspond to a number of firings of a single actor (represented by the Firing class) or an entire sub-schedule (represented by a hierarchically contained instance of this class). This nesting allows this concise representation of looped schedules. The nesting can be arbitrarily deep, but must be a tree where the leaf nodes represent actor firings. It is up to the scheduler to enforce this requirement. The add() and remove() methods are used to add or remove schedule elements. Only elements of type ScheduleElement (Schedule or Firing) may be added to the schedule list. Otherwise an exception will occur. The iteration count is set by the setIterationCount() method. If this method is not invoked, a default value of one will be used. As an example, suppose that we have an SDF graph containing actors A, B, C, and D, with the firing order ABCBCBCDD. This firing order can be represented by a simple looped schedule. The code to create this schedule appears below. Schedule S = new Schedule(); Firing S1 = new Firing(); Schedule S2 = new Schedule(); Firing S3 = new Firing(); S.add(S1); S.add(S2); S.add(S3); S1.setActor(A); S2.setIterationCount(3); Firing S2_1 = new Firing(); Firing S2_2 = new Firing(); S2_1.setActor(B); S2_2.setActor(C); S2.add(S2_1); S2.add(S2_2); S3.setIterationCount(2); S3.setActor(D); Note that this implementation is not synchronized. It is therefore not safe for a thread to make modifications to the schedule structure while multiple threads are concurrently accessing the schedule. ReferencesS. S. Bhattacharyya, P K. Murthy, and E. A. Lee, Software Syntheses from Dataflow Graphs, Kluwer Academic Publishers, 1996. - Since:
- Ptolemy II 1.0
- Version:
- $Id$
- Author:
- Brian K. Vogel, Steve Neuendorffer
- See Also:
- Firing,- ScheduleElement
- Pt.AcceptedRating:
- Yellow (chf)
- Pt.ProposedRating:
- Green (vogel)
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.List<ScheduleElement>_scheduleThe list of schedule elements contained by this schedule.- 
Fields inherited from class ptolemy.actor.sched.ScheduleElement_parent
 
- 
 - 
Constructor SummaryConstructors Constructor Description Schedule()Construct a schedule with iteration count of one and an empty schedule list.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.IteratoractorIterator()Return the actor sequence in the schedule.voidadd(int index, ScheduleElement element)Insert the specified schedule element at the specified position in the schedule list.voidadd(ScheduleElement element)Append the specified schedule element to the end of the schedule list.java.util.IteratorfiringIterator()Return the actor invocation sequence of this schedule in the form of a sequence of firings.ScheduleElementget(int index)Return the element at the specified position in the list.java.util.Iteratoriterator()Return an iterator over the schedule elements of this schedule.ScheduleElementremove(int index)Remove the schedule element at the specified position in the schedule list.intsize()Return the number of elements in this list.java.lang.StringtoString()Output a string representation of this Schedule.- 
Methods inherited from class ptolemy.actor.sched.ScheduleElement_getVersion, _incrementVersion, getIterationCount, setIterationCount, setParent
 
- 
 
- 
- 
- 
Field Detail- 
_scheduleprotected java.util.List<ScheduleElement> _schedule The list of schedule elements contained by this schedule.
 
- 
 - 
Method Detail- 
actorIteratorpublic java.util.Iterator actorIterator() Return the actor sequence in the schedule. A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active.Implementation note: This method is optimized to be memory efficient. It walks the schedule tree structure as the iterator methods are invoked. - Specified by:
- actorIteratorin class- ScheduleElement
- Returns:
- An iterator over instances of Firing.
- Throws:
- java.util.ConcurrentModificationException- If the underlying schedule structure is modified while the iterator is active.
- InternalErrorException- If the schedule contains any leaf nodes that are not an instance of Firing.
 
 - 
addpublic void add(ScheduleElement element) Append the specified schedule element to the end of the schedule list. This element must be an instance of ScheduleElement.- Parameters:
- element- The schedule element to add.
 
 - 
addpublic void add(int index, ScheduleElement element)Insert the specified schedule element at the specified position in the schedule list. This element must be an instance of ScheduleElement. An exception is thrown if the index is out of range.- Parameters:
- index- The index at which the specified element is to be inserted.
- element- The schedule element to add.
- Throws:
- java.lang.IndexOutOfBoundsException- If the specified index is out of range (index < 0 || index > size()).
 
 - 
firingIteratorpublic java.util.Iterator firingIterator() Return the actor invocation sequence of this schedule in the form of a sequence of firings. All of the lowest-level nodes of the schedule should be an instance of Firing. Otherwise an exception will occur at some point in the iteration.A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active. Implementation note: This method is optimized to be memory efficient. It walks the schedule tree structure as the iterator methods are invoked. - Specified by:
- firingIteratorin class- ScheduleElement
- Returns:
- An iterator over a sequence of firings.
- Throws:
- java.util.ConcurrentModificationException- If the underlying schedule structure is modified while the iterator is active.
 
 - 
getpublic ScheduleElement get(int index) Return the element at the specified position in the list.- Parameters:
- index- The index of the element to return.
- Returns:
- The element at the specified position in the list.
 
 - 
iteratorpublic java.util.Iterator iterator() Return an iterator over the schedule elements of this schedule. The ordering of elements in the iterator sequence is the order of the schedule list. The elements of the iterator sequence are instances of Firing or Schedule.A runtime exception is thrown if the underlying schedule structure is modified while the iterator is active. - Returns:
- An iterator over the schedule elements of this schedule.
- Throws:
- java.util.ConcurrentModificationException- If the underlying schedule structure is modified while the iterator is active.
 
 - 
removepublic ScheduleElement remove(int index) Remove the schedule element at the specified position in the schedule list.- Parameters:
- index- The index of the schedule element to be removed.
- Returns:
- The schedule element that was removed.
 
 - 
sizepublic int size() Return the number of elements in this list.- Returns:
- The number of elements in this list.
 
 - 
toStringpublic java.lang.String toString() Output a string representation of this Schedule.- Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-