dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / mapping / Schedule.java
diff --git a/dol/src/dol/datamodel/mapping/Schedule.java b/dol/src/dol/datamodel/mapping/Schedule.java
new file mode 100644 (file)
index 0000000..688afca
--- /dev/null
@@ -0,0 +1,160 @@
+/* $Id: Schedule.java 1 2010-02-24 13:03:05Z haidw $ */\r
+package dol.datamodel.mapping;\r
+\r
+import java.util.Vector;\r
+\r
+import dol.datamodel.architecture.ArchiResource;\r
+import dol.visitor.MapVisitor;\r
+\r
+/**\r
+ * This class represents a schedule element in the mapping.\r
+ */\r
+public class Schedule extends MapResource {\r
+\r
+    /**\r
+     * Constructor to create a Schedule with a name.\r
+     */\r
+    public Schedule(String name) {\r
+        super(name);\r
+        _entryList = new Vector<ScheduleEntry>();\r
+        _cfgList = new Vector<Configuration>();\r
+    }\r
+\r
+    /**\r
+     * Accept a Visitor\r
+     *\r
+     * @param x visitor object\r
+     */\r
+    public void accept(MapVisitor x) {\r
+        x.visitComponent(this);\r
+    }\r
+\r
+    /**\r
+     * Clone this Schedule resource.\r
+     *\r
+     * @return new instance of the Schedule resource.\r
+     */\r
+    @SuppressWarnings("unchecked")\r
+    public Object clone() {\r
+        Schedule newObj = (Schedule) super.clone();\r
+        newObj.setResource(_resource);\r
+        newObj.setSchedPolicy(_policy);\r
+        newObj.setCfgList((Vector<Configuration>)_cfgList.clone() );\r
+        newObj.setEntryList((Vector<ScheduleEntry>)_entryList.clone());\r
+        return (newObj);\r
+    }\r
+\r
+    /** Set the resource, a HW channel or a processor from the architecture */\r
+    public void setResource(ArchiResource r) {\r
+        _resource = r;\r
+    }\r
+\r
+    /** Get the resource */\r
+    public ArchiResource getResource() {\r
+        return _resource;\r
+    }\r
+\r
+    /** Set the scheduling policy */\r
+    public void setSchedPolicy(SchedulingPolicy p) {\r
+        _policy = p;\r
+    }\r
+\r
+    /** Get the scheduling policy */\r
+    public SchedulingPolicy getSchedPolicy() {\r
+        return _policy;\r
+    }\r
+\r
+    /**\r
+     * Get the list of configurations of this schedule.\r
+     *\r
+     * @return list of configurations\r
+     */\r
+    public Vector<Configuration> getCfgList() {\r
+        return _cfgList;\r
+    }\r
+\r
+    /**\r
+     * Set the list of configurations of this schedule.\r
+     *\r
+     * @param cfgList configuration list\r
+     */\r
+    public void setCfgList(Vector<Configuration> cfgList) {\r
+        _cfgList = cfgList;\r
+    }\r
+\r
+    /**\r
+     * Set the list of scheduler table entries.\r
+     *\r
+     * @param entryList The new list\r
+     */\r
+    public void setEntryList(Vector<ScheduleEntry> entryList) {\r
+        _entryList = entryList;\r
+    }\r
+\r
+    /** Get the list of scheduler table entries */\r
+    public Vector<ScheduleEntry> getEntryList() {\r
+        return _entryList;\r
+    }\r
+\r
+    /**\r
+     * Return the scheduler table entry with its schedule configuration \r
+     * that has a specific name.\r
+     * Return null if the entry cannot be found.\r
+     *\r
+     * @param  name the name of the entry for which we are looking for.\r
+     * @return the entry with its schedule configuration with the specified name.\r
+     */\r
+    public ScheduleEntry getScheduleEntry(String name) {\r
+        for(ScheduleEntry entry : _entryList) {\r
+            if (entry.getName().equals(name)) {\r
+                return entry;\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /**\r
+     * Return the value for the given configuration key. Return null\r
+     * when the key cannot be found.\r
+     *\r
+     * @param name name of the configuration key to search for\r
+     * @return value of the specified configuration key\r
+     */\r
+     public String getCfgValue(String name) {\r
+         for(Configuration c : _cfgList) {\r
+             if(c.getName().equals(name)) {\r
+                 return c.getValue();\r
+             }\r
+         }\r
+         return null;\r
+     }\r
+\r
+    /**\r
+     * Return a string representation of the Schedule.\r
+     *\r
+     * @return string representation of the Schedule\r
+     */\r
+    public String toString() {\r
+        return "Schedule: " + getName();\r
+    }\r
+\r
+    /** Resource that is scheduled */\r
+    ArchiResource _resource = null;\r
+\r
+    /** Scheduling policy */\r
+    SchedulingPolicy _policy = null;\r
+\r
+    /** List of the configurations of the Schedule */\r
+    protected Vector<Configuration> _cfgList = null;\r
+\r
+    /** List of scheduler table entries */\r
+    Vector<ScheduleEntry> _entryList = null;\r
+\r
+    /** Configuration key for the slots per cycle of a TDMA scheduler */\r
+    final public static String cfdTdmaSlotsPerCycle = "slotsonecycle";\r
+\r
+    /** Configuration key for the general slot length\r
+     * in nanoseconds of a TDMA scheduler */\r
+    final public static String cfgTdmaSlotLength = "slotlength";\r
+\r
+}\r