Search in sources :

Example 6 with CpuCore

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>";
    }
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) NBTTagString(net.minecraft.nbt.NBTTagString) RunningProgram(mcjty.rftoolscontrol.logic.running.RunningProgram)

Example 7 with CpuCore

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)");
        }
    }
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore)

Example 8 with CpuCore

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()));
        }
    }
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) RunningProgram(mcjty.rftoolscontrol.logic.running.RunningProgram)

Example 9 with CpuCore

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;
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore)

Example 10 with CpuCore

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;
}
Also used : CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore)

Aggregations

CpuCore (mcjty.rftoolscontrol.logic.running.CpuCore)13 RunningProgram (mcjty.rftoolscontrol.logic.running.RunningProgram)5 NBTTagList (net.minecraft.nbt.NBTTagList)2 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)1 Parameter (mcjty.rftoolscontrol.api.parameters.Parameter)1 ParameterType (mcjty.rftoolscontrol.api.parameters.ParameterType)1 CraftingStationTileEntity (mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity)1 MultiTankTileEntity (mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity)1 NodeTileEntity (mcjty.rftoolscontrol.blocks.node.NodeTileEntity)1 WorkbenchTileEntity (mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity)1 CompiledEvent (mcjty.rftoolscontrol.logic.compiled.CompiledEvent)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 Pair (org.apache.commons.lang3.tuple.Pair)1