Index: DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java
===================================================================
--- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java	(revision 1362)
@@ -1,9 +1,11 @@
 package dcworms.schedframe.scheduling;
 
-import java.util.List;
+import java.util.LinkedList;
 
+import schedframe.scheduling.ExecutionHistoryItem;
+import schedframe.scheduling.ResourceHistoryItem;
 import schedframe.scheduling.tasks.TaskInterface;
 import schedframe.scheduling.tasks.phases.ResourceConsumption;
-import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
+import schedframe.scheduling.tasks.phases.ExecutionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
 
@@ -12,9 +14,11 @@
 	public boolean expectSpecificResource(ResourceParameterName resourceName);	
 	public Object getExpectedSpecificResource(ResourceParameterName resourceName);
-
-	public void trackResource(String resName);
-	public List<String> getVisitedResources();
 	
-	public ResourceConsumptionProfile getResourceConsumptionProfile();
+	public LinkedList<ExecutionHistoryItem> getExecHistory();
+	public LinkedList<ResourceHistoryItem> getAllocatedResources();
+	
+	public ExecutionProfile getResourceConsumptionProfile();
 	public ResourceConsumption getCurrentResourceConsumption();
+	
+    public String getSchedulerName();
 }
Index: DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
===================================================================
--- DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java	(revision 1315)
+++ DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java	(revision 1362)
@@ -5,5 +5,4 @@
 import gridsim.dcworms.DCWormsTags;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -11,5 +10,4 @@
 import java.util.Map;
 
-import org.apache.commons.lang.ArrayUtils;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeUtilsExt;
@@ -25,6 +23,6 @@
 import schedframe.resources.units.ProcessingElements;
 import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.ExecutionHistoryItem;
 import schedframe.scheduling.ResourceHistoryItem;
-import schedframe.scheduling.UsedResourcesList;
 import schedframe.scheduling.WorkloadUnitHandler;
 import schedframe.scheduling.manager.tasks.JobRegistryImpl;
@@ -33,5 +31,5 @@
 import schedframe.scheduling.tasks.Task;
 import schedframe.scheduling.tasks.phases.ResourceConsumption;
-import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile;
+import schedframe.scheduling.tasks.phases.ExecutionProfile;
 import schedframe.scheduling.tasks.requirements.ResourceParameterName;
 
@@ -53,24 +51,26 @@
 	
 	protected int estimatedDuration;
-	//TO DO remove and benefit from visitedResources
 	protected String schedName;
-	protected UsedResourcesList usedResources;
-	//TO DO consider removing
-	protected List<String> visitedResources;
 
 	protected double submissionTime;
     protected double arrivalTime;
-	protected double execStartTime ;
+	protected double execStartTime;
     protected double totalCompletionTime; 
 	protected double finishTime; 
 	
-	private ResourceConsumptionProfile resourceConsumptionProfile;
+    private boolean firstTime = true;
+	protected double execStartTimeFirst;
+	
+	protected ExecutionProfile execProfile;
+	
+	protected LinkedList<ExecutionHistoryItem> execHistory;;
+	protected LinkedList<ResourceHistoryItem> allocatedResources;
 	
 	public Executable(Task t){
 		this.task = t;
 		this.status = DCWormsTags.CREATED;
-		
-		this.usedResources = new UsedResourcesList();
-		this.visitedResources = new ArrayList<String>();
+
+		this.allocatedResources = new LinkedList<ResourceHistoryItem>();
+		this.execHistory = new LinkedList<ExecutionHistoryItem>();
 		init();
 	}
@@ -81,6 +81,6 @@
 		this.processesSetId = procesesSet.getId(); 
 		
-		this.usedResources = new UsedResourcesList();
-		this.visitedResources = new ArrayList<String>();
+		this.allocatedResources = new LinkedList<ResourceHistoryItem>();
+		this.execHistory = new LinkedList<ExecutionHistoryItem>();
 		init();
 	}
@@ -88,4 +88,5 @@
 	protected void init() {
 		double currentTime = DateTimeUtilsExt.currentTimeMillis() / 1000;
+		this.arrivalTime = currentTime;
 		this.submissionTime =  currentTime;
         this.totalCompletionTime = 0.0;
@@ -168,7 +169,7 @@
         }
 
-        if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.NEW_EXEC_PHASE) {
+        if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.FAILED) {
             throw new Exception("Executable.setStatuts() : Error - " +
-                    "Invalid integer range for Execiutable status.");
+                    "Invalid integer range for Executable status.");
         }
 
@@ -189,69 +190,36 @@
         }
 		
-		if(newStatus == DCWormsTags.SUBMITTED){
+		/*if(newStatus == DCWormsTags.SUBMITTED){
 			 arrivalTime = GridSim.clock();
-		}
-
-        if (prevStatus == DCWormsTags.INEXEC) {
-            if (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED ||
-                status == DCWormsTags.SUCCESS) {
+		}*/
+
+        if ((prevStatus == DCWormsTags.INEXEC) && (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED ||
+                status == DCWormsTags.SUCCESS)){
                 totalCompletionTime += (currentTime -  execStartTime);
+                execStartTime = execStartTimeFirst;
+        }
+
+        /*if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) {
+            totalCompletionTime += (currentTime -  execStartTime);
+        }*/
+
+        if(prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED){
+        	
+        }
+        if (status == DCWormsTags.INEXEC) {
+        	
+        	execStartTime = currentTime;
+            if (firstTime){
+            	execStartTimeFirst = currentTime;
+            	firstTime = false;
             }
         }
-
-        if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) {
-            totalCompletionTime += (currentTime -  execStartTime);
-        }
-
-        if (status == DCWormsTags.INEXEC ||
-            (prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED) ) {
-        	execStartTime = currentTime;
-        	
-    		ProcessingElements pes = (ProcessingElements) getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
-    		for (ComputingResource resource : pes) {
-
-				LinkedList<ComputingResource> toExamine = new LinkedList<ComputingResource>();
-				toExamine.push(resource);
-
-				while (!toExamine.isEmpty()) {
-					ComputingResource compResource = toExamine.pop();
-					List<ComputingResource> resources = compResource.getChildren();
-					int numberOfRes = resources.size();
-					for (int i = 0; i < numberOfRes; i++) {
-						ComputingResource resourceChild = resources.get(i);
-						trackResource(resourceChild.getFullName());
-						toExamine.addLast(resourceChild);
-					}
-				}
-
-    			
-    			trackResource(resource.getFullName());
-    			
-    			ComputingResource parent = resource.getParent();
-				List<String> visitedResource = getVisitedResources();
-				String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]);
-    			while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) {
-    				trackResource(parent.getFullName());
-    				parent = parent.getParent();
-    			}
-    		}
-        }
         
-        if(status == DCWormsTags.NEW_EXEC_PHASE){
-        	if(prevStatus == DCWormsTags.INEXEC){
-        		status = DCWormsTags.INEXEC;
-        		setCompletionPercentage(0);
-        		resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1);
-        		
-        		DateTime currentDateTime = new DateTime();
-        		
-        		if(getUsedResources().getLast().getTimeStamp().getMillis() == currentDateTime.getMillis()){
-        			return;
-        		}
-    			ResourceHistoryItem resHistItem = new ResourceHistoryItem(getUsedResources().getLast().getResourceUnits(), currentDateTime);
-    			resHistItem.setCompletionPercentage(0);
-    			addUsedResources(resHistItem);
-        	}
-        }
+        if(status == DCWormsTags.NEW_EXEC_PHASE && prevStatus == DCWormsTags.INEXEC){
+    		status = DCWormsTags.INEXEC;
+    		completionPercentage = 0;
+    		execProfile.setCurrentPhase(execProfile.getCurrentPhase() + 1);
+        }
+
 	}
 	
@@ -295,15 +263,11 @@
 	}
 
-	public void addUsedResources(ResourceHistoryItem usedResources){
-		this.usedResources.add(usedResources);
-	}
-	
-	public UsedResourcesList getUsedResources(){
-		return this.usedResources;
-	}
-	
     public void setSchedulerName(int resourceId){
         this.schedName = GridSim.getEntityName(resourceId);
     }
+    
+    public void setSchedulerName(String resourceId){
+        this.schedName = resourceId;
+    }
 
     public String getSchedulerName(){
@@ -326,13 +290,5 @@
 		task.register(jobRegistry);
 	}
-	
-	public void trackResource(String resName){
-		visitedResources.add(resName);
-	}
-	
-	public List<String> getVisitedResources(){
-		return visitedResources;
-	}
-	
+
 	public ReadableDuration getExpectedDuration() throws NoSuchFieldException {
 		return task.getExpectedDuration();
@@ -410,10 +366,10 @@
 	}*/
 	
-	public ResourceConsumptionProfile getResourceConsumptionProfile(){
-		return resourceConsumptionProfile;
+	public ExecutionProfile getResourceConsumptionProfile(){
+		return execProfile;
 	}
 
 	public ResourceConsumption getCurrentResourceConsumption(){
-		return resourceConsumptionProfile.getCurrentResourceConsumption();
+		return execProfile.getCurrentResourceConsumption();
 	}
 	
@@ -437,5 +393,5 @@
 			}
 			resourceConsumptionList.add(resConsumption);
-		}else{
+		} else {
 			boolean found = false;
 			if(resourceType != null){
@@ -473,6 +429,6 @@
 		
 		usefulWork = (usefulWork != -1) ? usefulWork : this.getLength();
-		this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList);
-		this.resourceConsumptionProfile.setUsefulWork(usefulWork);
+		this.execProfile = new ExecutionProfile(resourceConsumptionList);
+		this.execProfile.setUsefulWork(usefulWork);
 
 	}
@@ -480,5 +436,5 @@
 	private boolean loadResourceConsumptionProfile(){
 
-		PEUnit peUnit = (PEUnit)getUsedResources().getLast().getResourceUnits()
+		PEUnit peUnit = (PEUnit)getAllocatedResources().getLast().getResourceUnits()
 				.get(StandardResourceUnitName.PE);
 		if(peUnit instanceof ProcessingElements){
@@ -513,3 +469,19 @@
 		
 	}
+
+	public LinkedList<ExecutionHistoryItem> getExecHistory() {
+		return execHistory;
+	}
+
+	public void addExecHistory(ExecutionHistoryItem execHistoryItem) {
+		this.execHistory.add(execHistoryItem);
+	}
+
+	public LinkedList<ResourceHistoryItem> getAllocatedResources() {
+		return allocatedResources;
+	}
+
+	public void addAllocatedResources(ResourceHistoryItem allocatedResourcesItem) {
+		this.allocatedResources.add(allocatedResourcesItem);
+	}
 }
