Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/FanEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/FanEnergyEstimationPlugin.java	(revision 1299)
@@ -2,6 +2,10 @@
 
 import schedframe.events.scheduling.EventReason;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
@@ -14,32 +18,36 @@
 		
 		double powerConsumption = 0;
-		/*try {
-			powerConsumption = resource.getAirThroughputInterface().getPowerConsumption(resource.getAirThroughputInterface().getAirThroughputState());
+		
+		Fan fan = (Fan) resource;
+		try {
+			powerConsumption = fan.getAirThroughputInterface().getPowerConsumption(fan.getAirThroughputInterface().getAirThroughputState());
 		} catch (NoSuchFieldException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
-		}*/
+		}
 
-		if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
+		/*if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
 			powerConsumption = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_POWER_CONSUMPTION;
 		} else {
 			powerConsumption = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
-		}
-		return powerConsumption;
+		}*/
+		return powerConsumption * getNumberOfWorkingNodes(fan)/(double)fan.getChilledResources().size();
 	}
 	
 	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		
 		double airThroughput = 0;
-		/*try {
+		Fan fan = (Fan) resource;
+		try {
 			if(event.getReason() == EventReason.SIM_INIT)
-				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+				airThroughput = fan.getAirThroughputInterface().getAirFlow(fan.getAirThroughputInterface().getAirThroughputState());
 			else
-				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+				airThroughput = fan.getAirThroughputInterface().getAirFlow(fan.getAirThroughputInterface().getAirThroughputState());
 		} catch (NoSuchFieldException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
-		}*/
+		}
 
-		if(event.getReason() == EventReason.SIM_INIT){
+		/*if(event.getReason() == EventReason.SIM_INIT){
 			if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
 				airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
@@ -54,8 +62,20 @@
 				airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
 			}
-		}
+		}*/
 
 		
-		return airThroughput;
+		return airThroughput * getNumberOfWorkingNodes(fan)/(double)fan.getChilledResources().size();
+	}
+	
+	private int getNumberOfWorkingNodes(Device device){
+		int quantity = 0;
+		Fan fan = (Fan) device;
+		for(ComputingResource compRes: device.getComputingResource().getChildren()){
+			Node node = (Node)compRes;
+			if(fan.getChilledResources().contains(node.getFullName()) && node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) ){
+				quantity++;
+			}
+		}
+		return quantity;
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java	(revision 1299)
@@ -1,7 +1,9 @@
 package example.energy.coolemall;
 
+import schedframe.resources.computing.Node;
 import schedframe.resources.computing.coolemall.ComputeBox1;
 import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
@@ -21,5 +23,14 @@
 			}
 		}
-		powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY;
+		
+		int nrOfPoweredOffNodes = 0;
+		for(Node node: computeBox1.getNodes()){
+			if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+				nrOfPoweredOffNodes++;
+			}
+		}
+		if(nrOfPoweredOffNodes != computeBox1.getNodes().size()){
+			powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY;			
+		}
 		return powerConsumption;
 	}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolEmAllTestbedMeasurements.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolEmAllTestbedMeasurements.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolEmAllTestbedMeasurements.java	(revision 1299)
@@ -4,36 +4,14 @@
 
 	//HARDWARE
-	public static final double SINGLE_FAN_ON_AIR_FLOW = 0.0112;
-	public static final double SINGLE_FAN_OFF_AIR_FLOW = 0;
+	//public static final double SINGLE_FAN_ON_AIR_FLOW = 0.0112;
+	//public static final double SINGLE_FAN_OFF_AIR_FLOW = 0;
 	
-	public static final double SINGLE_FAN_ON_POWER_CONSUMPTION = 6;
-	public static final double SINGLE_FAN_OFF_POWER_CONSUMPTION = 0;
+	//public static final double SINGLE_FAN_ON_POWER_CONSUMPTION = 0;
+	//public static final double SINGLE_FAN_OFF_POWER_CONSUMPTION = 0;
 	
-	public static final double OTHER_DEVICES_POWER_CONSUMPTION = 775;
+	public static final double OTHER_DEVICES_POWER_CONSUMPTION = 0;
 	
 	public static final double POWER_SUPPLY_EFFICIENCY = 0.87;
 	
 
-	public static final int Atom_D510_NR_OF_THREADS = 2;
-	
-	public static final int Atom_N2600_NR_OF_THREADS = 2;
-	
-	public static final int Core_i7_2715QE_NR_OF_THREADS = 4;
-	
-	public static final int Core_i7_3615QE_NR_OF_THREADS = 4;
-	
-	public static final int Fusion_G_T40N_NR_OF_THREADS = 2;
-	
-	//APPLICATIONS
-	public static final double Atom_D510 = 336.3;
-	
-	public static final double Atom_N2600 = 336.3;
-	
-	public static final double Core_i7_2715QE = 3076.4;
-	
-	public static final double Core_i7_3615QE = 3786.0;
-	
-	public static final double Fusion_G_T40N = 649.3;
-	
-
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpInletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpInletEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpInletEnergyEstimationPlugin.java	(revision 1299)
@@ -1,5 +1,11 @@
 package example.energy.coolemall;
 
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.ComputeBox1;
+import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
@@ -12,27 +18,68 @@
 			PhysicalResource resource) {
 		
+		/*********** Pfans_dc ***********/
 		double powerConsumption = 0;
+		double nf = 0.6;
+		
+		double delta_p;//from database, CFD
+		double Vair_total;
+		
+		delta_p = ConfigurationOptions.coolingData.getPressureDrop();
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		
+		if(delta_p != -1 && Vair_total != -1)
+			powerConsumption = delta_p * Vair_total / nf;
+		else {
+			Device flowPump = (Device) resource;
+			ComputingResource room = flowPump.getComputingResource();
+			
+			double ro = 1.168;//constant
+		
+			double mair_total;
+			
+			//in case of DCworms calculation of Vair_total
+			double mair_rack = 0;
 
-		double nf = 0.6;
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
 
-		double delta_p;//from database, CFD
-		try{
-			delta_p = ConfigurationOptions.pressureDrop;
-		} catch (Exception e){
-			delta_p = 0;
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
+						}
+					}
+				}
+			}
+			mair_total = mair_rack;
+			Vair_total = mair_total / ro;
+			
+
+			if(delta_p != -1 && Vair_total != -1)
+				powerConsumption = delta_p * Vair_total / nf;
 		}
 		
-		double Vair_total;
-		
-		try{
-			Vair_total = ConfigurationOptions.airFlowVolume;
-		} catch (Exception e){
-			Vair_total = 0;
-		}
-
-		
-		//if data not present in DB than don't take Pfans_dc into account
-		if(delta_p != -1 && Vair_total != -1)
-			powerConsumption = delta_p * Vair_total / nf;
+		//System.out.println("Flow Pump power: " + powerConsumption);
 		
 		return powerConsumption;
@@ -43,12 +90,54 @@
 		double Vair_total;
 		
-		try{
-			Vair_total = ConfigurationOptions.airFlowVolume;
-		} catch (Exception e){
-			Vair_total = 0;
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		if(Vair_total != -1) {
+			airThroughput = Vair_total;
+		} else {
+			Device flowPump = (Device) resource;
+			ComputingResource room = flowPump.getComputingResource();
+
+			double ro = 1.168;//constant
+			
+			double mair_total;
+			double mair_rack = 0;
+
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
+						}
+					}
+				}
+			}
+			mair_total = mair_rack;
+			Vair_total = mair_total / ro;
+			airThroughput = Vair_total;
 		}
-		airThroughput = Vair_total;
 		return airThroughput;
 	}
-
+	
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java	(revision 1253)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java	(revision 1299)
@@ -1,4 +1,6 @@
 package example.energy.coolemall;
 
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.Node;
 import schedframe.resources.computing.Processor;
@@ -6,14 +8,11 @@
 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
 import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
-import test.Node_Fan_Mapping;
 import example.energy.BaseEnergyEstimationPlugin;
 
 public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
 
-	//private static int OUT_START_ID = 0;
-	//private static int OUT_END_ID = 8;
-	
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
 			PhysicalResource resource) {
@@ -30,86 +29,36 @@
 			//powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
 			for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-				if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-					if(device.getPowerInterface().getRecentPowerUsage().getValue() == -1){
-						powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
-					}else
-						powerConsumption = powerConsumption + device.getPowerInterface().getRecentPowerUsage().getValue();
-					break;
+				if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+					Fan fan = (Fan) device;
+					if(fan.getChilledResources().contains(node.getFullName())){
+						if(fan.getPowerInterface().getRecentPowerUsage().getValue() == -1){
+							try {
+								powerConsumption = powerConsumption + fan.getAirThroughputInterface().getPowerConsumption(fan.getAirThroughputInterface().getAirThroughputState())/getNumberOfWorkingNodes(fan);
+							} catch (NoSuchFieldException e) {
+								// TODO Auto-generated catch block
+								e.printStackTrace();
+							}
+						}else
+							powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue()/getNumberOfWorkingNodes(fan);
+					}
 				}
 			}
 		} 
 
-
 		return powerConsumption;
 	}
-
-	/*public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
-
-		double airThroughput = 0;
-		try {
-			if(event.getReason() == EventReason.SIM_INIT)
-				return airThroughput;
-				//airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF);
-			else {
-				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
-				//airThroughput = computingResource.getResourceCharacteristic().getDevices().get(0).getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
-				//airThroughput = 0.28;
-			}
-		} catch (NoSuchFieldException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		
-		//Integer resId = Integer.parseInt(resource.getName().split("_")[1]);
-		//ComputingResource computingResource = (ComputingResource) resource;
-		//we estimate the air flow related to the outlets (nodes placed in the outlet row of RECS)
-		//if(resId >= OUT_START_ID  && resId <= OUT_END_ID){
-		//	for(ComputingResource compResource: computingResource.getParent().getChildren()){
-		//		Integer id = Integer.parseInt(compResource.getName().split("_")[1]);
-		//		//we take into account the inlet air flow (nodes placed "behind" the given node)
-		//		if(id - resId == 9 || id - resId == -9){
-		//			try {
-		//				airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2;
-		//			} catch (NoSuchFieldException e) {
-		//
-		//			}
-		//		}
-		//	}
-		//}
-
-		return airThroughput;
-	}*/
-
-	/*public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
-		double tout = 0;
-		double tin = 21.3;
-		double Q = 0.0056085;
-		double C = 1004;
-		double delta1 = 1.780594389/2;
-		double delta2 = 2.162043729/2;
-		double ro = 1.168;
-		double power1 = 0;
-		double power2 = 0;
-		
-		Integer resId = Integer.parseInt(resource.getName().split("_")[1]);
-		
-		ComputingResource computingResource = (ComputingResource) resource;
-		
-		//we estimate outlet temperature (related to the temperature of the nodes placed in outlet row)
-		for(ComputingResource compResource: computingResource.getParent().getChildren()){
-			Integer id = Integer.parseInt(compResource.getName().split("_")[1]);
-			//we take into account the power of nodes placed "behind" the given nodes
-			if(id - resId == 9){
-				power1 = compResource.getPowerInterface().getRecentPowerUsage().getValue();
-				power2 = resource.getPowerInterface().getRecentPowerUsage().getValue();
-			} else if(id - resId == -9){
-				power1 = resource.getPowerInterface().getRecentPowerUsage().getValue();
-				power2 = compResource.getPowerInterface().getRecentPowerUsage().getValue();
+	
+	
+	private int getNumberOfWorkingNodes(Device device){
+		int quantity = 0;
+		Fan fan = (Fan) device;
+		for(ComputingResource compRes: device.getComputingResource().getChildren()){
+			Node node = (Node)compRes;
+			if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON) && fan.getChilledResources().contains(node.getFullName())){
+				quantity++;
 			}
 		}
-		
-		tout = tin + delta1 * (power1/(Q * C * ro)) +  delta2 * (power2/(Q * C * ro));;
-		return tout;
-	}*/
-	
+		return quantity;
+	}
+
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB2EnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB2EnergyEstimationPlugin.java	(revision 1253)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB2EnergyEstimationPlugin.java	(revision 1299)
@@ -9,18 +9,16 @@
 import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
 import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 import simulator.ConfigurationOptions;
-import test.Node_Fan_Mapping;
 import example.energy.BaseEnergyEstimationPlugin;
 
 public class CB2EnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
 
-	
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
 			PhysicalResource resource) {
-		
 		
 		double Pdc;
@@ -36,9 +34,6 @@
 		
 		/*********** Pload_dc ***********/
-		for(ComputingResource cr: room.getChildren()){
-			ComputeBox1 cb1 = (ComputeBox1)cr;
-			Pload_dc = Pload_dc + cb1.getPowerInterface().getRecentPowerUsage().getValue();
-		}
-		
+		Pload_dc = calculatePit(room);
+
 		
 		
@@ -46,21 +41,15 @@
 		
 		/*********** Pothers ***********/		
-		double a;//experiment
-		try{
-			a = ConfigurationOptions.alpha;
-		} catch (Exception e){
-			a = 0.02;
-		}
-		
-		//if not defined assume alpha = 0.02
-		if(a == -1)
-			a = 0.02;
-		
-		Pothers = a * Pload_dc; 
+		Pothers = calculatePothers(Pload_dc);
 		
 		
 		
 		/************* COOLING PART *************/
-		
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
 		Device coolingDevice = null;
 		for(Device device: room.getResourceCharacteristic().getDevices()){
@@ -72,94 +61,190 @@
 
 		
-		/*********** Pfans_dc ***********/
-		double ro = 1.168;//constant
-		double nf;//DEBB
-		try{
-			nf = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CRAHFanEfficiency").get(0).getContent()).doubleValue();
-		} catch (Exception e){
-			nf = 0.6;
-		}
-		double delta_p;//from database, CFD
-		try{
-			delta_p = ConfigurationOptions.pressureDrop;
-		} catch (Exception e){
-			delta_p = -1;
-		}
-		
-		double Vair_total;
-		double mair_total;
-		
-		//in case of DCworms calculation of Vair_total
-		double mair_rack = 0;
-
+		double Pchiller = calculatePchiller(Pload_dc, Pfans_dc, Pothers, room);
+		double Pdry_cooler = calculatePdryCooler(Pload_dc, Pfans_dc, Pothers, room);
+		
+		double delta_Th_ex;//DEBB
+		try{
+			delta_Th_ex = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThEx").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_ex = 10;
+		}
+
+		double delta_Th_dry_cooler;//DEBB
+		try{
+			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_dry_cooler = 10;
+		}
+		
+		double Tamb;//experiment
+		try{
+			Tamb = ConfigurationOptions.coolingData.getAmbientAirTempeature();
+		} catch (Exception e){
+			Tamb = -1;
+		}
+
+		double Tr_out;//from database, CFD
+		try{
+			Tr_out = ConfigurationOptions.coolingData.getOutletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_out = -1;
+		}
+		
+		double Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		double Tev = Tr_in - delta_Th_ex;
+
+		
+		//if data not present in DB than don't take Pchiller into account
+		if(Tr_in != -1 && Tr_out != -1) {
+			if(Tamb != -1 && Tev - Tamb > 0 && delta_Th_dry_cooler < Tev - Tamb)
+				Pcooling_device = Pdry_cooler;
+			else
+				Pcooling_device = Pchiller;	
+		}
+		
+
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdry_cooler: " + Pdry_cooler + " Pchiller: "+ Pchiller);
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+		
+		//System.out.println("CB2 heat: " + Qload_dc + "; " + Qothers + "; " + Qfans_dc + "; " + Qdc);
+		//System.out.println("CB2 power: " + Pload_dc + "; " + Pothers + "; " + Pfans_dc + "; " + Pcooling_device + "; " + Pdc);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
 		for(ComputingResource cr: room.getChildren()){
 			ComputeBox1 cb1 = (ComputeBox1)cr;
-			for(NodeGroup nodeGroup: cb1.getNodesGroups()){
-				for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
-					if(device.getType().equals(StandardResourceType.Outlet)){
-						double mair_recs = 0;
-						double Vair_recs = 0;
-						
-						double Vair_recs1 = 0;
-						/*try {
-							Vair_recs1  = device.getAirThroughputInterface().getAirFlow(device.getAirThroughputInterface().getAirThroughputState());
-						} catch (NoSuchFieldException e) {
+			Pload_dc = Pload_dc + cb1.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		return Pload_dc;
+	}
+	
+	private double calculatePothers(double Pload_dc){
+		
+		double Pothers = 0;
+		
+		double a;//experiment
+		try{
+			a = ConfigurationOptions.coolingData.getAlpha();
+		} catch (Exception e){
+			a = 0.2;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		double nf;//DEBB
+		try{
+			nf = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CRAHFanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			nf = 0.6;
+		}
+		double delta_p;//from database, CFD
+		double Vair_total;
+		
+		delta_p = ConfigurationOptions.coolingData.getPressureDrop();
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		
+		if(delta_p != -1 && Vair_total != -1)
+			Pfans_dc = delta_p * Vair_total / nf;
+		else {
+			
+			double ro = 1.168;//constant
+		
+			double mair_total;
+			
+			double mair_rack = 0;
+
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
 						}
-						*/
-						if(device.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
-							Vair_recs1 = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
-						} else {
-							Vair_recs1 = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
-						}
-						double Vair_recs2 = 0;
-						for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
-							if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(device.getFullName().replace("Outlet", "Inlet"))){
-								/*try {
-									Vair_recs2  = device2.getAirThroughputInterface().getAirFlow(device2.getAirThroughputInterface().getAirThroughputState());
-								} catch (NoSuchFieldException e) {
-								}
-								*/
-								if(device2.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
-									Vair_recs2 = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
-								} else {
-									Vair_recs2 = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
-								}
-								break;
-							}
-						}	
-
-						Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
-
-						mair_recs = Vair_recs * ro;
-						mair_rack  = mair_rack + mair_recs;
 					}
 				}
 			}
-		}
-		mair_total = mair_rack;
-		Vair_total = mair_total / ro;
-		
-		//in case of CFD calculation of Vair_total
-		try{
-			Vair_total = ConfigurationOptions.airFlowVolume;
-		} catch (Exception e){
-			Vair_total = 0;
-		}
-		mair_total = Vair_total * ro;
-		
-		//if data not present in DB than don't take Pfans_dc into account
-		if(delta_p != -1 && Vair_total != -1)
-			Pfans_dc = delta_p * Vair_total / nf;
-		
-		
-		
-		/************ Pcooling_device ************/
-		
+			mair_total = mair_rack;
+			Vair_total = mair_total / ro;
+			
+
+			if(delta_p != -1 && Vair_total != -1)
+				Pfans_dc = delta_p * Vair_total / nf;
+		}
+		return Pfans_dc;
+	}
+	
+	private double calculatePchiller(double Pload_dc, double Pfans_dc, double Pothers, ComputingResource room){
 		
 		double Pchiller = 0;
-		double Pdry_cooler;
-		
-		/*********** Pchiller ***********/
-		double Cp = 1004;//constant
+		
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		double delta_Th_dry_cooler;//DEBB
+		try{
+			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_dry_cooler = 10;
+		}
+		
+		double Tamb;//experiment
+		try{
+			Tamb = ConfigurationOptions.coolingData.getAmbientAirTempeature();
+		} catch (Exception e){
+			Tamb = -1;
+		}
 		
 		double ncc;//DEBB
@@ -174,5 +259,5 @@
 			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
 		} catch (Exception e){
-			Qcooling_rated = 3000;
+			Qcooling_rated = 80000;
 		}
 		
@@ -183,11 +268,4 @@
 			EERrated = 5;
 		}
-		
-		double Tco;//DEBB
-		try{
-			Tco = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CWT").get(0).getContent()).doubleValue();
-		} catch (Exception e){
-			Tco = 30;
-		}
 
 		double delta_Th_ex;//DEBB
@@ -197,21 +275,12 @@
 			delta_Th_ex = 10;
 		}
-
-		double Tr_out;//from database, CFD
-		try{
-			Tr_out = ConfigurationOptions.outletRoomAirTempeature;
-		} catch (Exception e){
-			Tr_out = -1;
-		}
 		
 		double Tr_in;//experiment
 		try{
-			Tr_in = ConfigurationOptions.inletRoomAirTempeature;
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
 		} catch (Exception e){
 			Tr_in = -1;
 		}
-		
-		double Qdc;
-		double Qcooling;
+
 		
 		double Tev;		
@@ -228,9 +297,12 @@
 		
 		
-		Qdc = mair_total * Cp * (Tr_out - Tr_in);
-		Qcooling = Qdc / ncc;
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
 
 		Tev = Tr_in - delta_Th_ex;
 		double Tevf = 32 + 1.8 * Tev;
+		
+		double Tco = Tamb + delta_Th_dry_cooler;
+		
 		double Tcof = 32 + 1.8 * Tco;
 		CoolT = 0.647177 + 0.015888 * Tevf + 0.000103 * Math.pow(Tevf, 2) - 0.004167 * Tcof + 0.000007 * Math.pow(Tcof, 2) - 0.000064 * Tevf * Tcof;
@@ -247,45 +319,61 @@
 		Pchiller = Qcooling/EER;
 
-			
-		
-
-		/*********** Pdry_cooler ***********/
-		double delta_Th_dry_cooler;//DEBB
-		try{
-			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
-		} catch (Exception e){
-			delta_Th_dry_cooler = 10;
-		}
-		
-		double Tamb;//experiment
-		try{
-			Tamb = ConfigurationOptions.ambientAirTempeature;
-		} catch (Exception e){
-			Tamb = -1;
-		}
-		
-		Pdry_cooler = 0.02 * Qcooling;
-		
-		
-		//if data not present in DB than don't take Pchiller into account
-		if(Vair_total != -1 && Tr_in != -1 && Tr_out != -1) {
-			if(Tamb != -1 && Tev - Tamb > 0 && delta_Th_dry_cooler > Tev - Tamb)
-				Pcooling_device = Pdry_cooler;
-			else
-				Pcooling_device = Pchiller;	
-		}
-		
-		
-
-		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
-		//System.out.println("---");
-		//System.out.println("Pdry_cooler: " + Pdry_cooler + " Pchiller: "+ Pchiller);
-		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
-		
-		
-		
-		
+		return Pchiller;
+	}
+	
+	private double calculatePdryCooler(double Pload_dc, double Pfans_dc, double Pothers, ComputingResource room){
+
+		double Pdry_cooler = 0;
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		double n_dry_cooler;//DEBB
+		try{
+			 n_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("dryCoolerEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			 n_dry_cooler = 0.02;
+		}
+
+		double ncc;//DEBB
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+
+		Pdry_cooler = n_dry_cooler * Qcooling;
+		
+		return Pdry_cooler;
+	}
+	
+	private double calculateQ(double Pfans_dc, double Pothers, ComputingResource room){
+
+		double Qdc = 0;
+		
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		double nf;//DEBB
+		try{
+			nf = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CRAHFanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			nf = 0.6;
+		}
+
 		/**************** HEAT ****************/
-		double Qdc2;
 		
 		double Qload_dc = 0;
@@ -306,40 +394,120 @@
 						Qcpu = Qcpu + proc.getPowerInterface().getRecentPowerUsage().getValue();
 					}
-					double Qfan = 0;
-					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-							if(device.getPowerInterface().getRecentPowerUsage().getValue() == -1){
-								Qfan = Qfan + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
-							}else
-								Qfan = Qfan + device.getPowerInterface().getRecentPowerUsage().getValue();
-							break;
+					Qnodes = Qnodes + Qcpu;
+				}
+				double Qfans = 0;
+				for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+					Fan fan = (Fan) device;
+					if(fan.getPowerInterface().getRecentPowerUsage().getValue() == -1){
+						try {
+							Qfans = Qfans + (1 - delta_2) * fan.getAirThroughputInterface().getPowerConsumption(fan.getAirThroughputInterface().getAirThroughputState());
+						} catch (NoSuchFieldException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+					}else
+						Qfans = Qfans + (1 - delta_2) * fan.getPowerInterface().getRecentPowerUsage().getValue();
+				}
+				QnodeGroup = QnodeGroup + Qnodes + Qfans;
+			}
+			int nrOfPoweredOffNodes = 0;
+			for(Node node: cb1.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != cb1.getNodes().size()){
+				Qload_dc  = Qload_dc + QnodeGroup + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION;
+			} else {
+				Qload_dc  = Qload_dc + QnodeGroup;
+			}
+		}
+		
+		Qothers = Pothers;
+		
+		Qfans_dc = (1 - nf) * Pfans_dc;
+		
+		Qdc = Qload_dc + Qothers + Qfans_dc;
+
+		
+		return Qdc;
+	}
+	
+	
+	private double calculateQ2(ComputingResource room){
+
+		double Qdc = 0;
+
+		double mair_total;
+		double Vair_total;
+		double ro = 1.168;//constant
+		
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		
+		if(Vair_total != -1) {
+			mair_total = Vair_total * ro;
+		}
+		else {
+	
+			//in case of DCworms calculation of Vair_total
+			double mair_rack = 0;
+
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
 						}
 					}
-					Qnodes = Qnodes + Qcpu + (1 - delta_2) * Qfan;
 				}
-				QnodeGroup = QnodeGroup + Qnodes;
-			}
-			Qload_dc  = Qload_dc + QnodeGroup;
-		}
-		
-		Qload_dc = Qload_dc + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION;
-		
-		Qothers = Pothers;
-		
-		Qfans_dc = (1 - nf) * Pfans_dc;
-		
-		Qdc2 = Qload_dc + Qothers + Qfans_dc;
-		
-		double Qdc2v2 = 0;
-		
-		if(Vair_total != -1 && Tr_in != -1 && Tr_out != -1)
-			Qdc2v2 = mair_total * Cp * (Tr_out - Tr_in);
-
-		//System.out.println("Qdc2: " + Qdc2 + " Qdc2v2: " + Qdc2v2 + "diff: " + (Qdc2v2 - Qdc2));
-
-		
-		return Pdc;
-	}
-	
-
+			}
+			mair_total = mair_rack;
+		}
+		
+		double Cp = 1004;//constant
+
+
+		double Tr_out;//from database, CFD
+		try{
+			Tr_out = ConfigurationOptions.coolingData.getOutletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_out = -1;
+		}
+		
+		double Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+
+		Qdc = mair_total * Cp * (Tr_out - Tr_in);
+		
+		return Qdc;
+	}
+	
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpOutletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1299)
@@ -1,5 +1,11 @@
 package example.energy.coolemall;
 
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.ComputeBox1;
+import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
@@ -21,12 +27,53 @@
 		double Vair_total;
 		
-		try{
-			Vair_total = ConfigurationOptions.airFlowVolume;
-		} catch (Exception e){
-			Vair_total = 0;
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		if(Vair_total != -1) {
+			airThroughput = Vair_total;
+		} else {
+			Device flowPump = (Device) resource;
+			ComputingResource room = flowPump.getComputingResource();
+
+			double ro = 1.168;//constant
+			
+			double mair_total;
+			double mair_rack = 0;
+
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
+						}
+					}
+				}
+			}
+			mair_total = mair_rack;
+			Vair_total = mair_total / ro;
+			airThroughput = Vair_total;
 		}
-		airThroughput = Vair_total;
 		return airThroughput;
 	}
-
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolingDeviceEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolingDeviceEnergyEstimationPlugin.java	(revision 1299)
@@ -1,7 +1,14 @@
 package example.energy.coolemall;
 
-import schedframe.events.scheduling.EventReason;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.ComputeBox1;
+import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
 import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
@@ -11,16 +18,205 @@
 public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
 
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airThroughput = 0;
+		return airThroughput;
+	}
+
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
 			PhysicalResource resource) {
 		
 		double powerConsumption = 0;
-
+		
 		Device coolingDevice = (Device) resource;
-
+		ComputingResource room = (ComputingResource) coolingDevice.getComputingResource();
+		
+		double Pload_dc = calculatePit(room);
+		double Pothers = calculatePothers(Pload_dc);
+		double Pfans_dc = calculatePfans(room);
+		
+		
+		double Pchiller = calculatePchiller(Pload_dc, Pfans_dc, Pothers, room);
+		double Pdry_cooler = calculatePdryCooler(Pload_dc, Pfans_dc, Pothers, room);
+		
+		
+		double delta_Th_ex;//DEBB
+		try{
+			delta_Th_ex = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThEx").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_ex = 10;
+		}
+
+		double delta_Th_dry_cooler;//DEBB
+		try{
+			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_dry_cooler = 10;
+		}
+		
+		double Tamb;//experiment
+		try{
+			Tamb = ConfigurationOptions.coolingData.getAmbientAirTempeature();
+		} catch (Exception e){
+			Tamb = -1;
+		}
+
+		double Tr_out;//from database, CFD
+		try{
+			Tr_out = ConfigurationOptions.coolingData.getOutletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_out = -1;
+		}
+		
+		double Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		double Tev = Tr_in - delta_Th_ex;
+		
+		//if data is not present in DB than don't take Pchiller into account
+		if(Tr_in != -1 && Tr_out != -1) {
+			if(Tamb != -1 && Tev - Tamb > 0 && delta_Th_dry_cooler < Tev - Tamb)
+				powerConsumption = Pdry_cooler;
+			else
+				powerConsumption = Pchiller;	
+		}
+		
+		
+		//System.out.println("CoolingDevice heat data: " + Qload_dc + "; " + Qothers + "; " + Qfans_dc + "; " + Qdc);
+		
+		//System.out.println("CoolingDevice power: " + powerConsumption);
+		
+		
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			ComputeBox1 cb1 = (ComputeBox1)cr;
+			Pload_dc = Pload_dc + cb1.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		return Pload_dc;
+	}
+	
+	private double calculatePothers(double Pload_dc){
+		
+		double Pothers = 0;
+		
+		double a;//experiment
+		try{
+			a = ConfigurationOptions.coolingData.getAlpha();
+		} catch (Exception e){
+			a = 0.2;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		double nf;//DEBB
+		try{
+			nf = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CRAHFanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			nf = 0.6;
+		}
+		double delta_p;//from database, CFD
+		double Vair_total;
+		
+		delta_p = ConfigurationOptions.coolingData.getPressureDrop();
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		
+		if(delta_p != -1 && Vair_total != -1)
+			Pfans_dc = delta_p * Vair_total / nf;
+		else {
+			
+			double ro = 1.168;//constant
+		
+			double mair_total;
+			
+			double mair_rack = 0;
+
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
+						}
+					}
+				}
+			}
+			mair_total = mair_rack;
+			Vair_total = mair_total / ro;
+			
+
+			if(delta_p != -1 && Vair_total != -1)
+				Pfans_dc = delta_p * Vair_total / nf;
+		}
+		return Pfans_dc;
+	}
+	
+	private double calculatePchiller(double Pload_dc, double Pfans_dc, double Pothers, ComputingResource room){
+		
 		double Pchiller = 0;
-		double Pdry_cooler;
-		
-		/*********** Pchiller ***********/
-		double Cp = 1004;//constant
+		
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		double delta_Th_dry_cooler;//DEBB
+		try{
+			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_dry_cooler = 10;
+		}
+		
+		double Tamb;//experiment
+		try{
+			Tamb = ConfigurationOptions.coolingData.getAmbientAirTempeature();
+		} catch (Exception e){
+			Tamb = -1;
+		}
 		
 		double ncc;//DEBB
@@ -35,5 +231,5 @@
 			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
 		} catch (Exception e){
-			Qcooling_rated = 3000;
+			Qcooling_rated = 80000;
 		}
 		
@@ -44,11 +240,4 @@
 			EERrated = 5;
 		}
-		
-		double Tco;//DEBB
-		try{
-			Tco = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CWT").get(0).getContent()).doubleValue();
-		} catch (Exception e){
-			Tco = 30;
-		}
 
 		double delta_Th_ex;//DEBB
@@ -58,34 +247,12 @@
 			delta_Th_ex = 10;
 		}
-
-		double Tr_out;//from database, CFD
-		try{
-			Tr_out = ConfigurationOptions.outletRoomAirTempeature;
-		} catch (Exception e){
-			Tr_out = -1;
-		}
 		
 		double Tr_in;//experiment
 		try{
-			Tr_in = ConfigurationOptions.inletRoomAirTempeature;
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
 		} catch (Exception e){
 			Tr_in = -1;
 		}
 
-		
-		
-		double ro = 1.168;//cosntant
-		double	Vair_total;
-		double mair_total;
-		try{
-			Vair_total = ConfigurationOptions.airFlowVolume;
-		} catch (Exception e){
-			Vair_total = 0;
-		}
-		mair_total = Vair_total * ro;
-		
-		
-		double Qdc;
-		double Qcooling;
 		
 		double Tev;		
@@ -102,9 +269,12 @@
 		
 		
-		Qdc = mair_total * Cp * (Tr_out - Tr_in);
-		Qcooling = Qdc / ncc;
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
 
 		Tev = Tr_in - delta_Th_ex;
 		double Tevf = 32 + 1.8 * Tev;
+		
+		double Tco = Tamb + delta_Th_dry_cooler;
+		
 		double Tcof = 32 + 1.8 * Tco;
 		CoolT = 0.647177 + 0.015888 * Tevf + 0.000103 * Math.pow(Tevf, 2) - 0.004167 * Tcof + 0.000007 * Math.pow(Tcof, 2) - 0.000064 * Tevf * Tcof;
@@ -121,54 +291,194 @@
 		Pchiller = Qcooling/EER;
 
-			
-		
-
-		/*********** Pdry_cooler ***********/
-		double delta_Th_dry_cooler;//DEBB
-		try{
-			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
-		} catch (Exception e){
-			delta_Th_dry_cooler = 10;
-		}
-		
-		double Tamb;//experiment
-		try{
-			Tamb = ConfigurationOptions.ambientAirTempeature;
-		} catch (Exception e){
-			Tamb = -1;
-		}
-		
-		Pdry_cooler = 0.02 * Qcooling;
-		
-		
-		//if data not present in DB than don't take Pchiller into account
-		if(Vair_total != -1 && Tr_in != -1 && Tr_out != -1) {
-			if(Tamb != -1 && Tev - Tamb > 0 && delta_Th_dry_cooler > Tev - Tamb)
-				powerConsumption = Pdry_cooler;
-			else
-				powerConsumption = Pchiller;	
-		}
-		
-		
-
-		
-		return powerConsumption;
-	}
-	
-	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
-		double airThroughput = 0;
-		try {
-			if(event.getReason() == EventReason.SIM_INIT)
-				return airThroughput;
-				//airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF);
-			else
-				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
-		} catch (NoSuchFieldException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-
-		return airThroughput;
-	}
-
+		return Pchiller;
+	}
+	
+	private double calculatePdryCooler(double Pload_dc, double Pfans_dc, double Pothers, ComputingResource room){
+
+		double Pdry_cooler = 0;
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		double n_dry_cooler;//DEBB
+		try{
+			 n_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("dryCoolerEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			 n_dry_cooler = 0.02;
+		}
+
+		double ncc;//DEBB
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+
+		Pdry_cooler = n_dry_cooler * Qcooling;
+		
+		return Pdry_cooler;
+	}
+	
+	private double calculateQ(double Pfans_dc, double Pothers, ComputingResource room){
+
+		double Qdc = 0;
+		
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		double nf;//DEBB
+		try{
+			nf = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CRAHFanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			nf = 0.6;
+		}
+
+		/**************** HEAT ****************/
+		
+		double Qload_dc = 0;
+		double Qothers = 0;
+		double Qfans_dc = 0;
+
+		double delta_2; //DEBB - currently not present;
+		delta_2 = 0.4;
+		
+		for(ComputingResource cr: room.getChildren()){
+			ComputeBox1 cb1 = (ComputeBox1)cr;
+			double QnodeGroup = 0;
+			for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+				double Qnodes = 0;
+				for(Node node: nodeGroup.getNodes()){
+					double Qcpu = 0;
+					for(Processor proc: node.getProcessors()){
+						Qcpu = Qcpu + proc.getPowerInterface().getRecentPowerUsage().getValue();
+					}
+					Qnodes = Qnodes + Qcpu;
+				}
+				double Qfans = 0;
+				for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+					Fan fan = (Fan) device;
+					if(fan.getPowerInterface().getRecentPowerUsage().getValue() == -1){
+						try {
+							Qfans = Qfans + (1 - delta_2) * fan.getAirThroughputInterface().getPowerConsumption(fan.getAirThroughputInterface().getAirThroughputState());
+						} catch (NoSuchFieldException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+					}else
+						Qfans = Qfans + (1 - delta_2) * fan.getPowerInterface().getRecentPowerUsage().getValue();
+				}
+				QnodeGroup = QnodeGroup + Qnodes + Qfans;
+			}
+			int nrOfPoweredOffNodes = 0;
+			for(Node node: cb1.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != cb1.getNodes().size()){
+				Qload_dc  = Qload_dc + QnodeGroup + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION;
+			} else {
+				Qload_dc  = Qload_dc + QnodeGroup;
+			}
+		}
+		
+		Qothers = Pothers;
+		
+		Qfans_dc = (1 - nf) * Pfans_dc;
+		
+		Qdc = Qload_dc + Qothers + Qfans_dc;
+
+		
+		return Qdc;
+	}
+	
+	
+	private double calculateQ2(ComputingResource room){
+
+		double Qdc = 0;
+
+		double mair_total;
+		double Vair_total;
+		double ro = 1.168;//constant
+		
+		Vair_total = ConfigurationOptions.coolingData.getAirFlowVolume();
+		
+		if(Vair_total != -1) {
+			mair_total = Vair_total * ro;
+		}
+		else {
+	
+			//in case of DCworms calculation of Vair_total
+			double mair_rack = 0;
+
+			for(ComputingResource cr: room.getChildren()){
+				ComputeBox1 cb1 = (ComputeBox1)cr;
+				for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Outlet)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirThroughputInterface().getRecentAirFlow().getValue();
+
+									break;
+								}
+							}	
+
+							Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+							mair_recs = Vair_recs * ro;
+							mair_rack  = mair_rack + mair_recs;
+						}
+					}
+				}
+			}
+			mair_total = mair_rack;
+		}
+		
+		double Cp = 1004;//constant
+
+
+		double Tr_out;//from database, CFD
+		try{
+			Tr_out = ConfigurationOptions.coolingData.getOutletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_out = -1;
+		}
+		
+		double Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+
+		Qdc = mair_total * Cp * (Tr_out - Tr_in);
+		
+		return Qdc;
+	}
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java	(revision 1299)
@@ -1,7 +1,4 @@
 package example.energy.coolemall;
 
-import dcworms.schedframe.scheduling.ExecTask;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.Core;
 import schedframe.resources.computing.Processor;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
@@ -9,6 +6,4 @@
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.tasks.phases.PhaseBehaviour;
 import example.energy.BaseEnergyEstimationPlugin;
 
@@ -18,29 +13,5 @@
 			PhysicalResource resource) {
 		
-		/*double powerConsumption = 0;
-		Processor cpu = (Processor)resource;
-		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
-			powerConsumption = 0;
-		else {
-			if(resource.getStatus() == ResourceStatus.BUSY){
-				try {
-					powerConsumption = cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState());
-				} catch (NoSuchFieldException e) {
-					Parameter param = cpu.getResourceCharacteristic().getParameters().get("maxPower");
-					if(param != null)
-						powerConsumption = Double.valueOf(param.get(0).getContent());
-				}
-			}
-			else {
-				try {
-					powerConsumption = cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON);
-				} catch (NoSuchFieldException e) {
-					Parameter param = cpu.getResourceCharacteristic().getParameters().get("maxPower");
-					if(param != null)
-						powerConsumption = 0.7 * Double.valueOf(param.get(0).getContent());
-				}
-			}
-		}
-		return powerConsumption;*/
+		double processorLoad = 0;
 		double powerConsumption = 0;
 		Processor proc = (Processor)resource;
@@ -48,44 +19,24 @@
 			return 0;
 		else {
-			double processorLoad;
-			double sumCoresLoad = 0;
-			
-			int nrOfThreadsOnCpu = 1;
-			
-			if(proc.getResourceCharacteristic().getParameters().get("product") != null){
-				String productName = proc.getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Fusion_G_T40N_NR_OF_THREADS;
-				else if(productName.equals("Atom - D510"))
-					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_D510_NR_OF_THREADS;
-				else if(productName.equals("Atom - N2600"))
-					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS;
-				else if(productName.equals("Core i7 - 2715QE"))
-					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS;
-				else if(productName.equals("Core i7 - 3615QE"))
-					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS;
-			}
 
-			for(Core core: proc.getCores()){
-				
-				if(core.getStatus().equals(ResourceStatus.BUSY)){
-					JobRegistry jr = new JobRegistryImpl(core.getFullName());
-					for(ExecTask task: jr.getRunningTasks()){
-						double cpuUsage = 100;
-						double nrOfThreadsOfApplciation = 1;
-						for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){
-							if(pb.getResouceName().equals("PM_CPU_Usage")){
-								cpuUsage = pb.getUtilization();
-							}
-							if(pb.getResouceName().equals("PM_Threads")){
-								nrOfThreadsOfApplciation = pb.getUtilization();
-								break;
-							}
-						}
-						sumCoresLoad = sumCoresLoad + cpuUsage * (nrOfThreadsOnCpu / nrOfThreadsOfApplciation);
-					}
+			/*double usedFreq = proc.getPowerInterface().getHighestPState().getFrequency();
+
+			JobRegistry jr = new JobRegistryImpl(proc.getFullName());
+			for(ExecTask task: jr.getRunningTasks()){
+				String taskFreqString = task.getCurrentResourceConsumption().getReferenceHardware().get("cpu_maxfreq");
+				double taskFreq = Double.valueOf(taskFreqString);
+				if(taskFreq > usedFreq){
+					usedFreq = taskFreq;
 				}
 			}
-			processorLoad = 100 * sumCoresLoad/proc.getCores().size();
+			
+			processorLoad = proc.getLoadInterface().getRecentUtilization().getValue();
+			//System.out.println(proc.getFullName() + "processorLoad v2: " +  processorLoad);
+			
+			if(processorLoad != 0 && proc.getPowerInterface().getFrequency() != usedFreq) {
+				proc.getPowerInterface().setFrequency(usedFreq);
+			}*/
+			
+			processorLoad = proc.getLoadInterface().getRecentUtilization().getValue();
 			double lowestLoadLevel = 100;
 			double highestLoadLevel = 0;
@@ -130,6 +81,5 @@
 						double a;
 						double b;
-						if(lowerLoadLevel != higherLoadLevel)
-						{
+						if(lowerLoadLevel != higherLoadLevel) {
 							powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowerLoadLevel);
 							powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(higherLoadLevel);
@@ -155,7 +105,4 @@
 			}
 		}
-			
-
-		powerConsumption = powerConsumption - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
 		//System.out.println("estiamted power consumption: " + powerConsumption);
 		return powerConsumption;
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationHighPerf_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationHighPerf_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationHighPerf_SP.java	(revision 1299)
@@ -0,0 +1,260 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_ConsolidationHighPerf_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_ConsolidationHighPerf_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new FavourableNodeComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+	class PerformanceComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MIN_VALUE;
+	    	double node2Rank = Double.MIN_VALUE;
+
+	    	double node1Speed = 0;
+	    	for(Processor proc: node1.getProcessors()){
+	    		node1Speed = node1Speed + proc.getMIPS();
+	    	}
+	    	node1Rank = node1Speed / node1.getProcessors().size();
+	    	
+	    	double node2Speed = 0;
+	    	for(Processor proc: node2.getProcessors()){
+	    		node2Speed = node2Speed + proc.getMIPS();
+	    	}
+	    	node2Rank = node2Speed / node2.getProcessors().size();
+	    	
+	    	if(node1Rank == node2Rank){
+	    		node1Rank = Double.MIN_VALUE;
+	    		node2Rank = Double.MIN_VALUE;
+	    		PState pState;
+		    	for(Processor proc: node1.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node1Rank){
+			    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+		    	for(Processor proc: node2.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node2Rank){
+			    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+	    	}
+	    	
+	        if(node1Rank < node2Rank)
+	        	return 1;
+	        else if (node1Rank > node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationLowPower_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationLowPower_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationLowPower_SP.java	(revision 1299)
@@ -0,0 +1,246 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_ConsolidationLowPower_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_ConsolidationLowPower_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new FavourableNodeComparator());
+		if(avNodes.size() == 0){
+			return null;
+		} 
+		
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 5;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 5;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+	class PowerComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+
+    		PState pState;
+	    	for(Processor proc: node1.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node1Rank){
+		    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	for(Processor proc: node2.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node2Rank){
+		    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationHighPerf_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationHighPerf_NodePowMan_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationHighPerf_NodePowMan_SP.java	(revision 1299)
@@ -0,0 +1,401 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_ConsolidationHighPerf_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_ConsolidationHighPerf_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = resourceManager.getNodes();
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+							Fan fan = (Fan) device;
+							if(fan.getChilledResources().contains(node.getFullName())){
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							}
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					
+					if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+						Fan fan = (Fan) device;
+						int nrOfChilldedNodes = fan.getChilledResources().size();
+						if(fan.getChilledResources().contains(node.getFullName())){
+							if(nrOfChilldedNodes == 1)
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							else {
+								for(String chilledNode: fan.getChilledResources()){
+									for(Node node2: nodes){
+										if(chilledNode.equals(node2.getFullName())){
+											if(node2.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+												nrOfChilldedNodes--;
+											}
+										}
+									}
+								}
+								if(nrOfChilldedNodes <= 1)
+									fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							}
+
+						}
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+	class PerformanceComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MIN_VALUE;
+	    	double node2Rank = Double.MIN_VALUE;
+
+	    	double node1Speed = 0;
+	    	for(Processor proc: node1.getProcessors()){
+	    		node1Speed = node1Speed + proc.getMIPS();
+	    	}
+	    	node1Rank = node1Speed / node1.getProcessors().size();
+	    	
+	    	double node2Speed = 0;
+	    	for(Processor proc: node2.getProcessors()){
+	    		node2Speed = node2Speed + proc.getMIPS();
+	    	}
+	    	node2Rank = node2Speed / node2.getProcessors().size();
+	    	
+	    	if(node1Rank == node2Rank){
+	    		node1Rank = Double.MIN_VALUE;
+	    		node2Rank = Double.MIN_VALUE;
+	    		PState pState;
+		    	for(Processor proc: node1.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node1Rank){
+			    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+		    	for(Processor proc: node2.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node2Rank){
+			    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+	    	}
+	    	
+	        if(node1Rank < node2Rank)
+	        	return 1;
+	        else if (node1Rank > node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationLowPower_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationLowPower_NodePowMan_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationLowPower_NodePowMan_SP.java	(revision 1299)
@@ -0,0 +1,385 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_ConsolidationLowPower_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_ConsolidationLowPower_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = resourceManager.getNodes();
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+							Fan fan = (Fan) device;
+							if(fan.getChilledResources().contains(node.getFullName())){
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							}
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					
+					if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+						Fan fan = (Fan) device;
+						int nrOfChilldedNodes = fan.getChilledResources().size();
+						if(fan.getChilledResources().contains(node.getFullName())){
+							if(nrOfChilldedNodes == 1)
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							else {
+								for(String chilledNode: fan.getChilledResources()){
+									for(Node node2: nodes){
+										if(chilledNode.equals(node2.getFullName())){
+											if(node2.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+												nrOfChilldedNodes--;
+											}
+										}
+									}
+								}
+								if(nrOfChilldedNodes <= 1)
+									fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							}
+
+						}
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 5;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 5;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+	class PowerComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+
+    		PState pState;
+	    	for(Processor proc: node1.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node1Rank){
+		    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	for(Processor proc: node2.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node2Rank){
+		    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java	(revision 1258)
+++ 	(revision )
@@ -1,210 +1,0 @@
-package example.localplugin.coolemall.computebox1;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Core;
-import schedframe.resources.computing.Node;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-import test.Node_Fan_Mapping;
-import example.localplugin.BaseLocalSchedulingPlugin;
-import gridsim.dcworms.DCWormsTags;
-
-public class CB1_FCFS_Consolidation_SP extends BaseLocalSchedulingPlugin {
-
-	
-	public CB1_FCFS_Consolidation_SP () {
-		Node_Fan_Mapping.init();
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			 ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-					}
-				}
-			}
-			break;
-		}
-		return plan;
-	}
-
-	@SuppressWarnings("unchecked")
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-		
-		List<Node> nodes = resourceManager.getNodes();
-		List<Node> avNodes = filterNodes(nodes, task);
-		Collections.sort(avNodes, new FavourableNodeComparator());
-		if(avNodes.size() == 0)
-			return null;
-		Node node = findTheMostLoadedNode(avNodes);
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-
-		if (cpuRequest != 0) {
-
-			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
-			
-			List<Core> cores = node.getCores();			
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
-				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
-					cpuRequest--;
-				}
-			}
-			if (cpuRequest > 0) {
-				return null;
-			}
-			//choosenResources.add(node.getProcessors().get(0));
-			ProcessingElements pe = new ProcessingElements();
-			pe.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, pe);
-			return map;
-		}
-		return null;
-	}
-	
-	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
-		List<Node> filteredNodes = new ArrayList<Node>();
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		for (Node node : nodes) {
-
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				
-				filteredNodes.add(node);
-			}
-		}
-		
-		return filteredNodes;
-	}
-	
-	private Node findTheMostLoadedNode(List<Node> nodes){
-		Node mostLoadedNode = null;
-			
-		int maxRunningTask = -1;
-		int nrRunningTasks;
-		for(Node node: nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getFullName());
-			nrRunningTasks = jr.getRunningTasks().size(); 
-			if(nrRunningTasks > maxRunningTask){
-				mostLoadedNode = node;
-				maxRunningTask = nrRunningTasks;
-			}
-		}
-		return mostLoadedNode;
-	}
-	
-	class FavourableNodeComparator implements Comparator<Node>{
-		
-	    public int compare(Node node1, Node node2){    
-	    	double node1Rank = Double.MAX_VALUE;
-	    	double node2Rank = Double.MAX_VALUE;
-	    	
-	    	try {
-				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node1Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node1Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node1Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node1Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node1Rank = 1;
-			} catch (Exception e){
-				
-			}
-	    	try {
-				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node2Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node2Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node2Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node2Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node2Rank = 1;
-			} catch (Exception e){
-				
-			}
-	        if(node1Rank > node2Rank)
-	        	return 1;
-	        else if (node1Rank < node2Rank)
-	        	return -1;
-	        else return 0;	   
-	    }
-	}
-	
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java	(revision 1258)
+++ 	(revision )
@@ -1,331 +1,0 @@
-package example.localplugin.coolemall.computebox1;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.exceptions.ResourceException;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.StandardResourceType;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Core;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
-import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.devices.Device;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-import test.Node_Fan_Mapping;
-import example.localplugin.BaseLocalSchedulingPlugin;
-import gridsim.dcworms.DCWormsTags;
-
-public class CB1_FCFS_Consolidation_NodePowMan_SP extends BaseLocalSchedulingPlugin {
-
-	
-	public CB1_FCFS_Consolidation_NodePowMan_SP () {
-		Node_Fan_Mapping.init();
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			 ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			
-			List<Node> notSelectedNodes = resourceManager.getNodes();
-			
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
-						Node node = (Node) pe.get(0).getParent().getParent();
-						notSelectedNodes.remove(node);
-					}
-				}
-			}
-			manageResources(notSelectedNodes);
-			break;
-		}
-		return plan;
-	}
-
-	@SuppressWarnings("unchecked")
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-		
-		List<Node> nodes = resourceManager.getNodes();
-		List<Node> avNodes = filterNodes(nodes, task);
-		Node node;
-		if(avNodes.size() == 0){
-			try {
-				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
-			} catch (ResourceException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-			Collections.sort(nodes, new FavourableNodeComparator());
-			node = turnOnFirstNode(nodes, task);
-			if(node == null)
-				return null;
-		} else {
-			Collections.sort(avNodes, new FavourableNodeComparator());
-			node = findTheMostLoadedNode(avNodes);			
-		}
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-
-		if (cpuRequest != 0) {
-
-			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
-			
-			List<Core> cores = node.getCores();			
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
-				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
-					cpuRequest--;
-				}
-			}
-			if (cpuRequest > 0) {
-				return null;
-			}
-			//choosenResources.add(node.getProcessors().get(0));
-			ProcessingElements pe = new ProcessingElements();
-			pe.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, pe);
-			return map;
-		}
-		return null;
-	}
-	
-	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
-		List<Node> filteredNodes = new ArrayList<Node>();
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		for (Node node : nodes) {
-
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				
-				filteredNodes.add(node);
-			}
-		}
-		
-		return filteredNodes;
-	}
-	
-	private Node findTheMostLoadedNode(List<Node> nodes){
-		Node mostLoadedNode = null;
-			
-		int maxRunningTask = -1;
-		int nrRunningTasks;
-		for(Node node: nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getFullName());
-			nrRunningTasks = jr.getRunningTasks().size(); 
-			if(nrRunningTasks > maxRunningTask){
-				mostLoadedNode = node;
-				maxRunningTask = nrRunningTasks;
-			}
-		}
-		return mostLoadedNode;
-	}
-	
-	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
-		Node startedNode = null;
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		
-		for(Node node: nodes){
-			
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-				
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				else {
-					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
-							break;
-						}
-					}
-					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
-					startedNode = node;
-					break;
-				}				
-			}
-		}
-		return startedNode;
-	}
-	
-	protected void manageResources(List<Node> notSelectedNodes) {
-		turnOffIdleNodes(notSelectedNodes);
-		//adjustFans(notSelectedNodes);
-	
-	}
-
-	private void turnOffIdleNodes(List<Node> nodes){
-		for(Node node : nodes){
-			Processor proc = node.getProcessors().get(0);
-			int freeCores = 0;
-			for(Core core: proc.getCores()){
-				if(core.getStatus() == ResourceStatus.FREE)
-					freeCores++;
-			}
-			
-			if(freeCores == proc.getCores().size()) {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
-						break;
-					}
-				}
-				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
-			}
-
-		}
-	}
-
-	/*private void adjustFans(List<Node> nodes) {
-		for (Node node : nodes) {
-
-			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
-						break;
-					}
-				}
-			} else {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
-						break;
-					}
-				}
-			}
-		}
-	}
-	*/
-	
-	class FavourableNodeComparator implements Comparator<Node>{
-		
-	    public int compare(Node node1, Node node2){    
-	    	double node1Rank = Double.MAX_VALUE;
-	    	double node2Rank = Double.MAX_VALUE;
-	    	
-	    	try {
-				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node1Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node1Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node1Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node1Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node1Rank = 1;
-			} catch (Exception e){
-				
-			}
-	    	try {
-				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node2Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node2Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node2Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node2Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node2Rank = 1;
-			} catch (Exception e){
-				
-			}
-	        if(node1Rank > node2Rank)
-	        	return 1;
-	        else if (node1Rank < node2Rank)
-	        	return -1;
-	        else return 0;	   
-	    }
-	}
-	
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java	(revision 1258)
+++ 	(revision )
@@ -1,331 +1,0 @@
-package example.localplugin.coolemall.computebox1;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.exceptions.ResourceException;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.StandardResourceType;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Core;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
-import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.devices.Device;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-import test.Node_Fan_Mapping;
-import example.localplugin.BaseLocalSchedulingPlugin;
-import gridsim.dcworms.DCWormsTags;
-
-public class CB1_FCFS_ConsolidationAtom_NodePowMan_SP extends BaseLocalSchedulingPlugin {
-
-	
-	public CB1_FCFS_ConsolidationAtom_NodePowMan_SP () {
-		Node_Fan_Mapping.init();
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			 ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			
-			List<Node> notSelectedNodes = resourceManager.getNodes();
-			
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
-						Node node = (Node) pe.get(0).getParent().getParent();
-						notSelectedNodes.remove(node);
-					}
-				}
-			}
-			manageResources(notSelectedNodes);
-			break;
-		}
-		return plan;
-	}
-
-	@SuppressWarnings("unchecked")
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-		
-		List<Node> nodes = resourceManager.getNodes();
-		List<Node> avNodes = filterNodes(nodes, task);
-		Node node;
-		if(avNodes.size() == 0){
-			try {
-				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
-			} catch (ResourceException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-			Collections.sort(nodes, new FavourableNodeComparator());
-			node = turnOnFirstNode(nodes, task);
-			if(node == null)
-				return null;
-		} else {
-			Collections.sort(avNodes, new FavourableNodeComparator());
-			node = findTheMostLoadedNode(avNodes);			
-		}
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-
-		if (cpuRequest != 0) {
-
-			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
-			
-			List<Core> cores = node.getCores();			
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
-				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
-					cpuRequest--;
-				}
-			}
-			if (cpuRequest > 0) {
-				return null;
-			}
-			//choosenResources.add(node.getProcessors().get(0));
-			ProcessingElements pe = new ProcessingElements();
-			pe.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, pe);
-			return map;
-		}
-		return null;
-	}
-	
-	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
-		List<Node> filteredNodes = new ArrayList<Node>();
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		for (Node node : nodes) {
-
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				
-				filteredNodes.add(node);
-			}
-		}
-		
-		return filteredNodes;
-	}
-	
-	private Node findTheMostLoadedNode(List<Node> nodes){
-		Node mostLoadedNode = null;
-			
-		int maxRunningTask = -1;
-		int nrRunningTasks;
-		for(Node node: nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getFullName());
-			nrRunningTasks = jr.getRunningTasks().size(); 
-			if(nrRunningTasks > maxRunningTask){
-				mostLoadedNode = node;
-				maxRunningTask = nrRunningTasks;
-			}
-		}
-		return mostLoadedNode;
-	}
-	
-	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
-		Node startedNode = null;
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		
-		for(Node node: nodes){
-			
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-				
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				else {
-					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
-							break;
-						}
-					}
-					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
-					startedNode = node;
-					break;
-				}				
-			}
-		}
-		return startedNode;
-	}
-	
-	protected void manageResources(List<Node> notSelectedNodes) {
-		turnOffIdleNodes(notSelectedNodes);
-		//adjustFans(notSelectedNodes);
-	
-	}
-
-	private void turnOffIdleNodes(List<Node> nodes){
-		for(Node node : nodes){
-			Processor proc = node.getProcessors().get(0);
-			int freeCores = 0;
-			for(Core core: proc.getCores()){
-				if(core.getStatus() == ResourceStatus.FREE)
-					freeCores++;
-			}
-			
-			if(freeCores == proc.getCores().size()) {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
-						break;
-					}
-				}
-				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
-			}
-
-		}
-	}
-
-	/*private void adjustFans(List<Node> nodes) {
-		for (Node node : nodes) {
-
-			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
-						break;
-					}
-				}
-			} else {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
-						break;
-					}
-				}
-			}
-		}
-	}
-	*/
-	
-	class FavourableNodeComparator implements Comparator<Node>{
-		
-	    public int compare(Node node1, Node node2){    
-	    	double node1Rank = Double.MAX_VALUE;
-	    	double node2Rank = Double.MAX_VALUE;
-	    	
-	    	try {
-				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node1Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node1Rank = 2;
-				else if(productName.equals("Atom - N2600"))
-					node1Rank = 1;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node1Rank = 4;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node1Rank = 5;
-			} catch (Exception e){
-				
-			}
-	    	try {
-				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node2Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node2Rank = 2;
-				else if(productName.equals("Atom - N2600"))
-					node2Rank = 1;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node2Rank = 4;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node2Rank = 5;
-			} catch (Exception e){
-				
-			}
-	        if(node1Rank > node2Rank)
-	        	return 1;
-	        else if (node1Rank < node2Rank)
-	        	return -1;
-	        else return 0;	   
-	    }
-	}
-	
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java	(revision 1258)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java	(revision 1299)
@@ -8,7 +8,10 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
 import schedframe.resources.computing.Node;
-import schedframe.resources.computing.Processor;
 import schedframe.resources.units.ProcessingElements;
 import schedframe.resources.units.ResourceUnit;
@@ -18,5 +21,4 @@
 import schedframe.scheduling.manager.resources.ResourceManager;
 import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
 import schedframe.scheduling.plan.SchedulingPlanInterface;
 import schedframe.scheduling.plan.impl.SchedulingPlan;
@@ -25,8 +27,5 @@
 import schedframe.scheduling.queue.TaskQueueList;
 import schedframe.scheduling.tasks.TaskInterface;
-import schedframe.scheduling.tasks.phases.PhaseBehaviour;
 import test.Node_Fan_Mapping;
-import dcworms.schedframe.scheduling.ExecTask;
-import example.energy.coolemall.CoolEmAllTestbedMeasurements;
 import example.localplugin.BaseLocalSchedulingPlugin;
 import gridsim.dcworms.DCWormsTags;
@@ -62,4 +61,11 @@
 				if (task.getStatus() == DCWormsTags.READY) {
 
+					try {
+						if(resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Core, ResourceStatus.FREE).size() == 0)
+							break;
+					} catch (ResourceException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
 					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
 					if (choosenResources != null) {
@@ -70,7 +76,7 @@
 			break;
 		}
+		
 		return plan;
 	}
-
 	@SuppressWarnings("unchecked")
 	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
@@ -94,6 +100,16 @@
 
 			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
-			
-			choosenResources.add(node.getProcessors().get(0));
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			//choosenResources.add(node.getProcessors().get(0));
 			ProcessingElements pe = new ProcessingElements();
 			pe.addAll(choosenResources);
@@ -116,43 +132,19 @@
 			if (cpuRequest != 0) {
 
-				double sumLoad = 0;
-				Processor proc = node.getProcessors().get(0);
-				JobRegistry jr = new JobRegistryImpl(proc.getFullName());
-				for(ExecTask execTask: jr.getRunningTasks()){
-					double cpuUsage = 100;
-					double nrOfThreadsOfApplciation = 1;
-					for(PhaseBehaviour pb: execTask.getCurrentResourceConsumption().getBehaviourList()){
-						if(pb.getResouceName().equals("PM_CPU_Usage")){
-							cpuUsage = pb.getUtilization();
-						}
-						if(pb.getResouceName().equals("PM_Threads")){
-							nrOfThreadsOfApplciation = pb.getUtilization();
-							break;
-						}
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
 					}
-					sumLoad = sumLoad + nrOfThreadsOfApplciation;
 				}
 
-				int nrOfThreadsOnCpu = 1;
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
 				
-				if(proc.getResourceCharacteristic().getParameters().get("product") != null){
-					String productName = proc.getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-					if(productName.equals("Fusion G - T40N"))
-						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Fusion_G_T40N_NR_OF_THREADS;
-					else if(productName.equals("Atom - D510"))
-						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_D510_NR_OF_THREADS/2;
-					else if(productName.equals("Atom - N2600"))
-						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS/2;
-					else if(productName.equals("Core i7 - 2715QE"))
-						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS/2;
-					else if(productName.equals("Core i7 - 3615QE"))
-						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS/2;
-				}
-
-				System.out.println(sumLoad + ":" + nrOfThreadsOnCpu + ";" + cpuRequest);
-				int freeThreads = (int) (nrOfThreadsOnCpu - sumLoad) ;
-
-				
-				if(freeThreads < cpuRequest)
+				if(freeCores < cpuRequest)
 					continue;
 				
@@ -167,5 +159,4 @@
 		return nodes.get(rand.nextInt(nodes.size()));
 	}
-
 	
 }
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_SP.java	(revision 1299)
@@ -0,0 +1,282 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_ConsolidationHighPerf_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_ConsolidationHighPerf_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new PerformanceComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else {
+	        	//return 0;
+		    	double node1LoadRank = Double.MIN_VALUE;
+		    	double node2LoadRank = Double.MIN_VALUE;
+		    	
+		    	try {
+		    		Rack rack1 = (Rack) node1.getParent().getParent();
+					JobRegistry jr1 = new JobRegistryImpl(rack1.getFullName());
+		    		node1LoadRank = jr1.getRunningTasks().size(); 
+		    		
+		    		Rack rack2 = (Rack) node2.getParent().getParent();
+					JobRegistry jr2 = new JobRegistryImpl(rack2.getFullName());
+		    		node2LoadRank = jr2.getRunningTasks().size(); 
+			        if(node1LoadRank < node2LoadRank)
+			        	return 1;
+			        else if (node1LoadRank > node2LoadRank)
+			        	return -1;
+			        else return 0;
+		    	} catch (Exception e){
+		    		return 0;
+		    	}
+   
+	        }
+	    }
+	}
+
+	class PerformanceComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MIN_VALUE;
+	    	double node2Rank = Double.MIN_VALUE;
+
+	    	double node1Speed = 0;
+	    	for(Processor proc: node1.getProcessors()){
+	    		node1Speed = node1Speed + proc.getMIPS();
+	    	}
+	    	node1Rank = node1Speed / node1.getProcessors().size();
+	    	
+	    	double node2Speed = 0;
+	    	for(Processor proc: node2.getProcessors()){
+	    		node2Speed = node2Speed + proc.getMIPS();
+	    	}
+	    	node2Rank = node2Speed / node2.getProcessors().size();
+	    	
+	    	if(node1Rank == node2Rank){
+	    		node1Rank = Double.MIN_VALUE;
+	    		node2Rank = Double.MIN_VALUE;
+	    		PState pState;
+		    	for(Processor proc: node1.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node1Rank){
+			    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+		    	for(Processor proc: node2.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node2Rank){
+			    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+	    	}
+	    	
+	        if(node1Rank < node2Rank)
+	        	return 1;
+	        else if (node1Rank > node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_SP.java	(revision 1299)
@@ -0,0 +1,200 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_ConsolidationLowPower_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_ConsolidationLowPower_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new PowerComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+
+	class PowerComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+
+    		PState pState;
+	    	for(Processor proc: node1.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node1Rank){
+		    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	for(Processor proc: node2.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node2Rank){
+		    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_NodePowMan_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_NodePowMan_SP.java	(revision 1299)
@@ -0,0 +1,423 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_ConsolidationHighPerf_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_ConsolidationHighPerf_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = resourceManager.getNodes();
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new PerformanceComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new PerformanceComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+							Fan fan = (Fan) device;
+							if(fan.getChilledResources().contains(node.getFullName())){
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							}
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					
+					if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+						Fan fan = (Fan) device;
+						int nrOfChilldedNodes = fan.getChilledResources().size();
+						if(fan.getChilledResources().contains(node.getFullName())){
+							if(nrOfChilldedNodes == 1)
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							else {
+								for(String chilledNode: fan.getChilledResources()){
+									for(Node node2: nodes){
+										if(chilledNode.equals(node2.getFullName())){
+											if(node2.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+												nrOfChilldedNodes--;
+											}
+										}
+									}
+								}
+								if(nrOfChilldedNodes <= 1)
+									fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							}
+
+						}
+					}
+					
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else {
+	        	//return 0;
+		    	double node1LoadRank = Double.MIN_VALUE;
+		    	double node2LoadRank = Double.MIN_VALUE;
+		    	
+		    	try {
+		    		Rack rack1 = (Rack) node1.getParent().getParent();
+					JobRegistry jr1 = new JobRegistryImpl(rack1.getFullName());
+		    		node1LoadRank = jr1.getRunningTasks().size(); 
+		    		
+		    		Rack rack2 = (Rack) node2.getParent().getParent();
+					JobRegistry jr2 = new JobRegistryImpl(rack2.getFullName());
+		    		node2LoadRank = jr2.getRunningTasks().size(); 
+			        if(node1LoadRank < node2LoadRank)
+			        	return 1;
+			        else if (node1LoadRank > node2LoadRank)
+			        	return -1;
+			        else return 0;
+		    	} catch (Exception e){
+		    		return 0;
+		    	}
+	        }
+	    }
+	}
+	
+	class PerformanceComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MIN_VALUE;
+	    	double node2Rank = Double.MIN_VALUE;
+
+	    	double node1Speed = 0;
+	    	for(Processor proc: node1.getProcessors()){
+	    		node1Speed = node1Speed + proc.getMIPS();
+	    	}
+	    	node1Rank = node1Speed / node1.getProcessors().size();
+	    	
+	    	double node2Speed = 0;
+	    	for(Processor proc: node2.getProcessors()){
+	    		node2Speed = node2Speed + proc.getMIPS();
+	    	}
+	    	node2Rank = node2Speed / node2.getProcessors().size();
+	    	
+	    	if(node1Rank == node2Rank){
+	    		node1Rank = Double.MIN_VALUE;
+	    		node2Rank = Double.MIN_VALUE;
+	    		PState pState;
+		    	for(Processor proc: node1.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node1Rank){
+			    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+		    	for(Processor proc: node2.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node2Rank){
+			    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+	    	}
+	    	
+	        if(node1Rank < node2Rank)
+	        	return 1;
+	        else if (node1Rank > node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_NodePowMan_SP.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_NodePowMan_SP.java	(revision 1299)
@@ -0,0 +1,342 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import test.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_ConsolidationLowPower_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_ConsolidationLowPower_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = resourceManager.getNodes();
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new PowerComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new PowerComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+							Fan fan = (Fan) device;
+							if(fan.getChilledResources().contains(node.getFullName())){
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							}
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					
+					if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+						Fan fan = (Fan) device;
+						int nrOfChilldedNodes = fan.getChilledResources().size();
+						if(fan.getChilledResources().contains(node.getFullName())){
+							if(nrOfChilldedNodes == 1)
+								fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							else {
+								for(String chilledNode: fan.getChilledResources()){
+									for(Node node2: nodes){
+										if(chilledNode.equals(node2.getFullName())){
+											if(node2.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+												nrOfChilldedNodes--;
+											}
+										}
+									}
+								}
+								if(nrOfChilldedNodes <= 1)
+									fan.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+							}
+
+						}
+					}
+					
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class PowerComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+
+    		PState pState;
+	    	for(Processor proc: node1.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node1Rank){
+		    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	for(Processor proc: node2.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node2Rank){
+		    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java	(revision 1258)
+++ 	(revision )
@@ -1,211 +1,0 @@
-package example.localplugin.coolemall.computebox2;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Core;
-import schedframe.resources.computing.Node;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-import test.Node_Fan_Mapping;
-import example.localplugin.BaseLocalSchedulingPlugin;
-import gridsim.dcworms.DCWormsTags;
-
-public class CB2_FCFS_Consolidation_SP extends BaseLocalSchedulingPlugin {
-
-	
-	public CB2_FCFS_Consolidation_SP () {
-		Node_Fan_Mapping.init();
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			 ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-					}
-				}
-			}
-			break;
-		}
-		return plan;
-	}
-
-	@SuppressWarnings("unchecked")
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-		
-		List<Node> nodes = resourceManager.getNodes();
-		List<Node> avNodes = filterNodes(nodes, task);
-		Collections.sort(avNodes, new FavourableNodeComparator());
-		if(avNodes.size() == 0)
-			return null;
-		Node node = findTheMostLoadedNode(avNodes);
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-
-		if (cpuRequest != 0) {
-
-			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
-			
-			List<Core> cores = node.getCores();			
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
-				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
-					cpuRequest--;
-				}
-			}
-			if (cpuRequest > 0) {
-				return null;
-			}
-			//choosenResources.add(node.getProcessors().get(0));
-			ProcessingElements pe = new ProcessingElements();
-			pe.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, pe);
-			return map;
-		}
-		return null;
-	}
-	
-	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
-		List<Node> filteredNodes = new ArrayList<Node>();
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		for (Node node : nodes) {
-
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				
-				filteredNodes.add(node);
-			}
-		}
-		
-		return filteredNodes;
-	}
-	
-	private Node findTheMostLoadedNode(List<Node> nodes){
-		Node mostLoadedNode = null;
-			
-		int maxRunningTask = -1;
-		int nrRunningTasks;
-		for(Node node: nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getFullName());
-			nrRunningTasks = jr.getRunningTasks().size(); 
-			if(nrRunningTasks > maxRunningTask){
-				mostLoadedNode = node;
-				maxRunningTask = nrRunningTasks;
-			}
-		}
-		return mostLoadedNode;
-	}
-	
-
-	class FavourableNodeComparator implements Comparator<Node>{
-		
-	    public int compare(Node node1, Node node2){    
-	    	double node1Rank = Double.MAX_VALUE;
-	    	double node2Rank = Double.MAX_VALUE;
-	    	
-	    	try {
-				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node1Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node1Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node1Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node1Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node1Rank = 1;
-			} catch (Exception e){
-				
-			}
-	    	try {
-				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node2Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node2Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node2Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node2Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node2Rank = 1;
-			} catch (Exception e){
-				
-			}
-	        if(node1Rank > node2Rank)
-	        	return 1;
-	        else if (node1Rank < node2Rank)
-	        	return -1;
-	        else return 0;	   
-	    }
-	}
-	
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java	(revision 1258)
+++ 	(revision )
@@ -1,331 +1,0 @@
-package example.localplugin.coolemall.computebox2;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.exceptions.ResourceException;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.StandardResourceType;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Core;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
-import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.devices.Device;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-import test.Node_Fan_Mapping;
-import example.localplugin.BaseLocalSchedulingPlugin;
-import gridsim.dcworms.DCWormsTags;
-
-public class CB2_FCFS_Consolidation_NodePowMan_SP extends BaseLocalSchedulingPlugin {
-
-	
-	public CB2_FCFS_Consolidation_NodePowMan_SP () {
-		Node_Fan_Mapping.init();
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			 ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			
-			List<Node> notSelectedNodes = resourceManager.getNodes();
-			
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
-						Node node = (Node) pe.get(0).getParent().getParent();
-						notSelectedNodes.remove(node);
-					}
-				}
-			}
-			manageResources(notSelectedNodes);
-			break;
-		}
-		return plan;
-	}
-
-	@SuppressWarnings("unchecked")
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-		
-		List<Node> nodes = resourceManager.getNodes();
-		List<Node> avNodes = filterNodes(nodes, task);
-		Node node;
-		if(avNodes.size() == 0){
-			try {
-				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
-			} catch (ResourceException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-			Collections.sort(nodes, new FavourableNodeComparator());
-			node = turnOnFirstNode(nodes, task);
-			if(node == null)
-				return null;
-		} else {
-			Collections.sort(avNodes, new FavourableNodeComparator());
-			node = findTheMostLoadedNode(avNodes);			
-		}
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-
-		if (cpuRequest != 0) {
-
-			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
-			
-			List<Core> cores = node.getCores();			
-			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
-				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(cores.get(i));
-					cpuRequest--;
-				}
-			}
-			if (cpuRequest > 0) {
-				return null;
-			}
-			//choosenResources.add(node.getProcessors().get(0));
-			ProcessingElements pe = new ProcessingElements();
-			pe.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, pe);
-			return map;
-		}
-		return null;
-	}
-	
-	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
-		List<Node> filteredNodes = new ArrayList<Node>();
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		for (Node node : nodes) {
-
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				
-				filteredNodes.add(node);
-			}
-		}
-		
-		return filteredNodes;
-	}
-	
-	private Node findTheMostLoadedNode(List<Node> nodes){
-		Node mostLoadedNode = null;
-			
-		int maxRunningTask = -1;
-		int nrRunningTasks;
-		for(Node node: nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getFullName());
-			nrRunningTasks = jr.getRunningTasks().size(); 
-			if(nrRunningTasks > maxRunningTask){
-				mostLoadedNode = node;
-				maxRunningTask = nrRunningTasks;
-			}
-		}
-		return mostLoadedNode;
-	}
-	
-	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
-		Node startedNode = null;
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-		
-		for(Node node: nodes){
-			
-			if (cpuRequest != 0) {
-
-				List<Core> cores = node.getCores();
-				if (cores.size() < cpuRequest) {
-					if(cores.size() == 0){
-						if(node.getProcessors().size() < cpuRequest)
-							continue;
-					}
-				}
-				
-				int freeCores = 0;
-				for(Core core: cores){
-					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
-						freeCores++;
-				}
-				
-				if(freeCores < cpuRequest)
-					continue;
-				else {
-					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
-							break;
-						}
-					}
-					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
-					startedNode = node;
-					break;
-				}				
-			}
-		}
-		return startedNode;
-	}
-	
-	protected void manageResources(List<Node> notSelectedNodes) {
-		turnOffIdleNodes(notSelectedNodes);
-		//adjustFans(notSelectedNodes);
-	
-	}
-
-	private void turnOffIdleNodes(List<Node> nodes){
-		for(Node node : nodes){
-			Processor proc = node.getProcessors().get(0);
-			int freeCores = 0;
-			for(Core core: proc.getCores()){
-				if(core.getStatus() == ResourceStatus.FREE)
-					freeCores++;
-			}
-			
-			if(freeCores == proc.getCores().size()) {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
-						break;
-					}
-				}
-				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
-			}
-
-		}
-	}
-
-	/*private void adjustFans(List<Node> nodes) {
-		for (Node node : nodes) {
-
-			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
-						break;
-					}
-				}
-			} else {
-				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
-					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
-						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
-						break;
-					}
-				}
-			}
-		}
-	}
-	*/
-	
-	class FavourableNodeComparator implements Comparator<Node>{
-		
-	    public int compare(Node node1, Node node2){    
-	    	double node1Rank = Double.MAX_VALUE;
-	    	double node2Rank = Double.MAX_VALUE;
-	    	
-	    	try {
-				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node1Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node1Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node1Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node1Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node1Rank = 1;
-			} catch (Exception e){
-				
-			}
-	    	try {
-				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
-				if(productName.equals("Fusion G - T40N"))
-					node2Rank = 3;
-				else if(productName.equals("Atom - D510"))
-					node2Rank = 4;
-				else if(productName.equals("Atom - N2600"))
-					node2Rank = 5;
-				else if(productName.equals("Core i7 - 2715QE"))
-					node2Rank = 2;
-				else if(productName.equals("Core i7 - 3615QE"))
-					node2Rank = 1;
-			} catch (Exception e){
-				
-			}
-	        if(node1Rank > node2Rank)
-	        	return 1;
-	        else if (node1Rank < node2Rank)
-	        	return -1;
-	        else return 0;	   
-	    }
-	}
-	
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationHighPerf_NodePowMan_Plugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationHighPerf_NodePowMan_Plugin.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationHighPerf_NodePowMan_Plugin.java	(revision 1299)
@@ -0,0 +1,252 @@
+package example.localplugin;
+
+import gridsim.dcworms.DCWormsTags;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+
+public class Cluster_FCFSBF_ConsolidationHighPerf_NodePowMan_Plugin extends BaseLocalSchedulingPlugin {
+
+	public Cluster_FCFSBF_ConsolidationHighPerf_NodePowMan_Plugin () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			// check all tasks in queue
+
+			List<Node> notSelectedNodes = resourceManager.getNodes();
+			
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources =  chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources  != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent();
+						notSelectedNodes.remove(node);
+					} 
+				}
+			}
+			turnOffIdleNodes(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+	
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(ClusterResourceManager resourceManager, TaskInterface<?> task){
+
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> availableNodes = findSuitableNodes(task, nodes);
+		Node node;
+		if(availableNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new PerformanceComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		}else{
+			Collections.sort(availableNodes, new PerformanceComparator());
+			node = availableNodes.get(0);
+		} 
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		List<ComputingResource> choosenResources =  new ArrayList<ComputingResource>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (int i = 0; i < node.getProcessors().size() && cpuRequest > 0; i++) {
+			if (node.getProcessors().get(i).getStatus() == ResourceStatus.FREE) {
+				choosenResources.add(node.getProcessors().get(i));
+				cpuRequest--;
+			}
+		}
+		ProcessingElements result = new ProcessingElements(node.getFullName());
+		result.addAll(choosenResources);
+		map.put(StandardResourceUnitName.PE, result);
+		return map;
+	}
+	
+	private List<Node> findSuitableNodes(TaskInterface<?> task, List<Node> nodes) {
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 1;
+		}
+
+		List<Node> suitableNodes = new ArrayList<Node>();
+		for(Node node: nodes){
+			if(node.getFreeProcessorsNumber() >= cpuRequest){
+				suitableNodes.add(node);
+			}	
+
+		}
+		return suitableNodes;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Processor> processors = node.getProcessors();
+				if (processors.size() < cpuRequest) {
+					if(processors.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeProcessor = 0;
+				for(Processor processor: processors){
+					if(processor.getStatus() == ResourceStatus.FREE || processor.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeProcessor++;
+				}
+				
+				if(freeProcessor < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							device.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			int freeProcessors = 0;
+			for(Processor proc: node.getProcessors()){
+				if(proc.getStatus() == ResourceStatus.FREE)
+					freeProcessors++;
+			}
+			
+			if(freeProcessors == node.getProcessors().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getType().equals(StandardResourceType.Fan)){
+						device.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF);
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+	
+	class PerformanceComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MIN_VALUE;
+	    	double node2Rank = Double.MIN_VALUE;
+
+	    	double node1Speed = 0;
+	    	for(Processor proc: node1.getProcessors()){
+	    		node1Speed = proc.getMIPS();
+	    	}
+	    	node1Rank = node1Speed / node1.getProcessors().size();
+	    	
+	    	double node2Speed = 0;
+	    	for(Processor proc: node2.getProcessors()){
+	    		node2Speed = proc.getMIPS();
+	    	}
+	    	node2Rank = node2Speed / node2.getProcessors().size();
+	    	
+	    	if(node1Rank == node2Rank){
+	    		node1Rank = Double.MIN_VALUE;
+	    		node2Rank = Double.MIN_VALUE;
+	    		PState pState;
+		    	for(Processor proc: node1.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node1Rank){
+			    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+		    	for(Processor proc: node2.getProcessors()){
+		    		if(proc.getPowerInterface() != null) {
+			    		pState = proc.getPowerInterface().getLowestPState();
+			    		if(pState != null && pState.getFrequency() > node2Rank){
+			    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+			    		}
+		    		}
+		    	}
+	    	}
+	    	
+	        if(node1Rank < node2Rank)
+	        	return 1;
+	        else if (node1Rank > node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationLowPower_NodePowMan_Plugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationLowPower_NodePowMan_Plugin.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationLowPower_NodePowMan_Plugin.java	(revision 1299)
@@ -0,0 +1,235 @@
+package example.localplugin;
+
+import gridsim.dcworms.DCWormsTags;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+
+public class Cluster_FCFSBF_ConsolidationLowPower_NodePowMan_Plugin extends BaseLocalSchedulingPlugin {
+
+	public Cluster_FCFSBF_ConsolidationLowPower_NodePowMan_Plugin () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			// check all tasks in queue
+
+			List<Node> notSelectedNodes = resourceManager.getNodes();
+			
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources =  chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources  != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent();
+						notSelectedNodes.remove(node);
+					} 
+				}
+			}
+			turnOffIdleNodes(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+	
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(ClusterResourceManager resourceManager, TaskInterface<?> task){
+
+		List<Node> nodes = resourceManager.getNodes();
+		List<Node> availableNodes = findSuitableNodes(task, nodes);
+		Node node;
+		if(availableNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new PowerComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		}else{
+			Collections.sort(availableNodes, new PowerComparator());
+			node = availableNodes.get(0);
+		} 
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		List<ComputingResource> choosenResources =  new ArrayList<ComputingResource>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (int i = 0; i < node.getProcessors().size() && cpuRequest > 0; i++) {
+			if (node.getProcessors().get(i).getStatus() == ResourceStatus.FREE) {
+				choosenResources.add(node.getProcessors().get(i));
+				cpuRequest--;
+			}
+		}
+		ProcessingElements result = new ProcessingElements(node.getFullName());
+		result.addAll(choosenResources);
+		map.put(StandardResourceUnitName.PE, result);
+		return map;
+	}
+	
+	private List<Node> findSuitableNodes(TaskInterface<?> task, List<Node> nodes) {
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 1;
+		}
+
+		List<Node> suitableNodes = new ArrayList<Node>();
+		for(Node node: nodes){
+			if(node.getFreeProcessorsNumber() >= cpuRequest){
+				suitableNodes.add(node);
+			}	
+
+		}
+		return suitableNodes;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Processor> processors = node.getProcessors();
+				if (processors.size() < cpuRequest) {
+					if(processors.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeProcessor = 0;
+				for(Processor processor: processors){
+					if(processor.getStatus() == ResourceStatus.FREE || processor.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeProcessor++;
+				}
+				
+				if(freeProcessor < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							device.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			int freeProcessors = 0;
+			for(Processor proc: node.getProcessors()){
+				if(proc.getStatus() == ResourceStatus.FREE)
+					freeProcessors++;
+			}
+			
+			if(freeProcessors == node.getProcessors().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getType().equals(StandardResourceType.Fan)){
+						device.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF);
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+	
+	class PowerComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+
+    		PState pState;
+	    	for(Processor proc: node1.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node1Rank){
+		    			node1Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	for(Processor proc: node2.getProcessors()){
+	    		if(proc.getPowerInterface() != null) {
+		    		pState = proc.getPowerInterface().getLowestPState();
+		    		if(pState != null && pState.getPower() < node2Rank){
+		    			node2Rank = proc.getPowerInterface().getLowestPState().getFrequency();
+		    		}
+	    		}
+	    	}
+	    	
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ExamplePlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ExamplePlugin.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ExamplePlugin.java	(revision 1299)
@@ -0,0 +1,155 @@
+package example.localplugin;
+
+import gridsim.dcworms.DCWormsTags;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.units.Memory;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+
+public class Cluster_FCFSBF_ExamplePlugin extends BaseLocalSchedulingPlugin {
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			// check all tasks in queue
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+					
+					/****************3 ways to schedule task****************/
+					
+					/****************1. Choosing particular resources to perform execution****************/
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+					
+					/****************2. Choosing resource scheduler/provider to submit the task. If the given resource doesn't contains/isn't 
+					a scheduler, random resources from the given resource will be chosen in order to perform execution****************/
+					/*String provName = chooseProviderForExecution(resourceManager);
+					if (provName != null) {
+						addToSchedulingPlan(plan, task, provName);
+					}*/
+
+					/****************3. Scheduler will choose random resources to perform execution****************/
+					//addToSchedulingPlan(plan, task);
+				}
+			}
+
+			break;
+		}
+		return plan;
+	}
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		List<Node> nodes = resourceManager.getNodes();
+		for (Node node : nodes) {
+			int cpuRequest;
+			try {
+				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+			} catch (NoSuchFieldException e) {
+				cpuRequest = 0;
+			}
+
+			if (cpuRequest != 0) {
+
+				List<Processor> processors = node.getProcessors();
+				if (processors.size() < cpuRequest) {
+					continue;
+				}
+
+				List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
+				for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
+					if (processors.get(i).getStatus() == ResourceStatus.FREE) {
+						choosenResources.add(processors.get(i));
+						cpuRequest--;
+					}
+				}
+				if (cpuRequest > 0) {
+					continue;
+				}
+
+				ProcessingElements pe = new ProcessingElements();
+				pe.addAll(choosenResources);
+				map.put(StandardResourceUnitName.PE, pe);
+				
+				int memoryRequest;
+				try {
+					memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue();
+				} catch (NoSuchFieldException e) {
+					memoryRequest = 0;
+				}
+				if (memoryRequest != 0) {
+
+					Memory memory = null;
+					try{
+						if (node.getFreeMemory() >= memoryRequest) {		
+							memory = new Memory(node.getMemory(), memoryRequest, memoryRequest);
+						}		
+					} catch(NoSuchFieldException e){
+						continue;
+					}
+					if(memory == null)
+						continue;
+					else {
+						map.put(StandardResourceUnitName.MEMORY, memory);
+						return map;
+					}
+				} else return map;
+			}
+		}
+	
+		return null;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseProviderForExecution(ResourceManager unitsManager) {
+		List<ComputingResource> nodes;
+		Properties properties = new Properties();
+		properties.setProperty("type", StandardResourceType.Node.getName());
+		// properties.setProperty("status", ResourceStatus.FREE.toString());
+		nodes = (List<ComputingResource>) unitsManager.filterResources(properties);
+		
+		//always return the same node from the list
+		return nodes.get(0).getFullName();
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_DFSPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_DFSPlugin.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_DFSPlugin.java	(revision 1299)
@@ -0,0 +1,116 @@
+package example.localplugin;
+
+import gridsim.dcworms.DCWormsTags;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+
+public class Cluster_FCFSBF_DFSPlugin extends BaseLocalSchedulingPlugin {
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// our tasks are placed only in first queue (see
+		// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+		TaskQueue q = queues.get(0);
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources  != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+			adjustFrequency(resourceManager.getProcessors());
+		}
+		return plan;
+	}
+	
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+			List<ComputingResource> choosenResources = null;
+			List<Processor> processors = resourceManager.getProcessors();
+			if (processors.size() < cpuRequest) {
+				// log.warn("Task requires more cpus than is availiable in this resource.");
+				return null;
+			}
+
+			choosenResources = new ArrayList<ComputingResource>();
+
+			for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
+				if (processors.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(processors.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				// log.info("Task " + task.getJobId() + "_" + task.getId() +
+				// " requires more cpus than is availiable in this moment.");
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+		}
+		return map;
+	}
+	
+	private void adjustFrequency(List<Processor> processors){
+
+		for(Processor cpu: processors){
+			if(cpu.getStatus() == ResourceStatus.FREE) {
+				if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3"))
+					cpu.getPowerInterface().setPState("P3");
+			}
+			else{
+				if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0"))
+					cpu.getPowerInterface().setPState("P0");
+			}
+		}
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_DFSClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_DFSClusterPlugin.java	(revision 574)
+++ 	(revision )
@@ -1,116 +1,0 @@
-package example.localplugin;
-
-import gridsim.dcworms.DCWormsTags;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-
-public class FCFSBF_DFSClusterPlugin extends BaseLocalSchedulingPlugin {
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// our tasks are placed only in first queue (see
-		// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-		TaskQueue q = queues.get(0);
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources  != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-					} 
-				}
-			}
-			adjustFrequency(resourceManager.getProcessors());
-		}
-		return plan;
-	}
-	
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 0;
-		}
-
-		if (cpuRequest != 0) {
-			List<ComputingResource> choosenResources = null;
-			List<Processor> processors = resourceManager.getProcessors();
-			if (processors.size() < cpuRequest) {
-				// log.warn("Task requires more cpus than is availiable in this resource.");
-				return null;
-			}
-
-			choosenResources = new ArrayList<ComputingResource>();
-
-			for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
-				if (processors.get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(processors.get(i));
-					cpuRequest--;
-				}
-			}
-			if (cpuRequest > 0) {
-				// log.info("Task " + task.getJobId() + "_" + task.getId() +
-				// " requires more cpus than is availiable in this moment.");
-				return null;
-			}
-
-			ProcessingElements pe = new ProcessingElements();
-			pe.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, pe);
-		}
-		return map;
-	}
-	
-	private void adjustFrequency(List<Processor> processors){
-
-		for(Processor cpu: processors){
-			if(cpu.getStatus() == ResourceStatus.FREE) {
-				if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3"))
-					cpu.getPowerInterface().setPState("P3");
-			}
-			else{
-				if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0"))
-					cpu.getPowerInterface().setPState("P0");
-			}
-		}
-	}
-
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java	(revision 1247)
+++ 	(revision )
@@ -1,155 +1,0 @@
-package example.localplugin;
-
-import gridsim.dcworms.DCWormsTags;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.StandardResourceType;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.units.Memory;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-
-public class FCFSBF_ClusterPlugin extends BaseLocalSchedulingPlugin {
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			// check all tasks in queue
-
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-					
-					/****************3 ways to schedule task****************/
-					
-					/****************1. Choosing particular resources to perform execution****************/
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-					}
-					
-					/****************2. Choosing resource scheduler/provider to submit the task. If the given resource doesn't contains/isn't 
-					a scheduler, random resources from the given resource will be chosen in order to perform execution****************/
-					/*String provName = chooseProviderForExecution(resourceManager);
-					if (provName != null) {
-						addToSchedulingPlan(plan, task, provName);
-					}*/
-
-					/****************3. Scheduler will choose random resources to perform execution****************/
-					//addToSchedulingPlan(plan, task);
-				}
-			}
-
-			break;
-		}
-		return plan;
-	}
-
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
-			ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-		List<Node> nodes = resourceManager.getNodes();
-		for (Node node : nodes) {
-			int cpuRequest;
-			try {
-				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-			} catch (NoSuchFieldException e) {
-				cpuRequest = 0;
-			}
-
-			if (cpuRequest != 0) {
-
-				List<Processor> processors = node.getProcessors();
-				if (processors.size() < cpuRequest) {
-					continue;
-				}
-
-				List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
-				for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
-					if (processors.get(i).getStatus() == ResourceStatus.FREE) {
-						choosenResources.add(processors.get(i));
-						cpuRequest--;
-					}
-				}
-				if (cpuRequest > 0) {
-					continue;
-				}
-
-				ProcessingElements pe = new ProcessingElements();
-				pe.addAll(choosenResources);
-				map.put(StandardResourceUnitName.PE, pe);
-				
-				int memoryRequest;
-				try {
-					memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue();
-				} catch (NoSuchFieldException e) {
-					memoryRequest = 0;
-				}
-				if (memoryRequest != 0) {
-
-					Memory memory = null;
-					try{
-						if (node.getFreeMemory() >= memoryRequest) {		
-							memory = new Memory(node.getMemory(), memoryRequest, memoryRequest);
-						}		
-					} catch(NoSuchFieldException e){
-						continue;
-					}
-					if(memory == null)
-						continue;
-					else {
-						map.put(StandardResourceUnitName.MEMORY, memory);
-						return map;
-					}
-				} else return map;
-			}
-		}
-	
-		return null;
-	}
-
-	@SuppressWarnings("unchecked")
-	private String chooseProviderForExecution(ResourceManager unitsManager) {
-		List<ComputingResource> nodes;
-		Properties properties = new Properties();
-		properties.setProperty("type", StandardResourceType.Node.getName());
-		// properties.setProperty("status", ResourceStatus.FREE.toString());
-		nodes = (List<ComputingResource>) unitsManager.filterResources(properties);
-		
-		//always return the same node from the list
-		return nodes.get(0).getFullName();
-	}
-
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java	(revision 1247)
+++ 	(revision )
@@ -1,146 +1,0 @@
-package example.localplugin;
-
-import gridsim.dcworms.DCWormsTags;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-
-public class FCFSBF_NodePowerManagementClusterPlugin extends BaseLocalSchedulingPlugin {
-
-	public FCFSBF_NodePowerManagementClusterPlugin () {
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-
-			TaskQueue q = queues.get(0);
-
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources  != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-					} else {
-						if(harnessIdleNodesToWork(task, resourceManager.getNodes()))
-							i--;
-					}
-				}
-			}
-			turnOffIdleNodes(resourceManager.getNodes());
-			break;
-		}
-		return plan;
-	}
-	
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(ClusterResourceManager resourceManager, TaskInterface<?> task) {
-
-		List<Node> nodes = resourceManager.getNodes();
-		nodes = findSuitableNodes(task, nodes);
-		Collections.sort(nodes, new Comparator<Node>(){
-		    public int compare(Node node1, Node node2){    
-		        return node1.getResourceCharacteristic().getParameters().get("category").get(0).getContent().compareTo(node2.getResourceCharacteristic().getParameters().get("category").get(0).getContent());
-		    }
-		});
-		if(nodes.size() > 0)
-		{
-			Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-			List<ComputingResource> choosenResources =  new ArrayList<ComputingResource>();
-			int cpuRequest;
-			try {
-				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-			} catch (NoSuchFieldException e) {
-				cpuRequest = 0;
-			}
-			for (int i = 0; i < nodes.get(0).getProcessors().size() && cpuRequest > 0; i++) {
-				if (nodes.get(0).getProcessors().get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(nodes.get(0).getProcessors().get(i));
-					cpuRequest--;
-				}
-			}
-			ProcessingElements result = new ProcessingElements(nodes.get(0).getFullName());
-			result.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, result);
-			return map;
-		} else 
-			return null;
-	}
-	
-	private List<Node> findSuitableNodes(TaskInterface<?> task, List<Node> nodes){
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 1;
-		}
-		List<Node> avNodes = new ArrayList<Node>();
-		for(Node node: nodes){
-			if(node.getFreeProcessorsNumber() >= cpuRequest){
-				avNodes.add(node);
-			}
-		}
-		return avNodes;
-	}
-
-	private void turnOffIdleNodes(List<Node> nodes){
-		for(Node node : nodes){
-			if(node.getFreeProcessorsNumber() == node.getProcessorsNumber()){
-				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
-			}
-		}
-	}
-	
-	private boolean harnessIdleNodesToWork(TaskInterface<?> task, List<Node> nodes){
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 1;
-		}
-		Collections.sort(nodes, new Comparator<Node>(){
-		    public int compare(Node node1, Node node2){    
-		        return node1.getResourceCharacteristic().getParameters().get("category").get(0).getContent().compareTo(node2.getResourceCharacteristic().getParameters().get("category").get(0).getContent());
-		    }
-		});
-		for (int i = 0; i < nodes.size() && cpuRequest > 0; i++) {
-			Node node = nodes.get(i);
-			if(node.getPowerInterface().getPowerState() == StandardPowerStateName.OFF){
-				node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
-				cpuRequest -= node.getProcessorsNumber();
-			}
-		}
-		return cpuRequest > 0 ? false : true;
-	}
-
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java	(revision 1247)
+++ 	(revision )
@@ -1,139 +1,0 @@
-package example.localplugin;
-
-import gridsim.dcworms.DCWormsTags;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.StandardResourceType;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
-import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
-import schedframe.resources.devices.Device;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-
-public class FCFSBF_FanManagementClusterPlugin extends BaseLocalSchedulingPlugin {
-
-	private Random rand;
-	
-	public FCFSBF_FanManagementClusterPlugin () {
-		rand = new Random(5);
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			 ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-		//case TIMER:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			List<Node> notSelectedNodes = resourceManager.getNodes();
-			// check all tasks in queue
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Node node = chooseRandomProvider(resourceManager, task);
-					if (node != null) {
-						//if there are two or more tasks ( running on the given node then
-						if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 0){
-							List<Device> devices = node.getResourceCharacteristic().getDevices();
-							for(Device dev : devices){
-								if(dev.getType().equals(StandardResourceType.Fan)){
-									dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
-								}
-							}
-						}
-						else {
-							List<Device> devices = node.getResourceCharacteristic().getDevices();
-							for(Device dev : devices){
-								if(dev.getType().equals(StandardResourceType.Fan)){
-									dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);	
-								}
-							}
-						}
-						notSelectedNodes.remove(node);
-						addToSchedulingPlan(plan, task, node.getFullName());
-					}
-				}
-			}
-			adjustOtherFans(notSelectedNodes);
-			break;
-		}
-		return plan;
-	}
-
-	private Node chooseRandomProvider(ClusterResourceManager resourceManager, TaskInterface<?> task) {
-		List<Node> nodes = filterNodes(resourceManager.getNodes(), task);
-		return randomNode(nodes);
-	}
-	
-	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
-		List<Node> filteredNodes = new ArrayList<Node>();
-		for (Node node : nodes) {
-			int cpuRequest;
-			try {
-				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-			} catch (NoSuchFieldException e) {
-				cpuRequest = 0;
-			}
-			if (cpuRequest != 0) {
-				if(node.getFreeProcessorsNumber() > cpuRequest)
-					filteredNodes.add(node);
-			}
-		}
-		
-		return filteredNodes;
-	}
-	
-	private Node randomNode(List<Node> nodes){
-		return nodes.get(rand.nextInt(nodes.size()));
-	}
-	
-	private void adjustOtherFans(List<Node> nodes){
-		for(Node node : nodes){
-			List<Device> devices = node.getResourceCharacteristic().getDevices();
-			if(node.getFreeProcessorsNumber() == node.getProcessorsNumber()){
-				for(Device dev : devices){
-					if(dev.getType().equals(StandardResourceType.Fan)){
-						dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF);
-					}
-				}
-			} else if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 1){
-				for(Device dev : devices){
-					if(dev.getType().equals(StandardResourceType.Fan)){
-						dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
-					}
-				}
-			}
-			else {
-				for(Device dev : devices){
-					if(dev.getType().equals(StandardResourceType.Fan)){
-						dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);
-					}
-				}
-			}
-		}
-	}
-
-	
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/Cluster_FCFSBF_ConsolidationPlugin.java	(revision 1258)
+++ 	(revision )
@@ -1,145 +1,0 @@
-package example.localplugin;
-
-import gridsim.dcworms.DCWormsTags;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.Node;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.units.Memory;
-import schedframe.resources.units.ProcessingElements;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
-import schedframe.resources.units.StandardResourceUnitName;
-import schedframe.scheduling.manager.resources.ClusterResourceManager;
-import schedframe.scheduling.manager.resources.ResourceManager;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-import schedframe.scheduling.plan.SchedulingPlanInterface;
-import schedframe.scheduling.plan.impl.SchedulingPlan;
-import schedframe.scheduling.plugin.grid.ModuleList;
-import schedframe.scheduling.queue.TaskQueue;
-import schedframe.scheduling.queue.TaskQueueList;
-import schedframe.scheduling.tasks.TaskInterface;
-
-public class Cluster_FCFSBF_ConsolidationPlugin extends BaseLocalSchedulingPlugin {
-
-	public Cluster_FCFSBF_ConsolidationPlugin () {
-	}
-
-	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
-			ResourceManager resManager, ModuleList modules) {
-
-		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
-		SchedulingPlan plan = new SchedulingPlan();
-		// choose the events types to serve.
-		// Different actions for different events are possible.
-		switch (event.getType()) {
-		case START_TASK_EXECUTION:
-		case TASK_FINISHED:
-			// our tasks are placed only in first queue (see
-			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
-			TaskQueue q = queues.get(0);
-			// check all tasks in queue
-
-			for (int i = 0; i < q.size(); i++) {
-				TaskInterface<?> task = q.get(i);
-				// if status of the tasks in READY
-				if (task.getStatus() == DCWormsTags.READY) {
-
-					Map<ResourceUnitName, ResourceUnit> choosenResources =  chooseResourcesForExecution(resourceManager, task);
-					if (choosenResources  != null) {
-						addToSchedulingPlan(plan, task, choosenResources);
-					} 
-				}
-			}
-
-			break;
-		}
-		return plan;
-	}
-	
-	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(ClusterResourceManager resourceManager, TaskInterface<?> task){
-
-		List<Node> nodes = resourceManager.getNodes();
-		nodes = findSuitableNodes(task, nodes);
-		Collections.sort(nodes, new Comparator<Node>(){
-		    public int compare(Node node1, Node node2){   
-		        return node1.getResourceCharacteristic().getParameters().get("category").get(0).getContent().compareTo(node2.getResourceCharacteristic().getParameters().get("category").get(0).getContent());
-		    }
-		});
-		if(nodes.size() > 0)
-		{
-			Node node = nodes.get(0);
-			Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-			List<ComputingResource> choosenResources =  new ArrayList<ComputingResource>();
-			int cpuRequest;
-			try {
-				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-			} catch (NoSuchFieldException e) {
-				cpuRequest = 0;
-			}
-			for (int i = 0; i < node.getProcessors().size() && cpuRequest > 0; i++) {
-				if (node.getProcessors().get(i).getStatus() == ResourceStatus.FREE) {
-					choosenResources.add(node.getProcessors().get(i));
-					cpuRequest--;
-				}
-			}
-			ProcessingElements result = new ProcessingElements(node.getFullName());
-			result.addAll(choosenResources);
-			map.put(StandardResourceUnitName.PE, result);
-			
-			int memoryRequest;
-			try {
-				memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue();
-			} catch (NoSuchFieldException e) {
-				memoryRequest = 0;
-			}
-			if (memoryRequest != 0) {
-				Memory memory;
-				try {
-					memory = new Memory(node.getMemory(), memoryRequest, memoryRequest);
-					map.put(StandardResourceUnitName.MEMORY, memory);
-				} catch (NoSuchFieldException e) {
-					return null;
-				}
-
-			}
-			return map;
-		} else 
-			return null;
-	}
-	
-	private List<Node> findSuitableNodes(TaskInterface<?> task, List<Node> nodes) {
-		int cpuRequest;
-		try {
-			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			cpuRequest = 1;
-		}
-		int memoryRequest;
-		try {
-			memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue();
-		} catch (NoSuchFieldException e) {
-			memoryRequest = 0;
-		}
-		List<Node> suitableNodes = new ArrayList<Node>();
-		for(Node node: nodes){
-			try{
-				if(node.getFreeProcessorsNumber() >= cpuRequest && node.getFreeMemory() >= memoryRequest){
-					suitableNodes.add(node);
-				}	
-			} catch (NoSuchFieldException e){
-				
-			}
-		}
-		return suitableNodes;
-	}
-
-}
Index: DCWoRMS/branches/coolemall/src/example/timeestimation/coolemall/CPUFreqScallingPhaseTimeEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/timeestimation/coolemall/CPUFreqScallingPhaseTimeEstimationPlugin.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/example/timeestimation/coolemall/CPUFreqScallingPhaseTimeEstimationPlugin.java	(revision 1299)
@@ -0,0 +1,65 @@
+package example.timeestimation.coolemall;
+
+import java.util.Map;
+
+import org.joda.time.DateTime;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.units.PEUnit;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.tasks.phases.ResourceConsumption;
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
+import example.timeestimation.BaseTimeEstimationPlugin;
+
+public class CPUFreqScallingPhaseTimeEstimationPlugin extends BaseTimeEstimationPlugin{
+
+	
+	public double execTimeEstimation(SchedulingEvent event, ExecTask task,
+			Map<ResourceUnitName, ResourceUnit> allocatedResources,
+			double completionPercentage) {
+		
+		Executable exec = (Executable) task;
+		ResourceConsumption resConsumption = exec.getResourceConsumptionProfile().getCurrentResourceConsumption();
+		String taskFreqString = task.getCurrentResourceConsumption().getReferenceHardware().get("cpu_maxfreq");
+		double taskFreq = Double.valueOf(taskFreqString);
+		
+		PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE);
+		double currentFrequency = 0;
+		
+		if(peUnit instanceof ProcessingElements){
+			ProcessingElements pes = (ProcessingElements) peUnit;
+			for (ComputingResource compResource : pes) {
+				if(compResource instanceof Core) {
+					Core core = (Core) compResource;
+					currentFrequency = core.getProcessor().getPowerInterface().getPState().getFrequency();
+					break;
+				} else if (compResource instanceof Processor) {
+					Processor processor = (Processor) compResource;
+					currentFrequency = processor.getPowerInterface().getPState().getFrequency();
+					break;
+				}
+			}
+		}
+		else 
+			currentFrequency = taskFreq;
+
+		double execTime = (1 - completionPercentage/100) * resConsumption.getDuration() * (taskFreq / currentFrequency);
+
+		// if the result is very close to 0, but less then one millisecond then round this result to 0.001
+		if (Double.compare(execTime, 0.001) < 0) {
+			execTime = 0.001;
+		}
+
+		// time is measured in integer units, so get the nearest execTime int value.
+		execTime = Math.round(execTime);
+		return execTime;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/load/ProcessorLoadEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/load/ProcessorLoadEstimationPlugin.java	(revision 1286)
+++ DCWoRMS/branches/coolemall/src/example/load/ProcessorLoadEstimationPlugin.java	(revision 1299)
@@ -1,6 +1,4 @@
 package example.load;
 
-import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.Core;
 import schedframe.resources.computing.Processor;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
@@ -13,5 +11,4 @@
 public class ProcessorLoadEstimationPlugin extends BaseLoadEstimationPlugin{
 
-	@Override
 	public double estimateUtlization(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
 		Processor proc = (Processor) resource;
@@ -24,26 +21,18 @@
 		}
 
-		//for(Core core: proc.getCores()){
-			
-			//if(core.getStatus().equals(ResourceStatus.BUSY)){
-				JobRegistry jr = new JobRegistryImpl(proc.getFullName());
-				for(ExecTask task: jr.getRunningTasks()){
-					double cpuUsage = 1 / nrOfThreadsOnCpu;
-					double nrOfThreadsOfApplication = 1;
 
-					for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){
-						if(pb.getResouceName().equals("PM_CPU_Usage")){
-							cpuUsage = pb.getUtilization();
-						}
-						if(pb.getResouceName().equals("PM_Threads")){
-							nrOfThreadsOfApplication = pb.getUtilization();
-							break;
-						}
-					}
-					sumCoresLoad = sumCoresLoad + cpuUsage;// * (nrOfThreadsOfApplication / nrOfThreadsOnCpu);
+		JobRegistry jr = new JobRegistryImpl(proc.getFullName());
+		for(ExecTask task: jr.getRunningTasks()){
+			double cpuUsage = 1 / nrOfThreadsOnCpu;
 
+			for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){
+				if(pb.getResouceName().equals("PM_CPU_Usage")){
+					cpuUsage = pb.getUtilization();
 				}
-		//	}
-		//}
+			}
+			sumCoresLoad = sumCoresLoad + cpuUsage;
+
+		}
+
 
 		double processorLoad = 100 * sumCoresLoad;	
Index: DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
===================================================================
--- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java	(revision 1299)
@@ -2,5 +2,4 @@
 
 
-import example.energy.coolemall.CoolEmAllTestbedMeasurements;
 import gridsim.GridSim;
 import gridsim.dcworms.DCWormsTags;
@@ -36,5 +35,4 @@
 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
-import simulator.stats.implementation.ResourceUsefulWorkStats;
 
 /**
@@ -213,4 +211,19 @@
     		for (ComputingResource resource : pes) {
 
+				LinkedList<ComputingResource> toExamine = new LinkedList<ComputingResource>();
+				toExamine.push(resource);
+
+				while (!toExamine.isEmpty()) {
+					ComputingResource compResource = toExamine.pop();
+					List<ComputingResource> resources = compResource.getChildren();
+					int numberOfRes = resources.size();
+					for (int i = 0; i < numberOfRes; i++) {
+						ComputingResource resourceChild = resources.get(i);
+						trackResource(resourceChild.getFullName());
+						toExamine.addLast(resourceChild);
+					}
+				}
+
+    			
     			trackResource(resource.getFullName());
     			
@@ -477,13 +490,19 @@
 					String productName = resource.getResourceCharacteristic().getParameters().get("product").get(0).getContent();
 					if(productName.equals("Fusion G - T40N"))
-						preparePhases("amdf");
+						preparePhases("Fusion G - T40N");
 					else if(productName.equals("Atom - D510"))
-						preparePhases("atom64");
+						preparePhases("Atom - D510");
 					else if(productName.equals("Atom - N2600"))
-						preparePhases("atom64");
+						preparePhases("Atom - N2600");
 					else if(productName.equals("Core i7 - 2715QE"))
-						preparePhases("i7-2715QE");
+						preparePhases("Core i7 - 2715QE");
 					else if(productName.equals("Core i7 - 3615QE"))
-						preparePhases("i7-3615QE");
+						preparePhases("Core i7 - 3615QE");
+					else if(productName.equals("Xeon E5-2630"))
+						preparePhases("Xeon E5-2630");
+					else if(productName.equals("Xeon E5-2603"))
+						preparePhases("Xeon E5-2603");
+					else if(productName.equals("Xeon L5310"))
+						preparePhases("Xeon L5310");
 				}
 				return true;
Index: DCWoRMS/branches/coolemall/src/gridsim/dcworms/filter/ResourceEventFilter.java
===================================================================
--- DCWoRMS/branches/coolemall/src/gridsim/dcworms/filter/ResourceEventFilter.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/gridsim/dcworms/filter/ResourceEventFilter.java	(revision 1299)
@@ -0,0 +1,44 @@
+package gridsim.dcworms.filter;
+
+import eduni.simjava.Sim_event;
+import gridsim.filter.FilterResult;
+
+/**
+ * @author wojtek
+ *
+ */
+public class ResourceEventFilter extends FilterResult {
+
+	public ResourceEventFilter(int resId, int tag) {
+		super(resId, tag);
+	}
+
+	public boolean match(Sim_event ev) {
+
+		if (ev == null) {
+			return false;
+		}
+
+		boolean result = false;
+		try {
+
+			if (tag_ == ev.get_tag()) {
+				Object obj = ev.get_data();
+
+				if (obj instanceof String) {
+
+					String resId = (String) obj;
+
+					if (resId.hashCode() == eventID_) {
+						result = true;
+					}
+				}
+			}
+		} catch (Exception e) {
+			result = false;
+		}
+
+		return result;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java	(revision 1299)
@@ -21,5 +21,4 @@
 import org.joda.time.DateTimeUtilsExt;
 
-import schedframe.Initializable;
 import schedframe.SimulatedEnvironment;
 import simulator.reader.ResourceReader;
@@ -252,10 +251,15 @@
 		// (default 1)
 		
-		Date date = workload.getSimulationStartTime();
 		Calendar calendar = Calendar.getInstance();
-		if (date == null)
+		if(workload == null){
 			calendar.setTimeInMillis(0L);
-		else
-			calendar.setTime(date);
+		} else {
+			Date date = workload.getSimulationStartTime();
+			if (date == null)
+				calendar.setTimeInMillis(0L);
+			else
+				calendar.setTime(date);			
+		}
+
 
 		boolean traceFlag = true; // means: trace GridSim events/activities
@@ -268,14 +272,15 @@
 		ResourceReader resourceReader = new ResourceReader(
 				options.resdescFileName);
-		SimulatedEnvironment rc = resourceReader.read();
-		eventManager = new EventManager("eventManager", rc);
-		
-		for(Initializable initObj: rc.getToInit()){
+		SimulatedEnvironment simEnv = resourceReader.read();
+		
+		eventManager = new EventManager("eventManager", simEnv);
+		
+		/*for(Initializable initObj: rc.getToInit()){
 			initObj.initiate();
 		}
-		rc.setInitList(null);
+		rc.setInitList(null);*/
 		
 		DCWormsUsers users = new DCWormsUsers("Users",
-				rc.getScheduler().get_name(), workload);
+				simEnv.getScheduler().get_name(), workload);
 		
 		System.out.println("Starting simulation...");
@@ -287,5 +292,5 @@
 
 		DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier,
-				options, users, statsOutputPath, rc);
+				options, users, statsOutputPath, simEnv);
 		accumulatedStatistics.add(stats);
 		if (log.isInfoEnabled())
@@ -309,18 +314,14 @@
 	private WorkloadLoader loadWorkload(ConfigurationOptions options) throws IOException, MarshalException, ValidationException{
 		XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlJobReader = null;
-		WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader = null;
+		WAReader<org.qcg.broker.schemas.jobdesc.Job> workloadReader = null;
 
 		String wlFileName = options.inputWorkloadFileName;
 
-		String appProfilesFolder = options.appProfilesFolder;
+		if(wlFileName == null){
+			return null;
+		}
+		
 		if (options.inputFolder != null) {
-			File f = null;
-			if (options.inputTar != null) {
-				f = new File(options.inputFolder + File.separator
-						+ options.inputTar);
-			} else {
-				f = new File(options.inputFolder);
-			}
-
+			File f = new File(options.inputFolder);
 			xmlJobReader = new QcgXmlJobReader(f);
 
@@ -329,7 +330,9 @@
 		}
 
-		swfReader = AbstractWAReader.getInstace(wlFileName);
-
-		WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder);
+		workloadReader = AbstractWAReader.getInstace(wlFileName);
+		
+		String appProfilesFolderName = options.appProfilesFolder;
+		
+		WorkloadLoader workload = new WorkloadLoader(xmlJobReader, workloadReader, appProfilesFolderName);
 		workload.load();
 
Index: DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java	(revision 1299)
@@ -1,455 +1,16 @@
 package simulator.stats;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import simulator.stats.implementation.MetricsStats;
-import example.energy.coolemall.CoolEmAllTestbedMeasurements;
 
-public class MetricsCalculator {
+public interface MetricsCalculator {
 	
-	protected static final double MILLI_SEC = 1000;
-	protected static final double SEC_IN_HOUR = 3600;
+	public List<MetricsStats> calulateMetrics();
 	
-	protected Map<String, List<GSSAccumulator>> metricsData = new HashMap<String, List<GSSAccumulator>>();
-	protected long timestamp;
-	protected long startTime;
-	protected long endTime;
-
-	public List<MetricsStats> calulateMetrics(long timestamp){
-		this.timestamp = timestamp;
-		List<MetricsStats> metrics = new ArrayList<MetricsStats>();
-		/*for(String resourceTypeName: metricsData.keySet()){
-			MetricsStats metric = new MetricsStats(resourceTypeName, "energyUsage", metricsData.get(resourceTypeName).getMax());
-			metrics.add(metric);}
-		}*/
-		metrics.add(calculateITComputingEnergyConsumption());
-		metrics.add(calculateITEnergyConsumption());
-		metrics.add(calculateNodeGroupFansEnergyConsumption());
-		
-		metrics.add(calculateRackEnergyConsumption());
-		metrics.add(calculateDataCenterFansEnergyConsumption());
-		metrics.add(calculateCoolingDeviceEnergyConsumption());
-		metrics.add(calculateOtherDevicesEnergyConsumption());
-		
-		metrics.add(calculateTotalEnergyConsumption());
-		
-		metrics.add(calculateMeanRackPower());
-		metrics.add(calculateMeanPower());
-		metrics.add(calculateMaxRackPower());
-		metrics.add(calculateMaxPower());
-		
-		metrics.add(calculatePUE());
-		metrics.add(calculatePUELevel4());
-		metrics.add(calculateEnergyWasteRate());
-		
-		metrics.add(calculateUsefulWork());
-		metrics.add(calculateProductivity());
-
-		return metrics;
-	}
+	public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator);
 	
-	public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator){
-		List<GSSAccumulator> resourceEnergyAccumulatorList = metricsData.get(resourceTypeName);
-		if(resourceEnergyAccumulatorList == null){
-			resourceEnergyAccumulatorList = new ArrayList<GSSAccumulator>();
-		}
-		resourceEnergyAccumulatorList.add(resourceEnergyAccumulator);
-		metricsData.put(resourceTypeName, resourceEnergyAccumulatorList);
-	}
+	public Map<String, List<GSSAccumulator>> getMetricsData();
 	
-	public Map<String, List<GSSAccumulator>> getMetricsData(){
-		return metricsData;
-	}
-	
-	private MetricsStats calculateTotalEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Room")){
-				roomPower = roomPower + acc.getSum();
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", roomPower, timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculateITComputingEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double itComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor")){
-				itComputingPower = itComputingPower + acc.getSum();
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", (itComputingPower), timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculateITEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double totalSitePower = 0; 
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				totalSitePower = totalSitePower + acc.getSum();
-			}
-			double nodeComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Node")){
-				nodeComputingPower = nodeComputingPower+ acc.getSum();
-			}
-			double itComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor")){
-				itComputingPower = itComputingPower + acc.getSum();
-			}
-			double fanPowerConumspion = nodeComputingPower - itComputingPower;
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", (totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - fanPowerConumspion), timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculateNodeGroupFansEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double nodeComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Node")){
-				nodeComputingPower = nodeComputingPower+ acc.getSum();
-			}
-			double itComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor")){
-				itComputingPower = itComputingPower + acc.getSum();
-			}
-			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", nodeGroupFansPowerConumspion, timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculatePUELevel4(){
-		
-		MetricsStats metric;
-		try{
-			
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Room")){
-				roomPower = roomPower + acc.getSum();
-			}
-			
-			double totalSitePower = 0;
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				totalSitePower = totalSitePower + acc.getSum();
-			}
-			
-		
-			double nodeComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Node")){
-				nodeComputingPower = nodeComputingPower+ acc.getSum();
-			}
-			double itComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor")){
-				itComputingPower = itComputingPower + acc.getSum();
-			}
-			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
-
-			metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", roomPower/(totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", -1, timestamp, "");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculatePUE(){
-		
-		MetricsStats metric;
-		try{
-			
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Room")){
-				roomPower = roomPower + acc.getSum();
-			}
-			
-			double totalSitePower = 0;
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				totalSitePower = totalSitePower + acc.getSum();
-			}
-
-
-			metric = new MetricsStats("CoolEmAllTestbed", "PUE", roomPower/totalSitePower, timestamp, "");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "PUE", -1, timestamp, "");
-		}
-		return metric;
-	}
-
-	private MetricsStats calculateUsefulWork(){
-		
-		MetricsStats metric;
-		try{
-			double usefulWork = 0;
-			for(String key: metricsData.keySet()){
-				if(key.contains("/")){
-					for(GSSAccumulator acc: metricsData.get(key)){
-						usefulWork= usefulWork + acc.getSum();
-					}
-				}
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", usefulWork, timestamp, "UW units");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", -1, timestamp, "UW units");
-		}
-		
-		return metric;
-	}
-	
-	private MetricsStats calculateProductivity(){
-		
-		MetricsStats metric;
-		try{
-			double usefulWork = 0;
-			for(String key: metricsData.keySet()){
-				if(key.contains("/")){
-					for(GSSAccumulator acc: metricsData.get(key)){
-						usefulWork= usefulWork + acc.getSum();
-					}
-				}
-			}
-			double totalSitePower = 0; 
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				totalSitePower = totalSitePower + acc.getSum();
-			}
-			
-			metric = new MetricsStats("CoolEmAllTestbed", "Productivity", usefulWork/totalSitePower, timestamp, "UW units/Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Productivity", -1, timestamp, "UW units/Wh");
-		}
-		
-		return metric;
-	}
-	
-	
-	private MetricsStats calculateMaxRackPower(){
-		
-		MetricsStats metric;
-		try{
-			double maxPower = 0;
-			
-			for(GSSAccumulator acc: metricsData.get("Rack_MAX")){
-				maxPower = maxPower + acc.getSum();
-			}
-
-			metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", maxPower, timestamp, "W");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", -1, timestamp, "W");
-		}
-		
-		return metric;
-	}
-	
-	private MetricsStats calculateMaxPower(){
-		
-		MetricsStats metric;
-		try{
-			double maxPower = 0;
-			
-			for(GSSAccumulator acc: metricsData.get("Room_MAX")){
-				maxPower = maxPower + acc.getSum();
-			}
-
-			metric = new MetricsStats("CoolEmAllTestbed", "Max_power", maxPower, timestamp, "W");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Max_power", -1, timestamp, "W");
-		}
-		
-		return metric;
-	}
-	
-	private MetricsStats calculateDataCenterFansEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double inletsPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Inlet")){
-				inletsPower = inletsPower + acc.getSum();
-			}
-			
-			double outletsPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Outlet")){
-				outletsPower = outletsPower + acc.getSum();
-			}
-			
-			double nodeComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Node")){
-				nodeComputingPower = nodeComputingPower+ acc.getSum();
-			}
-			double itComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor")){
-				itComputingPower = itComputingPower + acc.getSum();
-			}
-			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
-			
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (inletsPower + outletsPower - nodeGroupFansPowerConumspion), timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	
-	private MetricsStats calculateRackEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				roomPower = roomPower + acc.getSum();
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", roomPower, timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_device_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculateCoolingDeviceEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double coolingDevicePower = 0;
-			for(GSSAccumulator acc: metricsData.get("CoolingDevice")){
-				coolingDevicePower = coolingDevicePower + acc.getSum();
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", coolingDevicePower, timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculateOtherDevicesEnergyConsumption(){
-		
-		MetricsStats metric;
-		try{
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Room")){
-				roomPower = roomPower + acc.getSum();
-			}
-			
-			double totalSitePower = 0;
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				totalSitePower = totalSitePower + acc.getSum();
-			}
-			
-			double coolingDevicePower = 0;
-			for(GSSAccumulator acc: metricsData.get("CoolingDevice")){
-				coolingDevicePower = coolingDevicePower + acc.getSum();
-			}
-			
-			double inletsPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Inlet")){
-				inletsPower = inletsPower + acc.getSum();
-			}
-			
-			double outletsPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Outlet")){
-				outletsPower = outletsPower + acc.getSum();
-			}
-			
-			double nodeComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Node")){
-				nodeComputingPower = nodeComputingPower+ acc.getSum();
-			}
-			double itComputingPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor")){
-				itComputingPower = itComputingPower + acc.getSum();
-			}
-			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
-			
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", roomPower - (totalSitePower + coolingDevicePower + (inletsPower + outletsPower - nodeGroupFansPowerConumspion)), timestamp, "Wh");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_consumption", -1, timestamp, "Wh");
-		}
-		return metric;
-	}
-
-	
-	private MetricsStats calculateMeanPower(){
-		
-		MetricsStats metric;
-		try{
-			
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Room")){
-				roomPower = roomPower + acc.getSum();
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", -1, timestamp, "W");
-		}
-		return metric;
-	}
-	
-	
-	private MetricsStats calculateMeanRackPower(){
-		
-		MetricsStats metric;
-		try{
-			
-			double roomPower = 0;
-			for(GSSAccumulator acc: metricsData.get("Rack")){
-				roomPower = roomPower + acc.getSum();
-			}
-			metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", -1, timestamp, "W");
-		}
-		return metric;
-	}
-	
-	private MetricsStats calculateEnergyWasteRate(){
-		
-		MetricsStats metric;
-		try{
-			double itComputingEnergy = 0;
-			for(GSSAccumulator acc: metricsData.get("Processor_CALC")){
-				itComputingEnergy = itComputingEnergy + acc.getSum();
-			}
-			itComputingEnergy = itComputingEnergy + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC);
-			double itEnergy = calculateITEnergyConsumption().getValue();
-			
-			metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", (1 - itComputingEnergy/itEnergy) * 100, timestamp, "%");
-		} catch (Exception e){
-			metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", -1, timestamp, "%");
-		}
-		return metric;
-	}
-	
-	public long getStartTime() {
-		return startTime;
-	}
-
-	public void setStartTime(long startTime) {
-		this.startTime = startTime;
-	}
-
-	public long getEndTime() {
-		return endTime;
-	}
-
-	public void setEndTime(long endTime) {
-		this.endTime = endTime;
-	}
 }
Index: DCWoRMS/branches/coolemall/src/simulator/stats/AbstractMetricsCalculator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/AbstractMetricsCalculator.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/AbstractMetricsCalculator.java	(revision 1299)
@@ -0,0 +1,43 @@
+package simulator.stats;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import simulator.stats.implementation.MetricsStats;
+
+public abstract class AbstractMetricsCalculator implements MetricsCalculator{
+	
+	protected static final double MILLI_SEC = 1000;
+	protected static final double SEC_IN_HOUR = 3600;
+	
+	protected Map<String, List<GSSAccumulator>> metricsData = new HashMap<String, List<GSSAccumulator>>();
+
+	protected long startTime;
+	protected long endTime;
+	protected long timestamp;
+	
+	public AbstractMetricsCalculator(long startTime, long endTime, long timestamp) {
+		super();
+		this.startTime = startTime;
+		this.endTime = endTime;
+		this.timestamp = timestamp;
+	}
+	
+	abstract public List<MetricsStats> calulateMetrics();
+	
+	public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator){
+		List<GSSAccumulator> resourceEnergyAccumulatorList = metricsData.get(resourceTypeName);
+		if(resourceEnergyAccumulatorList == null){
+			resourceEnergyAccumulatorList = new ArrayList<GSSAccumulator>();
+		}
+		resourceEnergyAccumulatorList.add(resourceEnergyAccumulator);
+		metricsData.put(resourceTypeName, resourceEnergyAccumulatorList);
+	}
+	
+	public Map<String, List<GSSAccumulator>> getMetricsData(){
+		return metricsData;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 1299)
@@ -62,11 +62,14 @@
 import schedframe.resources.UserResourceType;
 import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
 import schedframe.resources.computing.extensions.Extension;
 import schedframe.resources.computing.extensions.ExtensionList;
 import schedframe.resources.computing.extensions.ExtensionType;
 import schedframe.resources.computing.profiles.energy.EnergyExtension;
+import schedframe.resources.computing.profiles.energy.MeasurementHistory;
 import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue;
 import schedframe.resources.computing.profiles.energy.power.PowerUsage;
 import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue;
+import schedframe.resources.computing.profiles.load.LoadExtension;
 import schedframe.resources.devices.Device;
 import schedframe.resources.devices.PhysicalResource;
@@ -85,8 +88,9 @@
 import simulator.DataCenterWorkloadSimulator;
 import simulator.GenericUser;
+import simulator.stats.CoolEmAllMetricsCalculator;
+import simulator.stats.DCwormsMetricsCalculator;
 import simulator.stats.GSSAccumulator;
 import simulator.stats.MetricsCalculator;
 import simulator.stats.SimulationStatistics;
-import simulator.stats.implementation.out.AbstractStringSerializer;
 import simulator.stats.implementation.out.CoolEmAllStringSerializer;
 import simulator.stats.implementation.out.StringSerializer;
@@ -110,8 +114,9 @@
 	protected static final int MILLI_SEC = 1000;
 
-	protected static final String RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt";
+	protected static final String TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt";
 	protected static final String JOBS_STATISTICS_OUTPUT_FILE_NAME = "Jobs.txt";
 
 	protected static final String SIMULATION_STATISTICS_OUTPUT_FILE_NAME = "Simulation.txt";
+	protected static final String RESOURCEOCCUPANCY_STATISTICS_OUTPUT_FILE_NAME = "ResourceOccupancy.txt";
 	protected static final String RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt";
 	protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "EnergyUsage.txt";
@@ -141,10 +146,10 @@
 	protected SimulatedEnvironment resourceController;
 	protected boolean generateDiagrams = true;
-	protected AbstractStringSerializer serializer;
+	protected StringSerializer serializer;
 	protected long startSimulationTime;
 	protected long endSimulationTime;
 	
 	//RESOURCES
-	protected Map<String, List<ResStat>> basicResStats;
+	protected Map<String, List<ResStat>> pesStats;
 	protected Map<String, Double> basicResLoad;
 	
@@ -156,5 +161,6 @@
 	protected Map<String, List<XYDataset>> resourceAirFlowDiagrams;
 	protected Map<String, List<XYDataset>> resourceTemperatureDiagrams;
-	protected Map<String, List<XYDataset>> resourceLoadDiagrams;
+	protected Map<String, List<XYDataset>> resourceOccupancyDiagrams;
+	protected Map<String, List<XYDataset>> resourceUtilizationDiagrams;
 	
 	//TASKS
@@ -178,28 +184,18 @@
 
 		this.outputFolderName = outputFolderName;
-
-		this.serializer = new StringSerializer();
-		
-		if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){
-			this.serializer = new CoolEmAllStringSerializer();	
-		}
-		this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT);
-
 		this.resourceController = resourceController;
 		this.jr = new JobRegistryImpl("");
-		init();
-		metCalc = new MetricsCalculator();
-	}
-
-	public void generateStatistics() {
-
+		
 		if(users.isSimStartTimeDefined())
 			this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis();
 		else
 			this.startSimulationTime = new DateTime(users.getSubmissionStartTime() * 1000l).getMillis();
+		
 		this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
 
-		metCalc.setStartTime(startSimulationTime);
-		metCalc.setEndTime(endSimulationTime);
+		init();
+	}
+
+	public void generateStatistics() {
 		
 		long s = 0;
@@ -234,4 +230,13 @@
 		accStats = new GSSAccumulatorsStats();
 		statsData = new HashMap<String, GSSAccumulator>();
+		
+		this.serializer = new StringSerializer();		
+		this.metCalc =  new DCwormsMetricsCalculator(startSimulationTime, endSimulationTime, endSimulationTime);
+		
+		if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){
+			this.serializer = new CoolEmAllStringSerializer();
+			this.metCalc = new CoolEmAllMetricsCalculator(startSimulationTime, endSimulationTime, endSimulationTime);
+		}
+		this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT);
 	}
 
@@ -262,7 +267,9 @@
 			System.out.println("#STATS " + "===== Performance statistics =====");
 			System.out.println("#STATS " + "Makespan: " + df.format(accStats.makespan.getMean()) + " [s]");
-			System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]");
+			System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]" + "; mean: " + df.format(accStats.meanTaskCompletionTime.getMean()) + " [s]");
 			System.out.println("#STATS " + "Mean task execution time: " + df.format(accStats.meanTaskExecutionTime.getMean()) + " [s]");
+			System.out.println("#STATS " + "System occupancy: " + df.format(accStats.meanTotalOccupancy.getMean() * 100) + " [%]");
 			System.out.println("#STATS " + "System load: " + df.format(accStats.meanTotalLoad.getMean() * 100) + " [%]");
+			
 			
 			simulationStatsFile.println(txt);
@@ -300,5 +307,6 @@
 		taskGanttMap = new HashMap<String, TimetableEventGroup>();		
 		
-		resourceLoadDiagrams = new HashMap<String, List<XYDataset>>();
+		resourceOccupancyDiagrams = new HashMap<String, List<XYDataset>>();
+		resourceUtilizationDiagrams = new HashMap<String, List<XYDataset>>();
 		resourcePowerUsageDiagrams = new HashMap<String, List<XYDataset>>();
 		resourceAirFlowDiagrams = new HashMap<String, List<XYDataset>>();
@@ -309,12 +317,22 @@
 		
 		
-		PrintStream resourceLoadStatsFile = null;
+		PrintStream resourceOccupancyStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ RESOURCEOCCUPANCY_STATISTICS_OUTPUT_FILE_NAME);
+			resourceOccupancyStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			resourceOccupancyStatsFile = null;
+		}
+		
+		PrintStream resourceUtilizationStatsFile = null;
 		try {
 			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
 					+ simulationIdentifier + "_"
 					+ RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME);
-			resourceLoadStatsFile = new PrintStream(new FileOutputStream(file));
+			resourceUtilizationStatsFile = new PrintStream(new FileOutputStream(file));
 		} catch (IOException e) {
-			resourceLoadStatsFile = null;
+			resourceUtilizationStatsFile = null;
 		}
 		
@@ -389,10 +407,10 @@
 		}
 		
-		basicResStats = gatherPEStats(jr.getTasks());
-		peStatsPostProcessing(basicResStats);
-		basicResLoad = calculatePELoad( basicResStats);
+		pesStats = gatherPEStats(jr.getTasks());
+		peStatsPostProcessing(pesStats);
+		basicResLoad = calculatePELoad(pesStats);
 
 		if (configuration.creatediagrams_gantt) {
-			createPEGanttDiagram(basicResStats);
+			createPEGanttDiagram(pesStats);
 		}
 		
@@ -412,5 +430,6 @@
 				
 				for(ComputingResource compResource: compResources){
-					ResourceUsageStats resourceUsage = null;
+					ResourceUsageStats resourceUtilization = null;					
+					ResourceUsageStats resourceOccupancy = null;
 					ResourcePowerStats energyUsage = null;
 					ResourceAirFlowStats airFlow = null;
@@ -418,15 +437,22 @@
 					ResourceUsefulWorkStats usefulWork = null;
 					if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){
-						resourceUsage = gatherResourceLoadStats(compResource, basicResStats);
-						resourceUsage.setMeanValue(calculateMeanValue(resourceUsage));
-						if (resourceLoadStatsFile != null) {
-							Object txt = resourceUsage.serialize(serializer);
-							resourceLoadStatsFile.print(txt);
+						resourceOccupancy = gatherResourceOccupancyStats(compResource, pesStats);
+						resourceOccupancy.setMeanValue(calculateMeanValue(resourceOccupancy));
+						if (resourceOccupancyStatsFile != null) {
+							Object txt = resourceOccupancy.serialize(serializer);
+							resourceOccupancyStatsFile.print(txt);
 						}
-
+						
+						resourceUtilization = gatherResourceUtlizationStats(compResource);
+						resourceUtilization.setMeanValue(calculateMeanValue(resourceUtilization));
+						if (resourceUtilizationStatsFile != null) {
+							Object txt = resourceUtilization.serialize(serializer);
+							resourceUtilizationStatsFile.print(txt);
+						}
 					}
 					if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){
 						if (configuration.creatediagrams_resutilization) {
-							createResourceLoadDiagram(resourceUsage);
+							createResourceOccupancyDiagram(resourceOccupancy);
+							createResourceUtilizationDiagram(resourceUtilization);
 						}
 					}
@@ -437,41 +463,34 @@
 						resourceEnergyAccumulator.add(energyUsage.getSumValue());
 						maxResourceEnergyAccumulator.add(calculateMaxValue(energyUsage));
-						double calulcationsEnergy = 0;
+						double calculationsEnergy = 0;
 						try {
-							/*boolean doCalc = false;
-							double prevTimestamp = 0;
-							for(Long key: resourceUsage.getHistory().keySet()){
-								if(doCalc){
-									System.out.println(energyUsage.getHistory().get(key));
-									calulcationsEnergy = calulcationsEnergy + energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600 * MILLI_SEC);
-									doCalc  = false;
-								}
-								if(resourceUsage.getHistory().get(key)>0){
-									prevTimestamp = key;
-									doCalc = true;
-								}
-							}*/
 							boolean doCalc = false;
+							double load = 0;
 							long prevTimestamp = 0;
 							for(Long key: energyUsage.getHistory().keySet()){
 								if(doCalc){
-									double load = 0;
-									if(resourceUsage.getHistory().get(prevTimestamp)!= null){
-										load = resourceUsage.getHistory().get(prevTimestamp);
+									if(resourceTypeName.equals("Rack")){
+										calculationsEnergy = calculationsEnergy + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (key - prevTimestamp) /(3600.0 * MILLI_SEC);
+									}/* else if(resourceTypeName.equals("Processor")){
+										Processor proc =( Processor) compResource;
+										double maxPower = proc.getPowerInterface().getLowestPState().getLoadPowerUsage().get(100.0);
+										calculationsEnergy = calculationsEnergy + load * maxPower * (key - prevTimestamp) /(3600.0 * MILLI_SEC);
+									}*/
+									else 
+										calculationsEnergy = calculationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC);
+									doCalc = false;
+									load = 0;
+								}
+								
+								if(resourceUtilization.getHistory().get(key) != null){
+									load = resourceUtilization.getHistory().get(key);
+									if(load > 0 ){
+										doCalc = true;
+										prevTimestamp = key;
 									}
-									calulcationsEnergy = calulcationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC);
-									doCalc = false;
-								}
-								if(energyUsage.getHistory().get(key) > compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION){
-									
-									prevTimestamp = key;
-									doCalc = true;
 								}
 							}
-							//calulcationsEnergy = energyUsage.getSumValue() - 
-							//	((1 - resourceUsage.getMeanValue()) * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)) * 
-							//	(compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION);
-							//System.out.println(compResource.getFullName() + ";" + resourceUsage.getMeanValue() +":"+ calulcationsEnergy  + ":" + energyUsage.getSumValue());
-							calculationsEnergyAccumulator.add(calulcationsEnergy);
+
+							calculationsEnergyAccumulator.add(calculationsEnergy);
 						} catch (Exception e) {
 							e.printStackTrace();
@@ -510,4 +529,5 @@
 							devAccumulator.add(deviceEnergyUsage.getSumValue());
 							metCalc.addMetricsData(device.getType().getName(), devAccumulator);
+							metCalc.addMetricsData(device.getFullName(), devAccumulator);
 							if (deviceStatsFile != null) {
 								Object txt = deviceEnergyUsage.serialize(serializer);
@@ -666,5 +686,5 @@
 			//log.info("#STATS " + "Metrics");
 			System.out.println("#STATS " + "===== Metrics =====");
-			for(MetricsStats metric: metCalc.calulateMetrics(endSimulationTime)){
+			for(MetricsStats metric: metCalc.calulateMetrics()){
 				Object txt = metric.serialize(serializer);
 				//log.info("#STATS " +  metric.getResourceName() + " " + metric.getMetricName() + ": " + metric.getValue());
@@ -676,5 +696,5 @@
 			}
 		}
-		saveResourceUsageDiagrams();
+		saveResourceDiagrams();
 		createAccumulatedResourceSimulationStatistic();
 		
@@ -688,6 +708,9 @@
 			energyStatsFile.close();
 		}
-		if (resourceLoadStatsFile != null) {
-			resourceLoadStatsFile.close();
+		if (resourceOccupancyStatsFile != null) {
+			resourceOccupancyStatsFile.close();
+		}
+		if (resourceUtilizationStatsFile != null) {
+			resourceUtilizationStatsFile.close();
 		}
 		
@@ -813,5 +836,5 @@
 	
 	
-	private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) {
+	private ResourceUsageStats gatherResourceOccupancyStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) {
 		String usageType = null;
 		if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){
@@ -844,5 +867,5 @@
 		int usedResources = 0;
 		for(ComputingResource compResource: resource.getChildren()){
-			double meanLoad = calculateMeanValue(gatherResourceLoadStats(compResource, basicResStats));
+			double meanLoad = calculateMeanValue(gatherResourceOccupancyStats(compResource, pesStats));
 			if(meanLoad > 0){
 				usedResources++;
@@ -916,4 +939,34 @@
 	}
 	
+	private ResourceUsageStats gatherResourceUtlizationStats(PhysicalResource resource) {
+		
+		String usageType = null;
+		if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){
+			usageType = resource.getResourceCharacteristic().getParameters().get("load-sensor").get(0).getContent();
+		}
+		ResourceUsageStats resUtlization = new ResourceUsageStats(resource.getFullName(), resource.getType(), usageType);
+		Map<Long, Double> usage = resUtlization.getHistory();
+		
+		ExtensionList extensionList = resource.getExtensionList();
+		if(extensionList != null){
+			for (Extension extension : extensionList) {
+				if (extension.getType() == ExtensionType.LOAD_EXTENSION) {
+					LoadExtension le = (LoadExtension)extension;
+					if(le.getLoadProfile() == null)
+						break;
+					List<MeasurementHistory> loadHistory = le.getLoadProfile().getUtilizationHistory();
+					if(loadHistory.size() == 0)
+						break;
+					long endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
+
+					loadHistory.add(new MeasurementHistory(endSimulationTime, le.getLoadProfile().getUtilizationHistory().get(le.getLoadProfile().getUtilizationHistory().size() - 1).getValue()/100));
+					for(MeasurementHistory l:loadHistory){
+						usage.put(l.getTimestamp(), l.getValue()/100);
+					}
+				}
+			}
+		}
+		return resUtlization;
+	}
 	
 	private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) {
@@ -921,5 +974,5 @@
 		
 		String usageType = null;
-		if(resource.getResourceCharacteristic().getParameters().get("power-sensor")!= null){
+		if(resource.getResourceCharacteristic().getParameters().get("power-sensor") != null){
 			usageType = resource.getResourceCharacteristic().getParameters().get("power-sensor").get(0).getContent();
 		}
@@ -954,9 +1007,8 @@
 	}
 	
-	
 	private ResourceAirFlowStats gatherResourceAirFlowStats(PhysicalResource resource) {
 
 		String usageType = null;
-		if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor")!= null){
+		if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor") != null){
 			usageType = resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor").get(0).getContent();
 		}
@@ -1016,5 +1068,5 @@
 	}
 	
-	private void createResourceLoadDiagram(ResourceUsageStats resLoadStats) {
+	private void createResourceOccupancyDiagram(ResourceUsageStats resLoadStats) {
 
 		for(Long key: resLoadStats.getHistory().keySet()){
@@ -1026,11 +1078,31 @@
 				startSimulationTime, endSimulationTime);
 
-		List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resLoadStats.getResourceType().getName());
-		if(loadDiagram == null){
-			loadDiagram = new ArrayList<XYDataset>();
-			loadDiagram.add(dataset);
-			resourceLoadDiagrams.put(resLoadStats.getResourceType().getName(), loadDiagram);
+		List<XYDataset> occupancyDiagram = resourceOccupancyDiagrams.get(resLoadStats.getResourceType().getName());
+		if(occupancyDiagram == null){
+			occupancyDiagram = new ArrayList<XYDataset>();
+			occupancyDiagram.add(dataset);
+			resourceOccupancyDiagrams.put(resLoadStats.getResourceType().getName(), occupancyDiagram);
 		} else {
-			loadDiagram.add(dataset);
+			occupancyDiagram.add(dataset);
+		}
+	}
+	
+	private void createResourceUtilizationDiagram(ResourceUsageStats resLoadStats) {
+
+		for(Long key: resLoadStats.getHistory().keySet()){
+			Double value = resLoadStats.getHistory().get(key) * 100;
+			resLoadStats.getHistory().put(key, value);
+		}
+		
+		XYDataset dataset = createResourceChartDataSet(resLoadStats,
+				startSimulationTime, endSimulationTime);
+
+		List<XYDataset> utilizationDiagram = resourceUtilizationDiagrams.get(resLoadStats.getResourceType().getName());
+		if(utilizationDiagram == null){
+			utilizationDiagram = new ArrayList<XYDataset>();
+			utilizationDiagram.add(dataset);
+			resourceUtilizationDiagrams.put(resLoadStats.getResourceType().getName(), utilizationDiagram);
+		} else {
+			utilizationDiagram.add(dataset);
 		}
 	}
@@ -1109,5 +1181,5 @@
 	}
 
-	private boolean saveResourceUsageDiagrams() {
+	private boolean saveResourceDiagrams() {
 
 		if (!generateDiagrams)
@@ -1133,11 +1205,24 @@
 		chartName = "Load diagram for "
 			+ DataCenterWorkloadSimulator.SIMULATOR_NAME;
-		JFreeChart resourceLoadDiagram = null;
+		JFreeChart resourceOccupancyDiagram = null;
+		if (configuration.creatediagrams_resutilization) {
+			String axisName = "OCCUPANCY [%]";
+			for(String resType: resourceOccupancyDiagrams.keySet()){
+				resourceOccupancyDiagram = getResourceDynamicDiagram(resourceOccupancyDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
+				if (!saveXYPlotChart(resourceOccupancyDiagram, fileName + "ResourcesOccupancy_" + resType))
+					return false;
+			}
+		}
+		
+		chartName = "Utilization diagram for "
+			+ DataCenterWorkloadSimulator.SIMULATOR_NAME;
+		JFreeChart resourceUtilizationDiagram = null;
 		if (configuration.creatediagrams_resutilization) {
 			String axisName = "UTILIZATION [%]";
-			for(String resType: resourceLoadDiagrams.keySet()){
-				resourceLoadDiagram = getResourceDynamicDiagram(resourceLoadDiagrams.get(resType), simulationTime, chartName,
+			for(String resType: resourceUtilizationDiagrams.keySet()){
+				resourceUtilizationDiagram = getResourceDynamicDiagram(resourceUtilizationDiagrams.get(resType), simulationTime, chartName,
 						subtitle, axisName);
-				if (!saveXYPlotChart(resourceLoadDiagram, fileName + "ResourcesLoad_" + resType))
+				if (!saveXYPlotChart(resourceUtilizationDiagram, fileName + "ResourcesUtilization_" + resType))
 					return false;
 			}
@@ -1322,5 +1407,8 @@
 				//double load = calculateMeanValue(resourceUsage);
 				double load = calculateResourceLoad(compRes, basicResLoad);
-				accStats.meanTotalLoad.add(load);
+				accStats.meanTotalOccupancy.add(load);
+
+				ResourceUsageStats resourceUtilization = gatherResourceUtlizationStats(compRes);
+				accStats.meanTotalLoad.add(calculateMeanValue(resourceUtilization));
 				/*ResourceEnergyStats energyUsage = gatherResourceEnergyStats(compRes);
 				energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage));
@@ -1365,5 +1453,5 @@
 
 	
-	private double calculateMeanValue(ResourceDynamicStats resDynamicStats ){
+	private double calculateMeanValue(ResourceDynamicStats resDynamicStats){
 		double meanValue = 0;
 		long time = -1;
@@ -1387,5 +1475,5 @@
 	
 	
-	private double calculateMaxValue(ResourceDynamicStats resDynamicStats ){
+	private double calculateMaxValue(ResourceDynamicStats resDynamicStats){
 		double maxValue = 0;
 
@@ -1414,5 +1502,5 @@
 		try {
 			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX + simulationIdentifier + "_"
-					+ RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME);
+					+ TASKS_STATISTICS_OUTPUT_FILE_NAME);
 			taskStatsFile = new PrintStream(new FileOutputStream(file));
 		} catch (IOException e) {
@@ -1634,5 +1722,5 @@
 		chartName = "Task waiting times diagram for " + DataCenterWorkloadSimulator.SIMULATOR_NAME;
 		if (configuration.creatediagrams_taskswaitingtime) {
-			waitingTimeDiagram = getWaitingTimeDiagram(chartName, subtitle, simulationTime);
+			waitingTimeDiagram = getTaskWaitingTimeDiagram(chartName, subtitle, simulationTime);
 			if (!saveCategoryChart(waitingTimeDiagram, fileName + "Waiting_Time", null /* "Task {1} at {0}" */))
 				return false;
@@ -1655,5 +1743,5 @@
 	}
 
-	private JFreeChart getWaitingTimeDiagram(String chartName, Title subtitle, String simulationTime) {
+	private JFreeChart getTaskWaitingTimeDiagram(String chartName, Title subtitle, String simulationTime) {
 		String tasks = "Tasks";
 		boolean urls = false;
@@ -1878,4 +1966,4 @@
 	textTemperature,
 	chartTemperature,
-	textUsefulWorl;
+	textUsefulWork;
 }
Index: DCWoRMS/branches/coolemall/src/simulator/stats/CoolEmAllMetricsCalculator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/CoolEmAllMetricsCalculator.java	(revision 1299)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/CoolEmAllMetricsCalculator.java	(revision 1299)
@@ -0,0 +1,426 @@
+package simulator.stats;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import simulator.stats.implementation.MetricsStats;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolEmAllMetricsCalculator extends AbstractMetricsCalculator{
+	
+	public CoolEmAllMetricsCalculator (long startTime, long endTime, long timestamp){
+		super(startTime, endTime, timestamp);
+	}
+	
+	public List<MetricsStats> calulateMetrics(){
+		List<MetricsStats> metrics = new ArrayList<MetricsStats>();
+		/*for(String resourceTypeName: metricsData.keySet()){
+			MetricsStats metric = new MetricsStats(resourceTypeName, "energyUsage", metricsData.get(resourceTypeName).getMax());
+			metrics.add(metric);}
+		}*/
+		metrics.add(calculateITComputingEnergyConsumption());
+		metrics.add(calculateITEnergyConsumption());
+		metrics.add(calculateNodeGroupFansEnergyConsumption());
+		
+		metrics.add(calculateRackEnergyConsumption());
+		metrics.add(calculateDataCenterFansEnergyConsumption());
+		metrics.add(calculateCoolingDeviceEnergyConsumption());
+		metrics.add(calculateOtherDevicesEnergyConsumption());
+		
+		metrics.add(calculateTotalEnergyConsumption());
+		
+		metrics.add(calculateMeanRackPower());
+		metrics.add(calculateMeanPower());
+		metrics.add(calculateMaxRackPower());
+		metrics.add(calculateMaxPower());
+		
+		metrics.add(calculatePUE());
+		metrics.add(calculatePUELevel4());
+		metrics.add(calculateEnergyWasteRate());
+		
+		metrics.add(calculateUsefulWork());
+		metrics.add(calculateProductivity());
+
+		return metrics;
+	}
+
+	private MetricsStats calculateTotalEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", roomPower, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateITComputingEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", (itComputingPower), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateITEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double totalSitePower = 0; 
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", (totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateNodeGroupFansEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", nodeGroupFansPowerConumspion, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculatePUELevel4(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			
+			double totalSitePower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			
+		
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", roomPower/(totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", -1, timestamp, "");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculatePUE(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			
+			double totalSitePower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+
+
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE", roomPower/totalSitePower, timestamp, "");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE", -1, timestamp, "");
+		}
+		return metric;
+	}
+
+	private MetricsStats calculateUsefulWork(){
+		
+		MetricsStats metric;
+		try{
+			double usefulWork = 0;
+			for(String key: metricsData.keySet()){
+				if(key.contains("/")){
+					for(GSSAccumulator acc: metricsData.get(key)){
+						usefulWork= usefulWork + acc.getSum();
+					}
+				}
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", usefulWork, timestamp, "UW units");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", -1, timestamp, "UW units");
+		}
+		
+		return metric;
+	}
+	
+	private MetricsStats calculateProductivity(){
+		
+		MetricsStats metric;
+		try{
+			double usefulWork = 0;
+			for(String key: metricsData.keySet()){
+				if(key.contains("/")){
+					for(GSSAccumulator acc: metricsData.get(key)){
+						usefulWork= usefulWork + acc.getSum();
+					}
+				}
+			}
+			double totalSitePower = 0; 
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			
+			metric = new MetricsStats("CoolEmAllTestbed", "Productivity", usefulWork/totalSitePower, timestamp, "UW units/Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Productivity", -1, timestamp, "UW units/Wh");
+		}
+		
+		return metric;
+	}
+	
+	
+	private MetricsStats calculateMaxRackPower(){
+		
+		MetricsStats metric;
+		try{
+			double maxPower = 0;
+			
+			for(GSSAccumulator acc: metricsData.get("Rack_MAX")){
+				maxPower = maxPower + acc.getSum();
+			}
+
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", maxPower, timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", -1, timestamp, "W");
+		}
+		
+		return metric;
+	}
+	
+	private MetricsStats calculateMaxPower(){
+		
+		MetricsStats metric;
+		try{
+			double maxPower = 0;
+			
+			for(GSSAccumulator acc: metricsData.get("Room_MAX")){
+				maxPower = maxPower + acc.getSum();
+			}
+
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_power", maxPower, timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_power", -1, timestamp, "W");
+		}
+		
+		return metric;
+	}
+	
+	private MetricsStats calculateDataCenterFansEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double inletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Inlet")){
+				inletsPower = inletsPower + acc.getSum();
+			}
+			
+			double outletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Outlet")){
+				outletsPower = outletsPower + acc.getSum();
+			}
+			
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+			
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (inletsPower + outletsPower - nodeGroupFansPowerConumspion), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateRackEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", roomPower, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateCoolingDeviceEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double coolingDevicePower = 0;
+			for(GSSAccumulator acc: metricsData.get("CoolingDevice")){
+				coolingDevicePower = coolingDevicePower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", coolingDevicePower, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateOtherDevicesEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			
+			double totalSitePower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			
+			double coolingDevicePower = 0;
+			for(GSSAccumulator acc: metricsData.get("CoolingDevice")){
+				coolingDevicePower = coolingDevicePower + acc.getSum();
+			}
+			
+			double inletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Inlet")){
+				inletsPower = inletsPower + acc.getSum();
+			}
+			
+			double outletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Outlet")){
+				outletsPower = outletsPower + acc.getSum();
+			}
+			
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", roomPower - (totalSitePower + coolingDevicePower + (inletsPower + outletsPower - nodeGroupFansPowerConumspion)), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+
+	
+	private MetricsStats calculateMeanPower(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", -1, timestamp, "W");
+		}
+		return metric;
+	}
+	
+	
+	private MetricsStats calculateMeanRackPower(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", -1, timestamp, "W");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateEnergyWasteRate(){
+		
+		MetricsStats metric;
+		try{
+			double itComputingEnergy = 0;
+			double otherItComputingEnergy = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor_CALC")){
+				itComputingEnergy = itComputingEnergy + acc.getSum();
+			}
+			for(GSSAccumulator acc: metricsData.get("Rack_CALC")){
+				otherItComputingEnergy = otherItComputingEnergy + acc.getSum();
+			}
+			itComputingEnergy = itComputingEnergy ;//+ otherItComputingEnergy;// + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC);
+
+			double itEnergy = calculateITEnergyConsumption().getValue();
+			double processorsEnergy = calculateITComputingEnergyConsumption().getValue();
+
+			metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", (1 - itComputingEnergy/itEnergy) * 100, timestamp, "%");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", -1, timestamp, "%");
+		}
+		
+		return metric;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java	(revision 1299)
@@ -74,5 +74,5 @@
 		sendJobsIds = new HashSet<String>();
 		returnedJobsIds = new HashSet<String>();
-		
+		returnedJobs = new ArrayList<JobInterface<?>>();
 		this.xsltTransformer = new XsltTransformations();
 	}
@@ -80,6 +80,10 @@
 	@Override
 	public void body() {
-		sendJobs();
-		collectJobs();
+		if(workloadLoader != null){
+			sendJobs();
+			collectJobs();	
+		} else {
+			submissionStartTime = 0;
+		}
 
 		//GridSim dependent code for shutting down the simulation
@@ -93,8 +97,7 @@
 	 */
 	protected void collectJobs() {
-		final int FACTOR = Math.min(10, workloadLoader.getTaskCount()); //the refresh rate of the gauge: at most 10 times
+		final int FACTOR = Math.min(100, workloadLoader.getTaskCount() > 0 ? workloadLoader.getTaskCount() : 1); //the refresh rate of the gauge: at most 10 times
 		final int denominator = workloadLoader.getTaskCount() / FACTOR;
 		allTasksAreFinished = true;
-		returnedJobs = new ArrayList<JobInterface<?>>();
 		int counter = 0;
 		int oldRemeinder = 0;
@@ -244,4 +247,6 @@
 	
 	public List<JobDescription> getAllSentJobs() {
+		if (workloadLoader == null)
+			return new ArrayList<JobDescription>();
 		return (List<JobDescription>) workloadLoader.getJobs();
 	}
@@ -349,4 +354,7 @@
 	
 	public boolean isSimStartTimeDefined(){
+		if(workloadLoader == null){
+			return false;
+		}
 		return workloadLoader.isSimStartTimeDefined();
 	}
Index: DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java	(revision 1279)
+++ DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java	(revision 1299)
@@ -8,4 +8,6 @@
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
+
+import test.CoolingModelData;
 
 /**
@@ -189,11 +191,12 @@
 	public String [] resForUtilizationChart;
 	
-	public static double pressureDrop;
-	public static double outletRoomAirTempeature;
-	public static double inletRoomAirTempeature;
-	public static double ambientAirTempeature;
-	public static double airFlowVolume;
-	public static double alpha
-	;
+	public double pressureDrop;
+	public double outletRoomAirTempeature;
+	public double inletRoomAirTempeature;
+	public double ambientAirTempeature;
+	public double airFlowVolume;
+	public double alpha;
+	
+	public static CoolingModelData coolingData;
 	/**
 	 * An empty constructor.
@@ -389,39 +392,40 @@
 
 		try {
-			ConfigurationOptions.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue();
-		} catch(MissingResourceException e){
-			ConfigurationOptions.pressureDrop = 65;
-		}
-		
-		try {
-			ConfigurationOptions.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue();
-		} catch(MissingResourceException e){
-			ConfigurationOptions.outletRoomAirTempeature = 23;
-		}
-		
-		try {
-			ConfigurationOptions.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue();
-		} catch(MissingResourceException e){
-			ConfigurationOptions.inletRoomAirTempeature = 17;
-		}
-		
-		try {
-			ConfigurationOptions.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue();
-		} catch(MissingResourceException e){
-			ConfigurationOptions.ambientAirTempeature = 17;
-		}
-		
-		try {
-			ConfigurationOptions.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue();
-		} catch(MissingResourceException e){
-			ConfigurationOptions.airFlowVolume = 4;
-		}
-		
-		try {
-			ConfigurationOptions.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue();
-		} catch(MissingResourceException e){
-			ConfigurationOptions.alpha = 0.2;
-		}
-		
+			co.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue();
+		} catch(MissingResourceException e){
+			co.pressureDrop = -1;
+		}
+		
+		try {
+			co.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue();
+		} catch(MissingResourceException e){
+			co.outletRoomAirTempeature = -1;
+		}
+		
+		try {
+			co.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue();
+		} catch(MissingResourceException e){
+			co.inletRoomAirTempeature = -1;
+		}
+		
+		try {
+			co.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue();
+		} catch(MissingResourceException e){
+			co.ambientAirTempeature = -1;
+		}
+		
+		try {
+			co.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue();
+		} catch(MissingResourceException e){
+			co.airFlowVolume = -1;
+		}
+		
+		try {
+			co.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue();
+		} catch(MissingResourceException e){
+			co.alpha = -1;
+		}
+		
+		ConfigurationOptions.coolingData = new CoolingModelData(co.pressureDrop, co.outletRoomAirTempeature, co.inletRoomAirTempeature, co.ambientAirTempeature, co.airFlowVolume, co.alpha);
 		return co;
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java	(revision 1299)
@@ -3,4 +3,5 @@
 import gridsim.GridSimTags;
 import gridsim.dcworms.DCWormsTags;
+import gridsim.dcworms.filter.ResourceEventFilter;
 
 import java.util.ArrayList;
@@ -24,4 +25,8 @@
 import schedframe.resources.computing.profiles.energy.EnergyEventType;
 import schedframe.resources.computing.profiles.energy.EnergyExtension;
+import schedframe.resources.computing.profiles.load.LoadExtension;
+import schedframe.resources.computing.profiles.load.ResourceLoadCalendar;
+import schedframe.resources.computing.profiles.load.TimestampUtilization;
+import schedframe.resources.computing.profiles.load.ui.LoadInterface;
 import schedframe.resources.computing.properties.DefaultPropertiesBuilder;
 import schedframe.resources.computing.properties.PropertiesDirector;
@@ -34,4 +39,5 @@
 import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.Scheduler;
+import simulator.DataCenterWorkloadSimulator;
 
 public class ComputingResource extends PhysicalResource{
@@ -51,4 +57,5 @@
 		this.extensionList = new ExtensionListImpl(1);
 		initCharacteristics(resDesc);
+		accept(new LoadExtension(resDesc.getLoadProfile(), this));
 		accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airFlowProfile(resDesc.getAirThroughputProfile()).thermalProfile(resDesc.getThermalProfile()).build());	
 	}
@@ -67,4 +74,7 @@
 	public void setParent(ComputingResource newParent) {
 		parent = newParent;
+		if(this.getLoadInterface().getLoadCalendar().getLoadDistribution().size() == 0){
+			this.getLoadInterface().getLoadCalendar().getLoadDistribution().addAll(parent.getLoadInterface().getLoadCalendar().getLoadDistribution());
+		}
 	}
 
@@ -220,5 +230,5 @@
 		public void handleResourceEvent(Event event){
 			if (extensionList != null) {
-				for (Extension extension : extensionList) {
+				for (Extension extension: extensionList) {
 					if (extension.supportsEvent(event)) {
 						extension.handleEvent(event);
@@ -227,7 +237,7 @@
 				
 				for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) {
-					for (Extension extension : device.getExtensionList()) {
+					for (Extension extension: device.getExtensionList()) {
 						if (extension.supportsEvent(event)) {
-							//extension.handleEvent(event);
+							extension.handleEvent(event);
 						}
 					}
@@ -242,4 +252,6 @@
 			if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){
 				String src = event.getSource() != null ? event.getSource() : name;
+				ResourceEventFilter filter = new ResourceEventFilter(src.hashCode(), DCWormsTags.UPDATE_PROCESSING);
+				scheduler.sim_cancel(filter, null);
 				scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE_PROCESSING, src);
 			} else if(parent != null)
@@ -274,4 +286,13 @@
 		rec.execute(event);
 		
+		LoadInterface li = getLoadInterface();
+		if(li != null){
+			ResourceLoadCalendar rlc = li.getLoadCalendar();
+			LinkedList<TimestampUtilization> ll = rlc.getLoadDistribution();
+			for(TimestampUtilization tu: ll){
+				DataCenterWorkloadSimulator.getEventManager().sendToResource(getFullName(), tu.getStartTime(), new EnergyEvent(EnergyEventType.RESOURCE_UTILIZATION_CHANGED, getFullName()));
+				DataCenterWorkloadSimulator.getEventManager().sendToResource(getFullName(), tu.getEndTime(), new EnergyEvent(EnergyEventType.RESOURCE_UTILIZATION_CHANGED, getFullName()));
+			}					
+		}
 		//alternative way
 		//getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"));
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java	(revision 1247)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java	(revision 1299)
@@ -1,4 +1,5 @@
 package schedframe.resources.computing.coolemall;
 
+import java.util.ArrayList;
 import java.util.List;
 
@@ -8,4 +9,8 @@
 import schedframe.resources.computing.Processor;
 import schedframe.resources.computing.description.ComputingResourceDescription;
+import schedframe.resources.computing.description.ResourceDescription;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import test.Node_Fan_Mapping;
 
 public class NodeGroup extends ComputingResource{
@@ -13,4 +18,5 @@
 	public NodeGroup(ComputingResourceDescription resDesc) {
 		super(resDesc);
+		initNodes_FansMapping(resDesc);
 	}
 
@@ -25,3 +31,24 @@
 	}
 
+	
+	private void initNodes_FansMapping(ComputingResourceDescription resDesc){
+		Node_Fan_Mapping.init();
+		for(Device dev: this.getResourceCharacteristic().getDevices()){
+			if(dev.getType().equals(StandardResourceType.Fan) || dev.getType().equals(StandardResourceType.Inlet) | dev.getType().equals(StandardResourceType.Outlet)){
+				Fan fan = (Fan) dev;
+				List<String> chilledResources = new ArrayList<String>();
+				for(ResourceDescription nodeDesc: resDesc.getChildren()){
+					String nodeName = this.getFullName() + "/" + nodeDesc.getId();
+					if(!Node_Fan_Mapping.getNode_fan().containsKey(nodeName)){
+						chilledResources.add(nodeName);
+					} else if(Node_Fan_Mapping.getNode_fan().get(nodeName).equals(fan.getFullName())){
+						chilledResources.add(nodeName);
+					} else {
+						//if mapping present but there is no match do nothing
+					}
+				}
+				fan.setChilledResources(chilledResources);
+			}
+		}
+	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java	(revision 1281)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java	(revision 1299)
@@ -20,5 +20,5 @@
 		super(resource, pp);
 		currentPowerState = StandardPowerStateName.ON;
-		currentPState = getHighestPState();
+		currentPState = getLowestPState();
 	}
 	
