source: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResource.java @ 1423

Revision 1423, 3.2 KB checked in by wojtekp, 11 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.resources.devices;
2
3import schedframe.Initializable;
4import schedframe.events.EventHandler;
5import schedframe.resources.Resource;
6import schedframe.resources.ResourceStatus;
7import schedframe.resources.ResourceType;
8import schedframe.resources.computing.ResourceCharacteristics;
9import schedframe.resources.computing.extensions.Extension;
10import schedframe.resources.computing.extensions.ExtensionList;
11import schedframe.resources.computing.extensions.ExtensionListImpl;
12import schedframe.resources.computing.extensions.ExtensionType;
13import schedframe.resources.computing.profiles.energy.EnergyExtension;
14import schedframe.resources.computing.profiles.energy.ResourceEvent;
15import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirflowInterface;
16import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
17import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
18import schedframe.resources.computing.profiles.load.LoadExtension;
19import schedframe.resources.computing.profiles.load.ui.LoadInterface;
20
21public abstract class PhysicalResource implements Resource, Initializable{
22
23        protected String name;
24        protected ResourceType type;
25        protected String category;
26        protected ResourceStatus status;
27        protected ResourceCharacteristics resourceCharacteristic;
28        protected ExtensionList extensionList;
29
30       
31        public abstract void handleEvent(ResourceEvent event);
32       
33        public abstract EventHandler getEventHandler();
34       
35        public String getName() {
36                return name;
37        }
38
39        public ResourceType getType() {
40                return type;
41        }
42
43        public String getCategory(){
44                return category;
45        }
46       
47        public abstract void setStatus(ResourceStatus newStatus);
48       
49        public ResourceStatus getStatus() {
50                return status;
51        }
52       
53        private Extension getExtension(ExtensionType type){
54                if (extensionList != null) {
55                        for (Extension extension : extensionList) {
56                                if (extension.getType() == type) {
57                                        return extension;
58                                }
59                        }
60                }
61                return null;
62        }
63       
64        public PowerInterface getPowerInterface(){
65                Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
66                if(extension != null){
67                        EnergyExtension ee = (EnergyExtension)extension;
68                        return ee.getPowerInterface();
69                }
70                return null;
71        }
72       
73        public AirflowInterface getAirflowInterface(){
74                Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
75                if(extension != null){
76                        EnergyExtension ee = (EnergyExtension)extension;
77                        return ee.getAirflowInterface();
78                }
79                return null;
80        }
81       
82        public ThermalInterface getThermalInterface(){
83                Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
84                if(extension != null){
85                        EnergyExtension ee = (EnergyExtension)extension;
86                        return ee.getThermalInterface();
87                }
88                return null;
89        }
90
91        public LoadInterface getLoadInterface(){
92                Extension extension = getExtension(ExtensionType.LOAD_EXTENSION);
93                if(extension != null){
94                        LoadExtension le = (LoadExtension)extension;
95                        return le.getLoadInterface();
96                }
97                return null;
98        }
99       
100        public ExtensionList getExtensionList() {
101                if(extensionList == null){
102                        return new ExtensionListImpl(0);
103                }
104                return extensionList;
105        }
106       
107        protected void accept(Extension e){
108                extensionList.add(e);
109        }
110
111        public ResourceCharacteristics getResourceCharacteristic() {
112                return resourceCharacteristic;
113        }
114       
115}
Note: See TracBrowser for help on using the repository browser.