Index: /DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
===================================================================
--- /DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 767)
+++ /DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 822)
@@ -100,5 +100,4 @@
 
 		int tag = ev.get_tag();
-		Object obj;
 
 		switch (tag) {
@@ -130,6 +129,5 @@
 
 		case DCWormsTags.TASK_EXECUTION_FINISHED:
-			obj = ev.get_data();
-			execTask = (ExecTask) obj;
+			execTask = (ExecTask) ev.get_data();
 			if (execTask.getStatus() == DCWormsTags.INEXEC) {
 				
@@ -153,6 +151,5 @@
 			
 		case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED:
-			obj = ev.get_data();
-			execTask = (Executable) obj;
+			execTask = (Executable) ev.get_data();
 			if (pluginSupportsEvent(tag)) {
 				SchedulingEvent event = new TaskRequestedTimeExpiredEvent(execTask.getJobId(), execTask.getId());
@@ -163,6 +160,11 @@
 			break;
 			
-		case DCWormsTags.UPDATE:
+		case DCWormsTags.UPDATE_PROCESSING:
 			updateProcessingTimes(ev);
+			break;
+			
+		case DCWormsTags.PHASE_CHANGED:
+			execTask = (ExecTask) ev.get_data();
+			//updatePhases(execTask);
 			break;
 		}
@@ -216,5 +218,5 @@
 		boolean allocationStatus = getAllocationManager().allocateResources(choosenResources);
 		if(allocationStatus == false){
-			log.info("Task " + task.getJobId() + "_" + task.getId() + " requires more resources than is availiable at this moment.");
+			log.info("Task " + task.getJobId() + "_" + task.getId() + " requires more resources than is available at this moment.");
 			return;
 		}
@@ -241,4 +243,6 @@
 			e.printStackTrace();
 		}
+		
+		//updatePhases(exec);
 		scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec);
 
@@ -349,5 +353,5 @@
 			Executable exec = (Executable)task;
 			//exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration());
-			exec.setCompletionPercentage(exec.getCompletionPercentage() + (100 - exec.getCompletionPercentage())  * timeSpan/(exec.getEstimatedDuration() - new DateTime().getMillis()/1000 + exec.getExecStartTime() + timeSpan));
+			exec.setCompletionPercentage(exec.getCompletionPercentage() + (100 - exec.getCompletionPercentage()) * timeSpan/(exec.getEstimatedDuration() - new DateTime().getMillis()/1000 + exec.getExecStartTime() + timeSpan));
 			
 			UsedResourcesList usedResourcesList = exec.getUsedResources();
@@ -366,4 +370,12 @@
 				resource.handleEvent(new EnergyEvent(eventType, obj));
 			}
+			/*try {
+				for (ComputingResource resource : resourceManager.getResourcesOfType(pes.get(0).getType())) {
+					resource.handleEvent(new EnergyEvent(eventType, obj));
+				}
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}*/
 		} else {
 			ComputingResource resource = null;
@@ -418,4 +430,34 @@
 		}
 	}	
+	
+	
+	/*protected void updatePhases(ExecTask execTask) {
+		updateProcessingProgress();
+
+		if (execTask.getStatus() == DCWormsTags.INEXEC) {
+			Executable exec = (Executable)execTask;
+
+			double phaseLength = 0;
+			try{
+				phaseLength = exec.getResourceConsumptionProfile().getResourceConsumption(exec.getCurrentPhase()).getResourceConsumptionTypeChoice().getPercentage()/100;
+			} catch(Exception e){
+				ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED);
+				scheduler.sim_cancel(filter, null);
+				double t = DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000));
+				scheduler.sendInternal(t, DCWormsTags.TASK_EXECUTION_FINISHED, execTask);
+				PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
+				notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
+			}
+			if(phaseLength != 0){			
+				exec.setCurrentPhase(exec.getCurrentPhase() + 1);
+				ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.PHASE_CHANGED);
+				scheduler.sim_cancel(filter, null);
+				scheduler.sendInternal(phaseLength * exec.getEstimatedDuration(), DCWormsTags.PHASE_CHANGED, execTask);
+				PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
+				notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
+			} 
+			System.out.println("===" + exec.getJobId() + ":" + phaseLength);
+		}
+	}	*/
 
 	public double calculateTotalLoad(int size) {
