package schedframe.resources.computing; import schedframe.resources.StandardResourceType; import schedframe.resources.computing.description.ComputingResourceDescription; import schedframe.resources.units.CpuSpeed; import schedframe.resources.units.StandardResourceUnitName; public class Core extends ComputingResource{ public Core (ComputingResourceDescription resDesc) { super(resDesc); //PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); //accept(new EnergyExtension(pi, resDesc.getPowerProfile())); } public Processor getProcessor(){ ComputingResource compRes = parent; while(compRes != null && !compRes.getType().equals(StandardResourceType.Processor)){ compRes = compRes.getParent(); } Processor proc = null; try{ proc = (Processor)compRes; } catch(ClassCastException e) { } return proc; } public Node getNode(){ ComputingResource compRes = parent; while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ compRes = compRes.getParent(); } Node compNode = null; try{ compNode = (Node)compRes; } catch(ClassCastException e) { } return compNode; } public int getMIPS(){ int mips; try { mips = getSpeedUnit().getAmount(); } catch (NoSuchFieldException e) { mips = 1; } return mips; } public int getAvailableMIPS(){ int mips; try { mips = getSpeedUnit().getFreeAmount(); } catch (NoSuchFieldException e) { mips = 1; } return mips; } private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); } public void initCharacteristics(ComputingResourceDescription resDesc){ super.initCharacteristics(resDesc); try{ ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); } catch(Exception e){ ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, 1, 0)); } } /*private void accept(EnergyExtension e){ extensionList.add(e); e.setResource(this); }*/ }