source: xssim/trunk/src/test/rewolucja/resources/physical/implementation/Processor.java @ 220

Revision 220, 2.4 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.rewolucja.resources.physical.implementation;
2
3import java.util.Properties;
4
5import schedframe.resources.units.CpuSpeed;
6import schedframe.scheduling.utils.ResourceParameterName;
7import test.rewolucja.energy.extension.EnergyExtension;
8import test.rewolucja.energy.profile.PowerInterface;
9import test.rewolucja.energy.profile.implementation.CPUPowerProfile;
10import test.rewolucja.extensions.ExtensionType;
11import test.rewolucja.resources.ResourceCharacteristics;
12import test.rewolucja.resources.description.ExecResourceDescription;
13import test.rewolucja.resources.physical.base.ComputingResource;
14import test.rewolucja.resources.properties.CpuPropertiesBuilder;
15import test.rewolucja.resources.properties.PropertiesDirector;
16
17public class Processor extends ComputingResource{
18       
19
20        public Processor (ExecResourceDescription resDesc) {
21                super(resDesc);
22                accept(resDesc.getPowerProfile());
23        }
24       
25        /*public CPU (String resourceName, ResourceCharacteristics resourceCharacteristic) {
26                super(resourceName, ResourceType.CPU, resourceCharacteristic);
27                extensionList.add(new EnergyExtension(this, "example.energy.CPUEnergyEstimationPlugin"));
28        }*/
29
30        public ComputingNode getComputingNode(){
31                return (ComputingNode)parent;
32        }
33       
34        public int getMIPS(){
35                return getSpeedUnit().getAmount();
36        }
37       
38        public int getAvailableMIPS(){
39                return getSpeedUnit().getFreeAmount();
40        }
41
42        private CpuSpeed getSpeedUnit(){
43                return (CpuSpeed) getResourceCharacteristic().getResourceUnit(ResourceParameterName.CPUSPEED);
44        }
45       
46        public CPUPowerProfile getPowerInterface(){
47                if (extensionList != null) {
48                        if(extensionList.isExtensionAvailable(ExtensionType.ENERGY_EXTENSION)){
49                                EnergyExtension ee = (EnergyExtension)extensionList.getExtension(ExtensionType.ENERGY_EXTENSION);
50                                return (CPUPowerProfile)ee.getPowerInterface();
51                        }
52                }
53                return null;
54        }
55       
56        public void initCharacteristics(ExecResourceDescription resDesc){
57                resourceCharacteristic = new ResourceCharacteristics();
58                resourceCharacteristic.addResourceUnit(new CpuSpeed(name, 1, 0));
59        }
60       
61        public Properties getProperties(){
62                PropertiesDirector propDirector = new PropertiesDirector();
63                propDirector.setPropertiesBuilder(new CpuPropertiesBuilder());
64                propDirector.constructProperties(this);
65                return propDirector.getProperties();
66        }
67
68        public void accept(PowerInterface powIntVis){
69                extensionList.add(new EnergyExtension(this, powIntVis, "example.energy.CPUEnergyEstimationPlugin"));
70                powIntVis.visit(this);
71        }
72}
73
Note: See TracBrowser for help on using the repository browser.