Changeset 539 for DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/airthroughput
- Timestamp:
- 10/31/12 13:52:06 (12 years ago)
- Location:
- DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/airthroughput
- Files:
-
- 9 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
r477 r539 1 1 package schedframe.resources.computing.profiles.energy.airthroughput; 2 2 3 import java.util.ArrayList; 3 4 import java.util.List; 5 6 import org.joda.time.DateTimeUtils; 4 7 5 8 import schedframe.Parameters; … … 8 11 public class AirThroughputProfile { 9 12 10 AirThroughputEstimationPlugin airThroughputEstimationPlugin; 13 protected List<AirFlowValue> airFlowHistory; 14 15 protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; 11 16 protected List <AirThroughputState> airThroughputStates; 17 protected Parameters parameters; 12 18 13 19 public AirThroughputProfile(AirThroughputEstimationPlugin airThroughputEstimationPlugin, List<AirThroughputState> airThroughputStates) { … … 15 21 this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 16 22 this.airThroughputStates = airThroughputStates; 23 this.airFlowHistory = new ArrayList<AirFlowValue>(); 17 24 } 18 25 … … 21 28 } 22 29 23 public void init(Parameters parameters){ 24 30 public void addToPowerUsageHistory(double airFlow) { 31 32 if (airFlowHistory.size() == 0) { 33 AirFlowValue usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 34 airFlowHistory.add(usage); 35 return; 36 } 37 38 int lastIdx = airFlowHistory.size() - 1; 39 double lastAirFlow = airFlowHistory.get(lastIdx).getValue(); 40 if (lastAirFlow != airFlow) { 41 AirFlowValue usage = airFlowHistory.get(lastIdx); 42 long currentTime = DateTimeUtils.currentTimeMillis(); 43 if (usage.getTimestamp() == currentTime) { 44 usage.setValue(airFlow); 45 if(lastIdx > 0 && airFlowHistory.get(lastIdx - 1).getValue() == airFlow) 46 airFlowHistory.remove(usage); 47 } else { 48 usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 49 airFlowHistory.add(usage); 50 } 51 } 52 } 53 54 public List<AirFlowValue> getAirThroughputHistory() { 55 return airFlowHistory; 56 } 57 58 public void init(Parameters params){ 59 this.parameters = params; 60 } 61 62 public Parameters getParameters() { 63 return parameters; 25 64 } 26 65 }
Note: See TracChangeset
for help on using the changeset viewer.