Index: DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/utils/ApplicationProfileDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/utils/ApplicationProfileDescription.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/utils/ApplicationProfileDescription.java	(revision 1207)
@@ -0,0 +1,53 @@
+package dcworms.schedframe.scheduling.utils;
+
+import java.io.StringReader;
+
+import org.exolab.castor.xml.MarshalException;
+import org.exolab.castor.xml.ResolverException;
+import org.exolab.castor.xml.Unmarshaller;
+import org.exolab.castor.xml.ValidationException;
+import org.exolab.castor.xml.XMLContext;
+
+import schedframe.DescriptionContainer;
+
+public class ApplicationProfileDescription implements DescriptionContainer<org.qcg.broker.schemas.jobdesc.Task>{
+
+	private static final long serialVersionUID = 7853990656207447619L;
+	protected static Unmarshaller unmarshaller;
+	static {
+		XMLContext context = new XMLContext();
+		try {
+			context.addClass(org.qcg.broker.schemas.jobdesc.Job.class);
+			unmarshaller = context.createUnmarshaller();
+		} catch (ResolverException e) {
+			e.printStackTrace();
+			unmarshaller = null;
+		}
+	}
+	
+	protected String xml;
+	protected org.qcg.broker.schemas.jobdesc.Job app;
+	
+	public ApplicationProfileDescription(String xmlJobDesc){
+		xml = xmlJobDesc;
+	}
+
+
+	public org.qcg.broker.schemas.jobdesc.Task getDescription() {
+		if(app == null){
+			try {
+				app = (org.qcg.broker.schemas.jobdesc.Job) unmarshaller.unmarshal(new StringReader(xml));
+			} catch (MarshalException e) {
+				e.printStackTrace();
+			} catch (ValidationException e) {
+				e.printStackTrace();
+			}
+		}
+		return app.getTask(0);
+	}
+
+	public String getDocument() throws Exception {
+		return xml;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
===================================================================
--- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java	(revision 1157)
+++ DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java	(revision 1207)
@@ -2,4 +2,5 @@
 
 
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
 import gridsim.GridSim;
 import gridsim.dcworms.DCWormsTags;
@@ -7,4 +8,5 @@
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -14,8 +16,12 @@
 import org.joda.time.DateTimeUtilsExt;
 import org.joda.time.ReadableDuration;
+import org.qcg.broker.schemas.resreqs.ResourceConsumptionProfileType;
+import org.qcg.broker.schemas.resreqs.ResourceConsumptionType;
+import org.qcg.broker.schemas.resreqs.StringParameterType;
 
 import qcg.shared.constants.BrokerConstants;
 
 import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.units.PEUnit;
 import schedframe.resources.units.ProcessingElements;
 import schedframe.resources.units.StandardResourceUnitName;
@@ -30,4 +36,5 @@
 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
+import simulator.stats.implementation.ResourceUsefulWorkStats;
 
 /**
@@ -60,4 +67,6 @@
 	protected double finishTime; 
 	
+	private ResourceConsumptionProfile resourceConsumptionProfile;
+	
 	public Executable(Task t){
 		this.task = t;
@@ -83,4 +92,5 @@
 		this.submissionTime =  currentTime;
         this.totalCompletionTime = 0.0;
+        preparePhases(null);
 	 }
 	
@@ -168,4 +178,5 @@
         
         if(status == DCWormsTags.INEXEC){
+        	loadResourceConsumptionProfile();
         	task.setStatus((int) BrokerConstants.TASK_STATUS_RUNNING);
         } else if(status == DCWormsTags.QUEUED){
@@ -202,11 +213,11 @@
     		for (ComputingResource resource : pes) {
 
-    			trackResource(resource.getName());
+    			trackResource(resource.getFullName());
     			
     			ComputingResource parent = resource.getParent();
 				List<String> visitedResource = getVisitedResources();
 				String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]);
-    			while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getName())) {
-    				trackResource(parent.getName());
+    			while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) {
+    				trackResource(parent.getFullName());
     				parent = parent.getParent();
     			}
@@ -218,5 +229,5 @@
         		status = DCWormsTags.INEXEC;
         		setCompletionPercentage(0);
-        		task.getResourceConsumptionProfile().setCurrentPhase(task.getResourceConsumptionProfile().getCurrentPhase() + 1);
+        		resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1);
         		
         		DateTime currentDateTime = new DateTime();
@@ -386,9 +397,9 @@
 	
 	public ResourceConsumptionProfile getResourceConsumptionProfile(){
-		return task.getResourceConsumptionProfile();
+		return resourceConsumptionProfile;
 	}
 
 	public ResourceConsumption getCurrentResourceConsumption(){
-		return task.getResourceConsumptionProfile().getCurrentResourceConsumption();
+		return resourceConsumptionProfile.getCurrentResourceConsumption();
 	}
 	
@@ -396,4 +407,89 @@
 		return task.getApplicationName();
 	}
-
+	
+	private void preparePhases(String resourceType) {
+		LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>();
+		
+		long usefulWork = -1;
+		
+		if(task.getDescription().getExecution() == null || task.getDescription().getExecution().getResourceConsumptionProfile() == null
+				|| task.getDescription().getExecution().getResourceConsumptionProfile().length == 0 ){
+			ResourceConsumption resConsumption = null;
+			try {
+				resConsumption = new ResourceConsumption(getLength(), task.getComputingResourceRequirements());
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			resourceConsumptionList.add(resConsumption);
+		}else{
+			boolean found = false;
+			if(resourceType != null){
+				for(ResourceConsumptionProfileType resConsumptioProfile: task.getDescription().getExecution().getResourceConsumptionProfile()){
+					if(resConsumptioProfile.getType() != null && resConsumptioProfile.getType().equals(resourceType)){
+						for(ResourceConsumptionType resConsumption: resConsumptioProfile.getResourceConsumption()){
+							ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption);
+							resourceConsumptionList.add(resourceConsumption);
+						}
+						for(StringParameterType prop: resConsumptioProfile.getProperties()){
+							if(prop.getName().equals("usefulWork")){
+								usefulWork = Double.valueOf(prop.getContent()).longValue();
+								break;
+							}
+						}
+						found = true;
+						break;
+					}
+				}	
+			}			
+			if(!found){
+				for(ResourceConsumptionType resConsumption: task.getDescription().getExecution().getResourceConsumptionProfile()[0].getResourceConsumption()){
+					ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption);
+					resourceConsumptionList.add(resourceConsumption);
+				}
+				
+				for(StringParameterType prop: task.getDescription().getExecution().getResourceConsumptionProfile()[0].getProperties()){
+					if(prop.getName().equals("usefulWork")){
+						usefulWork = Double.valueOf(prop.getContent()).longValue();
+						break;
+					}
+				}
+			}
+		}
+		
+		usefulWork = (usefulWork != -1) ? usefulWork : this.getLength();
+		this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList);
+		this.resourceConsumptionProfile.setUsefulWork(usefulWork);
+
+	}
+
+	private boolean loadResourceConsumptionProfile(){
+
+		PEUnit peUnit = (PEUnit)getUsedResources().getLast().getResourceUnits()
+				.get(StandardResourceUnitName.PE);
+		if(peUnit instanceof ProcessingElements){
+			ProcessingElements pes = (ProcessingElements) peUnit;
+			for (ComputingResource resource : pes) {
+				while(resource != null && resource.getResourceCharacteristic().getParameters().get("product") == null){
+					resource = resource.getParent();
+				}
+				if(resource != null) {
+					String productName = resource.getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+					if(productName.equals("Fusion G - T40N"))
+						preparePhases("amdf");
+					else if(productName.equals("Atom - D510"))
+						preparePhases("atom64");
+					else if(productName.equals("Atom - N2600"))
+						preparePhases("atom64");
+					else if(productName.equals("Core i7 - 2715QE"))
+						preparePhases("i7-2715QE");
+					else if(productName.equals("Core i7 - 3615QE"))
+						preparePhases("i7-3615QE");
+				}
+				return true;
+			}
+		}
+		return false;
+		
+	}
 }
Index: DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java
===================================================================
--- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java	(revision 1191)
+++ DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java	(revision 1207)
@@ -5,4 +5,5 @@
 import schedframe.scheduling.tasks.TaskInterface;
 import schedframe.scheduling.tasks.phases.ResourceConsumption;
+import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
 
@@ -15,4 +16,5 @@
 	public List<String> getVisitedResources();
 	
+	public ResourceConsumptionProfile getResourceConsumptionProfile();
 	public ResourceConsumption getCurrentResourceConsumption();
 }
Index: DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java	(revision 1160)
+++ DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java	(revision 1207)
@@ -22,7 +22,4 @@
 import org.apache.commons.logging.LogFactory;
 import org.joda.time.DateTime;
-import org.qcg.broker.schemas.jobdesc.ParentType;
-import org.qcg.broker.schemas.jobdesc.Workflow;
-import org.qcg.broker.schemas.jobdesc.types.TaskStatesName;
 
 import qcg.shared.constants.BrokerConstants;
@@ -244,5 +241,4 @@
 			
 		}
-		System.out.println("finished sending jobs");
 	}
 	
Index: DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java	(revision 1131)
+++ DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java	(revision 1207)
@@ -19,4 +19,5 @@
 import javax.xml.xpath.XPathExpressionException;
 
+import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription;
 import dcworms.schedframe.scheduling.utils.JobDescription;
 import dcworms.schedframe.scheduling.utils.TaskDescription;
@@ -35,5 +36,6 @@
 		String value = 
 			//"org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
-			"org.apache.xalan.processor.TransformerFactoryImpl";
+			//"org.apache.xalan.processor.TransformerFactoryImpl";
+			"net.sf.saxon.TransformerFactoryImpl";
 		Properties props = System.getProperties();
 		props.put(key, value);
@@ -191,4 +193,9 @@
 	}
 	
+	public ApplicationProfileDescription getApplicationProfileDescription(String xmlJob){
+		ApplicationProfileDescription appProfDesc = new  ApplicationProfileDescription(xmlJob);
+		return appProfDesc;
+	}
+	
 	public String extractJobId(String job){
 		Transformer t = null;
Index: DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java	(revision 1207)
@@ -18,5 +18,5 @@
 public class EnvironmentWrapper {
 
-	Environment environment;
+	private Environment environment;
 
 	public void wrap(Environment environment) {
@@ -53,6 +53,4 @@
 	public ComputingResource[] getComputingResources() throws UnknownParameter{
 		
-		ArrayList<ComputingResource>tab = null;
-		
 		if(environment == null)
 			throw new UnknownParameter("Environment parameters are not defined.");
@@ -61,14 +59,14 @@
 			return null;
 		
-		tab = new ArrayList<ComputingResource>();
+		ArrayList<ComputingResource> computingResources = new ArrayList<ComputingResource>();
 		 
 		for(int i = 0; i < resources.getComputingResourceCount(); i++){
 			ComputingResource compRes = resources.getComputingResource(i);
-			tab.add(compRes);
+			computingResources.add(compRes);
 		}
-		if(tab.size() == 0)
+		if(computingResources.size() == 0)
 			return null;
 		else
-			return tab.toArray(new ComputingResource[0]);
+			return computingResources.toArray(new ComputingResource[0]);
 	}
 	
Index: DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java	(revision 1042)
+++ DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java	(revision 1207)
@@ -1,5 +1,3 @@
 package simulator.reader;
-
-import gridsim.ResourceCalendar;
 
 import java.io.File;
@@ -19,4 +17,5 @@
 import java.util.Set;
 
+import org.apache.commons.io.FilenameUtils;
 import org.exolab.castor.xml.MarshalException;
 import org.exolab.castor.xml.ValidationException;
@@ -26,12 +25,14 @@
 import schedframe.Parameter;
 import schedframe.Parameters;
-import schedframe.ResourceController;
+import schedframe.SimulatedEnvironment;
 import schedframe.exceptions.ResourceException;
+import schedframe.resources.CoolEmAllResourceFactory;
 import schedframe.resources.Resource;
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.ResourceFactory;
-import schedframe.resources.computing.description.AbstractResourceDescription;
+import schedframe.resources.computing.StandardResourceFactory;
 import schedframe.resources.computing.description.ComputingResourceDescription;
+import schedframe.resources.computing.description.ResourceDescription;
 import schedframe.resources.units.ResourceUnit;
 import schedframe.resources.units.ResourceUnitName;
@@ -45,41 +46,55 @@
 import schemas.ManagedComputingResources;
 import schemas.StringValueWithUnit;
-import simulator.ConfigurationOptions;
+import simulator.DataCenterWorkloadSimulator;
 import simulator.utils.InstanceFactory;
+import test.DEBBTranslator.src.PLMXMLTranslator;
 
 public class ResourceReader {
 	
 	private static String COOLEMALL_RESDESC_PREFIX = "DCWORMS";
-	protected String resDescFileName;
-
-	protected ResourceCalendar resourceCalendar;
-	protected List<Initializable> toInit = new ArrayList<Initializable>();
-	
+	private String resDescFileName;
+	private ResourceFactory resFactory;
+		
 	private ExecutionTimeEstimationPlugin execTimeEstimationPlugin;
-	private String globalSchedulingPluginName;
 	
 	private Set<String> compResLayers;
-	
-	public ResourceReader(ConfigurationOptions options) throws IOException {
-
-		resDescFileName = options.resdescFileName;
-		globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin";
-		prepareCalendar();
-		compResLayers = new LinkedHashSet<String>();
-	}
-
-	public ResourceController read() throws MarshalException, ValidationException, FileNotFoundException, Exception,
+	private List<Initializable> toInit;
+	
+	public ResourceReader(String resdescFileName) throws IOException {
+
+		this.resDescFileName = resdescFileName;
+		this.resFactory = new StandardResourceFactory();
+		this.compResLayers = new LinkedHashSet<String>();
+		this.toInit = new ArrayList<Initializable>();
+	}
+
+	public SimulatedEnvironment read() throws MarshalException, ValidationException, FileNotFoundException, Exception,
 			UnknownParameter {
 
 		File file = new File(resDescFileName);
-		
-		Environment env;
+
+		Environment env = null;
 		try{
 			env = Environment.unmarshal(new FileReader(file));
+			
 		} catch (Exception e){	
-			File dcwormsFile = new File(file.getParent() + "/" + COOLEMALL_RESDESC_PREFIX + "_" + file.getName());
-			env = Environment.unmarshal(new FileReader(dcwormsFile));
-		}
-		
+			//e.printStackTrace();
+			try{
+				File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName());
+				env = Environment.unmarshal(new FileReader(dcwormsFile));
+			} catch (Exception e2){
+				PLMXMLTranslator plmxmlTranslator = new PLMXMLTranslator();
+				String trasnlatedFileName = plmxmlTranslator.translate(new String[]{file.getAbsolutePath()});
+				File dcwormsFile = new File(trasnlatedFileName);			
+				//File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName());
+
+				env = Environment.unmarshal(new FileReader(dcwormsFile));
+			}
+		}
+		
+		if(env.getResources().getMode().equals("CoolEmAll")){
+			DataCenterWorkloadSimulator.MODE = "CoolEmAll";
+			resFactory = new CoolEmAllResourceFactory();
+		}
 		System.out.println("started creating environment description");
 		List<ComputingResourceDescription> mainCompResDescList = createEnvironmentDescription(env);
@@ -94,9 +109,9 @@
 		System.out.println("finished creating schedulers");
 
-		ResourceController rc = new ResourceController(mainScheduler, computingResources);
+		SimulatedEnvironment simEnv = new SimulatedEnvironment(mainScheduler, computingResources);
 		Collections.sort(toInit, new ResourceTypeComparator(new ArrayList<String>(compResLayers)));
-		rc.setInitList(toInit);
-		rc.setCompResLayers(compResLayers);
-		return rc;
+		simEnv.setInitList(toInit);
+		simEnv.setCompResLayers(compResLayers);
+		return simEnv;
 	}
 
@@ -181,5 +196,5 @@
 		
 		for(ComputingResourceDescription mainExecResDes : mainCompResDesList){
-			ComputingResource mainResource = ResourceFactory.createResource(mainExecResDes);
+			ComputingResource mainResource = resFactory.createComputingResource(mainExecResDes);
 			toExamine.push(mainExecResDes);
 			resStructure.push(mainResource);
@@ -192,5 +207,5 @@
 			toInit.add(parentResource);
 			compResLayers.add(parentResource.getType().getName());
-			List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren();
+			List<ResourceDescription> childrenResDesc = parentResDesc.getChildren();
 			if (childrenResDesc == null){
 				continue;
@@ -200,5 +215,5 @@
 				ComputingResourceDescription compResDesc = (ComputingResourceDescription) childrenResDesc.get(i);
 				toExamine.push(compResDesc);
-				ComputingResource resource = ResourceFactory.createResource(compResDesc);
+				ComputingResource resource = resFactory.createComputingResource(compResDesc);
 				parentResource.addChild(resource);
 				resStructure.push(resource);
@@ -254,17 +269,5 @@
 		}
 		else{
-			SchedulingPlugin schedulingPlugin = (SchedulingPlugin) InstanceFactory.createInstance(globalSchedulingPluginName,
-					SchedulingPlugin.class);
-			TaskQueueList queues = new TaskQueueList(1);
-			TaskQueue queue = new TaskQueue(false);
-			queues.add(queue);
-			ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>());
-			mainScheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin , execTimeEstimationPlugin,  queues, managedResources);
-
-			for(Scheduler lr: mainSchedulers){
-				mainScheduler.addChild(lr);
-			}
-			//necessary if children list isn't initialized in Scheduler
-			//mainScheduler.init();
+			throw new Exception("Worng schedule definition");
 		}
 		return mainScheduler;
@@ -332,7 +335,7 @@
 		//TODO - refactor (create scheduler in 1 line)
 		if(schedulerDef.getClazz().equals("GridBroker")){
-			scheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources);
+			scheduler = resFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources);
 		} else {
-			scheduler = ResourceFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin,  queues, managedResources);
+			scheduler = resFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin,  queues, managedResources);
 		}
 		return scheduler;
@@ -374,5 +377,5 @@
 				ComputingResource computingResource;
 				try {
-					if(resourceName.equals(mainCompRes.getName()))
+					if(mainCompRes.getFullName().contains(resourceName))
 						computingResource = mainCompRes;
 					else
@@ -421,22 +424,5 @@
 		return resourceUnits;
 	}
-	
-	private void prepareCalendar() {
-		long seed = 11L * 13L * 17L * 19L * 23L + 1L;
-		double timeZone = 0.0;
-		double peakLoad = 0.0; // the resource load during peak hour
-		double offPeakLoad = 0.0; // the resource load during off-peak hr
-		double holidayLoad = 0.0; // the resource load during holiday
-
-		// incorporates weekends so the grid resource is on 7 days a week
-		LinkedList<Integer> Weekends = new LinkedList<Integer>();
-		Weekends.add(java.util.Calendar.SATURDAY);
-		Weekends.add(java.util.Calendar.SUNDAY);
-
-		// incorporates holidays. However, no holidays are set in this example
-		LinkedList<Integer> Holidays = new LinkedList<Integer>();
-		resourceCalendar = new ResourceCalendar(timeZone, peakLoad, offPeakLoad, holidayLoad, Weekends, Holidays,
-				seed);
-	}
+
 	
 	class ResourceTypeComparator implements Comparator<Initializable>{
Index: DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java	(revision 1202)
+++ DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java	(revision 1207)
@@ -221,5 +221,5 @@
 					
 				case SWFFields.DATA_EXECUTABLE_NUMBER:
-					String pathToAppProfile = waParser.getAppMapping().get(String.valueOf(value));
+					String pathToAppProfile = waParser.getAppProfilesLocation().get(String.valueOf(value));
 					String appName = null;
 					if(pathToAppProfile == null){
Index: DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java	(revision 1163)
+++ DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java	(revision 1207)
@@ -15,9 +15,11 @@
 
 import simulator.workload.reader.archive.swf.SWFFields;
+
+import org.qcg.broker.schemas.jobdesc.FileType;
 import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType;
 import org.qcg.broker.schemas.jobdesc.Task;
 import org.qcg.broker.schemas.jobdesc.Workflow;
 
-import dcworms.schedframe.scheduling.utils.JobDescription;
+import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription;
 
 /**
@@ -116,5 +118,5 @@
 	}
 
-	public String mergeSwfAndXmlProfile(Map<String, JobDescription> applicationProfilesMap, String swfJobDesc) throws IOException{
+	public String mergeSwfAndAppProfile(Map<String, ApplicationProfileDescription> applicationProfiles, String swfJobDesc) throws IOException{
 		
 		StringReader reader = new StringReader(swfJobDesc);
@@ -132,12 +134,13 @@
 		for(int i = 0; i < job.getTaskCount(); i++){
 			try {
-				JobDescription xmlJobDescription = applicationProfilesMap.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent());
-				if(xmlJobDescription != null){
-					for(int j = 0; j < xmlJobDescription.size(); j++){
-						Task patternTask = xmlJobDescription.getDescription().getTask(j);
-						if(patternTask != null){
-							ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile();
-							job.getTask(j).getExecution().setResourceConsumptionProfile(rcp);
-						}
+				ApplicationProfileDescription appProfileDescription = applicationProfiles.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent());
+				if(appProfileDescription != null){
+					Task patternTask = appProfileDescription.getDescription();
+					if(patternTask != null){
+						ResourceConsumptionProfileType[] rcp = patternTask.getExecution().getResourceConsumptionProfile();
+						job.getTask(i).getExecution().setResourceConsumptionProfile(rcp);
+						FileType script = new FileType();
+						script.setName(patternTask.getId());
+						job.getTask(i).getExecution().addStdin(script);
 					}
 				}	
Index: DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java	(revision 1144)
+++ DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java	(revision 1207)
@@ -45,4 +45,4 @@
 	public int getType();
 	
-	public Map<String, String> getAppMapping();
+	public Map<String, String> getAppProfilesLocation();
 }
Index: DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java	(revision 1144)
+++ DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java	(revision 1207)
@@ -33,5 +33,5 @@
 	protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id
 	protected HashMap<String, Long> jobIndex;
-	protected HashMap<String, String> appMapping;
+	protected HashMap<String, String> appProfilesLocation;
 	protected String fields[];
 	protected int fieldsNo;
@@ -46,8 +46,9 @@
 		this.reverseIdMapping = new HashMap<String, String>();
 		this.jobIndex = new HashMap<String, Long>();
-		this.appMapping = new HashMap<String, String>();
+		this.appProfilesLocation = new HashMap<String, String>();
 		this.headerLoaded = false;
 		this.buildIndex = true;
 		this.fieldsNo = 18;
+		
 	}
 
@@ -152,5 +153,5 @@
 				String appId = valueData[0];
 				String pathToAppProfile = valueData[1];
-				appMapping.put(appId, pathToAppProfile);
+				appProfilesLocation.put(appId, pathToAppProfile);
 				continue;
 			}
@@ -296,6 +297,6 @@
 	
 	
-	public Map<String, String> getAppMapping() {
-		return appMapping;
+	public Map<String, String> getAppProfilesLocation() {
+		return appProfilesLocation;
 	}
 	
Index: DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java	(revision 1170)
+++ DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java	(revision 1207)
@@ -17,4 +17,5 @@
 import javax.xml.xpath.XPathExpressionException;
 
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -32,4 +33,5 @@
 import simulator.workload.reader.archive.swf.SWFFields;
 import simulator.workload.reader.xmlJob.XMLJobReader;
+import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription;
 import dcworms.schedframe.scheduling.utils.JobDescription;
 import dcworms.schedframe.scheduling.utils.TaskDescription;
@@ -56,7 +58,9 @@
 	
 	protected Map<String, JobDescription> jobsMap;
-	protected Map<String, JobDescription> applicationProfilesMap;
-
-	public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader){
+	
+	protected String appProfilesFolder;
+	protected Map<String, ApplicationProfileDescription> applicationProfiles;
+
+	public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader, String appProfilesFolder){
 		if(swfReader == null){
 			throw new RuntimeException("Swf reader is required to build proper tasks.");
@@ -67,5 +71,6 @@
 		this.generatedTasksCnt = 0;
 		this.jobsMap = new TreeMap<String, JobDescription>();
-		this.applicationProfilesMap = new TreeMap<String, JobDescription>();
+		this.appProfilesFolder = appProfilesFolder;
+		this.applicationProfiles = new TreeMap<String, ApplicationProfileDescription>();
 		try {
 			this.xsltTransformation = new XsltTransformations();
@@ -187,55 +192,30 @@
 
 		// determine which reader should be used
-		String jobDesc = null;
-		JobDescription job = null;
-			
+		String xmlJob = null;
+		JobDescription jobDesc = null;
+			
+		for(String key: waReader.getParser().getAppProfilesLocation().keySet()){
+			String xmlApp = loadApplicationProfile(waReader.getParser().getAppProfilesLocation().get(key));
+			xmlApp = this.xsltTransformation.extendJobDescription(xmlApp);
+			ApplicationProfileDescription app = this.xsltTransformation.getApplicationProfileDescription(xmlApp);
+			this.applicationProfiles.put(key, app);
+		}
+		
 		if(this.xmlJobReader != null){ // use xml job reader. Xml job require xslt transformation
-			while((jobDesc = this.xmlJobReader.readRaw()) != null){
-				jobDesc = this.xsltTransformation.extendJobDescription(jobDesc);
-				job = createJobDescription(jobDesc, puSpeed);
-				if(job != null)
-					this.jobsMap.put(job.getJobId(), job);
+			while((xmlJob = this.xmlJobReader.readRaw()) != null){
+				xmlJob = this.xsltTransformation.extendJobDescription(xmlJob);
+				jobDesc = createJobDescription(xmlJob, puSpeed);
+				if(jobDesc != null)
+					this.jobsMap.put(jobDesc.getJobId(), jobDesc);
 			}
 		} else {						// use swf job reader. Job created by this reader does not require xslt transformation
 			
-			for(String key: waReader.getParser().getAppMapping().keySet()){
-				jobDesc = loadApplicationProfile(waReader.getParser().getAppMapping().get(key));
-				jobDesc = this.xsltTransformation.extendJobDescription(jobDesc);
-					
-				try {
-					job = this.xsltTransformation.splitJobToTasks(jobDesc);
-				} catch (Exception e) {
-					throw new IOException(e.getMessage());
-				}
-				
-				this.applicationProfilesMap.put(key, job);
-			}
-			
-			while((jobDesc = this.waReader.readRaw()) != null){
+			while((xmlJob = this.waReader.readRaw()) != null){
 				QcgWAJobReader qcgReader = (QcgWAJobReader)waReader;
-				if(!applicationProfilesMap.isEmpty())
-					jobDesc = qcgReader.mergeSwfAndXmlProfile(applicationProfilesMap, jobDesc);
-				job = createJobDescription(jobDesc, puSpeed);
-				/*if(job!= null && !applicationProfilesMap.isEmpty()){
-					for(int i = 0; i < job.getDescription().getTaskCount(); i++){
-						try {
-							JobDescription xmlJobDescription = applicationProfilesMap.get(job.getDescription().getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent());
-							if(xmlJobDescription != null){
-								for(int j = 0; j < xmlJobDescription.size(); j++){
-									Task patternTask = xmlJobDescription.getDescription().getTask(j);
-									if(patternTask != null){
-										ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile();
-										job.getDescription().getTask(j).getExecution().setResourceConsumptionProfile(rcp);
-									}
-								}
-							}	
-						} catch (Exception e){
-							continue;
-						}
-					}					
-				}
-				*/
-				if(job != null)
-					this.jobsMap.put(job.getJobId(), job);
+				if(!applicationProfiles.isEmpty())
+					xmlJob = qcgReader.mergeSwfAndAppProfile(applicationProfiles, xmlJob);
+				jobDesc = createJobDescription(xmlJob, puSpeed);
+				if(jobDesc != null)
+					this.jobsMap.put(jobDesc.getJobId(), jobDesc);
 			}
 		}
@@ -302,11 +282,20 @@
 	}
 
-	public String loadApplicationProfile(String fileName) throws IOException{
+	public String loadApplicationProfile(String pathToAppProfile) throws IOException{
 		
 		BufferedReader reader = null;
 		StringBuffer buffer = new StringBuffer();
 
-		try {
-			reader = new BufferedReader(new FileReader(fileName));
+		String localPathToAppProfile;
+		
+		if(appProfilesFolder != null) {
+			String folderName = FilenameUtils.getFullPath(appProfilesFolder);
+			String fileName = FilenameUtils.getName(pathToAppProfile);
+			localPathToAppProfile = folderName + fileName;
+		} else {
+			localPathToAppProfile = pathToAppProfile;
+		}
+		try {
+			reader = new BufferedReader(new FileReader(localPathToAppProfile ));
 			String line = null;
 			
Index: DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java	(revision 802)
+++ DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java	(revision 1207)
@@ -52,5 +52,6 @@
 	public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER
 			+ ".inputfolder";
-	
+	/** The input folder with application profiles */
+	public static final String READ_SCENARIO_APPLCIATION_PROFILES = READ_SCENARIO_MODIFIER + ".applicationProfiles";
 	/** The name of the workload file */
 	public static final String READ_SCENARIO_WORKLOAD_FILE = READ_SCENARIO_MODIFIER
@@ -79,8 +80,12 @@
 	public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs";
 	public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation";
-	
-	public static final String COOLEMALL = "coolemall";
-	public static final String COOLEMALL_RESOURCE = COOLEMALL + ".resdesc";
-
+
+	public static final String PRESSURE_DROP = "pressuredrop";
+	public static final String OUTLET_ROOM_AIR_TEMPERATURE = "outletroomairtemperature";
+	public static final String INLET_ROOM_AIR_TEMPERATURE = "inletroomairtemperature";
+	public static final String AMBIENT_AIR_TEMPERATURE = "ambientairtemperature";
+	public static final String AIR_FLOW_VOLUME = "airflowvolume";
+	public static final String ALPHA = "alpha";
+	
 	/**
 	 * The main output folders base name
@@ -101,5 +106,5 @@
 	 * Suffix for read scenario output folder
 	 */
-	public String statsOutputSubfolderNameRerad = null;
+	public String statsOutputSubfolderNameRead = null;
 	
 	/* =============================================================================================== */
@@ -137,4 +142,6 @@
 	 */
 	public String inputFolder = null;
+	
+	public String appProfilesFolder = null;
 	
 	public String inputTar = null;
@@ -184,6 +191,11 @@
 	public String [] resForUtilizationChart;
 	
-	public String coolEmAllResdescFileName = null;
-
+	public static double pressureDrop;
+	public static double outletRoomAirTempeature;
+	public static double inletRoomAirTempeature;
+	public static double ambientAirTempeature;
+	public static double airFlowVolume;
+	public static double alpha
+	;
 	/**
 	 * An empty constructor.
@@ -255,4 +267,11 @@
 			
 			try {
+				co.appProfilesFolder  = getSeparatorTerminatedPath(bundle
+					.getString(READ_SCENARIO_APPLCIATION_PROFILES));
+			} catch (MissingResourceException e) {
+				co.appProfilesFolder  = null;
+			}
+			
+			try {
 				co.inputWorkloadFileName = bundle
 						.getString(READ_SCENARIO_WORKLOAD_FILE);
@@ -346,8 +365,8 @@
 		try {
 			co.statsOutputSubfolderNameCreate = bundle.getString(STATS_OUTPUT_SUBFOLDER_NAME);
-			co.statsOutputSubfolderNameRerad = co.statsOutputSubfolderNameCreate;
+			co.statsOutputSubfolderNameRead = co.statsOutputSubfolderNameCreate;
 		} catch(MissingResourceException e){
 			co.statsOutputSubfolderNameCreate = "stats_create";
-			co.statsOutputSubfolderNameRerad = "stats_read";
+			co.statsOutputSubfolderNameRead = "stats_read";
 		}
 
@@ -370,11 +389,41 @@
 			co.numberOfSimulations = 1;
 		}
-		
-		try {
-			co.coolEmAllResdescFileName = bundle.getString(COOLEMALL_RESOURCE);
-			System.setProperty("coolemall.resdesc", co.coolEmAllResdescFileName);
-		} catch(MissingResourceException e){
-			co.coolEmAllResdescFileName = null;
-		}
+
+		try {
+			ConfigurationOptions.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue();
+		} catch(MissingResourceException e){
+			ConfigurationOptions.pressureDrop = 175.337;
+		}
+		
+		try {
+			ConfigurationOptions.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue();
+		} catch(MissingResourceException e){
+			ConfigurationOptions.outletRoomAirTempeature = 23;
+		}
+		
+		try {
+			ConfigurationOptions.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue();
+		} catch(MissingResourceException e){
+			ConfigurationOptions.inletRoomAirTempeature = 17;
+		}
+		
+		try {
+			ConfigurationOptions.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue();
+		} catch(MissingResourceException e){
+			ConfigurationOptions.ambientAirTempeature = 17;
+		}
+		
+		try {
+			ConfigurationOptions.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue();
+		} catch(MissingResourceException e){
+			ConfigurationOptions.airFlowVolume = 0.304;
+		}
+		
+		try {
+			ConfigurationOptions.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue();
+		} catch(MissingResourceException e){
+			ConfigurationOptions.alpha = 0.02;
+		}
+		
 		return co;
 	}
Index: DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java	(revision 1142)
+++ DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java	(revision 1207)
@@ -14,4 +14,5 @@
 import javax.swing.filechooser.FileFilter;
 
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -21,5 +22,5 @@
 
 import schedframe.Initializable;
-import schedframe.ResourceController;
+import schedframe.SimulatedEnvironment;
 import simulator.reader.ResourceReader;
 import simulator.stats.AccumulatedStatistics;
@@ -51,5 +52,10 @@
 	 * The name of the simulator application
 	 */
-	public static final String SIMULATOR_NAME = "Data Center Workload Simulator";
+	public static final String SIMULATOR_NAME = "Data Center Workload and Resource Management Simulator";
+	
+	/**
+	 * The simulation mode
+	 */
+	public static String MODE = "Standard";
 
 	/**
@@ -183,7 +189,9 @@
 		}
 
-		if (log.isInfoEnabled())
+		if (log.isInfoEnabled()){
 			log.info("Done :: " + SIMULATOR_NAME + " has finished "
 					+ noOfSimulations + " simulation runs ::");
+			log.info("Simulation finished with status: 0");
+		}
 
 		System.out.flush();
@@ -259,6 +267,6 @@
 
 		ResourceReader resourceReader = new ResourceReader(
-				options);
-		ResourceController rc = resourceReader.read();
+				options.resdescFileName);
+		SimulatedEnvironment rc = resourceReader.read();
 		eventManager = new EventManager("eventManager", rc);
 		
@@ -268,12 +276,16 @@
 		rc.setInitList(null);
 		
-		DCWormsUsers wl = new DCWormsUsers("Users",
+		DCWormsUsers users = new DCWormsUsers("Users",
 				rc.getScheduler().get_name(), workload);
 		
+		System.out.println("Starting simulation...");
+
 		GridSimWrapper.startSimulation();
 		long stopSimulation = System.currentTimeMillis();
 
+		System.out.println("Simulation finished");
+
 		DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier,
-				options, wl, statsOutputPath, rc);
+				options, users, statsOutputPath, rc);
 		accumulatedStatistics.add(stats);
 		if (log.isInfoEnabled())
@@ -301,4 +313,5 @@
 		String wlFileName = options.inputWorkloadFileName;
 
+		String appProfilesFolder = options.appProfilesFolder;
 		if (options.inputFolder != null) {
 			File f = null;
@@ -318,5 +331,5 @@
 		swfReader = AbstractWAReader.getInstace(wlFileName);
 
-		WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader);
+		WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder);
 		workload.load();
 
@@ -346,10 +359,11 @@
 				prefix = options.inputFolder;
 			} else if (options.inputWorkloadFileName != null) {
-				prefix = new File(options.inputWorkloadFileName).getParent();
+				prefix = FilenameUtils.getFullPath(new File(options.inputWorkloadFileName).getAbsolutePath());
 			} else {
 				prefix = System.getProperty("user.dir");
 			}
-			statsOutputPath = prefix + File.separator
-					+ options.statsOutputSubfolderNameRerad;
+			//statsOutputPath = prefix + File.separator
+			//		+ options.statsOutputSubfolderNameRead;
+			statsOutputPath = options.statsOutputSubfolderNameRead;
 		}
 		statsOutputPath += File.separator;
Index: DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java	(revision 1207)
@@ -0,0 +1,455 @@
+package simulator.stats;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import simulator.stats.implementation.MetricsStats;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+
+public class MetricsCalculator {
+	
+	protected static final double MILLI_SEC = 1000;
+	protected static final double SEC_IN_HOUR = 3600;
+	
+	protected Map<String, List<GSSAccumulator>> metricsData = new HashMap<String, List<GSSAccumulator>>();
+	protected long timestamp;
+	protected long startTime;
+	protected long endTime;
+
+	public List<MetricsStats> calulateMetrics(long timestamp){
+		this.timestamp = timestamp;
+		List<MetricsStats> metrics = new ArrayList<MetricsStats>();
+		/*for(String resourceTypeName: metricsData.keySet()){
+			MetricsStats metric = new MetricsStats(resourceTypeName, "energyUsage", metricsData.get(resourceTypeName).getMax());
+			metrics.add(metric);}
+		}*/
+		metrics.add(calculateITComputingEnergyConsumption());
+		metrics.add(calculateITEnergyConsumption());
+		metrics.add(calculateNodeGroupFansEnergyConsumption());
+		
+		metrics.add(calculateRackEnergyConsumption());
+		metrics.add(calculateDataCenterFansEnergyConsumption());
+		metrics.add(calculateCoolingDeviceEnergyConsumption());
+		metrics.add(calculateOtherDevicesEnergyConsumption());
+		
+		metrics.add(calculateTotalEnergyConsumption());
+		
+		metrics.add(calculateMeanRackPower());
+		metrics.add(calculateMeanPower());
+		metrics.add(calculateMaxRackPower());
+		metrics.add(calculateMaxPower());
+		
+		metrics.add(calculatePUE());
+		metrics.add(calculatePUELevel4());
+		metrics.add(calculateEnergyWasteRate());
+		
+		metrics.add(calculateUsefulWork());
+		metrics.add(calculateProductivity());
+
+		return metrics;
+	}
+	
+	public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator){
+		List<GSSAccumulator> resourceEnergyAccumulatorList = metricsData.get(resourceTypeName);
+		if(resourceEnergyAccumulatorList == null){
+			resourceEnergyAccumulatorList = new ArrayList<GSSAccumulator>();
+		}
+		resourceEnergyAccumulatorList.add(resourceEnergyAccumulator);
+		metricsData.put(resourceTypeName, resourceEnergyAccumulatorList);
+	}
+	
+	public Map<String, List<GSSAccumulator>> getMetricsData(){
+		return metricsData;
+	}
+	
+	private MetricsStats calculateTotalEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", roomPower, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateITComputingEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", (itComputingPower), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateITEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double totalSitePower = 0; 
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double fanPowerConumspion = nodeComputingPower - itComputingPower;
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", (totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - fanPowerConumspion), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateNodeGroupFansEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", nodeGroupFansPowerConumspion, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculatePUELevel4(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			
+			double totalSitePower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			
+		
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", roomPower/(totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", -1, timestamp, "");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculatePUE(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			
+			double totalSitePower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+
+
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE", roomPower/totalSitePower, timestamp, "");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "PUE", -1, timestamp, "");
+		}
+		return metric;
+	}
+
+	private MetricsStats calculateUsefulWork(){
+		
+		MetricsStats metric;
+		try{
+			double usefulWork = 0;
+			for(String key: metricsData.keySet()){
+				if(key.contains("/")){
+					for(GSSAccumulator acc: metricsData.get(key)){
+						usefulWork= usefulWork + acc.getSum();
+					}
+				}
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", usefulWork, timestamp, "UW units");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", -1, timestamp, "UW units");
+		}
+		
+		return metric;
+	}
+	
+	private MetricsStats calculateProductivity(){
+		
+		MetricsStats metric;
+		try{
+			double usefulWork = 0;
+			for(String key: metricsData.keySet()){
+				if(key.contains("/")){
+					for(GSSAccumulator acc: metricsData.get(key)){
+						usefulWork= usefulWork + acc.getSum();
+					}
+				}
+			}
+			double totalSitePower = 0; 
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			
+			metric = new MetricsStats("CoolEmAllTestbed", "Productivity", usefulWork/totalSitePower, timestamp, "UW units/Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Productivity", -1, timestamp, "UW units/Wh");
+		}
+		
+		return metric;
+	}
+	
+	
+	private MetricsStats calculateMaxRackPower(){
+		
+		MetricsStats metric;
+		try{
+			double maxPower = 0;
+			
+			for(GSSAccumulator acc: metricsData.get("Rack_MAX")){
+				maxPower = maxPower + acc.getSum();
+			}
+
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", maxPower, timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", -1, timestamp, "W");
+		}
+		
+		return metric;
+	}
+	
+	private MetricsStats calculateMaxPower(){
+		
+		MetricsStats metric;
+		try{
+			double maxPower = 0;
+			
+			for(GSSAccumulator acc: metricsData.get("Room_MAX")){
+				maxPower = maxPower + acc.getSum();
+			}
+
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_power", maxPower, timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Max_power", -1, timestamp, "W");
+		}
+		
+		return metric;
+	}
+	
+	private MetricsStats calculateDataCenterFansEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double inletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Inlet")){
+				inletsPower = inletsPower + acc.getSum();
+			}
+			
+			double outletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Outlet")){
+				outletsPower = outletsPower + acc.getSum();
+			}
+			
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+			
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (inletsPower + outletsPower - nodeGroupFansPowerConumspion), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	
+	private MetricsStats calculateRackEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", roomPower, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_device_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateCoolingDeviceEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double coolingDevicePower = 0;
+			for(GSSAccumulator acc: metricsData.get("CoolingDevice")){
+				coolingDevicePower = coolingDevicePower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", coolingDevicePower, timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateOtherDevicesEnergyConsumption(){
+		
+		MetricsStats metric;
+		try{
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			
+			double totalSitePower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				totalSitePower = totalSitePower + acc.getSum();
+			}
+			
+			double coolingDevicePower = 0;
+			for(GSSAccumulator acc: metricsData.get("CoolingDevice")){
+				coolingDevicePower = coolingDevicePower + acc.getSum();
+			}
+			
+			double inletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Inlet")){
+				inletsPower = inletsPower + acc.getSum();
+			}
+			
+			double outletsPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Outlet")){
+				outletsPower = outletsPower + acc.getSum();
+			}
+			
+			double nodeComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Node")){
+				nodeComputingPower = nodeComputingPower+ acc.getSum();
+			}
+			double itComputingPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor")){
+				itComputingPower = itComputingPower + acc.getSum();
+			}
+			double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;
+			
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", roomPower - (totalSitePower + coolingDevicePower + (inletsPower + outletsPower - nodeGroupFansPowerConumspion)), timestamp, "Wh");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_consumption", -1, timestamp, "Wh");
+		}
+		return metric;
+	}
+
+	
+	private MetricsStats calculateMeanPower(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Room")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", -1, timestamp, "W");
+		}
+		return metric;
+	}
+	
+	
+	private MetricsStats calculateMeanRackPower(){
+		
+		MetricsStats metric;
+		try{
+			
+			double roomPower = 0;
+			for(GSSAccumulator acc: metricsData.get("Rack")){
+				roomPower = roomPower + acc.getSum();
+			}
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", -1, timestamp, "W");
+		}
+		return metric;
+	}
+	
+	private MetricsStats calculateEnergyWasteRate(){
+		
+		MetricsStats metric;
+		try{
+			double itComputingEnergy = 0;
+			for(GSSAccumulator acc: metricsData.get("Processor_CALC")){
+				itComputingEnergy = itComputingEnergy + acc.getSum();
+			}
+			itComputingEnergy = itComputingEnergy + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC);
+			double itEnergy = calculateITEnergyConsumption().getValue();
+			
+			metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", (1 - itComputingEnergy/itEnergy) * 100, timestamp, "%");
+		} catch (Exception e){
+			metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", -1, timestamp, "%");
+		}
+		return metric;
+	}
+	
+	public long getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(long startTime) {
+		this.startTime = startTime;
+	}
+
+	public long getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(long endTime) {
+		this.endTime = endTime;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/MetricsStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/MetricsStats.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/MetricsStats.java	(revision 1207)
@@ -0,0 +1,55 @@
+package simulator.stats.implementation;
+
+import simulator.stats.implementation.out.StatsSerializer;
+
+public class MetricsStats implements StatsInterface {
+
+	protected String resourceName;
+	protected String metricName;
+	protected double value;
+	protected long timestamp;
+	protected String unit;
+	
+	private String[] headers = { "resourceName", "metricName", "value" };
+	
+	public MetricsStats(String resourceName, String metricName, double value) {
+		this(resourceName, metricName, value, 0, "");
+	}
+
+	public MetricsStats(String resourceName, String metricName, double value, long timestamp, String unit) {
+		super();
+		this.resourceName = resourceName;
+		this.metricName = metricName;
+		this.value = value;
+		this.timestamp = timestamp;
+		this.unit = unit;
+	}
+	
+	public Object serialize(StatsSerializer serializer) {
+		return serializer.visit(this);
+	}
+
+	public String[] getHeaders() {
+		return headers;
+	}
+
+	public String getResourceName() {
+		return resourceName;
+	}
+
+	public String getMetricName() {
+		return metricName;
+	}
+
+	public double getValue() {
+		return value;
+	}
+
+	public long getTimestamp() {
+		return timestamp;
+	}
+
+	public String getUnit() {
+		return unit;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java	(revision 1140)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java	(revision 1207)
@@ -1,4 +1,5 @@
 package simulator.stats.implementation.out;
 
+import java.text.DecimalFormat;
 import java.util.Map;
 
@@ -7,9 +8,14 @@
 
 import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.ResourceHistoryChanges;
 import schedframe.resources.StandardResourceType;
+import simulator.stats.implementation.MetricsStats;
 import simulator.stats.implementation.ResourceAirFlowStats;
+import simulator.stats.implementation.ResourceAvailabilityStats;
+import simulator.stats.implementation.ResourceHistoryStats;
 import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceTemperatureStats;
 import simulator.stats.implementation.ResourceUsageStats;
+import simulator.stats.implementation.ResourceUsefulWorkStats;
 
 public class CoolEmAllStringSerializer extends StringSerializer {
@@ -19,5 +25,6 @@
 	public Object visit(ResourceUsageStats resourceUsageStats) {
 		Map<Long, Double> resourceUsage = resourceUsageStats.getHistory();
-		String cpuMetricName = "CPU_Load";
+		//String metricName = "cpu_load";
+		String metricName = resourceUsageStats.getUsageType();
 		int mapSize = resourceUsage.size();
 		/*
@@ -45,10 +52,12 @@
 		}
 		
-		if(resourceUsageStats.getResourceType().equals(StandardResourceType.Processor) || resourceUsageStats.getResourceType().equals(CoolEmAllResourceType.Processor)){
+		if(!resourceUsageStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsageStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){
 			for (Long timestamp : resourceUsage.keySet()) {
 				
-				buffer.append(cpuMetricName);
-				buffer.append(fieldSeparator);
-				buffer.append(resourceUsageStats.getResourceName());
+				buffer.append(metricName);
+				buffer.append(fieldSeparator);
+				if(resourceUsageStats.getResourceName().startsWith("/"))
+					buffer.append(resourceUsageStats.getResourceName().substring(1));
+				else buffer.append(resourceUsageStats.getResourceName());
 				buffer.append(fieldSeparator);
 				Double value = resourceUsage.get(timestamp);
@@ -73,5 +82,6 @@
 	public Object visit(ResourcePowerStats resourceEnergyStats) {
 		Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory();
-		String nodeMetricName = "RECS_Power";
+		//String nodeMetricName = "power";
+		String metricName = resourceEnergyStats.getUsageType();
 		int mapSize = resourceEnergy.size();
 		/*
@@ -98,9 +108,11 @@
 			buffer = new StringBuffer(size);
 		}
-		
-		if(resourceEnergyStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceEnergyStats.getResourceType().equals(CoolEmAllResourceType.Node)){
+		//if(resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.ComputingNode.getName()) || resourceEnergyStats.getResourceType().getName().equals(CoolEmAllResourceType.Node.getName()) || 
+				//resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName())  || resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName()) || 
+		//		resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Heatsink.getName())){
+		
 			for (Long timestamp : resourceEnergy.keySet()) {
 				
-				buffer.append(nodeMetricName);
+				buffer.append(metricName);
 				buffer.append(fieldSeparator);
 				if(resourceEnergyStats.getResourceName().startsWith("/"))
@@ -117,5 +129,5 @@
 				buffer.append(System.getProperty("line.separator"));
 			}
-		}
+	//	}
 
 		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
@@ -129,5 +141,6 @@
 	public Object visit(ResourceAirFlowStats resourceAirFlowStats) {
 		Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory();
-		String nodeMetricName = "RECS_Airflow";
+		//String nodeMetricName = "airflow_volume";
+		String metricName = resourceAirFlowStats.getUsageType();
 		int mapSize = resourceAirFlow.size();
 		/*
@@ -154,9 +167,8 @@
 			buffer = new StringBuffer(size);
 		}
-		
-		if(resourceAirFlowStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceAirFlowStats.getResourceType().equals(CoolEmAllResourceType.Node)){
+
+		if(resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName()) || resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName())){
 			for (Long timestamp : resourceAirFlow.keySet()) {
-				
-				buffer.append(nodeMetricName);
+				buffer.append(metricName);
 				buffer.append(fieldSeparator);
 				if(resourceAirFlowStats.getResourceName().startsWith("/"))
@@ -185,6 +197,9 @@
 	public Object visit(ResourceTemperatureStats resourceTemperatureStats) {
 		Map<Long, Double> resourceTemperature = resourceTemperatureStats.getHistory();
-		String nodeMetricName = "RECS_Temperature";
-		String cpuMetricName = "CPU_Temp";
+		//String nodeMetricName = "temperature";
+		//String cpuMetricName = "temperature";
+		
+		String metricName = resourceTemperatureStats.getUsageType();
+
 		int mapSize = resourceTemperature.size();
 		/*
@@ -212,17 +227,18 @@
 		}
 		
-		if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node) || 
-				resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){
-			String metricName = null;
+		if(resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Node.getName()) || resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Processor.getName())){
+			/*String metricName = null;
 			if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node)){
 				metricName = nodeMetricName;
 			} else if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){
 				metricName = cpuMetricName;
-			}
+			}*/
 			for (Long timestamp : resourceTemperature.keySet()) {
 				
 				buffer.append(metricName);
 				buffer.append(fieldSeparator);
-				buffer.append(resourceTemperatureStats.getResourceName());
+				if(resourceTemperatureStats.getResourceName().startsWith("/"))
+					buffer.append(resourceTemperatureStats.getResourceName().substring(1));
+				else buffer.append(resourceTemperatureStats.getResourceName());
 				buffer.append(fieldSeparator);
 				Double value = resourceTemperature.get(timestamp);
@@ -245,4 +261,140 @@
 	}
 
-
+	public Object visit(MetricsStats metricsStats) {
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add("metrics")) {
+			buffer = new StringBuffer(600);
+			/*String[] headers = metricsStats.getHeaders();
+			for(int i = 0; i < headers.length; i++)
+			{
+				buffer.append(headers[i]);
+				buffer.append(fieldSeparator);
+			}
+			buffer.append(System.getProperty("line.separator"));*/
+		} else {
+			buffer = new StringBuffer(300);
+		}
+		DecimalFormat df = new DecimalFormat();
+		df.setMaximumFractionDigits(3);
+		df.setGroupingUsed(false);
+		
+		buffer.append(metricsStats.getMetricName());
+		buffer.append(fieldSeparator);
+		buffer.append(metricsStats.getResourceName());
+		buffer.append(fieldSeparator);
+		buffer.append(metricsStats.getTimestamp());
+		buffer.append(fieldSeparator);
+		buffer.append(df.format(metricsStats.getValue()));
+		buffer.append(fieldSeparator);
+
+		return buffer.toString();
+	}
+	
+	public Object visit(ResourceHistoryStats arg) {
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add("metrics")) {
+			buffer = new StringBuffer(600);
+			/*String[] headers = metricsStats.getHeaders();
+			for(int i = 0; i < headers.length; i++)
+			{
+				buffer.append(headers[i]);
+				buffer.append(fieldSeparator);
+			}
+			buffer.append(System.getProperty("line.separator"));*/
+		} else {
+			buffer = new StringBuffer(300);
+		}
+		DecimalFormat df = new DecimalFormat();
+		df.setMaximumFractionDigits(3);
+		df.setGroupingUsed(false);
+		
+		for(ResourceHistoryChanges rhc: arg.getResHistChanges()){
+			buffer.append(rhc.getTimestamp());
+			buffer.append(fieldSeparator);
+			buffer.append(rhc.getResourceName());
+			buffer.append(fieldSeparator);
+			buffer.append(rhc.getOperation());
+			buffer.append(fieldSeparator);
+			buffer.append(rhc.getParamter());
+			buffer.append(fieldSeparator);
+			buffer.append(System.getProperty("line.separator"));
+		}
+
+		return buffer.toString();
+	}
+
+	public Object visit(ResourceUsefulWorkStats resourceUsefulWorkStats) {
+			
+		String metricName = resourceUsefulWorkStats.getUsageType();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add("metrics")) {
+			buffer = new StringBuffer(600);
+			/*String[] headers = metricsStats.getHeaders();
+			for(int i = 0; i < headers.length; i++)
+			{
+				buffer.append(headers[i]);
+				buffer.append(fieldSeparator);
+			}
+			buffer.append(System.getProperty("line.separator"));*/
+		} else {
+			buffer = new StringBuffer(300);
+		}
+		DecimalFormat df = new DecimalFormat();
+		df.setMaximumFractionDigits(3);
+		df.setGroupingUsed(false);
+		if(!resourceUsefulWorkStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsefulWorkStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){
+
+			buffer.append(metricName);
+			buffer.append(fieldSeparator);
+			buffer.append(resourceUsefulWorkStats.getResourceName());
+			buffer.append(fieldSeparator);
+			buffer.append(resourceUsefulWorkStats.getTimestamp());
+			buffer.append(fieldSeparator);
+			buffer.append(df.format(resourceUsefulWorkStats.getValue()));
+			buffer.append(fieldSeparator);
+			buffer.append(System.getProperty("line.separator"));
+		}
+		return buffer.toString();
+	}
+	
+
+	public Object visit(ResourceAvailabilityStats resourceAvailabilityStats) {
+		
+		String metricName = resourceAvailabilityStats.getUsageType();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add("metrics")) {
+			buffer = new StringBuffer(600);
+			/*String[] headers = metricsStats.getHeaders();
+			for(int i = 0; i < headers.length; i++)
+			{
+				buffer.append(headers[i]);
+				buffer.append(fieldSeparator);
+			}
+			buffer.append(System.getProperty("line.separator"));*/
+		} else {
+			buffer = new StringBuffer(300);
+		}
+		DecimalFormat df = new DecimalFormat();
+		df.setMaximumFractionDigits(3);
+		df.setGroupingUsed(false);
+		if(resourceAvailabilityStats.getResourceType().getName().equals(CoolEmAllResourceType.NodeGroup.getName())){
+
+			buffer.append(metricName);
+			buffer.append(fieldSeparator);
+			buffer.append(resourceAvailabilityStats.getResourceName());
+			buffer.append(fieldSeparator);
+			buffer.append(resourceAvailabilityStats.getTimestamp());
+			buffer.append(fieldSeparator);
+			buffer.append(df.format(resourceAvailabilityStats.getValue()));
+			buffer.append(fieldSeparator);
+			buffer.append(System.getProperty("line.separator"));
+		}
+		return buffer.toString();
+	}
 }
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java	(revision 805)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java	(revision 1207)
@@ -4,9 +4,13 @@
 import simulator.stats.implementation.GSSAccumulatorsStats;
 import simulator.stats.implementation.JobStats;
+import simulator.stats.implementation.MetricsStats;
 import simulator.stats.implementation.ResourceAirFlowStats;
+import simulator.stats.implementation.ResourceAvailabilityStats;
+import simulator.stats.implementation.ResourceHistoryStats;
 import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceStats;
 import simulator.stats.implementation.ResourceTemperatureStats;
 import simulator.stats.implementation.ResourceUsageStats;
+import simulator.stats.implementation.ResourceUsefulWorkStats;
 import simulator.stats.implementation.TaskStats;
 
@@ -34,5 +38,13 @@
 	public Object visit(ResourceTemperatureStats arg);
 	
+	public Object visit(ResourceUsefulWorkStats arg);
+	
 	public Object visit(GSSAccumulatorsStats arg);
 	
+	public Object visit(MetricsStats arg);
+	
+	public Object visit(ResourceHistoryStats arg);
+
+	public Object visit(ResourceAvailabilityStats resourceAvailabilityStats);
+	
 }
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java	(revision 1192)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java	(revision 1207)
@@ -11,9 +11,13 @@
 import simulator.stats.implementation.GSSAccumulatorsStats;
 import simulator.stats.implementation.JobStats;
+import simulator.stats.implementation.MetricsStats;
 import simulator.stats.implementation.ResourceAirFlowStats;
+import simulator.stats.implementation.ResourceAvailabilityStats;
+import simulator.stats.implementation.ResourceHistoryStats;
 import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceStats;
 import simulator.stats.implementation.ResourceTemperatureStats;
 import simulator.stats.implementation.ResourceUsageStats;
+import simulator.stats.implementation.ResourceUsefulWorkStats;
 import simulator.stats.implementation.TaskStats;
 
@@ -48,5 +52,4 @@
 						buffer.append(fieldSeparator);
 					}
-					
 				}
 
@@ -108,5 +111,11 @@
 					.longValue());
 			buffer.append(fieldSeparator);
-			buffer.append(taskStats.getProcessorsName());
+			buffer.append(taskStats.getHostName());
+			buffer.append(fieldSeparator);
+			buffer.append(taskStats.getProcessingElementsName());
+			buffer.append(fieldSeparator);
+			buffer.append(0);
+			buffer.append(fieldSeparator);
+			buffer.append(taskStats.getExecName());
 			buffer.append(fieldSeparator);
 		}
@@ -311,8 +320,4 @@
 		}
 		
-		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
-		if(lastIdx != -1)
-			buffer.deleteCharAt(lastIdx);
-		
 		if(resourceUsage.size() > 0){
 			buffer.append("mean: " + resourceUsageStats.getMeanValue());
@@ -373,9 +378,5 @@
 
 		}
-		
-		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
-		if(lastIdx != -1)
-			buffer.deleteCharAt(lastIdx);
-		
+
 		if(resourceEnergy.size() > 0) {
 			buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue());
@@ -437,8 +438,5 @@
 
 		}
-		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
-		if(lastIdx != -1)
-			buffer.deleteCharAt(lastIdx);
-		
+
 		if(resourceAirFlow.size() > 0) {
 			buffer.append("mean: "+resourceAirFlowStats.getMeanValue());
@@ -500,9 +498,5 @@
 
 		}
-		
-		int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));
-		if(lastIdx != -1)
-			buffer.deleteCharAt(lastIdx);
-		
+
 		if(resourceTemperature.size() > 0) {
 			buffer.append("mean: "+resourceTemperatureStats.getMeanValue());
@@ -573,3 +567,24 @@
 	}
 
+	public Object visit(MetricsStats metricsStats) {
+		StringBuffer buffer = new StringBuffer(300);
+		return buffer.toString();
+	}
+
+	public Object visit(ResourceHistoryStats arg) {
+		StringBuffer buffer = new StringBuffer(300);
+		return buffer.toString();
+	}
+
+	public Object visit(ResourceUsefulWorkStats arg) {
+		StringBuffer buffer = new StringBuffer(300);
+		return buffer.toString();
+	}
+
+	public Object visit(ResourceAvailabilityStats arg) {
+		StringBuffer buffer = new StringBuffer(300);
+		return buffer.toString();
+	}
+
+
 }
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceHistoryStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceHistoryStats.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceHistoryStats.java	(revision 1207)
@@ -0,0 +1,32 @@
+package simulator.stats.implementation;
+
+import java.util.List;
+
+import schedframe.resources.ResourceHistoryChanges;
+import simulator.stats.implementation.out.StatsSerializer;
+
+public class ResourceHistoryStats implements StatsInterface {
+
+	private String[] headers = {"timestamp", "resourceName", "operation", "parameter" };
+
+	protected List<ResourceHistoryChanges> resHistChanges;
+	
+	public ResourceHistoryStats(List<ResourceHistoryChanges> resHistChanges) {
+		super();
+		this.resHistChanges = resHistChanges;
+	}
+
+
+	public Object serialize(StatsSerializer serializer) {
+		return serializer.visit(this);
+	}
+
+	public String[] getHeaders() {
+		return headers;
+	}
+
+
+	public List<ResourceHistoryChanges> getResHistChanges() {
+		return resHistChanges;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 1199)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 1207)
@@ -7,4 +7,5 @@
 import java.io.IOException;
 import java.io.PrintStream;
+import java.text.DecimalFormat;
 import java.text.NumberFormat;
 import java.util.ArrayList;
@@ -14,6 +15,8 @@
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
@@ -54,5 +57,5 @@
 
 import schedframe.ExecutablesList;
-import schedframe.ResourceController;
+import schedframe.SimulatedEnvironment;
 import schedframe.exceptions.ResourceException;
 import schedframe.resources.ResourceType;
@@ -66,5 +69,6 @@
 import schedframe.resources.computing.profiles.energy.power.PowerUsage;
 import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue;
-import schedframe.resources.units.PEUnit;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.resources.units.ProcessingElements;
 import schedframe.resources.units.ResourceUnit;
@@ -82,7 +86,9 @@
 import simulator.GenericUser;
 import simulator.stats.GSSAccumulator;
+import simulator.stats.MetricsCalculator;
 import simulator.stats.SimulationStatistics;
 import simulator.stats.implementation.out.AbstractStringSerializer;
 import simulator.stats.implementation.out.CoolEmAllStringSerializer;
+import simulator.stats.implementation.out.StringSerializer;
 import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory;
 import csiro.mit.utils.jfreechart.timetablechart.data.Timetable;
@@ -93,4 +99,5 @@
 import dcworms.schedframe.scheduling.Executable;
 import eduni.simjava.Sim_stat;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
 
 public class DCWormsStatistics implements SimulationStatistics {
@@ -111,5 +118,10 @@
 	protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt";
 	protected static final String TEMPERATURE_STATISTICS_OUTPUT_FILE_NAME = "Temperature.txt";
-
+	protected static final String USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME = "UsefulWork.txt";
+	protected static final String DEVICE_STATISTICS_OUTPUT_FILE_NAME = "Devices.txt";
+	protected static final String NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME = "NodesAvailability.txt";
+	protected static final String METRICS_STATISTICS_OUTPUT_FILE_NAME = "Metrics.txt";
+	protected static final String RESOURCE_HISTORY_OUTPUT_FILE_NAME = "ResourceHistyory.txt";
+	
 	protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_";
 	protected static final String STATS_FILE_NAME_PREFIX = "Stats_";
@@ -127,5 +139,5 @@
 	
 	protected GenericUser users;
-	protected ResourceController resourceController;
+	protected SimulatedEnvironment resourceController;
 	protected boolean generateDiagrams = true;
 	protected AbstractStringSerializer serializer;
@@ -154,11 +166,11 @@
 	protected TaskSeriesCollection ganttDiagramTaskSeriesCollection;
 	protected TaskSeriesCollection ganttDiagramWaitingTimeSeriesCollection;
-	protected Map<String, List<String>> task_processorsMap;
+	protected Map<String, Set<ComputingResource>> task_processorsMap;
 
 	protected JobRegistry jr;
-
+	protected MetricsCalculator metCalc;
 	
 	public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users,
-			String outputFolderName, ResourceController resourceController) {
+			String outputFolderName, SimulatedEnvironment resourceController) {
 		this.simulationIdentifier = simulationIdentifier;
 		this.configuration = co;
@@ -167,5 +179,9 @@
 		this.outputFolderName = outputFolderName;
 
-		this.serializer = new CoolEmAllStringSerializer();
+		this.serializer = new StringSerializer();
+		
+		if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){
+			this.serializer = new CoolEmAllStringSerializer();	
+		}
 		this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT);
 
@@ -173,4 +189,5 @@
 		this.jr = new JobRegistryImpl("");
 		init();
+		metCalc = new MetricsCalculator();
 	}
 
@@ -183,4 +200,7 @@
 		this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
 
+		metCalc.setStartTime(startSimulationTime);
+		metCalc.setEndTime(endSimulationTime);
+		
 		long s = 0;
 		long e = 0;
@@ -211,5 +231,5 @@
 
 	private void init() {
-		task_processorsMap = new HashMap<String, List<String>>();
+		task_processorsMap = new HashMap<String, Set<ComputingResource>>();
 		accStats = new GSSAccumulatorsStats();
 		statsData = new HashMap<String, GSSAccumulator>();
@@ -229,4 +249,21 @@
 		if (simulationStatsFile != null) {
 			Object txt = accStats.serialize(this.serializer);
+			
+			DecimalFormat df = new DecimalFormat();
+			df.setMaximumFractionDigits(3);
+			df.setGroupingUsed(false);
+			
+			/*log.info("#STATS " + "Performance statistics");
+			log.info("#STATS " + "Makespan: " + accStats.makespan.getMean() + " [s]");
+			log.info("#STATS " + "Task completion time - " + "min: " + accStats.meanTaskCompletionTime.getMin() + "; max: " + accStats.meanTaskCompletionTime.getMax() + " [s]");
+			log.info("#STATS " + "Mean task execution time: " + accStats.meanTaskExecutionTime.getMean() + " [s]");
+			log.info("#STATS " + "System load: " + accStats.meanTotalLoad.getMean() * 100 + " [%]");*/
+			
+			System.out.println("#STATS " + "===== Performance statistics =====");
+			System.out.println("#STATS " + "Makespan: " + df.format(accStats.makespan.getMean()) + " [s]");
+			System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]");
+			System.out.println("#STATS " + "Mean task execution time: " + df.format(accStats.meanTaskExecutionTime.getMean()) + " [s]");
+			System.out.println("#STATS " + "System load: " + df.format(accStats.meanTotalLoad.getMean() * 100) + " [%]");
+			
 			simulationStatsFile.println(txt);
 		}
@@ -238,23 +275,24 @@
 
 	/************* RESOURCE STATISTICS SECTION **************/
-	private void gatherResourceStatistics() {
+	public void gatherResourceStatistics() {
 		
 		HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>();
 		
-		for(String resourceName: resourceController.getComputingResourceLayers()){
+		for(String resourceTypeName: resourceController.getComputingResourceLayers()){
 			List<Stats> cStats = new ArrayList<Stats>();
 			cStats.add(Stats.textLoad);
-			if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceName))
+			if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceTypeName))
 				cStats.add(Stats.chartLoad);
 			cStats.add(Stats.textEnergy);
-			if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName))
+			if(ArrayUtils.contains(configuration.resForEnergyChart, resourceTypeName))
 				cStats.add(Stats.chartEnergy);
 			cStats.add(Stats.textAirFlow);
-			if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName))
+			if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceTypeName))
 				cStats.add(Stats.chartAirFlow);
 			cStats.add(Stats.textTemperature);
-			if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceName))
+			if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceTypeName))
 				cStats.add(Stats.chartTemperature);
-			type_stats.put(resourceName, cStats);
+			type_stats.put(resourceTypeName, cStats);
+
 		}		
 		
@@ -269,4 +307,5 @@
 		ganttDiagramTimetable = new Timetable(new FixedMillisecond(
 				startSimulationTime), new FixedMillisecond(endSimulationTime));
+		
 		
 		PrintStream resourceLoadStatsFile = null;
@@ -310,4 +349,44 @@
 		}
 
+		PrintStream deviceStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ DEVICE_STATISTICS_OUTPUT_FILE_NAME);
+			deviceStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			deviceStatsFile = null;
+		}
+		
+		PrintStream nodesAvailabilityStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME);
+			nodesAvailabilityStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			nodesAvailabilityStatsFile = null;
+		}
+		
+		PrintStream metricsStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ METRICS_STATISTICS_OUTPUT_FILE_NAME);
+			metricsStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			metricsStatsFile = null;
+		}
+		
+		PrintStream usefulWorkStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME);
+			usefulWorkStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			usefulWorkStatsFile = null;
+		}
+		
 		basicResStats = gatherPEStats(jr.getTasks());
 		peStatsPostProcessing(basicResStats);
@@ -318,22 +397,26 @@
 		}
 		
-		for(String resourceName: resourceController.getComputingResourceLayers()){
-			List<ComputingResource> resources = null;
-
-			resources = new ArrayList<ComputingResource>();
+		List<ComputingResource> compResources = null;
+		for(String resourceTypeName: resourceController.getComputingResourceLayers()){
+			GSSAccumulator resourceEnergyAccumulator = new GSSAccumulator();
+			GSSAccumulator maxResourceEnergyAccumulator = new GSSAccumulator();
+			GSSAccumulator calculationsEnergyAccumulator = new GSSAccumulator();
+			compResources = new ArrayList<ComputingResource>();
 			for(ComputingResource compRes: resourceController.getComputingResources() ){
-				resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName)));
-			}
-			if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName))
-				resources.addAll(resourceController.getComputingResources());
-		
-			if(type_stats.containsKey(resourceName)){
-				for(ComputingResource resource: resources){
+				compResources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceTypeName)));
+			}
+			if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceTypeName))
+				compResources.addAll(resourceController.getComputingResources());
+			if(type_stats.containsKey(resourceTypeName)){
+		
+				
+				for(ComputingResource compResource: compResources){
 					ResourceUsageStats resourceUsage = null;
 					ResourcePowerStats energyUsage = null;
 					ResourceAirFlowStats airFlow = null;
 					ResourceTemperatureStats temperature = null;
-					if(type_stats.get(resourceName).contains(Stats.textLoad)){
-						resourceUsage = gatherResourceLoadStats(resource, basicResStats);
+					ResourceUsefulWorkStats usefulWork = null;
+					if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){
+						resourceUsage = gatherResourceLoadStats(compResource, basicResStats);
 						resourceUsage.setMeanValue(calculateMeanValue(resourceUsage));
 						if (resourceLoadStatsFile != null) {
@@ -341,17 +424,59 @@
 							resourceLoadStatsFile.print(txt);
 						}
-					}
-					if(type_stats.get(resourceName).contains(Stats.chartLoad)){
+
+					}
+					if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){
 						if (configuration.creatediagrams_resutilization) {
 							createResourceLoadDiagram(resourceUsage);
 						}
 					}
-					if(type_stats.get(resourceName).contains(Stats.textEnergy)){
-						energyUsage = gatherResourcePowerConsumptionStats(resource);
+					if(type_stats.get(resourceTypeName).contains(Stats.textEnergy)){
+						energyUsage = gatherResourcePowerConsumptionStats(compResource);
 						energyUsage.setMeanValue(calculateMeanValue(energyUsage));
 						energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
-						
-						EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
-						if(resourceController.getComputingResources().contains(resource)) {
+						resourceEnergyAccumulator.add(energyUsage.getSumValue());
+						maxResourceEnergyAccumulator.add(calculateMaxValue(energyUsage));
+						double calulcationsEnergy = 0;
+						try {
+							/*boolean doCalc = false;
+							double prevTimestamp = 0;
+							for(Long key: resourceUsage.getHistory().keySet()){
+								if(doCalc){
+									System.out.println(energyUsage.getHistory().get(key));
+									calulcationsEnergy = calulcationsEnergy + energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600 * MILLI_SEC);
+									doCalc  = false;
+								}
+								if(resourceUsage.getHistory().get(key)>0){
+									prevTimestamp = key;
+									doCalc = true;
+								}
+							}*/
+							boolean doCalc = false;
+							long prevTimestamp = 0;
+							for(Long key: energyUsage.getHistory().keySet()){
+								if(doCalc){
+									double load = 0;
+									if(resourceUsage.getHistory().get(prevTimestamp)!= null){
+										load = resourceUsage.getHistory().get(prevTimestamp);
+									}
+									calulcationsEnergy = calulcationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC);
+									doCalc = false;
+								}
+								if(energyUsage.getHistory().get(key) > compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION){
+									
+									prevTimestamp = key;
+									doCalc = true;
+								}
+							}
+							//calulcationsEnergy = energyUsage.getSumValue() - 
+							//	((1 - resourceUsage.getMeanValue()) * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)) * 
+							//	(compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION);
+							//System.out.println(compResource.getFullName() + ";" + resourceUsage.getMeanValue() +":"+ calulcationsEnergy  + ":" + energyUsage.getSumValue());
+							calculationsEnergyAccumulator.add(calulcationsEnergy);
+						} catch (Exception e) {
+							e.printStackTrace();
+						}
+						EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+						if(resourceController.getComputingResources().contains(compResource)) {
 							if( een != null && een.getPowerProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){
 								accStats.meanEnergyUsage.add(energyUsage.getSumValue());
@@ -359,5 +484,5 @@
 
 						} else if( een != null && een.getPowerProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){
-							ComputingResource parent = resource.getParent();
+							ComputingResource parent = compResource.getParent();
 							boolean top = true;
 							while(parent != null){
@@ -377,7 +502,25 @@
 							energyStatsFile.print(txt);
 						}
-					}
-					if(type_stats.get(resourceName).contains(Stats.chartEnergy)){
-
+						
+						for(Device device: compResource.getResourceCharacteristic().getDevices()){
+							GSSAccumulator devAccumulator = new GSSAccumulator();
+							ResourcePowerStats deviceEnergyUsage = gatherResourcePowerConsumptionStats(device);
+							deviceEnergyUsage.setMeanValue(calculateMeanValue(deviceEnergyUsage));
+							deviceEnergyUsage.setSumValue(deviceEnergyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
+							devAccumulator.add(deviceEnergyUsage.getSumValue());
+							metCalc.addMetricsData(device.getType().getName(), devAccumulator);
+							if (deviceStatsFile != null) {
+								Object txt = deviceEnergyUsage.serialize(serializer);
+								deviceStatsFile.print(txt);
+							}
+							
+							if(ArrayUtils.contains(configuration.resForEnergyChart, device.getType().getName())){
+								if (configuration.creatediagrams_respowerusage) {
+									createResourceEnergyDiagramData(deviceEnergyUsage);
+								}
+							}
+						}
+					}
+					if(type_stats.get(resourceTypeName).contains(Stats.chartEnergy)){
 						if (configuration.creatediagrams_respowerusage) {
 							createResourceEnergyDiagramData(energyUsage);
@@ -385,11 +528,11 @@
 					}
 					
-					if(type_stats.get(resourceName).contains(Stats.textAirFlow)){
-						airFlow = gatherResourceAirFlowStats(resource);
+					if(type_stats.get(resourceTypeName).contains(Stats.textAirFlow)){
+						airFlow = gatherResourceAirFlowStats(compResource);
 						airFlow.setMeanValue(calculateMeanValue(airFlow));
 						airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC));
 						
-						EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
-						if(resourceController.getComputingResources().contains(resource)) {
+						EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+						if(resourceController.getComputingResources().contains(compResource)) {
 							if( een != null && een.getAirFlowProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){
 								accStats.meanAirFlow.add(airFlow.getMeanValue());
@@ -397,5 +540,5 @@
 
 						} else if( een != null && een.getAirFlowProfile() != null ){
-							ComputingResource parent = resource.getParent();
+							ComputingResource parent = compResource.getParent();
 							een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
 							boolean top = true;
@@ -415,6 +558,23 @@
 							airFlowStatsFile.print(txt);
 						}
-					}
-					if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){
+						
+						for(Device device: compResource.getResourceCharacteristic().getDevices()){
+							ResourceAirFlowStats deviceAirFlow = gatherResourceAirFlowStats(device);
+							deviceAirFlow.setMeanValue(calculateMeanValue(deviceAirFlow));
+							deviceAirFlow.setSumValue(deviceAirFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC));
+							
+							if (deviceStatsFile != null) {
+								Object txt = deviceAirFlow.serialize(serializer);
+								deviceStatsFile.print(txt);
+							}
+							
+							if(ArrayUtils.contains(configuration.resForAirFlowChart, device.getType().getName())){
+								if (configuration.creatediagrams_resairflow) {
+									createResourceAirFlowDiagramData(deviceAirFlow);
+								}
+							}
+						}
+					}
+					if(type_stats.get(resourceTypeName).contains(Stats.chartAirFlow)){
 
 						if (configuration.creatediagrams_resairflow) {
@@ -423,11 +583,11 @@
 					}
 					
-					if(type_stats.get(resourceName).contains(Stats.textTemperature)){
-						temperature = gatherResourceTemperatureStats(resource);
+					if(type_stats.get(resourceTypeName).contains(Stats.textTemperature)){
+						temperature = gatherResourceTemperatureStats(compResource);
 						temperature.setMeanValue(calculateMeanValue(temperature));
 						temperature.setSumValue(temperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
 						
-						EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
-						if(resourceController.getComputingResources().contains(resource)) {
+						EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+						if(resourceController.getComputingResources().contains(compResource)) {
 							if( een != null  && een.getThermalProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){
 								accStats.meanTemperature.add(temperature.getMeanValue());
@@ -435,5 +595,5 @@
 
 						} else if( een != null && een.getThermalProfile() != null ){
-							ComputingResource parent = resource.getParent();
+							ComputingResource parent = compResource.getParent();
 							een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
 							boolean top = true;
@@ -453,15 +613,67 @@
 							temperatureStatsFile.print(txt);
 						}
-					}
-					if(type_stats.get(resourceName).contains(Stats.chartTemperature)){
-
+						
+						for(Device device: compResource.getResourceCharacteristic().getDevices()){
+							ResourceTemperatureStats deviceTemperature = gatherResourceTemperatureStats(device);
+							deviceTemperature.setMeanValue(calculateMeanValue(deviceTemperature));
+							deviceTemperature.setSumValue(deviceTemperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
+							
+							if (deviceStatsFile != null) {
+								Object txt = deviceTemperature.serialize(serializer);
+								deviceStatsFile.print(txt);
+							}
+							
+							if(ArrayUtils.contains(configuration.resForTemperatureChart, device.getType().getName())){
+								if (configuration.creatediagrams_restemperature) {
+									createResourceTemperatureDiagramData(deviceTemperature);
+								}
+							}
+						}						
+					}
+					if(type_stats.get(resourceTypeName).contains(Stats.chartTemperature)){
 						if (configuration.creatediagrams_restemperature) {
 							createResourceTemperatureDiagramData(temperature);
 						}
 					}
+					
+					if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){
+						usefulWork = gatherResourceUsefulWorkStats(compResource);
+						if (usefulWorkStatsFile != null) {
+							Object txt = usefulWork.serialize(serializer);
+							usefulWorkStatsFile.print(txt);
+						}
+					}
+					
+					
+					if (nodesAvailabilityStatsFile != null) {
+						ResourceAvailabilityStats ras = new ResourceAvailabilityStats(compResource.getFullName(), compResource.getType(), "availableNodes", compResource.getChildren().size(), endSimulationTime);
+						Object txt = ras.serialize(serializer);
+						nodesAvailabilityStatsFile.print(txt);
+						ras = gatherResourceAvailabilityStats(compResource);
+						txt = ras.serialize(serializer);
+						nodesAvailabilityStatsFile.print(txt);
+					}
+					
 				}
-			}
-		}
-		
+				metCalc.addMetricsData(resourceTypeName + "_CALC", calculationsEnergyAccumulator);
+				metCalc.addMetricsData(resourceTypeName, resourceEnergyAccumulator);
+				metCalc.addMetricsData(resourceTypeName + "_MAX", maxResourceEnergyAccumulator);
+			}
+		}
+		
+		
+		if (metricsStatsFile != null) {
+			//log.info("#STATS " + "Metrics");
+			System.out.println("#STATS " + "===== Metrics =====");
+			for(MetricsStats metric: metCalc.calulateMetrics(endSimulationTime)){
+				Object txt = metric.serialize(serializer);
+				//log.info("#STATS " +  metric.getResourceName() + " " + metric.getMetricName() + ": " + metric.getValue());
+				DecimalFormat df = new DecimalFormat();
+				df.setMaximumFractionDigits(3);
+				df.setGroupingUsed(false);
+				System.out.println("#STATS " +  metric.getMetricName().replaceAll("_", " ") + ": " + df.format(metric.getValue()) + " [" + metric.getUnit() + "]");
+				metricsStatsFile.println(txt);	
+			}
+		}
 		saveResourceUsageDiagrams();
 		createAccumulatedResourceSimulationStatistic();
@@ -479,4 +691,20 @@
 			resourceLoadStatsFile.close();
 		}
+		
+		if (usefulWorkStatsFile != null) {
+			usefulWorkStatsFile.close();
+		}
+		if (deviceStatsFile != null) {
+			deviceStatsFile.close();
+		}
+		
+		if (nodesAvailabilityStatsFile != null) {
+			nodesAvailabilityStatsFile.close();
+		}
+		
+		if (metricsStatsFile != null) {
+			metricsStatsFile.close();
+		}
+
 	}
 
@@ -500,6 +728,6 @@
 		}
 		for(ComputingResource resource: resources){
-			if(!basicResStats.containsKey(resource.getName())){
-				basicResStats.put(resource.getName(), new ArrayList<ResStat>());
+			if(!basicResStats.containsKey(resource.getFullName())){
+				basicResStats.put(resource.getFullName(), new ArrayList<ResStat>());
 			}
 		}
@@ -509,5 +737,4 @@
 		
 		Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator());
-
 		for (ExecTask execTask:executables) {
 			Executable exec = (Executable) execTask;
@@ -522,5 +749,5 @@
 				ProcessingElements pes = (ProcessingElements) resUnit;
 				for(ComputingResource pe: pes){
-					String peName = pe.getName();
+					String peName = pe.getFullName();
 					long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC;
 					long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC;
@@ -541,17 +768,31 @@
 					String uniqueTaskID = getUniqueTaskId(execTask);
 
-					List<String> peNames = task_processorsMap.get(uniqueTaskID);
+					Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID);
 					if (peNames == null) {
-						peNames = new ArrayList<String>();
-						peNames.add(peName);
+						peNames = new HashSet<ComputingResource>();
+						peNames.add(pe);
 						task_processorsMap.put(uniqueTaskID, peNames);
 					} else {
-						peNames.add(peName);
-					}
+						peNames.add(pe);
+					}
+
+					try{
+						double usefulWork = execTask.getResourceConsumptionProfile().getUsefulWork();
+						//double usefulWork = gatherUsefulWorkStats(pe).getValue();
+						GSSAccumulator uwAcc;
+						if(metCalc.getMetricsData().containsKey(pe.getFullName())){
+							uwAcc = metCalc.getMetricsData().get(pe.getFullName()).get(0);
+							uwAcc.add(usefulWork);
+						} else {
+							uwAcc = new GSSAccumulator();
+							uwAcc.add(usefulWork);
+							metCalc.addMetricsData(pe.getFullName(), uwAcc);
+						}
+					}  catch (Exception e){
+						
+					}
+					
 				}
-			} else if (resUnit instanceof PEUnit){
-				PEUnit peUnit = (PEUnit) resUnit;
-			}
-
+			} 
 		}
 		return basicResStats;
@@ -571,10 +812,15 @@
 	}
 	
+	
 	private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) {
-		ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), "resourceLoadStats");
+		String usageType = null;
+		if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){
+			usageType = resource.getResourceCharacteristic().getParameters().get("load-sensor").get(0).getContent();
+		}
+		ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), usageType);
 		int cnt = 0;
 		for(String resName: basicStats.keySet()){
 			try {
-				if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){
+				if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){
 					createResourceLoadData(usageStats, basicStats.get(resName));
 					cnt++;
@@ -591,4 +837,29 @@
 
 		return usageStats;
+	}
+	
+	private ResourceAvailabilityStats gatherResourceAvailabilityStats(ComputingResource resource) {
+		String usageType = new String ("usedNodes");
+
+		int usedResources = 0;
+		for(ComputingResource compResource: resource.getChildren()){
+			double meanLoad = calculateMeanValue(gatherResourceLoadStats(compResource, basicResStats));
+			if(meanLoad > 0){
+				usedResources++;
+			}
+		}
+		ResourceAvailabilityStats availabilityStats = new ResourceAvailabilityStats(resource.getFullName(), resource.getType(), usageType, usedResources, endSimulationTime);
+		return availabilityStats;
+	}
+	
+	private ResourceUsefulWorkStats gatherResourceUsefulWorkStats(ComputingResource compResource) {
+		String usageType = "usefulWork";
+		double usefulWork = 0;
+		JobRegistry jr = new JobRegistryImpl(compResource.getFullName());
+		for(ExecTask task: jr.getFinishedTasks()){
+			usefulWork = usefulWork + task.getResourceConsumptionProfile().getUsefulWork();
+		}
+		ResourceUsefulWorkStats usefulWorkStats = new ResourceUsefulWorkStats(compResource.getFullName(), compResource.getType(), usageType, usefulWork, endSimulationTime);
+		return usefulWorkStats;
 	}
 	
@@ -629,5 +900,8 @@
 			}
 		}
-
+		if(ganttData.get(startSimulationTime) == null)
+			ganttData.put(startSimulationTime, 0.0);
+		if(ganttData.get(endSimulationTime) == null)	
+			ganttData.put(endSimulationTime, 0.0);
 		return ganttData;
 	}
@@ -643,7 +917,12 @@
 	
 	
-	private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) {
+	private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) {
 		double power = 0;
-		ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), "resourcePowerConsumptionStats");
+		
+		String usageType = null;
+		if(resource.getResourceCharacteristic().getParameters().get("power-sensor")!= null){
+			usageType = resource.getResourceCharacteristic().getParameters().get("power-sensor").get(0).getContent();
+		}
+		ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), usageType);
 		Map<Long, Double> usage = resEnergyUsage.getHistory();
 		
@@ -665,5 +944,4 @@
 						usage.put(pu.getTimestamp(), pu.getValue());
 						
-					///	System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue());
 						power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC);
 						lastPower = pu.getValue();
@@ -673,12 +951,15 @@
 			}
 		}
-		//System.out.println(power);
 		return resEnergyUsage;
 	}
 	
 	
-	private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) {
-
-		ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), "resourceAirFlowStats");
+	private ResourceAirFlowStats gatherResourceAirFlowStats(PhysicalResource resource) {
+
+		String usageType = null;
+		if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor")!= null){
+			usageType = resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor").get(0).getContent();
+		}
+		ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), usageType);
 		Map<Long, Double> airFlow = resAirFlow.getHistory();
 		
@@ -704,7 +985,11 @@
 	}
 	
-	private ResourceTemperatureStats gatherResourceTemperatureStats(ComputingResource resource) {
-
-		ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), "resourceTemperatureStats");
+	private ResourceTemperatureStats gatherResourceTemperatureStats(PhysicalResource resource) {
+
+		String usageType = null;
+		if(resource.getResourceCharacteristic().getParameters().get("temperature-sensor")!= null){
+			usageType = resource.getResourceCharacteristic().getParameters().get("temperature-sensor").get(0).getContent();
+		}
+		ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), usageType);
 		Map<Long, Double> temperature = resTemperature.getHistory();
 		
@@ -1065,5 +1350,5 @@
 
 			try {
-				if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){
+				if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){
 					Double load = peLoad.get(resName);
 					sum += load;
@@ -1102,7 +1387,15 @@
 	
 	
-
-	
-	
+	private double calculateMaxValue(ResourceDynamicStats resDynamicStats ){
+		double maxValue = 0;
+
+		Map<Long, Double> history = resDynamicStats.getHistory();
+		for (Long key : history.keySet()) {
+			if(history.get(key) > maxValue){
+				maxValue = history.get(key) ;
+			}
+		}
+		return maxValue;
+	}
 	
 	
@@ -1221,5 +1514,5 @@
 		TaskStats taskStats = new TaskStats(task, startSimulationTime);
 		String uniqueTaskID = getUniqueTaskId(task);
-		taskStats.setProcessorsName(task_processorsMap.get(uniqueTaskID));
+		taskStats.setProcessors(task_processorsMap.get(uniqueTaskID));
 		return taskStats;
 	}
@@ -1484,16 +1777,27 @@
 
 		public int compare(String o1, String o2)  {
-			Integer o1int;
-			Integer o2int;
+			Integer o1int = 0;
+			Integer o2int = 0;
 			String o1string;
-			String o2string;
-			o1string = o1.substring(0, o1.indexOf("_"));
-			o2string = o2.substring(0, o2.indexOf("_"));
-			o1int = Integer.parseInt(o1.substring(o1.indexOf("_")+1));
-			o2int = Integer.parseInt(o2.substring(o2.indexOf("_")+1));
-			//if(o1string.compareTo(o2string) != 0)
-			//	return o1string.compareTo(o2string);
-			//else
+			String o2string = null;
+
+			if(o1.contains("_")){
+				o1string = o1.substring(0, o1.lastIndexOf("_"));
+				o1int = Integer.parseInt(o1.substring(o1.lastIndexOf("_")+1));
+			} else {
+				o1string = o1;
+			}
+			
+			if(o2.contains("_")){
+				o2string = o2.substring(0, o2.lastIndexOf("_"));
+				o2int = Integer.parseInt(o2.substring(o2.lastIndexOf("_")+1));
+			}else {
+				o2string = o2;
+			}
+
+			if(o1int.compareTo(o2int) != 0)
 				return o1int.compareTo(o2int);
+			else
+				return o1string.compareTo(o2string);
 		}
 	}
@@ -1573,4 +1877,5 @@
 	chartAirFlow,
 	textTemperature,
-	chartTemperature;
+	chartTemperature,
+	textUsefulWorl;
 }
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java	(revision 496)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java	(revision 1207)
@@ -12,4 +12,7 @@
 	public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) {
 		super(resourceName, resourceType, usageType);
+		if(usageType == null){
+			this.usageType = "airflow_volume";
+		}
 	}
 
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java	(revision 496)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java	(revision 1207)
@@ -10,4 +10,7 @@
 	public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) {
 		super(resourceName, resourceType, usageType);
+		if(usageType == null){
+			this.usageType = "cpu_load";
+		}
 	}
 
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsefulWorkStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsefulWorkStats.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsefulWorkStats.java	(revision 1207)
@@ -0,0 +1,60 @@
+package simulator.stats.implementation;
+
+import schedframe.resources.ResourceType;
+import simulator.stats.implementation.out.StatsSerializer;
+
+public class ResourceUsefulWorkStats implements StatsInterface{
+
+	protected String resourceName;
+	protected String usageType;
+	protected ResourceType resourceType;
+	protected long timestamp;
+	protected double value;
+
+	private String[] headers = { "resourceName", "timestamp", "usefulWork" };
+	
+	public ResourceUsefulWorkStats (String resourceName, ResourceType resourceType, String usageType, double value, long timestamp) {
+		this.resourceName = resourceName;
+		this.resourceType = resourceType;
+		this.usageType = usageType;
+		this.value = value;
+		this.timestamp = timestamp;
+		if(usageType == null){
+			this.usageType = "usefulWork";
+		}
+	}
+	
+	public ResourceUsefulWorkStats (String resourceName, ResourceType resourceType, String usageType,  double value) {
+		this(resourceName, resourceType, usageType, value, 0);
+	}
+
+
+	public double getValue() {
+		return value;
+	}
+
+	public Object serialize(StatsSerializer serializer) {
+		return serializer.visit(this);
+	}
+
+	public String getResourceName() {
+		return this.resourceName;
+	}
+	
+	public ResourceType getResourceType() {
+		return resourceType;
+	}
+	
+	public String getUsageType() {
+		return this.usageType;
+	}	
+
+	public String[] getHeaders() {
+		return headers;
+	}
+
+	public long getTimestamp() {
+		return timestamp;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAvailabilityStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAvailabilityStats.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAvailabilityStats.java	(revision 1207)
@@ -0,0 +1,60 @@
+package simulator.stats.implementation;
+
+import schedframe.resources.ResourceType;
+import simulator.stats.implementation.out.StatsSerializer;
+
+public class ResourceAvailabilityStats implements StatsInterface{
+
+	protected String resourceName;
+	protected String usageType;
+	protected ResourceType resourceType;
+	protected long timestamp;
+	protected double value;
+
+	private String[] headers = { "resourceName", "timestamp", "availability" };
+	
+	public ResourceAvailabilityStats (String resourceName, ResourceType resourceType, String usageType, double value, long timestamp) {
+		this.resourceName = resourceName;
+		this.resourceType = resourceType;
+		this.usageType = usageType;
+		this.value = value;
+		this.timestamp = timestamp;
+		if(usageType == null){
+			this.usageType = "availability";
+		}
+	}
+	
+	public ResourceAvailabilityStats (String resourceName, ResourceType resourceType, String usageType,  double value) {
+		this(resourceName, resourceType, usageType, value, 0);
+	}
+
+
+	public double getValue() {
+		return value;
+	}
+
+	public Object serialize(StatsSerializer serializer) {
+		return serializer.visit(this);
+	}
+
+	public String getResourceName() {
+		return this.resourceName;
+	}
+	
+	public ResourceType getResourceType() {
+		return resourceType;
+	}
+	
+	public String getUsageType() {
+		return this.usageType;
+	}	
+
+	public String[] getHeaders() {
+		return headers;
+	}
+
+	public long getTimestamp() {
+		return timestamp;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java	(revision 1207)
@@ -22,5 +22,5 @@
 
 	public ResourceStats(ComputingResource compResource) {
-		this.resourceName = compResource.getName();
+		this.resourceName = compResource.getFullName();
 		init();
 
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java	(revision 1199)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java	(revision 1207)
@@ -2,9 +2,15 @@
 
 
-import java.util.List;
-
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import simulator.stats.implementation.out.StatsSerializer;
 import dcworms.schedframe.scheduling.Executable;
-
-import simulator.stats.implementation.out.StatsSerializer;
 
 /**
@@ -14,5 +20,5 @@
  */
 public class TaskStats implements StatsInterface {
-	protected List<String> processorsName;
+	protected Set<ComputingResource> processingElements;
 	protected double reservationStartDate;
 	protected double reservationFinishDate;
@@ -26,5 +32,5 @@
 			"ExecutionTime", "ReadyTime", "StartTime", "FlowTime",
 			"WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness",
-			"ReservStartDate", "ReservFinishDate", "ProcessorName", "Energy"};
+			"ReservStartDate", "ReservFinishDate", "HostNames", "ProcessorName", "Energy", "AppName",};
 
 	public TaskStats(Executable task, long startSimulationTime) {
@@ -147,6 +153,6 @@
 	}
 
-	public void setProcessorsName(List<String> value) {
-		this.processorsName = value;
+	public void setProcessors(Set<ComputingResource> value) {
+		this.processingElements = value;
 	}
 
@@ -159,8 +165,35 @@
 	}
 
-	public List<String> getProcessorsName() {
-		return processorsName;
-	}
-
+	public Set<String> getProcessingElementsName() {
+		Set<String> processingElementsNames = new HashSet<String>();
+		Iterator<ComputingResource> it = processingElements.iterator();
+		while(it.hasNext()) {
+			ComputingResource compRes = it.next();
+			processingElementsNames.add(compRes.getFullName());
+		}
+		return processingElementsNames;
+	}
+
+	public Set<String> getHostName() {
+		Set<String> hostNames = new HashSet<String>();
+		Iterator<ComputingResource> it = processingElements.iterator();
+		while(it.hasNext()) {
+			ComputingResource compRes = it.next();
+			ComputingNode node = null;
+			if(compRes instanceof Core){
+				Core core =(Core) compRes;
+				node = (ComputingNode)core.getNode();
+			} else if(compRes instanceof Processor){
+				Processor proc = (Processor) compRes;
+				node = (ComputingNode)proc.getNode();
+			} else if(compRes instanceof ComputingNode){
+				node = (ComputingNode)compRes;
+			}
+			if(node != null)
+				hostNames.add(node.getFullName());
+		}
+		return hostNames;
+	}
+	
 	public double getReservationStartDate() {
 		return reservationStartDate;
@@ -170,4 +203,15 @@
 		return reservationFinishDate;
 	}
+	
+	public String getExecName() {
+		String execName = null;
+		if(task.getDescription().getExecution() != null) {
+			if(task.getDescription().getExecution().getStdin()!= null && task.getDescription().getExecution().getStdin().length > 0)
+				execName = task.getDescription().getExecution().getStdin()[0].getName();
+			else if(task.getDescription().getExecution().getExecutable() != null && task.getDescription().getExecution().getExecutable().getApplication() != null)
+				execName = task.getDescription().getExecution().getExecutable().getApplication().getName();
+		}
+		return execName;
+	}
 
 	public String[] getHeaders() {
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java	(revision 496)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java	(revision 1207)
@@ -12,4 +12,7 @@
 	public ResourcePowerStats (String resourceName, ResourceType resourceType, String usageType) {
 		super(resourceName, resourceType, usageType);
+		if(usageType == null){
+			this.usageType = "power";
+		}
 	}
 
Index: DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java
===================================================================
--- DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java	(revision 806)
+++ DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java	(revision 1207)
@@ -12,4 +12,7 @@
 	public ResourceTemperatureStats (String resourceName, ResourceType resourceType, String usageType) {
 		super(resourceName, resourceType, usageType);
+		if(usageType == null){
+			this.usageType = "temperature";
+		}
 	}
 
Index: DCWoRMS/branches/coolemall/src/schedframe/SimulatedEnvironment.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/SimulatedEnvironment.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/SimulatedEnvironment.java	(revision 1207)
@@ -0,0 +1,165 @@
+package schedframe;
+
+import gridsim.GridSim;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceHistoryChanges;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.scheduling.Scheduler;
+
+public class SimulatedEnvironment {
+
+	protected static Scheduler scheduler;
+	protected static List<ComputingResource> computingResources;
+	protected List<Initializable> toInit;
+	protected Set<String> compResLayers;
+	protected static List<ResourceHistoryChanges> compResHistory = new ArrayList<ResourceHistoryChanges>();
+	
+	public SimulatedEnvironment(Scheduler logicalStructure, List<ComputingResource> compResources){
+		scheduler = logicalStructure;
+		computingResources = compResources;
+	}
+
+	public Scheduler getScheduler() {
+		return scheduler;
+	}
+
+	public List<ComputingResource> getComputingResources() {
+		return computingResources;
+	}
+
+	public static ComputingResource getComputingResourceByName(String resourceName) throws ResourceException {
+		ComputingResource resourceWithName = null;
+		for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) {
+			ComputingResource resource = computingResources.get(i);
+			if (resource.getFullName().equals(resourceName))
+				resourceWithName = resource;
+			else
+				resourceWithName = resource.getDescendantByName(resourceName);
+		}
+		return resourceWithName;
+	}
+
+	private static Scheduler getSchedulerByName(String schedulerName) {
+		Scheduler schedulerWithName = null;
+
+		if (scheduler.getName().compareTo(schedulerName) == 0)
+			schedulerWithName = scheduler;
+		else if (scheduler.getChildren() != null) {
+			LinkedList<Scheduler> toExamine = new LinkedList<Scheduler>();
+			toExamine.push(scheduler);
+
+			while (!toExamine.isEmpty() && schedulerWithName != null) {
+				Scheduler scheduler = toExamine.pop();
+				List<Scheduler> schedulers = scheduler.getChildren();
+
+				int numberOfSched = schedulers.size();
+				for (int i = 0; i < numberOfSched; i++) {
+					Scheduler schedulerChild = schedulers.get(i);
+					if(scheduler.getName().equals(schedulerName)){
+						schedulerWithName = schedulerChild;
+						break;
+					} else
+						toExamine.addLast(schedulerChild);
+				}
+			}
+		}
+		return schedulerWithName;
+	}
+	
+	public static Scheduler getScheduler(String resName){
+		if(GridSim.getEntityId(resName) != -1){
+			return getSchedulerByName(resName);
+		}
+		ComputingResource resourceWithName = null;
+		try {
+			resourceWithName = getComputingResourceByName(resName);
+		} catch (ResourceException e) {
+		}
+		/*for(int i = 0 ; i < computingResources.size() && resourceWithName == null; i++){
+			ComputingResource resource = computingResources.get(i);
+			if(resource.getName().equals(resName))
+				resourceWithName = resource;
+			else
+				try {
+					resourceWithName = resource.getDescendantByName(resName);
+				} catch (ResourceException e) {
+					return null;
+				}
+		}*/
+		if(resourceWithName == null)
+			return null;
+		List<ComputingResource> children = resourceWithName.getChildren();
+		Set<Scheduler> childrenSchedulers = new HashSet<Scheduler>();
+		if(children.isEmpty())
+			return null;
+		for(ComputingResource child: children) {
+			childrenSchedulers.add(child.getScheduler());
+		}	
+
+		Set<Scheduler> tempChildrenSchedulers = new HashSet<Scheduler>(childrenSchedulers);
+		while(childrenSchedulers.size() > 1){
+			childrenSchedulers = new HashSet<Scheduler>();
+			for(Scheduler s: tempChildrenSchedulers){
+				childrenSchedulers.add(s.getParent());
+			}
+			tempChildrenSchedulers = new HashSet<Scheduler>(childrenSchedulers);
+		}
+		Iterator<Scheduler> it = childrenSchedulers.iterator();
+		Scheduler potentialScheduler = it.next();
+		if(potentialScheduler.getCompResources().containsAll(children))
+			return potentialScheduler;
+		return null;
+	}
+	
+	public static ComputingResource getCommonComputingResourceParent(List<ComputingResource> compResources){
+		if(compResources.size() == 0)
+			return null;
+		Set<ComputingResource> candidates = new HashSet<ComputingResource>(compResources);
+		while(candidates.size() > 1){
+			Set<ComputingResource> parents = new HashSet<ComputingResource>();
+			Iterator<ComputingResource> it = candidates.iterator();
+			while(it.hasNext()){
+				ComputingResource compRes = it.next();
+				if(compRes.getParent() != null){
+					parents.add(compRes.getParent());
+				}
+				it.remove();
+			}
+			candidates.addAll(parents);
+		}
+		return candidates.toArray(new ComputingResource[0])[0];
+	}
+
+	public void setInitList(List<Initializable> toI) {
+		toInit = toI;
+	}
+
+	public List<Initializable> getToInit() {
+		return toInit;
+	}
+
+	public Set<String> getComputingResourceLayers() {
+		return compResLayers;
+	}
+
+	public void setCompResLayers(Set<String> compResLayers) {
+		this.compResLayers = compResLayers;
+	}
+
+	public static void traceResource(long timestamp, String resourceName, String operation, String paramter){
+		ResourceHistoryChanges rhc = new ResourceHistoryChanges(timestamp, resourceName, operation, paramter);
+		compResHistory.add(rhc);
+	}
+
+	public static List<ResourceHistoryChanges> getCompResHistory() {
+		return compResHistory;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventCommand.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventCommand.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventCommand.java	(revision 1207)
@@ -16,5 +16,5 @@
 	public void execute(EventType evType) {
 		SchedulingEvent ev = new SchedulingEvent(evType);
-		ev.setSource(compResource.getName());
+		ev.setSource(compResource.getFullName());
 		compResource.getEventHandler().handleSchedulingEvent(ev);
 	}
@@ -22,5 +22,5 @@
 	public void execute(Event event) {
 		SchedulingEvent ev = new SchedulingEvent(event.getType());
-		ev.setSource(compResource.getName());
+		ev.setSource(compResource.getFullName());
 		compResource.getEventHandler().handleSchedulingEvent(ev);
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/events/ResourceEventCommand.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/events/ResourceEventCommand.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/events/ResourceEventCommand.java	(revision 1207)
@@ -1,12 +1,12 @@
 package schedframe.events;
 
-import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.devices.PhysicalResource;
 
 public class ResourceEventCommand implements EventCommand {
 
-	private ComputingResource compResource;
+	private PhysicalResource resource;
 	
-	public ResourceEventCommand(ComputingResource compResource) {
-		this.compResource = compResource;
+	public ResourceEventCommand(PhysicalResource resource) {
+		this.resource = resource;
 	}
 	
@@ -17,5 +17,5 @@
 
 	public void execute(Event event) {
-		compResource.getEventHandler().handleResourceEvent(event);
+		resource.getEventHandler().handleResourceEvent(event);
 	}
 
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Job.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Job.java	(revision 1159)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Job.java	(revision 1207)
@@ -7,5 +7,4 @@
 import org.qcg.broker.schemas.resreqs.types.TaskStatesName;
 
-import gridsim.dcworms.DCWormsTags;
 
 import java.io.StringWriter;
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java	(revision 1194)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java	(revision 1207)
@@ -4,5 +4,4 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
-import java.util.LinkedList;
 import java.util.List;
 
@@ -22,5 +21,4 @@
 import org.qcg.broker.schemas.resreqs.ProcessesResourceRequirements;
 import org.qcg.broker.schemas.resreqs.Requirements;
-import org.qcg.broker.schemas.resreqs.ResourceConsumptionType;
 import org.qcg.broker.schemas.resreqs.TaskResourceRequirements;
 import org.qcg.broker.schemas.resreqs.TimePeriod;
@@ -31,6 +29,4 @@
 import schedframe.scheduling.WorkloadUnitHandler;
 import schedframe.scheduling.manager.tasks.JobRegistryImpl;
-import schedframe.scheduling.tasks.phases.ResourceConsumption;
-import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
 
@@ -75,5 +71,4 @@
 	private long workloadLogWaitTime;
 	
-	private ResourceConsumptionProfile resourceConsumptionProfile;
 
 	public Task(org.qcg.broker.schemas.resreqs.Task task){
@@ -96,27 +91,5 @@
 	}
 
-	private void preparePhases() {
-		LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>();
-		
-		if(task.getExecution() == null || task.getExecution().getResourceConsumptionProfile() == null){
-			ResourceConsumption resConsumption = null;
-			try {
-				resConsumption = new ResourceConsumption(this.length, getComputingResourceRequirements());
-			} catch (NoSuchFieldException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-			resourceConsumptionList.add(resConsumption);
-		}
-		else{
-			for(ResourceConsumptionType resConsumption: task.getExecution().getResourceConsumptionProfile().getResourceConsumption()){
-				ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption);
-				resourceConsumptionList.add(resourceConsumption);
-			}
-		}
-		this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList);
-		
-	//	System.out.println("======"+task.getExecution().getExecutable().getApplication().getName());
-	}
+	
 	
 	public DateTime getExecutionStartTime() throws NoSuchFieldException {
@@ -310,5 +283,5 @@
 	}
 	
-	protected ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{
+	public ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{
 		
 		Requirements req = this.task.getRequirements();
@@ -450,5 +423,4 @@
 	public void setLength(long length) {
 		this.length = length;
-		preparePhases();
 	}
 
@@ -515,9 +487,5 @@
 		wuh.handleTask(this);
 	}
-	
-	public ResourceConsumptionProfile getResourceConsumptionProfile(){
-		return resourceConsumptionProfile;
-	}
-	
+
 	public String getApplicationName(){
 		try{
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/TaskInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/TaskInterface.java	(revision 1190)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/TaskInterface.java	(revision 1207)
@@ -7,5 +7,4 @@
 
 import schedframe.DescriptionContainer;
-import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
 
@@ -111,5 +110,5 @@
 	public long getWorkloadLogWaitTime();
 	
-	public ResourceConsumptionProfile getResourceConsumptionProfile();
+	//public ResourceConsumptionProfile getResourceConsumptionProfile();
 	
 	public String getApplicationName();
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java	(revision 1129)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java	(revision 1207)
@@ -9,5 +9,6 @@
 import org.qcg.broker.schemas.resreqs.ComputingResourceParameterType;
 import org.qcg.broker.schemas.resreqs.PhaseBehaviourType;
-import org.qcg.broker.schemas.resreqs.ReferenceType;
+import org.qcg.broker.schemas.resreqs.StringParameterType;
+
 import org.qcg.broker.schemas.resreqs.ResourceConsumptionType;
 
@@ -36,6 +37,6 @@
     	if(resConsumptionType.getReferenceHardware() != null){
         	for (int i = 0; i < resConsumptionType.getReferenceHardware().getReference().length; i++){
-        		ReferenceType rt = resConsumptionType.getReferenceHardware().getReference(i);
-        		referenceHardware.put(rt.getName(), rt.getContent());
+        		StringParameterType spt = resConsumptionType.getReferenceHardware().getReference(i);
+        		referenceHardware.put(spt.getName(), spt.getContent());
         	}
     	}
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java	(revision 896)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java	(revision 1207)
@@ -2,10 +2,10 @@
 
 import java.util.LinkedList;
-import java.util.List;
 
 public class ResourceConsumptionProfile {
 	
 	protected LinkedList<ResourceConsumption> resourceConsumptionList;
-	protected int currentPhase;
+	protected long usefulWork;
+	private int currentPhase;
 	
 	public ResourceConsumptionProfile() {
@@ -37,3 +37,11 @@
 		this.currentPhase = currentPhase;
 	}
+
+	public long getUsefulWork() {
+		return usefulWork;
+	}
+
+	public void setUsefulWork(long usefulWork) {
+		this.usefulWork = usefulWork;
+	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 1162)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 1207)
@@ -24,5 +24,5 @@
 
 import qcg.shared.constants.BrokerConstants;
-import schedframe.ResourceController;
+import schedframe.SimulatedEnvironment;
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.events.scheduling.SchedulingEventType;
@@ -323,5 +323,4 @@
 			ExecTask task = iter.next();
 			Executable exec = (Executable)task;
-			//exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration());
 			exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration()));
 			UsedResourcesList usedResourcesList = exec.getUsedResources();
@@ -338,4 +337,5 @@
 			for (ComputingResource resource : pes) {
 				resource.handleEvent(new EnergyEvent(eventType, obj));
+				//DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj));
 			}
 			/*try {
@@ -350,5 +350,5 @@
 			ComputingResource resource = null;
 			try {
-				resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());
+				resource = SimulatedEnvironment.getComputingResourceByName(peUnit.getResourceId());
 			} catch (ResourceException e) {
 				return;
@@ -428,6 +428,10 @@
 			if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){
 				scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask);
+				PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
+				notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
 			} else {
 				scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask);
+				PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
+				notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
 			}
 		}
@@ -540,5 +544,4 @@
 					job.setStatus((int)BrokerConstants.JOB_STATUS_SUBMITTED);
 			} catch (Exception e) {
-				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/SchedulerDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/SchedulerDescription.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/SchedulerDescription.java	(revision 1207)
@@ -2,4 +2,5 @@
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -9,14 +10,15 @@
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.description.ExecutingResourceDescription;
+import schedframe.resources.computing.description.ResourceDescription;
 import schedframe.resources.providers.ResourceProvider;
-import schedframe.resources.units.AbstractResourceUnit;
 import schedframe.resources.units.ResourceUnit;
 import schedframe.resources.units.ResourceUnitName;
 import schedframe.scheduling.queue.QueueDescription;
 
-public class SchedulerDescription extends ExecutingResourceDescription{
+public class SchedulerDescription extends ResourceDescription implements ExecutingResourceDescription{
 
 	protected ResourceProvider provider;
 	protected List<QueueDescription> accesQueues;
+	protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
 
 	public SchedulerDescription(ResourceProvider provider){
@@ -62,3 +64,46 @@
 		return provider;
 	}
+	
+	public void addResourceUnit(ResourceUnit unit) {
+		if (this.resUnits == null)
+			this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1);
+		List<ResourceUnit> list = null;
+		if (this.resUnits.containsKey(unit.getName())) {
+			list = this.resUnits.get(unit.getName());
+		} else {
+			list = new ArrayList<ResourceUnit>(1);
+			this.resUnits.put(unit.getName(), list);
+		}
+		list.add(unit);
+	}
+	
+	public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException {
+		return getResourceUnitList(unitName).get(0);
+	}
+
+	public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException {
+		if (resUnits.containsKey(unitName))
+			return resUnits.get(unitName);
+		else
+			throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id);
+	}
+
+	public Collection<ResourceUnit> getResourceUnit() {
+		if (resUnits == null)
+			return null;
+		List<ResourceUnit> values = new ArrayList<ResourceUnit>();
+		Collection<List<ResourceUnit>> lists = resUnits.values();
+		Iterator<List<ResourceUnit>> itr = lists.iterator();
+
+		while (itr.hasNext()) {
+			List<ResourceUnit> list = itr.next();
+			values.addAll(list);
+		}
+
+		return values;
+	}
+
+	public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() {
+		return resUnits;
+	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java	(revision 1207)
@@ -8,4 +8,5 @@
 import schedframe.resources.units.ResourceUnitName;
 
+//TODO - change name
 public class ResourceHistoryItem {
 
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ClusterResourceManager.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ClusterResourceManager.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ClusterResourceManager.java	(revision 1207)
@@ -23,5 +23,5 @@
 	public List<ComputingNode> getComputingNodes(){
 		try {
-			return (List<ComputingNode>) getResourcesOfType(StandardResourceType.ComputingNode);
+			return (List<ComputingNode>) getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			return new ArrayList<ComputingNode>();
@@ -40,5 +40,5 @@
 	@SuppressWarnings("unchecked")
 	public List<ComputingNode> getComputingNodes(Properties properties){
-		properties.setProperty("type", StandardResourceType.ComputingNode.toString());
+		properties.setProperty("type", StandardResourceType.Node.toString());
 		return (List<ComputingNode>) filterResources(properties);
 
Index: DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/LocalResourceManager.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/LocalResourceManager.java	(revision 1054)
+++ DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/LocalResourceManager.java	(revision 1207)
@@ -19,4 +19,5 @@
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.ComputingResourceCharacteristics;
 import schedframe.resources.computing.ResourceCharacteristics;
 import schedframe.resources.computing.validator.ResourcePropertiesValidator;
@@ -138,5 +139,5 @@
 		for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) {
 			ComputingResource resource = computingResources.get(i);
-			if (resource.getName().equals(resourceName))
+			if (resource.getFullName().equals(resourceName))
 				resourceWithName = resource;
 			else
@@ -154,5 +155,5 @@
 			while (!toExamine.isEmpty()) {
 				ComputingResource resource = toExamine.pop();
-				ResourceCharacteristics resourceCharacteristic = resource.getResourceCharacteristic();
+				ComputingResourceCharacteristics resourceCharacteristic = (ComputingResourceCharacteristics)resource.getResourceCharacteristic();
 				List<ResourceUnit> units = null;
 				units = resourceCharacteristic.getResourceUnits().get(unitName);
@@ -266,5 +267,5 @@
 		for(int i = 0 ; i < computingResources.size() && resourceWithName == null; i++){
 			ComputingResource resource = computingResources.get(i);
-			if(resource.getName().equals(resName))
+			if(resource.getFullName().equals(resName))
 				resourceWithName = resource;
 			else
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceType.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceType.java	(revision 1095)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceType.java	(revision 1207)
@@ -3,13 +3,21 @@
 public enum CoolEmAllResourceType implements ResourceType {
 	
-	ComputeBox2,
-	ComputeBox1,
-	NodeGroup,
-	Node,
-	Processor,
-	Core;
-
+	ComputeBox2("Room"),
+	ComputeBox1("Rack"),
+	NodeGroup("NodeGroup"),
+	Node("Node"),
+	Processor("Processor"),
+	Core("Core");
+	
+	private String label;
+	
+	CoolEmAllResourceType(String label){
+		this.label = label;
+	}
 	public String getName() {
 		return toString();
 	}
+	public String getLabel(){
+		return label;
+	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceTypeFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceTypeFactory.java	(revision 1097)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceTypeFactory.java	(revision 1207)
@@ -5,5 +5,5 @@
 	
 	public static ResourceType createResourceType(String typeName){
-		
+
 		if(typeName.equals(StandardResourceType.Grid.getName()))
 			return StandardResourceType.Grid;
@@ -15,6 +15,6 @@
 			return StandardResourceType.Rack;
 
-		else if (typeName.equals(StandardResourceType.ComputingNode.getName()))
-			return StandardResourceType.ComputingNode;
+		else if (typeName.equals(StandardResourceType.Node.getName()))
+			return StandardResourceType.Node;
 		
 		else if (typeName.equals(StandardResourceType.Processor.getName()))
@@ -24,4 +24,7 @@
 			return StandardResourceType.Core;
 		
+		else if (typeName.equals(CoolEmAllResourceType.ComputeBox2.getName()))
+			return CoolEmAllResourceType.ComputeBox2;
+		
 		else if (typeName.equals(CoolEmAllResourceType.ComputeBox1.getName()))
 			return CoolEmAllResourceType.ComputeBox1;
@@ -30,6 +33,21 @@
 			return CoolEmAllResourceType.NodeGroup;
 		
-		else if (typeName.equals(CoolEmAllResourceType.Node.getName()))
-			return CoolEmAllResourceType.Node;
+		else if (typeName.equals(StandardResourceType.CRAH.getName()))
+			return StandardResourceType.CRAH;
+		
+		else if (typeName.equals(StandardResourceType.Fan.getName()))
+			return StandardResourceType.Fan;
+		
+		else if (typeName.equals(StandardResourceType.Inlet.getName()))
+			return StandardResourceType.Inlet;
+		
+		else if (typeName.equals(StandardResourceType.Outlet.getName()))
+			return StandardResourceType.Outlet;
+		
+		else if (typeName.equals(StandardResourceType.CoolingDevice.getName()))
+			return StandardResourceType.CoolingDevice;
+		
+		else if (typeName.equals(StandardResourceType.Heatsink.getName()))
+			return StandardResourceType.Heatsink;
 		
 		else if (typeName.equals(StandardResourceType.ResourceProvider.getName()))
@@ -42,5 +60,5 @@
 			return StandardResourceType.LS;
 		
-		else return new UserResourceType(typeName);
+		return new UserResourceType(typeName);
 	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceHistoryChanges.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceHistoryChanges.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceHistoryChanges.java	(revision 1207)
@@ -0,0 +1,34 @@
+package schedframe.resources;
+
+
+public class ResourceHistoryChanges {
+	
+	private long timestamp;	
+	private String resourceName;
+	private String operation;
+	private String paramter;
+	
+	public ResourceHistoryChanges(long timestamp, String resourceName, String operation, String paramter) {
+		super();
+		this.timestamp = timestamp;
+		this.resourceName = resourceName;
+		this.operation = operation;
+		this.paramter = paramter;
+	}
+	
+	public long getTimestamp() {
+		return timestamp;
+	}
+	
+	public String getResourceName() {
+		return resourceName;
+	}
+	
+	public String getOperation() {
+		return operation;
+	}
+	
+	public String getParamter() {
+		return paramter;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/Device.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/Device.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/Device.java	(revision 1207)
@@ -0,0 +1,109 @@
+package schedframe.resources.devices;
+
+import schedframe.events.Event;
+import schedframe.events.EventHandler;
+import schedframe.events.ResourceEventCommand;
+import schedframe.events.scheduling.EventReason;
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.ResourceCharacteristics;
+import schedframe.resources.computing.extensions.Extension;
+import schedframe.resources.computing.extensions.ExtensionListImpl;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.EnergyEventType;
+import schedframe.resources.computing.profiles.energy.EnergyExtension;
+import schedframe.resources.devices.description.DeviceDescription;
+
+public class Device extends PhysicalResource{
+
+	private ComputingResource compResource;
+	
+	public Device (DeviceDescription devDesc){
+		this.type = devDesc.getType();
+		this.name = devDesc.getId();
+		this.extensionList = new ExtensionListImpl(1);
+		initCharacteristics(devDesc);
+		accept(new EnergyExtension.Builder().resource(this).powerProfile(devDesc.getPowerProfile()).airFlowProfile(devDesc.getAirThroughputProfile()).thermalProfile(devDesc.getThermalProfile()).build());	
+	}
+
+	public String getFullName() {
+		
+		if(this.getResourceCharacteristic().getParameters().get("fullPath") != null){
+			String fullPath = this.getResourceCharacteristic().getParameters().get("fullPath").get(0).getContent();
+			return fullPath;
+		}
+		else 
+			return compResource.getFullName() + "/" + name;
+	}
+
+	public void setStatus(ResourceStatus newStatus) {
+		if(newStatus != status){
+			status = newStatus;
+		}
+	}
+
+	public void handleEvent(Event event) {
+		ResourceEventCommand rec = new ResourceEventCommand(this);
+		rec.execute(event);
+	}
+	
+	class DeviceEventHandler implements EventHandler{
+		
+		public void handleResourceEvent(Event event){
+			if (extensionList != null) {
+				for (Extension extension : extensionList) {
+					if (extension.supportsEvent(event)) {
+						extension.handleEvent(event);
+					}
+				}
+			}
+			if(event.getReason() != EventReason.SIM_INIT)
+				compResource.handleEvent(event);
+		}
+		
+		public void handleSchedulingEvent(SchedulingEvent event){
+
+		}
+	}
+	
+	public EventHandler getEventHandler(){
+		return new DeviceEventHandler();
+	}
+	
+	public final void initiate(){
+		
+		ResourceEventCommand rec = new ResourceEventCommand(this);
+		EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller");
+		event.setReason(EventReason.SIM_INIT);
+		rec.execute(event);
+		
+		rec = new ResourceEventCommand(this);
+		event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller");
+		event.setReason(EventReason.SIM_INIT);
+		rec.execute(event);
+		
+		rec = new ResourceEventCommand(this);
+		event = new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, "Resource controller");
+		event.setReason(EventReason.SIM_INIT);
+		rec.execute(event);
+			
+		//alternative way
+		//getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"));
+		//getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"));
+		//getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, "Resource controller"));
+	}
+
+	protected void initCharacteristics(DeviceDescription devDesc){
+		resourceCharacteristic = ResourceCharacteristics.builder().location(devDesc.getLocation()).parameters(devDesc.getParameters()).build();
+	}
+
+	public void setComputingResource(ComputingResource compResource) {
+		this.compResource = compResource;
+	}
+
+	public ComputingResource getComputingResource() {
+		return compResource;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourcePowerInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourcePowerInterface.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourcePowerInterface.java	(revision 1207)
@@ -0,0 +1,101 @@
+package schedframe.resources.devices;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.joda.time.DateTimeUtils;
+
+import schedframe.Parameters;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.EnergyEventType;
+import schedframe.resources.computing.profiles.energy.power.PowerProfile;
+import schedframe.resources.computing.profiles.energy.power.PowerState;
+import schedframe.resources.computing.profiles.energy.power.PowerStateName;
+import schedframe.resources.computing.profiles.energy.power.PowerUsage;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
+
+public class PhysicalResourcePowerInterface implements PowerInterface{
+
+	protected PowerStateName currentPowerState;
+	protected PowerProfile powerProfile;
+	protected PhysicalResource resource;
+	
+	public PhysicalResourcePowerInterface(PhysicalResource resource, PowerProfile powerProfile){
+		this.resource = resource;
+		this.powerProfile = powerProfile;
+		this.currentPowerState = StandardPowerStateName.ON;
+	}
+	
+	public boolean setPowerState(PowerStateName state) {
+		if(supportPowerState(state)){
+			currentPowerState = state;
+
+			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));
+
+			return true;
+		}
+		return false;
+	}
+	
+
+	public PowerStateName getPowerState() {
+		return currentPowerState;
+	}
+
+	public List<PowerState> getSupportedPowerStates() throws NoSuchFieldException {
+		List<PowerState> powerStates = new ArrayList<PowerState>();
+		for(PowerState powerState: powerProfile.getSupportedPowerStates()){
+			powerStates.add(powerState);
+		}
+		return powerStates;
+	}
+
+	public boolean supportPowerState(PowerStateName state) {
+		for(PowerState powerState: powerProfile.getSupportedPowerStates()){
+			if(powerState.getName().equals(state)){
+				return true;
+			}
+		}
+		return false;
+		
+	}
+	
+	public double getPowerConsumption(PowerStateName state) throws NoSuchFieldException {
+		double powerConsumption = 0;
+		if(supportPowerState(state)){
+			for(PowerState powerState: powerProfile.getSupportedPowerStates()){
+				if(powerState.getName().equals(state)){
+					powerConsumption = powerState.getPowerUsage();
+					break;
+				}
+			}
+		} else {
+			throw new NoSuchFieldException("Power state not supported");
+		}
+		return powerConsumption;
+	}
+
+	public PowerUsage getRecentPowerUsage() {
+		PowerUsage powerUsage = null;
+		int lastIdx = getPowerUsageHistory().size() - 1;
+		if(lastIdx >= 0)
+			powerUsage = getPowerUsageHistory().get(lastIdx);
+		else {	
+			try {
+				powerUsage = new PowerUsage(DateTimeUtils.currentTimeMillis(), getPowerConsumption(currentPowerState));
+			} catch (NoSuchFieldException e) {
+			}
+		}
+		return powerUsage;
+	}
+	
+	public List<PowerUsage> getPowerUsageHistory(){
+		return powerProfile.getPowerUsageHistory();
+	}
+	
+	public Parameters getParameters() {
+		return powerProfile.getParameters();
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourceThermalInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourceThermalInterface.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourceThermalInterface.java	(revision 1207)
@@ -0,0 +1,43 @@
+package schedframe.resources.devices;
+
+import java.util.List;
+
+import org.joda.time.DateTimeUtils;
+
+import schedframe.Parameters;
+import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue;
+import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile;
+import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
+
+public class PhysicalResourceThermalInterface implements ThermalInterface{
+
+	private static int START_TEMP = 0;
+	protected PhysicalResource resource;
+	protected ThermalProfile thermalProfile;
+
+	public PhysicalResourceThermalInterface(PhysicalResource resource, ThermalProfile thermalProfile) {
+		super();
+		this.resource = resource;
+		this.thermalProfile = thermalProfile;
+	}
+
+	public TemperatureValue getRecentTemperature() {
+		TemperatureValue temperature = null;
+		int lastIdx = getTemperatureHistory().size() - 1;
+		if(lastIdx >= 0)
+			temperature = getTemperatureHistory().get(lastIdx);
+		else {	
+			temperature = new TemperatureValue(DateTimeUtils.currentTimeMillis(), START_TEMP);
+		}
+		return temperature;
+	}
+
+	public List<TemperatureValue> getTemperatureHistory() {
+		return thermalProfile.getTemperatureHistory();
+	}
+
+	public Parameters getParameters() {
+		return thermalProfile.getParameters();
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/DeviceResourceCharacteristics.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/DeviceResourceCharacteristics.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/DeviceResourceCharacteristics.java	(revision 1207)
@@ -0,0 +1,13 @@
+package schedframe.resources.devices;
+
+import schedframe.resources.computing.ResourceCharacteristics;
+
+public class DeviceResourceCharacteristics extends ResourceCharacteristics{
+
+	protected DeviceResourceCharacteristics(Builder<?> builder) {
+		super(builder);
+		// TODO Auto-generated constructor stub
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/description/PhysicalResourceDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/description/PhysicalResourceDescription.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/description/PhysicalResourceDescription.java	(revision 1207)
@@ -0,0 +1,262 @@
+package schedframe.resources.devices.description;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import schedframe.Parameter;
+import schedframe.Parameters;
+import schedframe.Property;
+import schedframe.resources.ResourceType;
+import schedframe.resources.computing.description.ResourceDescription;
+import schedframe.resources.computing.location.Location;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState;
+import schedframe.resources.computing.profiles.energy.airthroughput.plugin.AirThroughputEstimationPlugin;
+import schedframe.resources.computing.profiles.energy.airthroughput.plugin.DefaultAirThroughputEstimationPlugin;
+import schedframe.resources.computing.profiles.energy.power.PState;
+import schedframe.resources.computing.profiles.energy.power.PowerProfile;
+import schedframe.resources.computing.profiles.energy.power.PowerState;
+import schedframe.resources.computing.profiles.energy.power.PowerStateNameFactory;
+import schedframe.resources.computing.profiles.energy.power.Transition;
+import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin;
+import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile;
+import schedframe.resources.computing.profiles.energy.thermal.plugin.DefaultTemperatureEstimationPlugin;
+import schedframe.resources.computing.profiles.energy.thermal.plugin.TemperatureEstimationPlugin;
+import schemas.PowerUsage;
+import schemas.Profile;
+import simulator.utils.InstanceFactory;
+import example.energy.DefaultEnergyEstimationPlugin;
+
+public class PhysicalResourceDescription extends ResourceDescription{
+
+	protected PowerProfile powerProfile;
+	protected AirThroughputProfile airThroughputProfile;
+	protected ThermalProfile thermalProfile;
+	
+	protected String category;
+	protected Location location;
+	
+	public PhysicalResourceDescription(ResourceType type) {
+		super(type);
+		// TODO Auto-generated constructor stub
+	}
+
+	protected void initProfiles(Profile profile) {
+		if (profile != null) {
+			initPowerProfile(profile.getPowerProfile());
+			initAirThroughputProfile(profile.getAirThroughputProfile());
+			initThermalProfile(profile.getThermalProfile());
+		}
+	}
+	
+	protected void initPowerProfile(schemas.PowerProfile powerProfileCharacteristic) {
+		
+		if (powerProfileCharacteristic != null) {
+			EnergyEstimationPlugin energyEstimationPlugin = null;
+			List<PowerState> powerStates = null;
+			List<PState> pStates = null;
+			if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){
+				String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName();
+				if(energyEstimationPluginName != null) {
+					energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance(
+							energyEstimationPluginName, EnergyEstimationPlugin.class);			
+				} else {
+					energyEstimationPlugin = new DefaultEnergyEstimationPlugin();
+				}
+				Parameters params = extractParameters(powerProfileCharacteristic.getEnergyEstimationPlugin().getParameter());
+				energyEstimationPlugin.init(params);
+			}
+			
+			if(powerProfileCharacteristic.getPowerStates() != null) {
+				powerStates = new ArrayList<PowerState>();
+				int powerStateCount = powerProfileCharacteristic.getPowerStates().getPowerStateCount();
+				for (int i = 0; i < powerStateCount ; i++) {
+					schemas.PowerState ps = powerProfileCharacteristic.getPowerStates().getPowerState(i);
+					List<Transition> transitions = new ArrayList<Transition>();
+					int transitionCount = ps.getTransitionCount();
+					for (int j = 0; j < transitionCount; j++) {
+						schemas.Transition t = ps.getTransition(j);
+						Transition transition = new Transition(PowerStateNameFactory.createPowerStateName(t.getTo()), t
+								.getPowerUsage().getContent(), t.getTime().getContent());
+						Parameters params = extractParameters(t.getParameter());
+						transition.init(params);
+						transitions.add(transition);
+					}
+					//CoolEmAll DEBB description case
+					if(ps.getPowerUsage() == null){
+						ps.setPowerUsage(new PowerUsage("0"));
+					}
+					PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps
+							.getPowerUsage().getContent(), transitions);
+					Parameters params = extractParameters(ps.getParameter());
+					powerState.init(params);
+					powerStates.add(powerState);
+				}
+			}
+			
+			if(powerProfileCharacteristic.getParameter() != null){
+				pStates = new ArrayList<PState>();
+				int parameterCount = powerProfileCharacteristic.getParameterCount();
+				for(int i = 0; i < parameterCount; i++){
+					schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i);
+					if(parameter.getName().equals("pState")){
+						PState.Builder builder = new PState.Builder();
+						int propertyCount = parameter.getParameterTypeSequence().getPropertyCount();
+						for(int j = 0; j < propertyCount; j++){
+							schemas.Property property = parameter.getParameterTypeSequence().getProperty(j);
+							if(property.getName().equals("name")){
+								 builder = builder.name(property.getStringValueWithUnit(0).getContent());
+							} else if (property.getName().equals("frequency")){
+								 builder = builder.frequency(Double.valueOf(property.getStringValueWithUnit(0).getContent()));
+							} else if (property.getName().equals("voltage")){
+								builder = builder.voltage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));
+							} else if (property.getName().equals("powerUsage")){
+								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){
+									builder = builder.powerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));	
+								}
+							} else if (property.getName().equals("powerUsageMin")){
+								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){
+									builder = builder.powerUsageMin(Double.valueOf(property.getStringValueWithUnit(0).getContent()));	
+								}
+							} else if (property.getName().equals("powerUsageMax")){
+								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){
+									builder = builder.powerUsageMax(Double.valueOf(property.getStringValueWithUnit(0).getContent()));	
+								}
+							}else if (property.getName().equals("loadPowerUsage")){
+								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0 &&
+										property.getStringValueWithUnit(1).getContent() != null && property.getStringValueWithUnit(1).getContent().length() > 0){
+									//LoadPowerUsage lpu = new LoadPowerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()), Double.valueOf(property.getStringValueWithUnit(1).getContent()));
+									//builder = builder.loadPowerUsage(lpu);
+									builder.loadPowerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()), Double.valueOf(property.getStringValueWithUnit(1).getContent()));
+								}
+							}
+						}
+						PState pState = builder.build();
+						pStates.add(pState);
+					}
+				}	
+			}
+			this.powerProfile = new PowerProfile(energyEstimationPlugin, powerStates, pStates);
+			Parameters params = extractParameters(powerProfileCharacteristic.getParameter());
+			this.powerProfile.init(params);
+		}
+	}
+
+	protected void initAirThroughputProfile(schemas.AirThroughputProfile airThroughputProfile) {
+		if (airThroughputProfile != null) {
+			
+			AirThroughputEstimationPlugin airThroughputEstimationPlugin = null;
+			List<AirThroughputState> airThroughputStates = null;
+			if(airThroughputProfile.getAirThroughputEstimationPlugin() != null){
+				String airThroughputEstimationPluginName = airThroughputProfile.getAirThroughputEstimationPlugin().getName();
+				if(airThroughputEstimationPluginName != null) {
+					airThroughputEstimationPlugin = (AirThroughputEstimationPlugin) InstanceFactory.createInstance(
+							airThroughputEstimationPluginName, AirThroughputEstimationPlugin.class);			
+				} else {
+					airThroughputEstimationPlugin = new DefaultAirThroughputEstimationPlugin();
+				}
+				Parameters params = extractParameters(airThroughputProfile.getAirThroughputEstimationPlugin().getParameter());
+				airThroughputEstimationPlugin.init(params);
+			}
+			if(airThroughputProfile.getAirThroughputStates() != null){
+				airThroughputStates = new ArrayList<AirThroughputState>();
+				int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount();
+				for (int i = 0; i < airThrouhputStateCount; i++) {
+					schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i);
+					AirThroughputState airThroughputState = new AirThroughputState(ats.getName(), ats.getValue()
+							.getContent(), ats.getPowerUsage().getContent());
+					Parameters params = extractParameters(ats.getParameter());
+					airThroughputState.init(params);
+					airThroughputStates.add(airThroughputState);
+				}
+			}
+			this.airThroughputProfile = new AirThroughputProfile(airThroughputEstimationPlugin, airThroughputStates);
+			Parameters params = extractParameters(airThroughputProfile.getParameter());
+			this.airThroughputProfile.init(params);
+		}
+	}
+	
+	protected void initThermalProfile(schemas.ThermalProfile thermalProfile) {
+		
+		if (thermalProfile != null) {
+			
+			TemperatureEstimationPlugin temperatureEstimationPlugin = null;
+
+			if(thermalProfile.getTemperatureEstimationPlugin() != null){
+				String temperatureEstimationPluginName = thermalProfile.getTemperatureEstimationPlugin().getName();
+				if(temperatureEstimationPluginName != null) {
+					temperatureEstimationPlugin = (TemperatureEstimationPlugin) InstanceFactory.createInstance(
+							temperatureEstimationPluginName, TemperatureEstimationPlugin.class);			
+				} else {
+					temperatureEstimationPlugin = new DefaultTemperatureEstimationPlugin();
+				}
+				Parameters params = extractParameters(thermalProfile.getTemperatureEstimationPlugin().getParameter());
+				temperatureEstimationPlugin.init(params);
+			}
+			this.thermalProfile = new ThermalProfile();
+			Parameters params = extractParameters(thermalProfile.getParameter());
+			this.thermalProfile.init(params);
+		}
+	}
+	
+	protected void initLocation(schemas.Location l) {
+		if (location != null) {
+			this.location = new Location(l.getHorizontal(), l.getVertical(), l.getDepth());
+			Parameters params = extractParameters(l.getParameter());
+			this.location.init(params);
+		}
+	}
+
+	protected Parameters extractParameters(schemas.Parameter[] parameters){
+		
+		Parameters params = null;
+		
+		if(parameters.length != 0)
+			params = new Parameters();
+		
+		for(int i = 0; i < parameters.length; i++){
+			schemas.Parameter parameter = parameters[i];
+			Parameter param = new Parameter(parameter.getName());
+			if(parameter.getParameterTypeSequence() != null && parameter.getParameterTypeSequence().getProperty() != null)
+			{							
+				int propertyCount = parameter.getParameterTypeSequence().getPropertyCount();
+				for(int j = 0; j < propertyCount; j++){
+					schemas.Property property = parameter.getParameterTypeSequence().getProperty(j);
+					Property prop = new Property(property.getName());
+					int stringValueWithUnitCount = property.getStringValueWithUnitCount();
+					for(int k = 0; k < stringValueWithUnitCount; k++){
+						prop.add(property.getStringValueWithUnit(k));
+					}
+					param.addProperty(prop);
+				}
+			} else {
+				int stringValueWithUnitCount =  parameter.getStringValueWithUnitCount();
+				for(int j = 0; j < stringValueWithUnitCount; j++){
+					param.add(parameter.getStringValueWithUnit(j));
+				}
+			}
+			params.put(parameter.getName(), param);
+		}
+		return params;
+	}
+	
+	public PowerProfile getPowerProfile() {
+		return powerProfile;
+	}
+
+	public AirThroughputProfile getAirThroughputProfile() {
+		return airThroughputProfile;
+	}
+
+	public ThermalProfile getThermalProfile() {
+		return thermalProfile;
+	}
+	
+	public Location getLocation() {
+		return location;
+	}
+	
+	public String getCategory() {
+		return category;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/description/DeviceDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/description/DeviceDescription.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/description/DeviceDescription.java	(revision 1207)
@@ -0,0 +1,31 @@
+package schedframe.resources.devices.description;
+
+import schedframe.resources.ResourceTypeFactory;
+import schedframe.resources.utils.ResourceIdGenerator;
+
+public class DeviceDescription extends PhysicalResourceDescription{
+	
+	
+	public DeviceDescription(schemas.Device device) {
+
+		super(ResourceTypeFactory.createResourceType(device.getClazz()));
+		this.category = device.getType();
+		
+		initId(device);
+
+		if (device.getDeviceTypeChoiceSequence() != null) {
+			initProfiles(device.getDeviceTypeChoiceSequence().getProfile());
+			initLocation(device.getDeviceTypeChoiceSequence().getLocation());
+			this.parameters = extractParameters(device.getDeviceTypeChoiceSequence().getParameter());
+		}
+	}
+
+	private void initId(schemas.Device device){
+		this.id = device.getName() != null ? device.getName() : type.getName();
+		if(device.getCount() > 1 || device.getName() == null){
+			this.id = id + "_" + String.valueOf(ResourceIdGenerator.getId(type.getName()));
+		}
+	}
+	
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResource.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResource.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResource.java	(revision 1207)
@@ -0,0 +1,100 @@
+package schedframe.resources.devices;
+
+import schedframe.Initializable;
+import schedframe.events.Event;
+import schedframe.events.EventHandler;
+import schedframe.resources.Resource;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.ResourceType;
+import schedframe.resources.computing.ResourceCharacteristics;
+import schedframe.resources.computing.extensions.Extension;
+import schedframe.resources.computing.extensions.ExtensionList;
+import schedframe.resources.computing.extensions.ExtensionType;
+import schedframe.resources.computing.profiles.energy.EnergyExtension;
+import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;
+import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
+import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
+
+public abstract class PhysicalResource implements Resource, Initializable{
+
+	protected String name;
+	protected ResourceType type;
+	protected String category;
+	protected ResourceStatus status;
+	protected ResourceCharacteristics resourceCharacteristic;
+	protected ExtensionList extensionList;
+
+	
+	public abstract void handleEvent(Event event);
+	
+	public abstract EventHandler getEventHandler();
+	
+	public String getName() {
+		return name;
+	}
+
+	public ResourceType getType() {
+		return type;
+	}
+
+	public String getCategory(){
+		return category;
+	}
+	
+	public abstract void setStatus(ResourceStatus newStatus);
+	
+	public ResourceStatus getStatus() {
+		return status;
+	}
+	
+	private Extension getExtension(ExtensionType type){
+		if (extensionList != null) {
+			for (Extension extension : extensionList) {
+				if (extension.getType() == type) {
+					return extension;
+				}
+			}
+		}
+		return null;
+	}
+	
+	public PowerInterface getPowerInterface(){
+		Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
+		if(extension != null){
+			EnergyExtension ee = (EnergyExtension)extension;
+			return ee.getPowerInterface();
+		}
+		return null;
+	}
+	
+	public AirThroughputInterface getAirThroughputInterface(){
+		Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
+		if(extension != null){
+			EnergyExtension ee = (EnergyExtension)extension;
+			return ee.getAirThroughputInterface();
+		}
+		return null;
+	}
+	
+	public ThermalInterface getThermalInterface(){
+		Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
+		if(extension != null){
+			EnergyExtension ee = (EnergyExtension)extension;
+			return ee.getThermalInterface();
+		}
+		return null;
+	}
+	
+	public ExtensionList getExtensionList() {
+		return extensionList;
+	}
+	
+	protected void accept(Extension e){
+		extensionList.add(e);
+	}
+
+	public ResourceCharacteristics getResourceCharacteristic() {
+		return resourceCharacteristic;
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/DeviceEnergyExtension.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/DeviceEnergyExtension.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/DeviceEnergyExtension.java	(revision 1207)
@@ -0,0 +1,227 @@
+package schedframe.resources.devices;
+
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import schedframe.events.Event;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.extensions.Extension;
+import schedframe.resources.computing.extensions.ExtensionException;
+import schedframe.resources.computing.extensions.ExtensionType;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.EnergyEventType;
+import schedframe.resources.computing.profiles.energy.EnergyExtension;
+import schedframe.resources.computing.profiles.energy.EnergyExtension.Builder;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputInterfaceFactory;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile;
+import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;
+import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;
+import schedframe.resources.computing.profiles.energy.power.PowerProfile;
+import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
+import schedframe.resources.computing.profiles.energy.thermal.ThermalInterfaceFactory;
+import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile;
+import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import simulator.DataCenterWorkloadSimulator;
+
+public class DeviceEnergyExtension implements Extension{
+
+	private Log log = LogFactory.getLog(EnergyExtension.class);
+
+	protected PowerInterface powerInterface;
+	protected PowerProfile powerProfile;
+	
+	protected AirThroughputInterface airFlowInterface;
+	protected AirThroughputProfile airFlowProfile;
+	
+	protected ThermalInterface thermalInterface;
+	protected ThermalProfile thermalProfile;
+	
+  	protected PhysicalResource resource;
+
+
+	public static class Builder {
+		  
+		protected PhysicalResource resource;
+		protected PowerInterface powerInterface;
+		protected PowerProfile powerProfile;
+		
+		protected AirThroughputInterface airFlowInterface;
+		protected AirThroughputProfile airFlowProfile;
+		
+		protected ThermalInterface thermalInterface;
+		protected ThermalProfile thermalProfile;
+		
+		public Builder resource(PhysicalResource res) {this.resource = res; return this;}
+		
+		public Builder powerProfile(PowerProfile pp){this.powerProfile = pp; this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); return this; }
+
+        public Builder airFlowProfile(AirThroughputProfile atp){this.airFlowProfile = atp; this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); return this; }
+
+        public Builder thermalProfile(ThermalProfile tp){this.thermalProfile = tp; this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); return this; }
+
+        public DeviceEnergyExtension build() {
+            return new DeviceEnergyExtension(this);
+        }
+	}
+	
+	private DeviceEnergyExtension(Builder builder) {
+		this.resource = builder.resource;
+		this.powerInterface = builder.powerInterface;
+		this.powerProfile = builder.powerProfile;
+		
+		this.airFlowInterface = builder.airFlowInterface ;
+		this.airFlowProfile = builder.airFlowProfile;
+		
+		this.thermalInterface = builder.thermalInterface;
+		this.thermalProfile = builder.thermalProfile;
+	}
+
+	
+	public boolean supportsEvent(Event event) {
+
+		if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null)
+			return false;
+		if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName()))
+			return true;
+		else if(event.getType().getName().equals(EnergyEventType.FREQUENCY_CHANGED.getName()))
+			return true;
+		else if(event.getType().getName().equals(EnergyEventType.TASK_STARTED.getName()))
+			return true;
+		else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName()))
+			return true;
+		else if(event.getType().getName().equals(EnergyEventType.RESOURCE_UTILIZATION_CHANGED.getName()))
+			return true;
+	
+		if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName()))
+			return true;
+		if(event.getType().getName().equals(EnergyEventType.TEMPERATURE_CHANGED.getName()))
+			return true;
+		
+		else return false;
+	}
+
+	public void handleEvent(Event event) {
+		
+		EnergyEvent enEvent = (EnergyEvent)event;
+		double power = 0;
+		boolean status = false;
+		try{
+			switch (enEvent.getType()) {
+			
+			case POWER_STATE_CHANGED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				/*if(computingResource instanceof ComputingNode){
+					ComputingNode node = (ComputingNode)computingResource;
+					if(event.getData() instanceof PowerState){
+						PowerState newState = (PowerState)event.getData();
+						if(newState == PowerState.ON) {
+							addToPowerUsageHistory(power+node.getPowerInterface().START_COST);
+							addToPowerUsageHistory(DateTimeUtils.currentTimeMillis() + node.getPowerInterface().START_TIME, power);
+						}else if(newState == PowerState.OFF){
+							addToPowerUsageHistory(power+node.getPowerInterface().SHUTDOWN_COST);
+							addToPowerUsageHistory(DateTimeUtils.currentTimeMillis() + node.getPowerInterface().SHUTDOWN_TIME, power);
+						}
+					}
+				}
+				else*/ 
+				
+				status = powerProfile.addToPowerUsageHistory(power);
+				//temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case FREQUENCY_CHANGED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
+				//temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case TASK_STARTED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
+				//temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//thermalProfile.addToTemperatureHistory(temperature);
+				break;
+	
+			case TASK_FINISHED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
+				//temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case RESOURCE_UTILIZATION_CHANGED:
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
+				//temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case AIRFLOW_STATE_CHANGED:
+				double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				airFlowProfile.addToAirFlowHistory(airFlow);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				powerProfile.addToPowerUsageHistory(power);
+				//temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				//thermalProfile.addToTemperatureHistory(temperature);
+				break;
+				
+			case TEMPERATURE_CHANGED:
+				double temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				thermalProfile.addToTemperatureHistory(temperature);
+				break;
+			}
+		}catch(Exception e){
+			
+		}
+		if(status){
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, resource.getFullName()));
+
+		}
+	}
+
+	public void init(Properties properties) throws ExtensionException {
+		// TODO Auto-generated method stub
+	}
+
+	public ExtensionType getType() {
+		return ExtensionType.ENERGY_EXTENSION;
+	}
+
+	/*public ComputingResource getResource() {
+		return computingResource;
+	}
+
+	public void setResource(ComputingResource compRes){
+		this.computingResource = compRes;
+	}*/
+
+	public PowerInterface getPowerInterface() {
+		return powerInterface;
+	}
+
+	public PowerProfile getPowerProfile() {
+		return powerProfile;
+	}
+
+	public AirThroughputInterface getAirThroughputInterface() {
+		return airFlowInterface;
+	}
+
+	public AirThroughputProfile getAirFlowProfile() {
+		return airFlowProfile;
+	}
+	
+	public ThermalProfile getThermalProfile() {
+		return thermalProfile;
+	}
+
+	public ThermalInterface getThermalInterface() {
+		return thermalInterface;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/coolemall/FanAirThroughputInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/coolemall/FanAirThroughputInterface.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/coolemall/FanAirThroughputInterface.java	(revision 1207)
@@ -0,0 +1,22 @@
+package schedframe.resources.devices.coolemall;
+
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.resources.devices.PhysicalResourceAirThroughputInterface;
+
+public class FanAirThroughputInterface extends PhysicalResourceAirThroughputInterface {
+
+	public FanAirThroughputInterface(PhysicalResource resource, AirThroughputProfile airThroughputProfile) {
+		super(resource, airThroughputProfile);
+		this.currentAirThroughputState = new UserAirThroughputStateName("2");
+	}
+	
+	public boolean turnOn(){
+		return setAirThroughputState(new UserAirThroughputStateName("2"));
+	}
+
+	public boolean turnOff(){
+		return setAirThroughputState(new UserAirThroughputStateName("1"));
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourceAirThroughputInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourceAirThroughputInterface.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/devices/PhysicalResourceAirThroughputInterface.java	(revision 1207)
@@ -0,0 +1,111 @@
+package schedframe.resources.devices;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.joda.time.DateTimeUtils;
+
+import schedframe.Parameters;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.EnergyEventType;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;
+
+public class PhysicalResourceAirThroughputInterface implements AirThroughputInterface{
+
+	protected AirThroughputStateName currentAirThroughputState;
+	protected AirThroughputProfile airThroughputProfile;
+	protected PhysicalResource resource;
+	
+	public PhysicalResourceAirThroughputInterface(PhysicalResource resource, AirThroughputProfile airThroughputProfile){
+		this.resource = resource;
+		this.airThroughputProfile = airThroughputProfile;
+		this.currentAirThroughputState = StandardAirThroughputStateName.ON;
+	}
+	
+	public AirThroughputStateName getAirThroughputState() {
+		return currentAirThroughputState;
+	}
+
+	public boolean setAirThroughputState(AirThroughputStateName state) {
+		if(supportAirThroughputState(state)){
+			currentAirThroughputState = state;
+			
+			//TO DO - notifications should be called for all resources starting form the lowest layer
+			resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getFullName()));
+			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));
+			return true;
+		}
+		return false;
+	}
+
+	public boolean supportAirThroughputState(AirThroughputStateName state) {
+		for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){
+			if(airFlowState.getName().equals(state.getName())){
+				return true;
+			}
+		}
+		return false;
+	}
+
+	public List<AirThroughputState> getSupportedAirThroughputStates() throws NoSuchFieldException {
+		List<AirThroughputState> airThroughputStates = new ArrayList<AirThroughputState>();
+		for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){
+			airThroughputStates.add(airFlowState);
+		}
+		return airThroughputStates;
+	}
+
+	public double getAirFlow(AirThroughputStateName state) throws NoSuchFieldException {
+		double airThroughput = 0;
+		if(supportAirThroughputState(state)){
+			for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){
+				if(airFlowState.getName().equals(state.getName())){
+					airThroughput = airFlowState.getValue();
+					break;
+				}
+			}
+		}
+		return airThroughput;
+	}
+
+	public double getPowerConsumption(AirThroughputStateName state) throws NoSuchFieldException {
+		double powerConsumption = 0;
+		if(supportAirThroughputState(state)){
+			for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){
+				if(airFlowState.getName().equals(state.getName())){
+					powerConsumption = airFlowState.getPowerUsage();
+					break;
+				}
+			}
+		}
+		return powerConsumption;
+	}
+	
+	public AirFlowValue getRecentAirFlow() {
+		AirFlowValue airFlow = null;
+		int lastIdx = getAirFlowHistory().size() - 1;
+		if(lastIdx >= 0)
+			airFlow = getAirFlowHistory().get(lastIdx);
+		else {	
+			try {
+				airFlow = new AirFlowValue(DateTimeUtils.currentTimeMillis(), getAirFlow(currentAirThroughputState));
+			} catch (NoSuchFieldException e) {
+			}
+		}
+		return airFlow;
+	}
+	
+	public List<AirFlowValue> getAirFlowHistory(){
+		return airThroughputProfile.getAirThroughputHistory();
+	}
+	
+	public Parameters getParameters() {
+		return airThroughputProfile.getParameters();
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/properties/ResourceProperties.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/properties/ResourceProperties.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/properties/ResourceProperties.java	(revision 1207)
@@ -3,5 +3,5 @@
 import java.util.Properties;
 
-import schedframe.resources.computing.description.AbstractResourceDescription;
+import schedframe.resources.computing.description.ResourceDescription;
 
 public class ResourceProperties extends Properties{
@@ -16,5 +16,5 @@
 	}
 	
-	public ResourceProperties(AbstractResourceDescription ard){
+	public ResourceProperties(ResourceDescription ard){
 		
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java	(revision 1005)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java	(revision 1207)
@@ -9,5 +9,4 @@
 import java.util.Properties;
 
-import schedframe.Initializable;
 import schedframe.events.Event;
 import schedframe.events.EventHandler;
@@ -17,18 +16,12 @@
 import schedframe.events.scheduling.SchedulingEventCommand;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.Resource;
 import schedframe.resources.ResourceStatus;
 import schedframe.resources.ResourceType;
 import schedframe.resources.computing.description.ComputingResourceDescription;
 import schedframe.resources.computing.extensions.Extension;
-import schedframe.resources.computing.extensions.ExtensionList;
 import schedframe.resources.computing.extensions.ExtensionListImpl;
-import schedframe.resources.computing.extensions.ExtensionType;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
 import schedframe.resources.computing.profiles.energy.EnergyEventType;
 import schedframe.resources.computing.profiles.energy.EnergyExtension;
-import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;
-import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
-import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
 import schedframe.resources.computing.properties.DefaultPropertiesBuilder;
 import schedframe.resources.computing.properties.PropertiesDirector;
@@ -38,15 +31,9 @@
 import schedframe.resources.computing.validator.ResourceTypeValidator;
 import schedframe.resources.computing.validator.ResourceValidator;
-import schedframe.resources.units.PEUnit;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.Scheduler;
 
-public class ComputingResource implements Resource, Initializable{
-	
-	protected String name;
-	protected ResourceType type;
-	protected String category;
-	protected ResourceStatus status;
+public class ComputingResource extends PhysicalResource{
 
 	protected ComputingResource parent;
@@ -54,11 +41,6 @@
 	
 	protected Scheduler scheduler;
-	protected ResourceCharacteristics resourceCharacteristic;
-	protected ExtensionList extensionList;
-	
-
-	public ExtensionList getExtensionList() {
-		return extensionList;
-	}
+	//protected ResourceCharacteristics resourceCharacteristic;
+
 
 	public ComputingResource(ComputingResourceDescription resDesc) {
@@ -69,24 +51,12 @@
 		this.extensionList = new ExtensionListImpl(1);
 		initCharacteristics(resDesc);
-		accept(new EnergyExtension(this, resDesc.getPowerProfile(), resDesc.getAirThroughputProfile(), resDesc.getThermalProfile()));	
-		addFakeProcessors();
-	}
-
-	//TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method
-	private void addFakeProcessors() {
-		if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){
-			for(ResourceUnit resUnit: getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE)){
-				PEUnit peUnit = (PEUnit) resUnit;
-				for(int i = 0; i < peUnit.getAmount(); i++){
-					schemas.ComputingResource fakeCompResource = new schemas.ComputingResource();
-					fakeCompResource.setClazz("Processor");
-					addChild(ResourceFactory.createResource(new ComputingResourceDescription(fakeCompResource)));
-				}
-			}
-		}
+		accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airFlowProfile(resDesc.getAirThroughputProfile()).thermalProfile(resDesc.getThermalProfile()).build());	
 	}
 
 	protected void initCharacteristics(ComputingResourceDescription resDesc){
-		resourceCharacteristic = new ResourceCharacteristics.Builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).build();
+		resourceCharacteristic = ComputingResourceCharacteristics.builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).device(resDesc.getDevices()).build();
+		for(Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()){
+			device.setComputingResource(this);
+		}
 	}
 	
@@ -112,8 +82,4 @@
 	}
 
-	public String getName() {
-		return name;
-	}
-	
 	public String getFullName() {
 		if(this.getResourceCharacteristic().getParameters().get("fullPath") != null){
@@ -127,14 +93,6 @@
 	}
 
-	public ResourceType getType() {
-		return type;
-	}
-
-	public ResourceCharacteristics getResourceCharacteristic() {
-		return resourceCharacteristic;
-	}
-
-	public ResourceStatus getStatus() {
-		return status;
+	public ComputingResourceCharacteristics getResourceCharacteristic() {
+		return (ComputingResourceCharacteristics)resourceCharacteristic;
 	}
 
@@ -245,46 +203,4 @@
 	}
 	
-	public String getCategory(){
-		return category;
-	}
-	
-	public PowerInterface getPowerInterface(){
-		Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
-		if(extension != null){
-			EnergyExtension ee = (EnergyExtension)extension;
-			return ee.getPowerInterface();
-		}
-		return null;
-	}
-	
-	public AirThroughputInterface getAirThroughputInterface(){
-		Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
-		if(extension != null){
-			EnergyExtension ee = (EnergyExtension)extension;
-			return ee.getAirThroughputInterface();
-		}
-		return null;
-	}
-	
-	public ThermalInterface getThermalInterface(){
-		Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION);
-		if(extension != null){
-			EnergyExtension ee = (EnergyExtension)extension;
-			return ee.getThermalInterface();
-		}
-		return null;
-	}
-
-	private Extension getExtension(ExtensionType type){
-		if (extensionList != null) {
-			for (Extension extension : extensionList) {
-				if (extension.getType() == type) {
-					return extension;
-				}
-			}
-		}
-		return null;
-	}
-	
 	public Scheduler getScheduler() {
 		return scheduler;
@@ -307,4 +223,12 @@
 					if (extension.supportsEvent(event)) {
 						extension.handleEvent(event);
+					}
+				}
+				
+				for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) {
+					for (Extension extension : device.getExtensionList()) {
+						if (extension.supportsEvent(event)) {
+							//extension.handleEvent(event);
+						}
 					}
 				}
@@ -332,6 +256,8 @@
 	}
 	
-	public void initiate(){
-		
+	public final void initiate(){
+		for(Device dev: this.getResourceCharacteristic().getDevices()){
+			dev.initiate();
+		}
 		ResourceEventCommand rec = new ResourceEventCommand(this);
 		EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller");
@@ -343,12 +269,14 @@
 		rec.execute(event);
 		
+		rec = new ResourceEventCommand(this);
+		event = new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, "Resource controller");
+		event.setReason(EventReason.SIM_INIT);
+		rec.execute(event);
+		
 		//alternative way
 		//getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"));
 		//getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"));
 	}
-	
-	
-	private void accept(EnergyExtension e){
-		extensionList.add(e);
-	}
+
+
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceFactory.java	(revision 1095)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceFactory.java	(revision 1207)
@@ -1,79 +1,20 @@
 package schedframe.resources.computing;
 
-import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.description.ComputingResourceDescription;
-import schedframe.resources.computing.recs.ComputeBox1;
-import schedframe.resources.computing.recs.Node;
-import schedframe.resources.computing.recs.NodeGroup;
 import schedframe.scheduling.Scheduler;
 import schedframe.scheduling.manager.resources.ManagedResources;
 import schedframe.scheduling.plugin.SchedulingPlugin;
 import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin;
-import schedframe.scheduling.policy.AbstractManagementSystem;
-import schedframe.scheduling.policy.global.GridBroker;
-import schedframe.scheduling.policy.local.LocalManagementSystem;
 import schedframe.scheduling.queue.TaskQueueList;
-import simulator.DCWormsConstants;
 
 
-public class ResourceFactory {
+public interface ResourceFactory {
 
-	public static ComputingResource createResource(ComputingResourceDescription resDesc){
-		
-		if (resDesc.getType().equals(StandardResourceType.DataCenter))
-			return new DataCenter(resDesc);
-		else if (resDesc.getType().equals(StandardResourceType.Rack))
-			return new Rack(resDesc);
-		else if (resDesc.getType().equals(StandardResourceType.ComputingNode))
-			return new ComputingNode(resDesc);
-		else if (resDesc.getType().equals(StandardResourceType.Processor))
-			return new Processor(resDesc);
-		else if (resDesc.getType().equals(StandardResourceType.Core))
-			return new Core(resDesc);
-		else if (resDesc.getType().equals(CoolEmAllResourceType.ComputeBox1))
-			return new ComputeBox1(resDesc);
-		else if (resDesc.getType().equals(CoolEmAllResourceType.NodeGroup))
-			return new NodeGroup(resDesc);
-		else if (resDesc.getType().equals(CoolEmAllResourceType.Node))
-			return new Node(resDesc);
-		else if (resDesc.getType().equals(CoolEmAllResourceType.Processor))
-			return new Processor(resDesc);
-		else if (resDesc.getType().equals(CoolEmAllResourceType.Core))
-			return new Core(resDesc);
-		else
-			return new ComputingResource(resDesc);
+	public ComputingResource createComputingResource(ComputingResourceDescription resDesc);
+
+	//public Device createDevice(DeviceDescription devDesc);
 	
-		/*switch(resDesc.getType()){
-			case Grid: return new Grid(resDesc);
-			case DataCenter: return new DataCenter(resDesc);
-			case ComputingNode: return new ComputingNode(resDesc);
-			case Processor: return new Processor(resDesc);
-		default:
-			return new ComputingResource(resDesc);
-		}*/
-	}
-
-	public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{
-		AbstractManagementSystem ms;
-		switch(type){
-			case GS: {
-				ms = new GridBroker("grid",
-						schedulingPlugin, execTimeEstimationPlugin, queues);
-				return new Scheduler(ms, type, managedResources);
-			}
-			case LS: {
-				ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
-						schedulingPlugin, execTimeEstimationPlugin, queues);
-				return new Scheduler(ms, type, managedResources);
-			}
-
-		default:{
-				ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
-						schedulingPlugin, execTimeEstimationPlugin, queues);
-				return new Scheduler(ms, type, managedResources);
-			}
-		}
-	}
+	public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception;
 }
 
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Processor.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Processor.java	(revision 883)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Processor.java	(revision 1207)
@@ -9,6 +9,4 @@
 import schedframe.resources.computing.extensions.ExtensionType;
 import schedframe.resources.computing.profiles.energy.EnergyExtension;
-import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;
-import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
 import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface;
 import schedframe.resources.computing.properties.CpuPropertiesBuilder;
@@ -27,7 +25,15 @@
 	}
 
-
-	public ComputingNode getComputingNode(){
-		return (ComputingNode)parent;
+	public ComputingNode getNode(){
+		ComputingResource compRes = parent;
+		while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){
+			compRes = compRes.getParent();
+		}
+		ComputingNode compNode = null;
+		try{
+			compNode = (ComputingNode)compRes;
+		} catch(Exception e) {
+		}
+		return compNode;
 	}
 	
@@ -63,5 +69,5 @@
 
 	private CpuSpeed getSpeedUnit() throws NoSuchFieldException{
-		return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED);
+		return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED);
 	}
 	
@@ -80,7 +86,7 @@
 		super.initCharacteristics(resDesc);
 		try{
-			resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0));
+			((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0));
 		} catch(Exception e){
-			resourceCharacteristic.addResourceUnit(new CpuSpeed(name,  1, 0));
+			((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name,  1, 0));
 		}
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Rack.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Rack.java	(revision 756)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Rack.java	(revision 1207)
@@ -5,7 +5,4 @@
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.description.ComputingResourceDescription;
-import schedframe.resources.computing.profiles.energy.EnergyExtension;
-import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;
-import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
 
 public class Rack extends ComputingResource{
@@ -20,5 +17,5 @@
 	@SuppressWarnings("unchecked")
 	public List<ComputingNode> getComputingNodes(){
-		return (List<ComputingNode>) getDescendantsByType(StandardResourceType.ComputingNode);
+		return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node);
 	}
 	
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceCharacteristics.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceCharacteristics.java	(revision 1007)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceCharacteristics.java	(revision 1207)
@@ -1,13 +1,6 @@
 package schedframe.resources.computing;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 import schedframe.Parameters;
 import schedframe.resources.computing.location.Location;
-import schedframe.resources.units.ResourceUnit;
-import schedframe.resources.units.ResourceUnitName;
 
 
@@ -16,7 +9,8 @@
 	private static final long serialVersionUID = 2719535186621622647L;
 
-	protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
+	protected Location location;
 	protected Parameters parameters;
-	protected Location location;
+	//protected Location location;
+	//protected List<Device> devices;
 
 	/*public ResourceCharacteristics(Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits){
@@ -32,54 +26,6 @@
 	}*/
 	
-	public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() {
-		if(resUnits == null)
-			return new HashMap<ResourceUnitName, List<ResourceUnit>>();
-		return resUnits;
-	}
+
 	
-	public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException{
-		if(getResourceUnits().containsKey(unitName))
-			return getResourceUnits().get(unitName).get(0);
-		else throw new NoSuchFieldException("Resource unit " + unitName + 
-				" is not available in this resource ");
-	}
-	
-	public void addResourceUnit(ResourceUnit unit){ 
-		if(resUnits == null){
-			resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2);
-		}
-		List<ResourceUnit> list = null;
-		if(resUnits.containsKey(unit.getName())){
-			list = resUnits.get(unit.getName());
-		} else {
-			list = new ArrayList<ResourceUnit>(1);
-			resUnits.put(unit.getName(), list);
-		}
-		list.add(unit);
-	}
-	
-	
-	public static class Builder {
-		  
-		protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
-		protected Location location;
-		protected Parameters parameters;
-		
-		public Builder location(Location loc){this.location = loc; return this; }
-        public Builder parameters(Parameters params){this.parameters = params; return this; }
-        public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; }
-        public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; }
-        
-        public ResourceCharacteristics build() {
-            return new ResourceCharacteristics(this);
-        }
-	}
-	
-	private ResourceCharacteristics(Builder builder) {
-		this.location = builder.location;
-		this.parameters = builder.parameters;
-		this.resUnits = builder.resUnits;
-	}
-
 	public Parameters getParameters() {
 		if(parameters == null)
@@ -91,4 +37,56 @@
 		return location;
 	}
+	
+	protected ResourceCharacteristics(Builder<?> builder) {
+		//this.location = builder.location;
+		this.parameters = builder.parameters;
+		this.location = builder.location;
+		//this.devices = builder.devices;
+	}
+	
+    public static abstract class Builder<T extends Builder<T>> {
+  	  
+		protected Location location;
+		protected Parameters parameters;
+
+        public T parameters(Parameters params){this.parameters = params; return self(); }
+		public T location(Location loc){this.location = loc; return self(); }
+		
+        protected abstract T self();
+
+        public ResourceCharacteristics build() {
+            return new ResourceCharacteristics(this);
+        }
+    }
+    private static class Builder2 extends Builder<Builder2> {
+        @Override
+        protected Builder2 self() {
+            return this;
+        }
+    }
+
+    public static Builder<?> builder() {
+        return new Builder2();
+    }
+	
+	/*public static class Builder {
+		  
+		protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
+		//protected Location location;
+		protected Parameters parameters;
+		//protected List<Device> devices;
+		
+		//public Builder location(Location loc){this.location = loc; return this; }
+        public Builder parameters(Parameters params){this.parameters = params; return this; }
+        //public Builder device(List<Device> dev){this.devices = dev; return this; }
+        public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; }
+        public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; }
+        
+        public ResourceCharacteristics build() {
+            return new ResourceCharacteristics(this);
+        }
+	}
+	*/
+
 
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/Node.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/Node.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/Node.java	(revision 1207)
@@ -0,0 +1,34 @@
+package schedframe.resources.computing.coolemall;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.description.ComputingResourceDescription;
+
+public class Node extends ComputingNode{
+
+	public Node(ComputingResourceDescription resDesc) {
+		super(resDesc);
+		// TODO Auto-generated constructor stub
+	}
+	
+	public List<Core> getCores(){
+		List<Core> cores = new ArrayList<Core>();
+		for(Processor proc: getProcessors()){
+			cores.addAll(proc.getCores());
+		}
+		return cores;
+	}
+
+	public List<Core> getFreeCores(){
+		List<Core> freeCores = new ArrayList<Core>();
+		for(Processor proc: getProcessors()){
+			freeCores.addAll(proc.getFreeCores());
+		}
+		return freeCores;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox1.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox1.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox1.java	(revision 1207)
@@ -0,0 +1,28 @@
+package schedframe.resources.computing.coolemall;
+
+import java.util.List;
+
+import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.Rack;
+import schedframe.resources.computing.description.ComputingResourceDescription;
+
+public class ComputeBox1 extends Rack{
+	
+	public ComputeBox1(ComputingResourceDescription resDesc) {
+		super(resDesc);
+	}
+
+	@SuppressWarnings("unchecked")
+	public List<NodeGroup> getNodesGroups(){
+		return (List<NodeGroup>) getDescendantsByType(CoolEmAllResourceType.NodeGroup);
+	}
+	
+	@SuppressWarnings("unchecked")
+	public List<ComputingNode> getNodes(){
+		return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node);
+	}
+
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox2.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox2.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox2.java	(revision 1207)
@@ -0,0 +1,13 @@
+package schedframe.resources.computing.coolemall;
+
+import schedframe.resources.computing.DataCenter;
+import schedframe.resources.computing.description.ComputingResourceDescription;
+
+public class ComputeBox2 extends DataCenter {
+
+	public ComputeBox2(ComputingResourceDescription resDesc) {
+		super(resDesc);
+		// TODO Auto-generated constructor stub
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java	(revision 1207)
@@ -0,0 +1,26 @@
+package schedframe.resources.computing.coolemall;
+
+import java.util.List;
+
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.description.ComputingResourceDescription;
+
+public class NodeGroup extends ComputingResource{
+	
+	public NodeGroup(ComputingResourceDescription resDesc) {
+		super(resDesc);
+	}
+
+	@SuppressWarnings("unchecked")
+	public List<Node> getNodes(){
+		return (List<Node>) getDescendantsByType(StandardResourceType.Node);
+	}
+	
+	@SuppressWarnings("unchecked")
+	public List<Processor> getProcessors(){
+		return (List<Processor>) getDescendantsByType(StandardResourceType.Processor);
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Core.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Core.java	(revision 756)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Core.java	(revision 1207)
@@ -1,8 +1,6 @@
 package schedframe.resources.computing;
 
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.description.ComputingResourceDescription;
-import schedframe.resources.computing.profiles.energy.EnergyExtension;
-import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;
-import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
 import schedframe.resources.units.CpuSpeed;
 import schedframe.resources.units.StandardResourceUnitName;
@@ -18,5 +16,27 @@
 
 	public Processor getProcessor(){
-		return (Processor)parent;
+		ComputingResource compRes = parent;
+		while(compRes != null && !compRes.getType().equals(StandardResourceType.Processor)){
+			compRes = compRes.getParent();
+		}
+		Processor proc = null;
+		try{
+			proc = (Processor)compRes;
+		} catch(ClassCastException e) {
+		}
+		return proc;
+	}
+	
+	public ComputingNode getNode(){
+		ComputingResource compRes = parent;
+		while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){
+			compRes = compRes.getParent();
+		}
+		ComputingNode compNode = null;
+		try{
+			compNode = (ComputingNode)compRes;
+		} catch(ClassCastException e) {
+		}
+		return compNode;
 	}
 	
@@ -42,5 +62,5 @@
 
 	private CpuSpeed getSpeedUnit() throws NoSuchFieldException{
-		return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED);
+		return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED);
 	}
 
@@ -48,7 +68,7 @@
 		super.initCharacteristics(resDesc);
 		try{
-			resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0));
+			((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0));
 		} catch(Exception e){
-			resourceCharacteristic.addResourceUnit(new CpuSpeed(name,  1, 0));
+			((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name,  1, 0));
 		}
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/StandardResourceFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/StandardResourceFactory.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/StandardResourceFactory.java	(revision 1207)
@@ -0,0 +1,64 @@
+package schedframe.resources.computing;
+
+import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.description.ComputingResourceDescription;
+import schedframe.scheduling.Scheduler;
+import schedframe.scheduling.manager.resources.ManagedResources;
+import schedframe.scheduling.plugin.SchedulingPlugin;
+import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin;
+import schedframe.scheduling.policy.AbstractManagementSystem;
+import schedframe.scheduling.policy.global.GridBroker;
+import schedframe.scheduling.policy.local.LocalManagementSystem;
+import schedframe.scheduling.queue.TaskQueueList;
+import simulator.DCWormsConstants;
+
+public class StandardResourceFactory implements ResourceFactory {
+	
+	public ComputingResource createComputingResource(ComputingResourceDescription resDesc){
+		
+		if (resDesc.getType().equals(StandardResourceType.DataCenter))
+			return new DataCenter(resDesc);
+		else if (resDesc.getType().equals(StandardResourceType.Rack))
+			return new Rack(resDesc);
+		else if (resDesc.getType().equals(StandardResourceType.Node))
+			return new ComputingNode(resDesc);
+		else if (resDesc.getType().equals(StandardResourceType.Processor))
+			return new Processor(resDesc);
+		else if (resDesc.getType().equals(StandardResourceType.Core))
+			return new Core(resDesc);
+		else
+			return new ComputingResource(resDesc);
+	
+		/*switch(resDesc.getType()){
+			case Grid: return new Grid(resDesc);
+			case DataCenter: return new DataCenter(resDesc);
+			case ComputingNode: return new ComputingNode(resDesc);
+			case Processor: return new Processor(resDesc);
+		default:
+			return new ComputingResource(resDesc);
+		}*/
+	}
+
+	public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{
+		AbstractManagementSystem ms;
+		switch(type){
+			case GS: {
+				ms = new GridBroker("grid",
+						schedulingPlugin, execTimeEstimationPlugin, queues);
+				return new Scheduler(ms, type, managedResources);
+			}
+			case LS: {
+				ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
+						schedulingPlugin, execTimeEstimationPlugin, queues);
+				return new Scheduler(ms, type, managedResources);
+			}
+
+		default:{
+				ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
+						schedulingPlugin, execTimeEstimationPlugin, queues);
+				return new Scheduler(ms, type, managedResources);
+			}
+		}
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ComputingResourceDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ComputingResourceDescription.java	(revision 1113)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ComputingResourceDescription.java	(revision 1207)
@@ -1,49 +1,28 @@
 package schedframe.resources.computing.description;
 
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
+import java.util.Map;
 
-import schedframe.Parameter;
 import schedframe.Parameters;
-import schedframe.Property;
 import schedframe.resources.ResourceTypeFactory;
-import schedframe.resources.computing.location.Location;
-import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile;
-import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState;
-import schedframe.resources.computing.profiles.energy.airthroughput.plugin.AirThroughputEstimationPlugin;
-import schedframe.resources.computing.profiles.energy.airthroughput.plugin.DefaultAirThroughputEstimationPlugin;
-import schedframe.resources.computing.profiles.energy.power.PState;
-import schedframe.resources.computing.profiles.energy.power.PowerProfile;
-import schedframe.resources.computing.profiles.energy.power.PowerState;
-import schedframe.resources.computing.profiles.energy.power.PowerStateNameFactory;
-import schedframe.resources.computing.profiles.energy.power.Transition;
-import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin;
-import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile;
-import schedframe.resources.computing.profiles.energy.thermal.plugin.DefaultTemperatureEstimationPlugin;
-import schedframe.resources.computing.profiles.energy.thermal.plugin.TemperatureEstimationPlugin;
+import schedframe.resources.devices.Device;
+import schedframe.resources.devices.description.DeviceDescription;
+import schedframe.resources.devices.description.PhysicalResourceDescription;
 import schedframe.resources.units.ResourceUnit;
 import schedframe.resources.units.ResourceUnitFactory;
+import schedframe.resources.units.ResourceUnitName;
 import schedframe.resources.utils.ResourceIdGenerator;
 import schemas.ComputingResource;
-import schemas.PowerUsage;
-import schemas.Profile;
-import simulator.utils.InstanceFactory;
-import example.energy.DefaultEnergyEstimationPlugin;
 
-public class ComputingResourceDescription extends ExecutingResourceDescription {
 
-	//protected Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits;
-	protected PowerProfile powerProfile;
-	protected AirThroughputProfile airThroughputProfile;
-	protected ThermalProfile thermalProfile;
-	protected Location location;
-	protected String category;
-	//protected Parameters parameters;
+public class ComputingResourceDescription extends PhysicalResourceDescription implements ExecutingResourceDescription {
 
+	protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
+	protected List<Device> devices;
+	
 	public ComputingResourceDescription(ComputingResource computingResource) {
 
@@ -55,25 +34,8 @@
 		if (computingResource.getComputingResourceTypeChoiceSequence() != null) {
 			initResourceUnits(computingResource.getComputingResourceTypeChoiceSequence().getResourceUnit());
-			try {
-				if(System.getProperty("coolemall.resdesc") != null){
-					schemas.EnergyEstimationPlugin eep = new schemas.EnergyEstimationPlugin();
-					eep.setName(getEEP(createEEPQuery(computingResource), System.getProperty("coolemall.resdesc")));
-					if(computingResource.getComputingResourceTypeChoiceSequence().getProfile() != null) {
-						if(computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile() != null) {
-							computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep);
-						}
-					} else {
-						schemas.Profile p = new schemas.Profile();
-						computingResource.getComputingResourceTypeChoiceSequence().setProfile(p);
-						schemas.PowerProfile pp = new schemas.PowerProfile();
-						computingResource.getComputingResourceTypeChoiceSequence().getProfile().setPowerProfile(pp);
-						computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep);
-					}
-				}
-			} catch (FileNotFoundException e) {
-			} catch (IOException e) {
-			}
+
 			initProfiles(computingResource.getComputingResourceTypeChoiceSequence().getProfile());
 			initLocation(computingResource.getComputingResourceTypeChoiceSequence().getLocation());
+			initDevices(computingResource.getComputingResourceTypeChoiceSequence().getDevice());
 			this.parameters = extractParameters(computingResource.getComputingResourceTypeChoiceSequence().getParameter());
 		}
@@ -97,164 +59,18 @@
 		}
 	}
-
-	private void initProfiles(Profile profile) {
-		if (profile != null) {
-			initPowerProfile(profile.getPowerProfile());
-			initAirThroughputProfile(profile.getAirThroughputProfile());
-			initThermalProfile(profile.getThermalProfile());
-		}
-	}
 	
-	private void initPowerProfile(schemas.PowerProfile powerProfileCharacteristic) {
-		
-		if (powerProfileCharacteristic != null) {
-			EnergyEstimationPlugin energyEstimationPlugin = null;
-			List<PowerState> powerStates = null;
-			List<PState> pStates = null;
-			if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){
-				String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName();
-				if(energyEstimationPluginName != null) {
-					energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance(
-							energyEstimationPluginName, EnergyEstimationPlugin.class);			
-				} else {
-					energyEstimationPlugin = new DefaultEnergyEstimationPlugin();
-				}
-				Parameters params = extractParameters(powerProfileCharacteristic.getEnergyEstimationPlugin().getParameter());
-				energyEstimationPlugin.init(params);
+	private void initDevices(schemas.Device[] dev) {
+		if (dev != null){
+			this.devices = new ArrayList<Device>();
+			for(int i = 0; i < dev.length; i++){
+				Device device = new Device(new DeviceDescription(dev[i]));
+				this.devices.add(device);
 			}
-			
-			if(powerProfileCharacteristic.getPowerStates() != null) {
-				powerStates = new ArrayList<PowerState>();
-				int powerStateCount = powerProfileCharacteristic.getPowerStates().getPowerStateCount();
-				for (int i = 0; i < powerStateCount ; i++) {
-					schemas.PowerState ps = powerProfileCharacteristic.getPowerStates().getPowerState(i);
-					List<Transition> transitions = new ArrayList<Transition>();
-					int transitionCount = ps.getTransitionCount();
-					for (int j = 0; j < transitionCount; j++) {
-						schemas.Transition t = ps.getTransition(j);
-						Transition transition = new Transition(PowerStateNameFactory.createPowerStateName(t.getTo()), t
-								.getPowerUsage().getContent(), t.getTime().getContent());
-						Parameters params = extractParameters(t.getParameter());
-						transition.init(params);
-						transitions.add(transition);
-					}
-					//CoolEmAll DEBB description case
-					if(ps.getPowerUsage() == null){
-						ps.setPowerUsage(new PowerUsage("0"));
-					}
-					PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps
-							.getPowerUsage().getContent(), transitions);
-					Parameters params = extractParameters(ps.getParameter());
-					powerState.init(params);
-					powerStates.add(powerState);
-				}
-			}
-			
-			if(powerProfileCharacteristic.getParameter() != null){
-				pStates = new ArrayList<PState>();
-				int parameterCount = powerProfileCharacteristic.getParameterCount();
-				for(int i = 0; i < parameterCount; i++){
-					schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i);
-					if(parameter.getName().equals("pState")){
-						PState.Builder builder = new PState.Builder();
-						int propertyCount = parameter.getParameterTypeSequence().getPropertyCount();
-						for(int j = 0; j < propertyCount; j++){
-							schemas.Property property = parameter.getParameterTypeSequence().getProperty(j);
-							if(property.getName().equals("name")){
-								 builder = builder.name(property.getStringValueWithUnit(0).getContent());
-							} else if (property.getName().equals("frequency")){
-								 builder = builder.frequency(Double.valueOf(property.getStringValueWithUnit(0).getContent()));
-							} else if (property.getName().equals("voltage")){
-								builder = builder.voltage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));
-							} else if (property.getName().equals("powerUsage")){
-								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){
-									builder = builder.powerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));	
-								}
-							} else if (property.getName().equals("powerUsageMin")){
-								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){
-									builder = builder.powerUsageMin(Double.valueOf(property.getStringValueWithUnit(0).getContent()));	
-								}
-							} else if (property.getName().equals("powerUsageMax")){
-								if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){
-									builder = builder.powerUsageMax(Double.valueOf(property.getStringValueWithUnit(0).getContent()));	
-								}
-							}
-						}
-						PState pState = builder.build();
-						pStates.add(pState);
-					}
-				}	
-			}
-			this.powerProfile = new PowerProfile(energyEstimationPlugin, powerStates, pStates);
-			Parameters params = extractParameters(powerProfileCharacteristic.getParameter());
-			this.powerProfile.init(params);
 		}
 	}
 
-	private void initAirThroughputProfile(schemas.AirThroughputProfile airThroughputProfile) {
-		if (airThroughputProfile != null) {
-			
-			AirThroughputEstimationPlugin airThroughputEstimationPlugin = null;
-			List<AirThroughputState> airThroughputStates = null;
-			if(airThroughputProfile.getAirThroughputEstimationPlugin() != null){
-				String airThroughputEstimationPluginName = airThroughputProfile.getAirThroughputEstimationPlugin().getName();
-				if(airThroughputEstimationPluginName != null) {
-					airThroughputEstimationPlugin = (AirThroughputEstimationPlugin) InstanceFactory.createInstance(
-							airThroughputEstimationPluginName, AirThroughputEstimationPlugin.class);			
-				} else {
-					airThroughputEstimationPlugin = new DefaultAirThroughputEstimationPlugin();
-				}
-				Parameters params = extractParameters(airThroughputProfile.getAirThroughputEstimationPlugin().getParameter());
-				airThroughputEstimationPlugin.init(params);
-			}
-			if(airThroughputProfile.getAirThroughputStates() != null){
-				airThroughputStates = new ArrayList<AirThroughputState>();
-				int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount();
-				for (int i = 0; i < airThrouhputStateCount; i++) {
-					schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i);
-					AirThroughputState airThroughputState = new AirThroughputState(ats.getName(), ats.getValue()
-							.getContent(), ats.getPowerUsage().getContent());
-					Parameters params = extractParameters(ats.getParameter());
-					airThroughputState.init(params);
-					airThroughputStates.add(airThroughputState);
-				}
-			}
-			this.airThroughputProfile = new AirThroughputProfile(airThroughputEstimationPlugin, airThroughputStates);
-			Parameters params = extractParameters(airThroughputProfile.getParameter());
-			this.airThroughputProfile.init(params);
-		}
+	public String getCompResourceParameterValue(String name){
+		return getParameters().get(name).get(0).getContent();
 	}
-	
-	private void initThermalProfile(schemas.ThermalProfile thermalProfile) {
-		
-		if (thermalProfile != null) {
-			
-			TemperatureEstimationPlugin temperatureEstimationPlugin = null;
-
-			if(thermalProfile.getTemperatureEstimationPlugin() != null){
-				String temperatureEstimationPluginName = thermalProfile.getTemperatureEstimationPlugin().getName();
-				if(temperatureEstimationPluginName != null) {
-					temperatureEstimationPlugin = (TemperatureEstimationPlugin) InstanceFactory.createInstance(
-							temperatureEstimationPluginName, TemperatureEstimationPlugin.class);			
-				} else {
-					temperatureEstimationPlugin = new DefaultTemperatureEstimationPlugin();
-				}
-				Parameters params = extractParameters(thermalProfile.getTemperatureEstimationPlugin().getParameter());
-				temperatureEstimationPlugin.init(params);
-			}
-			this.thermalProfile = new ThermalProfile();
-			Parameters params = extractParameters(thermalProfile.getParameter());
-			this.thermalProfile.init(params);
-		}
-	}
-	
-	private void initLocation(schemas.Location l) {
-		if (location != null) {
-			this.location = new Location(l.getHorizontal(), l.getVertical(), l.getDepth());
-			Parameters params = extractParameters(l.getParameter());
-			this.location.init(params);
-		}
-	}
-
 
 	/*private Properties initProperties(schemas.Parameter[] parameters){
@@ -285,78 +101,52 @@
 		return prop;
 	}*/
-	
-	private Parameters extractParameters(schemas.Parameter[] parameters){
-		
-		Parameters params = null;
-		
-		if(parameters.length != 0)
-			params = new Parameters();
-		
-		for(int i = 0; i < parameters.length; i++){
-			schemas.Parameter parameter = parameters[i];
-			Parameter param = new Parameter(parameter.getName());
-			if(parameter.getParameterTypeSequence() != null && parameter.getParameterTypeSequence().getProperty() != null)
-			{							
-				int propertyCount = parameter.getParameterTypeSequence().getPropertyCount();
-				for(int j = 0; j < propertyCount; j++){
-					schemas.Property property = parameter.getParameterTypeSequence().getProperty(j);
-					Property prop = new Property(property.getName());
-					int stringValueWithUnitCount = property.getStringValueWithUnitCount();
-					for(int k = 0; k < stringValueWithUnitCount; k++){
-						prop.add(property.getStringValueWithUnit(k));
-					}
-					param.addProperty(prop);
-				}
-			} else {
-				int stringValueWithUnitCount =  parameter.getStringValueWithUnitCount();
-				for(int j = 0; j < stringValueWithUnitCount; j++){
-					param.add(parameter.getStringValueWithUnit(j));
-				}
-			}
-			params.put(parameter.getName(), param);
-		}
-		return params;
-	}
 
-	public PowerProfile getPowerProfile() {
-		return powerProfile;
-	}
 
-	public AirThroughputProfile getAirThroughputProfile() {
-		return airThroughputProfile;
-	}
-
-	public ThermalProfile getThermalProfile() {
-		return thermalProfile;
-	}
-	
-	public Location getLocation() {
-		return location;
-	}
-
-	public String getCategory() {
-		return category;
+	public List<Device> getDevices() {
+		return devices;
 	}
 
 
-	/***COOLEMALL CASE RELATED***/
-
-	private static ResourceBundle recsBundle;
-	
-	private ResourceBundle getRecsBundle(String fileName) throws FileNotFoundException, IOException{
-		if(recsBundle == null){
-			recsBundle = new PropertyResourceBundle(new FileInputStream(fileName));
+	public void addResourceUnit(ResourceUnit unit) {
+		if (this.resUnits == null)
+			this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1);
+		List<ResourceUnit> list = null;
+		if (this.resUnits.containsKey(unit.getName())) {
+			list = this.resUnits.get(unit.getName());
+		} else {
+			list = new ArrayList<ResourceUnit>(1);
+			this.resUnits.put(unit.getName(), list);
 		}
-		return recsBundle;
+		list.add(unit);
 	}
 	
-	protected String getEEP(String query, String fileName) throws FileNotFoundException, IOException{
-		ResourceBundle recsBundle = getRecsBundle(fileName);
-		return recsBundle.getString(query);
+	public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException {
+		return getResourceUnitList(unitName).get(0);
 	}
-	
-	protected String createEEPQuery(ComputingResource compRes) {
-		String query = compRes.getClazz() + "EEP";
-		return query;
+
+	public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException {
+		if (resUnits.containsKey(unitName))
+			return resUnits.get(unitName);
+		else
+			throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id);
+	}
+
+	public Collection<ResourceUnit> getResourceUnit() {
+		if (resUnits == null)
+			return null;
+		List<ResourceUnit> values = new ArrayList<ResourceUnit>();
+		Collection<List<ResourceUnit>> lists = resUnits.values();
+		Iterator<List<ResourceUnit>> itr = lists.iterator();
+
+		while (itr.hasNext()) {
+			List<ResourceUnit> list = itr.next();
+			values.addAll(list);
+		}
+
+		return values;
+	}
+
+	public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() {
+		return resUnits;
 	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ExecutingResourceDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ExecutingResourceDescription.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ExecutingResourceDescription.java	(revision 1207)
@@ -1,74 +1,21 @@
 package schedframe.resources.computing.description;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import schedframe.Parameters;
-import schedframe.resources.ResourceType;
 import schedframe.resources.units.ResourceUnit;
 import schedframe.resources.units.ResourceUnitName;
 
-public class ExecutingResourceDescription extends AbstractResourceDescription {
+public interface ExecutingResourceDescription {
+	
+	public void addResourceUnit(ResourceUnit unit);
+	
+	public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException ;
 
-	protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
-	protected Parameters parameters;
+	public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException;
+
+	public Collection<ResourceUnit> getResourceUnit();
 	
-	public ExecutingResourceDescription(ResourceType type) {
-		super(type);
-	}
-
-	public Parameters getParameters() {
-		return parameters;
-	}
-	
-	public String getCompResourceParameterValue(String name){
-		return getParameters().get(name).get(0).getContent();
-	}
-	
-	public void addResourceUnit(ResourceUnit unit) {
-		if (this.resUnits == null)
-			this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1);
-		List<ResourceUnit> list = null;
-		if (this.resUnits.containsKey(unit.getName())) {
-			list = this.resUnits.get(unit.getName());
-		} else {
-			list = new ArrayList<ResourceUnit>(1);
-			this.resUnits.put(unit.getName(), list);
-		}
-		list.add(unit);
-	}
-	
-	public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException {
-		return getResourceUnitList(unitName).get(0);
-	}
-
-	public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException {
-		if (resUnits.containsKey(unitName))
-			return resUnits.get(unitName);
-		else
-			throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id);
-	}
-
-	public Collection<ResourceUnit> getResourceUnit() {
-		if (resUnits == null)
-			return null;
-		List<ResourceUnit> values = new ArrayList<ResourceUnit>();
-		Collection<List<ResourceUnit>> lists = resUnits.values();
-		Iterator<List<ResourceUnit>> itr = lists.iterator();
-
-		while (itr.hasNext()) {
-			List<ResourceUnit> list = itr.next();
-			values.addAll(list);
-		}
-
-		return values;
-	}
-
-	public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() {
-		return resUnits;
-	}
+	public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits();
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ResourceDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ResourceDescription.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ResourceDescription.java	(revision 1207)
@@ -0,0 +1,64 @@
+package schedframe.resources.computing.description;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import schedframe.Parameters;
+import schedframe.resources.ResourceType;
+
+
+public abstract class ResourceDescription {
+
+	protected String id;
+	protected ResourceType type;
+	protected List<ResourceDescription> children;
+	protected Parameters parameters;
+	
+	public ResourceDescription(ResourceType type){
+		this.type = type;
+	}
+
+	public List<ResourceDescription> getChildren() {
+		return children;
+	}
+	
+	public void setChildren(List<ResourceDescription> children) {
+		this.children = children;
+	}
+	
+	public void addChildren(ResourceDescription child) {
+		//child.setParent(this);
+		if(children == null)
+			children = new ArrayList<ResourceDescription> (1);
+		this.children.add(child);
+	}
+
+	public String getId(){
+		return this.id;
+	}
+
+	public ResourceType getType() {
+		return type;
+	}
+	
+	public Parameters getParameters() {
+		return parameters;
+	}
+	
+	/*protected AbstractResourceDescription parent;
+	/public AbstractResourceDescription getParent() {
+		return parent;
+	}
+
+	public void setParent(AbstractResourceDescription parent) {
+		this.parent = parent;
+	}*/
+	
+	/*public enum ResourceType {
+		COMPUTING_RESOURCE,
+		QUEUING_SYSTEM;
+	}
+	*/
+	
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/AbstractResourceDescription.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/AbstractResourceDescription.java	(revision 477)
+++ 	(revision )
@@ -1,59 +1,0 @@
-package schedframe.resources.computing.description;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import schedframe.resources.ResourceType;
-
-
-public abstract class AbstractResourceDescription {
-
-	protected String id;
-	protected ResourceType type;
-	protected List<AbstractResourceDescription> children;
-	
-	public AbstractResourceDescription(ResourceType type){
-		this.type = type;
-		this.children = null;
-	}
-
-	public List<AbstractResourceDescription> getChildren() {
-		return children;
-	}
-	
-	public void setChildren(List<AbstractResourceDescription> children) {
-		this.children = children;
-	}
-	
-	public void addChildren(AbstractResourceDescription child) {
-		//child.setParent(this);
-		if(children == null)
-			children = new ArrayList<AbstractResourceDescription> (1);
-		this.children.add(child);
-	}
-
-	public String getId(){
-		return this.id;
-	}
-
-	public ResourceType getType() {
-		return type;
-	}
-	
-	/*protected AbstractResourceDescription parent;
-	/public AbstractResourceDescription getParent() {
-		return parent;
-	}
-
-	public void setParent(AbstractResourceDescription parent) {
-		this.parent = parent;
-	}*/
-	
-	/*public enum ResourceType {
-		COMPUTING_RESOURCE,
-		QUEUING_SYSTEM;
-	}
-	*/
-	
-}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java	(revision 1119)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java	(revision 1207)
@@ -1,3 +1,6 @@
 package schedframe.resources.computing.profiles.energy.power;
+
+import java.util.Map;
+import java.util.TreeMap;
 
 public class PState {
@@ -9,5 +12,7 @@
 	protected double powerUsageMin;
 	protected double powerUsageMax;
-
+	//protected List<LoadPowerUsage> loadPowerUsageList;
+	protected Map<Double, Double> loadPowerUsage;
+	
 	/*public PState(PStateType name, double frequency, double voltage, double power) {
 		super();
@@ -38,5 +43,14 @@
 		return powerUsageMax;
 	}
-	
+	/*public List<LoadPowerUsage> getLoadPowerUsageList() {
+		return loadPowerUsageList;
+	}*/
+	public Map<Double, Double> getLoadPowerUsage() {
+		if(loadPowerUsage == null) {
+			return new TreeMap<Double, Double>();
+		}
+		return loadPowerUsage;
+	}
+
 	public static class Builder {
 	  
@@ -47,4 +61,6 @@
 		protected double powerUsageMin;
 		protected double powerUsageMax;
+		//protected List<LoadPowerUsage> loadPowerUsageList = new ArrayList<LoadPowerUsage>();
+		protected Map<Double, Double> loadPowerUsage = new TreeMap<Double, Double>();
 		
 		public Builder name(String name){this.name = name; return this; }
@@ -54,4 +70,6 @@
         public Builder powerUsageMin(double rate){this.powerUsageMin = rate; return this; }
         public Builder powerUsageMax(double rate){this.powerUsageMax = rate; return this; }
+        //public Builder loadPowerUsage(LoadPowerUsage lpu){this.loadPowerUsageList.add(lpu); return this; }
+        public Builder loadPowerUsage(double load, double power){this.loadPowerUsage.put(load, power); return this; }
         
         public PState build() {
@@ -67,4 +85,8 @@
 		this.powerUsageMin = builder.powerUsageMin;
 		this.powerUsageMax = builder.powerUsageMax;
+		//this.loadPowerUsageList = builder.loadPowerUsageList;
+		this.loadPowerUsage = builder.loadPowerUsage;
 	}
+
+
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/LoadPowerUsage.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/LoadPowerUsage.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/LoadPowerUsage.java	(revision 1207)
@@ -0,0 +1,20 @@
+package schedframe.resources.computing.profiles.energy.power;
+
+public class LoadPowerUsage {
+	double load;
+	double powerUsage;
+	
+	public LoadPowerUsage(double load, double powerUsage) {
+		super();
+		this.load = load;
+		this.powerUsage = powerUsage;
+	}
+
+	public double getLoad() {
+		return load;
+	}
+
+	public double getPowerUsage() {
+		return powerUsage;
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java	(revision 1104)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java	(revision 1207)
@@ -1,44 +1,38 @@
 package schedframe.resources.computing.profiles.energy.power;
 
-import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.resources.devices.PhysicalResourcePowerInterface;
 
 public class PowerInterfaceFactory {
 
-
-
-	//new1
-	/*public static PowerInterface createPowerProfile(ResourceType resourceType, List<PowerState> powerStates, List<PState> pStates, String eepn){
-
-		PowerInterface powerProfile;
-
-		switch(resourceType){
-			case DataCenter: powerProfile = new DataCenterPowerInterfaceNew(eepn, powerStates); break;
-			case ComputingNode: powerProfile = new ComputingNodePowerInterfaceNew(eepn, powerStates); break;
-			case Processor: powerProfile = new CPUPowerInterfaceNew(eepn, powerStates, pStates); break;
-			default:
-				throw new IllegalArgumentException("ResourceType " + resourceType + " is not supported.");
-		}
-
-		return powerProfile;
-	}*/
 	
-	public static PowerInterface createPowerInterface(ComputingResource resource, PowerProfile pp){
+	public static PowerInterface createPowerInterface(PhysicalResource resource, PowerProfile pp){
 		if(pp == null)
 			return null;
 		PowerInterface powerInterface;
-
+		
 		if(resource.getType().getName().equals(StandardResourceType.DataCenter.getName()))
-			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface(resource, pp);
-		else if (resource.getType().getName().equals(StandardResourceType.ComputingNode.getName()))
-			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp);
+			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface((ComputingResource)resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.Node.getName()))
+			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface((ComputingResource)resource, pp);
 		else if (resource.getType().getName().equals(StandardResourceType.Processor.getName()))
-			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface(resource, pp);
-		else if (resource.getType().getName().equals(CoolEmAllResourceType.Node.getName()))
-			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp);
+			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface((ComputingResource)resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.CRAH.getName()))
+			powerInterface = new PhysicalResourcePowerInterface(resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.Fan.getName()))
+			powerInterface = new PhysicalResourcePowerInterface(resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.Inlet.getName()))
+			powerInterface = new PhysicalResourcePowerInterface(resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.Outlet.getName()))
+			powerInterface = new PhysicalResourcePowerInterface(resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName()))
+			powerInterface = new PhysicalResourcePowerInterface(resource, pp);
+		else if (resource.getType().getName().equals(StandardResourceType.Heatsink.getName()))
+			powerInterface = new PhysicalResourcePowerInterface(resource, pp);
 		else 
-			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface(resource, pp);
+			powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface((ComputingResource)resource, pp);
 
 		/*switch(resource.getType()){
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java	(revision 1167)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java	(revision 1207)
@@ -24,9 +24,10 @@
 	public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) {
 		this.energyEstimationPlugin = energyEstimationPlugin;
+		this.supportedPowerStates = powerStates;
 		this.powerUsage = new ArrayList<PowerUsage>();
-		this.supportedPowerStates = powerStates;
+		initDefaultPowerStates();
 	}
 	
-	public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) {
+	public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) {
 		this.energyEstimationPlugin = energyEstimationPlugin;
 		this.supportedPowerStates = powerStates;
@@ -37,4 +38,5 @@
 			supportedPStates.put(pState.getName(), pState);
 		}
+		initDefaultPowerStates();
 	}
 	
@@ -60,7 +62,7 @@
 	}
 	
-	public List<PowerState> getSupportedPowerStates() throws NoSuchFieldException{
+	public List<PowerState> getSupportedPowerStates() {
 		if(supportedPowerStates == null)
-			throw new NoSuchFieldException("Supported power states are not defined.");
+			return new ArrayList<PowerState>();
 		return supportedPowerStates;
 	}
@@ -111,4 +113,24 @@
 	}
 
-
+	protected void initDefaultPowerStates(){
+		boolean supportsON = false;
+		boolean supportsOFF = false;
+		if(supportedPowerStates == null){
+			supportedPowerStates = new ArrayList<PowerState>();
+		}
+		for(PowerState ps: supportedPowerStates){
+			if(ps.getName().equals(StandardPowerStateName.ON)){
+				supportsON = true;
+			} else if (ps.getName().equals(StandardPowerStateName.OFF)){
+				supportsOFF = true;
+			}
+		}
+		
+		if(!supportsON){
+			supportedPowerStates.add(new PowerState(StandardPowerStateName.ON, -1, new ArrayList<Transition>()));
+		}
+		if(!supportsOFF){
+			supportedPowerStates.add(new PowerState(StandardPowerStateName.OFF, -1, new ArrayList<Transition>()));
+		}
+	}
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java	(revision 495)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java	(revision 1207)
@@ -1,4 +1,7 @@
 package schedframe.resources.computing.profiles.energy.power.ui;
 
+import org.joda.time.DateTime;
+
+import schedframe.SimulatedEnvironment;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.DataCenter;
@@ -23,5 +26,5 @@
 			child.getPowerInterface().setPowerState(state);
 		}
-
+		//ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName());
 		return true;
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java	(revision 1166)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java	(revision 1207)
@@ -1,4 +1,9 @@
 package schedframe.resources.computing.profiles.energy.power.ui;
 
+
+
+import org.joda.time.DateTime;
+
+import schedframe.SimulatedEnvironment;
 import schedframe.resources.ResourceStatus;
 import schedframe.resources.computing.ComputingNode;
@@ -38,5 +43,5 @@
 		
 		if(!pePowerStateChangeStatus){
-			computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName()));
+			computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getFullName()));
 		}
 
@@ -48,4 +53,5 @@
 		}
 		//computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName()));
+		//ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName());
 		return true;
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java	(revision 579)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java	(revision 1207)
@@ -4,7 +4,9 @@
 import java.util.List;
 
+import org.joda.time.DateTime;
 import org.joda.time.DateTimeUtils;
 
 import schedframe.Parameters;
+import schedframe.SimulatedEnvironment;
 import schedframe.resources.ResourceStatus;
 import schedframe.resources.computing.ComputingResource;
@@ -46,9 +48,10 @@
 			}
 			//notifications from all levels
-			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName()));
+			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));
 
 			//notification from last level
 			//if (resource.getChildren() == null) resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource));
 			
+			//ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName());
 			return true;
 		}
@@ -70,12 +73,8 @@
 
 	public boolean supportPowerState(PowerStateName state) {
-		try {
-			for(PowerState powerState: powerProfile.getSupportedPowerStates()){
-				if(powerState.getName().equals(state)){
-					return true;
-				}
+		for(PowerState powerState: powerProfile.getSupportedPowerStates()){
+			if(powerState.getName().equals(state)){
+				return true;
 			}
-		} catch (NoSuchFieldException e) {
-			return false;
 		}
 		return false;
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java	(revision 782)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java	(revision 1207)
@@ -4,4 +4,7 @@
 import java.util.Map;
 
+import org.joda.time.DateTime;
+
+import schedframe.SimulatedEnvironment;
 import schedframe.resources.ResourceStatus;
 import schedframe.resources.computing.ComputingResource;
@@ -16,5 +19,4 @@
 
 	protected PState currentPState;
-
 
 	public ProcessorPowerInterface(ComputingResource resource, PowerProfile pp){
@@ -34,5 +36,5 @@
 				resource.setStatus(ResourceStatus.FREE);
 			}
-			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName()));		
+			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));		
 		}
 
@@ -68,6 +70,8 @@
 			//speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue());
 			//new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED);
-			resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getName()));
+			resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getFullName()));
 			//resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, resource.getName());
+			
+			//ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "PSTATE_CHANGED", pStateName);
 			return true;
 		}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java	(revision 1207)
@@ -2,15 +2,15 @@
 
 import schedframe.Plugin;
-import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistry;
 
 public interface EnergyEstimationPlugin extends Plugin {
 	
-	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource);
 
-	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);
+	public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource);
 
-	public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);
+	public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource);
 
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java	(revision 803)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java	(revision 1207)
@@ -1,14 +1,22 @@
 package schedframe.resources.computing.profiles.energy.thermal;
 
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.thermal.ui.ComputingResourceThermalInterface;
 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.resources.devices.PhysicalResourceThermalInterface;
 
 public class ThermalInterfaceFactory {
-	public static ThermalInterface createThermalInterface(ComputingResource resource, ThermalProfile tp){
+	public static ThermalInterface createThermalInterface(PhysicalResource resource, ThermalProfile tp){
 		if(tp == null)
 			return null;
-		ThermalInterface thermalInterface = new ComputingResourceThermalInterface(resource, tp);
-
+		ThermalInterface thermalInterface;
+		if (resource.getType().getName().equals(StandardResourceType.CRAH.getName()))
+			thermalInterface = new PhysicalResourceThermalInterface(resource, tp);
+		else if (resource.getType().getName().equals(StandardResourceType.Fan.getName()))
+			thermalInterface = new PhysicalResourceThermalInterface(resource, tp);
+		else 
+			thermalInterface = new ComputingResourceThermalInterface((ComputingResource)resource, tp);
 		return thermalInterface;
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java	(revision 495)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java	(revision 1207)
@@ -28,5 +28,5 @@
 	}
 	
-	public void addToPowerUsageHistory(double airFlow) {
+	public void addToAirFlowHistory(double airFlow) {
 
 		if (airFlowHistory.size() == 0) {
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java	(revision 753)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java	(revision 1207)
@@ -3,6 +3,6 @@
 public enum  StandardAirThroughputStateName implements AirThroughputStateName{
 
-	FAN_ON,
-	FAN_OFF;
+	ON,
+	OFF;
 
 	public String getName() {
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java	(revision 754)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java	(revision 1207)
@@ -4,8 +4,11 @@
 import java.util.List;
 
+import org.joda.time.DateTimeUtils;
+
 import schedframe.Parameters;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.EnergyEvent;
 import schedframe.resources.computing.profiles.energy.EnergyEventType;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue;
 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile;
 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState;
@@ -22,5 +25,5 @@
 		this.resource = resource;
 		this.airThroughputProfile = airThroughputProfile;
-		this.currentAirThroughputState = StandardAirThroughputStateName.FAN_ON;
+		this.currentAirThroughputState = StandardAirThroughputStateName.ON;
 	}
 	
@@ -34,5 +37,6 @@
 			
 			//TO DO - notifications should be called for all resources starting form the lowest layer
-			resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName()));
+			resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getFullName()));
+			resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));
 			return true;
 		}
@@ -83,4 +87,23 @@
 	}
 	
+	public AirFlowValue getRecentAirFlow() {
+		AirFlowValue airFlow = null;
+		int lastIdx = getAirFlowHistory().size() - 1;
+		if(lastIdx >= 0)
+			airFlow = getAirFlowHistory().get(lastIdx);
+		else {	
+			try {
+				airFlow = new AirFlowValue(DateTimeUtils.currentTimeMillis(), getAirFlow(currentAirThroughputState));
+			} catch (NoSuchFieldException e) {
+			}
+		}
+		return airFlow;
+	}
+	
+	public List<AirFlowValue> getAirFlowHistory(){
+		return airThroughputProfile.getAirThroughputHistory();
+	}
+	
+	
 	public Parameters getParameters() {
 		return airThroughputProfile.getParameters();
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java	(revision 754)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java	(revision 1207)
@@ -4,4 +4,5 @@
 
 import schedframe.Parameters;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue;
 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState;
 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputStateName;
@@ -9,5 +10,5 @@
 public interface AirThroughputInterface {
 	
-	public AirThroughputStateName  getAirThroughputState();
+	public AirThroughputStateName getAirThroughputState();
 	
 	public boolean setAirThroughputState(AirThroughputStateName airThroughputState);
@@ -21,4 +22,10 @@
 	public double getPowerConsumption(AirThroughputStateName state) throws NoSuchFieldException;
 	
+	public AirFlowValue getRecentAirFlow();
+	
+	List<AirFlowValue> getAirFlowHistory();
+	
 	public Parameters getParameters();
+	
+	
 }
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java	(revision 753)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java	(revision 1207)
@@ -1,15 +1,30 @@
 package schedframe.resources.computing.profiles.energy.airthroughput;
 
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;
 import schedframe.resources.computing.profiles.energy.airthroughput.ui.ComputingResourceAirThroughputInterface;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.resources.devices.PhysicalResourceAirThroughputInterface;
+import schedframe.resources.devices.coolemall.FanAirThroughputInterface;
 
 public class AirThroughputInterfaceFactory {
 	
-	public static AirThroughputInterface createAirThroughputInterface(ComputingResource resource, AirThroughputProfile atp){
+	public static AirThroughputInterface createAirThroughputInterface(PhysicalResource resource, AirThroughputProfile atp){
 		if(atp == null)
 			return null;
-		AirThroughputInterface airThroughputInterface = new ComputingResourceAirThroughputInterface(resource, atp);
-
+		AirThroughputInterface airThroughputInterface = null;
+		if(resource.getType().getName().equals(StandardResourceType.CRAH.getName()))
+			airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp);
+		else if(resource.getType().getName().equals(StandardResourceType.Fan.getName()))
+			airThroughputInterface = new FanAirThroughputInterface(resource, atp);
+		else if(resource.getType().getName().equals(StandardResourceType.Inlet.getName()))
+			airThroughputInterface = new FanAirThroughputInterface(resource, atp);
+		else if(resource.getType().getName().equals(StandardResourceType.Outlet.getName()))
+			airThroughputInterface = new FanAirThroughputInterface(resource, atp);
+		else if(resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName()))
+			airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp);
+		else
+			airThroughputInterface = new ComputingResourceAirThroughputInterface((ComputingResource)resource, atp);
 		return airThroughputInterface;
 	}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java	(revision 1165)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java	(revision 1207)
@@ -7,5 +7,4 @@
 
 import schedframe.events.Event;
-import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.extensions.Extension;
 import schedframe.resources.computing.extensions.ExtensionException;
@@ -20,5 +19,7 @@
 import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile;
 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface;
+import schedframe.resources.devices.PhysicalResource;
 import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import simulator.DataCenterWorkloadSimulator;
 
 public class EnergyExtension implements Extension{
@@ -35,34 +36,74 @@
 	protected ThermalProfile thermalProfile;
 	
-  	protected ComputingResource computingResource;
-
-
-	public EnergyExtension(ComputingResource computingResource, PowerInterface powerInterface, PowerProfile powerProfile) {
+  	protected PhysicalResource resource;
+
+
+	/*public EnergyExtension(PhysicalResource resource, PowerInterface powerInterface, PowerProfile powerProfile) {
+		super();
+		this.resource = resource;
 		this.powerProfile = powerProfile;
-		this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile);
-	}
-	
-	public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile,
+		this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile);
+	}
+	
+	public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile,
 			AirThroughputProfile airFlowProfile) {
 		super();
-		this.computingResource = computingResource;
+		this.resource = resource;
 		this.powerProfile = powerProfile;
-		this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile);
+		this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile);
 		this.airFlowProfile = airFlowProfile;
-		this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile);
-	}
-	
-	public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile,
+		this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile);
+	}
+	
+	public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile,
 			AirThroughputProfile airFlowProfile, ThermalProfile thermalProfile) {
 		super();
-		this.computingResource = computingResource;
+		this.resource = resource;
 		this.powerProfile = powerProfile;
-		this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile);
+		this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile);
 		this.airFlowProfile = airFlowProfile;
-		this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile);
+		this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile);
 		this.thermalProfile = thermalProfile;
-		this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(computingResource, thermalProfile);
-	}
-
+		this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile);
+	}*/
+
+	public static class Builder {
+		  
+		protected PhysicalResource resource;
+		protected PowerInterface powerInterface;
+		protected PowerProfile powerProfile;
+		
+		protected AirThroughputInterface airFlowInterface;
+		protected AirThroughputProfile airFlowProfile;
+		
+		protected ThermalInterface thermalInterface;
+		protected ThermalProfile thermalProfile;
+		
+		public Builder resource(PhysicalResource res) {this.resource = res; return this;}
+		
+		public Builder powerProfile(PowerProfile pp){this.powerProfile = pp; this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); return this; }
+
+        public Builder airFlowProfile(AirThroughputProfile atp){this.airFlowProfile = atp; this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); return this; }
+
+        public Builder thermalProfile(ThermalProfile tp){this.thermalProfile = tp; this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); return this; }
+
+        public EnergyExtension build() {
+            return new EnergyExtension(this);
+        }
+	}
+	
+	private EnergyExtension(Builder builder) {
+		this.resource = builder.resource;
+		this.powerInterface = builder.powerInterface;
+		this.powerProfile = builder.powerProfile;
+		
+		this.airFlowInterface = builder.airFlowInterface ;
+		this.airFlowProfile = builder.airFlowProfile;
+		
+		this.thermalInterface = builder.thermalInterface;
+		this.thermalProfile = builder.thermalProfile;
+	}
+
+	
 	public boolean supportsEvent(Event event) {
 
@@ -82,4 +123,6 @@
 		if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName()))
 			return true;
+		if(event.getType().getName().equals(EnergyEventType.TEMPERATURE_CHANGED.getName()))
+			return true;
 		
 		else return false;
@@ -90,10 +133,10 @@
 		EnergyEvent enEvent = (EnergyEvent)event;
 		double power = 0;
-		double temperature = 0;
+		boolean status = false;
 		try{
 			switch (enEvent.getType()) {
 			
 			case POWER_STATE_CHANGED:
-				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
 				/*if(computingResource instanceof ComputingNode){
 					ComputingNode node = (ComputingNode)computingResource;
@@ -109,45 +152,36 @@
 					}
 				}
-				else*/ powerProfile.addToPowerUsageHistory(power);
-				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				thermalProfile.addToTemperatureHistory(temperature);
+				else*/ 
+				
+				status = powerProfile.addToPowerUsageHistory(power);
 				break;
 				
 			case FREQUENCY_CHANGED:
-				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				powerProfile.addToPowerUsageHistory(power);
-				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				thermalProfile.addToTemperatureHistory(temperature);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
 				break;
 				
 			case TASK_STARTED:
-				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				powerProfile.addToPowerUsageHistory(power);
-				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				thermalProfile.addToTemperatureHistory(temperature);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
 				break;
 	
 			case TASK_FINISHED:
-				//System.out.println(this.resource.getName() + " - ENERGY EXTENSION: TASK FINISHED");
-				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				//System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power);
-				powerProfile.addToPowerUsageHistory(power);
-				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				thermalProfile.addToTemperatureHistory(temperature);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
 				break;
 				
 			case RESOURCE_UTILIZATION_CHANGED:
-				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				powerProfile.addToPowerUsageHistory(power);
-				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				thermalProfile.addToTemperatureHistory(temperature);
+				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				status = powerProfile.addToPowerUsageHistory(power);
 				break;
 				
 			case AIRFLOW_STATE_CHANGED:
-				double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				airFlowProfile.addToPowerUsageHistory(airFlow);
-				power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
-				powerProfile.addToPowerUsageHistory(power);
-				temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource);
+				double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
+				airFlowProfile.addToAirFlowHistory(airFlow);
+				break;
+				
+			case TEMPERATURE_CHANGED:
+				double temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(resource.getFullName()), resource);
 				thermalProfile.addToTemperatureHistory(temperature);
 				break;
@@ -156,4 +190,7 @@
 			
 		}
+		if(status){
+			DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, resource.getFullName()));
+		}
 	}
 
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/validator/ResourceNameValidator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/validator/ResourceNameValidator.java	(revision 477)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/validator/ResourceNameValidator.java	(revision 1207)
@@ -13,5 +13,5 @@
 	@Override
 	public boolean validate(ComputingResource resource) {
-		return resource.getName().equals(name);
+		return resource.getFullName().equals(name);
 	}
 
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResourceCharacteristics.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResourceCharacteristics.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResourceCharacteristics.java	(revision 1207)
@@ -0,0 +1,85 @@
+package schedframe.resources.computing;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+
+public class ComputingResourceCharacteristics extends ResourceCharacteristics{
+
+	
+	protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
+	protected List<Device> devices;
+	
+	protected ComputingResourceCharacteristics(Builder<?> builder) {
+		super(builder);
+		this.resUnits = builder.resUnits;
+		this.devices = builder.devices;
+		// TODO Auto-generated constructor stub
+	}
+
+	public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() {
+		if(resUnits == null)
+			return new HashMap<ResourceUnitName, List<ResourceUnit>>();
+		return resUnits;
+	}
+	
+	public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException{
+		if(getResourceUnits().containsKey(unitName))
+			return getResourceUnits().get(unitName).get(0);
+		else throw new NoSuchFieldException("Resource unit " + unitName + 
+				" is not available in this resource ");
+	}
+	
+	public void addResourceUnit(ResourceUnit unit){ 
+		if(resUnits == null){
+			resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2);
+		}
+		List<ResourceUnit> list = null;
+		if(resUnits.containsKey(unit.getName())){
+			list = resUnits.get(unit.getName());
+		} else {
+			list = new ArrayList<ResourceUnit>(1);
+			resUnits.put(unit.getName(), list);
+		}
+		list.add(unit);
+	}
+	
+
+	
+	public List<Device> getDevices(){
+		if(devices == null)
+			return new ArrayList<Device>();
+		return devices;
+	}
+	
+	public static abstract class Builder<T extends Builder<T>> extends ResourceCharacteristics.Builder<T> {
+
+		protected Map<ResourceUnitName, List<ResourceUnit>> resUnits;
+		protected List<Device> devices;
+		
+        public T resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return self(); }
+        public T resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return self(); }
+        public T device(List<Device> dev){this.devices = dev; return self(); }
+
+        public ComputingResourceCharacteristics build() {
+            return new ComputingResourceCharacteristics(this);
+        }
+    }
+
+    public static class Builder2 extends Builder<Builder2> {
+        @Override
+        protected Builder2 self() {
+            return this;
+        }
+    }
+
+    public static Builder<?> builder() {
+        return new Builder2();
+    }
+
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/DataCenter.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/DataCenter.java	(revision 756)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/DataCenter.java	(revision 1207)
@@ -20,5 +20,5 @@
 	@SuppressWarnings("unchecked")
 	public List<ComputingNode> getComputingNodes(){
-		return (List<ComputingNode>) getDescendantsByType(StandardResourceType.ComputingNode);
+		return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node);
 	}
 	
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java	(revision 756)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java	(revision 1207)
@@ -3,5 +3,4 @@
 import java.util.List;
 import java.util.Properties;
-
 
 import schedframe.resources.ResourceStatus;
@@ -10,9 +9,5 @@
 import schedframe.resources.computing.extensions.ExtensionType;
 import schedframe.resources.computing.profiles.energy.EnergyExtension;
-import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputInterfaceFactory;
-import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface;
-import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory;
 import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface;
-import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface;
 import schedframe.resources.computing.properties.ComputingNodePropertiesBuilder;
 import schedframe.resources.computing.properties.PropertiesDirector;
@@ -32,13 +27,5 @@
 		//accept(new EnergyExtension(pi, resDesc.getPowerProfile()));
 		//accept(new EnergyExtension(pi, resDesc.getPowerProfile(), ai, resDesc.getAirThroughputProfile()));	
-	}
-	
-	/*public ComputingNode (String resourceName, ResourceCharacteristics resourceCharacteristic, Category cat, PowerInterface powerInterface) {
-		super(resourceName, ResourceType.COMPUTING_NODE, resourceCharacteristic);
-		category = cat;
-		accept(powerInterface);
-	//	extensionList.add(new EnergyExtension(this, "example.energy.ComputingNodeEnergyEstimationPlugin"));
-	}*/
-	
+	}	
 	
 	public ComputingNodePowerInterface getPowerInterface(){
@@ -86,5 +73,5 @@
 	
 	public Memory getMemory() throws NoSuchFieldException {
-		return (Memory) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.MEMORY);
+		return (Memory) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.MEMORY);
 	}
 	
@@ -95,5 +82,5 @@
 	
 	private Cost getCost() throws NoSuchFieldException {
-		return (Cost) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.COST);
+		return (Cost) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.COST);
 	}
 
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceFactory.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceFactory.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceFactory.java	(revision 1207)
@@ -0,0 +1,56 @@
+package schedframe.resources;
+
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.DataCenter;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.ResourceFactory;
+import schedframe.resources.computing.coolemall.ComputeBox1;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.coolemall.NodeGroup;
+import schedframe.resources.computing.description.ComputingResourceDescription;
+import schedframe.scheduling.Scheduler;
+import schedframe.scheduling.manager.resources.ManagedResources;
+import schedframe.scheduling.plugin.SchedulingPlugin;
+import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin;
+import schedframe.scheduling.policy.AbstractManagementSystem;
+import schedframe.scheduling.policy.local.LocalManagementSystem;
+import schedframe.scheduling.queue.TaskQueueList;
+import simulator.DCWormsConstants;
+
+public class CoolEmAllResourceFactory implements ResourceFactory{
+	
+	public ComputingResource createComputingResource(ComputingResourceDescription resDesc){
+		
+		if (resDesc.getType().getName().equals(StandardResourceType.DataCenter.getName()))
+			return new DataCenter(resDesc);
+		else if (resDesc.getType().getName().equals(StandardResourceType.Rack.getName()))
+			return new ComputeBox1(resDesc);
+		else if (resDesc.getType().getName().equals(CoolEmAllResourceType.NodeGroup.getName()))
+			return new NodeGroup(resDesc);
+		else if (resDesc.getType().getName().equals(StandardResourceType.Node.getName()))
+			return new Node(resDesc);
+		else if (resDesc.getType().getName().equals(StandardResourceType.Processor.getName()))
+			return new Processor(resDesc);
+		else if (resDesc.getType().getName().equals(StandardResourceType.Core.getName()))
+			return new Core(resDesc);
+		else return new ComputingResource(resDesc);
+	}
+
+	public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{
+		AbstractManagementSystem ms;
+		switch(type){
+			case LS: {
+				ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
+						schedulingPlugin, execTimeEstimationPlugin, queues);
+				return new Scheduler(ms, type, managedResources);
+			}
+
+		default:{
+				ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
+						schedulingPlugin, execTimeEstimationPlugin, queues);
+				return new Scheduler(ms, type, managedResources);
+			}
+		}
+	}
+}
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/Resource.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/Resource.java	(revision 893)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/Resource.java	(revision 1207)
@@ -1,3 +1,4 @@
 package schedframe.resources;
+
 
 
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/StandardResourceType.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/StandardResourceType.java	(revision 1095)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/StandardResourceType.java	(revision 1207)
@@ -7,5 +7,5 @@
 	DataCenter,
 	Rack,
-	ComputingNode,
+	Node,
 	Processor,
 	Core,
@@ -13,5 +13,19 @@
 	ResourceProvider,
 	GS,
-	LS;
+	LS,
+	Fan,
+	Refrigeration,
+	Heatpipe,
+	ILC,
+	LCU,
+	CRAH,
+	HVAC,
+	Inlet,
+	Outlet,
+	Heatsink,
+	Sensor,
+	Network,
+	CoolingDevice,
+	PowerSupply;
 
 	public String getName() {
Index: DCWoRMS/branches/coolemall/src/schedframe/resources/utils/ResourceIdGenerator.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/resources/utils/ResourceIdGenerator.java	(revision 816)
+++ DCWoRMS/branches/coolemall/src/schedframe/resources/utils/ResourceIdGenerator.java	(revision 1207)
@@ -2,6 +2,4 @@
 
 import java.util.HashMap;
-
-import schedframe.resources.ResourceType;
 
 public class ResourceIdGenerator {
@@ -11,5 +9,5 @@
 	public static int getId(String key){
 
-		int value = 0;
+		int value = 1;
 		if(resourceCounter.containsKey(key)){
 			value = resourceCounter.get(key);
Index: DCWoRMS/branches/coolemall/src/schedframe/ResourceController.java
===================================================================
--- DCWoRMS/branches/coolemall/src/schedframe/ResourceController.java	(revision 768)
+++ 	(revision )
@@ -1,154 +1,0 @@
-package schedframe;
-
-import gridsim.GridSim;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import schedframe.exceptions.ResourceException;
-import schedframe.resources.computing.ComputingResource;
-import schedframe.scheduling.Scheduler;
-
-public class ResourceController {
-
-	protected static Scheduler scheduler;
-	protected static List<ComputingResource> computingResources;
-	protected List<Initializable> toInit;
-	protected Set<String> compResLayers;
-	
-	public ResourceController(Scheduler logicalStructure, List<ComputingResource> compResources){
-		scheduler = logicalStructure;
-		computingResources = compResources;
-	}
-
-	public Scheduler getScheduler() {
-		return scheduler;
-	}
-
-	public List<ComputingResource> getComputingResources() {
-		return computingResources;
-	}
-
-	public static ComputingResource getComputingResourceByName(String resourceName) throws ResourceException {
-		ComputingResource resourceWithName = null;
-		for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) {
-			ComputingResource resource = computingResources.get(i);
-			if (resource.getName().equals(resourceName))
-				resourceWithName = resource;
-			else
-				resourceWithName = resource.getDescendantByName(resourceName);
-		}
-		return resourceWithName;
-	}
-
-	private static Scheduler getSchedulerByName(String schedulerName) {
-		Scheduler schedulerWithName = null;
-
-		if (scheduler.getName().compareTo(schedulerName) == 0)
-			schedulerWithName = scheduler;
-		else if (scheduler.getChildren() != null) {
-			LinkedList<Scheduler> toExamine = new LinkedList<Scheduler>();
-			toExamine.push(scheduler);
-
-			while (!toExamine.isEmpty() && schedulerWithName != null) {
-				Scheduler scheduler = toExamine.pop();
-				List<Scheduler> schedulers = scheduler.getChildren();
-
-				int numberOfSched = schedulers.size();
-				for (int i = 0; i < numberOfSched; i++) {
-					Scheduler schedulerChild = schedulers.get(i);
-					if(scheduler.getName().equals(schedulerName)){
-						schedulerWithName = schedulerChild;
-						break;
-					} else
-						toExamine.addLast(schedulerChild);
-				}
-			}
-		}
-		return schedulerWithName;
-	}
-	
-	public static Scheduler getScheduler(String resName){
-		if(GridSim.getEntityId(resName) != -1){
-			return getSchedulerByName(resName);
-		}
-		ComputingResource resourceWithName = null;
-		try {
-			resourceWithName = getComputingResourceByName(resName);
-		} catch (ResourceException e) {
-		}
-		/*for(int i = 0 ; i < computingResources.size() && resourceWithName == null; i++){
-			ComputingResource resource = computingResources.get(i);
-			if(resource.getName().equals(resName))
-				resourceWithName = resource;
-			else
-				try {
-					resourceWithName = resource.getDescendantByName(resName);
-				} catch (ResourceException e) {
-					return null;
-				}
-		}*/
-		if(resourceWithName == null)
-			return null;
-		List<ComputingResource> children = resourceWithName.getChildren();
-		Set<Scheduler> childrenSchedulers = new HashSet<Scheduler>();
-		if(children.isEmpty())
-			return null;
-		for(ComputingResource child: children) {
-			childrenSchedulers.add(child.getScheduler());
-		}	
-
-		Set<Scheduler> tempChildrenSchedulers = new HashSet<Scheduler>(childrenSchedulers);
-		while(childrenSchedulers.size() > 1){
-			childrenSchedulers = new HashSet<Scheduler>();
-			for(Scheduler s: tempChildrenSchedulers){
-				childrenSchedulers.add(s.getParent());
-			}
-			tempChildrenSchedulers = new HashSet<Scheduler>(childrenSchedulers);
-		}
-		Iterator<Scheduler> it = childrenSchedulers.iterator();
-		Scheduler potentialScheduler = it.next();
-		if(potentialScheduler.getCompResources().containsAll(children))
-			return potentialScheduler;
-		return null;
-	}
-	
-	public static ComputingResource getCommonComputingResourceParent(List<ComputingResource> compResources){
-		if(compResources.size() == 0)
-			return null;
-		Set<ComputingResource> candidates = new HashSet<ComputingResource>(compResources);
-		while(candidates.size() > 1){
-			Set<ComputingResource> parents = new HashSet<ComputingResource>();
-			Iterator<ComputingResource> it = candidates.iterator();
-			while(it.hasNext()){
-				ComputingResource compRes = it.next();
-				if(compRes.getParent() != null){
-					parents.add(compRes.getParent());
-				}
-				it.remove();
-			}
-			candidates.addAll(parents);
-		}
-		return candidates.toArray(new ComputingResource[0])[0];
-	}
-
-	public void setInitList(List<Initializable> toI) {
-		toInit = toI;
-	}
-
-	public List<Initializable> getToInit() {
-		return toInit;
-	}
-
-	public Set<String> getComputingResourceLayers() {
-		return compResLayers;
-	}
-
-	public void setCompResLayers(Set<String> compResLayers) {
-		this.compResLayers = compResLayers;
-	}
-
-}
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/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/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/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/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/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.");
-	}
-}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
@@ -0,0 +1,341 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_Consolidation_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_Consolidation_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = null;
+			try {
+				notSelectedNodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+			} catch (ResourceException e) {
+			}
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java	(revision 1207)
@@ -0,0 +1,341 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_ConsolidationAtom_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_ConsolidationAtom_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = null;
+			try {
+				notSelectedNodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+			} catch (ResourceException e) {
+			}
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 5;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 5;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_LoadBalancing_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_LoadBalancing_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_LoadBalancing_SP.java	(revision 1207)
@@ -0,0 +1,89 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.List;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_LoadBalancing_SP extends BaseLocalSchedulingPlugin {
+
+	public CB1_FCFS_LoadBalancing_SP () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					String nodeName = chooseProvider(resourceManager);
+					if (nodeName != null) {
+						addToSchedulingPlan(plan, task, nodeName);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseProvider(ClusterResourceManager resourceManager) {
+		List<ComputingResource> nodes = null;
+		try {
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		int nodeIdx = findLeastLoadedResourceIdx(nodes);
+		return nodes.get(nodeIdx).getFullName();
+	}
+	
+	private int findLeastLoadedResourceIdx(List<ComputingResource> nodes ){
+		int resourceIdx = -1;
+		int minLoad = Integer.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = (Node) nodes.get(i);
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			int totalLoad = jr.getRunningTasks().size(); 
+			if(totalLoad < minLoad){
+				resourceIdx = i;
+				minLoad = totalLoad;
+			}
+		}
+		return resourceIdx;
+	}
+
+}
+
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java	(revision 1099)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java	(revision 1207)
@@ -1,11 +1,21 @@
 package example.localplugin.coolemall.computebox1;
 
+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.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -17,4 +27,5 @@
 import schedframe.scheduling.queue.TaskQueueList;
 import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
 import example.localplugin.BaseLocalSchedulingPlugin;
 import gridsim.dcworms.DCWormsTags;
@@ -26,4 +37,5 @@
 	public CB1_FCFS_Random_SP () {
 		rand = new Random(47);
+		Node_Fan_Mapping.init();
 	}
 
@@ -49,7 +61,7 @@
 				if (task.getStatus() == DCWormsTags.READY) {
 
-					String nodeName = chooseRandomProvider(resourceManager);
-					if (nodeName != null) {
-						addToSchedulingPlan(plan, task, nodeName);
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
 					}
 				}
@@ -61,14 +73,88 @@
 
 	@SuppressWarnings("unchecked")
-	private String chooseRandomProvider(ClusterResourceManager resourceManager) {
-		List<ComputingResource> nodes = null;
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
 		try {
-			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		int nodeIdx = rand.nextInt(nodes.size());
-		return nodes.get(nodeIdx).getName();
+		List<Node> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+		Node node = randomNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node randomNode(List<Node> nodes){
+		return nodes.get(rand.nextInt(nodes.size()));
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java	(revision 1207)
@@ -0,0 +1,218 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_Consolidation_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_Consolidation_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new FavourableNodeComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java	(revision 1100)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java	(revision 1207)
@@ -6,5 +6,5 @@
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
@@ -64,5 +64,5 @@
 		List<ComputingResource> nodes = null;
 		try {
-			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
@@ -70,5 +70,5 @@
 		}
 		int nodeIdx = rand.nextInt(nodes.size());
-		return nodes.get(nodeIdx).getName();
+		return nodes.get(nodeIdx).getFullName();
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java	(revision 1207)
@@ -0,0 +1,180 @@
+package example.localplugin.coolemall.computebox2;
+
+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.exceptions.ResourceException;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import schedframe.scheduling.tasks.phases.PhaseBehaviour;
+import testbed_hpc.Node_Fan_Mapping;
+import dcworms.schedframe.scheduling.ExecTask;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_Random_SP extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public CB2_FCFS_Random_SP () {
+		rand = new Random(47);
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+		Node node = randomNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				double sumLoad = 0;
+				Processor proc = node.getProcessors().get(0);
+				JobRegistry jr = new JobRegistryImpl(proc.getFullName());
+				for(ExecTask execTask: jr.getRunningTasks()){
+					double cpuUsage = 100;
+					double nrOfThreadsOfApplciation = 1;
+					for(PhaseBehaviour pb: execTask.getCurrentResourceConsumption().getBehaviourList()){
+						if(pb.getResouceName().equals("PM_CPU_Usage")){
+							cpuUsage = pb.getUtilization();
+						}
+						if(pb.getResouceName().equals("PM_Threads")){
+							nrOfThreadsOfApplciation = pb.getUtilization();
+							break;
+						}
+					}
+					sumLoad = sumLoad + nrOfThreadsOfApplciation;
+				}
+
+				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/2;
+					else if(productName.equals("Atom - N2600"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS/2;
+					else if(productName.equals("Core i7 - 2715QE"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS/2;
+					else if(productName.equals("Core i7 - 3615QE"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS/2;
+				}
+
+				System.out.println(sumLoad + ":" + nrOfThreadsOnCpu + ";" + cpuRequest);
+				int freeThreads = (int) (nrOfThreadsOnCpu - sumLoad) ;
+
+				
+				if(freeThreads < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node randomNode(List<Node> nodes){
+		return nodes.get(rand.nextInt(nodes.size()));
+	}
+
+	
+}
+
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java	(revision 1207)
@@ -0,0 +1,219 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_Consolidation_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_Consolidation_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new FavourableNodeComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
@@ -0,0 +1,341 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_Consolidation_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_Consolidation_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			List<Node> notSelectedNodes = null;
+			try {
+				notSelectedNodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+			} catch (ResourceException e) {
+			}
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_LoadBalancing_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_LoadBalancing_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_LoadBalancing_SP.java	(revision 1207)
@@ -0,0 +1,89 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.List;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_LoadBalancing_SP extends BaseLocalSchedulingPlugin {
+
+	public CB2_FCFS_LoadBalancing_SP () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					String nodeName = chooseProvider(resourceManager);
+					if (nodeName != null) {
+						addToSchedulingPlan(plan, task, nodeName);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseProvider(ClusterResourceManager resourceManager) {
+		List<ComputingResource> nodes = null;
+		try {
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		int nodeIdx = findLeastLoadedResourceIdx(nodes);
+		return nodes.get(nodeIdx).getFullName();
+	}
+	
+	private int findLeastLoadedResourceIdx(List<ComputingResource> nodes ){
+		int resourceIdx = -1;
+		int minLoad = Integer.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = (Node) nodes.get(i);
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			int totalLoad = jr.getRunningTasks().size(); 
+			if(totalLoad < minLoad){
+				resourceIdx = i;
+				minLoad = totalLoad;
+			}
+		}
+		return resourceIdx;
+	}
+
+}
+
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java	(revision 1102)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java	(revision 1207)
@@ -5,7 +5,7 @@
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.recs.Node;
+import schedframe.resources.computing.coolemall.Node;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -62,5 +62,5 @@
 		List<ComputingResource> nodes = null;
 		try {
-			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
@@ -68,5 +68,5 @@
 		}
 		int nodeIdx = findLeastLoadedResourceIdx(nodes);
-		return nodes.get(nodeIdx).getName();
+		return nodes.get(nodeIdx).getFullName();
 	}
 	
@@ -77,5 +77,5 @@
 		for(int i = 0; i < nodes.size(); i++){
 			Node node = (Node) nodes.get(i);
-			JobRegistry jr = new JobRegistryImpl(node.getName());
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
 			int totalLoad = jr.getRunningTasks().size(); 
 			if(totalLoad < minLoad){
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java	(revision 1103)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java	(revision 1207)
@@ -2,12 +2,22 @@
 
 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.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingNode;
-import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.Device;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -19,4 +29,5 @@
 import schedframe.scheduling.queue.TaskQueueList;
 import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
 import example.localplugin.BaseLocalSchedulingPlugin;
 import gridsim.dcworms.DCWormsTags;
@@ -28,4 +39,5 @@
 	public RECS_FCFS_Random_SP () {
 		rand = new Random(47);
+		Node_Fan_Mapping.init();
 	}
 
@@ -47,5 +59,5 @@
 			List<ComputingNode> notSelectedNodes = null;
 			try {
-				notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+				notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 			} catch (ResourceException e) {
 				// TODO Auto-generated catch block
@@ -57,10 +69,14 @@
 				// if status of the tasks in READY
 				if (task.getStatus() == DCWormsTags.READY) {
-					ComputingNode node = chooseRandomProvider(resourceManager);
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+					/*ComputingNode node = chooseRandomProvider(resourceManager);
 					if (node != null) {
-						node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+						//node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
 						notSelectedNodes.remove(node);
 						addToSchedulingPlan(plan, task, node.getName());
-					}
+					}*/
 				}
 			}
@@ -75,5 +91,5 @@
 		List<ComputingNode> nodes = null;
 		try {
-			nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
@@ -94,10 +110,110 @@
 		return filteredNodes;
 	}
+	
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<ComputingNode> nodes = null;
+		try {
+			nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+		List<ComputingNode> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+		ComputingNode node = randomNode(avNodes);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<Core> cores = node.getProcessors().get(0).getCores();
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
+			for (int i = 0; i < cores.size(); i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					//choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<ComputingNode> filterNodes(List<ComputingNode> nodes, TaskInterface<?> task){
+		List<ComputingNode> filteredNodes = new ArrayList<ComputingNode>();
+		for (ComputingNode node : nodes) {
+			int cpuRequest;
+			try {
+				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+			} catch (NoSuchFieldException e) {
+				cpuRequest = 0;
+			}
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getProcessors().get(0).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 != cores.size())
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private ComputingNode randomNode(List<ComputingNode> nodes){
+		return nodes.get(rand.nextInt(nodes.size()));
+	}
+	
 	private void adjustOtherFans(List<ComputingNode> nodes) {
 		for (ComputingNode node : nodes) {
+			
 			if (node.getProcessors().size() == node.getFreeProcessorsNumber()) {
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF);
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("Off"));
+						break;
+					}
+				}
+
 			} else {
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("On"));
+						break;
+					}
+				}
 			}
 		}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java	(revision 1102)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java	(revision 1207)
@@ -10,10 +10,10 @@
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.computing.recs.Node;
 import schedframe.resources.units.Memory;
 import schedframe.resources.units.ProcessingElements;
@@ -55,5 +55,5 @@
 			List<Node> nodes;
 			try {
-				nodes = (List<Node>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+				nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 			} catch (ResourceException e) {
 				break;
@@ -140,5 +140,5 @@
 				}
 			}
-			ProcessingElements result = new ProcessingElements(node.getName());
+			ProcessingElements result = new ProcessingElements(node.getFullName());
 			result.addAll(choosenResources);
 			map.put(StandardResourceUnitName.PE, result);
@@ -183,5 +183,5 @@
 	private void turnOffIdleNodes(List<Node> nodes){
 		for(Node node : nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getName());
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
 			if(jr.getRunningTasks().size() == 0)
 				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java	(revision 575)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java	(revision 1207)
@@ -145,10 +145,10 @@
 		List<ComputingResource> nodes;
 		Properties properties = new Properties();
-		properties.setProperty("type", StandardResourceType.ComputingNode.getName());
+		properties.setProperty("type", StandardResourceType.Node.getName());
 		// properties.setProperty("status", ResourceStatus.FREE.toString());
 		nodes = (List<ComputingResource>) unitsManager.filterResources(properties);
 		
 		//always return the same node from the list
-		return nodes.get(0).getName();
+		return nodes.get(0).getFullName();
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java	(revision 531)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java	(revision 1207)
@@ -90,5 +90,5 @@
 				}
 			}
-			ProcessingElements result = new ProcessingElements(nodes.get(0).getName());
+			ProcessingElements result = new ProcessingElements(nodes.get(0).getFullName());
 			result.addAll(choosenResources);
 			map.put(StandardResourceUnitName.PE, result);
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java	(revision 574)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java	(revision 1207)
@@ -61,5 +61,5 @@
 		List<ComputingNode> nodes = resourceManager.getComputingNodes();
 		int nodeIdx = rand.nextInt(nodes.size());
-		return nodes.get(nodeIdx).getName();
+		return nodes.get(nodeIdx).getFullName();
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java	(revision 778)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java	(revision 1207)
@@ -8,7 +8,9 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingNode;
 import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
 import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.Device;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -54,10 +56,22 @@
 					if (node != null) {
 						//if there are two or more tasks ( running on the given node then
-						if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 0)
-							node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
-						else 
-							node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+						if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 0){
+							List<Device> devices = node.getResourceCharacteristic().getDevices();
+							for(Device dev : devices){
+								if(dev.getType().equals(StandardResourceType.Fan)){
+									dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
+								}
+							}
+						}
+						else {
+							List<Device> devices = node.getResourceCharacteristic().getDevices();
+							for(Device dev : devices){
+								if(dev.getType().equals(StandardResourceType.Fan)){
+									dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);	
+								}
+							}
+						}
 						notSelectedNodes.remove(node);
-						addToSchedulingPlan(plan, task, node.getName());
+						addToSchedulingPlan(plan, task, node.getFullName());
 					}
 				}
@@ -98,10 +112,25 @@
 	private void adjustOtherFans(List<ComputingNode> nodes){
 		for(ComputingNode node : nodes){
+			List<Device> devices = node.getResourceCharacteristic().getDevices();
 			if(node.getFreeProcessorsNumber() == node.getProcessorsNumber()){
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF);
-			} else if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 1)
-				node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
-			else 
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+				for(Device dev : devices){
+					if(dev.getType().equals(StandardResourceType.Fan)){
+						dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF);
+					}
+				}
+			} else if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 1){
+				for(Device dev : devices){
+					if(dev.getType().equals(StandardResourceType.Fan)){
+						dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
+					}
+				}
+			}
+			else {
+				for(Device dev : devices){
+					if(dev.getType().equals(StandardResourceType.Fan)){
+						dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);
+					}
+				}
+			}
 		}
 	}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java	(revision 574)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java	(revision 1207)
@@ -98,5 +98,5 @@
 				}
 			}
-			ProcessingElements result = new ProcessingElements(node.getName());
+			ProcessingElements result = new ProcessingElements(node.getFullName());
 			result.addAll(choosenResources);
 			map.put(StandardResourceUnitName.PE, result);
