use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.
the class ProcessorTileEntity method getStatus.
private String getStatus(int c) {
CpuCore core = cpuCores.get(c);
String db = core.isDebug() ? "[DB] " : "";
if (core.hasProgram()) {
RunningProgram program = core.getProgram();
if (program.getDelay() > 0) {
return db + "<delayed: " + program.getDelay() + ">";
} else if (program.getLock() != null) {
return db + "<locked: " + program.getLock() + ">";
} else {
return db + "<busy>";
}
} else {
return db + "<idle>";
}
}
use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.
the class ProcessorTileEntity method listStatus.
public void listStatus() {
int n = 0;
for (CpuCore core : getCpuCores()) {
log("Core: " + n + " -> " + getStatus(n));
n++;
}
log("Event queue: " + eventQueue.size());
log("Waiting items: " + waitingForItems.size());
log("Locks: " + locks.size());
if (lastException != null) {
long dt = System.currentTimeMillis() - lastExceptionTime;
log("Last: " + TextFormatting.RED + lastException);
if (dt > 60000 * 60) {
log("(" + (dt / (60000 / 60)) + "hours ago)");
} else if (dt > 60000) {
log("(" + (dt / 60000) + "min ago)");
} else if (dt > 1000) {
log("(" + (dt / 1000) + "sec ago)");
} else {
log("(" + dt + "ms ago)");
}
}
}
use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.
the class ProcessorTileEntity method runOrQueueEvent.
private void runOrQueueEvent(int cardIndex, CompiledEvent event, @Nullable String ticket, @Nullable Parameter parameter) {
if (event.isSingle() && runningEvents.contains(Pair.of(cardIndex, event.getIndex()))) {
// Already running and single
queueEvent(cardIndex, event, ticket, parameter);
return;
}
CpuCore core = findAvailableCore(cardIndex);
if (core == null) {
// No available core
queueEvent(cardIndex, event, ticket, parameter);
} else {
RunningProgram program = new RunningProgram(cardIndex);
program.startFromEvent(event);
program.setCraftTicket(ticket);
program.setLastValue(parameter);
core.startProgram(program);
if (event.isSingle()) {
runningEvents.add(Pair.of(cardIndex, event.getIndex()));
}
}
}
use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.
the class ProcessorTileEntity method readCores.
private void readCores(NBTTagCompound tagCompound) {
NBTTagList coreList = tagCompound.getTagList("cores", Constants.NBT.TAG_COMPOUND);
cpuCores.clear();
coresDirty = false;
for (int i = 0; i < coreList.tagCount(); i++) {
CpuCore core = new CpuCore();
core.readFromNBT(coreList.getCompoundTagAt(i));
cpuCores.add(core);
}
if (cpuCores.isEmpty()) {
coresDirty = true;
}
}
use of mcjty.rftoolscontrol.logic.running.CpuCore in project RFToolsControl by McJty.
the class ProcessorTileEntity method stopPrograms.
public int stopPrograms() {
int n = 0;
for (CpuCore core : getCpuCores()) {
if (core.hasProgram()) {
n++;
core.stopProgram();
}
}
locks.clear();
runningEvents.clear();
return n;
}
Aggregations