Index: /DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
===================================================================
--- /DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 1298)
+++ /DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 1332)
@@ -164,11 +164,12 @@
 			break;
 			
-		case DCWormsTags.UPDATE_PROCESSING:
-			updateProcessingTimes(ev);
-			break;
 			
 		case DCWormsTags.TASK_EXECUTION_CHANGED:
 			execTask = (ExecTask) ev.get_data();
 			updateTaskExecution(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED);
+			break;
+			
+		case DCWormsTags.UPDATE_PROCESSING:
+			updateProcessingTimes(ev);
 			break;
 			
@@ -244,4 +245,5 @@
 		DateTime currentTime = new DateTime();
 		ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime);
+		resHistItem.setCompletionPercentage(0);
 		exec.addUsedResources(resHistItem);
 		
@@ -252,4 +254,7 @@
 			e.printStackTrace();
 		}
+		
+		PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE);
+		notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec);
 		
 		updateTaskExecution(exec, SchedulingEventType.START_TASK_EXECUTION);
@@ -265,8 +270,4 @@
 
 		log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad());
-		
-		PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE);
-		
-		notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec);
 		
 	}
@@ -314,4 +315,5 @@
 	
 	protected void updateProcessingProgress() {
+
 		double timeSpan = DoubleMath.subtract(Sim_system.clock(), lastUpdateTime);
 		if (timeSpan <= 0.0) {
@@ -324,9 +326,16 @@
 			ExecTask task = iter.next();
 			Executable exec = (Executable)task;
-			if( exec.getUsedResources().size() > 1){	 
-				exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration() * (1.0 - exec.getCompletionPercentage()/100.0)));
-			}
+
+			if(exec.getUsedResources().size() > 1){
+				//System.out.println("--- upadteProgressX: " + Sim_system.sim_clock() );
+				//System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " +  exec.getEstimatedDuration());
+				exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / (exec.getEstimatedDuration()) * (1.0 - exec.getUsedResources().get(exec.getUsedResources().size()-1).getCompletionPercentage()/100.0)));
+				//System.out.println("newProgress: " + exec.getCompletionPercentage()  );	
+			} 
 			else {
+				//System.out.println("--- upadteProgress2: " + Sim_system.sim_clock() );
+				//System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " +  exec.getEstimatedDuration());
 				exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration()));
+				//System.out.println("newProgress: " + exec.getCompletionPercentage()  );	
 			}
 		}
@@ -337,5 +346,5 @@
 			ProcessingElements pes = (ProcessingElements) peUnit;
 			for (ComputingResource resource : pes) {
-				resource.handleEvent(new EnergyEvent(eventType, obj));
+				resource.handleEvent(new EnergyEvent(eventType, obj, scheduler.getFullName()));
 				//DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj));
 			}
@@ -355,5 +364,5 @@
 				return;
 			}
-			resource.handleEvent(new EnergyEvent(eventType, obj));
+			resource.handleEvent(new EnergyEvent(eventType, obj, scheduler.getFullName()));
 		}
 	}
@@ -371,8 +380,13 @@
 				continue;
 			}
+			//System.out.println("=== upadteTIme: " + Sim_system.sim_clock() );
+			//System.out.println("execId: " + exec.getId() +  "; estimatedDuration " + exec.getEstimatedDuration());
+			//System.out.println("execId: " + exec.getId() + "; difference " + DoubleMath.subtract((lastTimeStamp + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)));
+			//System.out.println("completionPercantage: " + exec.getCompletionPercentage() + "; basic duration: " +exec.getResourceConsumptionProfile().getCurrentResourceConsumption().getDuration() +   "; phaseDuration: " +  phaseDuration);
 
 			exec.setEstimatedDuration(phaseDuration);
 			DateTime currentTime = new DateTime();
 			ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime);
+			resHistItem.setCompletionPercentage(exec.getCompletionPercentage());
 			exec.addUsedResources(resHistItem);
 			
@@ -381,12 +395,12 @@
 				scheduler.sim_cancel(filter, null);
 				scheduler.sendInternal(phaseDuration , DCWormsTags.TASK_EXECUTION_FINISHED, execTask);
-				PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
-				notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
+				//PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
+				//notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
 			} else{
 				ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_CHANGED);
 				scheduler.sim_cancel(filter, null);
 				scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask);
-				PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
-				notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
+				//PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);
+				//notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);
 			}
 		}
@@ -488,5 +502,6 @@
 	
 	public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) {
-		updateProcessingProgress();
+		//250314
+		//updateProcessingProgress();
 		if (log.isInfoEnabled())
 			log.info("Received job " + wu.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis()));
