- Timestamp:
- 10/10/12 12:12:06 (13 years ago)
- Location:
- DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput
- Files:
-
- 2 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
r477 r495 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; … … 7 10 8 11 public class AirThroughputProfile { 12 13 protected List<AirFlowValue> airFlowHistory; 9 14 10 15 protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; … … 16 21 this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 17 22 this.airThroughputStates = airThroughputStates; 23 this.airFlowHistory = new ArrayList<AirFlowValue>(); 18 24 } 19 25 20 26 public List<AirThroughputState> getAirThroughputStates() { 21 27 return airThroughputStates; 28 } 29 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; 22 56 } 23 57 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java
r477 r495 10 10 public String getAirThroughputState(); 11 11 12 public boolean setAirThroughputState(String airThroug putState);12 public boolean setAirThroughputState(String airThroughputState); 13 13 14 14 public boolean supportAirThroughputState(String powerState); -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/DefaultAirThroughputInterface.java
r477 r495 6 6 import schedframe.Parameters; 7 7 import schedframe.resources.computing.ComputingResource; 8 import schedframe.resources.computing.profiles.energy.EnergyEvent; 9 import schedframe.resources.computing.profiles.energy.EnergyEventType; 8 10 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 9 11 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 10 12 11 public class DefaultAirThroug putInterface implements AirThroughputInterface{13 public class DefaultAirThroughputInterface implements AirThroughputInterface{ 12 14 13 15 protected String currentAirThroughputState; 14 16 protected AirThroughputProfile airThroughputProfile; 15 17 protected ComputingResource resource; 18 19 public DefaultAirThroughputInterface(ComputingResource resource, AirThroughputProfile airThroughputProfile){ 20 this.resource = resource; 21 this.airThroughputProfile = airThroughputProfile; 22 } 16 23 17 24 public String getAirThroughputState() { … … 22 29 if(supportAirThroughputState(state)){ 23 30 currentAirThroughputState = state; 31 32 //TO DO - notifications should be called for all resources starting form the lowest layer 33 resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName())); 34 24 35 return true; 25 36 } … … 28 39 29 40 public boolean supportAirThroughputState(String state) { 30 31 41 for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){ 32 42 if(airFlowState.getName().equals(state)){
Note: See TracChangeset
for help on using the changeset viewer.