Index: DCWoRMS/branches/coolemall/src/example/energy/device/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/device/FanEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/device/FanEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,39 @@
+package example.energy.device;
+
+import schedframe.events.scheduling.EventReason;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class FanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		double powerConsumption = 0;
+		try {
+			if(event.getReason() == EventReason.SIM_INIT)
+				powerConsumption = powerConsumption + resource.getAirThroughputInterface().getPowerConsumption(StandardAirThroughputStateName.OFF);
+			else
+				powerConsumption = powerConsumption + resource.getAirThroughputInterface().getPowerConsumption(resource.getAirThroughputInterface().getAirThroughputState());
+		} catch (NoSuchFieldException e) {
+		}
+
+		return powerConsumption;
+	}
+
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airThroughput = 0;
+		try {
+			if(event.getReason() == EventReason.SIM_INIT)
+				airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.OFF);
+			else
+				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return airThroughput;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/BaseEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/BaseEnergyEstimationPlugin.java	(revision 751)
+++ DCWoRMS/branches/coolemall/src/example/energy/BaseEnergyEstimationPlugin.java	(revision 1207)
@@ -3,7 +3,7 @@
 import schedframe.Parameters;
 import schedframe.PluginConfiguration;
-import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
 import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 
@@ -17,10 +17,10 @@
 	
 	@Override
-	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
 		throw new RuntimeException("Not implemented.");
 	}
 
 	@Override
-	public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {
+	public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource  resource) {
 		throw new RuntimeException("Not implemented.");
 	}
Index: DCWoRMS/branches/coolemall/src/example/energy/DataCenterEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/DataCenterEnergyEstimationPlugin.java	(revision 520)
+++ DCWoRMS/branches/coolemall/src/example/energy/DataCenterEnergyEstimationPlugin.java	(revision 1207)
@@ -2,8 +2,8 @@
 
 import schedframe.resources.computing.ComputingNode;
-import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.DataCenter;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
 import schedframe.resources.computing.profiles.energy.power.PowerUsage;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 
@@ -12,5 +12,5 @@
 	@Override
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
+			PhysicalResource resource) {
 		double power = 0;
 		DataCenter dataCenter = (DataCenter)resource;
Index: DCWoRMS/branches/coolemall/src/example/energy/ProcessorEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/ProcessorEnergyEstimationPlugin.java	(revision 901)
+++ DCWoRMS/branches/coolemall/src/example/energy/ProcessorEnergyEstimationPlugin.java	(revision 1207)
@@ -2,8 +2,8 @@
 
 import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.Processor;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 
@@ -11,6 +11,7 @@
 
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
+			PhysicalResource resource) {
 		double powerConsumption;
+
 		Processor cpu = (Processor)resource;
 		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeGroupEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeGroupEnergyEstimationPlugin.java	(revision 913)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeGroupEnergyEstimationPlugin.java	(revision 1207)
@@ -1,9 +1,8 @@
 package example.energy.coolemall;
 
-import schedframe.Parameter;
-import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.resources.computing.recs.Node;
-import schedframe.resources.computing.recs.NodeGroup;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 import example.energy.BaseEnergyEstimationPlugin;
@@ -12,20 +11,13 @@
 
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
+			PhysicalResource resource) {
+		
 		double powerConsumption = 0;
 		NodeGroup nodeGroup = (NodeGroup)resource;
-		for(Node cn: nodeGroup.getNodes()){
+		for(Node node: nodeGroup.getNodes()){
 			try{
-				powerConsumption = powerConsumption + cn.getPowerInterface().getRecentPowerUsage().getValue();
+				powerConsumption = powerConsumption + node.getPowerInterface().getRecentPowerUsage().getValue();
 			} catch (Exception e){
-				
 			}
-		}
-		try {
-			powerConsumption = powerConsumption + nodeGroup.getPowerInterface().getPowerConsumption(nodeGroup.getPowerInterface().getPowerState());
-		} catch (NoSuchFieldException e) {
-			Parameter param = nodeGroup.getResourceCharacteristic().getParameters().get("maxPower");
-			if(param != null)
-				powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent());
 		}
 
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/FanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/FanEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/FanEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,62 @@
+package example.energy.coolemall;
+
+import schedframe.events.scheduling.EventReason;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class FanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		/*try {
+			powerConsumption = resource.getAirThroughputInterface().getPowerConsumption(resource.getAirThroughputInterface().getAirThroughputState());
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}*/
+
+		if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
+			powerConsumption = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_POWER_CONSUMPTION;
+		} else {
+			powerConsumption = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
+		}
+		return powerConsumption;
+	}
+	
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airThroughput = 0;
+		/*try {
+			if(event.getReason() == EventReason.SIM_INIT)
+				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+			else
+				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}*/
+
+		if(event.getReason() == EventReason.SIM_INIT){
+			if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
+				airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
+			} else {
+				airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
+			}
+		}
+		else {
+			if(resource.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
+				airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
+			} else {
+				airThroughput = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
+			}
+		}
+
+		
+		return airThroughput;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java	(revision 913)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java	(revision 1207)
@@ -1,9 +1,8 @@
 package example.energy.coolemall;
 
-import schedframe.Parameter;
-import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.ComputeBox1;
+import schedframe.resources.computing.coolemall.NodeGroup;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.resources.computing.recs.ComputeBox1;
-import schedframe.resources.computing.recs.NodeGroup;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 import example.energy.BaseEnergyEstimationPlugin;
@@ -12,5 +11,5 @@
 
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
+			PhysicalResource resource) {
 		double powerConsumption = 0;
 		ComputeBox1 computeBox1 = (ComputeBox1)resource;
@@ -22,14 +21,5 @@
 			}
 		}
-
-		try {
-			powerConsumption = powerConsumption + computeBox1.getPowerInterface().getPowerConsumption(computeBox1.getPowerInterface().getPowerState());
-		} catch (NoSuchFieldException e) {
-			Parameter param = computeBox1.getResourceCharacteristic().getParameters().get("maxPower");
-			if(param != null)
-				powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent());
-		}
-
-		
+		powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY;
 		return powerConsumption;
 	}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolEmAllTestbedMeasurements.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolEmAllTestbedMeasurements.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolEmAllTestbedMeasurements.java	(revision 1207)
@@ -0,0 +1,39 @@
+package example.energy.coolemall;
+
+public class CoolEmAllTestbedMeasurements {
+
+	//HARDWARE
+	public static final double SINGLE_FAN_ON_AIR_FLOW = 0.0112;
+	public static final double SINGLE_FAN_OFF_AIR_FLOW = 0;
+	
+	public static final double SINGLE_FAN_ON_POWER_CONSUMPTION = 6;
+	public static final double SINGLE_FAN_OFF_POWER_CONSUMPTION = 0;
+	
+	public static final double OTHER_DEVICES_POWER_CONSUMPTION = 775;
+	
+	public static final double POWER_SUPPLY_EFFICIENCY = 0.87;
+	
+
+	public static final int Atom_D510_NR_OF_THREADS = 2;
+	
+	public static final int Atom_N2600_NR_OF_THREADS = 2;
+	
+	public static final int Core_i7_2715QE_NR_OF_THREADS = 4;
+	
+	public static final int Core_i7_3615QE_NR_OF_THREADS = 4;
+	
+	public static final int Fusion_G_T40N_NR_OF_THREADS = 2;
+	
+	//APPLICATIONS
+	public static final double Atom_D510 = 336.3;
+	
+	public static final double Atom_N2600 = 336.3;
+	
+	public static final double Core_i7_2715QE = 3076.4;
+	
+	public static final double Core_i7_3615QE = 3786.0;
+	
+	public static final double Fusion_G_T40N = 649.3;
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpInletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpInletEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpInletEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,54 @@
+package example.energy.coolemall;
+
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class FlowPumpInletEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+
+		double nf = 0.6;
+
+		double delta_p;//from database, CFD
+		try{
+			delta_p = ConfigurationOptions.pressureDrop;
+		} catch (Exception e){
+			delta_p = 0;
+		}
+		
+		double Vair_total;
+		
+		try{
+			Vair_total = ConfigurationOptions.airFlowVolume;
+		} catch (Exception e){
+			Vair_total = 0;
+		}
+
+		
+		//if data not present in DB than don't take Pfans_dc into account
+		if(delta_p != -1 && Vair_total != -1)
+			powerConsumption = delta_p * Vair_total / nf;
+		
+		return powerConsumption;
+	}
+	
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airThroughput = 0;
+		double Vair_total;
+		
+		try{
+			Vair_total = ConfigurationOptions.airFlowVolume;
+		} catch (Exception e){
+			Vair_total = 0;
+		}
+		airThroughput = Vair_total;
+		return airThroughput;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java	(revision 1146)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java	(revision 1207)
@@ -1,20 +1,21 @@
 package example.energy.coolemall;
 
-import schedframe.Parameter;
-import schedframe.events.scheduling.EventReason;
-import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.resources.computing.recs.Node;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
+import testbed_hpc.Node_Fan_Mapping;
 import example.energy.BaseEnergyEstimationPlugin;
 
 public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
 
-	private static int OUT_START_ID = 0;
-	private static int OUT_END_ID = 8;
+	//private static int OUT_START_ID = 0;
+	//private static int OUT_END_ID = 8;
 	
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
+			PhysicalResource resource) {
 		double powerConsumption = 0;
 		Node node = (Node) resource;
@@ -26,16 +27,22 @@
 			}
 		}
-		try {
-			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
-		} catch (NoSuchFieldException e) {
-			Parameter param = node.getResourceCharacteristic().getParameters().get("maxPower");
-			if(param != null)
-				powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent());
-		}
+		if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){
+			//powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
+			for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+				if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+					if(device.getPowerInterface().getRecentPowerUsage().getValue() == -1){
+						powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
+					}else
+						powerConsumption = powerConsumption + device.getPowerInterface().getRecentPowerUsage().getValue();
+					break;
+				}
+			}
+		} 
+
 
 		return powerConsumption;
 	}
 
-	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {
+	/*public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
 
 		double airThroughput = 0;
@@ -44,6 +51,9 @@
 				return airThroughput;
 				//airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF);
-			else
+			else {
 				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+				//airThroughput = computingResource.getResourceCharacteristic().getDevices().get(0).getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+				//airThroughput = 0.28;
+			}
 		} catch (NoSuchFieldException e) {
 			// TODO Auto-generated catch block
@@ -51,24 +61,25 @@
 		}
 		
-		Integer resId = Integer.parseInt(resource.getName().split("_")[1]);
+		//Integer resId = Integer.parseInt(resource.getName().split("_")[1]);
+		//ComputingResource computingResource = (ComputingResource) resource;
 		//we estimate the air flow related to the outlets (nodes placed in the outlet row of RECS)
-		if(resId >= OUT_START_ID  && resId <= OUT_END_ID){
-			for(ComputingResource compResource: resource.getParent().getChildren()){
-				Integer id = Integer.parseInt(compResource.getName().split("_")[1]);
-				//we take into account the inlet air flow (nodes placed "behind" the given node)
-				if(id - resId == 9 || id - resId == -9){
-					try {
-						airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2;
-					} catch (NoSuchFieldException e) {
-		
-					}
-				}
-			}
-		}
+		//if(resId >= OUT_START_ID  && resId <= OUT_END_ID){
+		//	for(ComputingResource compResource: computingResource.getParent().getChildren()){
+		//		Integer id = Integer.parseInt(compResource.getName().split("_")[1]);
+		//		//we take into account the inlet air flow (nodes placed "behind" the given node)
+		//		if(id - resId == 9 || id - resId == -9){
+		//			try {
+		//				airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2;
+		//			} catch (NoSuchFieldException e) {
+		//
+		//			}
+		//		}
+		//	}
+		//}
 
 		return airThroughput;
-	}
+	}*/
 
-	public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {
+	/*public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
 		double tout = 0;
 		double tin = 21.3;
@@ -83,6 +94,8 @@
 		Integer resId = Integer.parseInt(resource.getName().split("_")[1]);
 		
+		ComputingResource computingResource = (ComputingResource) resource;
+		
 		//we estimate outlet temperature (related to the temperature of the nodes placed in outlet row)
-		for(ComputingResource compResource: resource.getParent().getChildren()){
+		for(ComputingResource compResource: computingResource.getParent().getChildren()){
 			Integer id = Integer.parseInt(compResource.getName().split("_")[1]);
 			//we take into account the power of nodes placed "behind" the given nodes
@@ -98,5 +111,5 @@
 		tout = tin + delta1 * (power1/(Q * C * ro)) +  delta2 * (power2/(Q * C * ro));;
 		return tout;
-	}
+	}*/
 	
 }
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB2EnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB2EnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB2EnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,345 @@
+package example.energy.coolemall;
+
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.ComputeBox1;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.coolemall.NodeGroup;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import testbed_hpc.Node_Fan_Mapping;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class CB2EnergyEstimationPlugin extends BaseEnergyEstimationPlugin{
+
+	
+	public double estimatePowerConsumption(EnergyEvent 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 ***********/
+		for(ComputingResource cr: room.getChildren()){
+			ComputeBox1 cb1 = (ComputeBox1)cr;
+			Pload_dc = Pload_dc + cb1.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		
+		
+		
+		/**************** NON- IT PART ****************/
+		
+		/*********** Pothers ***********/		
+		double a;//experiment
+		try{
+			a = ConfigurationOptions.alpha;
+		} catch (Exception e){
+			a = 0.02;
+		}
+		
+		//if not defined assume alpha = 0.02
+		if(a == -1)
+			a = 0.02;
+		
+		Pothers = a * Pload_dc; 
+		
+		
+		
+		/************* COOLING PART *************/
+		
+		Device coolingDevice = null;
+		for(Device device: room.getResourceCharacteristic().getDevices()){
+			if(device.getType().equals(StandardResourceType.CoolingDevice)){
+				coolingDevice = device;
+				break;
+			}
+		}
+
+		
+		/*********** Pfans_dc ***********/
+		double ro = 1.168;//constant
+		double nf;//DEBB
+		try{
+			nf = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CRAHFanEfficiency").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			nf = 0.6;
+		}
+		double delta_p;//from database, CFD
+		try{
+			delta_p = ConfigurationOptions.pressureDrop;
+		} catch (Exception e){
+			delta_p = -1;
+		}
+		
+		double Vair_total;
+		double mair_total;
+		
+		//in case of DCworms calculation of Vair_total
+		double mair_rack = 0;
+
+		for(ComputingResource cr: room.getChildren()){
+			ComputeBox1 cb1 = (ComputeBox1)cr;
+			for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+				for(Device device: nodeGroup.getResourceCharacteristic().getDevices()){
+					if(device.getType().equals(StandardResourceType.Outlet)){
+						double mair_recs = 0;
+						double Vair_recs = 0;
+						
+						double Vair_recs1 = 0;
+						/*try {
+							Vair_recs1  = device.getAirThroughputInterface().getAirFlow(device.getAirThroughputInterface().getAirThroughputState());
+						} catch (NoSuchFieldException e) {
+						}
+						*/
+						if(device.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
+							Vair_recs1 = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
+						} else {
+							Vair_recs1 = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
+						}
+						double Vair_recs2 = 0;
+						for(Device device2: nodeGroup.getResourceCharacteristic().getDevices()){
+							if(device2.getType().equals(StandardResourceType.Inlet) && device2.getFullName().equals(device.getFullName().replace("Outlet", "Inlet"))){
+								/*try {
+									Vair_recs2  = device2.getAirThroughputInterface().getAirFlow(device2.getAirThroughputInterface().getAirThroughputState());
+								} catch (NoSuchFieldException e) {
+								}
+								*/
+								if(device2.getAirThroughputInterface().getAirThroughputState().getName().equals(new UserAirThroughputStateName("1").getName())){
+									Vair_recs2 = CoolEmAllTestbedMeasurements.SINGLE_FAN_OFF_AIR_FLOW;
+								} else {
+									Vair_recs2 = CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_AIR_FLOW;
+								}
+								break;
+							}
+						}	
+
+						Vair_recs  = Math.max(Vair_recs1, Vair_recs2);
+
+						mair_recs = Vair_recs * ro;
+						mair_rack  = mair_rack + mair_recs;
+					}
+				}
+			}
+		}
+		mair_total = mair_rack;
+		Vair_total = mair_total / ro;
+		
+		//in case of CFD calculation of Vair_total
+		try{
+			Vair_total = ConfigurationOptions.airFlowVolume;
+		} catch (Exception e){
+			Vair_total = 0;
+		}
+		mair_total = Vair_total * ro;
+		
+		//if data not present in DB than don't take Pfans_dc into account
+		if(delta_p != -1 && Vair_total != -1)
+			Pfans_dc = delta_p * Vair_total / nf;
+		
+		
+		
+		/************ Pcooling_device ************/
+		
+		
+		double Pchiller = 0;
+		double Pdry_cooler;
+		
+		/*********** Pchiller ***********/
+		double Cp = 1004;//constant
+		
+		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 = 3000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+		
+		double Tco;//DEBB
+		try{
+			Tco = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CWT").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Tco = 30;
+		}
+
+		double delta_Th_ex;//DEBB
+		try{
+			delta_Th_ex = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThEx").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_ex = 10;
+		}
+
+		double Tr_out;//from database, CFD
+		try{
+			Tr_out = ConfigurationOptions.outletRoomAirTempeature;
+		} catch (Exception e){
+			Tr_out = -1;
+		}
+		
+		double Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.inletRoomAirTempeature;
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+		
+		double Qdc;
+		double Qcooling;
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		Qdc = mair_total * Cp * (Tr_out - Tr_in);
+		Qcooling = Qdc / ncc;
+
+		Tev = Tr_in - delta_Th_ex;
+		double Tevf = 32 + 1.8 * Tev;
+		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;
+
+			
+		
+
+		/*********** Pdry_cooler ***********/
+		double delta_Th_dry_cooler;//DEBB
+		try{
+			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_dry_cooler = 10;
+		}
+		
+		double Tamb;//experiment
+		try{
+			Tamb = ConfigurationOptions.ambientAirTempeature;
+		} catch (Exception e){
+			Tamb = -1;
+		}
+		
+		Pdry_cooler = 0.02 * Qcooling;
+		
+		
+		//if data not present in DB than don't take Pchiller into account
+		if(Vair_total != -1 && Tr_in != -1 && Tr_out != -1) {
+			if(Tamb != -1 && Tev - Tamb > 0 && delta_Th_dry_cooler > Tev - Tamb)
+				Pcooling_device = Pdry_cooler;
+			else
+				Pcooling_device = Pchiller;	
+		}
+		
+		
+
+		Pdc = Pload_dc + Pothers + Pfans_dc + Pcooling_device;
+		//System.out.println("---");
+		//System.out.println("Pdry_cooler: " + Pdry_cooler + " Pchiller: "+ Pchiller);
+		//System.out.println("Pdc: " + Pdc + " Pload_dc: "+ Pload_dc + " Pothers: " + Pothers + " Pfans_dc: " + Pfans_dc + " Pcooling_device: " + Pcooling_device);
+		
+		
+		
+		
+		/**************** HEAT ****************/
+		double Qdc2;
+		
+		double Qload_dc = 0;
+		double Qothers = 0;
+		double Qfans_dc = 0;
+
+		double delta_2; //DEBB - currently not present;
+		delta_2 = 0.4;
+		
+		for(ComputingResource cr: room.getChildren()){
+			ComputeBox1 cb1 = (ComputeBox1)cr;
+			double QnodeGroup = 0;
+			for(NodeGroup nodeGroup: cb1.getNodesGroups()){
+				double Qnodes = 0;
+				for(Node node: nodeGroup.getNodes()){
+					double Qcpu = 0;
+					for(Processor proc: node.getProcessors()){
+						Qcpu = Qcpu + proc.getPowerInterface().getRecentPowerUsage().getValue();
+					}
+					double Qfan = 0;
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							if(device.getPowerInterface().getRecentPowerUsage().getValue() == -1){
+								Qfan = Qfan + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
+							}else
+								Qfan = Qfan + device.getPowerInterface().getRecentPowerUsage().getValue();
+							break;
+						}
+					}
+					Qnodes = Qnodes + Qcpu + (1 - delta_2) * Qfan;
+				}
+				QnodeGroup = QnodeGroup + Qnodes;
+			}
+			Qload_dc  = Qload_dc + QnodeGroup;
+		}
+		
+		Qload_dc = Qload_dc + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION;
+		
+		Qothers = Pothers;
+		
+		Qfans_dc = (1 - nf) * Pfans_dc;
+		
+		Qdc2 = Qload_dc + Qothers + Qfans_dc;
+		
+		double Qdc2v2 = 0;
+		
+		if(Vair_total != -1 && Tr_in != -1 && Tr_out != -1)
+			Qdc2v2 = mair_total * Cp * (Tr_out - Tr_in);
+
+		//System.out.println("Qdc2: " + Qdc2 + " Qdc2v2: " + Qdc2v2 + "diff: " + (Qdc2v2 - Qdc2));
+
+		
+		return Pdc;
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpOutletEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/FlowPumpOutletEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,32 @@
+package example.energy.coolemall;
+
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class FlowPumpOutletEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+
+		return powerConsumption;
+	}
+	
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airThroughput = 0;
+		double Vair_total;
+		
+		try{
+			Vair_total = ConfigurationOptions.airFlowVolume;
+		} catch (Exception e){
+			Vair_total = 0;
+		}
+		airThroughput = Vair_total;
+		return airThroughput;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/HeatsinkEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/HeatsinkEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/HeatsinkEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,26 @@
+package example.energy.coolemall;
+
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class HeatsinkEnergyEstimationPlugin extends BaseEnergyEstimationPlugin  {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		Device device = (Device) resource;
+		ComputingNode cn = (ComputingNode) device.getComputingResource();
+		for(Processor proc : cn.getProcessors()){
+			powerConsumption = powerConsumption + proc.getPowerInterface().getRecentPowerUsage().getValue();
+		}
+		return powerConsumption;
+	}
+
+}
+
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoreEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoreEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoreEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,17 @@
+package example.energy.coolemall;
+
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class CoreEnergyEstimationPlugin extends BaseEnergyEstimationPlugin  {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+		return powerConsumption;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolingDeviceEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolingDeviceEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/CoolingDeviceEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,174 @@
+package example.energy.coolemall;
+
+import schedframe.events.scheduling.EventReason;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.ConfigurationOptions;
+import example.energy.BaseEnergyEstimationPlugin;
+
+public class CoolingDeviceEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		
+		double powerConsumption = 0;
+
+		Device coolingDevice = (Device) resource;
+
+		double Pchiller = 0;
+		double Pdry_cooler;
+		
+		/*********** Pchiller ***********/
+		double Cp = 1004;//constant
+		
+		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 = 3000;
+		}
+		
+		double EERrated;//DEBB
+		try{
+			EERrated = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("EERRated").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			EERrated = 5;
+		}
+		
+		double Tco;//DEBB
+		try{
+			Tco = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("CWT").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			Tco = 30;
+		}
+
+		double delta_Th_ex;//DEBB
+		try{
+			delta_Th_ex = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThEx").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_ex = 10;
+		}
+
+		double Tr_out;//from database, CFD
+		try{
+			Tr_out = ConfigurationOptions.outletRoomAirTempeature;
+		} catch (Exception e){
+			Tr_out = -1;
+		}
+		
+		double Tr_in;//experiment
+		try{
+			Tr_in = ConfigurationOptions.inletRoomAirTempeature;
+		} catch (Exception e){
+			Tr_in = -1;
+		}
+
+		
+		
+		double ro = 1.168;//cosntant
+		double	Vair_total;
+		double mair_total;
+		try{
+			Vair_total = ConfigurationOptions.airFlowVolume;
+		} catch (Exception e){
+			Vair_total = 0;
+		}
+		mair_total = Vair_total * ro;
+		
+		
+		double Qdc;
+		double Qcooling;
+		
+		double Tev;		
+		double CoolT;
+		double Qcooling_nom;
+		double PLR;
+
+		double delta_T;
+		double CoolPR;
+		double CoolPRrated;
+		double CoolPRT;
+		double CoolPRPLR;
+		double EER;
+		
+		
+		Qdc = mair_total * Cp * (Tr_out - Tr_in);
+		Qcooling = Qdc / ncc;
+
+		Tev = Tr_in - delta_Th_ex;
+		double Tevf = 32 + 1.8 * Tev;
+		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;
+
+			
+		
+
+		/*********** Pdry_cooler ***********/
+		double delta_Th_dry_cooler;//DEBB
+		try{
+			delta_Th_dry_cooler = Double.valueOf(coolingDevice.getResourceCharacteristic().getParameters().get("deltaThDryCooler").get(0).getContent()).doubleValue();
+		} catch (Exception e){
+			delta_Th_dry_cooler = 10;
+		}
+		
+		double Tamb;//experiment
+		try{
+			Tamb = ConfigurationOptions.ambientAirTempeature;
+		} catch (Exception e){
+			Tamb = -1;
+		}
+		
+		Pdry_cooler = 0.02 * Qcooling;
+		
+		
+		//if data not present in DB than don't take Pchiller into account
+		if(Vair_total != -1 && Tr_in != -1 && Tr_out != -1) {
+			if(Tamb != -1 && Tev - Tamb > 0 && delta_Th_dry_cooler > Tev - Tamb)
+				powerConsumption = Pdry_cooler;
+			else
+				powerConsumption = Pchiller;	
+		}
+		
+		
+
+		
+		return powerConsumption;
+	}
+	
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
+		double airThroughput = 0;
+		try {
+			if(event.getReason() == EventReason.SIM_INIT)
+				return airThroughput;
+				//airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF);
+			else
+				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
+		} catch (NoSuchFieldException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return airThroughput;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java	(revision 913)
+++ DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java	(revision 1207)
@@ -1,11 +1,14 @@
 package example.energy.coolemall;
 
-import schedframe.Parameter;
+import dcworms.schedframe.scheduling.ExecTask;
 import schedframe.resources.ResourceStatus;
-import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
 import schedframe.resources.computing.Processor;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.tasks.phases.PhaseBehaviour;
 import example.energy.BaseEnergyEstimationPlugin;
 
@@ -13,6 +16,7 @@
 
 	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
-		double powerConsumption = 0;
+			PhysicalResource resource) {
+		
+		/*double powerConsumption = 0;
 		Processor cpu = (Processor)resource;
 		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
@@ -38,4 +42,121 @@
 			}
 		}
+		return powerConsumption;*/
+		double powerConsumption = 0;
+		Processor proc = (Processor)resource;
+		if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF))
+			return 0;
+		else {
+			double processorLoad;
+			double sumCoresLoad = 0;
+			
+			int nrOfThreadsOnCpu = 1;
+			
+			if(proc.getResourceCharacteristic().getParameters().get("product") != null){
+				String productName = proc.getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Fusion_G_T40N_NR_OF_THREADS;
+				else if(productName.equals("Atom - D510"))
+					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_D510_NR_OF_THREADS;
+				else if(productName.equals("Atom - N2600"))
+					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS;
+				else if(productName.equals("Core i7 - 2715QE"))
+					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS;
+				else if(productName.equals("Core i7 - 3615QE"))
+					nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS;
+			}
+
+			for(Core core: proc.getCores()){
+				
+				if(core.getStatus().equals(ResourceStatus.BUSY)){
+					JobRegistry jr = new JobRegistryImpl(core.getFullName());
+					for(ExecTask task: jr.getRunningTasks()){
+						double cpuUsage = 100;
+						double nrOfThreadsOfApplciation = 1;
+						for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){
+							if(pb.getResouceName().equals("PM_CPU_Usage")){
+								cpuUsage = pb.getUtilization();
+							}
+							if(pb.getResouceName().equals("PM_Threads")){
+								nrOfThreadsOfApplciation = pb.getUtilization();
+								break;
+							}
+						}
+						sumCoresLoad = sumCoresLoad + cpuUsage * (nrOfThreadsOnCpu / nrOfThreadsOfApplciation);
+					}
+				}
+			}
+			processorLoad = 100 * sumCoresLoad/proc.getCores().size();
+			double lowestLoadLevel = 100;
+			double highestLoadLevel = 0;
+			if(proc.getPowerInterface().getPState().getLoadPowerUsage().containsKey(new Double(processorLoad))){
+				powerConsumption = proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(processorLoad));
+				//System.out.println("power from profile: " + powerConsumption);
+			} 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();
+						//System.out.println("load = 0; power = idle power usage: " + powerConsumption);
+					} catch (Exception e){
+						powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel));
+						//System.out.println("error load = 0; power = 0.7 max power: " + powerConsumption);
+					}
+				} 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;
+						/*System.out.println("a" +lowestLoadLevel + ";" +highestLoadLevel);
+						System.out.println("b" +lowerLoadLevel + ";" +higherLoadLevel);
+						System.out.println("c" +powerBelow + ";" +powerAbove);
+						System.out.println(resource.getFullName() + "load: " + processorLoad + "linear power estimation " + powerConsumption);*/
+	
+					} catch (Exception e){
+						powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel));	
+						//System.out.println("error; power = 0.7 max power: " + powerConsumption);
+					}
+				}
+			}
+		}
+			
+
+		powerConsumption = powerConsumption - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION;
+		//System.out.println("estiamted power consumption: " + powerConsumption);
 		return powerConsumption;
 	}
Index: DCWoRMS/branches/coolemall/src/example/energy/DefaultEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/DefaultEnergyEstimationPlugin.java	(revision 546)
+++ DCWoRMS/branches/coolemall/src/example/energy/DefaultEnergyEstimationPlugin.java	(revision 1207)
@@ -3,4 +3,5 @@
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 
@@ -9,5 +10,5 @@
 
 
-	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) {
 		double powerConsumption = 0;
 		try {
@@ -17,13 +18,7 @@
 		}
 		
-		powerConsumption = powerConsumption + getChildrenPowerConsumption(resource);
-		
-		for(ComputingResource child:resource.getChildren()){
-			try {
-				//powerConsumption = powerConsumption + child.getPowerInterface().getRecentPowerUsage().getValue(); 
-			} catch (Exception e) {
+		ComputingResource cr = (ComputingResource) resource;
+		powerConsumption = powerConsumption + getChildrenPowerConsumption(cr);
 
-			}
-		}
 		return powerConsumption;
 	}
Index: DCWoRMS/branches/coolemall/src/example/energy/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/NodeEnergyEstimationPlugin.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/energy/NodeEnergyEstimationPlugin.java	(revision 1207)
@@ -0,0 +1,34 @@
+package example.energy;
+
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		for(Processor cpu: node.getProcessors()){
+			try{
+				powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+			} catch (Exception e){
+				
+			}
+		}
+		try {
+			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+			for(Device dev: node.getResourceCharacteristic().getDevices()){
+				powerConsumption = powerConsumption + dev.getPowerInterface().getRecentPowerUsage().getValue();
+			}
+		} catch (NoSuchFieldException e) {
+		}
+
+		return powerConsumption;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/example/energy/ComputingNodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/ComputingNodeEnergyEstimationPlugin.java	(revision 532)
+++ 	(revision )
@@ -1,30 +1,0 @@
-package example.energy;
-
-import schedframe.resources.computing.ComputingNode;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-
-public class ComputingNodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
-
-	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
-		double powerConsumption = 0;
-		ComputingNode node = (ComputingNode) resource;
-		for(Processor cpu: node.getProcessors()){
-			try{
-				powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
-			} catch (Exception e){
-				
-			}
-		}
-		try {
-			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
-		} catch (NoSuchFieldException e) {
-		}
-
-		return powerConsumption;
-	}
-
-}
Index: DCWoRMS/branches/coolemall/src/example/energy/ComputingNodeWithFanEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/energy/ComputingNodeWithFanEnergyEstimationPlugin.java	(revision 774)
+++ 	(revision )
@@ -1,50 +1,0 @@
-package example.energy;
-
-import schedframe.events.scheduling.EventReason;
-import schedframe.resources.computing.ComputingNode;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.Processor;
-import schedframe.resources.computing.profiles.energy.EnergyEvent;
-import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
-import schedframe.scheduling.manager.tasks.JobRegistry;
-
-public class ComputingNodeWithFanEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
-
-	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
-			ComputingResource resource) {
-		double powerConsumption = 0;
-		ComputingNode node = (ComputingNode) resource;
-		for(Processor cpu: node.getProcessors()){
-			try{
-				powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
-			} catch (Exception e){
-				
-			}
-		}
-		try {
-			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
-			if(event.getReason() == EventReason.SIM_INIT)
-				powerConsumption = powerConsumption + node.getAirThroughputInterface().getPowerConsumption(StandardAirThroughputStateName.FAN_OFF);
-			else
-				powerConsumption = powerConsumption + node.getAirThroughputInterface().getPowerConsumption(node.getAirThroughputInterface().getAirThroughputState());
-		} catch (NoSuchFieldException e) {
-		}
-
-		return powerConsumption;
-	}
-
-	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) {
-		double airThroughput = 0;
-		try {
-			if(event.getReason() == EventReason.SIM_INIT)
-				airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF);
-			else
-				airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState());
-		} catch (NoSuchFieldException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		return airThroughput;
-		//throw new RuntimeException("Not implemented.");
-	}
-}
