Revision 546,
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 | |
---|
[542] | 3 | import schedframe.resources.computing.ComputingResource; |
---|
| 4 | import schedframe.resources.computing.profiles.energy.EnergyEvent; |
---|
| 5 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
[477] | 6 | |
---|
[542] | 7 | |
---|
[477] | 8 | public class DefaultEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{ |
---|
| 9 | |
---|
[542] | 10 | |
---|
| 11 | public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { |
---|
| 12 | double powerConsumption = 0; |
---|
| 13 | try { |
---|
| 14 | powerConsumption = resource.getPowerInterface().getPowerConsumption(resource.getPowerInterface().getPowerState()); |
---|
| 15 | } catch (NoSuchFieldException e) { |
---|
| 16 | powerConsumption = 0; |
---|
| 17 | } |
---|
[546] | 18 | |
---|
| 19 | powerConsumption = powerConsumption + getChildrenPowerConsumption(resource); |
---|
| 20 | |
---|
[542] | 21 | for(ComputingResource child:resource.getChildren()){ |
---|
[546] | 22 | try { |
---|
| 23 | //powerConsumption = powerConsumption + child.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 24 | } catch (Exception e) { |
---|
| 25 | |
---|
| 26 | } |
---|
[542] | 27 | } |
---|
| 28 | return powerConsumption; |
---|
[477] | 29 | } |
---|
[546] | 30 | |
---|
| 31 | private double getChildrenPowerConsumption(ComputingResource resource){ |
---|
| 32 | double powerConsumption = 0; |
---|
| 33 | for(ComputingResource child:resource.getChildren()){ |
---|
| 34 | try { |
---|
| 35 | powerConsumption = powerConsumption + child.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 36 | } catch (Exception e) { |
---|
| 37 | powerConsumption = powerConsumption + getChildrenPowerConsumption(child); |
---|
| 38 | } |
---|
| 39 | } |
---|
| 40 | return powerConsumption; |
---|
| 41 | } |
---|
[477] | 42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.