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