[751] | 1 | package example.energy; |
---|
| 2 | |
---|
| 3 | import schedframe.resources.computing.ComputingNode; |
---|
| 4 | import schedframe.resources.computing.ComputingResource; |
---|
| 5 | import schedframe.resources.computing.Processor; |
---|
| 6 | import schedframe.resources.computing.profiles.energy.EnergyEvent; |
---|
| 7 | import schedframe.scheduling.manager.tasks.JobRegistry; |
---|
| 8 | |
---|
| 9 | public class ComputingNodeWithFanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { |
---|
| 10 | |
---|
| 11 | public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, |
---|
| 12 | ComputingResource resource) { |
---|
| 13 | double powerConsumption = 0; |
---|
| 14 | ComputingNode node = (ComputingNode) resource; |
---|
| 15 | for(Processor cpu: node.getProcessors()){ |
---|
| 16 | try{ |
---|
| 17 | powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue(); |
---|
| 18 | } catch (Exception e){ |
---|
| 19 | |
---|
| 20 | } |
---|
| 21 | } |
---|
| 22 | try { |
---|
| 23 | powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); |
---|
| 24 | powerConsumption = powerConsumption + node.getAirThroughputInterface().getPowerConsumption(node.getAirThroughputInterface().getAirThroughputState()); |
---|
| 25 | } catch (NoSuchFieldException e) { |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | return powerConsumption; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { |
---|
| 32 | double airThroughput = 0; |
---|
| 33 | try { |
---|
| 34 | airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState()); |
---|
| 35 | } catch (NoSuchFieldException e) { |
---|
| 36 | // TODO Auto-generated catch block |
---|
| 37 | e.printStackTrace(); |
---|
| 38 | } |
---|
| 39 | return airThroughput; |
---|
| 40 | //throw new RuntimeException("Not implemented."); |
---|
| 41 | } |
---|
| 42 | } |
---|