package test.article2.recs.plugins.energy; import schedframe.events.scheduling.EventReason; import schedframe.resources.computing.ComputingResource; import schedframe.resources.computing.Processor; import schedframe.resources.computing.profiles.energy.EnergyEvent; import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName; 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(EnergyEvent event, JobRegistry jobRegistry, ComputingResource 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(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { double airThroughput = 0; try { if(event.getReason() == EventReason.SIM_INIT) airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF); else airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState()); } 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.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2; } catch (NoSuchFieldException e) { } } } } return airThroughput; } }