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