package schedframe.resources.units; import schedframe.resources.PowerInterface; public class Processor implements Cloneable { protected int id; protected int cpuId; protected int coreId; protected String computingNodeId; protected Status status; protected Status previousStatus; protected PowerInterface powerProfile; private static int _id = 0; private static int nextId(){ _id++; return _id; } public Processor(){ this.id = nextId(); this.cpuId = this.id; this.coreId = 0; this.status = Status.FREE; this.powerProfile = null; this.computingNodeId = null; } public Processor(Processor p){ this(); this.status = p.getStatus(); this.cpuId = p.getCpuId(); this.coreId = p.getCoreId(); this.powerProfile = p.getPowerProfile(); } public Processor(int cpuId, int coreId){ this(); this.cpuId = cpuId; this.coreId = coreId; } public int getId(){ return this.id; } public PowerInterface getPowerProfile(){ return this.powerProfile; } public Status getStatus(){ return this.status; } public void setStatus(Status s){ if(s == Status.FREE && this.previousStatus == Status.RESERVED){ s = Status.RESERVED; } this.previousStatus = this.status; this.status = s; } public void reset(){ this.status = Status.FREE; } public int getCpuId(){ return this.cpuId; } public int getCoreId(){ return this.coreId; } public String getComputingNodeId(){ return this.computingNodeId; } public void setComputingNodeId(String arg){ this.computingNodeId = arg; } public void accept(PowerInterface v){ v.visit(this); this.powerProfile = v; } public Object clone(){ Processor obj = null; try { obj = (Processor) super.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } return obj; } public enum Status{ BUSY, FREE, RESERVED; } }