diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeChannel.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeChannel.java index 66c231a8b..83822587d 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeChannel.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeChannel.java @@ -1,10 +1,10 @@ package net.zscript.javareceiver.core; import net.zscript.javareceiver.execution.ActionSource; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction; +import net.zscript.javareceiver.semanticParser.SemanticAction; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; public abstract class ZcodeChannel implements ActionSource { @@ -25,12 +25,12 @@ public SemanticParser getParser() { } @Override - public ZcodeOutStream getOutStream(Zcode zcode) { + public ZcodeOutStream getOutStream(Zscript zscript) { return out; } @Override - public ZcodeSemanticAction getAction() { + public SemanticAction getAction() { return p.getAction(); } @@ -41,7 +41,7 @@ public void setChannelIndex(byte i) { p.setChannelIndex(i); } - public abstract void channelInfo(final ZcodeCommandContext ctx); + public abstract void channelInfo(final CommandContext ctx); - public abstract void channelSetup(final ZcodeCommandContext ctx); + public abstract void channelSetup(final CommandContext ctx); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/Zcode.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/Zscript.java similarity index 98% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/Zcode.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/Zscript.java index f5b05463f..54306d9f4 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/Zcode.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/Zscript.java @@ -9,7 +9,7 @@ import net.zscript.javareceiver.modules.ZcodeModuleRegistry; import net.zscript.javareceiver.notifications.ZcodeNotificationSource; -public class Zcode { +public class Zscript { private final ZcodeModuleRegistry moduleRegistry = new ZcodeModuleRegistry(); private final ZcodeLocks locks = new ZcodeLocks(); private final List channels = new ArrayList<>(); @@ -41,7 +41,7 @@ protected void writeBytes(byte[] bytes, int count, boolean hexMode) { }; - public Zcode() { + public Zscript() { executor = new ZcodeExecutor(this); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeStatus.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZscriptStatus.java similarity index 99% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeStatus.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZscriptStatus.java index bb08d879e..7fd3539e5 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZcodeStatus.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/core/ZscriptStatus.java @@ -1,6 +1,6 @@ package net.zscript.javareceiver.core; -public class ZcodeStatus { +public class ZscriptStatus { /** command success */ public static final byte SUCCESS = 0x0; diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ActionSource.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ActionSource.java index ada2374a0..d226dcafb 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ActionSource.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ActionSource.java @@ -1,10 +1,10 @@ package net.zscript.javareceiver.execution; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeOutStream; public interface ActionSource { ZcodeAction getAction(); - ZcodeOutStream getOutStream(Zcode zcode); + ZcodeOutStream getOutStream(Zscript zscript); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAddressingContext.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/AddressingContext.java similarity index 88% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAddressingContext.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/AddressingContext.java index 8f23f92e3..972fd182f 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAddressingContext.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/AddressingContext.java @@ -2,7 +2,7 @@ import java.util.Optional; -import net.zscript.javareceiver.core.ZcodeStatus; +import net.zscript.javareceiver.core.ZscriptStatus; import net.zscript.javareceiver.semanticParser.ContextView; import net.zscript.javareceiver.tokenizer.BlockIterator; import net.zscript.javareceiver.tokenizer.OptIterator; @@ -10,8 +10,8 @@ import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer.TokenReader.ReadToken; -public class ZcodeAddressingContext extends AbstractContext { - public ZcodeAddressingContext(final ContextView contextView) { +public class AddressingContext extends AbstractContext { + public AddressingContext(final ContextView contextView) { super(contextView); } @@ -60,23 +60,23 @@ public boolean verify() { if (token.isMarker()) { return true; } - status(ZcodeStatus.INVALID_KEY); + status(ZscriptStatus.INVALID_KEY); return false; } if (token.getKey() == Zchars.Z_ADDRESSING || token.getKey() == Zchars.Z_ADDRESSING_CONTINUE) { continue; } if (token.getKey() != ZcodeTokenizer.ADDRESSING_FIELD_KEY) { - status(ZcodeStatus.INVALID_KEY); + status(ZscriptStatus.INVALID_KEY); return false; } if (i == 1) { - status(ZcodeStatus.INTERNAL_ERROR); + status(ZscriptStatus.INTERNAL_ERROR); return false; } hasReachedData = true; } - status(ZcodeStatus.MISSING_KEY); + status(ZscriptStatus.MISSING_KEY); return false; } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeCommandContext.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/CommandContext.java similarity index 91% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeCommandContext.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/CommandContext.java index 0d80c48ef..6845e768c 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeCommandContext.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/CommandContext.java @@ -6,23 +6,23 @@ import java.util.Optional; import java.util.OptionalInt; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeCommandOutStream; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; +import net.zscript.javareceiver.core.ZscriptStatus; import net.zscript.javareceiver.semanticParser.ContextView; import net.zscript.javareceiver.tokenizer.BlockIterator; import net.zscript.javareceiver.tokenizer.OptIterator; import net.zscript.javareceiver.tokenizer.Zchars; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer.TokenReader.ReadToken; -public class ZcodeCommandContext extends AbstractContext { - private final Zcode zcode; +public class CommandContext extends AbstractContext { + private final Zscript zscript; private final ZcodeOutStream out; - public ZcodeCommandContext(final Zcode zcode, final ContextView contextView, final ZcodeOutStream out) { + public CommandContext(final Zscript zscript, final ContextView contextView, final ZcodeOutStream out) { super(contextView); - this.zcode = zcode; + this.zscript = zscript; this.out = out; } @@ -177,18 +177,18 @@ public boolean verify() { if (Zchars.isNumericKey(key)) { if (foundCmds.get(key - 'A')) { commandComplete(); - status(ZcodeStatus.REPEATED_KEY); + status(ZscriptStatus.REPEATED_KEY); return false; } foundCmds.set(key - 'A'); if (rt.getDataSize() > 2) { commandComplete(); - status(ZcodeStatus.FIELD_TOO_LONG); + status(ZscriptStatus.FIELD_TOO_LONG); return false; } } else if (!Zchars.isBigField(key)) { commandComplete(); - status(ZcodeStatus.INVALID_KEY); + status(ZscriptStatus.INVALID_KEY); return false; } } @@ -199,8 +199,8 @@ public void activate() { contextView.activate(); } - public Zcode getZcode() { - return zcode; + public Zscript getZcode() { + return zscript; } public int getChannelIndex() { diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAction.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAction.java index 7d10f43b4..53a2f8235 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAction.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeAction.java @@ -1,15 +1,15 @@ package net.zscript.javareceiver.execution; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeOutStream; public interface ZcodeAction { boolean isEmptyAction(); - void performAction(Zcode z, ZcodeOutStream out); + void performAction(Zscript z, ZcodeOutStream out); - boolean canLock(Zcode z); + boolean canLock(Zscript z); - boolean lock(Zcode z); + boolean lock(Zscript z); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeExecutor.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeExecutor.java index d8ac75dec..aafc8507f 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeExecutor.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeExecutor.java @@ -3,15 +3,15 @@ import java.util.ArrayList; import java.util.List; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; public class ZcodeExecutor { - private final Zcode zcode; + private final Zscript zscript; private final ZcodeScheduler scheduler = new ZcodeScheduler(); - public ZcodeExecutor(Zcode zcode) { - this.zcode = zcode; + public ZcodeExecutor(Zscript zscript) { + this.zscript = zscript; } public boolean progress(List sources) { @@ -24,18 +24,18 @@ public boolean progress(List sources) { for (ActionSource source : sources) { ZcodeAction action = source.getAction(); if (action.isEmptyAction()) { - action.performAction(zcode, null); + action.performAction(zscript, null); } else { hasNonWait = true; } possibleActions.add(action); } - int indexToExec = scheduler.decide(zcode, possibleActions); + int indexToExec = scheduler.decide(zscript, possibleActions); ZcodeAction action = possibleActions.get(indexToExec); - if (!action.isEmptyAction() && action.lock(zcode)) { - action.performAction(zcode, sources.get(indexToExec).getOutStream(zcode)); + if (!action.isEmptyAction() && action.lock(zscript)) { + action.performAction(zscript, sources.get(indexToExec).getOutStream(zscript)); } return hasNonWait; } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeScheduler.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeScheduler.java index 1093957e3..ebd18962e 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeScheduler.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/execution/ZcodeScheduler.java @@ -2,15 +2,15 @@ import java.util.List; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; public class ZcodeScheduler { - int decide(Zcode zcode, List possibilities) { + int decide(Zscript zscript, List possibilities) { // TODO: a better one for (int i = 0; i < possibilities.size(); i++) { ZcodeAction action = possibilities.get(i); - if (!action.isEmptyAction() && action.canLock(zcode)) { + if (!action.isEmptyAction() && action.canLock(zscript)) { return i; } } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModule.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModule.java index f7040b760..66efbc8b4 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModule.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModule.java @@ -1,31 +1,31 @@ package net.zscript.javareceiver.modules; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.AddressingContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.tokenizer.Zchars; public interface ZcodeModule { int getModuleID(); - void execute(ZcodeCommandContext ctx, int command); + void execute(CommandContext ctx, int command); - default void moveAlong(ZcodeCommandContext ctx, int command) { - ctx.status(ZcodeStatus.INTERNAL_ERROR); + default void moveAlong(CommandContext ctx, int command) { + ctx.status(ZscriptStatus.INTERNAL_ERROR); } - default void address(ZcodeAddressingContext ctx) { - ctx.status(ZcodeStatus.INTERNAL_ERROR); + default void address(AddressingContext ctx) { + ctx.status(ZscriptStatus.INTERNAL_ERROR); } - default void addressMoveAlong(ZcodeAddressingContext ctx) { - ctx.status(ZcodeStatus.INTERNAL_ERROR); + default void addressMoveAlong(AddressingContext ctx) { + ctx.status(ZscriptStatus.INTERNAL_ERROR); } default boolean notification(ZcodeOutStream out, int i, boolean isAddressed) { - out.asCommandOutStream().writeField(Zchars.Z_STATUS, ZcodeStatus.INTERNAL_ERROR); + out.asCommandOutStream().writeField(Zchars.Z_STATUS, ZscriptStatus.INTERNAL_ERROR); return true; } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModuleRegistry.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModuleRegistry.java index 140a66018..9495c3fb4 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModuleRegistry.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/ZcodeModuleRegistry.java @@ -3,9 +3,9 @@ import java.util.OptionalInt; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.AddressingContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.tokenizer.Zchars; public class ZcodeModuleRegistry { @@ -19,54 +19,54 @@ public void addModule(ZcodeModule m) { modules[m.getModuleID()] = m; } - public void execute(ZcodeCommandContext ctx) { + public void execute(CommandContext ctx) { // commands are completable unless explicitly marked otherwise by a command ctx.commandComplete(); OptionalInt value = ctx.getField(Zchars.Z_CMD); if (value.isEmpty()) { - ctx.status(ZcodeStatus.COMMAND_NOT_FOUND); + ctx.status(ZscriptStatus.COMMAND_NOT_FOUND); return; } int cmd = value.getAsInt(); if ((cmd >> 4) >= 0x1000) { - ctx.status(ZcodeStatus.FIELD_TOO_LONG); + ctx.status(ZscriptStatus.FIELD_TOO_LONG); return; } if (cmd > MAX_SYSTEM_CMD && !ctx.isActivated()) { - ctx.status(ZcodeStatus.NOT_ACTIVATED); + ctx.status(ZscriptStatus.NOT_ACTIVATED); return; } if (modules[cmd >> 4] == null) { - ctx.status(ZcodeStatus.COMMAND_NOT_FOUND); + ctx.status(ZscriptStatus.COMMAND_NOT_FOUND); return; } modules[cmd >> 4].execute(ctx, cmd & 0xF); } - public void moveAlong(ZcodeCommandContext ctx) { + public void moveAlong(CommandContext ctx) { ctx.commandComplete(); int cmd = ctx.getField(Zchars.Z_CMD).getAsInt(); modules[cmd >> 4].moveAlong(ctx, cmd & 0xF); } - public void execute(ZcodeAddressingContext ctx) { + public void execute(AddressingContext ctx) { ctx.commandComplete(); if (!ctx.isActivated()) { - ctx.status(ZcodeStatus.NOT_ACTIVATED); + ctx.status(ZscriptStatus.NOT_ACTIVATED); return; } int addr = ctx.getAddressSegments().next().get(); ZcodeModule module = modules[addr]; if (module == null) { - ctx.status(ZcodeStatus.ADDRESS_NOT_FOUND); + ctx.status(ZscriptStatus.ADDRESS_NOT_FOUND); return; } module.address(ctx); } - public void moveAlong(ZcodeAddressingContext ctx) { + public void moveAlong(AddressingContext ctx) { ctx.commandComplete(); int addr = ctx.getAddressSegments().next().get(); modules[addr].addressMoveAlong(ctx); @@ -74,7 +74,7 @@ public void moveAlong(ZcodeAddressingContext ctx) { public boolean notification(ZcodeOutStream out, int type, boolean isAddressed) { if (modules[type >> 4] == null) { - out.asCommandOutStream().writeField(Zchars.Z_STATUS, ZcodeStatus.INTERNAL_ERROR); + out.asCommandOutStream().writeField(Zchars.Z_STATUS, ZscriptStatus.INTERNAL_ERROR); return true; } return modules[type >> 4].notification(out, type & 0xF, isAddressed); diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeActivateCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeActivateCommand.java deleted file mode 100644 index 59322670c..000000000 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeActivateCommand.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.zscript.javareceiver.modules.core; - -import net.zscript.javareceiver.execution.ZcodeCommandContext; - -public class ZcodeActivateCommand { - - public static void execute(ZcodeCommandContext ctx) { - ctx.getOutStream().writeField('A', ctx.isActivated() ? 1 : 0); - ctx.activate(); - } - -} diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptActivateCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptActivateCommand.java new file mode 100644 index 000000000..1efe95750 --- /dev/null +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptActivateCommand.java @@ -0,0 +1,12 @@ +package net.zscript.javareceiver.modules.core; + +import net.zscript.javareceiver.execution.CommandContext; + +public class ZscriptActivateCommand { + + public static void execute(CommandContext ctx) { + ctx.getOutStream().writeField('A', ctx.isActivated() ? 1 : 0); + ctx.activate(); + } + +} diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeCapabilitiesCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptCapabilitiesCommand.java similarity index 87% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeCapabilitiesCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptCapabilitiesCommand.java index 36c856e67..233e315dd 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeCapabilitiesCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptCapabilitiesCommand.java @@ -1,10 +1,10 @@ package net.zscript.javareceiver.modules.core; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; -public class ZcodeCapabilitiesCommand { +public class ZscriptCapabilitiesCommand { private static int getVersion() { String version = System.getProperty("java.version"); @@ -30,7 +30,7 @@ private static int getVersion() { public int coreZcodeVersion = 0; public String coreZcodeStr = "Prototype parsing/running system for JVM"; - public void execute(ZcodeCommandContext ctx) { + public void execute(CommandContext ctx) { ZcodeCommandOutStream out = ctx.getOutStream(); int versionType = ctx.getField((byte) 'V', 0); @@ -65,9 +65,9 @@ public void execute(ZcodeCommandContext ctx) { out.writeQuotedString(str); } } else { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); } - out.writeField('C', ZcodeCoreModule.getCommands()); + out.writeField('C', ZscriptCoreModule.getCommands()); out.writeField('M', ctx.getZcode().getModuleRegistry().getCommandSwitchExistsBottom(0)); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeChannelInfoCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptChannelInfoCommand.java similarity index 68% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeChannelInfoCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptChannelInfoCommand.java index ebbda081b..bf8c0d100 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeChannelInfoCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptChannelInfoCommand.java @@ -3,19 +3,19 @@ import java.util.List; import net.zscript.javareceiver.core.ZcodeChannel; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; -public class ZcodeChannelInfoCommand { +public class ZscriptChannelInfoCommand { - public static void execute(ZcodeCommandContext ctx) { + public static void execute(CommandContext ctx) { List chs = ctx.getZcode().getChannels(); int current = ctx.getChannelIndex(); int target = ctx.getField((byte) 'C', current); if (target >= chs.size()) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } ctx.getOutStream().writeField('C', chs.size()); diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeCoreModule.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptCoreModule.java similarity index 52% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeCoreModule.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptCoreModule.java index 0128037d6..29edcc83a 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeCoreModule.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptCoreModule.java @@ -1,15 +1,15 @@ package net.zscript.javareceiver.modules.core; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.AddressingContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.modules.ZcodeModule; import net.zscript.javareceiver.tokenizer.BlockIterator; -public class ZcodeCoreModule implements ZcodeModule { - private final ZcodeCapabilitiesCommand capabilitiesCmd = new ZcodeCapabilitiesCommand(); - private final ZcodeGuidCommand guidCmd = new ZcodeGuidCommand(); - private final ZcodeRandomCodeCommand codeCmd = new ZcodeRandomCodeCommand(); +public class ZscriptCoreModule implements ZcodeModule { + private final ZscriptCapabilitiesCommand capabilitiesCmd = new ZscriptCapabilitiesCommand(); + private final ZscriptGuidCommand guidCmd = new ZscriptGuidCommand(); + private final ZscriptRandomCodeCommand codeCmd = new ZscriptRandomCodeCommand(); public static int getCommands() { return 0x3007; @@ -21,22 +21,22 @@ public int getModuleID() { } @Override - public void execute(ZcodeCommandContext ctx, int command) { + public void execute(CommandContext ctx, int command) { switch (command) { case 0x0: capabilitiesCmd.execute(ctx); break; case 0x1: - ZcodeEchoCommand.execute(ctx); + ZscriptEchoCommand.execute(ctx); break; case 0x2: - ZcodeActivateCommand.execute(ctx); + ZscriptActivateCommand.execute(ctx); break; case 0x4: guidCmd.fetch(ctx); break; case 0x8: - ZcodeChannelInfoCommand.execute(ctx); + ZscriptChannelInfoCommand.execute(ctx); break; case 0xc: codeCmd.make(ctx); @@ -45,27 +45,27 @@ public void execute(ZcodeCommandContext ctx, int command) { codeCmd.match(ctx); break; default: - ctx.status(ZcodeStatus.COMMAND_NOT_FOUND); + ctx.status(ZscriptStatus.COMMAND_NOT_FOUND); } } @Override - public void address(ZcodeAddressingContext ctx) { + public void address(AddressingContext ctx) { for (BlockIterator iterator = ctx.getAddressedData(); iterator.hasNext();) { byte b = iterator.next(); System.out.print((char) b); } } - public ZcodeCapabilitiesCommand getCapabilitiesCmd() { + public ZscriptCapabilitiesCommand getCapabilitiesCmd() { return capabilitiesCmd; } - public ZcodeRandomCodeCommand getCodeCmd() { + public ZscriptRandomCodeCommand getCodeCmd() { return codeCmd; } - public ZcodeGuidCommand getGuidCmd() { + public ZscriptGuidCommand getGuidCmd() { return guidCmd; } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeEchoCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptEchoCommand.java similarity index 85% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeEchoCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptEchoCommand.java index 90e340e21..e74d527c9 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeEchoCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptEchoCommand.java @@ -3,14 +3,14 @@ import java.util.Optional; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.execution.ZcodeField; import net.zscript.javareceiver.tokenizer.OptIterator; import net.zscript.javareceiver.tokenizer.Zchars; -public class ZcodeEchoCommand { +public class ZscriptEchoCommand { - public static void execute(ZcodeCommandContext ctx) { + public static void execute(CommandContext ctx) { ZcodeCommandOutStream out = ctx.getOutStream(); OptIterator iterator = ctx.fieldIterator(); for (Optional opt = iterator.next(); opt.isPresent(); opt = iterator.next()) { diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeGuidCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptGuidCommand.java similarity index 71% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeGuidCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptGuidCommand.java index 5bf5d89b7..c020e5469 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeGuidCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptGuidCommand.java @@ -4,15 +4,15 @@ import java.util.Iterator; import java.util.UUID; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; -public class ZcodeGuidCommand { +public class ZscriptGuidCommand { private UUID uuid = null; - public void fetch(ZcodeCommandContext ctx) { + public void fetch(CommandContext ctx) { if (uuid == null) { - ctx.status(ZcodeStatus.COMMAND_FAIL); + ctx.status(ZscriptStatus.COMMAND_FAIL); } else { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); @@ -22,9 +22,9 @@ public void fetch(ZcodeCommandContext ctx) { } } - public void set(ZcodeCommandContext ctx) { + public void set(CommandContext ctx) { if (ctx.getBigFieldSize() != 16) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); } else { byte[] data = new byte[16]; int i = 0; diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeRandomCodeCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptRandomCodeCommand.java similarity index 61% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeRandomCodeCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptRandomCodeCommand.java index e6444b502..4375c6fca 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZcodeRandomCodeCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/core/ZscriptRandomCodeCommand.java @@ -4,28 +4,28 @@ import java.util.Random; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; -public class ZcodeRandomCodeCommand { +public class ZscriptRandomCodeCommand { private final Random r = new Random(); private int code; - public void make(ZcodeCommandContext ctx) { + public void make(CommandContext ctx) { ZcodeCommandOutStream out = ctx.getOutStream(); code = r.nextInt(0x1000); out.writeField('C', code); } - public void match(ZcodeCommandContext ctx) { + public void match(CommandContext ctx) { OptionalInt givenCode = ctx.getField((byte) 'C'); if (givenCode.isEmpty()) { - ctx.status(ZcodeStatus.MISSING_KEY); + ctx.status(ZscriptStatus.MISSING_KEY); return; } if (givenCode.getAsInt() != code) { - ctx.status(ZcodeStatus.COMMAND_FAIL); + ctx.status(ZscriptStatus.COMMAND_FAIL); } } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeChannelSetupCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptChannelSetupCommand.java similarity index 68% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeChannelSetupCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptChannelSetupCommand.java index b10cef0ca..5aac22cec 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeChannelSetupCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptChannelSetupCommand.java @@ -3,18 +3,18 @@ import java.util.List; import net.zscript.javareceiver.core.ZcodeChannel; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; -public class ZcodeChannelSetupCommand { +public class ZscriptChannelSetupCommand { - public static void execute(ZcodeCommandContext ctx) { + public static void execute(CommandContext ctx) { List chs = ctx.getZcode().getChannels(); int current = ctx.getChannelIndex(); int target = ctx.getField((byte) 'C', current); if (target >= chs.size()) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } chs.get(target).channelSetup(ctx); diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeExtendedCapabilitiesCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptExtendedCapabilitiesCommand.java similarity index 65% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeExtendedCapabilitiesCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptExtendedCapabilitiesCommand.java index 25c7dca9b..ff4d42db2 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeExtendedCapabilitiesCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptExtendedCapabilitiesCommand.java @@ -3,21 +3,21 @@ import java.util.OptionalInt; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; -public class ZcodeExtendedCapabilitiesCommand { +public class ZscriptExtendedCapabilitiesCommand { - public static void execute(ZcodeCommandContext ctx) { + public static void execute(CommandContext ctx) { ZcodeCommandOutStream out = ctx.getOutStream(); - out.writeField('C', ZcodeOuterCoreModule.getCommands()); + out.writeField('C', ZscriptOuterCoreModule.getCommands()); out.writeField('M', ctx.getZcode().getModuleRegistry().getCommandSwitchExistsBroad()); OptionalInt targetOpt = ctx.getField((byte) 'M'); if (targetOpt.isPresent()) { int target = targetOpt.getAsInt(); if (target > 16) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } int result = ctx.getZcode().getModuleRegistry().getCommandSwitchExistsTop(target); diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeOuterCoreModule.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptOuterCoreModule.java similarity index 63% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeOuterCoreModule.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptOuterCoreModule.java index 68d59bfc4..2951610a6 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZcodeOuterCoreModule.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/modules/outerCore/ZscriptOuterCoreModule.java @@ -2,16 +2,16 @@ import net.zscript.javareceiver.core.ZcodeLockSet; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.modules.ZcodeModule; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.notifications.ZcodeNotificationSource; -public class ZcodeOuterCoreModule implements ZcodeModule { +public class ZscriptOuterCoreModule implements ZcodeModule { private final ZcodeNotificationSource source = new ZcodeNotificationSource(); - public ZcodeOuterCoreModule() { + public ZscriptOuterCoreModule() { source.setNotification(ZcodeLockSet.allLocked(), 0x10); } @@ -29,19 +29,19 @@ public int getModuleID() { } @Override - public void execute(ZcodeCommandContext ctx, int command) { + public void execute(CommandContext ctx, int command) { switch (command) { case 0x0: - ZcodeExtendedCapabilitiesCommand.execute(ctx); + ZscriptExtendedCapabilitiesCommand.execute(ctx); break; case 0x4: - ((ZcodeCoreModule) ctx.getZcode().getModuleRegistry().getModule(0)).getGuidCmd().set(ctx); + ((ZscriptCoreModule) ctx.getZcode().getModuleRegistry().getModule(0)).getGuidCmd().set(ctx); break; case 0x8: - ZcodeChannelSetupCommand.execute(ctx); + ZscriptChannelSetupCommand.execute(ctx); break; default: - ctx.status(ZcodeStatus.COMMAND_NOT_FOUND); + ctx.status(ZscriptStatus.COMMAND_NOT_FOUND); } } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationAction.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationAction.java index d84737799..479aa1c51 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationAction.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationAction.java @@ -1,6 +1,6 @@ package net.zscript.javareceiver.notifications; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeCommandOutStream; import net.zscript.javareceiver.core.ZcodeLockSet; import net.zscript.javareceiver.core.ZcodeOutStream; @@ -19,7 +19,7 @@ public boolean isEmptyAction() { } @Override - public void performAction(Zcode z, ZcodeOutStream out) { + public void performAction(Zscript z, ZcodeOutStream out) { if (!source.hasNotification() || out == null) { return; } @@ -50,7 +50,7 @@ private void startResponse(ZcodeOutStream out) { } @Override - public boolean canLock(Zcode z) { + public boolean canLock(Zscript z) { ZcodeLockSet ls = source.getLocks(); if (ls == null) { ls = ZcodeLockSet.allLocked(); @@ -59,7 +59,7 @@ public boolean canLock(Zcode z) { } @Override - public boolean lock(Zcode z) { + public boolean lock(Zscript z) { ZcodeLockSet ls = source.getLocks(); if (ls == null) { ls = ZcodeLockSet.allLocked(); diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationSource.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationSource.java index 37aa5535b..6777a676f 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationSource.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/notifications/ZcodeNotificationSource.java @@ -1,6 +1,6 @@ package net.zscript.javareceiver.notifications; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeLockSet; import net.zscript.javareceiver.core.ZcodeOutStream; import net.zscript.javareceiver.execution.ActionSource; @@ -20,8 +20,8 @@ public void actionExecuted() { } @Override - public ZcodeOutStream getOutStream(Zcode zcode) { - return zcode.getNotificationOutStream(); + public ZcodeOutStream getOutStream(Zscript zscript) { + return zscript.getNotificationOutStream(); } public int getID() { diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ActionFactory.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ActionFactory.java new file mode 100644 index 000000000..1a4fcc020 --- /dev/null +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ActionFactory.java @@ -0,0 +1,11 @@ +package net.zscript.javareceiver.semanticParser; + +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; + +public interface ActionFactory { + + SemanticAction waitForTokens(ParseState parseState); + + SemanticAction ofType(ParseState parseState, ActionType type); + +} \ No newline at end of file diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ExecutionActionFactory.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ExecutionActionFactory.java index 85b57cc88..52ac09e74 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ExecutionActionFactory.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ExecutionActionFactory.java @@ -1,17 +1,17 @@ package net.zscript.javareceiver.semanticParser; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; -public class ExecutionActionFactory implements ZcodeActionFactory { +public class ExecutionActionFactory implements ActionFactory { @Override - public ZcodeSemanticAction waitForTokens(ParseState parseState) { - return new ZcodeSemanticAction(ActionType.WAIT_FOR_TOKENS, parseState); + public SemanticAction waitForTokens(ParseState parseState) { + return new SemanticAction(ActionType.WAIT_FOR_TOKENS, parseState); } @Override - public ZcodeSemanticAction ofType(ParseState parseState, ActionType type) { - return new ZcodeSemanticAction(type, parseState); + public SemanticAction ofType(ParseState parseState, ActionType type) { + return new SemanticAction(type, parseState); } } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ParseState.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ParseState.java index fe2fd3b82..a978770d1 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ParseState.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ParseState.java @@ -1,7 +1,7 @@ package net.zscript.javareceiver.semanticParser; -import net.zscript.javareceiver.core.Zcode; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.core.Zscript; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; /** * Defines methods accessed by ZcodeActions. @@ -19,11 +19,11 @@ public interface ParseState { int getEcho(); - boolean canLock(Zcode zcode); + boolean canLock(Zscript zscript); - boolean lock(Zcode zcode); + boolean lock(Zscript zscript); - void unlock(Zcode zcode); + void unlock(Zscript zscript); boolean isEmpty(); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ZcodeSemanticAction.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticAction.java similarity index 72% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ZcodeSemanticAction.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticAction.java index d003a806e..cb0f806e6 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ZcodeSemanticAction.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticAction.java @@ -1,16 +1,16 @@ package net.zscript.javareceiver.semanticParser; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeCommandOutStream; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; +import net.zscript.javareceiver.core.ZscriptStatus; import net.zscript.javareceiver.execution.ZcodeAction; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.execution.AddressingContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.tokenizer.Zchars; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; -public class ZcodeSemanticAction implements ZcodeAction { +public class SemanticAction implements ZcodeAction { enum ActionType { INVALID, GO_AROUND, @@ -29,7 +29,7 @@ enum ActionType { private final ParseState parseState; private final ActionType type; - ZcodeSemanticAction(ActionType type, ParseState parser) { + SemanticAction(ActionType type, ParseState parser) { this.parseState = parser; this.type = type; } @@ -40,28 +40,28 @@ public boolean isEmptyAction() { } @Override - public void performAction(Zcode zcode, ZcodeOutStream out) { - performActionImpl(zcode, out); + public void performAction(Zscript zscript, ZcodeOutStream out) { + performActionImpl(zscript, out); parseState.actionPerformed(type); } - protected void performActionImpl(Zcode zcode, ZcodeOutStream out) { + protected void performActionImpl(Zscript zscript, ZcodeOutStream out) { switch (type) { case ERROR: startResponse(out, (byte) 0x10); // TODO: debate out.asCommandOutStream().writeField(Zchars.Z_STATUS, parseState.getErrorStatus()); out.endSequence(); out.close(); - parseState.unlock(zcode); + parseState.unlock(zscript); break; case INVOKE_ADDRESSING: - ZcodeAddressingContext addrCtx = new ZcodeAddressingContext((ContextView) parseState); + AddressingContext addrCtx = new AddressingContext((ContextView) parseState); if (addrCtx.verify()) { - zcode.getModuleRegistry().execute(addrCtx); + zscript.getModuleRegistry().execute(addrCtx); } break; case ADDRESSING_MOVEALONG: - zcode.getModuleRegistry().moveAlong(new ZcodeAddressingContext((ContextView) parseState)); + zscript.getModuleRegistry().moveAlong(new AddressingContext((ContextView) parseState)); break; case RUN_FIRST_COMMAND: startResponse(out, (byte) 0); @@ -70,21 +70,21 @@ protected void performActionImpl(Zcode zcode, ZcodeOutStream out) { if (type == ActionType.RUN_COMMAND) { sendNormalMarkerPrefix(out); } - ZcodeCommandContext cmdCtx = new ZcodeCommandContext(zcode, (ContextView) parseState, out); + CommandContext cmdCtx = new CommandContext(zscript, (ContextView) parseState, out); if (cmdCtx.verify()) { if (!parseState.isEmpty()) { - zcode.getModuleRegistry().execute(cmdCtx); + zscript.getModuleRegistry().execute(cmdCtx); if (cmdCtx.isCommandComplete()) { - cmdCtx.status(ZcodeStatus.SUCCESS); + cmdCtx.status(ZscriptStatus.SUCCESS); } } } break; case COMMAND_MOVEALONG: - ZcodeCommandContext cmdCtx1 = new ZcodeCommandContext(zcode, (ContextView) parseState, out); - zcode.getModuleRegistry().moveAlong(cmdCtx1); + CommandContext cmdCtx1 = new CommandContext(zscript, (ContextView) parseState, out); + zscript.getModuleRegistry().moveAlong(cmdCtx1); if (cmdCtx1.isCommandComplete()) { - cmdCtx1.status(ZcodeStatus.SUCCESS); + cmdCtx1.status(ZscriptStatus.SUCCESS); } break; case END_SEQUENCE: @@ -92,7 +92,7 @@ protected void performActionImpl(Zcode zcode, ZcodeOutStream out) { out.endSequence(); out.close(); } - parseState.unlock(zcode); + parseState.unlock(zscript); break; case CLOSE_PAREN: out.writeCloseParen(); @@ -142,13 +142,13 @@ public String toString() { } @Override - public boolean canLock(Zcode zcode) { - return parseState.canLock(zcode); + public boolean canLock(Zscript zscript) { + return parseState.canLock(zscript); } @Override - public boolean lock(Zcode zcode) { - return parseState.lock(zcode); + public boolean lock(Zscript zscript) { + return parseState.lock(zscript); } // visible for testing diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticParser.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticParser.java index 5764b3494..ddb07d07b 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticParser.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/SemanticParser.java @@ -3,11 +3,11 @@ import java.util.Optional; import java.util.function.Predicate; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeLockSet; import net.zscript.javareceiver.core.ZcodeLocks; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; import net.zscript.javareceiver.tokenizer.TokenBufferIterator; import net.zscript.javareceiver.tokenizer.Zchars; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; @@ -19,9 +19,9 @@ public class SemanticParser implements ParseState, ContextView { // 6 bytes + 1 pointer - private final TokenReader reader; - private final ZcodeActionFactory actionFactory; - private byte channelIndex; + private final TokenReader reader; + private final ActionFactory actionFactory; + private byte channelIndex; private class MarkerCache { private byte nextMarker = 0; // 5 bit really @@ -230,7 +230,7 @@ private boolean isInErrorState() { || state == State.ERROR_STATUS; } - public SemanticParser(final TokenReader reader, ZcodeActionFactory actionFactory) { + public SemanticParser(final TokenReader reader, ActionFactory actionFactory) { this.reader = reader; this.actionFactory = actionFactory; this.currentAction = ActionType.INVALID; @@ -247,7 +247,7 @@ State getState() { * * @return */ - public ZcodeSemanticAction getAction() { + public SemanticAction getAction() { // currentAction is always nulled after action execution while (currentAction == ActionType.INVALID || currentAction == ActionType.GO_AROUND) { if (markerCache.checkNeedsTokens() == ActionType.WAIT_FOR_TOKENS) { @@ -543,11 +543,11 @@ public byte takeCurrentMarker() { public byte getErrorStatus() { switch (state) { case ERROR_COMMENT_WITH_SEQ_FIELDS: - return ZcodeStatus.INVALID_COMMENT; + return ZscriptStatus.INVALID_COMMENT; case ERROR_LOCKS: - return ZcodeStatus.INVALID_LOCKS; + return ZscriptStatus.INVALID_LOCKS; case ERROR_MULTIPLE_ECHO: - return ZcodeStatus.INVALID_ECHO; + return ZscriptStatus.INVALID_ECHO; case ERROR_TOKENIZER: byte tokenizerError = reader.getFirstKey(); if (!reader.getFirstReadToken().isSequenceEndMarker()) { @@ -556,19 +556,19 @@ public byte getErrorStatus() { byte statusValue; if (tokenizerError == ZcodeTokenizer.ERROR_BUFFER_OVERRUN) { - statusValue = ZcodeStatus.BUFFER_OVR_ERROR; + statusValue = ZscriptStatus.BUFFER_OVR_ERROR; } else if (tokenizerError == ZcodeTokenizer.ERROR_CODE_FIELD_TOO_LONG) { - statusValue = ZcodeStatus.FIELD_TOO_LONG; + statusValue = ZscriptStatus.FIELD_TOO_LONG; } else if (tokenizerError == ZcodeTokenizer.ERROR_CODE_ILLEGAL_TOKEN) { - statusValue = ZcodeStatus.ILLEGAL_KEY; + statusValue = ZscriptStatus.ILLEGAL_KEY; } else if (tokenizerError == ZcodeTokenizer.ERROR_CODE_ODD_BIGFIELD_LENGTH) { - statusValue = ZcodeStatus.ODD_LENGTH; + statusValue = ZscriptStatus.ODD_LENGTH; } else if (tokenizerError == ZcodeTokenizer.ERROR_CODE_STRING_ESCAPING) { - statusValue = ZcodeStatus.ESCAPING_ERROR; + statusValue = ZscriptStatus.ESCAPING_ERROR; } else if (tokenizerError == ZcodeTokenizer.ERROR_CODE_STRING_NOT_TERMINATED) { - statusValue = ZcodeStatus.UNTERMINATED_STRING; + statusValue = ZscriptStatus.UNTERMINATED_STRING; } else { - statusValue = (ZcodeStatus.INTERNAL_ERROR); + statusValue = (ZscriptStatus.INTERNAL_ERROR); } return statusValue; case ERROR_STATUS: @@ -578,16 +578,16 @@ public byte getErrorStatus() { } @Override - public boolean canLock(final Zcode zcode) { - return locked || zcode.canLock(locks); + public boolean canLock(final Zscript zscript) { + return locked || zscript.canLock(locks); } @Override - public boolean lock(Zcode zcode) { + public boolean lock(Zscript zscript) { if (locked) { return true; } - locked = zcode.lock(locks); + locked = zscript.lock(locks); return locked; } @@ -597,8 +597,8 @@ public boolean hasSentStatus() { } @Override - public void unlock(Zcode zcode) { - zcode.unlock(locks); + public void unlock(Zscript zscript) { + zscript.unlock(locks); this.locked = false; } @@ -669,16 +669,16 @@ public boolean requestStatusChange(byte status) { } hasSetStatus = true; - if (ZcodeStatus.isSuccess(status)) { + if (ZscriptStatus.isSuccess(status)) { return true; } - if (ZcodeStatus.isError(status)) { + if (ZscriptStatus.isError(status)) { state = State.ERROR_STATUS; return true; } - if (ZcodeStatus.isFailure(status)) { + if (ZscriptStatus.isFailure(status)) { switch (state) { case COMMAND_COMPLETE: case COMMAND_INCOMPLETE: diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ZcodeActionFactory.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ZcodeActionFactory.java deleted file mode 100644 index 8344b08b4..000000000 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javareceiver/semanticParser/ZcodeActionFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.zscript.javareceiver.semanticParser; - -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; - -public interface ZcodeActionFactory { - - ZcodeSemanticAction waitForTokens(ParseState parseState); - - ZcodeSemanticAction ofType(ParseState parseState, ActionType type); - -} \ No newline at end of file diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZcodeConnection.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZcodeConnection.java index fea54f20a..7c7180559 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZcodeConnection.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZcodeConnection.java @@ -9,11 +9,11 @@ import net.zscript.javaclient.responseParser.ZcodeConnection; import net.zscript.javareceiver.core.OutputStreamOutStream; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeChannel; -import net.zscript.javareceiver.execution.ZcodeCommandContext; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; -import net.zscript.javareceiver.modules.outerCore.ZcodeOuterCoreModule; +import net.zscript.javareceiver.execution.CommandContext; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; +import net.zscript.javareceiver.modules.outerCore.ZscriptOuterCoreModule; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; @@ -23,16 +23,16 @@ public class LocalZcodeConnection implements ZcodeConnection { private Consumer handler; private class ProgressForever implements Runnable { - private final Zcode zcode; + private final Zscript zscript; - public ProgressForever(Zcode zcode) { - this.zcode = zcode; + public ProgressForever(Zscript zscript) { + this.zscript = zscript; } @Override public void run() { try { - zcode.progress(); + zscript.progress(); } catch (Exception e) { e.printStackTrace(); } @@ -42,13 +42,13 @@ public void run() { } public LocalZcodeConnection() { - Zcode zcode = new Zcode(); + Zscript zscript = new Zscript(); - zcode.addModule(new ZcodeCoreModule()); - zcode.addModule(new ZcodeOuterCoreModule()); + zscript.addModule(new ZscriptCoreModule()); + zscript.addModule(new ZscriptOuterCoreModule()); ZcodeTokenRingBuffer rbuff = ZcodeTokenRingBuffer.createBufferWithCapacity(100); - zcode.addChannel(new ZcodeChannel(rbuff, new OutputStreamOutStream<>(new ByteArrayOutputStream()) { + zscript.addChannel(new ZcodeChannel(rbuff, new OutputStreamOutStream<>(new ByteArrayOutputStream()) { @Override public void close() { @@ -79,16 +79,16 @@ public void moveAlong() { } @Override - public void channelInfo(ZcodeCommandContext view) { + public void channelInfo(CommandContext view) { view.getOutStream().writeQuotedString("Basic text channel"); } @Override - public void channelSetup(ZcodeCommandContext view) { + public void channelSetup(CommandContext view) { } }); - exec.submit(new ProgressForever(zcode)); + exec.submit(new ProgressForever(zscript)); } @Override diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/demoRun/Main.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/demoRun/Main.java index 6ee683799..5a9b4eaf7 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/demoRun/Main.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/demoRun/Main.java @@ -2,27 +2,27 @@ import java.io.IOException; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeChannel; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.execution.ZcodeCommandContext; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; -import net.zscript.javareceiver.modules.outerCore.ZcodeOuterCoreModule; +import net.zscript.javareceiver.execution.CommandContext; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; +import net.zscript.javareceiver.modules.outerCore.ZscriptOuterCoreModule; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; public class Main { public static void main(String[] args) throws IOException { - Zcode zcode = new Zcode(); - ZcodeOuterCoreModule oCore = new ZcodeOuterCoreModule(); - zcode.addNotificationSource(oCore.getNotificationSource()); - zcode.addModule(oCore); - zcode.addModule(new ZcodeCoreModule()); + Zscript zscript = new Zscript(); + ZscriptOuterCoreModule oCore = new ZscriptOuterCoreModule(); + zscript.addNotificationSource(oCore.getNotificationSource()); + zscript.addModule(oCore); + zscript.addModule(new ZscriptCoreModule()); byte[] code = "Z2(Z1S1)Z1&Z1|Z1\n".getBytes(); ZcodeTokenRingBuffer rbuff = ZcodeTokenRingBuffer.createBufferWithCapacity(100); ZcodeOutStream out = new ZcodePrintingOutStream(); - zcode.addChannel(new ZcodeChannel(rbuff, out) { + zscript.addChannel(new ZcodeChannel(rbuff, out) { ZcodeTokenizer in = new ZcodeTokenizer(rbuff.getTokenWriter(), 2); private int i = 0; @@ -34,17 +34,17 @@ public void moveAlong() { } @Override - public void channelInfo(ZcodeCommandContext ctx) { + public void channelInfo(CommandContext ctx) { ctx.getOutStream().writeQuotedString("Basic text channel"); } @Override - public void channelSetup(ZcodeCommandContext ctx) { + public void channelSetup(CommandContext ctx) { } }); - zcode.setNotificationOutStream(out); + zscript.setNotificationOutStream(out); for (int i = 0; i < 10000; i++) { - zcode.progress(); + zscript.progress(); } } } diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/EchoCommandTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/EchoCommandTest.java index 97ca7dbf1..7511cdd0b 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/EchoCommandTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/EchoCommandTest.java @@ -13,8 +13,8 @@ import org.junit.jupiter.params.provider.MethodSource; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.core.Zscript; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; @@ -27,16 +27,16 @@ class EchoCommandTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } @Test diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/LockEchoParserTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/LockEchoParserTest.java index e2442c03c..935d0ad53 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/LockEchoParserTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/LockEchoParserTest.java @@ -14,14 +14,14 @@ import org.junit.jupiter.params.provider.MethodSource; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeLockSet; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction; +import net.zscript.javareceiver.semanticParser.SemanticAction; import net.zscript.javareceiver.semanticParser.SemanticParser.State; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; @@ -32,16 +32,16 @@ class LockEchoParserTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } @Test @@ -87,31 +87,31 @@ private static Stream shouldHandleLocks() { @Test public void shouldApplyLocks() { "%16 Z1A &".chars().forEachOrdered(c -> tokenizer.accept((byte) c)); - ZcodeSemanticAction action = parser.getAction(); + SemanticAction action = parser.getAction(); assertThat(action.getType()).isEqualTo(ActionType.RUN_FIRST_COMMAND); - assertThat(zcode.canLock(ZcodeLockSet.allLocked())).isTrue(); - action.lock(zcode); - assertThat(zcode.canLock(ZcodeLockSet.allLocked())).isFalse(); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x1).iterator()))).isTrue(); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x2).iterator()))).isFalse(); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x4).iterator()))).isFalse(); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x8).iterator()))).isTrue(); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x10).iterator()))).isFalse(); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x20).iterator()))).isTrue(); - - action.performAction(zcode, outStream); + assertThat(zscript.canLock(ZcodeLockSet.allLocked())).isTrue(); + action.lock(zscript); + assertThat(zscript.canLock(ZcodeLockSet.allLocked())).isFalse(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x1).iterator()))).isTrue(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x2).iterator()))).isFalse(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x4).iterator()))).isFalse(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x8).iterator()))).isTrue(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x10).iterator()))).isFalse(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x20).iterator()))).isTrue(); + + action.performAction(zscript, outStream); assertThat(outStream.toString()).isEqualTo("!AS"); parserActionTester.parseSnippet("Z1B", ActionType.WAIT_FOR_TOKENS, State.COMMAND_COMPLETE_NEEDS_TOKENS, "!AS"); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x2).iterator()))).isFalse(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x2).iterator()))).isFalse(); parserActionTester.parseSnippet("\n", ActionType.RUN_COMMAND, State.COMMAND_COMPLETE, "!AS&BS"); - assertThat(zcode.canLock(ZcodeLockSet.from(List.of((byte) 0x2).iterator()))).isFalse(); + assertThat(zscript.canLock(ZcodeLockSet.from(List.of((byte) 0x2).iterator()))).isFalse(); parserActionTester.parseSnippet("", ActionType.END_SEQUENCE, State.PRESEQUENCE, "!AS&BS\n"); - assertThat(zcode.canLock(ZcodeLockSet.allLocked())).isTrue(); + assertThat(zscript.canLock(ZcodeLockSet.allLocked())).isTrue(); parserActionTester.parseSnippet("", ActionType.WAIT_FOR_TOKENS, State.PRESEQUENCE, "!AS&BS\n"); } diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/ParserActionTester.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/ParserActionTester.java index 3fd1ac269..cb87b3d4d 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/ParserActionTester.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/ParserActionTester.java @@ -4,12 +4,12 @@ import java.util.List; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeOutStream; import net.zscript.javareceiver.semanticParser.SemanticParser; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction; +import net.zscript.javareceiver.semanticParser.SemanticAction; import net.zscript.javareceiver.semanticParser.SemanticParser.State; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; @@ -17,14 +17,14 @@ * Testing utility methods. */ class ParserActionTester { - private final Zcode zcode; + private final Zscript zscript; private final ZcodeTokenBuffer buffer; private final ZcodeTokenizer tokenizer; private final SemanticParser parser; private final ZcodeOutStream outStream; - public ParserActionTester(Zcode zcode, ZcodeTokenBuffer buffer, ZcodeTokenizer tokenizer, SemanticParser parser, ZcodeOutStream outStream) { - this.zcode = zcode; + public ParserActionTester(Zscript zscript, ZcodeTokenBuffer buffer, ZcodeTokenizer tokenizer, SemanticParser parser, ZcodeOutStream outStream) { + this.zscript = zscript; this.buffer = buffer; this.tokenizer = tokenizer; this.parser = parser; @@ -40,11 +40,11 @@ void parseSnippet(final String text, final List actionTypes) { actionTypes.forEach(t -> { System.out.println("Expecting actionType=" + t); - ZcodeSemanticAction action = parser.getAction(); + SemanticAction action = parser.getAction(); System.out.println(" Received action: actionType=" + action + "; state=" + parser.getState()); assertThat(action.getType()).isEqualTo(t); - action.performAction(zcode, outStream); + action.performAction(zscript, outStream); System.out.println(" - After execute action: outStream=" + outStream.toString().replaceAll("\\n", "\\\\n") + "; state=" + parser.getState()); }); @@ -57,10 +57,10 @@ void parseSnippet(final String text, String output) { buffer.getTokenReader().iterator().forEach(t -> System.out.print(t + " ")); System.out.println(); - ZcodeSemanticAction a1; + SemanticAction a1; while ((a1 = parser.getAction()).getType() != ActionType.WAIT_FOR_TOKENS) { System.out.println(" Received action: actionType=" + a1 + "; state=" + parser.getState()); - a1.performAction(zcode, outStream); + a1.performAction(zscript, outStream); System.out.println(" - After execute action: outStream=" + outStream.toString().replaceAll("\\n", "\\\\n") + "; state=" + parser.getState()); } assertThat(outStream.toString()).isEqualTo(output); @@ -73,13 +73,13 @@ void parseSnippet(final String text, ActionType expectedActionType, State endSta buffer.getTokenReader().iterator().forEach(t -> System.out.print(t + " ")); System.out.println(); - ZcodeSemanticAction action = parser.getAction(); + SemanticAction action = parser.getAction(); System.out.println(" Received action: actionType=" + action + " (expected=" + expectedActionType + "); state=" + parser.getState()); if (expectedActionType != null) { assertThat(action.getType()).isEqualTo(expectedActionType); } - action.performAction(zcode, outStream); + action.performAction(zscript, outStream); System.out.println(" - After execute action: outStream=" + outStream.toString().replaceAll("\\n", "\\\\n") + "; state=" + parser.getState()); if (endState != null) { diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAddressingTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAddressingTest.java index 0b6ba5ba8..2b46db490 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAddressingTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAddressingTest.java @@ -1,9 +1,9 @@ package net.zscript.javareceiver.semanticParser; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.END_SEQUENCE; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.ERROR; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.INVOKE_ADDRESSING; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.WAIT_FOR_TOKENS; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.END_SEQUENCE; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.ERROR; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.INVOKE_ADDRESSING; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.WAIT_FOR_TOKENS; import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; @@ -13,8 +13,8 @@ import org.junit.jupiter.api.Test; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.core.Zscript; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; @@ -27,16 +27,16 @@ public class SemanticParserAddressingTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } @Test diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAsyncCommandTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAsyncCommandTest.java index 56bb8f605..faa0a060b 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAsyncCommandTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserAsyncCommandTest.java @@ -8,17 +8,17 @@ import org.junit.jupiter.api.Test; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.execution.AddressingContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.modules.ZcodeModule; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; import net.zscript.javareceiver.semanticParser.ContextView.AsyncActionNotifier; import net.zscript.javareceiver.semanticParser.SemanticParser.State; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; import net.zscript.javareceiver.tokenizer.OptIterator; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; @@ -30,7 +30,7 @@ class SemanticParserAsyncCommandTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @@ -38,13 +38,13 @@ class SemanticParserAsyncCommandTest { @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); newModule = new AsyncTestModule(); - zcode.addModule(newModule); + zscript.addModule(newModule); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } static class AsyncTestModule implements ZcodeModule { @@ -59,7 +59,7 @@ public int getModuleID() { } @Override - public void execute(ZcodeCommandContext ctx, int command) { + public void execute(CommandContext ctx, int command) { switch (command) { case 2: // picked 2 at random. this is command 0xf2 @@ -68,7 +68,7 @@ public void execute(ZcodeCommandContext ctx, int command) { } @Override - public void moveAlong(ZcodeCommandContext ctx, int command) { + public void moveAlong(CommandContext ctx, int command) { switch (command) { case 2: c2.moveAlong(ctx); @@ -79,7 +79,7 @@ public void moveAlong(ZcodeCommandContext ctx, int command) { * For testing, use 2nd part of address to match someValue if it's <10. Otherwise, don't go async at all. */ @Override - public void address(ZcodeAddressingContext ctx) { + public void address(AddressingContext ctx) { OptIterator s = ctx.getAddressSegments(); s.next(); // throw away module-lookup key if (s.next().get() < 10) { @@ -89,7 +89,7 @@ public void address(ZcodeAddressingContext ctx) { } @Override - public void addressMoveAlong(ZcodeAddressingContext ctx) { + public void addressMoveAlong(AddressingContext ctx) { OptIterator s = ctx.getAddressSegments(); s.next(); // throw away module-lookup key if (s.next().get() != someValue) { @@ -108,7 +108,7 @@ public void increment() { */ class AsyncCommand { - public void execute(ZcodeCommandContext ctx) { + public void execute(CommandContext ctx) { ZcodeCommandOutStream out = ctx.getOutStream(); out.writeField('A', 0xff); @@ -121,7 +121,7 @@ public void execute(ZcodeCommandContext ctx) { } } - public void moveAlong(ZcodeCommandContext ctx) { + public void moveAlong(CommandContext ctx) { int endOnValue = ctx.getField((byte) 'E', 1); if (someValue < endOnValue) { diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserMulticommandTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserMulticommandTest.java index cfbbb0773..676a1f3d7 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserMulticommandTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserMulticommandTest.java @@ -1,8 +1,8 @@ package net.zscript.javareceiver.semanticParser; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.END_SEQUENCE; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.RUN_FIRST_COMMAND; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.WAIT_FOR_TOKENS; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.END_SEQUENCE; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.RUN_FIRST_COMMAND; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.WAIT_FOR_TOKENS; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.params.provider.Arguments.of; @@ -17,8 +17,8 @@ import org.junit.jupiter.params.provider.MethodSource; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.core.Zscript; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; @@ -31,16 +31,16 @@ class SemanticParserMulticommandTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } @Test diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTest.java index b5af92d41..3a7abae8b 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTest.java @@ -1,10 +1,10 @@ package net.zscript.javareceiver.semanticParser; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.CLOSE_PAREN; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.END_SEQUENCE; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.RUN_COMMAND; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.RUN_FIRST_COMMAND; -import static net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType.WAIT_FOR_TOKENS; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.CLOSE_PAREN; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.END_SEQUENCE; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.RUN_COMMAND; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.RUN_FIRST_COMMAND; +import static net.zscript.javareceiver.semanticParser.SemanticAction.ActionType.WAIT_FOR_TOKENS; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.params.provider.Arguments.of; @@ -19,13 +19,13 @@ import org.junit.jupiter.params.provider.MethodSource; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.core.Zscript; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction; +import net.zscript.javareceiver.semanticParser.SemanticAction; import net.zscript.javareceiver.semanticParser.SemanticParser.State; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; @@ -36,22 +36,22 @@ class SemanticParserTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } @Test void shouldStartNoActionWithEmptyTokens() { assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); - final ZcodeSemanticAction a = parser.getAction(); + final SemanticAction a = parser.getAction(); assertThat(a.getType()).isEqualTo(WAIT_FOR_TOKENS); assertThat(outStream.getString()).isEqualTo(""); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); @@ -62,19 +62,19 @@ void shouldProduceActionForCommand() { "Z0\n".chars().forEachOrdered(c -> tokenizer.accept((byte) c)); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); - final ZcodeSemanticAction a1 = parser.getAction(); + final SemanticAction a1 = parser.getAction(); assertThat(a1.getType()).isEqualTo(RUN_FIRST_COMMAND); - a1.performAction(zcode, outStream); + a1.performAction(zscript, outStream); assertThat(outStream.getStringAndReset()).isEqualTo("!V1C3007M1S"); assertThat(parser.getState()).isEqualTo(State.COMMAND_COMPLETE); - final ZcodeSemanticAction a2 = parser.getAction(); + final SemanticAction a2 = parser.getAction(); assertThat(a2.getType()).isEqualTo(END_SEQUENCE); - a2.performAction(zcode, outStream); + a2.performAction(zscript, outStream); assertThat(outStream.getStringAndReset()).isEqualTo("\n"); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); - final ZcodeSemanticAction a3 = parser.getAction(); + final SemanticAction a3 = parser.getAction(); assertThat(a3.getType()).isEqualTo(WAIT_FOR_TOKENS); assertThat(outStream.getString()).isEqualTo(""); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); @@ -87,26 +87,26 @@ void shouldProduceActionForTwoCommands() { "Z1A & Z1B\n".chars().forEachOrdered(c -> tokenizer.accept((byte) c)); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); - final ZcodeSemanticAction a1 = parser.getAction(); + final SemanticAction a1 = parser.getAction(); assertThat(a1.getType()).isEqualTo(RUN_FIRST_COMMAND); - a1.performAction(zcode, outStream); + a1.performAction(zscript, outStream); assertThat(outStream.getStringAndReset()).isEqualTo("!AS"); assertThat(parser.getState()).isEqualTo(State.COMMAND_COMPLETE); - final ZcodeSemanticAction a2 = parser.getAction(); + final SemanticAction a2 = parser.getAction(); assertThat(a2.getType()).isEqualTo(RUN_COMMAND); // assertThat(a2.getInfo()).isEqualTo(ZcodeTokenizer.CMD_END_ANDTHEN); - a2.performAction(zcode, outStream); + a2.performAction(zscript, outStream); assertThat(outStream.getStringAndReset()).isEqualTo("&BS"); assertThat(parser.getState()).isEqualTo(State.COMMAND_COMPLETE); - final ZcodeSemanticAction a3 = parser.getAction(); + final SemanticAction a3 = parser.getAction(); assertThat(a3.getType()).isEqualTo(END_SEQUENCE); - a3.performAction(zcode, outStream); + a3.performAction(zscript, outStream); assertThat(outStream.getStringAndReset()).isEqualTo("\n"); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); - final ZcodeSemanticAction a4 = parser.getAction(); + final SemanticAction a4 = parser.getAction(); assertThat(a4.getType()).isEqualTo(WAIT_FOR_TOKENS); assertThat(outStream.getString()).isEqualTo(""); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); @@ -119,9 +119,9 @@ void shouldProduceActionForComment() { "#a\n".chars().forEachOrdered(c -> tokenizer.accept((byte) c)); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); - final ZcodeSemanticAction a1 = parser.getAction(); + final SemanticAction a1 = parser.getAction(); assertThat(a1.getType()).isEqualTo(WAIT_FOR_TOKENS); - a1.performAction(zcode, outStream); + a1.performAction(zscript, outStream); assertThat(outStream.getStringAndReset()).isEqualTo(""); assertThat(parser.getState()).isEqualTo(State.PRESEQUENCE); assertThat(outStream.isOpen()).isFalse(); diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTokenWaitTest.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTokenWaitTest.java index de48063b4..e1b4ef468 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTokenWaitTest.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javareceiver/semanticParser/SemanticParserTokenWaitTest.java @@ -8,12 +8,12 @@ import org.junit.jupiter.api.Test; import net.zscript.javareceiver.core.StringWriterOutStream; -import net.zscript.javareceiver.core.Zcode; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; +import net.zscript.javareceiver.core.Zscript; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; import net.zscript.javareceiver.semanticParser.ExecutionActionFactory; import net.zscript.javareceiver.semanticParser.SemanticParser; import net.zscript.javareceiver.semanticParser.SemanticParser.State; -import net.zscript.javareceiver.semanticParser.ZcodeSemanticAction.ActionType; +import net.zscript.javareceiver.semanticParser.SemanticAction.ActionType; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; @@ -24,16 +24,16 @@ class SemanticParserTokenWaitTest { private final SemanticParser parser = new SemanticParser(buffer.getTokenReader(), new ExecutionActionFactory()); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private StringWriterOutStream outStream; private ParserActionTester parserActionTester; @BeforeEach void setup() throws IOException { - zcode.addModule(new ZcodeCoreModule()); + zscript.addModule(new ZscriptCoreModule()); outStream = new StringWriterOutStream(); - parserActionTester = new ParserActionTester(zcode, buffer, tokenizer, parser, outStream); + parserActionTester = new ParserActionTester(zscript, buffer, tokenizer, parser, outStream); } @Test diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/ZcodeEntityController.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/ZcodeEntityController.java index 4047cdabf..4adb80a75 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/ZcodeEntityController.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/ZcodeEntityController.java @@ -8,11 +8,11 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import net.zscript.javareceiver.core.Zcode; +import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZcodeChannel; import net.zscript.javareceiver.modules.ZcodeModule; -import net.zscript.javareceiver.modules.core.ZcodeCoreModule; -import net.zscript.javareceiver.modules.outerCore.ZcodeOuterCoreModule; +import net.zscript.javareceiver.modules.core.ZscriptCoreModule; +import net.zscript.javareceiver.modules.outerCore.ZscriptOuterCoreModule; import net.zscript.javareceiver.notifications.ZcodeNotificationSource; import net.zscript.javasimulator.BlankCommunicationResponse; import net.zscript.javasimulator.CommunicationPacket; @@ -27,7 +27,7 @@ public class ZcodeEntityController extends EntityController { private final ExecutorService interruptExec = Executors.newSingleThreadExecutor(); private final Thread mainCurrent = findCurrentMain(); private final Thread interruptCurrent = findCurrentInterrupt(); - private final Zcode zcode = new Zcode(); + private final Zscript zscript = new Zscript(); private volatile boolean hasNonWait = false; private Thread findCurrentMain() { @@ -113,7 +113,7 @@ private class ProgressForever implements Runnable { @Override public void run() { try { - hasNonWait = zcode.progress(); + hasNonWait = zscript.progress(); } catch (Exception e) { hasNonWait = false; e.printStackTrace(); @@ -133,8 +133,8 @@ public boolean hasActivity() { } public ZcodeEntityController() { - addModule(new ZcodeCoreModule()); - addModule(new ZcodeOuterCoreModule()); + addModule(new ZscriptCoreModule()); + addModule(new ZscriptOuterCoreModule()); mainExec.submit(new ProgressForever()); } @@ -152,11 +152,11 @@ public void add(ZcodeSimulatorConsumer consumer, } public void addChannel(ZcodeChannel channel) { - switchToMainThread(() -> zcode.addChannel(channel)); + switchToMainThread(() -> zscript.addChannel(channel)); } public void addModule(ZcodeModule module) { - switchToMainThread(() -> zcode.addModule(module)); + switchToMainThread(() -> zscript.addModule(module)); } @SuppressWarnings("unchecked") @@ -182,6 +182,6 @@ public > Communic } public void add(ZcodeNotificationSource notificationSource) { - switchToMainThread(() -> zcode.addNotificationSource(notificationSource)); + switchToMainThread(() -> zscript.addNotificationSource(notificationSource)); } } diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cChannel.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cChannel.java index 3c78112d5..79529b339 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cChannel.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cChannel.java @@ -9,7 +9,7 @@ import net.zscript.javareceiver.core.ZcodeAbstractOutStream; import net.zscript.javareceiver.core.ZcodeChannel; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.tokenizer.ZcodeTokenBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenRingBuffer; import net.zscript.javareceiver.tokenizer.ZcodeTokenizer; @@ -148,13 +148,13 @@ public > CommunicationRespo } @Override - public void channelInfo(ZcodeCommandContext ctx) { + public void channelInfo(CommandContext ctx) { // TODO Auto-generated method stub } @Override - public void channelSetup(ZcodeCommandContext ctx) { + public void channelSetup(CommandContext ctx) { // TODO Auto-generated method stub } diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cModule.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cModule.java index 281699f8c..fb04cbce1 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cModule.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cModule.java @@ -4,9 +4,9 @@ import java.util.List; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.AddressingContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javareceiver.modules.ZcodeModule; import net.zscript.javareceiver.notifications.ZcodeNotificationSource; import net.zscript.javasimulator.Entity; @@ -35,7 +35,7 @@ public int getModuleID() { } @Override - public void execute(ZcodeCommandContext ctx, int command) { + public void execute(CommandContext ctx, int command) { switch (command) { case 0: ZcodeI2cCapabilitiesCommand.execute(ctx, entity); @@ -51,13 +51,13 @@ public void execute(ZcodeCommandContext ctx, int command) { break; default: - ctx.status(ZcodeStatus.COMMAND_NOT_FOUND); + ctx.status(ZscriptStatus.COMMAND_NOT_FOUND); break; } } @Override - public void address(ZcodeAddressingContext ctx) { + public void address(AddressingContext ctx) { ZcodeI2cAddressAction.execute(ctx, this); } diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cNotificationHandler.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cNotificationHandler.java index 21388c148..a64088c4c 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cNotificationHandler.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/I2cNotificationHandler.java @@ -5,7 +5,7 @@ import net.zscript.javareceiver.core.ZcodeCommandOutStream; import net.zscript.javareceiver.core.ZcodeLockSet; import net.zscript.javareceiver.core.ZcodeOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; +import net.zscript.javareceiver.core.ZscriptStatus; import net.zscript.javareceiver.notifications.ZcodeNotificationSource; import net.zscript.javareceiver.tokenizer.Zchars; import net.zscript.javasimulator.BlankCommunicationResponse; @@ -97,7 +97,7 @@ public boolean notification(Entity entity, ZcodeOutStream out, int i, boolean is I2cResponse addrRespTmp = (I2cResponse) entity.getConnection(I2cProtocolCategory.class, i).sendMessage(entity, new I2cReceivePacket(SmBusAlertConnection.ALERT_ADDRESS, 2)); if (!addrRespTmp.worked()) { if (isAddressed) { - commandOut.writeField('S', ZcodeStatus.ADDRESS_NOT_FOUND); + commandOut.writeField('S', ZscriptStatus.ADDRESS_NOT_FOUND); } else { commandOut.writeField('P', i); } @@ -132,7 +132,7 @@ public boolean notification(Entity entity, ZcodeOutStream out, int i, boolean is if (!respTmp.worked()) { out.endSequence(); commandOut.writeField('!', 0x50); - commandOut.writeField('S', ZcodeStatus.ADDRESS_NOT_FOUND); + commandOut.writeField('S', ZscriptStatus.ADDRESS_NOT_FOUND); break; } data = ((I2cReceiveResponse) respTmp).getData(); diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cAddressAction.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cAddressAction.java index b3218e2fc..9e3092da1 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cAddressAction.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cAddressAction.java @@ -3,8 +3,8 @@ import java.util.Iterator; import java.util.Optional; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeAddressingContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.AddressingContext; import net.zscript.javareceiver.tokenizer.OptIterator; import net.zscript.javasimulator.Connection; import net.zscript.javasimulator.Entity; @@ -14,34 +14,34 @@ import net.zscript.javasimulator.connections.i2c.I2cSendPacket; public class ZcodeI2cAddressAction { - public static void execute(ZcodeAddressingContext ctx, I2cModule module) { + public static void execute(AddressingContext ctx, I2cModule module) { Entity entity = module.getEntity(); OptIterator it = ctx.getAddressSegments(); if (!it.next().isPresent()) { - ctx.status(ZcodeStatus.INTERNAL_ERROR); + ctx.status(ZscriptStatus.INTERNAL_ERROR); return; } Optional oint = it.next(); if (!oint.isPresent()) { - ctx.status(ZcodeStatus.INTERNAL_ERROR); + ctx.status(ZscriptStatus.INTERNAL_ERROR); return; } int port = oint.get(); oint = it.next(); if (!oint.isPresent()) { - ctx.status(ZcodeStatus.INTERNAL_ERROR); + ctx.status(ZscriptStatus.INTERNAL_ERROR); return; } boolean tenBit = (port & 0x8000) != 0; port &= ~0x8000; int addr = oint.get(); if (port >= entity.countConnection(I2cProtocolCategory.class)) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } if (!tenBit && addr >= 128 || addr >= 1024) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } @@ -55,7 +55,7 @@ public static void execute(ZcodeAddressingContext ctx, I2cModule module) { I2cResponse resp = (I2cResponse) connection.sendMessage(entity, new I2cSendPacket(new I2cAddress(tenBit, addr), module.getBaud(port), true, data)); if (!resp.worked()) { - ctx.status(ZcodeStatus.ADDRESS_NOT_FOUND); + ctx.status(ZscriptStatus.ADDRESS_NOT_FOUND); return; } } diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cCapabilitiesCommand.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cCapabilitiesCommand.java index d46975ff7..79a04ac7d 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cCapabilitiesCommand.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cCapabilitiesCommand.java @@ -1,13 +1,13 @@ package net.zscript.javasimulator.zcode.i2c; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javasimulator.Entity; import net.zscript.javasimulator.connections.i2c.I2cProtocolCategory; public class ZcodeI2cCapabilitiesCommand { - public static void execute(ZcodeCommandContext ctx, Entity entity) { + public static void execute(CommandContext ctx, Entity entity) { ZcodeCommandOutStream out = ctx.getOutStream(); out.writeField('C', 0x0f); out.writeField('N', 0); diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cReadCommand.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cReadCommand.java index 6c739ddc0..61d4b8725 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cReadCommand.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cReadCommand.java @@ -3,8 +3,8 @@ import java.util.OptionalInt; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javasimulator.Connection; import net.zscript.javasimulator.Entity; import net.zscript.javasimulator.connections.i2c.I2cAddress; @@ -15,7 +15,7 @@ public class ZcodeI2cReadCommand { - public static void execute(ZcodeCommandContext ctx, I2cModule module) { + public static void execute(CommandContext ctx, I2cModule module) { Entity entity = module.getEntity(); ZcodeCommandOutStream out = ctx.getOutStream(); OptionalInt addrOpt = ctx.getField((byte) 'A'); @@ -23,15 +23,15 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { OptionalInt lengthOpt = ctx.getField((byte) 'L'); if (addrOpt.isEmpty()) { - ctx.status(ZcodeStatus.MISSING_KEY); + ctx.status(ZscriptStatus.MISSING_KEY); return; } if (portOpt.isEmpty()) { - ctx.status(ZcodeStatus.MISSING_KEY); + ctx.status(ZscriptStatus.MISSING_KEY); return; } if (lengthOpt.isEmpty()) { - ctx.status(ZcodeStatus.MISSING_KEY); + ctx.status(ZscriptStatus.MISSING_KEY); return; } int addr = addrOpt.getAsInt(); @@ -40,11 +40,11 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { int attempts = ctx.getField((byte) 'T', 1); boolean tenBit = ctx.hasField((byte) 'N'); if (port >= entity.countConnection(I2cProtocolCategory.class)) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } if (!tenBit && addr >= 128 || addr >= 1024) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } @@ -59,7 +59,7 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { out.writeField('T', i); if (resp.addressNack()) { out.writeField('I', 2); - ctx.status(ZcodeStatus.COMMAND_NO_TARGET); + ctx.status(ZscriptStatus.COMMAND_NO_TARGET); } else { out.writeField('I', 0); I2cReceiveResponse recResp = (I2cReceiveResponse) resp; diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSendCommand.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSendCommand.java index 17ed50c35..88821d77b 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSendCommand.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSendCommand.java @@ -3,8 +3,8 @@ import java.util.OptionalInt; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javasimulator.Connection; import net.zscript.javasimulator.Entity; import net.zscript.javasimulator.connections.i2c.I2cAddress; @@ -14,18 +14,18 @@ public class ZcodeI2cSendCommand { - public static void execute(ZcodeCommandContext ctx, I2cModule module) { + public static void execute(CommandContext ctx, I2cModule module) { Entity entity = module.getEntity(); ZcodeCommandOutStream out = ctx.getOutStream(); OptionalInt addrOpt = ctx.getField((byte) 'A'); OptionalInt portOpt = ctx.getField((byte) 'P'); if (addrOpt.isEmpty()) { - ctx.status(ZcodeStatus.MISSING_KEY); + ctx.status(ZscriptStatus.MISSING_KEY); return; } if (portOpt.isEmpty()) { - ctx.status(ZcodeStatus.MISSING_KEY); + ctx.status(ZscriptStatus.MISSING_KEY); return; } int addr = addrOpt.getAsInt(); @@ -34,11 +34,11 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { boolean tenBit = ctx.hasField((byte) 'N'); byte[] data = ctx.getBigFieldData(); if (port >= entity.countConnection(I2cProtocolCategory.class)) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } if (!tenBit && addr >= 128 || addr >= 1024) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } Connection connection = entity.getConnection(I2cProtocolCategory.class, port); @@ -52,12 +52,12 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { out.writeField('T', i); if (resp.addressNack()) { out.writeField('I', 2); - ctx.status(ZcodeStatus.COMMAND_NO_TARGET); + ctx.status(ZscriptStatus.COMMAND_NO_TARGET); return; } if (!resp.worked()) { out.writeField('I', 1); - ctx.status(ZcodeStatus.COMMAND_DATA_NOT_TRANSMITTED); + ctx.status(ZscriptStatus.COMMAND_DATA_NOT_TRANSMITTED); return; } else { out.writeField('I', 0); diff --git a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSetupCommand.java b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSetupCommand.java index da3086747..4c7994230 100644 --- a/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSetupCommand.java +++ b/simulator/zscript-simulator-jvm/src/main/java/net/zscript/javasimulator/zcode/i2c/ZcodeI2cSetupCommand.java @@ -3,17 +3,17 @@ import java.util.OptionalInt; import net.zscript.javareceiver.core.ZcodeCommandOutStream; -import net.zscript.javareceiver.core.ZcodeStatus; -import net.zscript.javareceiver.execution.ZcodeCommandContext; +import net.zscript.javareceiver.core.ZscriptStatus; +import net.zscript.javareceiver.execution.CommandContext; import net.zscript.javasimulator.connections.i2c.I2cProtocolCategory; public class ZcodeI2cSetupCommand { - public static void execute(ZcodeCommandContext ctx, I2cModule module) { + public static void execute(CommandContext ctx, I2cModule module) { ZcodeCommandOutStream out = ctx.getOutStream(); OptionalInt portOpt = ctx.getField((byte) 'P'); if (portOpt.isPresent() && portOpt.getAsInt() >= module.getEntity().countConnection(I2cProtocolCategory.class)) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } if (portOpt.isPresent()) { @@ -24,7 +24,7 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { OptionalInt freqOpt = ctx.getField((byte) 'F'); if (freqOpt.isPresent()) { if (freqOpt.getAsInt() > 3) { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } int freq = freqOpt.getAsInt(); @@ -38,7 +38,7 @@ public static void execute(ZcodeCommandContext ctx, I2cModule module) { } else if (freq == 3) { baud = 1000_000; } else { - ctx.status(ZcodeStatus.VALUE_OUT_OF_RANGE); + ctx.status(ZscriptStatus.VALUE_OUT_OF_RANGE); return; } if (portOpt.isPresent()) {