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