source: xssim/branches/tpiontek/src/example/energy/CPUEnergyEstimationPlugin.java @ 241

Revision 241, 1.3 KB checked in by piontek, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package example.energy;
2
3import gssim.schedframe.scheduling.ExecTaskInterface;
4
5import java.util.List;
6import java.util.Properties;
7
8import schedframe.resources.PowerState;
9import test.rewolucja.energy.EnergyEvent;
10import test.rewolucja.resources.ResourceStatus;
11import test.rewolucja.resources.physical.base.ComputingResource;
12import test.rewolucja.resources.physical.implementation.Processor;
13import test.rewolucja.scheduling.JobRegistryInterface;
14
15public class CPUEnergyEstimationPlugin extends BaseEnergyEstimationPlugin  {
16
17        @Override
18        public double estimatePowerConsumption(EnergyEvent event, JobRegistryInterface jobRegistry,
19                        ComputingResource resource) {
20                Processor cpu = (Processor)resource;
21               
22                if(resource.getPowerInterface().getPowerState() == PowerState.OFF)
23                        return 0;
24               
25                double factor = 1.3;
26               
27                if(resource.getStatus() == ResourceStatus.BUSY)
28                {
29                        List<ExecTaskInterface> tasks = jobRegistry.getRunningTasks();
30                        int type = Integer.parseInt( tasks.get(0).getJobId());
31                       
32                        switch( type % 4)
33                        {
34                                default: factor = 1.3;
35                        }
36                       
37                        return cpu.getPowerInterface().getPState().getPower() * factor;
38                }       
39                else
40                        return cpu.getPowerInterface().getPState().getPower();
41        }
42
43        public String getName() {
44                return getClass().getName();
45        }
46
47        public void init(Properties properties) {
48                // TODO Auto-generated method stub
49               
50        }
51
52}
Note: See TracBrowser for help on using the repository browser.