diff --git a/build.settings b/build.settings index 4157d9c..1ebcfcf 100644 --- a/build.settings +++ b/build.settings @@ -1 +1 @@ -toast.version=1.2.0 +toast.version=1.3.0 diff --git a/src/main/java/jaci/openrio/toast/core/command/CommandBus.java b/src/main/java/jaci/openrio/toast/core/command/CommandBus.java index 9180869..b12d416 100644 --- a/src/main/java/jaci/openrio/toast/core/command/CommandBus.java +++ b/src/main/java/jaci/openrio/toast/core/command/CommandBus.java @@ -2,6 +2,7 @@ import jaci.openrio.toast.core.ToastBootstrap; import jaci.openrio.toast.core.command.cmd.CommandGroovyScript; +import jaci.openrio.toast.core.command.cmd.CommandThreadPool; import jaci.openrio.toast.core.command.cmd.CommandUSB; import java.util.List; @@ -32,6 +33,7 @@ public static void init() { private static void registerNatives() { registerCommand(new CommandGroovyScript()); registerCommand(new CommandUSB()); + registerCommand(new CommandThreadPool()); } /** @@ -71,7 +73,7 @@ private static void setupSim() { Scanner scanner = new Scanner(System.in); Thread thread = new Thread() { public void run() { - Thread.currentThread().setName("Toast|SimulationCommands"); + Thread.currentThread().setName("Toast|Sim"); try { while (Thread.currentThread().isAlive()) { parseMessage(scanner.nextLine()); diff --git a/src/main/java/jaci/openrio/toast/core/command/cmd/CommandGroovyScript.java b/src/main/java/jaci/openrio/toast/core/command/cmd/CommandGroovyScript.java index 3557669..a793076 100644 --- a/src/main/java/jaci/openrio/toast/core/command/cmd/CommandGroovyScript.java +++ b/src/main/java/jaci/openrio/toast/core/command/cmd/CommandGroovyScript.java @@ -7,6 +7,16 @@ import jaci.openrio.toast.core.shared.GlobalBlackboard; import jaci.openrio.toast.core.thread.ToastThreadPool; +/** + * This command is used for on-the-fly Groovy Scripting. For the most part, this is useless, but it's both fun to play + * around with, useful for debugging, and freaking awesome. + * + * command_name: 'script' + * args: + * -c Execute the script in the {@link jaci.openrio.toast.core.thread.ToastThreadPool}, concurrently + * + * @author Jaci + */ public class CommandGroovyScript extends FuzzyCommand { @Override public boolean shouldInvoke(String message) { diff --git a/src/main/java/jaci/openrio/toast/core/command/cmd/CommandThreadPool.java b/src/main/java/jaci/openrio/toast/core/command/cmd/CommandThreadPool.java new file mode 100644 index 0000000..7ec3791 --- /dev/null +++ b/src/main/java/jaci/openrio/toast/core/command/cmd/CommandThreadPool.java @@ -0,0 +1,36 @@ +package jaci.openrio.toast.core.command.cmd; + +import jaci.openrio.toast.core.Toast; +import jaci.openrio.toast.core.command.AbstractCommand; +import jaci.openrio.toast.core.thread.ToastThreadPool; +import jaci.openrio.toast.lib.log.Logger; + +import java.util.concurrent.ThreadPoolExecutor; + +/** + * This command will simply echo data about the {@link jaci.openrio.toast.core.thread.ToastThreadPool} to the console. + * This is for debugging purposes + * + * command_name: 'threads' + * args: nil + * + * @author Jaci + */ +public class CommandThreadPool extends AbstractCommand { + + @Override + public String getCommandName() { + return "threads"; + } + + @Override + public void invokeCommand(int argLength, String[] args, String command) { + ThreadPoolExecutor e = (ThreadPoolExecutor) ToastThreadPool.INSTANCE.getService(); + Logger l = Toast.log(); + l.info("*Toast Thread Pool Instance Data: "); + l.info(String.format("\t Active Threads: %d, Core Threads: %d", e.getPoolSize(), e.getCorePoolSize())); + l.info(String.format("\t Active Jobs: %d, Completed Jobs: %d, Total Jobs: %d", e.getActiveCount(), e.getCompletedTaskCount(), e.getTaskCount())); + l.info(String.format("\t Shutdown? %s, Terminated? %s, Terminating? %s", e.isShutdown(), e.isTerminated(), e.isTerminating())); + l.info("*End Toast Thread Pool Data"); + } +} diff --git a/src/main/java/jaci/openrio/toast/core/command/cmd/CommandUSB.java b/src/main/java/jaci/openrio/toast/core/command/cmd/CommandUSB.java index b8263bc..ca57365 100644 --- a/src/main/java/jaci/openrio/toast/core/command/cmd/CommandUSB.java +++ b/src/main/java/jaci/openrio/toast/core/command/cmd/CommandUSB.java @@ -13,6 +13,20 @@ import java.nio.file.Files; import java.nio.file.StandardCopyOption; +/** + * This command is used for USB Mass Storage devices. This will be responsible for generating missing autorun files, + * dumping Toast Local data to a USB Drive and loading a backup from a USB drive. + * + * command_name: 'usb' + * args: + * generate Generates a toast_autorun.conf file on every invalid USB drive connected + * dump Dumps the local Toast files to a USB device. + * [drive_name] Specify a USB drive to dump to. If not set, it will dump to all drives. + * load Copy all Toast files from USB drives to the local Toast directory (reload backup) + * [drive_name] Specify a USB drive to load from. If not set, it will load from all drives. + * + * @author Jaci + */ public class CommandUSB extends AbstractCommand { @Override public String getCommandName() { diff --git a/src/main/java/jaci/openrio/toast/core/thread/ToastThreadPool.java b/src/main/java/jaci/openrio/toast/core/thread/ToastThreadPool.java index 4307362..4b7bf98 100644 --- a/src/main/java/jaci/openrio/toast/core/thread/ToastThreadPool.java +++ b/src/main/java/jaci/openrio/toast/core/thread/ToastThreadPool.java @@ -52,7 +52,7 @@ public ToastThreadPool(String name, int size) { * Initialize the Thread Pool. This is handled by Toast, do not call this yourself. */ public static void init() { - INSTANCE = new ToastThreadPool("Pool-Worker"); + INSTANCE = new ToastThreadPool("Toast|Pool"); } /**