Ignore:
Timestamp:
10/10/12 12:12:06 (13 years ago)
Author:
wojtekp
Message:
 
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  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import java.util.ArrayList; 
    34import java.util.List; 
     5 
     6import org.joda.time.DateTimeUtils; 
    47 
    58import schedframe.Parameters; 
     
    710 
    811public class AirThroughputProfile { 
     12         
     13        protected List<AirFlowValue> airFlowHistory; 
    914         
    1015        protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; 
     
    1621                this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 
    1722                this.airThroughputStates = airThroughputStates; 
     23                this.airFlowHistory = new ArrayList<AirFlowValue>(); 
    1824        } 
    1925 
    2026        public List<AirThroughputState> getAirThroughputStates() { 
    2127                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; 
    2256        } 
    2357         
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java

    r477 r495  
    1010        public String getAirThroughputState(); 
    1111         
    12         public boolean setAirThroughputState(String airThrougputState); 
     12        public boolean setAirThroughputState(String airThroughputState); 
    1313         
    1414        public boolean supportAirThroughputState(String powerState); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/DefaultAirThroughputInterface.java

    r477 r495  
    66import schedframe.Parameters; 
    77import schedframe.resources.computing.ComputingResource; 
     8import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     9import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    810import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    911import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    1012 
    11 public class DefaultAirThrougputInterface implements AirThroughputInterface{ 
     13public class DefaultAirThroughputInterface implements AirThroughputInterface{ 
    1214 
    1315        protected String currentAirThroughputState; 
    1416        protected AirThroughputProfile airThroughputProfile; 
    1517        protected ComputingResource resource; 
     18         
     19        public DefaultAirThroughputInterface(ComputingResource resource, AirThroughputProfile airThroughputProfile){ 
     20                this.resource = resource; 
     21                this.airThroughputProfile = airThroughputProfile; 
     22        } 
    1623         
    1724        public String getAirThroughputState() { 
     
    2229                if(supportAirThroughputState(state)){ 
    2330                        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 
    2435                        return true; 
    2536                } 
     
    2839 
    2940        public boolean supportAirThroughputState(String state) { 
    30  
    3141                for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){ 
    3242                        if(airFlowState.getName().equals(state)){ 
Note: See TracChangeset for help on using the changeset viewer.