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/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/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/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/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_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_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_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/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;
+	}
+
+}
