package schedframe.resources.computing.profiles.energy.airthroughput; import java.util.ArrayList; import java.util.List; import org.joda.time.DateTimeUtils; import schedframe.Parameters; import schedframe.resources.computing.profiles.energy.airthroughput.plugin.AirThroughputEstimationPlugin; public class AirThroughputProfile { protected List airFlowHistory; protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; protected List airThroughputStates; protected Parameters parameters; public AirThroughputProfile(AirThroughputEstimationPlugin airThroughputEstimationPlugin, List airThroughputStates) { super(); this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; this.airThroughputStates = airThroughputStates; this.airFlowHistory = new ArrayList(); } public List getAirThroughputStates() { return airThroughputStates; } public void addToPowerUsageHistory(double airFlow) { if (airFlowHistory.size() == 0) { AirFlowValue usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); airFlowHistory.add(usage); return; } int lastIdx = airFlowHistory.size() - 1; double lastAirFlow = airFlowHistory.get(lastIdx).getValue(); if (lastAirFlow != airFlow) { AirFlowValue usage = airFlowHistory.get(lastIdx); long currentTime = DateTimeUtils.currentTimeMillis(); if (usage.getTimestamp() == currentTime) { usage.setValue(airFlow); if(lastIdx > 0 && airFlowHistory.get(lastIdx - 1).getValue() == airFlow) airFlowHistory.remove(usage); } else { usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); airFlowHistory.add(usage); } } } public List getAirThroughputHistory() { return airFlowHistory; } public void init(Parameters params){ this.parameters = params; } public Parameters getParameters() { return parameters; } }