dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / mapping / Schedule.java
1 /* $Id: Schedule.java 1 2010-02-24 13:03:05Z haidw $ */\r
2 package dol.datamodel.mapping;\r
3 \r
4 import java.util.Vector;\r
5 \r
6 import dol.datamodel.architecture.ArchiResource;\r
7 import dol.visitor.MapVisitor;\r
8 \r
9 /**\r
10  * This class represents a schedule element in the mapping.\r
11  */\r
12 public class Schedule extends MapResource {\r
13 \r
14     /**\r
15      * Constructor to create a Schedule with a name.\r
16      */\r
17     public Schedule(String name) {\r
18         super(name);\r
19         _entryList = new Vector<ScheduleEntry>();\r
20         _cfgList = new Vector<Configuration>();\r
21     }\r
22 \r
23     /**\r
24      * Accept a Visitor\r
25      *\r
26      * @param x visitor object\r
27      */\r
28     public void accept(MapVisitor x) {\r
29         x.visitComponent(this);\r
30     }\r
31 \r
32     /**\r
33      * Clone this Schedule resource.\r
34      *\r
35      * @return new instance of the Schedule resource.\r
36      */\r
37     @SuppressWarnings("unchecked")\r
38     public Object clone() {\r
39         Schedule newObj = (Schedule) super.clone();\r
40         newObj.setResource(_resource);\r
41         newObj.setSchedPolicy(_policy);\r
42         newObj.setCfgList((Vector<Configuration>)_cfgList.clone() );\r
43         newObj.setEntryList((Vector<ScheduleEntry>)_entryList.clone());\r
44         return (newObj);\r
45     }\r
46 \r
47     /** Set the resource, a HW channel or a processor from the architecture */\r
48     public void setResource(ArchiResource r) {\r
49         _resource = r;\r
50     }\r
51 \r
52     /** Get the resource */\r
53     public ArchiResource getResource() {\r
54         return _resource;\r
55     }\r
56 \r
57     /** Set the scheduling policy */\r
58     public void setSchedPolicy(SchedulingPolicy p) {\r
59         _policy = p;\r
60     }\r
61 \r
62     /** Get the scheduling policy */\r
63     public SchedulingPolicy getSchedPolicy() {\r
64         return _policy;\r
65     }\r
66 \r
67     /**\r
68      * Get the list of configurations of this schedule.\r
69      *\r
70      * @return list of configurations\r
71      */\r
72     public Vector<Configuration> getCfgList() {\r
73         return _cfgList;\r
74     }\r
75 \r
76     /**\r
77      * Set the list of configurations of this schedule.\r
78      *\r
79      * @param cfgList configuration list\r
80      */\r
81     public void setCfgList(Vector<Configuration> cfgList) {\r
82         _cfgList = cfgList;\r
83     }\r
84 \r
85     /**\r
86      * Set the list of scheduler table entries.\r
87      *\r
88      * @param entryList The new list\r
89      */\r
90     public void setEntryList(Vector<ScheduleEntry> entryList) {\r
91         _entryList = entryList;\r
92     }\r
93 \r
94     /** Get the list of scheduler table entries */\r
95     public Vector<ScheduleEntry> getEntryList() {\r
96         return _entryList;\r
97     }\r
98 \r
99     /**\r
100      * Return the scheduler table entry with its schedule configuration \r
101      * that has a specific name.\r
102      * Return null if the entry cannot be found.\r
103      *\r
104      * @param  name the name of the entry for which we are looking for.\r
105      * @return the entry with its schedule configuration with the specified name.\r
106      */\r
107     public ScheduleEntry getScheduleEntry(String name) {\r
108         for(ScheduleEntry entry : _entryList) {\r
109             if (entry.getName().equals(name)) {\r
110                 return entry;\r
111             }\r
112         }\r
113         return null;\r
114     }\r
115 \r
116     /**\r
117      * Return the value for the given configuration key. Return null\r
118      * when the key cannot be found.\r
119      *\r
120      * @param name name of the configuration key to search for\r
121      * @return value of the specified configuration key\r
122      */\r
123      public String getCfgValue(String name) {\r
124          for(Configuration c : _cfgList) {\r
125              if(c.getName().equals(name)) {\r
126                  return c.getValue();\r
127              }\r
128          }\r
129          return null;\r
130      }\r
131 \r
132     /**\r
133      * Return a string representation of the Schedule.\r
134      *\r
135      * @return string representation of the Schedule\r
136      */\r
137     public String toString() {\r
138         return "Schedule: " + getName();\r
139     }\r
140 \r
141     /** Resource that is scheduled */\r
142     ArchiResource _resource = null;\r
143 \r
144     /** Scheduling policy */\r
145     SchedulingPolicy _policy = null;\r
146 \r
147     /** List of the configurations of the Schedule */\r
148     protected Vector<Configuration> _cfgList = null;\r
149 \r
150     /** List of scheduler table entries */\r
151     Vector<ScheduleEntry> _entryList = null;\r
152 \r
153     /** Configuration key for the slots per cycle of a TDMA scheduler */\r
154     final public static String cfdTdmaSlotsPerCycle = "slotsonecycle";\r
155 \r
156     /** Configuration key for the general slot length\r
157      * in nanoseconds of a TDMA scheduler */\r
158     final public static String cfgTdmaSlotLength = "slotlength";\r
159 \r
160 }\r