Revision 1207,
1.5 KB
checked in by wojtekp, 11 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Line | |
---|
1 | package example.energy; |
---|
2 | |
---|
3 | import schedframe.resources.ResourceStatus; |
---|
4 | import schedframe.resources.computing.Processor; |
---|
5 | import schedframe.resources.computing.profiles.energy.EnergyEvent; |
---|
6 | import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; |
---|
7 | import schedframe.resources.devices.PhysicalResource; |
---|
8 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
9 | |
---|
10 | public class ProcessorEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
11 | |
---|
12 | public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, |
---|
13 | PhysicalResource resource) { |
---|
14 | double powerConsumption; |
---|
15 | |
---|
16 | Processor cpu = (Processor)resource; |
---|
17 | if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) |
---|
18 | powerConsumption = 0; |
---|
19 | else { |
---|
20 | if(resource.getStatus() == ResourceStatus.BUSY){ |
---|
21 | try { |
---|
22 | |
---|
23 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); |
---|
24 | } catch (NoSuchFieldException e) { |
---|
25 | try { |
---|
26 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON); |
---|
27 | } catch (NoSuchFieldException e1) { |
---|
28 | powerConsumption = 10; |
---|
29 | } |
---|
30 | } |
---|
31 | } else{ |
---|
32 | try { |
---|
33 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); |
---|
34 | } catch (NoSuchFieldException e) { |
---|
35 | try { |
---|
36 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON); |
---|
37 | } catch (NoSuchFieldException e1) { |
---|
38 | powerConsumption = 0; |
---|
39 | } |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | } |
---|
44 | return powerConsumption; |
---|
45 | } |
---|
46 | |
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.