Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngDynamicFuture.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngDynamicFuture.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngDynamicFuture.java	(revision 1593)
@@ -0,0 +1,380 @@
+package experiments.e2dc2015.models.i5;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.computing.profiles.energy.airthroughput.CustomAirflowStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.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 experiments.e2dc2015.EnvironmentConditions;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPluginFansMngDynamicFuture extends BaseLocalSchedulingPlugin {
+
+
+	private Random rand;
+	
+	public FCFSBF_RandomPluginFansMngDynamicFuture() {
+		rand = new Random(5);
+	}
+
+	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 TIMER:
+
+			System.out.println("##" + Sim_system.clock());
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(StandardResourceType.Processor, 0.0, new ResourceEvent(ResourceEventType.TIMER, null));
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(EnvironmentConditions.SYSTEM_UDPATE_INTERVAL, DCWormsTags.TIMER, "Test");
+			break;
+			
+		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;
+		case RESOURCE_TEMPERATURE_LIMIT_EXCEEDED:
+			manageFans(resourceManager.getResourceByName(event.getSource()));
+			break;
+
+		}	
+
+		return plan;
+	}
+	
+	private void manageFans(ComputingResource cr ){
+		//System.out.println("tuning fans");
+		double temp = cr.getThermalInterface().getRecentTemperature().getValue();
+		double prevTemp;
+			
+		double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
+		double Pcpu = cr.getPowerInterface().getRecentPowerUsage().getValue();
+		
+		
+		
+		/*************/
+		
+		double R = 0;
+		double Rb = 0;
+		double Rcv = 0;
+		try{
+			Rb = Double.valueOf(cr.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double k = 0;
+		try{
+			k = Double.valueOf(cr.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double a = 0;
+		try{
+			a = Double.valueOf(cr.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			a = 1;
+		}
+
+		double V = 0;
+	
+		//System.out.println("------ " + cr.getFullName());
+		for(Device device: cr.getParent().getParent().getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue();
+				int nodeId = Integer.valueOf(cr.getParent().getName().split("_")[1]).intValue();
+				//System.out.println(device.getName() + "; " + cpu.getParent().getName());
+				//System.out.println(fanId + "; " + cpuId);
+				if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN /*|| Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW*/){
+					//System.out.println("********");
+					Fan fan = (Fan) device;
+					V = fan.getAirflowInterface().getRecentAirflow().getValue();
+					break;
+				}
+			}
+		}
+		//System.out.println("V: " + V);
+		Rcv =  1/ (k * Math.pow(V, a));
+		R = Rb + Rcv; 
+		double C = 0;
+		try{
+			C = Double.valueOf(cr.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		
+		
+		double objective_temperature =  Pcpu * R + Tin; 
+		
+		
+		
+		
+		double delta_t = 15;
+		
+		/*************/
+		
+		double nextTemp = objective_temperature - (objective_temperature - temp) * Math.exp(-delta_t/(R * C));
+		
+		if(cr.getThermalInterface().getTemperatureHistory().size() == 1)
+			prevTemp = temp;
+		else {
+			prevTemp = cr.getThermalInterface().getTemperatureHistory().get(cr.getThermalInterface().getTemperatureHistory().size() - 2).getValue();
+		}
+		//System.out.println(Sim_system.clock() + "; " + prevTemp +": " +temp + ": " + objective_temperature + ": " + nextTemp+"; " + Pcpu);
+
+		//System.out.println(Sim_system.clock() + " === " + prevTemp+  ";  " + temp);
+		boolean getingHotter = prevTemp < temp;
+		boolean getingColder = prevTemp > temp;
+		Node n = (Node) cr.getParent();
+		List<ComputingResource> neighbours = n.getParent().getChildren();
+		for(Device d: n.getParent().getResourceCharacteristic().getDevices()){
+			//System.out.println(d.getName() + "; " + n.getName());
+			int fanId = Integer.valueOf(d.getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN /*|| Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW*/){
+				Fan f = (Fan) d;
+				int speed;
+				try{
+					speed= Integer.valueOf(f.getAirflowInterface().getAirflowState().getLabel().split("_")[1]).intValue();
+				} catch(Exception e){
+					speed = 0;
+				}
+				for(ComputingResource neighbour: neighbours){
+					int neighbourId = Integer.valueOf(neighbour.getName().split("_")[1]).intValue();
+					if(neighbourId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && neighbourId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN){
+						double neighbourTemp = neighbour.getChildren().get(0).getThermalInterface().getRecentTemperature().getValue();
+						if(neighbourTemp > temp){
+							return;
+						}
+					}
+				}
+				
+				//System.out.println("getingHotter: "+ (prevTemp < temp));
+				if(getingHotter){
+					if(nextTemp > temp)
+					temp = nextTemp;
+					if(temp > EnvironmentConditions._30_2_40- EnvironmentConditions.tempShift && temp < EnvironmentConditions._40_2_50- EnvironmentConditions.tempShift ){
+						if(speed < 40){
+							//System.out.println("+++++++++ 30 to 40");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_40"));
+						}
+					} else if(temp > EnvironmentConditions._40_2_50- EnvironmentConditions.tempShift && temp < EnvironmentConditions._50_2_60- EnvironmentConditions.tempShift ){
+						if(speed < 50){
+							//System.out.println("++++++++ 40 to 50");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_50"));
+						}
+					} else if(temp > EnvironmentConditions._50_2_60- EnvironmentConditions.tempShift && temp < EnvironmentConditions._60_2_70- EnvironmentConditions.tempShift ){
+						if(speed < 60){
+						//System.out.println("++++++++ 50 to 60");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_60"));
+						}
+					} else if(temp > EnvironmentConditions._60_2_70- EnvironmentConditions.tempShift && temp < EnvironmentConditions._70_2_80- EnvironmentConditions.tempShift ){
+						if(speed < 70){
+							//System.out.println("++++++++ 60 to 70");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_70"));
+						}
+					} else if(temp > EnvironmentConditions._70_2_80- EnvironmentConditions.tempShift && temp < EnvironmentConditions._80_2_90- EnvironmentConditions.tempShift ){
+						if(speed < 80){
+							//System.out.println("++++++++ 70 to 80");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_80"));
+						}
+					} else if(temp > EnvironmentConditions._80_2_90- EnvironmentConditions.tempShift && temp < EnvironmentConditions._90_2_100- EnvironmentConditions.tempShift ){
+						if(speed < 90){
+							//System.out.println("++++++++ 80 to 90");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_90"));
+						}
+					} else if(temp > EnvironmentConditions._90_2_100- EnvironmentConditions.tempShift ){
+						if(speed < 100){
+							//System.out.println("++++++++ 90 to 100");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_100"));
+						}
+					}						
+				} else if (getingColder){
+					if(temp > EnvironmentConditions._90_2_80 && temp < EnvironmentConditions._100_2_90){
+						if(speed == 100){
+							//System.out.println("-------- 100 to 90");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_90"));
+						}
+					} else if(temp > EnvironmentConditions._80_2_70 && temp < EnvironmentConditions._90_2_80){
+						if(speed >= 90){
+							//System.out.println("-------- 90 to 80");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_80"));		
+						}
+					} else if(temp > EnvironmentConditions._70_2_60 && temp < EnvironmentConditions._80_2_70){
+						if(speed >= 80){
+							//System.out.println("-------- 80 to 70");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_70"));		
+						}
+					} else if(temp > EnvironmentConditions._60_2_50 && temp < EnvironmentConditions._70_2_60){
+						if(speed >= 70){
+							//System.out.println("-------- 70 to 60");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_60"));		
+						}
+					} else if(temp > EnvironmentConditions._50_2_40 && temp < EnvironmentConditions._60_2_50){
+						if(speed >= 60){
+							//System.out.println("-------- 60 to 50");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_50"));		
+						}
+					} else if(temp > EnvironmentConditions._40_2_30 && temp < EnvironmentConditions._50_2_40){
+						if(speed >= 50){
+							//System.out.println("-------- 60 to 40");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_40"));		
+						}
+					}  else if (temp < EnvironmentConditions._40_2_30) {
+						if(speed >= 40){
+							//System.out.println("-------- 40 to 30");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_30"));	
+						}
+					}
+				}
+			}
+		}
+	}
+	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, task);
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeCores().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeCores().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor>  processors = node.getProcessors();
+			List<Core> cores = node.getCores();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngDynamic.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngDynamic.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngDynamic.java	(revision 1593)
@@ -0,0 +1,305 @@
+package experiments.e2dc2015.models.i5;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.computing.profiles.energy.airthroughput.CustomAirflowStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.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 experiments.e2dc2015.EnvironmentConditions;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPluginFansMngDynamic extends BaseLocalSchedulingPlugin {
+
+
+	private Random rand;
+	
+	public FCFSBF_RandomPluginFansMngDynamic() {
+		rand = new Random(5);
+	}
+
+	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 TIMER:
+
+			System.out.println("##" + Sim_system.clock());
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(StandardResourceType.Processor, 0.0, new ResourceEvent(ResourceEventType.TIMER, null));
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(EnvironmentConditions.SYSTEM_UDPATE_INTERVAL, DCWormsTags.TIMER, "Test");
+			break;
+			
+		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;
+		case RESOURCE_TEMPERATURE_LIMIT_EXCEEDED:
+			manageFans(resourceManager.getResourceByName(event.getSource()));
+			break;
+
+		}	
+
+		return plan;
+	}
+	
+	private void manageFans(ComputingResource cr ){
+		//System.out.println("tuning fans");
+		double temp = cr.getThermalInterface().getRecentTemperature().getValue();
+		double prevTemp;
+		if(cr.getThermalInterface().getTemperatureHistory().size() == 1)
+			prevTemp = temp;
+		else {
+			prevTemp = cr.getThermalInterface().getTemperatureHistory().get(cr.getThermalInterface().getTemperatureHistory().size() - 2).getValue();
+		}
+
+		//System.out.println(Sim_system.clock() + " === " + prevTemp+  ";  " + temp);
+		boolean getingHotter = prevTemp < temp;
+		boolean getingColder = prevTemp > temp;
+		Node n = (Node) cr.getParent();
+		List<ComputingResource> neighbours = n.getParent().getChildren();
+		for(Device d: n.getParent().getResourceCharacteristic().getDevices()){
+			//System.out.println(d.getName() + "; " + n.getName());
+			int fanId = Integer.valueOf(d.getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN /*|| Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW*/){
+				Fan f = (Fan) d;
+				int speed;
+				try{
+					speed= Integer.valueOf(f.getAirflowInterface().getAirflowState().getLabel().split("_")[1]).intValue();
+				} catch(Exception e){
+					speed = 0;
+				}
+				for(ComputingResource neighbour: neighbours){
+					int neighbourId = Integer.valueOf(neighbour.getName().split("_")[1]).intValue();
+					if(neighbourId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && neighbourId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN){
+						double neighbourTemp = neighbour.getChildren().get(0).getThermalInterface().getRecentTemperature().getValue();
+						if(neighbourTemp > temp){
+							return;
+						}
+					}
+				}
+				//System.out.println("getingHotter: "+ (prevTemp < temp));
+				if(getingHotter){
+					if(temp > EnvironmentConditions._30_2_40- EnvironmentConditions.tempShift && temp < EnvironmentConditions._40_2_50- EnvironmentConditions.tempShift ){
+						if(speed < 40){
+							//System.out.println("+++++++++ 30 to 40");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_40"));
+						}
+					} else if(temp > EnvironmentConditions._40_2_50- EnvironmentConditions.tempShift && temp < EnvironmentConditions._50_2_60- EnvironmentConditions.tempShift ){
+						if(speed < 50){
+							//System.out.println("++++++++ 40 to 50");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_50"));
+						}
+					} else if(temp > EnvironmentConditions._50_2_60- EnvironmentConditions.tempShift && temp < EnvironmentConditions._60_2_70- EnvironmentConditions.tempShift ){
+						if(speed < 60){
+							//System.out.println("++++++++ 50 to 60");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_60"));
+						}
+					} else if(temp > EnvironmentConditions._60_2_70- EnvironmentConditions.tempShift && temp < EnvironmentConditions._70_2_80- EnvironmentConditions.tempShift ){
+						if(speed < 70){
+							//System.out.println("++++++++ 60 to 70");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_70"));
+						}
+					} else if(temp > EnvironmentConditions._70_2_80- EnvironmentConditions.tempShift && temp < EnvironmentConditions._80_2_90- EnvironmentConditions.tempShift ){
+						if(speed < 80){
+							//System.out.println("++++++++ 70 to 80");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_80"));
+						}
+					} else if(temp > EnvironmentConditions._80_2_90- EnvironmentConditions.tempShift && temp < EnvironmentConditions._90_2_100- EnvironmentConditions.tempShift ){
+						if(speed < 90){
+							//System.out.println("++++++++ 80 to 90");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_90"));
+						}
+					} else if(temp > EnvironmentConditions._90_2_100- EnvironmentConditions.tempShift ){
+						if(speed < 100){
+							//System.out.println("++++++++ 90 to 100");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_100"));
+						}
+					}						
+				} else if (getingColder){
+					if(temp > EnvironmentConditions._90_2_80 && temp < EnvironmentConditions._100_2_90){
+						if(speed == 100){
+							//System.out.println("-------- 100 to 90");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_90"));
+						}
+					} else if(temp > EnvironmentConditions._80_2_70 && temp < EnvironmentConditions._90_2_80){
+						if(speed >= 90){
+							//System.out.println("-------- 90 to 80");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_80"));		
+						}
+					} else if(temp > EnvironmentConditions._70_2_60 && temp < EnvironmentConditions._80_2_70){
+						if(speed >= 80){
+							//System.out.println("-------- 80 to 70");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_70"));		
+						}
+					} else if(temp > EnvironmentConditions._60_2_50 && temp < EnvironmentConditions._70_2_60){
+						if(speed >= 70){
+							//System.out.println("-------- 70 to 60");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_60"));		
+						}
+					} else if(temp > EnvironmentConditions._50_2_40 && temp < EnvironmentConditions._60_2_50){
+						if(speed >= 60){
+							//System.out.println("-------- 60 to 50");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_50"));		
+						}
+					} else if(temp > EnvironmentConditions._40_2_30 && temp < EnvironmentConditions._50_2_40){
+						if(speed >= 50){
+							//System.out.println("-------- 60 to 40");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_40"));		
+						}
+					}  else if (temp < EnvironmentConditions._40_2_30) {
+						if(speed >= 40){
+							//System.out.println("-------- 40 to 30");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_30"));	
+						}
+					}
+				}
+			}
+		}
+	}
+	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, task);
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeCores().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeCores().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor>  processors = node.getProcessors();
+			List<Core> cores = node.getCores();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/NodeGroupEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/NodeGroupEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/NodeGroupEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,37 @@
+package experiments.e2dc2015.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();
+				powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).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/experiments/e2dc2015/models/i5/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FanEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FanEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,70 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngStatic.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngStatic.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPluginFansMngStatic.java	(revision 1593)
@@ -0,0 +1,255 @@
+package experiments.e2dc2015.models.i5;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.computing.profiles.energy.airthroughput.CustomAirflowStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.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 experiments.e2dc2015.EnvironmentConditions;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPluginFansMngStatic extends BaseLocalSchedulingPlugin {
+
+
+	private Random rand;
+	
+	public FCFSBF_RandomPluginFansMngStatic() {
+		rand = new Random(5);
+	}
+
+	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 TIMER:
+
+			System.out.println("##" + Sim_system.clock());
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(StandardResourceType.Processor, 0.0, new ResourceEvent(ResourceEventType.TIMER, null));
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(EnvironmentConditions.SYSTEM_UDPATE_INTERVAL, DCWormsTags.TIMER, "Test");
+			break;
+			
+		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;
+		case RESOURCE_TEMPERATURE_LIMIT_EXCEEDED:
+			manageFans(resourceManager.getResourceByName(event.getSource()));
+			break;
+
+		}	
+
+		return plan;
+	}
+	
+	private void manageFans(ComputingResource cr ){
+		//System.out.println("tuning fans");
+		double temp = cr.getThermalInterface().getRecentTemperature().getValue();
+		double prevTemp;
+		if(cr.getThermalInterface().getTemperatureHistory().size() == 1)
+			prevTemp = temp;
+		else {
+			prevTemp = cr.getThermalInterface().getTemperatureHistory().get(cr.getThermalInterface().getTemperatureHistory().size() - 2).getValue();
+		}
+
+		//System.out.println(Sim_system.clock() + " === " + prevTemp+  ";  " + temp);
+		boolean getingHotter = prevTemp < temp;
+		boolean getingColder = prevTemp > temp;
+		Node n = (Node) cr.getParent();
+		List<ComputingResource> neighbours = n.getParent().getChildren();
+		for(Device d: n.getParent().getResourceCharacteristic().getDevices()){
+			//System.out.println(d.getName() + "; " + n.getName());
+			int fanId = Integer.valueOf(d.getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN /*|| Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW*/){
+				Fan f = (Fan) d;
+				int speed;
+				try{
+					speed= Integer.valueOf(f.getAirflowInterface().getAirflowState().getLabel().split("_")[1]).intValue();
+				} catch(Exception e){
+					speed = 0;
+				}
+				for(ComputingResource neighbour: neighbours){
+					int neighbourId = Integer.valueOf(neighbour.getName().split("_")[1]).intValue();
+					if(neighbourId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && neighbourId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN){
+						double neighbourTemp = neighbour.getChildren().get(0).getThermalInterface().getRecentTemperature().getValue();
+						if(neighbourTemp > temp){
+							return;
+						}
+					}
+				}
+				//System.out.println("getingHotter: "+ (prevTemp < temp));
+				if(getingHotter){
+					if(temp > EnvironmentConditions._30_2_70 - EnvironmentConditions.tempShift && temp < EnvironmentConditions._70_2_100- EnvironmentConditions.tempShift ){
+						if(speed < 70){
+							//System.out.println("+++++++++ low 2 medium");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_70"));
+						}
+					} else if (temp > EnvironmentConditions._70_2_100- EnvironmentConditions.tempShift ) {
+						if(speed < 100){
+							//System.out.println("++++++++high 2 high");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_100"));
+						}
+					}					
+				} else if (getingColder){
+					if(temp > EnvironmentConditions._70_2_30 && temp < EnvironmentConditions._100_2_70){
+						if(speed == 100){
+							//System.out.println("-------- max 2 high");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_70"));
+						}
+					} else if (temp < EnvironmentConditions._70_2_30) {
+						if(speed >= 70){
+							//System.out.println("-------- medium 2 low");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_30"));	
+						}
+					}
+				}
+			}
+		}
+	}
+	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, task);
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeCores().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeCores().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor>  processors = node.getProcessors();
+			List<Core> cores = node.getCores();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FlowPumpInletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FlowPumpInletEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FlowPumpInletEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,143 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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.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;
+			airflow = Vair_total;
+		}
+		return airflow;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FlowPumpOutletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,79 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/PowerLeakageEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/PowerLeakageEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/PowerLeakageEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,33 @@
+package experiments.e2dc2015.models.i5;
+
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+import experiments.e2dc2015.EnvironmentConditions;
+
+public class PowerLeakageEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+
+		double powerLekage = 0;
+		Device pl = (Device) resource;
+		double tempDiff = pl.getComputingResource().getThermalInterface().getRecentTemperature().getValue() - EnvironmentConditions.i5_baseLeakageTemp;
+		if(tempDiff < 0)
+			return 0;
+		if(pl.getComputingResource().getThermalInterface().getRecentTemperature().getValue() > 90){
+			powerLekage = 0.3 * tempDiff;
+		} else
+			powerLekage = EnvironmentConditions.i5_leakageFactor * tempDiff;
+		//powerConsumption = factor * pl.getComputingResource().getPowerInterface().getRecentPowerUsage().getValue();
+		/*Device pl = (Device) resource;
+		if(pl.getComputingResource().getThermalInterface().getRecentTemperature().getValue() > 90){
+			powerConsumption = powerConsumption + 15;
+		}*/
+		return powerLekage;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/CoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/CoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,485 @@
+package experiments.e2dc2015.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/experiments/e2dc2015/models/i5/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/DataCenterEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/DataCenterEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,523 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/RackEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/RackEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/RackEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,49 @@
+package experiments.e2dc2015.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){
+				
+			}
+		}
+		
+		for(Node node: rack.getNodes()){
+			if(node.getProcessors().get(0).getThermalInterface().getRecentTemperature().getValue() > 90){
+				//powerConsumption = powerConsumption + 15;
+			}
+		}
+		
+		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/experiments/e2dc2015/models/i5/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/FCFSBF_RandomPlugin.java	(revision 1593)
@@ -0,0 +1,174 @@
+package experiments.e2dc2015.models.i5;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.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 TIMER:
+			if(Sim_system.clock() > 4){
+				int a =3;
+			}
+			System.out.println("##########################" + Sim_system.clock());
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(StandardResourceType.Processor, 0.0, new ResourceEvent(ResourceEventType.TIMER, null));
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(EnvironmentConditions.SYSTEM_UDPATE_INTERVAL, DCWormsTags.TIMER, "Test");
+			break;
+			
+		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.getFreeCores().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeCores().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Core> cores = node.getCores();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			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<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangCoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,60 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/TangDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangDataCenterEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangDataCenterEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,101 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/NodeEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/NodeEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,137 @@
+package experiments.e2dc2015.models.i5;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+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 eduni.simjava.Sim_system;
+import example.energy.BaseEnergyEstimationPlugin;
+import experiments.e2dc2015.EnvironmentConditions;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	private double timestamp = 0;
+	private double old_temperature = EnvironmentConditions.i5_nodeTidle;
+	private double new_temperature = -1;
+	private double objective_temperature = EnvironmentConditions.i5_nodeTidle;
+
+	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;
+	}
+
+	@Override
+	public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+
+		Node node = (Node) resource;
+		Processor cpu = node.getProcessors().get(0);
+		double Pserv = 0;
+
+		double R = 0;
+		double Rb = 0;
+		double Rcv = 0;
+		try{
+			Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double k = 0;
+		try{
+			k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double a = 0;
+		try{
+			a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			a = 1;
+		}
+
+
+		double C = 0;
+		try{
+			C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double V = 0;
+		double Pfan = 0;
+		for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue();
+				int nodeId = Integer.valueOf(node.getName().split("_")[1]).intValue();
+				if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN){
+					Fan fan = (Fan) device;
+					V = fan.getAirflowInterface().getRecentAirflow().getValue();
+					Pfan =  fan.getPowerInterface().getRecentPowerUsage().getValue();
+					break;
+				}
+			}
+		}
+
+		Rcv =  1/ (k * Math.pow(V, a));
+		R = Rb + Rcv; 
+		
+		double K = 0;
+		double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY;
+		double ro = EnvironmentConditions.AIR_DENSITY;
+
+		K = V * Cair * ro;
+		//System.out.println("-------K: " + K +  "; V:" + V);
+
+		double delta_t = Sim_system.clock() - timestamp;
+
+		double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
+		Pserv = node.getPowerInterface().getRecentPowerUsage().getValue();
+		Pserv = Pserv + Pfan;
+		
+		NodeGroup ng = (NodeGroup) node.getParent();
+		for(Node n: ng.getNodes()){
+			int cpuNodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			if(nodeId - cpuNodeId == 1 && (cpuNodeId - 1)/3 == (nodeId - 1)/3){
+				if(n.getThermalInterface().getRecentTemperature().getValue() == 0){
+					Tin = EnvironmentConditions.i5_nodeTidle;
+				} else
+					Tin = n.getThermalInterface().getRecentTemperature().getValue();
+				//System.out.println("======" + cpu.getFullName() + " previous node: " + n.getFullName() + "; " + Tin);
+				break;
+			}
+		}
+		
+		double targetTemp = Pserv/K + Tin; 
+		objective_temperature = targetTemp;
+
+		new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C));
+
+		// 5) save everything
+		timestamp = Sim_system.clock();
+		old_temperature = new_temperature;
+		//System.out.println(node.getFullName() + "; node temp:" + new_temperature + "; "+ objective_temperature );
+		return new_temperature;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangHeatDataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangHeatDataCenterEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangHeatDataCenterEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,158 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/TangHeatCoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangHeatCoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/TangHeatCoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,115 @@
+package experiments.e2dc2015.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 experiments.e2dc2015.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/experiments/e2dc2015/models/i5/CpuEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/CpuEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/i5/CpuEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,295 @@
+package experiments.e2dc2015.models.i5;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.NodeGroup;
+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.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.energy.BaseEnergyEstimationPlugin;
+import experiments.e2dc2015.EnvironmentConditions;
+import gridsim.dcworms.DCWormsTags;
+
+public class CpuEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	
+	private double timestamp = 0;
+	private double old_temperature = EnvironmentConditions.i5_cpuTidle;
+	private double new_temperature = -1;
+	private double objective_temperature = EnvironmentConditions.i5_cpuTidle;
+	
+	private boolean fan = false;
+	
+	private double next_timer = -1;    
+	
+	private int cpu_temp_monitor = 0;
+	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;
+	}
+	
+	@Override
+	public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double future = -1;
+
+		Processor cpu = (Processor) resource;
+
+		double R = 0;
+		double Rb = 0;
+		double Rcv = 0;
+		try{
+			Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double k = 0;
+		try{
+			k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double a = 0;
+		try{
+			a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			a = 1;
+		}
+
+		double V = 0;
+	
+		//System.out.println("------ " + cpu.getFullName());
+		for(Device device: cpu.getParent().getParent().getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue();
+				int nodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue();
+				//System.out.println(device.getName() + "; " + cpu.getParent().getName());
+				//System.out.println(fanId + "; " + cpuId);
+				if(nodeId > (fanId - 1) * EnvironmentConditions.NODES_IN_A_COLUMN && nodeId <= fanId * EnvironmentConditions.NODES_IN_A_COLUMN /*|| Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW*/){
+					//System.out.println("********");
+					Fan fan = (Fan) device;
+					V = fan.getAirflowInterface().getRecentAirflow().getValue();
+					break;
+				}
+			}
+		}
+		//System.out.println("V: " + V);
+		Rcv =  1/ (k * Math.pow(V, a));
+		R = Rb + Rcv; 
+		double C = 0;
+		try{
+			C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		// 1) look where we are
+		double delta_t = Sim_system.clock() - timestamp;
+		/***************model1*************/
+		//new_temperature = objective_temperature - (objective_temperature - old_temperature) * Math.exp(-delta_t/sink);
+		
+		/***************model2*************/
+		//new_temperature = objective_temperature - (objective_temperature - old_temperature) * Math.exp(-delta_t/(R * C));
+		 
+
+		// 2) calculate if fan is needed ?
+		if(new_temperature <= EnvironmentConditions.TFanLow) {
+			fan = false;
+		}
+		if(new_temperature >= EnvironmentConditions.TFanHigh) {
+			fan = true; 
+		}
+		
+		// 3) compute new objective
+		double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
+		double Pcpu = cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		new_temperature = objective_temperature - (objective_temperature - old_temperature) * Math.exp(-delta_t/(R * C));
+		//new_temperature = (Pcpu * R + Tin) - (Pcpu * R + Tin - Tidle) * Math.exp(-Sim_system.clock()/(R * C));;
+		
+		//System.out.println("getting inlet...: ");
+		NodeGroup ng = (NodeGroup) cpu.getParent().getParent();
+		for(Node n: ng.getNodes()){
+			int cpuNodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			//System.out.println(cpuNodeId + "; " + nodeId);
+			if(nodeId - cpuNodeId == 1 && (cpuNodeId - 1)/3 == (nodeId - 1)/3){
+				if(n.getThermalInterface().getRecentTemperature().getValue() == 0){
+					Tin = EnvironmentConditions.i5_nodeTidle;
+				} else
+					Tin = n.getThermalInterface().getRecentTemperature().getValue();
+				//System.out.println("======" + cpu.getFullName() + " previous node: " + n.getFullName() + "; " + Tin);
+				break;
+			}
+		}
+		if(cpu.getThermalInterface().getRecentTemperature().getValue() == 0)
+			Tin = (2 * Tin + EnvironmentConditions.i5_cpuTidle)/3;
+		else
+			Tin = (2 * Tin + cpu.getThermalInterface().getRecentTemperature().getValue())/3;
+		/***************model1 - GEO1*************/
+		//double cpuLoad = cpu.getLoadInterface().getRecentUtilization().getValue();
+		//double targetTemp = Tidle + cpuLoad/100 * dTfull;
+		//if(fan) {
+		//	targetTemp = targetTemp - dTfan;
+		//}
+		
+		
+		/***************model2 - GEO2*************/
+		//Node node = (Node) cpu.getParent();
+		//Pserv = node.getPowerInterface().getRecentPowerUsage().getValue();
+		//double targetTemp = Pcpu * R + Tin; 
+		
+		/***************model3 - GEO1 + GEO2*************/
+		/*double targetTemp = Pcpu * R + Tin; 
+		if(fan) {
+			targetTemp = targetTemp - dTfan;
+		}*/
+	
+		/***************model4 - WP*************/
+		double targetTemp = Pcpu * R + Tin; 
+		//System.out.println("----------" + targetTemp +  ": " +  Pcpu +  ": " +  R +  ": " +  Tin);
+		// 4) check if we will need to tune fans
+		if(fan && targetTemp < EnvironmentConditions.TFanLow) {
+			double timer = C * R * Math.log((new_temperature - targetTemp)/(targetTemp - EnvironmentConditions.TFanLow));
+			if(future == -1 || future > timer) {
+				future = timer;
+			}
+		}
+		if(!fan && targetTemp > EnvironmentConditions.TFanHigh) {
+			double timer = C * R * Math.log((new_temperature - targetTemp)/(targetTemp - EnvironmentConditions.TFanHigh));
+			if(future == -1 || future > timer) {
+				future = timer;
+			}
+		}
+
+		// 5) save everything
+		timestamp = Sim_system.clock();
+		old_temperature = new_temperature;
+		objective_temperature = targetTemp;
+
+
+		if((future >= 0) && ((next_timer < Sim_system.clock()) || (next_timer >= future + Sim_system.clock()))) {
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(future, DCWormsTags.FANMGT, "Test");
+			next_timer = future + Sim_system.clock() - 0.01;
+		}		
+		
+		if(Sim_system.clock() == 0)
+			return new_temperature;
+		//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+		/*if(new_temperature < EnvironmentConditions.tempLevelMedium2Low){
+			if(cpu_temp_monitor != 1){
+				cpu_temp_monitor = 1;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelMedium2Low && new_temperature < EnvironmentConditions.tempLevelLow2Medium - EnvironmentConditions.tempShift ){
+			if(cpu_temp_monitor != 2){
+				cpu_temp_monitor = 2;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelLow2Medium - EnvironmentConditions.tempShift && new_temperature < EnvironmentConditions.tempLevelHigh2Medium){
+			if(cpu_temp_monitor != 3){
+				cpu_temp_monitor = 3;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelHigh2Medium && new_temperature < EnvironmentConditions.tempLevelMedium2High - EnvironmentConditions.tempShift ){
+			if(cpu_temp_monitor != 4){
+				cpu_temp_monitor = 4;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelMedium2High - EnvironmentConditions.tempShift  && new_temperature < EnvironmentConditions.tempLevelMax2High){
+			if(cpu_temp_monitor != 5){
+				cpu_temp_monitor = 5;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelMax2High && new_temperature < EnvironmentConditions.tempLevelHigh2Max - EnvironmentConditions.tempShift ){
+			if(cpu_temp_monitor != 6){
+				cpu_temp_monitor = 6;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelHigh2Max - EnvironmentConditions.tempShift ){
+			if(cpu_temp_monitor != 7){
+				cpu_temp_monitor = 7;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		}*/
+		DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+		//System.out.println("cpu temp:" + new_temperature);
+		return new_temperature;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FanEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FanEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,70 @@
+package experiments.e2dc2015.models.arm;
+
+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 experiments.e2dc2015.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/experiments/e2dc2015/models/arm/FlowPumpInletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FlowPumpInletEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FlowPumpInletEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,143 @@
+package experiments.e2dc2015.models.arm;
+
+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 experiments.e2dc2015.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);
+		
+		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.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;
+			airflow = Vair_total;
+		}
+		return airflow;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/NodeEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/NodeEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,137 @@
+package experiments.e2dc2015.models.arm;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+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 eduni.simjava.Sim_system;
+import example.energy.BaseEnergyEstimationPlugin;
+import experiments.e2dc2015.EnvironmentConditions;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	private double timestamp = 0;
+	private double old_temperature = EnvironmentConditions.arm_nodeTidle;
+	private double new_temperature = -1;
+	private double objective_temperature = EnvironmentConditions.arm_nodeTidle;
+
+	private static double Pidle = 2;
+	private static double Pfull = 3;
+
+
+	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;
+	}
+
+	@Override
+	public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+
+		Node node = (Node) resource;
+		Processor cpu = node.getProcessors().get(0);
+		double Pserv = 0;
+
+		double R = 0;
+		double Rb = 0;
+		double Rcv = 0;
+		try{
+			Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double k = 0;
+		try{
+			k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double a = 0;
+		try{
+			a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			a = 1;
+		}
+
+
+		double C = 0;
+		try{
+			C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double V = 0;
+		double Pfan = 0;
+		for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue();
+				int nodeId = Integer.valueOf(node.getName().split("_")[1]).intValue();
+				if(nodeId == fanId){
+					Fan fan = (Fan) device;
+					V = fan.getAirflowInterface().getRecentAirflow().getValue();
+					Pfan =  fan.getPowerInterface().getRecentPowerUsage().getValue();
+					break;
+				}
+			}
+		}
+
+		Rcv =  1/ (k * Math.pow(V, a));
+		R = Rb + Rcv; 
+		
+		double K = 0;
+		double Cair = EnvironmentConditions.AIR_HEAT_CAPACITY;
+		double ro = EnvironmentConditions.AIR_DENSITY;
+
+		K = V * Cair * ro;
+		//System.out.println("-------K: " + K +  "; V:" + V);
+
+		double delta_t = Sim_system.clock() - timestamp;
+
+		double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
+		Pserv = node.getPowerInterface().getRecentPowerUsage().getValue();
+		Pserv = Pserv + Pfan;
+		
+		NodeGroup ng = (NodeGroup) node.getParent();
+		for(Node n: ng.getNodes()){
+			int cpuNodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			if(nodeId - cpuNodeId == 9){
+				if(n.getThermalInterface().getRecentTemperature().getValue() == 0){
+					Tin = EnvironmentConditions.arm_nodeTidle;
+				} else
+					Tin = n.getThermalInterface().getRecentTemperature().getValue();
+				//System.out.println("======" + cpu.getFullName() + " previous node: " + n.getFullName() + "; " + Tin);
+				break;
+			}
+		}
+		
+		double targetTemp = Pserv/K + Tin; 
+		objective_temperature = targetTemp;
+
+		new_temperature = objective_temperature + (old_temperature - objective_temperature) * Math.exp(-delta_t / (R * C));
+
+		// 5) save everything
+		timestamp = Sim_system.clock();
+		old_temperature = new_temperature;
+
+		return new_temperature;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FlowPumpOutletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,79 @@
+package experiments.e2dc2015.models.arm;
+
+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 experiments.e2dc2015.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/experiments/e2dc2015/models/arm/PowerLeakageEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/PowerLeakageEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/PowerLeakageEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,30 @@
+package experiments.e2dc2015.models.arm;
+
+import schedframe.resources.computing.profiles.energy.ResourceEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+import experiments.e2dc2015.EnvironmentConditions;
+
+public class PowerLeakageEnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	public double estimatePowerConsumption(ResourceEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+
+		double powerLekage = 0;
+		Device pl = (Device) resource;
+		double tempDiff = pl.getComputingResource().getThermalInterface().getRecentTemperature().getValue() - EnvironmentConditions.arm_baseLeakageTemp;
+		if(tempDiff < 0)
+			return 0;
+		powerLekage = EnvironmentConditions.arm_leakageFactor * tempDiff;
+		//powerConsumption = factor * pl.getComputingResource().getPowerInterface().getRecentPowerUsage().getValue();
+		/*Device pl = (Device) resource;
+		if(pl.getComputingResource().getThermalInterface().getRecentTemperature().getValue() > 90){
+			powerConsumption = powerConsumption + 15;
+		}*/
+		return powerLekage;
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/CpuEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/CpuEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/CpuEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,293 @@
+package experiments.e2dc2015.models.arm;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.NodeGroup;
+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.DataCenterWorkloadSimulator;
+import eduni.simjava.Sim_system;
+import example.energy.BaseEnergyEstimationPlugin;
+import experiments.e2dc2015.EnvironmentConditions;
+import gridsim.dcworms.DCWormsTags;
+
+public class CpuEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	
+	private double timestamp = 0;
+	private double old_temperature = EnvironmentConditions.arm_cpuTidle;
+	private double new_temperature = -1;
+	private double objective_temperature = EnvironmentConditions.arm_cpuTidle;
+	
+	private boolean fan = false;
+	
+	private double next_timer = -1;    
+	
+	private int cpu_temp_monitor = 0;
+	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;
+	}
+	
+	@Override
+	public double estimateTemperature(ResourceEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double future = -1;
+
+		Processor cpu = (Processor) resource;
+
+		double R = 0;
+		double Rb = 0;
+		double Rcv = 0;
+		try{
+			Rb = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalResistance").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double k = 0;
+		try{
+			k = Double.valueOf(cpu.getPowerInterface().getParameters().get("k").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		
+		double a = 0;
+		try{
+			a = Double.valueOf(cpu.getPowerInterface().getParameters().get("a").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			a = 1;
+		}
+
+		double V = 0;
+	
+		//System.out.println("------ " + cpu.getFullName());
+		for(Device device: cpu.getParent().getParent().getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.Fan)){
+				int fanId = Integer.valueOf(device.getName().split("_")[1]).intValue();
+				int nodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue();
+				//System.out.println(device.getName() + "; " + cpu.getParent().getName());
+				//System.out.println(fanId + "; " + nodeId);
+				if(nodeId == fanId /*|| Integer.valueOf(device.getName().split("_")[1]) == Integer.valueOf(cpu.getParent().getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW*/){
+					Fan fan = (Fan) device;
+					V = fan.getAirflowInterface().getRecentAirflow().getValue();
+					break;
+				}
+			}
+		}
+		//System.out.println("V: " + V);
+		Rcv =  1/ (k * Math.pow(V, a));
+		R = Rb + Rcv; 
+		double C = 0;
+		try{
+			C = Double.valueOf(cpu.getPowerInterface().getParameters().get("thermalCapacity").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			//
+		}
+		// 1) look where we are
+		double delta_t = Sim_system.clock() - timestamp;
+		/***************model1*************/
+		//new_temperature = objective_temperature - (objective_temperature - old_temperature) * Math.exp(-delta_t/sink);
+		
+		/***************model2*************/
+		//new_temperature = objective_temperature - (objective_temperature - old_temperature) * Math.exp(-delta_t/(R * C));
+		 
+
+		// 2) calculate if fan is needed ?
+		if(new_temperature <= EnvironmentConditions.TFanLow) {
+			fan = false;
+		}
+		if(new_temperature >= EnvironmentConditions.TFanHigh) {
+			fan = true; 
+		}
+		
+		// 3) compute new objective
+		double Tin = EnvironmentConditions.ROOM_TEMPERATURE;
+		double Pcpu = cpu.getPowerInterface().getRecentPowerUsage().getValue();
+		new_temperature = objective_temperature - (objective_temperature - old_temperature) * Math.exp(-delta_t/(R * C));
+		//new_temperature = (Pcpu * R + Tin) - (Pcpu * R + Tin - Tidle) * Math.exp(-Sim_system.clock()/(R * C));;
+	
+		//System.out.println("getting inlet...: ");
+		NodeGroup ng = (NodeGroup) cpu.getParent().getParent();
+		for(Node n: ng.getNodes()){
+			int cpuNodeId = Integer.valueOf(cpu.getParent().getName().split("_")[1]).intValue();
+			int nodeId = Integer.valueOf(n.getName().split("_")[1]).intValue();
+			//System.out.println(cpuNodeId + "; " + nodeId);
+			if(nodeId - cpuNodeId == 9){
+				if(n.getThermalInterface().getRecentTemperature().getValue() == 0){
+					Tin = EnvironmentConditions.arm_nodeTidle;
+				} else
+					Tin = n.getThermalInterface().getRecentTemperature().getValue();
+				//System.out.println("======" + cpu.getFullName() + " previous node: " + n.getFullName() + "; " + Tin);
+				break;
+			}
+		}
+		if(cpu.getThermalInterface().getRecentTemperature().getValue() == 0)
+			Tin = (2 * Tin + EnvironmentConditions.arm_cpuTidle)/3;
+		else
+			Tin = (2 * Tin + 4*cpu.getThermalInterface().getRecentTemperature().getValue())/6;
+		/***************model1 - GEO1*************/
+		//double cpuLoad = cpu.getLoadInterface().getRecentUtilization().getValue();
+		//double targetTemp = Tidle + cpuLoad/100 * dTfull;
+		//if(fan) {
+		//	targetTemp = targetTemp - dTfan;
+		//}
+		System.out.println(new_temperature + "; " + objective_temperature + "; " + Tin +  "; " + Pcpu + "; " + R);
+		
+		/***************model2 - GEO2*************/
+		//Node node = (Node) cpu.getParent();
+		//Pserv = node.getPowerInterface().getRecentPowerUsage().getValue();
+		//double targetTemp = Pcpu * R + Tin; 
+		
+		/***************model3 - GEO1 + GEO2*************/
+		/*double targetTemp = Pcpu * R + Tin; 
+		if(fan) {
+			targetTemp = targetTemp - dTfan;
+		}*/
+	
+		/***************model4 - WP*************/
+		double targetTemp = Pcpu * R + Tin; 
+		//System.out.println("----------" + targetTemp +  ": " +  Pcpu +  ": " +  R +  ": " +  Tin);
+		// 4) check if we will need to tune fans
+		if(fan && targetTemp < EnvironmentConditions.TFanLow) {
+			double timer = C * R * Math.log((new_temperature - targetTemp)/(targetTemp - EnvironmentConditions.TFanLow));
+			if(future == -1 || future > timer) {
+				future = timer;
+			}
+		}
+		if(!fan && targetTemp > EnvironmentConditions.TFanHigh) {
+			double timer = C * R * Math.log((new_temperature - targetTemp)/(targetTemp - EnvironmentConditions.TFanHigh));
+			if(future == -1 || future > timer) {
+				future = timer;
+			}
+		}
+
+		// 5) save everything
+		timestamp = Sim_system.clock();
+		old_temperature = new_temperature;
+		objective_temperature = targetTemp;
+
+
+		if((future >= 0) && ((next_timer < Sim_system.clock()) || (next_timer >= future + Sim_system.clock()))) {
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(future, DCWormsTags.FANMGT, "Test");
+			next_timer = future + Sim_system.clock() - 0.01;
+		}		
+		
+		if(Sim_system.clock() == 0)
+			return new_temperature;
+		if(new_temperature < EnvironmentConditions.tempLevelMedium2Low){
+			if(cpu_temp_monitor != 1){
+				cpu_temp_monitor = 1;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelMedium2Low && new_temperature < EnvironmentConditions.tempLevelLow2Medium){
+			if(cpu_temp_monitor != 2){
+				cpu_temp_monitor = 2;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelLow2Medium && new_temperature < EnvironmentConditions.tempLevelHigh2Medium){
+			if(cpu_temp_monitor != 3){
+				cpu_temp_monitor = 3;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelHigh2Medium && new_temperature < EnvironmentConditions.tempLevelMedium2High){
+			if(cpu_temp_monitor != 4){
+				cpu_temp_monitor = 4;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelMedium2High && new_temperature < EnvironmentConditions.tempLevelMax2High){
+			if(cpu_temp_monitor != 5){
+				cpu_temp_monitor = 5;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelMax2High && new_temperature < EnvironmentConditions.tempLevelHigh2Max){
+			if(cpu_temp_monitor != 6){
+				cpu_temp_monitor = 6;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		} else if(new_temperature > EnvironmentConditions.tempLevelHigh2Max){
+			if(cpu_temp_monitor != 7){
+				cpu_temp_monitor = 7;
+				DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+			}
+		}
+		//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.RESOURCE_TEMPERATURE_LIMIT_EXCEEDED, resource.getFullName());
+		//System.out.println("cpu temp:" + new_temperature);
+		return new_temperature;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/CoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/CoolingDeviceEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,485 @@
+package experiments.e2dc2015.models.arm;
+
+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/experiments/e2dc2015/models/arm/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/DataCenterEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/DataCenterEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,514 @@
+package experiments.e2dc2015.models.arm;
+
+
+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 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;	
+		}
+		
+
+		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.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/experiments/e2dc2015/models/arm/FCFSBF_RandomPluginFansMng.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FCFSBF_RandomPluginFansMng.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FCFSBF_RandomPluginFansMng.java	(revision 1593)
@@ -0,0 +1,253 @@
+package experiments.e2dc2015.models.arm;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.computing.profiles.energy.airthroughput.CustomAirflowStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.Fan;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.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 experiments.e2dc2015.EnvironmentConditions;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPluginFansMng extends BaseLocalSchedulingPlugin {
+
+
+	private Random rand;
+	
+	public FCFSBF_RandomPluginFansMng() {
+		rand = new Random(5);
+	}
+
+	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 TIMER:
+
+			System.out.println("##" + Sim_system.clock());
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(StandardResourceType.Processor, 0.0, new ResourceEvent(ResourceEventType.TIMER, null));
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(EnvironmentConditions.SYSTEM_UDPATE_INTERVAL, DCWormsTags.TIMER, "Test");
+			break;
+			
+		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;
+		case RESOURCE_TEMPERATURE_LIMIT_EXCEEDED:
+			manageFans(resourceManager.getResourceByName(event.getSource()));
+			break;
+
+		}	
+
+		return plan;
+	}
+	
+	private void manageFans(ComputingResource cr ){
+		//System.out.println("tuning fans");
+		double temp = cr.getThermalInterface().getRecentTemperature().getValue();
+		double prevTemp;
+		if(cr.getThermalInterface().getTemperatureHistory().size() == 1)
+			prevTemp = temp;
+		else {
+			prevTemp = cr.getThermalInterface().getTemperatureHistory().get(cr.getThermalInterface().getTemperatureHistory().size() - 2).getValue();
+		}
+
+		//System.out.println(prevTemp+  ";  " + temp);
+		boolean getingHotter = prevTemp < temp;
+		boolean getingColder = prevTemp > temp;
+		Node n = (Node) cr.getParent();
+		for(Device d: n.getParent().getResourceCharacteristic().getDevices()){
+			//System.out.println(d.getName() + "; " + n.getName());
+			if(Integer.valueOf(d.getName().split("_")[1]) == Integer.valueOf(n.getName().split("_")[1]) || Integer.valueOf(d.getName().split("_")[1]) == Integer.valueOf(n.getName().split("_")[1]) - EnvironmentConditions.NODES_IN_A_ROW){
+				Fan f = (Fan) d;
+				int speed;
+				try{
+					speed= Integer.valueOf(f.getAirflowInterface().getAirflowState().getLabel().split("_")[1]).intValue();
+				} catch(Exception e){
+					speed = 0;
+				}
+				//System.out.println("getingHotter: "+ (prevTemp < temp));
+				if(getingHotter){
+					if(temp > EnvironmentConditions.tempLevelLow2Medium && temp < EnvironmentConditions.tempLevelMedium2High){
+						if(speed < 60){
+							//System.out.println("+++++++++ low 2 medium");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_60"));
+						}
+					} else if (temp > EnvironmentConditions.tempLevelMedium2High && temp < EnvironmentConditions.tempLevelHigh2Max) {
+						if(speed < 80){
+							//System.out.println("++++++++medium 2 high");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_80"));
+						}
+					} else if (temp > EnvironmentConditions.tempLevelHigh2Max) {
+						if(speed < 100){
+							//System.out.println("++++++++high 2 max");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_100"));
+						}
+					}					
+				} else if (getingColder){
+					if(temp > EnvironmentConditions.tempLevelHigh2Medium && temp < EnvironmentConditions.tempLevelMax2High){
+						if(speed == 100){
+							//System.out.println("-------- max 2 high");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_80"));
+						}
+					} else if(temp > EnvironmentConditions.tempLevelMedium2Low && temp < EnvironmentConditions.tempLevelHigh2Medium){
+						if(speed >= 80){
+							//System.out.println("-------- high 2 medium");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_60"));		
+						}
+					} else if (temp < EnvironmentConditions.tempLevelMedium2Low) {
+						if(speed >= 60){
+							//System.out.println("-------- medium 2 low");
+							f.getAirflowInterface().setAirflowState(new CustomAirflowStateName("ON_30"));	
+						}
+					}
+				}
+			}
+		}
+	}
+	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, task);
+		if(filteredNodes.size()==0)
+			return null;
+		Node node = chooseRandomNode(filteredNodes);
+		while(node.getFreeCores().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeCores().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Processor>  processors = node.getProcessors();
+			List<Core> cores = node.getCores();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/RackEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/RackEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/RackEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,49 @@
+package experiments.e2dc2015.models.arm;
+
+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){
+				
+			}
+		}
+		
+		for(Node node: rack.getNodes()){
+			if(node.getProcessors().get(0).getThermalInterface().getRecentTemperature().getValue() > 90){
+				//powerConsumption = powerConsumption + 15;
+			}
+		}
+		
+		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/experiments/e2dc2015/models/arm/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FCFSBF_RandomPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/FCFSBF_RandomPlugin.java	(revision 1593)
@@ -0,0 +1,174 @@
+package experiments.e2dc2015.models.arm;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+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.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(5);
+	}
+
+	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 TIMER:
+			if(Sim_system.clock()>2){
+				int a =3;
+			}
+			System.out.println("##########################" + Sim_system.clock());
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(StandardResourceType.Processor, 0.0, new ResourceEvent(ResourceEventType.TIMER, null));
+			//DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(EnvironmentConditions.SYSTEM_UDPATE_INTERVAL, DCWormsTags.TIMER, "Test");
+			break;
+			
+		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.getFreeCores().size() < cpuRequest){
+			node = chooseRandomNode(nodes);
+		}
+		
+		if (cpuRequest != 0) {
+
+			if (node.getFreeCores().size() < cpuRequest) {
+				return null;
+			}
+
+			List<Core> cores = node.getCores();
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			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<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+
+	private Node chooseRandomNode(List<Node> nodes) {
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx);
+	}
+
+
+}
+
Index: DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/NodeGroupEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/NodeGroupEnergyEstimationPlugin.java	(revision 1593)
+++ DCWoRMS/branches/coolemall/src/experiments/e2dc2015/models/arm/NodeGroupEnergyEstimationPlugin.java	(revision 1593)
@@ -0,0 +1,37 @@
+package experiments.e2dc2015.models.arm;
+
+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();
+				//powerConsumption = powerConsumption + node.getProcessors().get(0).getResourceCharacteristic().getDevices().get(0).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;
+	}
+
+}
