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.AirflowEstimationPlugin; public class AirflowProfile { protected List airflowHistory; protected AirflowEstimationPlugin airflowEstimationPlugin; protected List airflowStates; protected Parameters parameters; public AirflowProfile(AirflowEstimationPlugin airflowEstimationPlugin, List airflowStates) { super(); this.airflowEstimationPlugin = airflowEstimationPlugin; this.airflowStates = airflowStates; this.airflowHistory = new ArrayList(); } public List getAirflowStates() { return airflowStates; } public void addToAirFlowHistory(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 getAirflowHistory() { return airflowHistory; } public void init(Parameters params){ this.parameters = params; } public Parameters getParameters() { return parameters; } }