package experiments.e2dc2013.recs.plugins.energy; import schedframe.events.EventReason; import schedframe.resources.computing.ComputingResource; import schedframe.resources.computing.Processor; import schedframe.resources.computing.profiles.energy.ResourceEvent; import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirflowStateName; import schedframe.resources.devices.PhysicalResource; import schedframe.scheduling.manager.tasks.JobRegistry; import example.energy.BaseEnergyEstimationPlugin; public class RecsCpuBaseEEP extends BaseEnergyEstimationPlugin { private static int START_ID = 0; private static int END_ID = 8; protected double cpuTypeConstant; protected double inletTemperature; public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) { double powerConsumption = 0; Processor cpu = (Processor) resource; try { powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } return powerConsumption; } public double estimateAirThroughput(ResourceEvent event, JobRegistry jobRegistry, ComputingResource resource) { double airThroughput = 0; try { if(event.getReason() == EventReason.SIM_INIT) airThroughput = resource.getAirflowInterface().getAirflow(StandardAirflowStateName.OFF); else airThroughput = resource.getAirflowInterface().getAirflow(resource.getAirflowInterface().getAirflowState()); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } Integer resId = Integer.parseInt(resource.getName().split("_")[1]); if(resId >= START_ID && resId <= END_ID){ for(ComputingResource compResource: resource.getParent().getChildren()){ Integer id = Integer.parseInt(compResource.getName().split("_")[1]); if(id - resId == 9 || id - resId == -9){ try { airThroughput = airThroughput + compResource.getAirflowInterface().getAirflow(compResource.getAirflowInterface().getAirflowState())/2; } catch (NoSuchFieldException e) { } } } } return airThroughput; } }