2ee5331440eb4d8c4119ff7c469b8ec473fd6864
[jump.git] / dol / src / dol / datamodel / mapping / ScheduleEntry.java
1 /* $Id: ScheduleEntry.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.pn.Schedulable;\r
7 import dol.visitor.MapVisitor;\r
8 \r
9 /**\r
10  * This class represents an origin element in the mapping which refers\r
11  * to a PN process or a SW channel with a configuration element.\r
12  */\r
13 public class ScheduleEntry extends MapResource {\r
14 \r
15     /**\r
16      * Constructor to create a ScheduleProcess with a name.\r
17      */\r
18     public ScheduleEntry(String name) {\r
19         super(name);\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 ScheduleProcess resource.\r
34      *\r
35      * @return new instance of the ScheduleProcess resource.\r
36      */\r
37     @SuppressWarnings("unchecked")\r
38     public Object clone() {\r
39         ScheduleEntry newObj = (ScheduleEntry) super.clone();\r
40         newObj.setConsumer(_consumer);\r
41         newObj.setCfgList((Vector<Configuration>)_cfgList.clone());\r
42         return (newObj);\r
43     }\r
44 \r
45     /**\r
46      * Get the list of configurations of this scheduled process.\r
47      *\r
48      * @return list of configurations\r
49      */\r
50     public Vector<Configuration> getCfgList() {\r
51         return _cfgList;\r
52     }\r
53 \r
54     /**\r
55      * Set the list of configurations of this scheduled process.\r
56      *\r
57      * @param cfgList configuration list\r
58      */\r
59     public void setCfgList(Vector<Configuration> cfgList) {\r
60         _cfgList = cfgList;\r
61     }\r
62 \r
63     /** Set the consumer */\r
64     public void setConsumer(Schedulable c) {\r
65         _consumer = c;\r
66     }\r
67 \r
68     /** Get the consumer */\r
69     public Schedulable getConsumer() {\r
70         return _consumer;\r
71     }\r
72 \r
73     /**\r
74      * Return the value for the given configuration key. Return null\r
75      * when the key cannot be found.\r
76      *\r
77      * @param name name of the configuration key to search for\r
78      * @return value of the specified configuration key\r
79      */\r
80      public String getCfgValue(String name) {\r
81          for(Configuration c : _cfgList) {\r
82              if(c.getName().equals(name)) {\r
83                  return c.getValue();\r
84              }\r
85          }\r
86          return null;\r
87      }\r
88 \r
89     /**\r
90      * Return a string representation of the ScheduleProcess.\r
91      *\r
92      * @return string representation of the ScheduleProcess\r
93      */\r
94     public String toString() {\r
95         return "ScheduleProcess: " + getName();\r
96     }\r
97 \r
98     /** Consumer: PN process or SW channel */\r
99     private Schedulable _consumer = null;\r
100 \r
101     /** list of the configurations of the ScheduleProcess */\r
102     protected Vector<Configuration> _cfgList = null;\r
103 \r
104     /** Configuration key for the priority of a task in a fixed priority scheduler */\r
105     final public static String cfgFpPriority = "priority";\r
106 \r
107     /** Configuration key for the index of the TDMA slot of a process */\r
108     final public static String cfgTdmaStartSlot = "startslot";\r
109 \r
110     /** Configuration key for the number of TDMA slots for a process */\r
111     final public static String cfgTdmaNumberOfSlots = "numberofslots";\r
112 \r
113 }\r