Index: DCWoRMS/branches/coolemall/src/test/fips/models/fpga/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/FCFSBF_RandomPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/FCFSBF_RandomPlugin.java	(revision 1600)
@@ -0,0 +1,159 @@
+package test.fips.models.fpga;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.events.scheduling.SchedulingEvent;
+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.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.ResourceEventType;
+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.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public FCFSBF_RandomPlugin() {
+		rand = new Random(175);
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Processor> cpus = resourceManager.getProcessors();
+		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(cpus, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+
+			break;
+
+		}	
+		return plan;
+	}
+	
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Processor> cpus, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+
+
+		
+		if (cpuRequest != 0) {
+
+
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cpus.size() && cpuRequest > 0; i++) {
+				if (cpus.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cpus.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+
+	private List<Node> filterNodes(List<Node> nodes, int cpuRequest){
+		List<Node> filteredNodes = new ArrayList<Node>();
+
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Processor> cpus = node.getProcessors();
+				if (cpus.size() < cpuRequest) {
+					if(cpus.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCpus = 0;
+				for(Processor cpu: cpus){
+					if(cpu.getStatus() == ResourceStatus.FREE)
+						freeCpus++;
+				}
+				
+				if(freeCpus < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/test/fips/models/fpga/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,60 @@
+package test.fips.models.fpga;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class TangCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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 airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption =  (Pload_dc + Pothers)/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/fpga/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,101 @@
+package test.fips.models.fpga;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = (Pload_dc + Pothers + Pfans_dc)/CoP;
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+		for(Device d: room.getResourceCharacteristic().getDevices()){
+			if(d.getType().getName().equals("Outlet") || d.getType().getName().equals("Inlet") )
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+
+		return Pfans_dc;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/fpga/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/NodeEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/NodeEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,34 @@
+package test.fips.models.fpga;
+
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	private static double Pidle = 0;
+	private static double Pfull = 0;
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		Node node = (Node) resource;
+		double powerConsumption = 0;
+
+		double Pcpu = 0;	
+		for(Processor cpu: node.getProcessors()){
+			Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
+		//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
+		return powerConsumption;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/fpga/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,485 @@
+package test.fips.models.fpga;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Fan", "Fan"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+System.out.println(Qcooling);
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/fpga/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/DataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/DataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,527 @@
+package test.fips.models.fpga;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class DataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		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;
+				System.out.println("1");
+			}
+			else{
+				Pcooling_device = Pchiller;	
+				System.out.println("2");
+			}	
+		}
+		
+
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		//Pcooling_device = Pload_dc/CoP;
+		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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			
+			for(Device d: room.getResourceCharacteristic().getDevices()){
+				if(d.getFullName().contains("Cooling"))
+					continue;
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+			//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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/fpga/FPGAEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/fpga/FPGAEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/fpga/FPGAEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,59 @@
+package test.fips.models.fpga;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.CustomPowerStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.tasks.phases.PhaseSystemLoad;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class FPGAEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		/*double powerConsumption = 0;
+
+		Processor cpu = (Processor)resource;
+		powerConsumption = Pidle + (Pfull- Pidle) * cpu.getLoadInterface().getRecentUtilization().getValue()/100;			
+
+		return powerConsumption;*/
+		double load = 0;
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			if(load == 0){
+				powerConsumption = 7;
+			}
+			for(ExecTask task: jobRegistry.getRunningTasks()){
+				double usage = 0;
+				double energy = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Total_Running_Energy"));
+				double idle_energy = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Total_Idle_Energy"));
+				double av_power = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Average_Power"));
+				 powerConsumption =  powerConsumption + av_power;
+				for(PhaseSystemLoad pb: task.getExecutionProfile().getCurrentExecutionPhase().getSystemLoad()){
+					if(pb.getResouceName().equals("Usage")){
+						usage = pb.getUtilization();
+						break;
+					}
+					if(pb.getResouceName().equals("PM_Running_Energy")){
+						//energy = pb.getUtilization();
+						break;
+					}
+				}
+
+			}
+
+		}
+		
+		return powerConsumption;
+
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/FlowPumpInletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/FlowPumpInletEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/FlowPumpInletEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,143 @@
+package test.fips.models.i5;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class FlowPumpInletEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			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;
+
+			for(ComputingResource cr: room.getChildren()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) &&  Integer.valueOf(device2.getName().split("_")[1]) == Integer.valueOf(device.getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+		}
+		
+		//System.out.println("Flow Pump power: " + powerConsumption);
+		//powerConsumption = 0;
+		return powerConsumption;
+	}
+	
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		double Vair_total;
+		
+		Vair_total = ConfigurationOptions.coolingData.getAirflowVolume();
+		if(Vair_total != -1) {
+			airflow = 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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().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.getAirflowInterface().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;
+			airflow = Vair_total;
+		}
+		return airflow;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/NodeEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/NodeEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,34 @@
+package test.fips.models.i5;
+
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	private static double Pidle = 6;
+	private static double Pfull = 10;
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		Node node = (Node) resource;
+		double powerConsumption = 0;
+
+		double Pcpu = 0;	
+		for(Processor cpu: node.getProcessors()){
+			Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
+		//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
+		return powerConsumption;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/FlowPumpOutletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,79 @@
+package test.fips.models.i5;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class FlowPumpOutletEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+
+		return powerConsumption;
+	}
+	
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		double Vair_total;
+		
+		Vair_total = ConfigurationOptions.coolingData.getAirflowVolume();
+		if(Vair_total != -1) {
+			airflow = 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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) || Integer.valueOf(device2.getName().split("_")[1]) == Integer.valueOf(device.getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			airflow = Vair_total;
+		}
+		return airflow;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangHeatCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangHeatCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangHeatCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,115 @@
+package test.fips.models.i5;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangHeatCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		
+		Device coolingDevice = (Device) resource;
+		ComputingResource room = (ComputingResource) coolingDevice.getComputingResource();
+		
+		double Pload_dc = calculatePit(room);
+		double Q = calculateQ( 0.02*Pload_dc, room);
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption = Q/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		return Pload_dc;
+	}
+
+	
+	private double calculateQ(double Pothers, ComputingResource room){
+
+		double Qdc = 0;
+
+
+		/**************** HEAT ****************/
+		
+		double Qload_dc = 0;
+		double Qothers = 0;
+
+		double delta_2; //DEBB - currently not present;
+		delta_2 = 0.4;
+		
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.getProcessors()){
+						Qcpu = Qcpu + proc.getPowerInterface().getRecentPowerUsage().getValue();
+					}
+					Qnodes = Qnodes + n.getPowerInterface().getRecentPowerUsage().getValue();;
+				}
+				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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.getNodes().size()){
+				Qload_dc  = Qload_dc + QnodeGroup + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION;
+			} else {
+				Qload_dc  = Qload_dc + QnodeGroup;
+			}
+		}
+		
+		Qothers = Pothers;
+		
+		Qdc = Qload_dc + Qothers;
+
+		
+		return Qdc;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangHeatDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangHeatDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangHeatDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,158 @@
+package test.fips.models.i5;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangHeatDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		double Q= calculateQ(Pothers, room);
+		Pcooling_device = coolingDevice.getPowerInterface().getRecentPowerUsage().getValue();
+		Pdc = Pload_dc + Pcooling_device+ Pothers;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers +  " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+
+	private double calculateQ(double Pothers, ComputingResource room){
+
+		double Qdc = 0;
+		
+
+		/**************** HEAT ****************/
+		
+		double Qload_dc = 0;
+		double Qothers = 0;
+
+		double delta_2; //DEBB - currently not present;
+		delta_2 = 0.4;
+		
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.getProcessors()){
+						Qcpu = Qcpu + proc.getPowerInterface().getRecentPowerUsage().getValue();
+					}
+					Qnodes = node.getPowerInterface().getRecentPowerUsage().getValue() + 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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.getNodes().size()){
+				Qload_dc  = Qload_dc + QnodeGroup + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION;
+			} else {
+				Qload_dc  = Qload_dc + QnodeGroup;
+			}
+		}
+		
+		Qothers = Pothers;
+		
+		
+		Qdc = Qload_dc + Qothers;
+
+		
+		return Qdc;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/CpuEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/CpuEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/CpuEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,90 @@
+package test.fips.models.i5;
+
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class CpuEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		/*double powerConsumption = 0;
+
+		Processor cpu = (Processor)resource;
+		powerConsumption = Pidle + (Pfull- Pidle) * cpu.getLoadInterface().getRecentUtilization().getValue()/100;			
+
+		return powerConsumption;*/
+		
+		double processorLoad = 0;
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			processorLoad = proc.getLoadInterface().getRecentUtilization().getValue();
+			double lowestLoadLevel = 100;
+			double highestLoadLevel = 0;
+			if(proc.getPowerInterface().getPState().getLoadPowerUsage().containsKey(new Double(processorLoad))){
+				powerConsumption = proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(processorLoad));
+			} else {
+				for(Double load: proc.getPowerInterface().getPState().getLoadPowerUsage().keySet()){
+					if(lowestLoadLevel > load){
+						lowestLoadLevel = load;
+					}
+					if(highestLoadLevel < load){
+						highestLoadLevel = load;
+					}
+				}
+				if(processorLoad == 0){
+					try{
+						powerConsumption = proc.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage();
+					} catch (Exception e){
+						powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel));
+					}
+				} else {
+					
+					double lowerLoadLevel = lowestLoadLevel;
+					double higherLoadLevel = highestLoadLevel;
+					
+					try{
+					
+						for(Double load: proc.getPowerInterface().getPState().getLoadPowerUsage().keySet()){
+							if(processorLoad > load){
+								lowerLoadLevel = load;
+							}
+							else if(processorLoad < load){
+								higherLoadLevel = load;
+								break;
+							}
+						}
+						double powerBelow;
+						double powerAbove;
+						double a;
+						double b;
+						if(lowerLoadLevel != higherLoadLevel) {
+							powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowerLoadLevel);
+							powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(higherLoadLevel);
+							a = (powerAbove - powerBelow)/(higherLoadLevel - lowerLoadLevel);
+							b = powerAbove - a * higherLoadLevel;
+						} else {
+							powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowestLoadLevel);
+							powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(highestLoadLevel);
+							a = (powerAbove - powerBelow)/(highestLoadLevel - lowestLoadLevel);
+							b = powerAbove - a * highestLoadLevel;
+						}
+						powerConsumption = a * processorLoad + b;
+					} catch (Exception e){
+						powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel));	
+					}
+				}
+			}
+		}
+		return powerConsumption;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,485 @@
+package test.fips.models.i5;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/i5/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/DataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/DataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,523 @@
+package test.fips.models.i5;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class DataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		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;	
+		}
+		
+
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = Pload_dc/CoP;
+		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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			
+			for(Device d: room.getResourceCharacteristic().getDevices()){
+				if(d.getFullName().contains("Cooling"))
+					continue;
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+			//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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/i5/RackEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/RackEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/RackEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,43 @@
+package test.fips.models.i5;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class RackEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+	
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+
+		
+		double powerConsumption = 0;
+		Rack rack = (Rack)resource;
+		for(ComputingResource nodeGroup: rack.getChildren()){
+			try{
+				powerConsumption = powerConsumption + nodeGroup.getPowerInterface().getRecentPowerUsage().getValue();
+			} catch (Exception e){
+				
+			}
+		}
+		
+		int nrOfPoweredOffNodes = 0;
+		for(Node node: rack.getNodes()){
+			if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+				nrOfPoweredOffNodes++;
+			}
+		}
+		if(nrOfPoweredOffNodes != rack.getNodes().size()){
+			powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY;			
+		}
+
+		return powerConsumption;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/FCFSBF_RandomPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/FCFSBF_RandomPlugin.java	(revision 1600)
@@ -0,0 +1,171 @@
+package test.fips.models.i5;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import org.joda.time.DateTime;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.events.scheduling.SchedulingEvent;
+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.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.ResourceEventType;
+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.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public FCFSBF_RandomPlugin() {
+		rand = new Random(175);
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Node> nodes = resourceManager.getNodes();
+		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:
+			System.out.println("aaa" + event.getType().toString());
+			// 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(nodes, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+
+			break;
+
+		}	
+		return plan;
+	}
+	
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Node> nodes, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		List<Node> filteredNodes = filterNodes(nodes, cpuRequest);
+		System.out.println("f" + filteredNodes.size());
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeProcessors().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeProcessors().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor> cpus = node.getProcessors();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cpus.size() && cpuRequest > 0; i++) {
+				if (cpus.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cpus.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+
+	private List<Node> filterNodes(List<Node> nodes, int cpuRequest){
+		List<Node> filteredNodes = new ArrayList<Node>();
+
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Processor> cpus = node.getProcessors();
+				if (cpus.size() < cpuRequest) {
+					if(cpus.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCpus = 0;
+				for(Processor cpu: cpus){
+					if(cpu.getStatus() == ResourceStatus.FREE)
+						freeCpus++;
+				}
+				
+				if(freeCpus < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/NodeGroupEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/NodeGroupEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/NodeGroupEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,36 @@
+package test.fips.models.i5;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.coolemall.NodeGroup;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeGroupEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		NodeGroup nodeGroup = (NodeGroup)resource;
+		for(Node node: nodeGroup.getNodes()){
+			try{
+				powerConsumption = powerConsumption + node.getPowerInterface().getRecentPowerUsage().getValue();
+
+			} catch (Exception e){
+			}
+		}
+		for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				Fan fan = (Fan) device;
+				powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+		}
+		return powerConsumption;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/FanEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/FanEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,70 @@
+package test.fips.models.i5;
+
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class FanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		Fan fan = (Fan) resource;
+		/*Node node = (Node) fan.getComputingResource();
+		double Tcpu = 0;
+		for(Processor cpu: node.getProcessors()){
+			Tcpu = Tcpu + cpu.getThermalInterface().getRecentTemperature().getValue();
+		}
+		Tcpu = Tcpu/node.getProcessors().size();
+		
+		if (Tcpu < TFanLow) {
+			powerConsumption = 4;
+		} else if (Tcpu > TFanHigh){
+			powerConsumption = PFanMax;
+		}
+		*/
+		
+		try {
+			powerConsumption = fan.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+		} catch (NoSuchFieldException e) {
+			//
+		}
+		
+		return powerConsumption;
+	}
+	
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		
+		double airflow = 0;
+		Fan fan = (Fan) resource;
+		
+		/*double fanEfficiency = 0;
+		try{
+			fanEfficiency = Double.valueOf(fan.getPowerInterface().getParameters().get("fanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+
+		double dp = 1013.25;
+		airflow = fan.getPowerInterface().getRecentPowerUsage().getValue() * fanEfficiency /dp;*/
+
+		try {
+			airflow = fan.getAirflowInterface().getAirflow(fan.getAirflowInterface().getAirflowState());
+		} catch (NoSuchFieldException e) {
+			//
+		}
+		return airflow;
+	}
+	
+	public double estimateTemperature (ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double temperature = EnvironmentConditions.ROOM_TEMPERATURE;
+		return temperature;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,60 @@
+package test.fips.models.i5;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class TangCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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 airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption =  (Pload_dc + Pothers)/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i5/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,101 @@
+package test.fips.models.i5;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = (Pload_dc + Pothers + Pfans_dc)/CoP;
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+		for(Device d: room.getResourceCharacteristic().getDevices()){
+			if(d.getType().getName().equals("Outlet") || d.getType().getName().equals("Inlet") )
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+
+		return Pfans_dc;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,485 @@
+package test.fips.models.i7;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+		System.out.println(Qcooling);
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/i7/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/DataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/DataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,527 @@
+package test.fips.models.i7;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class DataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		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;
+				System.out.println("1");
+			}
+			else{
+				Pcooling_device = Pchiller;	
+				System.out.println("2");
+			}
+		}
+		
+
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		//Pcooling_device = Pload_dc/CoP;
+		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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			
+			for(Device d: room.getResourceCharacteristic().getDevices()){
+				if(d.getFullName().contains("Cooling"))
+					continue;
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+			//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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/i7/RackEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/RackEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/RackEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,43 @@
+package test.fips.models.i7;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class RackEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+	
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+
+		
+		double powerConsumption = 0;
+		Rack rack = (Rack)resource;
+		for(ComputingResource nodeGroup: rack.getChildren()){
+			try{
+				powerConsumption = powerConsumption + nodeGroup.getPowerInterface().getRecentPowerUsage().getValue();
+			} catch (Exception e){
+				
+			}
+		}
+		
+		int nrOfPoweredOffNodes = 0;
+		for(Node node: rack.getNodes()){
+			if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+				nrOfPoweredOffNodes++;
+			}
+		}
+		if(nrOfPoweredOffNodes != rack.getNodes().size()){
+			powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY;			
+		}
+
+		return powerConsumption;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/FCFSBF_RandomPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/FCFSBF_RandomPlugin.java	(revision 1600)
@@ -0,0 +1,159 @@
+package test.fips.models.i7;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.events.scheduling.SchedulingEvent;
+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.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.ResourceEventType;
+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.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public FCFSBF_RandomPlugin() {
+		rand = new Random(175);
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Processor> cpus = resourceManager.getProcessors();
+		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(cpus, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+
+			break;
+
+		}	
+		return plan;
+	}
+	
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Processor> cpus, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+
+
+		
+		if (cpuRequest != 0) {
+
+
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cpus.size() && cpuRequest > 0; i++) {
+				if (cpus.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cpus.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+
+	private List<Node> filterNodes(List<Node> nodes, int cpuRequest){
+		List<Node> filteredNodes = new ArrayList<Node>();
+
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Processor> cpus = node.getProcessors();
+				if (cpus.size() < cpuRequest) {
+					if(cpus.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCpus = 0;
+				for(Processor cpu: cpus){
+					if(cpu.getStatus() == ResourceStatus.FREE)
+						freeCpus++;
+				}
+				
+				if(freeCpus < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/NodeGroupEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/NodeGroupEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/NodeGroupEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,36 @@
+package test.fips.models.i7;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.coolemall.NodeGroup;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeGroupEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		NodeGroup nodeGroup = (NodeGroup)resource;
+		for(Node node: nodeGroup.getNodes()){
+			try{
+				powerConsumption = powerConsumption + node.getPowerInterface().getRecentPowerUsage().getValue();
+
+			} catch (Exception e){
+			}
+		}
+		for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				Fan fan = (Fan) device;
+				powerConsumption = powerConsumption + fan.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+		}
+		return powerConsumption;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/FanEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/FanEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,70 @@
+package test.fips.models.i7;
+
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class FanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		Fan fan = (Fan) resource;
+		/*Node node = (Node) fan.getComputingResource();
+		double Tcpu = 0;
+		for(Processor cpu: node.getProcessors()){
+			Tcpu = Tcpu + cpu.getThermalInterface().getRecentTemperature().getValue();
+		}
+		Tcpu = Tcpu/node.getProcessors().size();
+		
+		if (Tcpu < TFanLow) {
+			powerConsumption = 4;
+		} else if (Tcpu > TFanHigh){
+			powerConsumption = PFanMax;
+		}
+		*/
+		
+		try {
+			powerConsumption = fan.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+		} catch (NoSuchFieldException e) {
+			//
+		}
+		
+		return powerConsumption;
+	}
+	
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		
+		double airflow = 0;
+		Fan fan = (Fan) resource;
+		
+		/*double fanEfficiency = 0;
+		try{
+			fanEfficiency = Double.valueOf(fan.getPowerInterface().getParameters().get("fanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+
+		double dp = 1013.25;
+		airflow = fan.getPowerInterface().getRecentPowerUsage().getValue() * fanEfficiency /dp;*/
+
+		try {
+			airflow = fan.getAirflowInterface().getAirflow(fan.getAirflowInterface().getAirflowState());
+		} catch (NoSuchFieldException e) {
+			//
+		}
+		return airflow;
+	}
+	
+	public double estimateTemperature (ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double temperature = EnvironmentConditions.ROOM_TEMPERATURE;
+		return temperature;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,60 @@
+package test.fips.models.i7;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class TangCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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 airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption =  (Pload_dc + Pothers)/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,101 @@
+package test.fips.models.i7;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = (Pload_dc + Pothers + Pfans_dc)/CoP;
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+		for(Device d: room.getResourceCharacteristic().getDevices()){
+			if(d.getType().getName().equals("Outlet") || d.getType().getName().equals("Inlet") )
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+
+		return Pfans_dc;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/FlowPumpInletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/FlowPumpInletEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/FlowPumpInletEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,143 @@
+package test.fips.models.i7;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class FlowPumpInletEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			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;
+
+			for(ComputingResource cr: room.getChildren()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) &&  Integer.valueOf(device2.getName().split("_")[1]) == Integer.valueOf(device.getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+		}
+		
+		//System.out.println("Flow Pump power: " + powerConsumption);
+		//powerConsumption = 0;
+		return powerConsumption;
+	}
+	
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		double Vair_total;
+		
+		Vair_total = ConfigurationOptions.coolingData.getAirflowVolume();
+		if(Vair_total != -1) {
+			airflow = 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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().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.getAirflowInterface().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;
+			airflow = Vair_total;
+		}
+		return airflow;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/NodeEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/NodeEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,34 @@
+package test.fips.models.i7;
+
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	private static double Pidle = 0;
+	private static double Pfull = 0;
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		Node node = (Node) resource;
+		double powerConsumption = 0;
+
+		double Pcpu = 0;	
+		for(Processor cpu: node.getProcessors()){
+			Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		powerConsumption = Pcpu + Pidle + (Pfull- Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
+		//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
+		return powerConsumption;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/FlowPumpOutletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,79 @@
+package test.fips.models.i7;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class FlowPumpOutletEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+
+		return powerConsumption;
+	}
+	
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		double Vair_total;
+		
+		Vair_total = ConfigurationOptions.coolingData.getAirflowVolume();
+		if(Vair_total != -1) {
+			airflow = 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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) || Integer.valueOf(device2.getName().split("_")[1]) == Integer.valueOf(device.getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			airflow = Vair_total;
+		}
+		return airflow;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/i7/CpuEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/i7/CpuEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/i7/CpuEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,58 @@
+package test.fips.models.i7;
+
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.tasks.phases.PhaseSystemLoad;
+import dcworms.schedframe.scheduling.ExecTask;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class CpuEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		/*double powerConsumption = 0;
+
+		Processor cpu = (Processor)resource;
+		powerConsumption = Pidle + (Pfull- Pidle) * cpu.getLoadInterface().getRecentUtilization().getValue()/100;			
+
+		return powerConsumption;*/
+		double load = 0;
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			if(load == 0){
+				powerConsumption = 18;
+			}
+			for(ExecTask task: jobRegistry.getRunningTasks()){
+				double usage = 0;
+				//double energy = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Total_Running_Energy"));
+				//double idle_energy = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Total_Idle_Energy"));
+				double av_power = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Average_Power"));
+				 powerConsumption =  powerConsumption + av_power;
+				for(PhaseSystemLoad pb: task.getExecutionProfile().getCurrentExecutionPhase().getSystemLoad()){
+					if(pb.getResouceName().equals("Usage")){
+						usage = pb.getUtilization();
+						break;
+					}
+					if(pb.getResouceName().equals("PM_Running_Energy")){
+						//energy = pb.getUtilization();
+						break;
+					}
+				}
+
+			}
+
+		}
+		
+		return powerConsumption;
+
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,60 @@
+package test.fips.models.xeon_fpga;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class TangCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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 airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption =  (Pload_dc + Pothers)/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,101 @@
+package test.fips.models.xeon_fpga;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = (Pload_dc + Pothers + Pfans_dc)/CoP;
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+		for(Device d: room.getResourceCharacteristic().getDevices()){
+			if(d.getType().getName().equals("Outlet") || d.getType().getName().equals("Inlet") )
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+
+		return Pfans_dc;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/NodeEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/NodeEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,34 @@
+package test.fips.models.xeon_fpga;
+
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	private static double Pidle = 0;
+	private static double Pfull = 0;
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		Node node = (Node) resource;
+		double powerConsumption = 0;
+
+		double Pcpu = 0;	
+		for(Processor cpu: node.getProcessors()){
+			Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		powerConsumption = Pcpu + Pidle + (Pfull - Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
+		//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
+		return powerConsumption;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/XeonFpgaEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/XeonFpgaEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/XeonFpgaEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,54 @@
+package test.fips.models.xeon_fpga;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.tasks.phases.PhaseSystemLoad;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class XeonFpgaEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		/*double powerConsumption = 0;
+
+		Processor cpu = (Processor)resource;
+		powerConsumption = Pidle + (Pfull- Pidle) * cpu.getLoadInterface().getRecentUtilization().getValue()/100;			
+
+		return powerConsumption;*/
+		double load = 0;
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			if(load == 0){
+				powerConsumption = 17;
+			}
+			for(ExecTask task: jobRegistry.getRunningTasks()){
+				double usage = 0;
+				double av_power = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Average_Power"));
+				powerConsumption =  powerConsumption + av_power;
+				for(PhaseSystemLoad pb: task.getExecutionProfile().getCurrentExecutionPhase().getSystemLoad()){
+					if(pb.getResouceName().equals("PM_Usage")){
+						usage = pb.getUtilization();
+						break;
+					}
+					if(pb.getResouceName().equals("PM_Running_Energy")){
+						break;
+					}
+				}
+
+			}
+		}
+		return powerConsumption;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,485 @@
+package test.fips.models.xeon_fpga;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+		System.out.println(Qcooling);
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/xeon_fpga/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/DataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/DataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,527 @@
+package test.fips.models.xeon_fpga;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class DataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		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;
+				System.out.println("1");
+			}
+			else{
+				Pcooling_device = Pchiller;	
+				System.out.println("2");
+			}
+		}
+		
+
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		//Pcooling_device = Pload_dc/CoP;
+		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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			
+			for(Device d: room.getResourceCharacteristic().getDevices()){
+				if(d.getFullName().contains("Cooling"))
+					continue;
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+			//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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/xeon_fpga/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/FCFSBF_RandomPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon_fpga/FCFSBF_RandomPlugin.java	(revision 1600)
@@ -0,0 +1,167 @@
+package test.fips.models.xeon_fpga;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.events.scheduling.SchedulingEvent;
+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.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.ResourceEventType;
+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.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public FCFSBF_RandomPlugin() {
+		rand = new Random(175);
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Node> nodes = resourceManager.getNodes();
+		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(nodes, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+
+			break;
+
+		}	
+		return plan;
+	}
+	
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Node> nodes, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		List<Node> filteredNodes = filterNodes(nodes, cpuRequest);
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeProcessors().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeProcessors().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor> cpus = node.getProcessors();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cpus.size() && cpuRequest > 0; i++) {
+				if (cpus.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cpus.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+
+	private List<Node> filterNodes(List<Node> nodes, int cpuRequest){
+		List<Node> filteredNodes = new ArrayList<Node>();
+
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Processor> cpus = node.getProcessors();
+				if (cpus.size() < cpuRequest) {
+					if(cpus.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCpus = 0;
+				for(Processor cpu: cpus){
+					if(cpu.getStatus() == ResourceStatus.FREE)
+						freeCpus++;
+				}
+				
+				if(freeCpus < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,485 @@
+package test.fips.models.teslaK40;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+		System.out.println(Qcooling);
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/teslaK40/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/DataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/DataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,527 @@
+package test.fips.models.teslaK40;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class DataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		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;
+				System.out.println("1");
+			}
+			else{
+				Pcooling_device = Pchiller;	
+				System.out.println("2");
+			}
+		}
+		
+
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		//Pcooling_device = Pload_dc/CoP;
+		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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			
+			for(Device d: room.getResourceCharacteristic().getDevices()){
+				if(d.getFullName().contains("Cooling"))
+					continue;
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+			//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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/teslaK40/K40EnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/K40EnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/K40EnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,57 @@
+package test.fips.models.teslaK40;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.tasks.phases.PhaseSystemLoad;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class K40EnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		/*double powerConsumption = 0;
+
+		Processor cpu = (Processor)resource;
+		powerConsumption = Pidle + (Pfull- Pidle) * cpu.getLoadInterface().getRecentUtilization().getValue()/100;			
+
+		return powerConsumption;*/
+		double load = 0;
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			if(load == 0){
+				powerConsumption = 37;
+			}
+			for(ExecTask task: jobRegistry.getRunningTasks()){
+				double usage = 0;
+				//double energy = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Total_Running_Energy"));
+				//double idle_energy = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Total_Idle_Energy"));
+				double av_power = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Average_Power"));
+				powerConsumption =  powerConsumption + av_power;
+				for(PhaseSystemLoad pb: task.getExecutionProfile().getCurrentExecutionPhase().getSystemLoad()){
+					if(pb.getResouceName().equals("PM_Usage")){
+						usage = pb.getUtilization();
+						break;
+					}
+					if(pb.getResouceName().equals("PM_Running_Energy")){
+
+						break;
+					}
+				}
+
+			}
+		}
+		return powerConsumption;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,60 @@
+package test.fips.models.teslaK40;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class TangCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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 airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption =  (Pload_dc + Pothers)/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,101 @@
+package test.fips.models.teslaK40;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = (Pload_dc + Pothers + Pfans_dc)/CoP;
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+		for(Device d: room.getResourceCharacteristic().getDevices()){
+			if(d.getType().getName().equals("Outlet") || d.getType().getName().equals("Inlet") )
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+
+		return Pfans_dc;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/NodeEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/teslaK40/NodeEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,34 @@
+package test.fips.models.teslaK40;
+
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	private static double Pidle = 20;
+	private static double Pfull = 20;
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		Node node = (Node) resource;
+		double powerConsumption = 0;
+
+		double Pcpu = 0;	
+		for(Processor cpu: node.getProcessors()){
+			Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		powerConsumption = Pcpu + Pidle + (Pfull - Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
+		//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
+		return powerConsumption;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,60 @@
+package test.fips.models.xeon;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+import test.fips.EnvironmentConditions;
+
+public class TangCoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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 airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		
+		powerConsumption =  (Pload_dc + Pothers)/CoP;
+		return powerConsumption;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/TangDataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,101 @@
+package test.fips.models.xeon;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class TangDataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		Pcooling_device = (Pload_dc + Pothers + Pfans_dc)/CoP;
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+
+		return Pdc;
+	}
+	
+	private double calculatePit(ComputingResource room){
+		double Pload_dc = 0;
+		for(ComputingResource cr: room.getChildren()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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.02;
+		}
+
+		Pothers = a * Pload_dc;
+		return Pothers;
+	}
+	
+	private double calculatePfans(ComputingResource room){
+		
+		double Pfans_dc = 0;
+		for(Device d: room.getResourceCharacteristic().getDevices()){
+			if(d.getType().getName().equals("Outlet") || d.getType().getName().equals("Inlet") )
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+
+		return Pfans_dc;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/NodeEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/NodeEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,34 @@
+package test.fips.models.xeon;
+
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	private static double Pidle = 0;
+	private static double Pfull = 0;
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		Node node = (Node) resource;
+		double powerConsumption = 0;
+
+		double Pcpu = 0;	
+		for(Processor cpu: node.getProcessors()){
+			Pcpu = Pcpu + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		powerConsumption = Pcpu + Pidle + (Pfull - Pidle) * node.getLoadInterface().getRecentUtilization().getValue()/100;
+		//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).getPowerInterface().getRecentPowerUsage().getValue();
+		return powerConsumption;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon/XeonEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/XeonEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/XeonEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,53 @@
+package test.fips.models.xeon;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.tasks.phases.PhaseSystemLoad;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class XeonEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		/*double powerConsumption = 0;
+
+		Processor cpu = (Processor)resource;
+		powerConsumption = Pidle + (Pfull- Pidle) * cpu.getLoadInterface().getRecentUtilization().getValue()/100;			
+
+		return powerConsumption;*/
+		double load = 0;
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			load = proc.getLoadInterface().getRecentUtilization().getValue();
+			if(load == 0){
+				powerConsumption = 11;
+			}
+			for(ExecTask task: jobRegistry.getRunningTasks()){
+				double usage = 0;
+				double av_power = Double.valueOf(task.getExecutionProfile().getCurrentExecutionPhase().getReferenceHardware().get("Average_Power"));
+				powerConsumption =  powerConsumption + av_power;
+				for(PhaseSystemLoad pb: task.getExecutionProfile().getCurrentExecutionPhase().getSystemLoad()){
+					if(pb.getResouceName().equals("PM_Usage")){
+						usage = pb.getUtilization();
+						break;
+					}
+					if(pb.getResouceName().equals("PM_Running_Energy")){
+						break;
+					}
+				}
+
+			}
+		}
+		return powerConsumption;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/test/fips/models/xeon/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/CoolingDeviceEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,485 @@
+package test.fips.models.xeon;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimateAirflow(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airflow = 0;
+		return airflow;
+	}
+
+	public double estimatePowerConsumption(ResourceEvent 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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		double Qdc = calculateQ(Pfans_dc, Pothers, room);
+		double Qcooling = Qdc / ncc;
+		System.out.println(Qcooling);
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/xeon/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/DataCenterEnergyEstimationPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/DataCenterEnergyEstimationPlugin.java	(revision 1600)
@@ -0,0 +1,527 @@
+package test.fips.models.xeon;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+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 example.energy.BaseEnergyEstimationPlugin;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import test.fips.EnvironmentConditions;
+
+public class DataCenterEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double Pdc;
+		
+		double Pload_dc = 0;
+		double Pothers = 0;
+		double Pfans_dc = 0;
+		double Pcooling_device = 0;
+
+		ComputingResource room = (ComputingResource) resource;
+		
+		/**************** IT PART ****************/
+		
+		/*********** Pload_dc ***********/
+		Pload_dc = calculatePit(room);
+
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		Pothers = calculatePothers(Pload_dc);
+		
+		
+		
+		/************* COOLING PART *************/
+
+		
+		/*********** Pfans_dc ***********/
+		Pfans_dc = calculatePfans(room);
+		
+		/************ Pcooling_device ************/
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		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;
+				System.out.println("1");
+			}
+			else{
+				Pcooling_device = Pchiller;	
+				System.out.println("2");
+			}
+		}
+		
+
+		double airTemp = EnvironmentConditions.ROOM_TEMPERATURE;
+		double CoP = 0.0068 * Math.pow(airTemp, 2) + 0.0008 * airTemp + 0.458;
+		//
+		//Pcooling_device = Pload_dc/CoP;
+		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()){
+			Rack rack = (Rack)cr;
+			Pload_dc = Pload_dc + rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+						if(device.getType().equals(StandardResourceType.Fan)){
+							
+							Fan fan = (Fan) device;
+							double mair_recs = 0;
+							double Vair_recs = 0;
+							
+							double Vair_recs1 = 0;
+
+							Vair_recs1  = fan.getAirflowInterface().getRecentAirflow().getValue();
+
+							double Vair_recs2 = 0;
+							for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+								if(device2.getType().equals(StandardResourceType.Fan) && device2.getFullName().equals(fan.getFullName().replace("Outlet", "Inlet"))){
+
+									Vair_recs2  = device2.getAirflowInterface().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;
+			
+			for(Device d: room.getResourceCharacteristic().getDevices()){
+				if(d.getFullName().contains("Cooling"))
+					continue;
+				Pfans_dc = Pfans_dc + d.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+			//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;
+		
+		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
+		try{
+			ncc = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCoilEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			ncc = 0.95;
+		}
+		
+		double Qcooling_rated;//DEBB
+		try{
+			Qcooling_rated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("coolingCapacityRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Qcooling_rated = 80000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+
+		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 Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.coolingData.getInletRoomAirTempeature();
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		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;
+		Qcooling_nom = Qcooling_rated * CoolT;		
+		PLR = Qcooling / Qcooling_nom;
+		
+		delta_T = Tcof - Tevf;
+		CoolPRrated = 1 / EERrated;
+		CoolPRT = 0.564064 - 0.011463 * Tevf + 0.000112 * Math.pow(Tevf, 2) + 0.008091 * Tcof + 0.000070 * Math.pow(Tcof, 2) - 0.000126 * Tevf * Tcof;
+		CoolPRPLR = 0.023918 + 0.889469 * PLR + 0.077931 * Math.pow(PLR, 2) - 0.000264 * delta_T + 0.000007 * Math.pow(delta_T, 2) + 0.000180 * PLR * delta_T;
+		CoolPR = CoolPRrated * CoolPRT * CoolPRPLR;
+		EER = 1/CoolPR;
+		
+		Pchiller = Qcooling/EER;
+
+		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()){
+			Rack rack = (Rack)cr;
+			double QnodeGroup = 0;
+			for(ComputingResource nodeGroup: rack.getChildren()){
+				double Qnodes = 0;
+				for(ComputingResource node: nodeGroup.getChildren()){
+					double Qcpu = 0;
+					Node n = (Node)node;
+					for(Processor proc: n.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.getAirflowInterface().getPowerConsumption(fan.getAirflowInterface().getAirflowState());
+						} 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: rack.getNodes()){
+				if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)){
+					nrOfPoweredOffNodes++;
+				}
+			}
+			if(nrOfPoweredOffNodes != rack.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()){
+				Rack rack = (Rack)cr;
+				for(ComputingResource nodeGroup: rack.getChildren()){
+					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.getAirflowInterface().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.getAirflowInterface().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/test/fips/models/xeon/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/fips/models/xeon/FCFSBF_RandomPlugin.java	(revision 1600)
+++ DCWoRMS/branches/coolemall/src/test/fips/models/xeon/FCFSBF_RandomPlugin.java	(revision 1600)
@@ -0,0 +1,167 @@
+package test.fips.models.xeon;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.events.scheduling.SchedulingEvent;
+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.ResourceEvent;
+import schedframe.resources.computing.profiles.energy.ResourceEventType;
+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.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public FCFSBF_RandomPlugin() {
+		rand = new Random(175);
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Node> nodes = resourceManager.getNodes();
+		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(nodes, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+
+			break;
+
+		}	
+		return plan;
+	}
+	
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Node> nodes, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		List<Node> filteredNodes = filterNodes(nodes, cpuRequest);
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeProcessors().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeProcessors().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor> cpus = node.getProcessors();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cpus.size() && cpuRequest > 0; i++) {
+				if (cpus.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cpus.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+
+	private List<Node> filterNodes(List<Node> nodes, int cpuRequest){
+		List<Node> filteredNodes = new ArrayList<Node>();
+
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Processor> cpus = node.getProcessors();
+				if (cpus.size() < cpuRequest) {
+					if(cpus.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCpus = 0;
+				for(Processor cpu: cpus){
+					if(cpu.getStatus() == ResourceStatus.FREE)
+						freeCpus++;
+				}
+				
+				if(freeCpus < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
