Index: DCWoRMS/trunk/build/classes/simulator/DCWormsUsers.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/DCWormsUsers.java	(revision 539)
+++ DCWoRMS/trunk/build/classes/simulator/DCWormsUsers.java	(revision 539)
@@ -0,0 +1,328 @@
+package simulator;
+
+import dcworms.schedframe.scheduling.utils.JobDescription;
+import dcworms.schedframe.scheduling.utils.TaskDescription;
+import eduni.simjava.Sim_event;
+import eduni.simjava.Sim_system;
+import gridsim.GridSim;
+import gridsim.GridSimTags;
+import gridsim.IO_data;
+import gridsim.dcworms.DCWormsTags;
+import gridsim.net.InfoPacket;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.joda.time.DateTime;
+
+import qcg.shared.constants.BrokerConstants;
+import schedframe.scheduling.tasks.Job;
+import schedframe.scheduling.tasks.JobInterface;
+import schedframe.scheduling.tasks.Task;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.utils.XsltTransformations;
+import simulator.workload.WorkloadLoader;
+
+public class DCWormsUsers extends GridSim implements GenericUser {
+
+	/**A job generator, which produces jobs and tasks. These jobs are then sent by this entity */
+	protected WorkloadLoader workloadLoader;
+	
+	/** The name of the entity, to which the created tasks will be sent */
+	protected String destName;
+	
+	/** Indicates, that all tasks that returned to this object are finished */
+	protected boolean allTasksAreFinished;
+	
+	/** Stores the list of jobs, that have been returned to this object */
+	protected List<JobInterface<?>> returnedJobs;
+	protected Set<String> sendJobsIds;
+	protected Set<String> returnedJobsIds;
+	
+	protected XsltTransformations xsltTransformer;
+	
+	/**
+	 * Indicates, that an error has occurred - it is used for debug purposes
+	 */
+	protected boolean error;
+	
+	private static Log log = LogFactory.getLog(DCWormsUsers.class);
+	
+	/**
+	 * Constructs the users object with the given parameters
+	 * @param name the name of the users entity (must be unique across all entities in the whole simulation)
+	 * @param destinationName the name of the entity, to which the created tasks will be sent 
+	 * @param jobGenerator the job generator, which produces jobs and tasks, that will be sent by this class
+	 * @throws Exception if any occurs (see {@link GridSim#GridSim(String, double)})
+	 */
+	public DCWormsUsers(String name, String destinationName, WorkloadLoader workload) throws Exception {
+		super(name, DCWormsConstants.DEFAULT_BAUD_RATE);
+		this.workloadLoader = workload;
+		destName = destinationName;
+		allTasksAreFinished = true;
+		error = false;
+		
+		sendJobsIds = new HashSet<String>();
+		returnedJobsIds = new HashSet<String>();
+		
+		this.xsltTransformer = new XsltTransformations();
+	}
+
+	@Override
+	public void body() {
+		sendJobs();
+		collectJobs();
+
+		//GridSim dependent code for shutting down the simulation
+		shutdownGridStatisticsEntity();
+		terminateIOEntities();
+		shutdownUserEntity();
+	}
+
+	/**
+	 * Collects the jobs sent to broker(s)
+	 */
+	protected void collectJobs() {
+		final int FACTOR = Math.min(10, workloadLoader.getTaskCount()); //the refresh rate of the gauge: at most 10 times
+		final int denominator = workloadLoader.getTaskCount() / FACTOR;
+		allTasksAreFinished = true;
+		returnedJobs = new ArrayList<JobInterface<?>>();
+		int counter = 0;
+		int oldRemeinder = 0;
+		boolean hundredPercent = false;
+		
+		Sim_event ev = new Sim_event();
+		sim_get_next(ev);
+		while (Sim_system.running()) {
+			switch (ev.get_tag()) {
+			case GridSimTags.END_OF_SIMULATION:
+				//no action
+				break;
+			
+			case GridSimTags.INFOPKT_SUBMIT:
+				processPingRequest(ev);
+				break;
+				
+			case GridSimTags.GRIDLET_RETURN:
+				JobInterface<?> returnedJob = (JobInterface<?>) ev.get_data();
+				
+				String jobId = returnedJob.getId();
+
+				
+				if (returnedJobs.contains(returnedJob)) {
+					if(log.isErrorEnabled())
+						log.error("Received the same job twice (job ID " + jobId + ")");
+					error = true;
+					break;
+				} 
+				
+				returnedJobs.add(returnedJob);
+				returnedJobsIds.add(jobId);
+				
+				if(returnedJob.getStatus() == BrokerConstants.JOB_STATUS_FINISHED) {
+					if(log.isDebugEnabled())
+						log.debug("Received finished job " + jobId);
+					
+				} else {
+					if(returnedJob.getStatus() == BrokerConstants.JOB_STATUS_CANCELED) {
+						if(log.isWarnEnabled()){
+							String str = "Warning! An uncomplished job (Job ID: "+jobId+") has returned to users. Job was canceled.";
+							log.warn(str);
+						}
+					}
+					
+					allTasksAreFinished = false;
+				}
+				
+				counter += returnedJob.getTaskCount();
+				int remainder = (counter / denominator);
+				if (remainder != oldRemeinder) {
+					int gauge = ((counter * 100) / (workloadLoader.getTaskCount()));
+					if(log.isInfoEnabled())
+						log.info(gauge + "% ");
+					
+					oldRemeinder = remainder;
+					if (gauge == 100)
+						hundredPercent = true;
+				}
+			
+				break;
+			} 
+			
+			//if all the Gridlets have been collected
+			if (counter == workloadLoader.getTaskCount()) {
+				break;
+			}
+			
+			sim_get_next(ev);
+		}
+		
+		//if all the Gridlets have been collected
+		if (counter == workloadLoader.getTaskCount()) {
+			if (! hundredPercent) {
+				if(log.isInfoEnabled())
+					log.info("100%");
+			}
+			if(log.isInfoEnabled())
+				log.info(get_name() + ": Received all "+workloadLoader.getJobCount()+" jobs and " + counter + " tasks");			
+		} else {
+			if(log.isErrorEnabled())
+				log.error(get_name() + ": ERROR DID NOT RECEIVED all tasks - some tasks were not finished! (received "+counter+" of "+workloadLoader.getTaskCount()+")");
+		}
+		
+		Iterator <String> itr = sendJobsIds.iterator();
+		String jobId;
+		if(log.isInfoEnabled()){
+			log.info("Missing tasks: ");
+			while(itr.hasNext()){
+				jobId = itr.next();
+				if(!returnedJobsIds.contains(jobId)){
+					log.info(jobId + ", ");
+				}
+			}
+		}
+		
+	}
+
+	/**
+	 * Sends jobs to broker entities
+	 */
+	protected void sendJobs() {
+		
+		Map<Long, List<Job>> jobTimes = new TreeMap<Long, List<Job>>();
+		int destID = GridSim.getEntityId(destName);
+		//destID=GridSim.getEntityId("BROKER@COMPUTING_GRID_0");
+		List<JobDescription> jobs = workloadLoader.getJobs();
+		//TaskRequirements taskReq = new TaskRequirementsImpl();
+		//double values[] = null;
+
+		for (JobDescription job : jobs) {
+			long l_submissionTime = Long.MAX_VALUE;
+			//pick the lowest submission time
+			for (TaskDescription task : job) {
+				if (task.getSubmissionTime() < l_submissionTime)
+					l_submissionTime = task.getSubmissionTime();
+			}
+
+			//store the submission time expressed in seconds after the simulation start time
+			long submissionTime = l_submissionTime;
+			
+			Job newJob = prepareJob(job, submissionTime);
+			
+			List<Job> list = jobTimes.get(submissionTime);
+			if (list == null) {
+				list = new ArrayList<Job>();
+				jobTimes.put(submissionTime, list);
+			}
+			list.add(newJob);
+		}
+		for (Long submissionTime : jobTimes.keySet()) {
+			List<Job> list = jobTimes.get(submissionTime);
+			for(int i = 0; i < list.size(); i++){
+				this.sendJobsIds.add(list.get(i).getId());
+				send(destID, submissionTime, GridSimTags.GRIDLET_SUBMIT, list.get(i));
+			}
+			
+			//send(output, submissionTime, GridSimTags.GRIDLET_SUBMIT, new IO_data(list, GssConstants.DEFAULT_GRIDLET_SIZE, destID));
+			//send(destID, submissionTime, GridSimTags.GRIDLET_SUBMIT, list);
+			
+		}
+		System.out.println("finished sending jobs");
+	}
+	
+	public List<JobDescription> getAllSentJobs() {
+		return (List<JobDescription>) workloadLoader.getJobs();
+	}
+	
+	public List<TaskDescription> getAllSentTasks() {
+		List<TaskDescription> result = new ArrayList<TaskDescription>();
+		List<JobDescription> sentJobs = getAllSentJobs();
+		for (JobDescription job : sentJobs) {
+			result.addAll(job);
+		}
+		return result;
+	}
+	
+	public List<JobInterface<?>> getAllReceivedJobs() {
+		return returnedJobs;
+	}
+
+	public int getFinishedTasksCount() {
+		int result = 0;
+		for (JobInterface<?> job : returnedJobs) {
+			for (TaskInterface<?> task: job.getTask()) {
+				if(task.getStatus() == DCWormsTags.SUCCESS)
+					result++;
+			}
+		}
+		return result;
+	}
+	
+	public String getUserName() {
+		return get_name();
+	}
+	
+	public boolean isError() {
+		return error;
+	}
+	
+	/**
+	 * Performs action concerning a ping request to this entity
+	 * @param ev the event object
+	 */
+	protected void processPingRequest(Sim_event ev) {
+        InfoPacket pkt = (InfoPacket) ev.get_data();
+        pkt.setTag(GridSimTags.INFOPKT_RETURN);
+        pkt.setDestID(pkt.getSrcID());
+
+		// sends back to the sender
+		send(output, GridSimTags.SCHEDULE_NOW, GridSimTags.INFOPKT_RETURN,
+				new IO_data(pkt, pkt.getSize(), pkt.getSrcID()));
+    }
+		
+	protected Job prepareJob(JobDescription jobDescription, long submissionTime){
+
+		Job newJob = new Job(jobDescription.getJobId());
+		DateTime submitionTime = new DateTime();
+        submitionTime = submitionTime.plusMillis((int)submissionTime*1000);
+			try {
+				
+				// transform job description to resource requirements
+
+				newJob.setSenderId(this.get_id());
+				
+				for (TaskDescription taskDescription : jobDescription) {
+					
+					String xmlResReq = this.xsltTransformer.taskToResourceRequirements(
+										taskDescription.getDocument(),
+										jobDescription.getJobId(),
+										taskDescription.getUserDn(),
+										submitionTime);
+
+					Task newTask = new Task(xmlResReq);
+					newTask.setSenderId(this.get_id());
+					newTask.setStatus((int)BrokerConstants.TASK_STATUS_UNSUBMITTED);
+					newTask.setLength(taskDescription.getTaskLength());
+					newTask.setWorkloadLogWaitTime(taskDescription.getWorkloadLogWaitTime());
+			//		newTask.setSubmissionTime(taskDescription.getSubmissionTime());
+					
+					newJob.add(newTask);
+				}
+
+				jobDescription.discardUnused();
+				
+			} catch (Exception e){
+				log.error(e.getMessage());
+				e.printStackTrace();
+			}
+		
+		return newJob;
+	}
+}
Index: DCWoRMS/trunk/build/classes/simulator/workload/generator/impl/QcgJobGenerator.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/workload/generator/impl/QcgJobGenerator.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/workload/generator/impl/QcgJobGenerator.java	(revision 539)
@@ -58,5 +58,5 @@
 import org.xml.sax.InputSource;
 
-import simulator.WormsConstants;
+import simulator.DCWormsConstants;
 import simulator.utils.GSSimXML;
 import simulator.utils.XsltTransformations;
@@ -259,5 +259,5 @@
 			
 			//initially - a standard value
-			taskCountToBeGenerated = WormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB; 
+			taskCountToBeGenerated = DCWormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB; 
 			
 			try {
Index: DCWoRMS/trunk/build/classes/simulator/workload/WorkloadLoader.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/workload/WorkloadLoader.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/workload/WorkloadLoader.java	(revision 539)
@@ -2,6 +2,4 @@
 
 import org.qcg.broker.schemas.jobdesc.QcgJob;
-import gssim.schedframe.scheduling.utils.JobDescription;
-import gssim.schedframe.scheduling.utils.TaskDescription;
 
 import java.io.IOException;
@@ -24,4 +22,7 @@
 import org.exolab.castor.xml.MarshalException;
 import org.exolab.castor.xml.ValidationException;
+
+import dcworms.schedframe.scheduling.utils.JobDescription;
+import dcworms.schedframe.scheduling.utils.TaskDescription;
 
 
Index: DCWoRMS/trunk/build/classes/simulator/DCWormsConstants.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/DCWormsConstants.java	(revision 539)
+++ DCWoRMS/trunk/build/classes/simulator/DCWormsConstants.java	(revision 539)
@@ -0,0 +1,102 @@
+package simulator;
+
+import eduni.simjava.Sim_stat;
+
+public class DCWormsConstants {
+
+	public static final String START_TIME="start_time";
+	
+	public static final String END_TIME = "end_time";
+	
+	public static final String RESOURCES = "resources";
+
+	
+	/**
+	 * the links have the maximal baud rate - no delays
+	 */
+	public static final double DEFAULT_BAUD_RATE = Double.MAX_VALUE;
+	
+	/**
+	 * Default name suffix of the allocation policy for every resource
+	 */
+	public static final String DEFAULT_RESOURCE_MANAGER_NAME = "ResourceManager";
+	
+	/**
+	 * The cost of processing per time unit
+	 */
+	public static final float DEFAULT_RESOURCE_PROCESSING_COST = 1f;
+	
+	/**
+	 * The default number of tasks in a single job
+	 */
+	public static final int DEFAULT_TASK_COUNT_IN_SINGLE_JOB = 1;
+
+	/**
+	 * The name of the broker interface entity (the entity that invokes proper methods on the given plugin)
+	 */
+	public static final String BrokerInterfaceEntityName = "BrokerInterfaceEntity";
+	
+	/**
+	 * The name of the output file with generated graphs
+	 */
+	public static final String GraphsFileName = "GssGraphs.sjg";
+	
+	/**
+	 * The name of the file where the resources' statistical data are to be stored
+	 */
+	public static final String resourceStatisticsOutputFileName = "Stats_Resources.txt"; 
+	
+	/**
+	 * The name of the file where the tasks' statistical data are to be stored
+	 */
+	public static final String tasksStatisitcsOutputFileName = "Stats_Tasks.txt";  
+
+	
+	public static final String MANAGEMENT_SYSTEM = "ManagementSystem";
+
+	
+/*
+ *  
+ * STATISTICAL INFORMATION VARIABLES AND METHODS 
+ * 
+ */
+	
+	/**
+	 * The utilization measure name
+	 */
+	public static final String USAGE_MEASURE_NAME = "Resource's utilization";
+	
+	/**
+	 * The waiting tasks queue length measure name
+	 */
+	public static final String TASKS_QUEUE_LENGTH_MEASURE_NAME = "Mean queue task count";
+	
+	/**
+	 * The paused tasks list length measure name
+	 */
+	public static final String PAUSED_TASKS_LIST_LENGTH_MEASURE_NAME = "Paused tasks list length";
+	
+	/**
+	 * @param queuesCount the number of queues for which the measures are to be added
+	 * @return a Sim_stat object to be used in all resources
+	 */
+	public static Sim_stat getResourcesStatisticsObject(int queuesCount) {		
+		Sim_stat stat = new Sim_stat();
+		//stat.add_measure(Sim_stat.ARRIVAL_RATE);
+		//stat.add_measure(Sim_stat.QUEUE_LENGTH);
+		//stat.add_measure(Sim_stat.RESIDENCE_TIME);
+		//stat.add_measure(Sim_stat.SERVICE_TIME);
+		stat.add_measure(Sim_stat.THROUGHPUT);
+		//stat.add_measure(Sim_stat.UTILISATION);
+		//stat.add_measure(Sim_stat.WAITING_TIME);
+		
+		stat.add_measure(USAGE_MEASURE_NAME, Sim_stat.STATE_BASED, true); //continuous
+		for (int i = 0; i < queuesCount; ++i) {
+			stat.add_measure(TASKS_QUEUE_LENGTH_MEASURE_NAME+"_"+Integer.toString(i), Sim_stat.STATE_BASED, true); //continuous
+		}
+		stat.add_measure(PAUSED_TASKS_LIST_LENGTH_MEASURE_NAME, Sim_stat.STATE_BASED, true); //continuous
+		//stat.add_measure(TASKS_AR_QUEUE_LENGTH_MEASURE_NAME, Sim_stat.STATE_BASED, true); //continuous
+		return stat;
+	}
+
+}
Index: DCWoRMS/trunk/build/classes/simulator/GenericUser.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/GenericUser.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/GenericUser.java	(revision 539)
@@ -2,8 +2,9 @@
 
 
-import gssim.schedframe.scheduling.utils.JobDescription;
-import gssim.schedframe.scheduling.utils.TaskDescription;
 
 import java.util.List;
+
+import dcworms.schedframe.scheduling.utils.JobDescription;
+import dcworms.schedframe.scheduling.utils.TaskDescription;
 
 import schedframe.scheduling.tasks.Job;
Index: DCWoRMS/trunk/build/classes/simulator/DataCenterWorkloadSimulator.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/DataCenterWorkloadSimulator.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/DataCenterWorkloadSimulator.java	(revision 539)
@@ -1,5 +1,4 @@
 package simulator;
 
-//import eduni.cloudsim.GSSIM;
 import java.io.File;
 import java.io.FileReader;
@@ -26,5 +25,5 @@
 import simulator.reader.ResourceReader;
 import simulator.stats.AccumulatedStatistics;
-import simulator.stats.implementation.GSSimStatistics;
+import simulator.stats.implementation.DCWormsStatistics;
 import simulator.utils.LogErrStream;
 import simulator.workload.WorkloadLoader;
@@ -40,5 +39,5 @@
  * {@link #main(String[])} method used to invoke the program. This class also
  * provides second possibility to start the simulator, namely one may use the
- * {@link #performSimulation(ConfigurationOptions, GSSimStatistics)} method.
+ * {@link #performSimulation(ConfigurationOptions, DCWormsStatistics)} method.
  * In this case, the input parameter, describing the simulation options, must be
  * earlier prepared. The results of the simulation can be acquired using the
@@ -98,6 +97,6 @@
 	 */
 	public static void main(String[] args) {
-		DataCenterWorkloadSimulator gssim = new DataCenterWorkloadSimulator();
-		gssim.run(args);
+		DataCenterWorkloadSimulator dcworms = new DataCenterWorkloadSimulator();
+		dcworms.run(args);
 	}
 
@@ -117,5 +116,5 @@
 				@Override
 				public String getDescription() {
-					return "WoRMS experiment file";
+					return "DCWoRMS experiment file";
 				}
 			};
@@ -198,5 +197,5 @@
 	}
 
-	private void runMultiuser(String rootDirPath, DataCenterWorkloadSimulator gssim) {
+	private void runMultiuser(String rootDirPath, DataCenterWorkloadSimulator dcworms) {
 		throw new RuntimeException("not supported yet");
 	}
@@ -269,5 +268,5 @@
 		rc.setInitList(null);
 		
-		WormsUsers wl = new WormsUsers("Users",
+		DCWormsUsers wl = new DCWormsUsers("Users",
 				rc.getScheduler().get_name(), workload);
 		
@@ -275,5 +274,5 @@
 		long stopSimulation = System.currentTimeMillis();
 
-		GSSimStatistics stats = new GSSimStatistics(simulationIdentifier,
+		DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier,
 				options, wl, statsOutputPath, rc);
 		accumulatedStatistics.add(stats);
Index: DCWoRMS/trunk/build/classes/simulator/stats/AccumulatedStatistics.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/AccumulatedStatistics.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/stats/AccumulatedStatistics.java	(revision 539)
@@ -10,5 +10,5 @@
 import java.util.List;
 
-import simulator.stats.implementation.GSSimStatistics;
+import simulator.stats.implementation.DCWormsStatistics;
 import gridsim.Accumulator;
 
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/TaskStats.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/TaskStats.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/TaskStats.java	(revision 539)
@@ -1,7 +1,8 @@
 package simulator.stats.implementation;
 
-import gssim.schedframe.scheduling.Executable;
 
 import java.util.List;
+
+import dcworms.schedframe.scheduling.Executable;
 
 import simulator.stats.implementation.out.StatsSerializer;
@@ -45,15 +46,10 @@
 
 	public String getUserDN() {
-		return this.task.getUserDn();
+		return this.task.getUserDN();
 	}
 
 	public String getResName() {
-		String resNames[] = this.task.getAllResourceName();
-		String resName = "";
-		for (int i = 0; i < resNames.length; i++) {
-			resName += resNames[i];
-			if (resNames.length > 1)
-				resName += " ";
-		}
+		String resName = this.task.getSchedulerName();
+
 		return resName;
 	}
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/DCWormsStatistics.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/DCWormsStatistics.java	(revision 539)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/DCWormsStatistics.java	(revision 539)
@@ -0,0 +1,1405 @@
+package simulator.stats.implementation;
+
+import java.awt.Color;
+import java.awt.Paint;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartRenderingInfo;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.AxisLocation;
+import org.jfree.chart.axis.DateAxis;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.encoders.ImageFormat;
+import org.jfree.chart.labels.CategoryItemLabelGenerator;
+import org.jfree.chart.labels.ItemLabelAnchor;
+import org.jfree.chart.labels.ItemLabelPosition;
+import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.CombinedDomainXYPlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.category.CategoryItemRenderer;
+import org.jfree.chart.renderer.category.GanttRenderer;
+import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.chart.title.Title;
+import org.jfree.data.gantt.TaskSeries;
+import org.jfree.data.gantt.TaskSeriesCollection;
+import org.jfree.data.time.FixedMillisecond;
+import org.jfree.data.xy.XYDataset;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+import org.jfree.ui.TextAnchor;
+import org.joda.time.DateTimeUtilsExt;
+
+import schedframe.ExecutablesList;
+import schedframe.ResourceController;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceType;
+import schedframe.resources.UserResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.extensions.Extension;
+import schedframe.resources.computing.extensions.ExtensionList;
+import schedframe.resources.computing.extensions.ExtensionType;
+import schedframe.resources.computing.profiles.energy.EnergyExtension;
+import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue;
+import schedframe.resources.computing.profiles.energy.power.PowerUsage;
+import schedframe.resources.units.PEUnit;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.ResourceHistoryItem;
+import schedframe.scheduling.Scheduler;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.tasks.Job;
+import schedframe.scheduling.tasks.JobInterface;
+import simulator.ConfigurationOptions;
+import simulator.DCWormsConstants;
+import simulator.DataCenterWorkloadSimulator;
+import simulator.GenericUser;
+import simulator.stats.GSSAccumulator;
+import simulator.stats.SimulationStatistics;
+import simulator.stats.implementation.out.AbstractStringSerializer;
+import simulator.stats.implementation.out.StringSerializer;
+import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory;
+import csiro.mit.utils.jfreechart.timetablechart.data.Timetable;
+import csiro.mit.utils.jfreechart.timetablechart.data.TimetableEventGroup;
+import csiro.mit.utils.jfreechart.timetablechart.data.TimetableEventSource;
+import csiro.mit.utils.jfreechart.timetablechart.renderer.TimetableRenderer;
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
+import eduni.simjava.Sim_stat;
+
+public class DCWormsStatistics implements SimulationStatistics {
+
+	private Log log = LogFactory.getLog(DCWormsStatistics.class);
+
+	protected static float ALPHA = 0.5f;
+	protected static int GANTT_WIDTH = 1200;
+	
+	protected static final int MILLI_SEC = 1000;
+
+	protected static final String RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt";
+	protected static final String JOBS_STATISTICS_OUTPUT_FILE_NAME = "Jobs.txt";
+
+	protected static final String SIMULATION_STATISTICS_OUTPUT_FILE_NAME = "Simulation.txt";
+	protected static final String RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt";
+	protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "EnergyUsage.txt";
+	protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt";
+
+	protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_";
+	protected static final String STATS_FILE_NAME_PREFIX = "Stats_";
+
+	protected static final String TASK_SEPARATOR = ";";
+	protected static final String JOB_SEPARATOR = ";";
+
+	protected String outputFolderName;
+
+	protected String simulationIdentifier;
+	protected ConfigurationOptions configuration;
+
+	protected GSSAccumulatorsStats accStats;
+	protected Map<String, GSSAccumulator> statsData;
+	
+	protected GenericUser users;
+	protected ResourceController resourceController;
+	protected boolean generateDiagrams = true;
+	protected AbstractStringSerializer serializer;
+	protected long startSimulationTime;
+	protected long endSimulationTime;
+	
+	//RESOURCES
+	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;
+	
+	//TASKS
+	protected int numOfdelayedTasks = 0;
+	protected int numOfNotExecutedTasks = 0;
+	protected double maxCj = 0;
+
+	protected boolean allTasksFinished;
+	protected TaskSeriesCollection ganttDiagramTaskSeriesCollection;
+	protected TaskSeriesCollection ganttDiagramWaitingTimeSeriesCollection;
+	protected HashMap<String, List<String>> task_processorsMap;
+
+	protected JobRegistry jr;
+
+	
+	public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users,
+			String outputFolderName, ResourceController resourceController) {
+		this.simulationIdentifier = simulationIdentifier;
+		this.configuration = co;
+		this.users = users;
+
+		this.outputFolderName = outputFolderName;
+
+		this.serializer = new StringSerializer();
+		this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT);
+
+		this.resourceController = resourceController;
+		this.jr = new JobRegistryImpl("");
+		init();
+	}
+
+	public void generateStatistics() {
+
+		this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis();
+		this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
+
+		long s = 0;
+		long e = 0;
+
+		log.info("gatherResourceStatistics");
+		s = System.currentTimeMillis();
+		gatherResourceStatistics();
+		e = System.currentTimeMillis();
+		log.info("time in sec: " + ((e - s) / MILLI_SEC));
+		
+		log.info("gatherTaskStatistics");
+		s = System.currentTimeMillis();
+		gatherTaskStatistics();
+		e = System.currentTimeMillis();
+		log.info("time in sec: " + ((e - s) / MILLI_SEC));
+
+		log.info("saveSimulationStatistics");
+		s = System.currentTimeMillis();
+		saveSimulationStatistics();
+		e = System.currentTimeMillis();
+		log.info("time in sec: " + ((e - s) / MILLI_SEC));
+	}
+
+
+	public String getOutputFolderName() {
+		return outputFolderName;
+	}
+
+	private void init() {
+
+		task_processorsMap = new HashMap<String, List<String>>();
+		accStats = new GSSAccumulatorsStats();
+		statsData = new HashMap<String, GSSAccumulator>();
+	}
+
+	public void saveSimulationStatistics() {
+		PrintStream simulationStatsFile = null;
+		if (configuration.createsimulationstatistics) {
+			try {
+				File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX + simulationIdentifier + "_"
+						+ SIMULATION_STATISTICS_OUTPUT_FILE_NAME);
+				simulationStatsFile = new PrintStream(new FileOutputStream(file));
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		if (simulationStatsFile != null) {
+			Object txt = accStats.serialize(this.serializer);
+			simulationStatsFile.println(txt);
+		}
+
+		if (simulationStatsFile != null) {
+			simulationStatsFile.close();
+		}
+	}
+
+	/************* RESOURCE STATISTICS SECTION **************/
+	private void gatherResourceStatistics() {
+		
+		HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>();
+		
+		for(String resourceName: resourceController.getComputingResourceLayers()){
+			List<Stats> cStats = new ArrayList<Stats>();
+			cStats.add(Stats.textLoad);
+			if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceName))
+				cStats.add(Stats.chartLoad);
+			cStats.add(Stats.textEnergy);
+			if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName))
+				cStats.add(Stats.chartEnergy);
+			cStats.add(Stats.textAirFlow);
+			if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName))
+				cStats.add(Stats.chartAirFlow);
+			type_stats.put(resourceName, cStats);
+		}		
+		
+		peGanttMap = new HashMap<String, TimetableEventSource>();
+		taskGanttMap = new HashMap<String, TimetableEventGroup>();		
+		
+		resourceLoadDiagrams = new HashMap<ResourceType, List<XYDataset>>();
+		resourcePowerUsageDiagrams = new HashMap<ResourceType, List<XYDataset>>();
+		resourceAirFlowDiagrams = new HashMap<ResourceType, List<XYDataset>>();
+		
+		ganttDiagramTimetable = new Timetable(new FixedMillisecond(
+				startSimulationTime), new FixedMillisecond(endSimulationTime));
+		
+		PrintStream resourceLoadStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME);
+			resourceLoadStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			resourceLoadStatsFile = null;
+		}
+		
+		PrintStream energyStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME);
+			energyStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			energyStatsFile = null;
+		}
+		
+		PrintStream airFlowStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX
+					+ simulationIdentifier + "_"
+					+ AIRFLOW_STATISTICS_OUTPUT_FILE_NAME);
+			airFlowStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			airFlowStatsFile = null;
+		}
+
+		basicResStats = gatherPEStats(jr.getExecutableTasks());
+		peStatsPostProcessing(basicResStats);
+		basicResLoad = calculatePELoad( basicResStats);
+
+		if (configuration.creatediagrams_gantt) {
+			createPEGanttDiagram(basicResStats);
+		}
+		
+		for(String resourceName: resourceController.getComputingResourceLayers()){
+			List<ComputingResource> resources = null;
+
+			resources = 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){
+					ResourceUsageStats resourceUsage = null;
+					ResourcePowerStats energyUsage = null;
+					ResourceAirFlowStats airFlow = null;
+					if(type_stats.get(resourceName).contains(Stats.textLoad)){
+						resourceUsage = gatherResourceLoadStats(resource, basicResStats);
+						resourceUsage.setMeanValue(calculateMeanValue(resourceUsage));
+						if (resourceLoadStatsFile != null) {
+							Object txt = resourceUsage.serialize(serializer);
+							resourceLoadStatsFile.println(txt);
+						}
+					}
+					if(type_stats.get(resourceName).contains(Stats.chartLoad)){
+						if (configuration.creatediagrams_resutilization) {
+							createResourceLoadDiagram(resourceUsage);
+						}
+					}
+					if(type_stats.get(resourceName).contains(Stats.textEnergy)){
+						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.getMeanValue());
+							}
+
+						} else if( een != null && een.getPowerProfile() != null ){
+							ComputingResource parent = resource.getParent();
+							een = (EnergyExtension )(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+							boolean top = true;
+							while(parent != null){
+								if(een != null &&  een.getPowerProfile() != null) {
+									top = false;
+									break;
+								}
+								parent = parent.getParent();
+							}
+							if(top == true){
+								accStats.meanEnergyUsage.add(energyUsage.getMeanValue());
+							}
+						}
+						if (energyStatsFile != null) {
+							Object txt = energyUsage.serialize(serializer);
+							energyStatsFile.println(txt);
+						}
+					}
+					if(type_stats.get(resourceName).contains(Stats.chartEnergy)){
+
+						if (configuration.creatediagrams_respowerusage) {
+							createResourceEnergyDiagramData(energyUsage);
+						}
+					}
+					
+					if(type_stats.get(resourceName).contains(Stats.textAirFlow)){
+						airFlow = gatherResourceAirFlowStats(resource);
+						airFlow.setMeanValue(calculateMeanValue(airFlow));
+						airFlow.setSumValue(airFlow.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.meanAirFlow.add(airFlow.meanValue);
+							}
+
+						} else if( een != null && een.getAirFlowProfile() != null ){
+							ComputingResource parent = resource.getParent();
+							een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION));
+							boolean top = true;
+							while(parent != null){
+								if(een != null &&  een.getAirFlowProfile() != null) {
+									top = false;
+									break;
+								}
+								parent = parent.getParent();
+							}
+							if(top == true){
+								accStats.meanAirFlow.add(airFlow.meanValue);
+							}
+						}
+						if (airFlowStatsFile != null) {
+							Object txt = airFlow.serialize(serializer);
+							airFlowStatsFile.println(txt);
+						}
+					}
+					if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){
+
+						if (configuration.creatediagrams_resairflow) {
+							createResourceAirFlowDiagramData(airFlow);
+						}
+					}
+				}
+			}
+		}
+		
+		saveResourceGanttDiagrams();
+		createAccumulatedResourceSimulationStatistic();
+		
+		if (airFlowStatsFile != null) {
+			airFlowStatsFile.close();
+		}
+		if (energyStatsFile != null) {
+			energyStatsFile.close();
+		}
+		if (resourceLoadStatsFile != null) {
+			resourceLoadStatsFile.close();
+		}
+	}
+
+	
+	private void peStatsPostProcessing(Map<String, List<ResStat>> basicResStats){
+		ResourceType resType = null;
+
+		for(String key: basicResStats.keySet()){
+			List<ResStat> resStats = basicResStats.get(key);
+			resType = resStats.get(0).getResType();
+			break;
+		}
+		List<ComputingResource> resources = null;
+		try {
+			resources = new ArrayList<ComputingResource>();
+			for(ComputingResource compRes: resourceController.getComputingResources() ){
+				resources.addAll(compRes.getDescendantsByType(resType));
+			}
+		} catch (Exception e) {
+			return;
+		}
+		for(ComputingResource resource: resources){
+			if(!basicResStats.containsKey(resource.getName())){
+				basicResStats.put(resource.getName(), new ArrayList<ResStat>());
+			}
+		}
+	}
+	
+	private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) {
+		
+		Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator());
+
+		for (ExecTask execTask:executables) {
+			Executable exec = (Executable) execTask;
+
+			List<ResourceHistoryItem> resHistItemList = exec.getUsedResources();
+			if(resHistItemList.size() == 0)
+				return basicResStats;
+			Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits();
+			ResourceUnit resUnit = res.get(StandardResourceUnitName.PE);
+			//ProcessingElements pes = (ProcessingElements) resUnit ;
+			if(resUnit instanceof ProcessingElements){
+				ProcessingElements pes = (ProcessingElements) resUnit;
+				for(ComputingResource pe: pes){
+					String peName = pe.getName();
+					long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC;
+					long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC;
+
+					String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId();
+					
+					ResStat resStat = new ResStat(peName, pe.getType(), startDate, endDate, uniqueTaskID);
+					
+					List<ResStat> resStats = basicResStats.get(peName);
+					if (resStats == null) {
+						resStats = new ArrayList<ResStat>();
+						resStats.add(resStat);
+						basicResStats.put(peName, resStats);
+					} else {
+						resStats.add(resStat);
+					}
+
+					List<String> peNames = task_processorsMap.get(uniqueTaskID);
+					if (peNames == null) {
+						peNames = new ArrayList<String>();
+						peNames.add(peName);
+						task_processorsMap.put(uniqueTaskID, peNames);
+					} else {
+						peNames.add(peName);
+					}
+				}
+			} else if (resUnit instanceof PEUnit){
+				PEUnit peUnit = (PEUnit) resUnit ;
+			}
+
+		}
+		return basicResStats;
+	}
+	
+	private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) {
+		ResourceUsageStats usageStats = new ResourceUsageStats(resource.getName(), resource.getType(), "resourceLoadStats");
+		int cnt = 0;
+		for(String resName: basicStats.keySet()){
+			try {
+				if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){
+					createResourceLoadData(usageStats, basicStats.get(resName));
+					cnt++;
+				}
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		for(Long key: usageStats.getHistory().keySet()){
+			Double value = usageStats.getHistory().get(key)/cnt;
+			usageStats.getHistory().put(key, value);
+		}
+
+		return usageStats;
+	}
+	
+	private Map<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) {
+
+		TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getHistory();
+		for (ResStat resStat : resStats) {
+			
+			long start_time = resStat.getStartDate();
+			long end_time = resStat.getEndDate();
+			if (end_time > start_time) {
+				Double end = ganttData.get(end_time);
+				if (end == null) {
+					ganttData.put(end_time, 0.0);
+					Long left = getLeftKey(ganttData, end_time);
+					if (left != null) {
+						Double leftValue = ganttData.get(left);
+						ganttData.put(end_time, leftValue);
+					}
+				}
+
+				Double start = ganttData.get(start_time);
+				if (start == null) {
+					ganttData.put(start_time, 0.0);
+					Long left = getLeftKey(ganttData, start_time);
+					if (left != null) {
+						Double leftValue = ganttData.get(left);
+						ganttData.put(start_time, leftValue);
+					}
+				}
+
+				SortedMap<Long, Double> sm = ganttData.subMap(start_time,
+						end_time);
+				for (Long key : sm.keySet()) {
+					Double keyVal = ganttData.get(key);
+					ganttData.put(key, keyVal + 1);
+				}
+			}
+		}
+
+		return ganttData;
+	}
+
+	private Long getLeftKey(TreeMap<Long, Double> ganttData, Long toKey) {
+
+		SortedMap<Long, Double> sm = ganttData.headMap(toKey);
+		if (sm.isEmpty()) {
+			return null;
+		}
+		return sm.lastKey();
+	}
+	
+	
+	private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) {
+		double power = 0;
+		ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getName(), resource.getType(), "resourcePowerConsumptionStats");
+		Map<Long, Double> usage = resEnergyUsage.getHistory();
+		
+		ExtensionList extensionList = resource.getExtensionList();
+		if(extensionList != null){
+			for (Extension extension : extensionList) {
+				if (extension.getType() == ExtensionType.ENERGY_EXTENSION) {
+					EnergyExtension ee = (EnergyExtension)extension;
+					if(ee.getPowerProfile() == null)
+						break;
+					List<PowerUsage> powerUsage = ee.getPowerProfile().getPowerUsageHistory();
+					if(powerUsage.size() == 0)
+						break;
+					long lastTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis();
+					long endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
+					double lastPower = 0;
+					powerUsage.add(new PowerUsage(endSimulationTime, ee.getPowerProfile().getPowerUsageHistory().get(ee.getPowerProfile().getPowerUsageHistory().size()-1).getValue()));
+					for(PowerUsage pu:powerUsage){
+						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();
+						lastTime = pu.getTimestamp();
+					}
+				}
+			}
+		}
+		//System.out.println(power);
+		return resEnergyUsage;
+	}
+	
+	
+	private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) {
+
+		ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getName(), resource.getType(), "resourceAirFlowStats");
+		Map<Long, Double> airFlow = resAirFlow.getHistory();
+		
+		ExtensionList extensionList = resource.getExtensionList();
+		if(extensionList != null){
+			for (Extension extension : extensionList) {
+				if (extension.getType() == ExtensionType.ENERGY_EXTENSION) {
+					EnergyExtension ee = (EnergyExtension)extension;
+					if(ee.getAirFlowProfile() == null)
+						break;
+					List<AirFlowValue> airFlowHistory = ee.getAirFlowProfile().getAirThroughputHistory();
+					if(airFlowHistory.size() == 0)
+						break;
+					long endSimulationTime = DateTimeUtilsExt.currentTimeMillis();
+					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());
+					}
+				}
+			}
+		}
+		return resAirFlow;
+	}
+	
+	private void createResourceLoadDiagram(ResourceUsageStats resLoadStats) {
+
+		for(Long key: resLoadStats.getHistory().keySet()){
+			Double value = resLoadStats.getHistory().get(key) * 100;
+			resLoadStats.getHistory().put(key, value);
+		}
+
+		XYDataset dataset = createResourceChartDataSet(resLoadStats,
+				startSimulationTime, endSimulationTime);
+
+		List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resLoadStats.getResourceType());
+		if(loadDiagram == null){
+			loadDiagram = new ArrayList<XYDataset>();
+			loadDiagram.add(dataset);
+			resourceLoadDiagrams.put(resLoadStats.getResourceType(), loadDiagram);
+		} else {
+			loadDiagram.add(dataset);
+		}
+	}
+	
+	private void createResourceEnergyDiagramData(ResourceDynamicStats powerConsumptionStats) {
+
+		XYDataset dataset = createResourceChartDataSet(powerConsumptionStats,
+				startSimulationTime, endSimulationTime);
+		
+		List<XYDataset> energyDiagramData = resourcePowerUsageDiagrams.get(powerConsumptionStats.getResourceType());
+		if(energyDiagramData == null){
+			energyDiagramData = new ArrayList<XYDataset>();
+			energyDiagramData.add(dataset);
+			resourcePowerUsageDiagrams.put(powerConsumptionStats.getResourceType(), energyDiagramData);
+		} else {
+			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(dynamicStats.getResourceName(), false, true);
+		//data.add(start, 0);
+		for (Long key : chartData.keySet()) {
+			Double val = chartData.get(key);
+			data.add(key, val);
+		}
+		data.add(end, 0);
+		dataset.addSeries(data);
+		return dataset;
+	}
+
+	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() {
+
+		if (!generateDiagrams)
+			return false;
+
+		String fileName = new File(outputFolderName, DIAGRAMS_FILE_NAME_PREFIX
+				+ simulationIdentifier + "_").getAbsolutePath();
+
+		String chartName = "Gantt diagram for "
+				+ DataCenterWorkloadSimulator.SIMULATOR_NAME;
+		String simulationTime = "Simulation time";
+		Title subtitle = new TextTitle("created for \"" + simulationIdentifier
+				+ "\" at " + Calendar.getInstance().getTime().toString());
+
+		JFreeChart peDiagram = null;
+		if (configuration.creatediagrams_gantt) {
+			peDiagram = getPEGanttDiagram(chartName, subtitle,
+					simulationTime);
+			if (!saveCategoryChart(peDiagram, fileName + "Gantt",
+					"{0}"))
+				return false;
+		}
+
+		JFreeChart resourceLoadDiagram = null;
+		if (configuration.creatediagrams_resutilization) {
+			String axisName = "UTILIZATION [%]";
+			for(ResourceType resType: resourceLoadDiagrams.keySet()){
+				resourceLoadDiagram = getResourceDynamicDiagram(resourceLoadDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
+				if (!saveXYPlotChart(resourceLoadDiagram, fileName + "Resources Load - "+resType))
+					return false;
+			}
+		}
+		
+		JFreeChart resourceEnergyDiagram = null;
+		if (configuration.creatediagrams_respowerusage) {
+			String axisName = "POWER [W]";
+			for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){
+				resourceEnergyDiagram = getResourceDynamicDiagram(resourcePowerUsageDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
+				if (!saveXYPlotChart(resourceEnergyDiagram, fileName + "Energy - "+resType))
+					return false;
+			}
+		}
+		
+		JFreeChart resourceAirFlowDiagram = null;
+		if (configuration.creatediagrams_resairflow) {
+			String axisName = "AIR FLOW [m^3/min]";
+			for(ResourceType resType: resourceAirFlowDiagrams.keySet()){
+				resourceAirFlowDiagram = getResourceDynamicDiagram(resourceAirFlowDiagrams.get(resType), simulationTime, chartName,
+						subtitle, axisName);
+				if (!saveXYPlotChart(resourceAirFlowDiagram, fileName + "AirThroughput - "+resType))
+					return false;
+			}
+		}
+		return true;
+	}
+	
+	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,
+				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;
+		boolean legend = true;
+		CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot();
+		DateAxis xAxis = new DateAxis(simulationTime);
+		JFreeChart chart = null;
+
+		for (XYDataset dataset : diagramData) {
+			JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "",
+				null, dataset, PlotOrientation.VERTICAL, legend, tooltip, urls);
+			XYPlot tPlot = tChart.getXYPlot();
+			NumberAxis yAxis = new NumberAxis(axisName);
+			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);
+		chart = new JFreeChart(chartName, cPlot);
+		chart.addSubtitle(subtitle);
+		return chart;
+	}
+	
+	private boolean saveXYPlotChart(JFreeChart c, String fileName) {
+		c.setNotify(false);
+		c.setAntiAlias(true);
+		c.setTextAntiAlias(true);
+		c.setBorderVisible(false);
+
+		int height = 900;
+
+		CombinedDomainXYPlot cPlot = (CombinedDomainXYPlot) c.getPlot();
+		int nPlots = cPlot.getSubplots().size();
+
+		if (nPlots > 3) {
+			height = nPlots * 300;
+		}
+		int width = GANTT_WIDTH;
+
+		if (configuration.creatediagrams_resources_scale != -1)
+			width = (int) ((endSimulationTime - startSimulationTime) * configuration.creatediagrams_resources_scale);
+		ChartRenderingInfo info = new ChartRenderingInfo();
+		File f = new File(fileName + "." + ImageFormat.PNG);
+		final String dcwormsSubtitle = "Created by "
+				+ DataCenterWorkloadSimulator.SIMULATOR_NAME
+				+ " http://www.gssim.org/";
+		c.addSubtitle(new TextTitle(dcwormsSubtitle));
+		boolean encodeAlpha = false;
+		int compression = 9;// values 0-9
+		try {
+			ChartUtilities.saveChartAsPNG(f, c, width, height, info,
+					encodeAlpha, compression);
+		} catch (IOException e) {
+			e.printStackTrace();
+			return false;
+		}
+		return true;
+	}
+	
+	private void createPEGanttDiagram(Map<String,List<ResStat>> basicResStats) {
+		for(String peName: basicResStats.keySet()){
+			TimetableEventSource pe = new TimetableEventSource(peName);
+			ganttDiagramTimetable.addEventSource(pe);
+			peGanttMap.put(peName, pe);
+			for(ResStat resStat: basicResStats.get(peName)){
+
+				pe = peGanttMap.get(resStat.getPeName());
+				if(pe == null){
+					//pe = new TimetableEventSource(resStat.getPeName());
+				//	ganttDiagramPeTimetable.addEventSource(pe);
+				//	peGanttMap.put(resStat.getPeName(), pe);
+				}
+				TimetableEventGroup task = taskGanttMap.get(resStat.getTaskID());
+				long startDate = resStat.getStartDate();
+				long endDate = resStat.getEndDate();
+				if (task == null) {
+					task = new TimetableEventGroup(resStat.getTaskID());
+					taskGanttMap.put(resStat.getTaskID(), task);
+					ganttDiagramTimetable.addEventGroup(task);
+				}
+				ganttDiagramTimetable.addEvent(pe, task,
+						new FixedMillisecond(startDate), new FixedMillisecond(endDate));
+			}
+		}
+	}
+
+
+	//TO DO
+	private void createAccumulatedResourceSimulationStatistic() {
+
+		List<ComputingResource> resources = resourceController.getComputingResources();
+		for(ComputingResource compRes: resources){
+			//for(ComputingResource child :compRes.getChildren()){
+			
+				//ResourceUsageStats resourceUsage = gatherResourceLoadStats(compRes, basicResStats);
+				//double load = calculateMeanValue(resourceUsage);
+				double load = calculateResourceLoad(compRes, basicResLoad);
+				accStats.meanTotalLoad.add(load);
+				/*ResourceEnergyStats energyUsage = gatherResourceEnergyStats(compRes);
+				energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage));
+				accStats.meanEnergyUsage.add(energyUsage.meanUsage);*/
+			//}	
+		}
+	}
+
+	private Map<String, Double> calculatePELoad(Map<String, List<ResStat>> basicResStats){
+		Map<String, Double> peLoad = new HashMap<String, Double>();
+		for(String resName: basicResStats.keySet()){
+			List<ResStat> resStats = basicResStats.get(resName);
+			double sum = 0;
+			for(ResStat resStat:resStats){
+				sum += (resStat.endDate - resStat.startDate);
+			}
+			double load = sum / (endSimulationTime - startSimulationTime);
+			peLoad.put(resName, load);
+		}
+		return peLoad;
+	}
+	
+	private  Double calculateResourceLoad(ComputingResource resource, Map<String, Double> peLoad ){
+		int peCnt = 0;
+		double sum = 0;
+		for(String resName: peLoad.keySet()){
+
+			try {
+				if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){
+					Double load = peLoad.get(resName);
+					sum += load;
+					peCnt++;
+				}
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		
+		return sum/peCnt;
+	}
+
+	
+	private double calculateMeanValue(ResourceDynamicStats resDynamicStats ){
+		double meanValue = 0;
+		long time = 0;
+		double value = 0;
+		
+		Map<Long, Double> history = resDynamicStats.getHistory();
+		for (Long key : history.keySet()) {
+			
+			if (time != 0) {
+				meanValue += (value * (key - time)) / (endSimulationTime - startSimulationTime);
+				time = key;
+			} else {
+				time = key;
+			}
+			value = history.get(key);
+		}
+		return meanValue;
+	}
+	
+	
+
+	
+	
+	
+	
+
+
+	/************* TASK STATISTICS SECTION **************/
+	public void gatherTaskStatistics() {
+
+		List<JobInterface<?>> jobs = users.getAllReceivedJobs();
+		Collections.sort(jobs, new JobIdComparator());
+
+		ganttDiagramTaskSeriesCollection = new TaskSeriesCollection();
+		ganttDiagramWaitingTimeSeriesCollection = new TaskSeriesCollection();
+
+		PrintStream taskStatsFile = null;
+		try {
+			File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX + simulationIdentifier + "_"
+					+ RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME);
+			taskStatsFile = new PrintStream(new FileOutputStream(file));
+		} catch (IOException e) {
+			taskStatsFile = null;
+		}
+
+		PrintStream jobStatsFile = null;
+		if (configuration.createjobsstatistics) {
+			try {
+				File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX + simulationIdentifier + "_"
+						+ JOBS_STATISTICS_OUTPUT_FILE_NAME);
+				jobStatsFile = new PrintStream(new FileOutputStream(file));
+			} catch (IOException e) {
+				jobStatsFile = null;
+			}
+		}
+
+		for (int i = 0; i < jobs.size(); i++) {
+			Job job = (Job) jobs.get(i);
+
+			List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId());
+			List<TaskStats> taskStatsList = new ArrayList<TaskStats>();
+
+			this.serializer.setFieldSeparator(TASK_SEPARATOR);
+
+			for (int j = 0; j < execList.size(); j++) {
+
+				Executable task = (Executable) execList.get(j);
+
+				TaskStats taskStats = createTaskStats(task);
+				if (taskStats != null && taskStatsFile != null) {
+					Object txt = taskStats.serialize(serializer);
+					taskStatsFile.println(txt);
+				}
+				if (taskStats != null && taskStats.getExecFinishDate() != -1) {
+					if (configuration.createsimulationstatistics) {
+						createAccumulatedTaskSimulationStatistic(taskStats);
+					}
+					allTasksFinished &= task.isFinished();
+					if (generateDiagrams) {
+						if (configuration.creatediagrams_tasks)
+							createTaskDiagramData(task);
+						if (configuration.creatediagrams_taskswaitingtime)
+							createTaskWaitingTimeDiagramData(task);
+					}
+					taskStatsList.add(taskStats);
+				}
+			}
+			if (configuration.createjobsstatistics && taskStatsList.size() > 0) {
+
+				this.serializer.setFieldSeparator(JOB_SEPARATOR);
+				JobStats jobStats = createJobStats(taskStatsList);
+				if (jobStatsFile != null) {
+					Object txt = jobStats.serialize(serializer);
+					jobStatsFile.println(txt);
+				}
+			}
+		}
+
+		if (configuration.createsimulationstatistics) {
+			accStats.makespan.add(maxCj);
+			accStats.delayedTasks.add(numOfdelayedTasks);
+			accStats.failedRequests.add(users.getAllSentTasks().size() - users.getFinishedTasksCount());
+			if(resourceController.getScheduler().getType().getName().equals("GS")){
+				for(Scheduler sched: resourceController.getScheduler().getChildren()){
+					accStats.meanQueueLength.add(getSchedulerQueueStats(sched));
+				}
+			}
+			else {
+				accStats.meanQueueLength.add(getSchedulerQueueStats(resourceController.getScheduler()));
+			}
+		}
+
+		saveTaskGanttDiagrams();
+
+		if (taskStatsFile != null) {
+			taskStatsFile.close();
+		}
+		if (jobStatsFile != null) {
+			jobStatsFile.close();
+		}
+	}
+
+	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);
+		String uniqueTaskID = taskStats.getJobID() + "_" + taskStats.getTaskID();
+		taskStats.setProcessorsName(task_processorsMap.get(uniqueTaskID));
+		return taskStats;
+	}
+
+	private JobStats createJobStats(List<TaskStats> tasksStats) {
+
+		String jobID = ((TaskStats) tasksStats.get(0)).getJobID();
+		JobStats jobStats = new JobStats(jobID);
+		double maxCj = 0;
+
+		for (int i = 0; i < tasksStats.size(); i++) {
+
+			TaskStats task = (TaskStats) tasksStats.get(i);
+			jobStats.meanTaskStartTime.add(task.getStartTime());
+			jobStats.meanTaskCompletionTime.add(task.getCompletionTime());
+			maxCj = Math.max(maxCj, task.getCompletionTime());
+			jobStats.meanTaskExecutionTime.add(task.getExecutionTime());
+			jobStats.meanTaskWaitingTime.add(task.getWaitingTime());
+			jobStats.meanTaskFlowTime.add(task.getFlowTime());
+			jobStats.meanTaskGQ_WaitingTime.add(task.getGQ_WaitingTime());
+			jobStats.lateness.add(task.getLateness());
+			jobStats.tardiness.add(task.getTardiness());
+		}
+		jobStats.makespan.add(maxCj);
+
+		return jobStats;
+	}
+
+	private void createAccumulatedTaskSimulationStatistic(TaskStats taskStats) {
+		accStats.meanTaskFlowTime.add(taskStats.getFlowTime());
+		accStats.meanTaskExecutionTime.add(taskStats.getExecutionTime());
+		accStats.meanTaskCompletionTime.add(taskStats.getCompletionTime());
+		accStats.meanTaskWaitingTime.add(taskStats.getWaitingTime());
+		accStats.meanTaskStartTime.add(taskStats.getStartTime());
+
+		accStats.lateness.add(taskStats.getLateness());
+		accStats.tardiness.add(taskStats.getTardiness());
+
+		if (taskStats.getExecFinishDate() == -1) {
+			numOfNotExecutedTasks++;
+		}
+		if (taskStats.getTardiness() > 0.0) {
+			numOfdelayedTasks++;
+		}
+
+		maxCj = Math.max(maxCj, taskStats.getCompletionTime());
+	}
+
+	private void createTaskDiagramData(Executable task) {
+		String uniqueTaskID = task.getJobId() + "_" + task.getId();
+
+		String resID = task.getSchedulerName();
+
+		long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * MILLI_SEC;
+		long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * MILLI_SEC;
+
+		TaskSeries taskRes = ganttDiagramTaskSeriesCollection.getSeries(resID);
+		if (taskRes == null) {
+			taskRes = new TaskSeries(resID);
+			ganttDiagramTaskSeriesCollection.add(taskRes);
+		}
+		org.jfree.data.gantt.Task ganttTask = new org.jfree.data.gantt.Task(uniqueTaskID, new Date(execStartTime),
+				new Date(execEndTime));
+		if (!task.isFinished()) {
+			ganttTask.setPercentComplete(1.0);
+		}
+		taskRes.add(ganttTask);
+	}
+
+	private void createTaskWaitingTimeDiagramData(Executable task) {
+		String uniqueTaskID = task.getJobId() + "_" + task.getId();
+
+		String resID = task.getSchedulerName();
+
+		long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * MILLI_SEC;
+		long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * MILLI_SEC;
+
+		TaskSeries waitRes = ganttDiagramWaitingTimeSeriesCollection.getSeries(resID);
+		if (waitRes == null) {
+			waitRes = new TaskSeries(resID);
+			ganttDiagramWaitingTimeSeriesCollection.add(waitRes);
+		}
+
+		long sub = Double.valueOf(task.getSubmissionTime()).longValue() * MILLI_SEC;
+		org.jfree.data.gantt.Task wait_exec = new org.jfree.data.gantt.Task(uniqueTaskID, new Date(sub), new Date(
+				execEndTime));
+		org.jfree.data.gantt.Task exec = new org.jfree.data.gantt.Task(uniqueTaskID, new Date(execStartTime), new Date(
+				execEndTime));
+		if (!task.isFinished()) {
+			exec.setPercentComplete(1.0);
+		}
+		wait_exec.addSubtask(wait_exec);
+		wait_exec.addSubtask(exec);
+		waitRes.add(wait_exec);
+	}
+
+	private boolean saveTaskGanttDiagrams() {
+
+		JFreeChart taskDiagram = null;
+		JFreeChart waitingTimeDiagram = null;
+
+		if (!generateDiagrams)
+			return false;
+
+		String fileName = new File(outputFolderName, DIAGRAMS_FILE_NAME_PREFIX + simulationIdentifier + "_")
+				.getAbsolutePath();
+
+		String chartName = "Gantt diagram for " + DataCenterWorkloadSimulator.SIMULATOR_NAME;
+		String simulationTime = "Simulation time";
+		Title subtitle = new TextTitle("created for \"" + simulationIdentifier + "\" at "
+				+ Calendar.getInstance().getTime().toString());
+
+		if (configuration.creatediagrams_tasks) {
+			taskDiagram = getTaskDiagram(chartName, subtitle, simulationTime);
+			if (!saveCategoryChart(taskDiagram, fileName + "Tasks", null /* "{0}" */))
+				return false;
+		}
+
+		if (configuration.creatediagrams_taskswaitingtime) {
+			waitingTimeDiagram = getWaitingTimeDiagram(chartName, subtitle, simulationTime);
+			if (!saveCategoryChart(waitingTimeDiagram, fileName + "Waiting_Time", null /* "Task {1} at {0}" */))
+				return false;
+		}
+
+		return true;
+	}
+
+	private JFreeChart getTaskDiagram(String chartName, Title subtitle, String simulationTime) {
+		String tasks = "Tasks";
+		boolean urls = false;
+		boolean tooltip = true;
+		boolean legend = true;
+		JFreeChart chart = ChartFactory.createGanttChart(chartName, tasks, simulationTime,
+				ganttDiagramTaskSeriesCollection, legend, tooltip, urls);
+		chart.addSubtitle(subtitle);
+		GanttRenderer re = (GanttRenderer) chart.getCategoryPlot().getRenderer();
+		re.setCompletePaint(Color.black);
+		return chart;
+	}
+
+	private JFreeChart getWaitingTimeDiagram(String chartName, Title subtitle, String simulationTime) {
+		String tasks = "Tasks";
+		boolean urls = false;
+		boolean tooltip = true;
+		boolean legend = true;
+		JFreeChart chart = ChartFactory.createGanttChart(chartName, tasks, simulationTime,
+				ganttDiagramWaitingTimeSeriesCollection, legend, tooltip, urls);
+		chart.addSubtitle(subtitle);
+		chart.getPlot().setForegroundAlpha(ALPHA);
+		GanttRenderer re = (GanttRenderer) chart.getCategoryPlot().getRenderer();
+		re.setCompletePaint(Color.black);
+		return chart;
+	}
+
+	private boolean saveCategoryChart(JFreeChart c, String fileName, String labelFormat) {
+		c.setNotify(false);
+		c.setAntiAlias(true);
+		c.setTextAntiAlias(true);
+		c.setBorderVisible(false);
+
+		CategoryPlot categoryplot = (CategoryPlot) c.getPlot();
+		categoryplot.setDomainGridlinesVisible(true);
+
+		if (labelFormat != null) {
+			CategoryItemRenderer rend = categoryplot.getRenderer();
+			rend.setBaseItemLabelsVisible(true);
+			ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER);
+			rend.setBasePositiveItemLabelPosition(position);
+			NumberFormat nf = NumberFormat.getInstance();
+			CategoryItemLabelGenerator gen = new StandardCategoryItemLabelGenerator(labelFormat, nf);
+			rend.setBaseItemLabelGenerator(gen);
+		}
+
+		int rows = c.getCategoryPlot().getDataset().getColumnKeys().size();
+
+		int height = 900;
+		if (rows > 45) {
+			height = rows * 20;
+		}
+		int width = calculateChartWidth(c);
+		CategoryItemRenderer rend = c.getCategoryPlot().getRenderer();
+
+		for (int i = 0; i < c.getCategoryPlot().getDataset().getRowKeys().size(); i++) {
+			Paint collor = c.getCategoryPlot().getDrawingSupplier().getNextPaint();
+			rend.setSeriesOutlinePaint(i, collor);
+			rend.setSeriesPaint(i, collor);
+		}
+
+		ChartRenderingInfo info = new ChartRenderingInfo();
+		// info.setEntityCollection(null);
+		File f = new File(fileName + "." + ImageFormat.PNG);
+		final String dcwormsSubtitle = "Created by " + DataCenterWorkloadSimulator.SIMULATOR_NAME + " http://www.gssim.org/";
+		c.addSubtitle(new TextTitle(dcwormsSubtitle));
+		boolean encodeAlpha = false;
+		int compression = 9;
+		try {
+			ChartUtilities.saveChartAsPNG(f, c, width, height, info, encodeAlpha, compression);
+
+		} catch (IOException e) {
+			e.printStackTrace();
+			return false;
+		} catch (Exception e) {
+			if (log.isErrorEnabled())
+				log.error("The png file (" + fileName
+						+ ")\nwill not be generated (It can be too large data size problem)", e);
+		} catch (Throwable t) {
+			log.error("The png file (" + fileName + ")\nwill not be generated (It can be too large data size problem)",
+					t);
+		}
+
+		return true;
+	}
+
+	private int calculateChartWidth(JFreeChart c) {
+
+		int ganttWidth = GANTT_WIDTH;
+		int rows = c.getCategoryPlot().getDataset().getColumnKeys().size();
+
+		if (rows > 45) {
+			int height = rows * 20;
+			ganttWidth = Math.max((int) (height * 1.5), GANTT_WIDTH);
+		}
+		return ganttWidth;
+	}
+
+	private static class JobIdComparator implements Comparator<JobInterface<?>> {
+
+		public int compare(JobInterface<?> o1, JobInterface<?> o2) {
+			Integer o1int;
+			Integer o2int;
+			try{
+				o1int = Integer.parseInt(o1.getId());
+				o2int = Integer.parseInt(o2.getId());
+				return o1int.compareTo(o2int);
+			} catch(NumberFormatException e){
+				return o1.getId().compareTo(o2.getId());
+			}
+		}
+	}
+	
+	private static class MapPEIdComparator implements Comparator<String> {
+
+		public int compare(String o1, String o2)  {
+			Integer o1int;
+			Integer o2int;
+
+			o1int = Integer.parseInt(o1.substring(o1.indexOf("_")+1));
+			o2int = Integer.parseInt(o2.substring(o2.indexOf("_")+1));
+			return o1int.compareTo(o2int);
+		}
+	}
+
+	public GSSAccumulator getStats(String name) {
+		return statsData.get(name);
+	}
+	
+	private void createStatsData() {
+		statsData.put(MAKESPAN, accStats.makespan);
+		statsData.put(TASK_COMPLETION_TIME, accStats.meanTaskCompletionTime);
+		statsData.put(TASK_EXECUTION_TIME, accStats.meanTaskExecutionTime);
+		statsData.put(TASK_START_TIME, accStats.meanTaskStartTime);
+		statsData.put(TASK_FLOW_TIME, accStats.meanTaskFlowTime);
+		statsData.put(TASK_WAITING_TIME, accStats.meanTaskWaitingTime);
+		statsData.put(TASK_LATENESS, accStats.lateness);
+		statsData.put(TASK_TARDINESS, accStats.tardiness);
+		statsData.put(DELAYED_TASKS, accStats.delayedTasks);
+		statsData.put(FAILED_REQUESTS, accStats.failedRequests);
+		statsData.put(RESOURCES_TOTAL_LOAD, accStats.meanTotalLoad);
+		statsData.put(RESOURCES_RESERVATION_LOAD, accStats.meanReservationLoad);
+		statsData.put(RESOURCES_RESERVATION_LOAD, accStats.meanEnergyUsage);
+		statsData.put(RESOURCES_QUEUE_LENGTH, accStats.meanQueueLength);
+	}
+
+
+	public boolean accumulatedStats() {
+		return configuration.createsimulationstatistics;
+	}
+
+}
+
+class ResStat{
+	
+	public long getStartDate() {
+		return startDate;
+	}
+	public void setStartDate(long startDate) {
+		this.startDate = startDate;
+	}
+	public long getEndDate() {
+		return endDate;
+	}
+	public void setEndDate(long endDate) {
+		this.endDate = endDate;
+	}
+	public String getTaskID() {
+		return taskID;
+	}
+	public void setTaskID(String taskID) {
+		this.taskID = taskID;
+	}
+
+	public ResStat( String peName, long startDate, long endDate, String taskID) {
+		super();
+		this.startDate = startDate;
+		this.endDate = endDate;
+		this.taskID = taskID;
+		this.peName = peName;
+	}
+	public String getPeName() {
+		return peName;
+	}
+	public void setPeName(String peName) {
+		this.peName = peName;
+	}
+	public ResStat(String peName, ResourceType resType, long startDate, long endDate, String taskID) {
+		super();
+		this.peName = peName;
+		this.resType = resType;
+		this.startDate = startDate;
+		this.endDate = endDate;
+		this.taskID = taskID;
+	}
+	String peName;
+	ResourceType resType;
+	long startDate;
+	long endDate;
+	String taskID;
+
+	public ResourceType getResType() {
+		return resType;
+	}
+	public void setResType(ResourceType resType) {
+		this.resType = resType;
+	}
+}
+
+enum Stats{
+	textLoad,
+	chartLoad,
+	textEnergy,
+	chartEnergy,
+	textAirFlow,
+	chartAirFlow;
+}
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceAirFlowStats.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceAirFlowStats.java	(revision 539)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceAirFlowStats.java	(revision 539)
@@ -0,0 +1,32 @@
+package simulator.stats.implementation;
+
+import schedframe.resources.ResourceType;
+import simulator.stats.implementation.out.StatsSerializer;
+
+public class ResourceAirFlowStats extends ResourceDynamicStats implements StatsInterface{
+
+	protected double sumValue;
+	
+	private String[] headers = { "resourceName", "timestamp", "airFlow" };
+	
+	public ResourceAirFlowStats (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/build/classes/simulator/stats/implementation/ResourceUsageStats.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceUsageStats.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceUsageStats.java	(revision 539)
@@ -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, Integer> 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, Integer>();
-		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, Integer> getUsage() {
-		return this.usage;
+		super(resourceName, resourceType, usageType);
 	}
 
@@ -62,4 +19,3 @@
 		return headers;
 	}
-
 }
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/GSSAccumulatorsStats.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/GSSAccumulatorsStats.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/GSSAccumulatorsStats.java	(revision 539)
@@ -10,4 +10,5 @@
 	public GSSAccumulator meanQueueLength;
 	public GSSAccumulator meanEnergyUsage;
+	public GSSAccumulator meanAirFlow;
 
 	public GSSAccumulator meanTaskStartTime;
@@ -29,5 +30,6 @@
 		meanReservationLoad = new GSSAccumulator();
 		meanQueueLength = new GSSAccumulator();
-		meanEnergyUsage = new GSSAccumulator();
+		meanEnergyUsage = new GSSAccumulator(); 
+		meanAirFlow = new GSSAccumulator(); 
 
 		meanTaskStartTime = new GSSAccumulator();
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourcePowerStats.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourcePowerStats.java	(revision 539)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourcePowerStats.java	(revision 539)
@@ -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/build/classes/simulator/stats/implementation/out/StringSerializer.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StringSerializer.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StringSerializer.java	(revision 539)
@@ -11,5 +11,6 @@
 import simulator.stats.implementation.GSSAccumulatorsStats;
 import simulator.stats.implementation.JobStats;
-import simulator.stats.implementation.ResourceEnergyStats;
+import simulator.stats.implementation.ResourceAirFlowStats;
+import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceStats;
 import simulator.stats.implementation.ResourceUsageStats;
@@ -258,5 +259,5 @@
 
 	public Object visit(ResourceUsageStats resourceUsageStats) {
-		Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage();
+		Map<Long, Double> resourceUsage = resourceUsageStats.getHistory();
 		
 		int mapSize = resourceUsage.size();
@@ -297,5 +298,5 @@
 			buffer.append(resourceUsageStats.getResourceName());
 			buffer.append(fieldSeparator);
-			Integer value = resourceUsage.get(timestamp);
+			Double value = resourceUsage.get(timestamp);
 			buffer.append(timestamp);
 			buffer.append(fieldSeparator);
@@ -306,12 +307,13 @@
 
 		}
-
-		buffer.append("mean: " + resourceUsageStats.getMeanUsage());
-		buffer.append(System.getProperty("line.separator"));
-		return buffer.toString();
-	}
-
-	public Object visit(ResourceEnergyStats resourceEnergyStats) {
-		Map<Long, Double> resourceEnergy = resourceEnergyStats.getEnergy();
+		if(resourceUsage.size() > 0){
+			buffer.append("mean: " + resourceUsageStats.getMeanValue());
+			buffer.append(System.getProperty("line.separator"));	
+		}
+		return buffer.toString();
+	}
+
+	public Object visit(ResourcePowerStats resourceEnergyStats) {
+		Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory();
 		
 		int mapSize = resourceEnergy.size();
@@ -361,6 +363,67 @@
 
 		}
-		buffer.append("mean: "+resourceEnergyStats.getMeanUsage() + " sum: " +resourceEnergyStats.getSumUsage());
-		buffer.append(System.getProperty("line.separator"));
+		
+		if(resourceEnergy.size() > 0) {
+			buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue());
+			buffer.append(System.getProperty("line.separator"));	
+		}
+
+		return buffer.toString();
+	}
+
+	public Object visit(ResourceAirFlowStats resourceAirFlowStats) {
+		Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory();
+		
+		int mapSize = resourceAirFlow.size();
+		/*
+		 * FIXME:
+		 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 
+		 * max 30 signs - this gives max 71582788 lines. If resourceUsage map
+		 * contains more elements then we have a problem, because content of
+		 * resourceUsage map will not fit in the buffer.
+		 * This will need further attention in the future.
+		 */
+		int maxSize = (Integer.MAX_VALUE / 30 ) - 1;
+		if(mapSize >= maxSize){
+			log.error("Resource usage data is to long to fit in the buffer.");
+			return null;
+		}
+		
+		int size = 30 * resourceAirFlow.size();
+		
+		StringBuffer buffer = null;
+
+		if(printedHeaders.add(resourceAirFlowStats.getUsageType())) {
+			buffer = new StringBuffer(size + 42);
+			String[] headers = resourceAirFlowStats.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(size);
+		}
+		
+		
+		for (Long timestamp : resourceAirFlow.keySet()) {
+			
+			buffer.append(resourceAirFlowStats.getResourceName());
+			buffer.append(fieldSeparator);
+			Double value = resourceAirFlow.get(timestamp);
+			buffer.append(timestamp);
+			buffer.append(fieldSeparator);
+			buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT
+					.format(value));
+			buffer.append(fieldSeparator);
+			buffer.append(System.getProperty("line.separator"));
+
+		}
+		
+		if(resourceAirFlow.size() > 0) {
+			buffer.append("mean: "+resourceAirFlowStats.getMeanValue() + " sum: " +resourceAirFlowStats.getSumValue());
+			buffer.append(System.getProperty("line.separator"));	
+		}
 
 		return buffer.toString();
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StatsSerializer.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StatsSerializer.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StatsSerializer.java	(revision 539)
@@ -4,5 +4,6 @@
 import simulator.stats.implementation.GSSAccumulatorsStats;
 import simulator.stats.implementation.JobStats;
-import simulator.stats.implementation.ResourceEnergyStats;
+import simulator.stats.implementation.ResourceAirFlowStats;
+import simulator.stats.implementation.ResourcePowerStats;
 import simulator.stats.implementation.ResourceStats;
 import simulator.stats.implementation.ResourceUsageStats;
@@ -26,6 +27,7 @@
 	public Object visit(ResourceUsageStats arg);
 	
-	public Object visit(ResourceEnergyStats arg);
+	public Object visit(ResourcePowerStats arg);
 
+	public Object visit(ResourceAirFlowStats arg);
 	
 	public Object visit(GSSAccumulatorsStats arg);
Index: DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceDynamicStats.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceDynamicStats.java	(revision 539)
+++ DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceDynamicStats.java	(revision 539)
@@ -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/build/classes/simulator/utils/XsltTransformations.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/utils/XsltTransformations.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/utils/XsltTransformations.java	(revision 539)
@@ -1,6 +1,4 @@
 package simulator.utils;
 
-import gssim.schedframe.scheduling.utils.JobDescription;
-import gssim.schedframe.scheduling.utils.TaskDescription;
 
 import java.io.IOException;
@@ -20,4 +18,7 @@
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.xpath.XPathExpressionException;
+
+import dcworms.schedframe.scheduling.utils.JobDescription;
+import dcworms.schedframe.scheduling.utils.TaskDescription;
 
 /**
Index: DCWoRMS/trunk/build/classes/simulator/reader/ResourceReader.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/reader/ResourceReader.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/reader/ResourceReader.java	(revision 539)
@@ -11,7 +11,9 @@
 import java.util.Deque;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.exolab.castor.types.AnyNode;
@@ -54,4 +56,6 @@
 	private String globalSchedulingPluginName;
 	
+	private Set<String> compResLayers;
+	
 	public ResourceReader(ConfigurationOptions options) throws IOException {
 
@@ -59,4 +63,5 @@
 		globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin";
 		prepareCalendar();
+		compResLayers = new LinkedHashSet<String>();
 	}
 
@@ -64,21 +69,5 @@
 			UnknownParameter {
 
-		//File file = new File("src/test/rewolucja/schemas/example/coolemall/example4.xml");
 		File file = new File(resDescFileName);
-		//File file = new File("example/tomekp/experiment1/tomExp3.xml");
-		/*long s =System.currentTimeMillis();
-		System.out.println("start: ");
-		List<Processor> list = new ArrayList<Processor>();
-		for(int i =0;i<3000000;i++){
-			schemas.ComputingResource compResDef = new schemas.ComputingResource();
-			compResDef.setName("a"+i);
-			compResDef.setClazz("Processor");
-			CompResourceDescription resDesc = new CompResourceDescription(compResDef);
-			Processor proc = new Processor(resDesc);
-			list.add(proc);
-		}
-		long e = System.currentTimeMillis();
-		System.out.println("end: ");
-		System.out.println(e-s);*/
 		Environment env = Environment.unmarshal(new FileReader(file));
 		
@@ -97,4 +86,5 @@
 		ResourceController rc = new ResourceController(mainScheduler, computingResources);
 		rc.setInitList(toInit);
+		rc.setCompResLayers(compResLayers);
 		return rc;
 	}
@@ -177,5 +167,4 @@
 
 		List<ComputingResource> mainCompResourceList = new ArrayList<ComputingResource>();
-		
 		Deque<ComputingResourceDescription> toExamine = new ArrayDeque<ComputingResourceDescription>();
 		Deque<ComputingResource> resStructure = new ArrayDeque<ComputingResource>();
@@ -192,4 +181,5 @@
 			ComputingResource parentResource = resStructure.pop();
 			toInit.add(parentResource);
+			compResLayers.add(parentResource.getType().getName());
 			List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren();
 			if (childrenResDesc == null){
@@ -250,5 +240,5 @@
 		//TODO - refactor (remove - create scheduler on the basis of resource description)
 		Scheduler mainScheduler = null;
-		if(mainSchedulers.size() == 1 && mainSchedulers.get(0).get_name().equals("grid")){
+		if(mainSchedulers.size() == 1 /*&& mainSchedulers.get(0).get_name().equals("grid")*/){
 			mainScheduler = mainSchedulers.get(0);
 		}
@@ -261,7 +251,5 @@
 			ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>());
 			mainScheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin , execTimeEstimationPlugin,  queues, managedResources);
-			/*ManagementSystem ms = new GridBroker("grid",
-					globalSchedulingPluginName, execTimeEstimationPlugin);
-			mainScheduler = new Scheduler(ms, mainCompResourceList);*/
+
 			for(Scheduler lr: mainSchedulers){
 				mainScheduler.addChild(lr);
@@ -280,8 +268,8 @@
 		TaskQueueList queues = new TaskQueueList(1);
 		
-		if(schedulerDef.getQueue() != null && schedulerDef.getQueueCount() > 0){
-			int queueCount = schedulerDef.getQueueCount();
+		if(schedulerDef.getQueues()!= null){
+			int queueCount = schedulerDef.getQueues().getQueueCount();
 			for(int i = 0; i < queueCount; i++){
-				schemas.QueueType queueDef = schedulerDef.getQueue(i);
+				schemas.QueueType queueDef = schedulerDef.getQueues().getQueue(i);
 				TaskQueue queue = new TaskQueue(queueDef.getReservation());
 				queue.setName(queueDef.getName());
Index: DCWoRMS/trunk/build/classes/simulator/ConfigurationOptions.java
===================================================================
--- DCWoRMS/trunk/build/classes/simulator/ConfigurationOptions.java	(revision 477)
+++ DCWoRMS/trunk/build/classes/simulator/ConfigurationOptions.java	(revision 539)
@@ -8,5 +8,4 @@
 import java.util.PropertyResourceBundle;
 import java.util.ResourceBundle;
-import java.util.logging.FileHandler;
 
 /**
@@ -26,10 +25,5 @@
 	 * =============================================================================================
 	 */
-	/** Grid scheduler's plugin path */
-	public static final String GRID_SCHEDULING_PLUGIN_NAME_MODIFIER = "gridschedulingpluginname";
-	/** Forecast finish time plugin path */
-	public static final String EXEC_TIME_ESTIMATION_PLUGIN_NAME_MODIFIER = "exectimeestimationpluginname";
-	/** Local allocation policy plugin path */
-	public static final String LOCAL_ALLOC_POLICY_PLUGIN_NAME_MODIFIER = "localallocpolicypluginname";
+
 	/** The path to the resource description file */
 	public static final String RESOURCE_DESC_MODIFIER = "resdesc";
@@ -58,5 +52,4 @@
 	public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER
 			+ ".inputfolder";
-	public static final String READ_SCENARIO_INPUT_TAR = READ_SCENARIO_MODIFIER+ ".tar";
 	
 	/** The name of the workload file */
@@ -64,33 +57,25 @@
 			+ ".workloadfilename";
 
-	/** Shall a detailed history be printed */
-	public static final String PRINT_HISTORY_MODIFIER = "printhistory";
-
 	/** The default name of a workload file */
 	public static final String DEFAULT_WORKLOAD_FILE_NAME = "workload.swf";
 
 	public static final String CREATE_XML_SUPPLEMENT_FILES = "createXMLSupplement";
-	
-	public static final String PROVIDER_LIST_FILE = "in/provider.list";
-	
-	/** Network topology file path */
-	public static final String NETWORK_TOPOLOGY_FILE_MODIFIER = "networktopologyfilename";
+
 	
 	public static final String CREATEDIAGRAMS = "creatediagrams";
-	public static final String CREATEDIAGRAMS_PROCESSORS = CREATEDIAGRAMS +".processors";
-	public static final String CREATEDIAGRAMS_RESERVATIONS = CREATEDIAGRAMS + ".reservations";
-	public static final String CREATEDIAGRAMS_RESOURCES = CREATEDIAGRAMS + ".resources";
-	public static final String CREATEDIAGRAMS_ENERGYUSAGE = CREATEDIAGRAMS + ".energyusage";
-	public static final String CREATEDIAGRAMS_RESOURCES_SCALE = CREATEDIAGRAMS_RESOURCES + ".scale";
+	public static final String CREATEDIAGRAMS_GANTT = CREATEDIAGRAMS +".gantt";
 	public static final String CREATEDIAGRAMS_TASKS = CREATEDIAGRAMS + ".tasks";
 	public static final String CREATEDIAGRAMS_TASKSWAITINGTIME = CREATEDIAGRAMS + ".taskswaitingtime";
+	public static final String CREATEDIAGRAMS_UTILIZATION = CREATEDIAGRAMS + ".resutilization";
+	public static final String CREATEDIAGRAMS_ENERGYUSAGE = CREATEDIAGRAMS + ".respowerusage";
+	public static final String CREATEDIAGRAMS_AIRFLOW = CREATEDIAGRAMS + ".resairflow";
+	public static final String CREATEDIAGRAMS_RESOURCES_SCALE = CREATEDIAGRAMS_UTILIZATION + ".scale";
+
 	
 	public static final String CREATESTATISTICS = "createstatistics";
 	public static final String ACCUMULATED_RESOURCES_STATISTICS = CREATESTATISTICS + ".accumulatedresources";
 	public static final String EXTENDED_TASKS_STATISTICS = CREATESTATISTICS + ".extendedtasks";
-	public static final String GRIDLET_HISTORY_STATISTICS = CREATESTATISTICS + ".gridlethistory";
 	public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs";
 	public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation";
-	public static final String FORMAT_STATISTICS_OUTPUT = CREATESTATISTICS + ".formatoutput";
 	
 	/**
@@ -116,29 +101,5 @@
 	/* =============================================================================================== */
 	
-	public String providerListFile = null;
-
-	/**
-	 * the full grid scheduling plugin name with package prefix, e.g.
-	 * simulator.plugin.gridscheduling.raPlugin.RAPlugin (the plugin is loaded
-	 * using {@link Class#forName(java.lang.String)} and
-	 * {@link Class#newInstance()} methods)
-	 */
-	public String gridSchedulingPluginName = null;
-
-	/**
-	 * the full forecast finish time plugin name with package prefix, e.g.
-	 * simulator.plugin.gridscheduling.raPlugin.RAPlugin (the plugin is loaded
-	 * using {@link Class#forName(java.lang.String)} and
-	 * {@link Class#newInstance()} methods)
-	 */
-	public String exectimeestimationplugin = null;
-
-	/**
-	 * the full local allocation policy plugin name with package prefix, e.g.
-	 * simulator.plugin.gridscheduling.raPlugin.RAPlugin (the plugin is loaded
-	 * using {@link Class#forName(java.lang.String)} and
-	 * {@link Class#newInstance()} methods)
-	 */
-	public String localAllocPolicyPluginName = null;
+
 
 	/**
@@ -180,8 +141,4 @@
 	public String inputWorkloadFileName = DEFAULT_WORKLOAD_FILE_NAME;
 
-	/**
-	 * a txt file name with topology description
-	 */
-	public String networkTopologyFileName = null;
 	
 	/**
@@ -199,9 +156,4 @@
 	public boolean overwriteFiles = false;
 
-	/**
-	 * true if the history files are to be generated (makes the simulation
-	 * slower)
-	 */
-	public boolean printHistory = false;
 	
 	/**
@@ -210,21 +162,20 @@
 	public int numberOfSimulations = 1; //default value
 
-	public boolean creatediagrams_processors = true;
-	public boolean creatediagrams_reservations = true;
-	public boolean creatediagrams_resources = true;
-	public boolean creatediagrams_energyusage = true;
-	public boolean creatediagrams_tasks = true;
-	public boolean creatediagrams_taskswaitingtime = true;
-	public double     creatediagrams_resources_scale = 1;
-	
-	public boolean createaccumulatedresourcesstatistics = true;
-	public boolean createextendedtasksstatistics = true;
-	public boolean creategridlethistorystatistics = true;
+	public boolean creatediagrams_gantt = false;
+	public boolean creatediagrams_tasks = false;
+	public boolean creatediagrams_taskswaitingtime = false;
+	
+	public boolean creatediagrams_resutilization = false;
+	public boolean creatediagrams_respowerusage = false;
+	public boolean creatediagrams_resairflow = false;
+	public double  creatediagrams_resources_scale = 1;
+
 	public boolean createjobsstatistics = true;
 	public boolean createsimulationstatistics = true;
-	public boolean formatstatisticsoutput = false;
-	
-	public static final String ENV_DESC_MODIFIER = "envdesc";
-	public String envDescFileName = null;
+	
+	public String [] resForEnergyChart;
+	public String [] resForAirFlowChart;
+	public String [] resForUtilizationChart;
+	
 	/**
 	 * An empty constructor.
@@ -257,34 +208,6 @@
 			return null;
 		}
-
-		try {
-			co.gridSchedulingPluginName = bundle
-					.getString(GRID_SCHEDULING_PLUGIN_NAME_MODIFIER);
-		} catch(MissingResourceException e){
-			co.gridSchedulingPluginName = null;
-		}
-
-		try {
-			co.exectimeestimationplugin = bundle
-					.getString(EXEC_TIME_ESTIMATION_PLUGIN_NAME_MODIFIER);
-		} catch(MissingResourceException e){
-			co.exectimeestimationplugin = null;
-		}
-
-		try {
-			co.localAllocPolicyPluginName = bundle
-					.getString(LOCAL_ALLOC_POLICY_PLUGIN_NAME_MODIFIER);
-		} catch(MissingResourceException e){
-			co.localAllocPolicyPluginName = null;
-		}
-
 		
 		co.resdescFileName = bundle.getString(RESOURCE_DESC_MODIFIER);
-		
-		try {
-			co.envDescFileName = bundle.getString(ENV_DESC_MODIFIER);
-		} catch(MissingResourceException e){
-			co.envDescFileName = null;
-		}
 		
 		try {
@@ -314,12 +237,4 @@
 		}
 
-
-		try {
-			co.networkTopologyFileName = bundle
-					.getString(NETWORK_TOPOLOGY_FILE_MODIFIER);
-		} catch(MissingResourceException e){
-			co.networkTopologyFileName = null;
-		}
-		
 		if (co.createScenario == false) {
 			// read scenario
@@ -329,11 +244,4 @@
 			} catch (MissingResourceException e) {
 				co.inputFolder = null;
-			}
-			
-			try {
-				co.inputTar = getSeparatorTerminatedPath(bundle
-					.getString(READ_SCENARIO_INPUT_TAR));
-			} catch (MissingResourceException e) {
-				co.inputTar = null;
 			}
 			
@@ -357,12 +265,5 @@
 			co.createXMLSupplement = false;
 		}
-		
-		try {
-			co.printHistory = Boolean.valueOf(
-					bundle.getString(PRINT_HISTORY_MODIFIER)).booleanValue();
-		} catch(MissingResourceException e){
-			co.printHistory = false;
-		}
-		
+
 		// create diagrams
 		
@@ -372,23 +273,20 @@
 					bundle.getString(CREATEDIAGRAMS)).booleanValue();
 		} catch(MissingResourceException e){
-			createDiagrams = true;
-		}
-		try {
-			co.creatediagrams_processors = Boolean.valueOf(
-					bundle.getString(CREATEDIAGRAMS_PROCESSORS)).booleanValue() && createDiagrams;
-		} catch(MissingResourceException e){
-			co.creatediagrams_processors = createDiagrams;
-		}
-		try {
-			co.creatediagrams_reservations = Boolean.valueOf(
-					bundle.getString(CREATEDIAGRAMS_RESERVATIONS)).booleanValue() && createDiagrams;
-		} catch(MissingResourceException e){
-			co.creatediagrams_reservations = createDiagrams;
-		}
-		try {
-			co.creatediagrams_resources = Boolean.valueOf(
-					bundle.getString(CREATEDIAGRAMS_RESOURCES)).booleanValue() && createDiagrams;
-		} catch(MissingResourceException e){
-			co.creatediagrams_resources = createDiagrams;
+			createDiagrams = false;
+		}
+		try {
+			co.creatediagrams_gantt = Boolean.valueOf(
+					bundle.getString(CREATEDIAGRAMS_GANTT)).booleanValue();
+		} catch(MissingResourceException e){
+			co.creatediagrams_gantt = createDiagrams;
+		}
+
+		try {
+			co.resForUtilizationChart = bundle.getString(CREATEDIAGRAMS_UTILIZATION).split(";");
+			if(co.resForUtilizationChart.length > 0){
+				co.creatediagrams_resutilization = true;
+			}
+		} catch(MissingResourceException e){
+			co.creatediagrams_resutilization = createDiagrams;
 		}
 		try {
@@ -399,12 +297,24 @@
 		}
 		try {
-			co.creatediagrams_energyusage = Boolean.valueOf(
-					bundle.getString(CREATEDIAGRAMS_ENERGYUSAGE)).booleanValue() && createDiagrams;
-		} catch(MissingResourceException e){
-			co.creatediagrams_energyusage = createDiagrams;
-		}
+			co.resForEnergyChart = bundle.getString(CREATEDIAGRAMS_ENERGYUSAGE).split(";");
+			if(co.resForEnergyChart.length > 0){
+				co.creatediagrams_respowerusage = true;
+			}
+		} catch(MissingResourceException e){
+			co.creatediagrams_respowerusage = createDiagrams;
+		}
+		
+		try {
+			co.resForAirFlowChart = bundle.getString(CREATEDIAGRAMS_AIRFLOW).split(";");
+			if(co.resForAirFlowChart.length > 0){
+				co.creatediagrams_resairflow = true;
+			}
+		} catch(MissingResourceException e){
+			co.creatediagrams_resairflow = createDiagrams;
+		}
+		
 		try {
 			co.creatediagrams_tasks = Boolean.valueOf(
-					bundle.getString(CREATEDIAGRAMS_TASKS)).booleanValue() && createDiagrams;
+					bundle.getString(CREATEDIAGRAMS_TASKS)).booleanValue();
 		} catch(MissingResourceException e){
 			co.creatediagrams_tasks = createDiagrams;
@@ -412,9 +322,8 @@
 		try {
 			co.creatediagrams_taskswaitingtime = Boolean.valueOf(
-					bundle.getString(CREATEDIAGRAMS_TASKSWAITINGTIME)).booleanValue() && createDiagrams;
+					bundle.getString(CREATEDIAGRAMS_TASKSWAITINGTIME)).booleanValue();
 		} catch(MissingResourceException e){
 			co.creatediagrams_taskswaitingtime = createDiagrams;
 		}
-		
 		
 		try {
@@ -427,22 +336,4 @@
 
 		try {
-			co.createaccumulatedresourcesstatistics = Boolean.valueOf(
-					bundle.getString(ACCUMULATED_RESOURCES_STATISTICS)).booleanValue();
-		} catch(MissingResourceException e){
-			co.createaccumulatedresourcesstatistics = true;
-		}
-		try {
-			co.createextendedtasksstatistics = Boolean.valueOf(
-					bundle.getString(EXTENDED_TASKS_STATISTICS)).booleanValue();
-		} catch(MissingResourceException e){
-			co.createextendedtasksstatistics = true;
-		}
-		try {
-			co.creategridlethistorystatistics = Boolean.valueOf(
-					bundle.getString(GRIDLET_HISTORY_STATISTICS)).booleanValue();
-		} catch(MissingResourceException e){
-			co.creategridlethistorystatistics = true;
-		}
-		try {
 			co.createjobsstatistics = Boolean.valueOf(
 					bundle.getString(JOBS_STATISTICS)).booleanValue();
@@ -456,11 +347,5 @@
 			co.createsimulationstatistics = true;
 		}
-		try {
-			co.formatstatisticsoutput = Boolean.valueOf(
-					bundle.getString(FORMAT_STATISTICS_OUTPUT)).booleanValue();
-		} catch(MissingResourceException e){
-			co.formatstatisticsoutput = false;
-		}
-		
+
 		try {
 			co.numberOfSimulations = Integer.valueOf(bundle.getString(NUMBER_OF_SIMULATIONS)).intValue();
@@ -469,69 +354,4 @@
 		}
 		return co;
-	}
-
-	/**
-	 * Creates a new configuration object in the CREATE_SCENARIO mode.
-	 * 
-	 * @param gridSchedulingPluginName
-	 * @param forecastFinishTimePluginName
-	 * @param localAllocPolicyPluginName
-	 * @param resdescFileName
-	 * @param taskParamFileName
-	 * @param outputFolder
-	 * @param outputWorkloadFileName
-	 * @param overwriteFiles
-	 * @param printHistory
-	 */
-	public ConfigurationOptions(String gridSchedulingPluginName,
-			String exectimeestimationplugin,
-			String localAllocPolicyPluginName, String resdescFileName,
-			String taskParamFileName, String outputFolder,
-			String outputWorkloadFileName, boolean overwriteFiles,
-			boolean printHistory) {
-		super();
-		this.gridSchedulingPluginName = gridSchedulingPluginName;
-		this.exectimeestimationplugin = exectimeestimationplugin;
-		this.localAllocPolicyPluginName = localAllocPolicyPluginName;
-		this.resdescFileName = resdescFileName;
-		this.workloadDescFileName = taskParamFileName;
-		this.outputFolder = getSeparatorTerminatedPath(outputFolder);
-		this.outputWorkloadFileName = outputWorkloadFileName;
-		this.overwriteFiles = overwriteFiles;
-		this.printHistory = printHistory;
-
-		// the create mode
-		this.createScenario = true;
-	}
-
-	/**
-	 * Creates a new configuration object in the READ_SCENARIO mode.
-	 * 
-	 * @param gridSchedulingPluginName
-	 * @param forecastFinishTimePluginName
-	 * @param localAllocPolicyPluginName
-	 * @param resdescFileName
-	 * @param inputFolder
-	 * @param inputWorkloadFileName
-	 * @param overwriteFiles
-	 * @param printHistory
-	 */
-	public ConfigurationOptions(String gridSchedulingPluginName,
-			String exectimeestimationplugin,
-			String localAllocPolicyPluginName, String resdescFileName,
-			String inputFolder, String inputWorkloadFileName,
-			boolean overwriteFiles, boolean printHistory) {
-		super();
-		this.gridSchedulingPluginName = gridSchedulingPluginName;
-		this.exectimeestimationplugin = exectimeestimationplugin;
-		this.localAllocPolicyPluginName = localAllocPolicyPluginName;
-		this.resdescFileName = resdescFileName;
-		this.inputFolder = getSeparatorTerminatedPath(inputFolder);
-		this.inputWorkloadFileName = inputWorkloadFileName;
-		this.overwriteFiles = overwriteFiles;
-		this.printHistory = printHistory;
-		//FileHandler.loadDataset(new File("iris.data"), 4, ",");
-		// the read mode
-		this.createScenario = false;
 	}
 
