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