dol: initial dol commit
[jump.git] / dol / src / dol / datamodel / mapping / ScheduleEntry.java
diff --git a/dol/src/dol/datamodel/mapping/ScheduleEntry.java b/dol/src/dol/datamodel/mapping/ScheduleEntry.java
new file mode 100644 (file)
index 0000000..2ee5331
--- /dev/null
@@ -0,0 +1,113 @@
+/* $Id: ScheduleEntry.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.pn.Schedulable;\r
+import dol.visitor.MapVisitor;\r
+\r
+/**\r
+ * This class represents an origin element in the mapping which refers\r
+ * to a PN process or a SW channel with a configuration element.\r
+ */\r
+public class ScheduleEntry extends MapResource {\r
+\r
+    /**\r
+     * Constructor to create a ScheduleProcess with a name.\r
+     */\r
+    public ScheduleEntry(String name) {\r
+        super(name);\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 ScheduleProcess resource.\r
+     *\r
+     * @return new instance of the ScheduleProcess resource.\r
+     */\r
+    @SuppressWarnings("unchecked")\r
+    public Object clone() {\r
+        ScheduleEntry newObj = (ScheduleEntry) super.clone();\r
+        newObj.setConsumer(_consumer);\r
+        newObj.setCfgList((Vector<Configuration>)_cfgList.clone());\r
+        return (newObj);\r
+    }\r
+\r
+    /**\r
+     * Get the list of configurations of this scheduled process.\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 scheduled process.\r
+     *\r
+     * @param cfgList configuration list\r
+     */\r
+    public void setCfgList(Vector<Configuration> cfgList) {\r
+        _cfgList = cfgList;\r
+    }\r
+\r
+    /** Set the consumer */\r
+    public void setConsumer(Schedulable c) {\r
+        _consumer = c;\r
+    }\r
+\r
+    /** Get the consumer */\r
+    public Schedulable getConsumer() {\r
+        return _consumer;\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 ScheduleProcess.\r
+     *\r
+     * @return string representation of the ScheduleProcess\r
+     */\r
+    public String toString() {\r
+        return "ScheduleProcess: " + getName();\r
+    }\r
+\r
+    /** Consumer: PN process or SW channel */\r
+    private Schedulable _consumer = null;\r
+\r
+    /** list of the configurations of the ScheduleProcess */\r
+    protected Vector<Configuration> _cfgList = null;\r
+\r
+    /** Configuration key for the priority of a task in a fixed priority scheduler */\r
+    final public static String cfgFpPriority = "priority";\r
+\r
+    /** Configuration key for the index of the TDMA slot of a process */\r
+    final public static String cfgTdmaStartSlot = "startslot";\r
+\r
+    /** Configuration key for the number of TDMA slots for a process */\r
+    final public static String cfgTdmaNumberOfSlots = "numberofslots";\r
+\r
+}\r