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