Index: /DCWoRMS/trunk/src/simulator/stats/implementation/ResourcePowerStats.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/ResourcePowerStats.java	(revision 496)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/ResourcePowerStats.java	(revision 496)
@@ -0,0 +1,32 @@
+package simulator.stats.implementation;
+
+import schedframe.resources.ResourceType;
+import simulator.stats.implementation.out.StatsSerializer;
+
+public class ResourcePowerStats extends ResourceDynamicStats implements StatsInterface{
+
+	protected double sumValue;
+
+	private String[] headers = { "resourceName", "timestamp", "consumption" };
+	
+	public ResourcePowerStats (String resourceName, ResourceType resourceType, String usageType) {
+		super(resourceName, resourceType, usageType);
+	}
+
+	public void setSumValue(double sumValue) {
+		this.sumValue = sumValue;
+	}
+
+	public double getSumValue() {
+		return sumValue;
+	}
+
+	public Object serialize(StatsSerializer serializer) {
+		return serializer.visit(this);
+	}
+
+	public String[] getHeaders() {
+		return headers;
+	}
+
+}
Index: /DCWoRMS/trunk/src/simulator/stats/implementation/out/StatsSerializer.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/out/StatsSerializer.java	(revision 495)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/out/StatsSerializer.java	(revision 496)
@@ -5,5 +5,5 @@
 import simulator.stats.implementation.JobStats;
 import simulator.stats.implementation.ResourceAirFlowStats;
-import simulator.stats.implementation.ResourceEnergyStats;
+import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceStats;
 import simulator.stats.implementation.ResourceUsageStats;
@@ -27,5 +27,5 @@
 	public Object visit(ResourceUsageStats arg);
 	
-	public Object visit(ResourceEnergyStats arg);
+	public Object visit(ResourcePowerStats arg);
 
 	public Object visit(ResourceAirFlowStats arg);
Index: /DCWoRMS/trunk/src/simulator/stats/implementation/out/StringSerializer.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/out/StringSerializer.java	(revision 495)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/out/StringSerializer.java	(revision 496)
@@ -12,5 +12,5 @@
 import simulator.stats.implementation.JobStats;
 import simulator.stats.implementation.ResourceAirFlowStats;
-import simulator.stats.implementation.ResourceEnergyStats;
+import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceStats;
 import simulator.stats.implementation.ResourceUsageStats;
@@ -259,5 +259,5 @@
 
 	public Object visit(ResourceUsageStats resourceUsageStats) {
-		Map<Long, Double> resourceUsage = resourceUsageStats.getUsage();
+		Map<Long, Double> resourceUsage = resourceUsageStats.getHistory();
 		
 		int mapSize = resourceUsage.size();
@@ -308,5 +308,5 @@
 		}
 		if(resourceUsage.size() > 0){
-			buffer.append("mean: " + resourceUsageStats.getMeanUsage());
+			buffer.append("mean: " + resourceUsageStats.getMeanValue());
 			buffer.append(System.getProperty("line.separator"));	
 		}
@@ -314,6 +314,6 @@
 	}
 
-	public Object visit(ResourceEnergyStats resourceEnergyStats) {
-		Map<Long, Double> resourceEnergy = resourceEnergyStats.getEnergy();
+	public Object visit(ResourcePowerStats resourceEnergyStats) {
+		Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory();
 		
 		int mapSize = resourceEnergy.size();
@@ -365,5 +365,5 @@
 		
 		if(resourceEnergy.size() > 0) {
-			buffer.append("mean: "+resourceEnergyStats.getMeanUsage() + " sum: " +resourceEnergyStats.getSumUsage());
+			buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue());
 			buffer.append(System.getProperty("line.separator"));	
 		}
@@ -373,5 +373,5 @@
 
 	public Object visit(ResourceAirFlowStats resourceAirFlowStats) {
-		Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getAirFlow();
+		Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory();
 		
 		int mapSize = resourceAirFlow.size();
@@ -423,5 +423,5 @@
 		
 		if(resourceAirFlow.size() > 0) {
-			buffer.append("mean: "+resourceAirFlowStats.getMeanUsage() + " sum: " +resourceAirFlowStats.getSumUsage());
+			buffer.append("mean: "+resourceAirFlowStats.getMeanValue() + " sum: " +resourceAirFlowStats.getSumValue());
 			buffer.append(System.getProperty("line.separator"));	
 		}
Index: /DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 495)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java	(revision 496)
@@ -131,13 +131,14 @@
 	
 	//RESOURCES
-	protected Timetable ganttDiagramPeTimetable;
+	protected Map<String, List<ResStat>> basicResStats;
+	protected Map<String, Double> basicResLoad;
+	
+	protected Map<String, TimetableEventSource> peGanttMap;
+	protected Map<String, TimetableEventGroup> taskGanttMap;
+	
+	protected Timetable ganttDiagramTimetable;
 	protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams;
 	protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams;
 	protected Map<ResourceType, List<XYDataset>> resourceLoadDiagrams;
-	protected Map<String,List<ResStat>> basicResStats;
-	protected HashMap<String, Double> basicResLoad;
-	
-	protected Map<String, TimetableEventSource> peGanttMap;
-	protected Map<String, TimetableEventGroup> taskGanttMap;
 	
 	//TASKS
@@ -256,5 +257,5 @@
 		resourceAirFlowDiagrams = new HashMap<ResourceType, List<XYDataset>>();
 		
-		ganttDiagramPeTimetable = new Timetable(new FixedMillisecond(
+		ganttDiagramTimetable = new Timetable(new FixedMillisecond(
 				startSimulationTime), new FixedMillisecond(endSimulationTime));
 		
@@ -310,9 +311,9 @@
 				for(ComputingResource resource: resources){
 					ResourceUsageStats resourceUsage = null;
-					ResourceEnergyStats energyUsage = null;
+					ResourcePowerStats energyUsage = null;
 					ResourceAirFlowStats airFlow = null;
 					if(type_stats.get(resourceName).contains(Stats.textLoad)){
 						resourceUsage = gatherResourceLoadStats(resource, basicResStats);
-						resourceUsage.setMeanUsage(calculateResourceLoad(resource, basicResLoad));
+						resourceUsage.setMeanValue(calculateResourceLoad(resource, basicResLoad));
 						if (resourceLoadStatsFile != null) {
 							Object txt = resourceUsage.serialize(serializer);
@@ -326,12 +327,12 @@
 					}
 					if(type_stats.get(resourceName).contains(Stats.textEnergy)){
-						energyUsage = gatherResourceEnergyStats(resource);
-						energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage));
-						energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
+						energyUsage = gatherResourcePowerConsumptionStats(resource);
+						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)) {
 							if( een != null /*&& een.getPp() != null*/ ){
-								accStats.meanEnergyUsage.add(energyUsage.meanUsage);
+								accStats.meanEnergyUsage.add(energyUsage.getMeanValue());
 							}
 
@@ -348,5 +349,5 @@
 							}
 							if(top == true){
-								accStats.meanEnergyUsage.add(energyUsage.meanUsage);
+								accStats.meanEnergyUsage.add(energyUsage.getMeanValue());
 							}
 						}
@@ -359,5 +360,5 @@
 
 						if (configuration.creatediagrams_energyusage) {
-							createResourceEnergyGanttDiagram(energyUsage);
+							createResourceEnergyDiagramData(energyUsage);
 						}
 					}
@@ -365,6 +366,6 @@
 					if(type_stats.get(resourceName).contains(Stats.textAirFlow)){
 						airFlow = gatherResourceAirFlowStats(resource);
-						airFlow.setMeanUsage(calculateAirFlowLoad(airFlow));
-						airFlow.setSumUsage(airFlow.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
+						airFlow.setMeanValue(calculateMeanValue(airFlow));
+						airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));
 						
 						EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
@@ -397,5 +398,5 @@
 
 						if (configuration.creatediagrams_airflow) {
-							createResourceAirFlowGanttDiagram(airFlow);
+							createResourceAirFlowDiagramData(airFlow);
 						}
 					}
@@ -406,4 +407,5 @@
 		saveResourceGanttDiagrams();
 		createAccumulatedResourceSimulationStatistic();
+		
 		if (airFlowStatsFile != null) {
 			airFlowStatsFile.close();
@@ -416,18 +418,5 @@
 		}
 	}
-	
-	private double getSchedulerQueueStats(Scheduler scheduler) {
-
-		Sim_stat stats = scheduler.get_stat();
-		List<Object[]> measures = stats.get_measures();
-		for (Object[] info : measures) {
-			String measure = (String) info[0];
-			if (measure
-					.startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) {
-				return stats.average(measure);
-			}
-		}
-		return 0;
-	}
+
 	
 	private void peStatsPostProcessing(Map<String, List<ResStat>> basicResStats){
@@ -517,7 +506,7 @@
 			}
 		}
-		for(Long key: usageStats.getUsage().keySet()){
-			Double value = usageStats.getUsage().get(key)/cnt;
-			usageStats.getUsage().put(key, value);
+		for(Long key: usageStats.getHistory().keySet()){
+			Double value = usageStats.getHistory().get(key)/cnt;
+			usageStats.getHistory().put(key, 100*value);
 		}
 
@@ -525,7 +514,7 @@
 	}
 	
-	private TreeMap<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) {
-
-		TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getUsage();
+	private Map<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) {
+
+		TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getHistory();
 		for (ResStat resStat : resStats) {
 			
@@ -575,8 +564,8 @@
 	
 	
-	private ResourceEnergyStats gatherResourceEnergyStats(ComputingResource resource) {
+	private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) {
 		double power = 0;
-		ResourceEnergyStats resEnergyUsage = new ResourceEnergyStats(resource.getName(), resource.getType(), "resourceEnergyStats");
-		Map<Long, Double> usage = resEnergyUsage.getEnergy();
+		ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getName(), resource.getType(), "resourcePowerConsumptionStats");
+		Map<Long, Double> usage = resEnergyUsage.getHistory();
 		
 		ExtensionList extensionList = resource.getExtensionList();
@@ -613,5 +602,5 @@
 
 		ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getName(), resource.getType(), "resourceAirFlowStats");
-		Map<Long, Double> airFlow = resAirFlow.getAirFlow();
+		Map<Long, Double> airFlow = resAirFlow.getHistory();
 		
 		ExtensionList extensionList = resource.getExtensionList();
@@ -625,13 +614,8 @@
 					if(airFlowHistory.size() == 0)
 						break;
-					long lastTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis();
 					long endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
-					double lastAirFlow = 0;
 					airFlowHistory.add(new AirFlowValue(endSimulationTime, ee.getAirFlowProfile().getAirThroughputHistory().get(ee.getAirFlowProfile().getAirThroughputHistory().size()-1).getValue()));
 					for(AirFlowValue af:airFlowHistory){
 						airFlow.put(af.getTimestamp(), af.getValue());
-
-						lastAirFlow = af.getValue();
-						lastTime = af.getTimestamp();
 					}
 				}
@@ -641,45 +625,58 @@
 	}
 	
-	private void createResourceEnergyGanttDiagram(ResourceEnergyStats powerUsage) {
-
-		XYDataset dataset = createResourceEnergyGanttDataSet(powerUsage,
+	private void createResourceLoadDiagram(ResourceUsageStats resLoadStats) {
+
+		XYDataset dataset = createResourceChartDataSet(resLoadStats,
 				startSimulationTime, endSimulationTime);
-		
-		List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(powerUsage.getResourceType());
-		if(energyDiagram == null){
-			energyDiagram = new ArrayList<XYDataset>();
-			energyDiagram.add(dataset);
-			resourcePowerUsageDiagrams.put(powerUsage.getResourceType(), energyDiagram);
+
+		List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resLoadStats.getResourceType());
+		if(loadDiagram == null){
+			loadDiagram = new ArrayList<XYDataset>();
+			loadDiagram.add(dataset);
+			resourceLoadDiagrams.put(resLoadStats.getResourceType(), loadDiagram);
 		} else {
-			energyDiagram.add(dataset);
-		}
-
-	}
-
-	private void createResourceAirFlowGanttDiagram(ResourceAirFlowStats airFlow) {
-
-		XYDataset dataset = createResourceAirFlowGanttDataSet(airFlow,
+			loadDiagram.add(dataset);
+		}
+	}
+	
+	private void createResourceEnergyDiagramData(ResourceDynamicStats powerConsumptionStats) {
+
+		XYDataset dataset = createResourceChartDataSet(powerConsumptionStats,
 				startSimulationTime, endSimulationTime);
 		
-		List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(airFlow.getResourceType());
-		if(airFlowDiagram == null){
-			airFlowDiagram = new ArrayList<XYDataset>();
-			airFlowDiagram.add(dataset);
-			resourceAirFlowDiagrams.put(airFlow.getResourceType(), airFlowDiagram);
+		List<XYDataset> energyDiagramData = resourcePowerUsageDiagrams.get(powerConsumptionStats.getResourceType());
+		if(energyDiagramData == null){
+			energyDiagramData = new ArrayList<XYDataset>();
+			energyDiagramData.add(dataset);
+			resourcePowerUsageDiagrams.put(powerConsumptionStats.getResourceType(), energyDiagramData);
 		} else {
-			airFlowDiagram.add(dataset);
-		}
-
-	}
-	
-	private XYDataset createResourceEnergyGanttDataSet(
-			ResourceEnergyStats energyUsage, long start, long end) {
-
-		TreeMap<Long, Double> ganttdata = createResourceEnergyGanttData(energyUsage);
+			energyDiagramData.add(dataset);
+		}
+	}
+
+	private void createResourceAirFlowDiagramData(ResourceDynamicStats airFlowStats) {
+
+		XYDataset dataset = createResourceChartDataSet(airFlowStats,
+				startSimulationTime, endSimulationTime);
+		
+		List<XYDataset> airFlowDiagramData = resourceAirFlowDiagrams.get(airFlowStats.getResourceType());
+		if(airFlowDiagramData == null){
+			airFlowDiagramData = new ArrayList<XYDataset>();
+			airFlowDiagramData.add(dataset);
+			resourceAirFlowDiagrams.put(airFlowStats.getResourceType(), airFlowDiagramData);
+		} else {
+			airFlowDiagramData.add(dataset);
+		}
+	}
+
+	private XYDataset createResourceChartDataSet(
+			ResourceDynamicStats dynamicStats, long start, long end) {
+
+		Map<Long, Double> chartData = getResourceChartRawData(dynamicStats);
 		XYSeriesCollection dataset = new XYSeriesCollection();
-		XYSeries data = new XYSeries(energyUsage.getResourceName(), false, true);
+		XYSeries data = new XYSeries(dynamicStats.getResourceName(), false, true);
 		//data.add(start, 0);
-		for (Long key : ganttdata.keySet()) {
-			Double val = ganttdata.get(key);
+		for (Long key : chartData.keySet()) {
+			Double val = chartData.get(key);
 			data.add(key, val);
 		}
@@ -689,48 +686,17 @@
 	}
 
-	private TreeMap<Long, Double> createResourceEnergyGanttData(
-			ResourceEnergyStats energyUsage) {
-
-		Map<Long, Double> energy = energyUsage.getEnergy();
-		TreeMap<Long, Double> ganttData = new TreeMap<Long, Double>();
-		for (Long euKey : energy.keySet()) {
-
-			ganttData.put(euKey, energy.get(euKey));
-		}
-		return ganttData;
-	}
-
-	private XYDataset createResourceAirFlowGanttDataSet(
-			ResourceAirFlowStats airFlowStats, long start, long end) {
-
-		TreeMap<Long, Double> ganttdata = createResourceAirFlowGanttData(airFlowStats);
-		XYSeriesCollection dataset = new XYSeriesCollection();
-		XYSeries data = new XYSeries(airFlowStats.getResourceName(), false, true);
-		//data.add(start, 0);
-		for (Long key : ganttdata.keySet()) {
-			Double val = ganttdata.get(key);
-			data.add(key, val);
-		}
-		data.add(end, 0);
-		dataset.addSeries(data);
-		return dataset;
-	}
-
-	private TreeMap<Long, Double> createResourceAirFlowGanttData(
-			ResourceAirFlowStats airFlowStats) {
-
-		Map<Long, Double> airFlow = airFlowStats.getAirFlow();
-		TreeMap<Long, Double> ganttData = new TreeMap<Long, Double>();
-		for (Long afKey : airFlow.keySet()) {
-			ganttData.put(afKey, airFlow.get(afKey));
-		}
-		return ganttData;
+	private Map<Long, Double> getResourceChartRawData(
+			ResourceDynamicStats dynamicStats) {
+
+		Map<Long, Double> history = dynamicStats.getHistory();
+		Map<Long, Double> chartData = new TreeMap<Long, Double>();
+		for (Long key : history.keySet()) {
+			chartData.put(key, history.get(key));
+		}
+		return chartData;
 	}
 
 	private boolean saveResourceGanttDiagrams() {
-		JFreeChart resourceDiagram = null;
-		JFreeChart peDiagram = null;
-		JFreeChart resourceEnergyDiagram = null;
-		JFreeChart resourceAirFlowDiagram = null;
+
 		if (!generateDiagrams)
 			return false;
@@ -745,7 +711,7 @@
 				+ "\" at " + Calendar.getInstance().getTime().toString());
 
-		
+		JFreeChart peDiagram = null;
 		if (configuration.creatediagrams_processors) {
-			peDiagram = getPeGanttDiagram(chartName, subtitle,
+			peDiagram = getPEGanttDiagram(chartName, subtitle,
 					simulationTime);
 			if (!saveCategoryChart(peDiagram, fileName + "Gantt",
@@ -754,17 +720,21 @@
 		}
 
+		JFreeChart resourceLoadDiagram = null;
 		if (configuration.creatediagrams_resources) {
+			String axisName = "UTILIZATION [%]";
 			for(ResourceType resType: resourceLoadDiagrams.keySet()){
-				resourceDiagram = getResourcesLoadDiagram(resType, chartName, subtitle,
-						simulationTime);
-				if (!saveXYPlotChart(resourceDiagram, fileName + "Resources Load - "+resType))
+				resourceLoadDiagram = getResourceDynamicDiagram(resourceLoadDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
+				if (!saveXYPlotChart(resourceLoadDiagram, fileName + "Resources Load - "+resType))
 					return false;
 			}
-
-		}
+		}
+		
+		JFreeChart resourceEnergyDiagram = null;
 		if (configuration.creatediagrams_energyusage) {
+			String axisName = "POWER [W]";
 			for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){
-				resourceEnergyDiagram = getResourcesEnergyDiagram(resType, chartName,
-						subtitle, simulationTime);
+				resourceEnergyDiagram = getResourceDynamicDiagram(resourcePowerUsageDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
 				if (!saveXYPlotChart(resourceEnergyDiagram, fileName + "Energy - "+resType))
 					return false;
@@ -772,9 +742,10 @@
 		}
 		
-		
+		JFreeChart resourceAirFlowDiagram = null;
 		if (configuration.creatediagrams_airflow) {
+			String axisName = "AIR FLOW [m^3/min]";
 			for(ResourceType resType: resourceAirFlowDiagrams.keySet()){
-				resourceAirFlowDiagram = getResourcesAirFlowDiagram(resType, chartName,
-						subtitle, simulationTime);
+				resourceAirFlowDiagram = getResourceDynamicDiagram(resourceAirFlowDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
 				if (!saveXYPlotChart(resourceAirFlowDiagram, fileName + "AirThroughput - "+resType))
 					return false;
@@ -784,7 +755,21 @@
 	}
 	
-	private JFreeChart getResourcesLoadDiagram(ResourceType resType, String chartName, Title subtitle,
+	private JFreeChart getPEGanttDiagram(String chartName, Title subtitle,
 			String simulationTime) {
-		String cpu = "UTILIZATION [%]";
+		String processors = "Processing Elements";
+		boolean tooltip = true;
+		boolean legend = true;
+		JFreeChart chart = TimetableChartFactory.createTimetableChart(
+				chartName, processors, simulationTime,
+				ganttDiagramTimetable, legend, tooltip);
+		chart.addSubtitle(subtitle);
+		TimetableRenderer rend = (TimetableRenderer) chart.getCategoryPlot()
+				.getRenderer();
+		rend.setBackgroundBarPaint(null);
+		return chart;
+	}
+	
+	private JFreeChart getResourceDynamicDiagram(List<XYDataset> diagramData, String simulationTime, String chartName, Title subtitle,
+			String axisName) {
 		boolean urls = false;
 		boolean tooltip = true;
@@ -794,11 +779,9 @@
 		JFreeChart chart = null;
 
-		List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resType);
-		for (XYDataset dataset : loadDiagram) {
+		for (XYDataset dataset : diagramData) {
 			JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "",
-				null, dataset, PlotOrientation.VERTICAL, legend, tooltip,
-				urls);
+				null, dataset, PlotOrientation.VERTICAL, legend, tooltip, urls);
 			XYPlot tPlot = tChart.getXYPlot();
-			NumberAxis yAxis = new NumberAxis(cpu);
+			NumberAxis yAxis = new NumberAxis(axisName);
 			yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
 			tPlot.setRangeAxis(yAxis);
@@ -813,83 +796,4 @@
 		return chart;
 	}
-
-	private JFreeChart getResourcesEnergyDiagram(ResourceType resType, String chartName,
-			Title subtitle, String simulationTime) {
-		String energy = "POWER [W]";
-		boolean urls = false;
-		boolean tooltip = true;
-		boolean legend = true;
-		CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot();
-		DateAxis xAxis = new DateAxis(simulationTime);
-
-		List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(resType);
-		for (XYDataset dataset : energyDiagram) {
-
-			JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "",
-					null, dataset, PlotOrientation.VERTICAL, legend, tooltip,
-					urls);
-
-			XYPlot tPlot = tChart.getXYPlot();
-			NumberAxis yAxis = new NumberAxis(energy);
-			yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
-			tPlot.setRangeAxis(yAxis);
-			XYStepAreaRenderer rend = (XYStepAreaRenderer) tPlot.getRenderer();
-			rend.setShapesVisible(false);
-			cPlot.add(tPlot);
-		}
-		cPlot.setDomainAxis(xAxis);
-		cPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
-		JFreeChart chart = new JFreeChart(chartName, cPlot);
-		chart.addSubtitle(subtitle);
-		return chart;
-	}
-	
-	private JFreeChart getResourcesAirFlowDiagram(ResourceType resType, String chartName,
-			Title subtitle, String simulationTime) {
-		String airFlow = "AIR FLOW [m^3/min]";
-		boolean urls = false;
-		boolean tooltip = true;
-		boolean legend = true;
-		CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot();
-		DateAxis xAxis = new DateAxis(simulationTime);
-
-		List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(resType);
-		for (XYDataset dataset : airFlowDiagram) {
-
-			JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "",
-					null, dataset, PlotOrientation.VERTICAL, legend, tooltip,
-					urls);
-
-			XYPlot tPlot = tChart.getXYPlot();
-			NumberAxis yAxis = new NumberAxis(airFlow);
-			yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
-			tPlot.setRangeAxis(yAxis);
-			XYStepAreaRenderer rend = (XYStepAreaRenderer) tPlot.getRenderer();
-			rend.setShapesVisible(false);
-			cPlot.add(tPlot);
-		}
-		cPlot.setDomainAxis(xAxis);
-		cPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);
-		JFreeChart chart = new JFreeChart(chartName, cPlot);
-		chart.addSubtitle(subtitle);
-		return chart;
-	}
-	
-	
-	private JFreeChart getPeGanttDiagram(String chartName, Title subtitle,
-			String simulationTime) {
-		String processors = "Processing Elements";
-		boolean tooltip = true;
-		boolean legend = true;
-		JFreeChart chart = TimetableChartFactory.createTimetableChart(
-				chartName, processors, simulationTime,
-				ganttDiagramPeTimetable, legend, tooltip);
-		chart.addSubtitle(subtitle);
-		TimetableRenderer rend = (TimetableRenderer) chart.getCategoryPlot()
-				.getRenderer();
-		rend.setBackgroundBarPaint(null);
-		return chart;
-	}
-	
 	
 	private boolean saveXYPlotChart(JFreeChart c, String fileName) {
@@ -932,5 +836,5 @@
 		for(String peName: basicResStats.keySet()){
 			TimetableEventSource pe = new TimetableEventSource(peName);
-			ganttDiagramPeTimetable.addEventSource(pe);
+			ganttDiagramTimetable.addEventSource(pe);
 			peGanttMap.put(peName, pe);
 			for(ResStat resStat: basicResStats.get(peName)){
@@ -948,7 +852,7 @@
 					task = new TimetableEventGroup(resStat.getTaskID());
 					taskGanttMap.put(resStat.getTaskID(), task);
-					ganttDiagramPeTimetable.addEventGroup(task);
-				}
-				ganttDiagramPeTimetable.addEvent(pe, task,
+					ganttDiagramTimetable.addEventGroup(task);
+				}
+				ganttDiagramTimetable.addEvent(pe, task,
 						new FixedMillisecond(startDate), new FixedMillisecond(endDate));
 			}
@@ -956,33 +860,5 @@
 	}
 
-	private void createResourceLoadDiagram(ResourceUsageStats resStats) {
-
-		XYDataset dataset = createResourceLoadDataSet(resStats);
-
-		List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resStats.getResourceType());
-		if(loadDiagram == null){
-			loadDiagram = new ArrayList<XYDataset>();
-			loadDiagram.add(dataset);
-			resourceLoadDiagrams.put(resStats.getResourceType(), loadDiagram);
-		} else {
-			loadDiagram.add(dataset);
-		}
-	}
-
-	private XYDataset createResourceLoadDataSet(ResourceUsageStats resStats) {
-
-		XYSeriesCollection dataset = new XYSeriesCollection();
-		XYSeries data = new XYSeries(resStats.resourceName, false, true);
-		Map<Long, Double> usage = resStats.getUsage();
-		
-		for (Long key : usage.keySet()) {
-			Double val = usage.get(key);
-			double newv = 100 * val;
-			//System.out.println(newv+":"+val+";"+basicResStats.size());
-			data.add(key, new Double(newv));
-		}
-		dataset.addSeries(data);
-		return dataset;
-	}
+
 
 	private void createAccumulatedResourceSimulationStatistic() {
@@ -1014,5 +890,5 @@
 	}
 	
-	private  Double calculateResourceLoad(ComputingResource resource, HashMap<String, Double> peLoad ){
+	private  Double calculateResourceLoad(ComputingResource resource, Map<String, Double> peLoad ){
 		int peCnt = 0;
 		double sum = 0;
@@ -1033,67 +909,30 @@
 		return sum/peCnt;
 	}
-	
-	private double calculateEnergyLoad(ResourceEnergyStats resEnergyStats ){
-		double meanEnergyUsage = 0;
+
+	
+	private double calculateMeanValue(ResourceDynamicStats resDynamicStats ){
+		double meanValue = 0;
 		long time = 0;
-		double usage = 0;
-		Map<Long, Double> enUsage = resEnergyStats.getEnergy();
-		for (Long key : enUsage.keySet()) {
+		double value = 0;
+		
+		Map<Long, Double> history = resDynamicStats.getHistory();
+		for (Long key : history.keySet()) {
 			
 			if (time != 0) {
-				meanEnergyUsage += (usage * (key - time))
-						/ (endSimulationTime - startSimulationTime);
-
+				meanValue += (value * (key - time)) / (endSimulationTime - startSimulationTime);
 				time = key;
 			} else {
 				time = key;
 			}
-			usage = (double) enUsage.get(key);
-		}
-		return meanEnergyUsage;
-	}
-	
-	private double calculateAirFlowLoad(ResourceAirFlowStats resAirFlowStats ){
-		double meanAirFlow = 0;
-		long time = 0;
-		double usage = 0;
-		Map<Long, Double> airFlow = resAirFlowStats.getAirFlow();
-		for (Long key : airFlow.keySet()) {
-			
-			if (time != 0) {
-				meanAirFlow += (usage * (key - time))
-						/ (endSimulationTime - startSimulationTime);
-
-				time = key;
-			} else {
-				time = key;
-			}
-			usage = (double) airFlow.get(key);
-		}
-		return meanAirFlow;
-	}
-	
-	
-	/*private void createPEGanttDiagram(String peName,
-			String uniqueTaskID, Map<String, Object> historyItem) {
-		TimetableEventSource pe = peGanttMap.get(peName);
-		if(pe == null){
-			pe = new TimetableEventSource(peName);
-			ganttDiagramPETimetable.addEventSource(pe);
-			peGanttMap.put(peName, pe);
-		}
-		TimetableEventGroup task = taskGanttMap.get(uniqueTaskID);
-		long startDate = ((DateTime) historyItem.get(GssimConstants.START_TIME))
-				.getMillis();
-		long endDate = ((DateTime) historyItem.get(GssimConstants.END_TIME))
-				.getMillis();
-		if (task == null) {
-			task = new TimetableEventGroup(uniqueTaskID);
-			taskGanttMap.put(uniqueTaskID, task);
-			ganttDiagramPETimetable.addEventGroup(task);
-		}
-		ganttDiagramPETimetable.addEvent(pe, task,
-				new FixedMillisecond(startDate), new FixedMillisecond(endDate));
-	}*/
+			value = history.get(key);
+		}
+		return meanValue;
+	}
+	
+	
+
+	
+	
+	
 	
 
@@ -1194,4 +1033,18 @@
 	}
 
+	private double getSchedulerQueueStats(Scheduler scheduler) {
+
+		Sim_stat stats = scheduler.get_stat();
+		List<Object[]> measures = stats.get_measures();
+		for (Object[] info : measures) {
+			String measure = (String) info[0];
+			if (measure
+					.startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) {
+				return stats.average(measure);
+			}
+		}
+		return 0;
+	}
+	
 	private TaskStats createTaskStats(Executable task) {
 		TaskStats taskStats = new TaskStats(task, startSimulationTime);
@@ -1425,5 +1278,4 @@
 
 		public int compare(JobInterface<?> o1, JobInterface<?> o2) {
-
 			Integer o1int;
 			Integer o2int;
@@ -1435,5 +1287,4 @@
 				return o1.getId().compareTo(o2.getId());
 			}
-
 		}
 	}
@@ -1481,5 +1332,4 @@
 class ResStat{
 	
-	
 	public long getStartDate() {
 		return startDate;
Index: /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceAirFlowStats.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceAirFlowStats.java	(revision 495)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceAirFlowStats.java	(revision 496)
@@ -1,59 +1,25 @@
 package simulator.stats.implementation;
-
-import java.util.Map;
-import java.util.TreeMap;
 
 import schedframe.resources.ResourceType;
 import simulator.stats.implementation.out.StatsSerializer;
 
-public class ResourceAirFlowStats {
-	protected Map<Long, Double> airFlow;
-	protected String resourceName;
-	protected String usageType;
-	protected ResourceType resourceType;
-	protected double meanValue;
+public class ResourceAirFlowStats extends ResourceDynamicStats implements StatsInterface{
+
 	protected double sumValue;
 	
-	public void setSumUsage(double sumUsage) {
-		this.sumValue = sumUsage;
+	private String[] headers = { "resourceName", "timestamp", "airFlow" };
+	
+	public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) {
+		super(resourceName, resourceType, usageType);
 	}
 
-	public double getSumUsage() {
+	public void setSumValue(double sumValue) {
+		this.sumValue = sumValue;
+	}
+
+	public double getSumValue() {
 		return sumValue;
 	}
-	public void setMeanUsage(double meanUsage) {
-		this.meanValue = meanUsage;
-	}
 	
-	public double getMeanUsage() {
-		return meanValue;
-	}
-	
-	private String[] headers = { "resourceName", "timestamp", "value" };
-	
-	public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) {
-		this.resourceName = resourceName;
-		this.resourceType = resourceType;
-		this.usageType = usageType;
-		this.airFlow = new TreeMap<Long, Double>();
-		this.meanValue = 0;
-	}
-
-	public String getResourceName() {
-		return this.resourceName;
-	}
-	
-	public ResourceType getResourceType() {
-		return resourceType;
-	}
-
-	public String getUsageType() {
-		return this.usageType;
-	}	
-
-	public Map<Long, Double> getAirFlow() {
-		return this.airFlow;
-	}
-
 	public Object serialize(StatsSerializer serializer) {
 		return serializer.visit(this);
Index: /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceDynamicStats.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceDynamicStats.java	(revision 496)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceDynamicStats.java	(revision 496)
@@ -0,0 +1,53 @@
+package simulator.stats.implementation;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import schedframe.resources.ResourceType;
+
+public abstract class ResourceDynamicStats {
+	
+	protected Map<Long, Double> history;
+	protected String resourceName;
+	protected String usageType;
+	protected ResourceType resourceType;
+	protected double meanValue;
+
+	private String[] headers = { "resourceName", "timestamp", "usage" };
+
+	public ResourceDynamicStats(String resourceName, ResourceType resourceType, String usageType) {
+		this.resourceName = resourceName;
+		this.resourceType = resourceType;
+		this.usageType = usageType;
+		this.history = new TreeMap<Long, Double>();
+		this.meanValue = 0;
+	}
+
+	public void setMeanValue(double meanValue) {
+		this.meanValue = meanValue;
+	}
+	
+	public double getMeanValue() {
+		return meanValue;
+	}
+
+	public String getResourceName() {
+		return this.resourceName;
+	}
+	
+	public ResourceType getResourceType() {
+		return resourceType;
+	}
+	
+	public String getUsageType() {
+		return this.usageType;
+	}	
+
+	public Map<Long, Double> getHistory() {
+		return this.history;
+	}
+
+	public String[] getHeaders() {
+		return headers;
+	}
+}
Index: /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceUsageStats.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceUsageStats.java	(revision 495)
+++ /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceUsageStats.java	(revision 496)
@@ -1,56 +1,13 @@
 package simulator.stats.implementation;
 
-import java.util.Map;
-import java.util.TreeMap;
-
 import schedframe.resources.ResourceType;
-import schedframe.resources.StandardResourceType;
 import simulator.stats.implementation.out.StatsSerializer;
 
-/**
- * 
- * @author Marcin Krystek
- * 
- */
-public class ResourceUsageStats implements StatsInterface {
+public class ResourceUsageStats extends ResourceDynamicStats implements StatsInterface {
 
-	protected Map<Long, Double> usage;
-	protected String resourceName;
-	protected String usageType;
-	protected ResourceType resourceType;
-	protected double meanUsage;
-	
-	public void setMeanUsage(double meanUsage) {
-		this.meanUsage = meanUsage;
-	}
-
-	private String[] headers = { "resourceName", "timestamp", "usage" };
+	private String[] headers = { "resourceName", "timestamp", "utilization" };
 
 	public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) {
-		this.resourceName = resourceName;
-		this.resourceType = resourceType;
-		this.usageType = usageType;
-		this.usage = new TreeMap<Long, Double>();
-		this.meanUsage = 0;
-	}
-
-	public double getMeanUsage() {
-		return meanUsage;
-	}
-
-	public String getResourceName() {
-		return this.resourceName;
-	}
-	
-	public ResourceType getResourceType() {
-		return resourceType;
-	}
-	
-	public String getUsageType() {
-		return this.usageType;
-	}	
-
-	public Map<Long, Double> getUsage() {
-		return this.usage;
+		super(resourceName, resourceType, usageType);
 	}
 
@@ -62,4 +19,3 @@
 		return headers;
 	}
-
 }
Index: WoRMS/trunk/src/simulator/stats/implementation/ResourceEnergyStats.java
===================================================================
--- /DCWoRMS/trunk/src/simulator/stats/implementation/ResourceEnergyStats.java	(revision 477)
+++ 	(revision )
@@ -1,66 +1,0 @@
-package simulator.stats.implementation;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import schedframe.resources.ResourceType;
-import simulator.stats.implementation.out.StatsSerializer;
-
-public class ResourceEnergyStats {
-	protected Map<Long, Double> energy;
-	protected String resourceName;
-	protected String usageType;
-	protected ResourceType resourceType;
-	protected double meanUsage;
-	protected double sumUsage;
-	
-	public void setSumUsage(double sumUsage) {
-		this.sumUsage = sumUsage;
-	}
-
-	public double getSumUsage() {
-		return sumUsage;
-	}
-	public void setMeanUsage(double meanUsage) {
-		this.meanUsage = meanUsage;
-	}
-	
-	public double getMeanUsage() {
-		return meanUsage;
-	}
-	
-	private String[] headers = { "resourceName", "timestamp", "usage" };
-	
-	public ResourceEnergyStats (String resourceName, ResourceType resourceType, String usageType) {
-		this.resourceName = resourceName;
-		this.resourceType = resourceType;
-		this.usageType = usageType;
-		this.energy = new TreeMap<Long, Double>();
-		this.meanUsage = 0;
-	}
-
-	public String getResourceName() {
-		return this.resourceName;
-	}
-	
-	public ResourceType getResourceType() {
-		return resourceType;
-	}
-
-	public String getUsageType() {
-		return this.usageType;
-	}	
-
-	public Map<Long, Double> getEnergy() {
-		return this.energy;
-	}
-
-	public Object serialize(StatsSerializer serializer) {
-		return serializer.visit(this);
-	}
-
-	public String[] getHeaders() {
-		return headers;
-	}
-
-}
