Revision 883,
1.5 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 { |
---|
[883] | 19 | if(resource.getStatus() == ResourceStatus.BUSY){ |
---|
| 20 | try { |
---|
| 21 | |
---|
[580] | 22 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); |
---|
[883] | 23 | } catch (NoSuchFieldException e) { |
---|
| 24 | try { |
---|
| 25 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON); |
---|
| 26 | } catch (NoSuchFieldException e1) { |
---|
| 27 | powerConsumption = 10; |
---|
| 28 | } |
---|
[580] | 29 | } |
---|
[883] | 30 | } else{ |
---|
[497] | 31 | try { |
---|
[883] | 32 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); |
---|
| 33 | } catch (NoSuchFieldException e) { |
---|
| 34 | try { |
---|
| 35 | powerConsumption = cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON); |
---|
| 36 | } catch (NoSuchFieldException e1) { |
---|
| 37 | powerConsumption = 0; |
---|
| 38 | } |
---|
[497] | 39 | } |
---|
[477] | 40 | } |
---|
[883] | 41 | |
---|
[497] | 42 | } |
---|
[532] | 43 | return powerConsumption; |
---|
[477] | 44 | } |
---|
| 45 | |
---|
| 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.