Index: DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/AmdNodeEEP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/AmdNodeEEP.java	(revision 707)
+++ DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/AmdNodeEEP.java	(revision 1172)
@@ -40,4 +40,94 @@
 			e.printStackTrace();
 		}
+		/*return powerConsumption;
+		
+		double nodeIdle = 10;
+		double cpuBase = 2;
+		double c = 1.12;
+		double f;
+		double fbase;
+		double papp = 0;
+		double load = 0;
+		double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+
+			if(jobRegistry.getRunningTasks().size() > 0) {
+				ExecTask task = jobRegistry.getRunningTasks().get(0);
+				try {
+					load = task.getCpuCntRequest()/8;
+				} catch (NoSuchFieldException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				f = node.getProcessors().get(0).getPowerInterface().getFrequency();
+				fbase = node.getProcessors().get(0).getPowerInterface().getHighestPState().getFrequency();
+				switch(tta.getAppType(task)){
+				case abinit:{
+					break;
+				}
+				case c_ray:{
+					papp = 1;
+					break;
+				}
+				case fft: {
+					papp = 2;
+					break;
+				}
+				case lin_3gb: {
+					break;
+				}
+				case lin_tiny: {
+					break;
+				}
+				case tar: {
+					papp = 2.5;
+					break;
+				}
+				}
+				
+				try {
+					load = getLoad(createQuery(jobRegistry.getRunningTasks().get(0)))/100;
+				} catch (FileNotFoundException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				powerConsumption = nodeIdle  + load * cpuBase * Math.pow(c, (f-fbase)/100) + papp;
+
+			}
+			else {
+				for(Processor cpu: node.getProcessors()){
+					try{
+						//powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+					} catch (Exception e){
+						
+					}
+				}
+				try {
+					powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+				} catch (NoSuchFieldException e) {
+				}
+			}
+			
+		
+	
+		/*double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		if(jobRegistry.getRunningTasks().size() > 0) {
+			for(Processor cpu: node.getProcessors()){
+				try{
+					powerConsumption = node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()) + cpu.getPowerInterface().getPState().getPower();
+				} catch (Exception e){
+					
+				}
+			}
+		}
+		else try {
+			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+		} catch (NoSuchFieldException e) {
+		}
+		System.out.println("pca:" + powerConsumption);*/
 		return powerConsumption;
 	}
Index: DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/AtomD510NodeEEP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/AtomD510NodeEEP.java	(revision 707)
+++ DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/AtomD510NodeEEP.java	(revision 1172)
@@ -41,4 +41,95 @@
 		}
 
+		/*return powerConsumption;
+		
+		double nodeIdle = 19;
+		double cpuBase = 1;
+		double c = 1.12;
+		double f;
+		double fbase;
+		double papp = 0;
+		double load = 0;
+		
+		double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		
+		if(jobRegistry.getRunningTasks().size() > 0) {
+			ExecTask task = jobRegistry.getRunningTasks().get(0);
+			try {
+				load = task.getCpuCntRequest()/8;
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			f = node.getProcessors().get(0).getPowerInterface().getFrequency();
+			fbase = node.getProcessors().get(0).getPowerInterface().getHighestPState().getFrequency();
+			TaskToApp tta = new TaskToApp();
+			switch(tta.getAppType(task)){
+			case abinit:{
+				break;
+			}
+			case c_ray:{
+				papp = 0.05;
+				break;
+			}
+			case fft: {
+				papp = 0.1;
+				break;
+			}
+			case lin_3gb: {
+				break;
+			}
+			case lin_tiny: {
+				papp = 0.2;
+				break;
+			}
+			case tar: {
+				papp = 0.5;
+				break;
+			}
+			}
+			try {
+				load = getLoad(createQuery(jobRegistry.getRunningTasks().get(0)))/100;
+			} catch (FileNotFoundException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			powerConsumption = nodeIdle  + load * cpuBase * Math.pow(c, (f-fbase)/100) + papp;
+
+		}
+		else {
+			for(Processor cpu: node.getProcessors()){
+				try{
+					//powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+				} catch (Exception e){
+					
+				}
+			}
+			try {
+				powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+			} catch (NoSuchFieldException e) {
+			}
+		}
+		
+	
+		/*double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		if(jobRegistry.getRunningTasks().size() > 0) {
+			for(Processor cpu: node.getProcessors()){
+				try{
+					powerConsumption = powerConsumption + cpu.getPowerInterface().getPState().getPower();
+				} catch (Exception e){
+					
+				}
+			}
+		}
+		try {
+			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+		} catch (NoSuchFieldException e) {
+		}
+		System.out.println("pcd:" + powerConsumption);*/
 		return powerConsumption;
 	}
Index: DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/IntelNodeEEP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/IntelNodeEEP.java	(revision 707)
+++ DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/IntelNodeEEP.java	(revision 1172)
@@ -43,4 +43,111 @@
 
 		return powerConsumption;
+		
+		/*double nodeIdle = 11.5;
+		double cpuBase = 8;
+		double c = 1.12;
+		double f;
+		double fbase;
+		double papp = 0;
+		double load = 0;
+		
+		double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		
+		if(jobRegistry.getRunningTasks().size() > 0) {
+			ExecTask task = jobRegistry.getRunningTasks().get(0);
+			try {
+				load = task.getCpuCntRequest()/8;
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			f = node.getProcessors().get(0).getPowerInterface().getFrequency();
+			fbase = node.getProcessors().get(0).getPowerInterface().getHighestPState().getFrequency();
+			TaskToApp tta = new TaskToApp();
+			switch(tta.getAppType(task)){
+			case abinit:{
+				papp = 3.3;
+				break;
+			}
+			case c_ray:{
+				papp = 4;
+				break;
+			}
+			case fft: {
+				papp = 3.5;
+				break;
+			}
+			case lin_3gb: {
+				papp = 6;
+				break;
+			}
+			case lin_tiny: {
+				papp = 2.5;
+				break;
+			}
+			case tar: {
+				papp = 3;
+				break;
+			}
+			}
+			try {
+				load = getLoad(createQuery(jobRegistry.getRunningTasks().get(0)))/100;
+			} catch (FileNotFoundException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			powerConsumption = nodeIdle  + load * cpuBase * Math.pow(c, (f-fbase)/100) + papp;
+			try {
+				double temp = nodeIdle  + task.getCpuCntRequest()/8 * cpuBase * Math.pow(c, (f-fbase)/100) + papp;
+				try {
+					System.out.println(tta.getAppType(task).name()+":"+node.getName()+":"+task.getCpuCntRequest() +":"+powerConsumption+";"+ temp+";"+getMeasuredPower(createQuery(task)));
+				} catch (FileNotFoundException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			} catch (NoSuchFieldException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		else {
+			for(Processor cpu: node.getProcessors()){
+				try{
+					//powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+				} catch (Exception e){
+					
+				}
+			}
+			try {
+				powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+			} catch (NoSuchFieldException e) {
+			}
+		}
+		*/
+	
+		/*double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		if(jobRegistry.getRunningTasks().size() > 0) {
+			for(Processor cpu: node.getProcessors()){
+				try{
+					powerConsumption = powerConsumption + cpu.getPowerInterface().getPState().getPower();
+				} catch (Exception e){
+					
+				}
+			}
+		}
+		try {
+			powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+		} catch (NoSuchFieldException e) {
+		}
+		System.out.println("pci:" + powerConsumption);*/
+		//return powerConsumption;
 	}
 
Index: DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/RecsNodeModelEEP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/RecsNodeModelEEP.java	(revision 1172)
+++ DCWoRMS/branches/coolemall/src/test/article/recs/plugins/energy/RecsNodeModelEEP.java	(revision 1172)
@@ -0,0 +1,270 @@
+package test.article.recs.plugins.energy;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+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.manager.tasks.JobRegistry;
+import test.article.recs.utils.AppType;
+import test.article.recs.utils.TaskToApp;
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
+
+public class RecsNodeModelEEP extends RecsNodeBaseEEP{
+
+	private static String POWER_DATA_FILE_NAME = "src/test/article/recs/data/power_data.properties";
+	private static String LOAD_DATA_FILE_NAME = "src/test/article/recs/data/load.properties";
+	
+	private ResourceBundle loadBundle;
+
+	private ResourceBundle powBundle;
+	
+	private TaskToApp taskToApp = new TaskToApp();
+	
+	
+	static int HIT = 0;
+	static int MISSED = 0;
+
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			ComputingResource resource) {
+		double powerConsumption = 0;
+		ComputingNode node = (ComputingNode) resource;
+		
+		try {
+			if(jobRegistry.getRunningTasks().size() > 0) {
+				powerConsumption = powerConsumption + getMeasuredPower(createQuery(jobRegistry.getRunningTasks().get(0)));
+			}
+			else {
+				for(Processor cpu: node.getProcessors()){
+					try{
+						//powerConsumption = powerConsumption + cpu.getPowerInterface().getRecentPowerUsage().getValue();
+					} catch (Exception e){
+						
+					}
+				}
+				try {
+					powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());
+				} catch (NoSuchFieldException e) {
+				}
+			}
+		} catch (FileNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return powerConsumption;
+	}
+	
+	private String getApplicationType(ExecTask task){	
+		AppType appType = taskToApp.getAppType(task);
+		return appType.toString();
+	}
+	
+	protected String createQuery(ExecTask task) {
+		Executable exec = (Executable)task;
+		Map<ResourceUnitName, ResourceUnit> allocatedResources = exec.getUsedResources().getLast().getResourceUnits();
+		PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE);
+		
+		String query = getApplicationType(task) + "." + getNodeCategory(peUnit) + "." + getFrequency(peUnit) + "." + getCoreCnt(task);
+		return query;
+	}
+	
+	private String getNodeCategory(PEUnit peUnit){
+		
+		ProcessingElements pe = (ProcessingElements) peUnit;
+		if(pe.get(0) instanceof ComputingNode)
+			return ((ComputingNode)pe.get(0)).getCategory();
+		if(pe.get(0) instanceof Processor)
+			return ((Processor)pe.get(0)).getParent().getCategory();
+		Core core = (Core)pe.get(0);
+		return core.getParent().getParent().getCategory();
+	}
+	
+	private int getFrequency(PEUnit peUnit){
+		ProcessingElements pe = (ProcessingElements) peUnit;
+		if(pe.get(0) instanceof ComputingNode)
+			return Double.valueOf(((ComputingNode)pe.get(0)).getProcessors().get(0).getPowerInterface().getFrequency()).intValue();
+		if(pe.get(0) instanceof Processor)
+			return Double.valueOf(((Processor)pe.get(0)).getPowerInterface().getFrequency()).intValue();
+		Core core = (Core)pe.get(0);
+		Processor proc = (Processor) core.getParent();
+		double freq = proc.getPowerInterface().getFrequency();
+		return Double.valueOf(freq).intValue();
+		
+	}
+	
+	private int getCoreCnt(ExecTask task){	
+		double cpuReq;
+		try {
+			cpuReq = task.getCpuCntRequest();
+		} catch (NoSuchFieldException e) {
+				cpuReq = 1;
+		}
+		return Double.valueOf(cpuReq).intValue();
+	}
+	
+	private double getAppLoad(ExecTask task){	
+		double appLoad = taskToApp.getAppLoad(task);
+		return appLoad;
+	}
+	
+	protected double getMeasuredPowerOld(String query) throws FileNotFoundException, IOException{
+		
+		HashMap<String, List<Integer>> knownCoreCntMap = new HashMap<String, List<Integer>>();
+		Integer [] knownCoreCntI = {1, 3, 5, 7};
+		List<Integer> knonwCoreCntListI = Arrays.asList(knownCoreCntI);
+		knownCoreCntMap.put("Intel_i7", knonwCoreCntListI);
+	
+
+		Integer [] knownCoreCntA = {1, 3};
+		List<Integer> knonwCoreCntListA = Arrays.asList(knownCoreCntA);
+		knownCoreCntMap.put("Atom_D510", knonwCoreCntListA);
+		
+		Integer [] knownCoreCntAF = {1};
+		List<Integer> knonwCoreCntListAF = Arrays.asList(knownCoreCntAF);
+		knownCoreCntMap.put("AMD_Fusion", knonwCoreCntListAF);
+		
+		ResourceBundle powBundle = getPowBundle();
+		double measuredPower = 0;
+		
+		int coreCnt = Double.valueOf(query.split("\\.")[3]).intValue();
+		List<Integer> knonwCoreCntList = knownCoreCntMap.get(query.split("\\.")[1]);
+		
+		if(!knonwCoreCntList.contains(coreCnt)){
+			
+			double coreBelow = 0;
+			double coreAbove = 0;
+			
+			for(int i = 0; i < knonwCoreCntList.size(); i++){
+				if(coreCnt > knonwCoreCntList.get(i)){
+					coreBelow = knonwCoreCntList.get(i);
+					coreAbove = knonwCoreCntList.get(i+1);
+				}
+			}
+			String queryBelow = query.split("\\.")[0] + "." + query.split("\\.")[1] + "." + query.split("\\.")[2] + "." + Double.valueOf(coreBelow).intValue();
+			String queryAbove = query.split("\\.")[0] + "." + query.split("\\.")[1] + "." + query.split("\\.")[2] + "." + Double.valueOf(coreAbove).intValue();
+			System.out.println(queryBelow);
+			System.out.println(queryAbove);
+			double measuredBelow = Double.valueOf(powBundle.getString(queryBelow)).doubleValue();
+			double measuredAbove = Double.valueOf(powBundle.getString(queryAbove)).doubleValue();
+			double a = (measuredAbove - measuredBelow)/(coreAbove/8 - coreBelow/8);
+			double b = measuredAbove - a * coreAbove/8;
+			measuredPower = a * coreCnt/8 + b;
+			MISSED++;
+			System.out.println("m:" + MISSED);
+		} else {
+			HIT++;
+			System.out.println("h:" + HIT);
+			measuredPower = Double.valueOf(powBundle.getString(query)).doubleValue();
+		}
+		return measuredPower;
+	}
+	
+	protected double getMeasuredPower(String query) throws FileNotFoundException, IOException{
+		
+		HashMap<String, List<Integer>> knownCoreCntMap = new HashMap<String, List<Integer>>();
+		Integer [] knownCoreCntI = {1, 8};
+		List<Integer> knonwCoreCntListI = Arrays.asList(knownCoreCntI);
+		knownCoreCntMap.put("Intel_i7", knonwCoreCntListI);
+	
+		Integer [] knownCoreCntA = {1, 4};
+		List<Integer> knonwCoreCntListA = Arrays.asList(knownCoreCntA);
+		knownCoreCntMap.put("Atom_D510", knonwCoreCntListA);
+		
+		Integer [] knownCoreCntAF = {1, 2};
+		List<Integer> knonwCoreCntListAF = Arrays.asList(knownCoreCntAF);
+		knownCoreCntMap.put("AMD_Fusion", knonwCoreCntListAF);
+		
+		ResourceBundle powBundle = getPowBundle();
+		double measuredPower = 0;
+		
+		int coreCnt = Double.valueOf(query.split("\\.")[3]).intValue();
+		List<Integer> knonwCoreCntList = knownCoreCntMap.get(query.split("\\.")[1]);
+		
+		if(!knonwCoreCntList.contains(coreCnt)){
+			//double queryLoad = (double) coreCnt / 8;
+			double queryLoad = getLoad(query);
+			double loadBelow = 0;
+			double loadAbove = 0;
+			
+			if(query.split("\\.")[1].equals("Intel_i7")){
+				loadBelow = 1;
+				loadAbove = 8;
+			}
+			else if(query.split("\\.")[1].equals("Atom_D510")){
+				loadBelow = 1;
+				loadAbove = 4;
+			}
+			else if(query.split("\\.")[1].equals("AMD_Fusion")){
+				loadBelow = 1;
+				loadAbove = 2;
+			}
+			
+			String queryBelow = query.split("\\.")[0] + "." + query.split("\\.")[1] + "." + query.split("\\.")[2] + "." + 1;
+			String queryAbove = null;
+			if(query.split("\\.")[1].equals("Intel_i7"))
+				queryAbove = query.split("\\.")[0] + "." + query.split("\\.")[1] + "." + query.split("\\.")[2] + "." + 8;
+			else if(query.split("\\.")[1].equals("Atom_D510"))
+				queryAbove = query.split("\\.")[0] + "." + query.split("\\.")[1] + "." + query.split("\\.")[2] + "." + 4;
+			else if(query.split("\\.")[1].equals("AMD_Fusion"))
+				queryAbove = query.split("\\.")[0] + "." + query.split("\\.")[1] + "." + query.split("\\.")[2] + "." + 2;
+			
+			System.out.println(queryBelow);
+			System.out.println(queryAbove);
+			loadAbove = getLoad(queryAbove);
+			loadBelow = getLoad(queryBelow);
+			double measuredBelow = Double.valueOf(powBundle.getString(queryBelow)).doubleValue();
+			double measuredAbove = Double.valueOf(powBundle.getString(queryAbove)).doubleValue();
+			double a = (measuredAbove - measuredBelow)/(loadAbove - loadBelow);
+			double b = measuredAbove - a * loadAbove;
+			measuredPower = a * queryLoad + b;
+			MISSED++;
+			System.out.println("m:" + MISSED);
+		} else {
+			HIT++;
+			System.out.println("h:" + HIT);
+			measuredPower = Double.valueOf(powBundle.getString(query)).doubleValue();
+		}
+		return measuredPower;
+	}
+	
+	private ResourceBundle getPowBundle() throws FileNotFoundException, IOException{
+		if(powBundle == null){
+			 powBundle = new PropertyResourceBundle(new FileInputStream(POWER_DATA_FILE_NAME));
+		}
+		return powBundle;
+	}
+	
+	protected double getLoad(String query) throws FileNotFoundException, IOException{
+		ResourceBundle loadBundle = getLoadBundle();
+		return Double.valueOf(loadBundle.getString(query)).doubleValue();
+	}
+	
+	private ResourceBundle getLoadBundle() throws FileNotFoundException, IOException{
+		if(loadBundle == null){
+			loadBundle = new PropertyResourceBundle(new FileInputStream(LOAD_DATA_FILE_NAME));
+		}
+		return loadBundle;
+	}
+
+
+}
