Index: DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java	(revision 769)
+++ DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java	(revision 820)
@@ -17,4 +17,7 @@
 import schedframe.resources.computing.profiles.energy.power.PowerProfile;
 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
+import schedframe.resources.computing.profiles.energy.thermal.ThermalInterfaceFactory;
+import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile;
+import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
 import schedframe.scheduling.manager.tasks.JobRegistryImpl;
 
@@ -29,18 +32,13 @@
 	protected AirThroughputProfile airFlowProfile;
 	
+	protected ThermalInterface thermalInterface;
+	protected ThermalProfile thermalProfile;
+	
   	protected ComputingResource computingResource;
 
-	public EnergyExtension(PowerInterface powerInterface, PowerProfile pp) {
-		this.powerInterface = powerInterface;
-		this.powerProfile = pp;
-	}
 
-	public EnergyExtension(PowerInterface powerInterface, PowerProfile powerProfile,
-			AirThroughputInterface airFlowInterface, AirThroughputProfile airFlowProfile) {
-		super();
-		this.powerInterface = powerInterface;
+	public EnergyExtension(ComputingResource computingResource, PowerInterface powerInterface, PowerProfile powerProfile) {
 		this.powerProfile = powerProfile;
-		this.airFlowInterface = airFlowInterface;
-		this.airFlowProfile = airFlowProfile;
+		this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile);
 	}
 	
@@ -53,4 +51,16 @@
 		this.airFlowProfile = airFlowProfile;
 		this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile);
+	}
+	
+	public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile,
+			AirThroughputProfile airFlowProfile, ThermalProfile thermalProfile) {
+		super();
+		this.computingResource = computingResource;
+		this.powerProfile = powerProfile;
+		this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile);
+		this.airFlowProfile = airFlowProfile;
+		this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile);
+		this.thermalProfile = thermalProfile;
+		this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(computingResource, thermalProfile);
 	}
 
@@ -67,7 +77,7 @@
 		else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName()))
 			return true;
-		
-		if(airFlowProfile == null)
-			return false;	
+		else if(event.getType().getName().equals(EnergyEventType.RESOURCE_UTILIZATION_CHANGED.getName()))
+			return true;
+	
 		if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName()))
 			return true;
@@ -77,49 +87,70 @@
 
 	public void handleEvent(Event event) {
+		
 		EnergyEvent enEvent = (EnergyEvent)event;
 		double power = 0;
-		switch (enEvent.getType()) {
-		
-		case POWER_STATE_CHANGED:
-			power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-			/*if(computingResource instanceof ComputingNode){
-				ComputingNode node = (ComputingNode)computingResource;
-				if(event.getData() instanceof PowerState){
-					PowerState newState = (PowerState)event.getData();
-					if(newState == PowerState.ON) {
-						addToPowerUsageHistory(power+node.getPowerInterface().START_COST);
-						addToPowerUsageHistory(DateTimeUtils.currentTimeMillis()+node.getPowerInterface().START_TIME, power);
-					}else if(newState == PowerState.OFF){
-						addToPowerUsageHistory(power+node.getPowerInterface().SHUTDOWN_COST);
-						addToPowerUsageHistory(DateTimeUtils.currentTimeMillis()+node.getPowerInterface().SHUTDOWN_TIME, power);
+		double temperature = 0;
+		try{
+			switch (enEvent.getType()) {
+			
+			case POWER_STATE_CHANGED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				/*if(computingResource instanceof ComputingNode){
+					ComputingNode node = (ComputingNode)computingResource;
+					if(event.getData() instanceof PowerState){
+						PowerState newState = (PowerState)event.getData();
+						if(newState == PowerState.ON) {
+							addToPowerUsageHistory(power+node.getPowerInterface().START_COST);
+							addToPowerUsageHistory(DateTimeUtils.currentTimeMillis() + node.getPowerInterface().START_TIME, power);
+						}else if(newState == PowerState.OFF){
+							addToPowerUsageHistory(power+node.getPowerInterface().SHUTDOWN_COST);
+							addToPowerUsageHistory(DateTimeUtils.currentTimeMillis() + node.getPowerInterface().SHUTDOWN_TIME, power);
+						}
 					}
 				}
+				else*/ powerProfile.addToPowerUsageHistory(power);
+				break;
+				
+			case FREQUENCY_CHANGED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				powerProfile.addToPowerUsageHistory(power);
+				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case TASK_STARTED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				powerProfile.addToPowerUsageHistory(power);
+				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				thermalProfile.addToTemperatureHistory(temperature);
+				break;
+	
+			case TASK_FINISHED:
+				//System.out.println(this.resource.getName() + " - ENERGY EXTENSION: TASK FINISHED");
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power);
+				powerProfile.addToPowerUsageHistory(power);
+				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case RESOURCE_UTILIZATION_CHANGED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				powerProfile.addToPowerUsageHistory(power);
+				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case AIRFLOW_STATE_CHANGED:
+				double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				airFlowProfile.addToPowerUsageHistory(airFlow);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				powerProfile.addToPowerUsageHistory(power);
+				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				thermalProfile.addToTemperatureHistory(temperature);
+				break;
 			}
-			else*/ powerProfile.addToPowerUsageHistory(power);
-			break;
+		}catch(Exception e){
 			
-		case FREQUENCY_CHANGED:
-			power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-			powerProfile.addToPowerUsageHistory(power);
-			break;
-			
-		case TASK_STARTED:
-			power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-			powerProfile.addToPowerUsageHistory(power);
-			break;
-
-		case TASK_FINISHED:
-			//System.out.println(this.resource.getName() + " - ENERGY EXTENSION: TASK FINISHED");
-			power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-			//System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power);
-			powerProfile.addToPowerUsageHistory(power);
-			break;
-		case AIRFLOW_STATE_CHANGED:
-			System.out.println("=====" + computingResource.getName());
-			double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-			airFlowProfile.addToPowerUsageHistory(airFlow);
-			power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-			powerProfile.addToPowerUsageHistory(power);
-			break;
 		}
 	}
@@ -156,4 +187,12 @@
 		return airFlowProfile;
 	}
+	
+	public ThermalProfile getThermalProfile() {
+		return thermalProfile;
+	}
+
+	public ThermalInterface getThermalInterface() {
+		return thermalInterface;
+	}
 
 }
