From cbe61cc9b1b8dce4e6e2d72d6d14c2957791f0b8 Mon Sep 17 00:00:00 2001 From: susanw1 Date: Tue, 1 Aug 2023 23:15:21 +0100 Subject: [PATCH] [#72] Zcode filenames to Zscript --- ...seQueue.java => CommandResponseQueue.java} | 30 ++++++------ ...System.java => CommandResponseSystem.java} | 6 +-- ...tem.java => ResponseAddressingSystem.java} | 16 +++---- ...esponseParser.java => ResponseParser.java} | 22 ++++----- ...{ZcodeAddress.java => ZscriptAddress.java} | 18 +++---- ...Connection.java => ZscriptConnection.java} | 2 +- ...odeAbortCommand.java => AbortCommand.java} | 4 +- ...eAndSeqElement.java => AndSeqElement.java} | 26 +++++----- ...odeBlankCommand.java => BlankCommand.java} | 8 ++-- .../zcodeApi/CommandSeqElement.java | 12 ++--- ...ailureCommand.java => FailureCommand.java} | 8 ++-- ...odeOrSeqElement.java => OrSeqElement.java} | 6 +-- ...{ZcodeCommand.java => ZscriptCommand.java} | 48 +++++++++---------- ...uilder.java => ZscriptCommandBuilder.java} | 26 +++++----- ...codeResponse.java => ZscriptResponse.java} | 2 +- ...ener.java => ZscriptResponseListener.java} | 6 +-- ...va => ZscriptUnparsedCommandResponse.java} | 4 +- .../LocalZscriptConnection.java | 4 +- .../javaclient/responseParser/Main2.java | 12 ++--- .../DemoActivateCommandBuilder.java | 12 ++--- .../DemoCapabilitiesCommandBuilder.java | 12 ++--- 21 files changed, 142 insertions(+), 142 deletions(-) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/{ZcodeCommandResponseQueue.java => CommandResponseQueue.java} (85%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/{ZcodeCommandResponseSystem.java => CommandResponseSystem.java} (60%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/{ZcodeResponseAddressingSystem.java => ResponseAddressingSystem.java} (52%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/{ZcodeResponseParser.java => ResponseParser.java} (90%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/{ZcodeAddress.java => ZscriptAddress.java} (59%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/{ZcodeConnection.java => ZscriptConnection.java} (81%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeAbortCommand.java => AbortCommand.java} (91%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeAndSeqElement.java => AndSeqElement.java} (75%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeBlankCommand.java => BlankCommand.java} (85%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeFailureCommand.java => FailureCommand.java} (86%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeOrSeqElement.java => OrSeqElement.java} (84%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeCommand.java => ZscriptCommand.java} (63%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeCommandBuilder.java => ZscriptCommandBuilder.java} (84%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeResponse.java => ZscriptResponse.java} (56%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeResponseListener.java => ZscriptResponseListener.java} (60%) rename receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/{ZcodeUnparsedCommandResponse.java => ZscriptUnparsedCommandResponse.java} (97%) diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeCommandResponseQueue.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/CommandResponseQueue.java similarity index 85% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeCommandResponseQueue.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/CommandResponseQueue.java index b38cbbec7..28475739f 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeCommandResponseQueue.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/CommandResponseQueue.java @@ -8,16 +8,16 @@ import java.util.Queue; import java.util.function.Consumer; -import net.zscript.javaclient.responseParser.ZcodeResponseParser.ResponseHeader; +import net.zscript.javaclient.responseParser.ResponseParser.ResponseHeader; import net.zscript.javaclient.zcodeApi.CommandSeqElement; -import net.zscript.javaclient.zcodeApi.ZcodeCommandBuilder; +import net.zscript.javaclient.zcodeApi.ZscriptCommandBuilder; -public class ZcodeCommandResponseQueue implements ZcodeCommandResponseSystem { +public class CommandResponseQueue implements CommandResponseSystem { private static final int MAX_SENT = 10; - private final ZcodeResponseAddressingSystem addrSystem = new ZcodeResponseAddressingSystem(this); + private final ResponseAddressingSystem addrSystem = new ResponseAddressingSystem(this); - private ZcodeConnection connection; + private ZscriptConnection connection; private interface CommandEntry { byte[] compile(); @@ -37,7 +37,7 @@ public CommandSeqElEntry(final CommandSeqElement cmdSeq, final int echo) { @Override public byte[] compile() { // TODO: decide on how locking will work... - byte[] echoF = ZcodeCommandBuilder.writeField((byte) '_', echo); + byte[] echoF = ZscriptCommandBuilder.writeField((byte) '_', echo); byte[] startData = cmdSeq.compile(false); ByteArrayOutputStream str = new ByteArrayOutputStream(startData.length + echoF.length + 1); @@ -52,7 +52,7 @@ public byte[] compile() { } public void callback(final byte[] received) { - ZcodeResponseParser.parseFullResponse(cmdSeq, received); + ResponseParser.parseFullResponse(cmdSeq, received); } public int getEcho() { @@ -67,9 +67,9 @@ public boolean canBePipelined() { private class AddrCommandSeqElEntry implements CommandEntry { private final byte[] cmdSeq; - private final ZcodeAddress addr; + private final ZscriptAddress addr; - public AddrCommandSeqElEntry(final byte[] cmdSeq, final ZcodeAddress addr) { + public AddrCommandSeqElEntry(final byte[] cmdSeq, final ZscriptAddress addr) { this.cmdSeq = cmdSeq; this.addr = addr; } @@ -81,7 +81,7 @@ public byte[] compile() { try { boolean isFirst = true; for (int i : addr.getAddr()) { - str.write(ZcodeCommandBuilder.writeField((byte) (isFirst ? '@' : '.'), i)); + str.write(ZscriptCommandBuilder.writeField((byte) (isFirst ? '@' : '.'), i)); isFirst = false; } str.write(cmdSeq); @@ -127,10 +127,10 @@ public boolean canBePipelined() { private int currentEcho = 0; private boolean canPipeline = true; - public ZcodeCommandResponseQueue(ZcodeConnection connection) { + public CommandResponseQueue(ZscriptConnection connection) { this.connection = connection; connection.onReceive(resp -> { - ResponseHeader header = ZcodeResponseParser.parseResponseHeader(resp); + ResponseHeader header = ResponseParser.parseResponseHeader(resp); if (header.getAddr().length == 0) { callback(resp, header.getEcho(), header.getType()); } else { @@ -140,7 +140,7 @@ public ZcodeCommandResponseQueue(ZcodeConnection connection) { } @Override - public void send(final ZcodeAddress addr, final byte[] data) { + public void send(final ZscriptAddress addr, final byte[] data) { if (sent.size() < MAX_SENT && canPipeline) { AddrCommandSeqElEntry el = new AddrCommandSeqElEntry(data, addr); sent.add(el); @@ -211,8 +211,8 @@ private void callback(final byte[] response, int echo, int respType) { } @Override - public ZcodeResponseAddressingSystem getResponseAddressingSystem() { - return new ZcodeResponseAddressingSystem(this); + public ResponseAddressingSystem getResponseAddressingSystem() { + return new ResponseAddressingSystem(this); } } \ No newline at end of file diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeCommandResponseSystem.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/CommandResponseSystem.java similarity index 60% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeCommandResponseSystem.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/CommandResponseSystem.java index 3b68e1b18..3bc936e99 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeCommandResponseSystem.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/CommandResponseSystem.java @@ -4,12 +4,12 @@ import net.zscript.javaclient.zcodeApi.CommandSeqElement; -public interface ZcodeCommandResponseSystem { +public interface CommandResponseSystem { void send(CommandSeqElement seq); - void send(ZcodeAddress addr, byte[] data); + void send(ZscriptAddress addr, byte[] data); void send(byte[] zcode, Consumer callback); - ZcodeResponseAddressingSystem getResponseAddressingSystem(); + ResponseAddressingSystem getResponseAddressingSystem(); } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeResponseAddressingSystem.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ResponseAddressingSystem.java similarity index 52% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeResponseAddressingSystem.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ResponseAddressingSystem.java index 2c8cb5e54..a09c14b4b 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeResponseAddressingSystem.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ResponseAddressingSystem.java @@ -4,17 +4,17 @@ import java.util.Map; import java.util.function.Consumer; -public class ZcodeResponseAddressingSystem { - private final ZcodeCommandResponseSystem parent; - private final Map> addressResp = new HashMap<>(); - private final Map addressConnection = new HashMap<>(); +public class ResponseAddressingSystem { + private final CommandResponseSystem parent; + private final Map> addressResp = new HashMap<>(); + private final Map addressConnection = new HashMap<>(); - public ZcodeResponseAddressingSystem(ZcodeCommandResponseSystem parent) { + public ResponseAddressingSystem(CommandResponseSystem parent) { this.parent = parent; } - public ZcodeConnection getAddressConnection(ZcodeAddress addr) { - return addressConnection.computeIfAbsent(addr, a -> new ZcodeConnection() { + public ZscriptConnection getAddressConnection(ZscriptAddress addr) { + return addressConnection.computeIfAbsent(addr, a -> new ZscriptConnection() { @Override public void send(byte[] data) { parent.send(addr, data); @@ -28,7 +28,7 @@ public void onReceive(Consumer handler) { } public void response(int[] addr, byte[] received) { - addressResp.get(new ZcodeAddress(addr)).accept(received); + addressResp.get(new ZscriptAddress(addr)).accept(received); } } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeResponseParser.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ResponseParser.java similarity index 90% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeResponseParser.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ResponseParser.java index de446ea4f..fbcc82cc7 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ZcodeResponseParser.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/responseParser/ResponseParser.java @@ -7,9 +7,9 @@ import java.util.Set; import net.zscript.javaclient.zcodeApi.CommandSeqElement; -import net.zscript.javaclient.zcodeApi.ZcodeCommand; -import net.zscript.javaclient.zcodeApi.ZcodeUnparsedCommandResponse; -import net.zscript.javaclient.zcodeApi.ZcodeCommand.ZcodeSequencePath; +import net.zscript.javaclient.zcodeApi.ZscriptCommand; +import net.zscript.javaclient.zcodeApi.ZscriptUnparsedCommandResponse; +import net.zscript.javaclient.zcodeApi.ZscriptCommand.ZcodeSequencePath; import net.zscript.javareceiver.tokenizer.OptIterator; import net.zscript.javareceiver.tokenizer.TokenBuffer; import net.zscript.javareceiver.tokenizer.TokenExtendingBuffer; @@ -17,7 +17,7 @@ import net.zscript.javareceiver.tokenizer.TokenBuffer.TokenReader; import net.zscript.javareceiver.tokenizer.TokenBuffer.TokenReader.ReadToken; -public class ZcodeResponseParser { +public class ResponseParser { static class ResponseHeader { private final int[] addr; private final int type; @@ -146,10 +146,10 @@ public static void parseFullResponse(final CommandSeqElement command, final byte } private static void matchMarkers(final CommandSeqElement command, final List markers, final List tokenAfterMarkers) { - ZcodeCommand current = null; - ZcodeSequencePath successPath = ZcodeCommand.findFirstCommand(command); - ZcodeSequencePath failPath = ZcodeCommand.findFirstCommand(command); - Set sentResponses = new HashSet<>(); + ZscriptCommand current = null; + ZcodeSequencePath successPath = ZscriptCommand.findFirstCommand(command); + ZcodeSequencePath failPath = ZscriptCommand.findFirstCommand(command); + Set sentResponses = new HashSet<>(); int offset = 0; @@ -196,11 +196,11 @@ private static void matchMarkers(final CommandSeqElement command, final List handler); diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeAbortCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/AbortCommand.java similarity index 91% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeAbortCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/AbortCommand.java index 60ec19df7..ee80f50d1 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeAbortCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/AbortCommand.java @@ -2,7 +2,7 @@ import java.nio.charset.StandardCharsets; -public class ZcodeAbortCommand extends ZcodeCommand { +public class AbortCommand extends ZscriptCommand { @Override public CommandSeqElement thenFail() { @@ -65,7 +65,7 @@ public boolean isCommand() { } @Override - public void response(ZcodeUnparsedCommandResponse resp) { + public void response(ZscriptUnparsedCommandResponse resp) { } @Override diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeAndSeqElement.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/AndSeqElement.java similarity index 75% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeAndSeqElement.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/AndSeqElement.java index eebb320cb..dfceec5f6 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeAndSeqElement.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/AndSeqElement.java @@ -6,17 +6,17 @@ import java.util.Iterator; import java.util.List; -public class ZcodeAndSeqElement extends CommandSeqElement { +public class AndSeqElement extends CommandSeqElement { private final List elements; - ZcodeAndSeqElement(List elements) { + AndSeqElement(List elements) { this.elements = elements; for (CommandSeqElement el : elements) { el.setParent(this); } } - ZcodeAndSeqElement(CommandSeqElement el1, CommandSeqElement el2) { + AndSeqElement(CommandSeqElement el1, CommandSeqElement el2) { this.elements = new ArrayList<>(); elements.add(el1); elements.add(el2); @@ -27,12 +27,12 @@ public class ZcodeAndSeqElement extends CommandSeqElement { @Override public CommandSeqElement andThen(CommandSeqElement next) { List newEls = new ArrayList<>(elements); - if (next.getClass() == ZcodeAndSeqElement.class) { - newEls.addAll(((ZcodeAndSeqElement) next).elements); + if (next.getClass() == AndSeqElement.class) { + newEls.addAll(((AndSeqElement) next).elements); } else { newEls.add(next); } - return new ZcodeAndSeqElement(newEls); + return new AndSeqElement(newEls); } @Override @@ -54,25 +54,25 @@ public boolean isCommand() { public CommandSeqElement reEvaluate() { List els = new ArrayList<>(); for (CommandSeqElement element : elements) { - if (element.getClass() == ZcodeFailureCommand.class) { + if (element.getClass() == FailureCommand.class) { els.add(element); break; - } else if (element.getClass() == ZcodeAbortCommand.class) { + } else if (element.getClass() == AbortCommand.class) { els.add(element); break; - } else if (element.getClass() == ZcodeAndSeqElement.class) { - els.addAll(((ZcodeAndSeqElement) element).elements); - } else if (element.getClass() == ZcodeBlankCommand.class) { + } else if (element.getClass() == AndSeqElement.class) { + els.addAll(((AndSeqElement) element).elements); + } else if (element.getClass() == BlankCommand.class) { } else { els.add(element.reEvaluate()); } } if (els.size() == 0) { - return new ZcodeBlankCommand(); + return new BlankCommand(); } else if (els.size() == 1) { return els.get(0); } - return new ZcodeAndSeqElement(els); + return new AndSeqElement(els); } @Override diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeBlankCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/BlankCommand.java similarity index 85% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeBlankCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/BlankCommand.java index 9ddfa9812..3609d5a69 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeBlankCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/BlankCommand.java @@ -1,15 +1,15 @@ package net.zscript.javaclient.zcodeApi; -public class ZcodeBlankCommand extends ZcodeCommand { +public class BlankCommand extends ZscriptCommand { @Override public CommandSeqElement thenFail() { - return new ZcodeFailureCommand(); + return new FailureCommand(); } @Override public CommandSeqElement thenAbort() { - return new ZcodeAbortCommand(); + return new AbortCommand(); } @Override @@ -63,7 +63,7 @@ public byte[] compile(boolean includeParens) { } @Override - public void response(ZcodeUnparsedCommandResponse resp) { + public void response(ZscriptUnparsedCommandResponse resp) { } @Override diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/CommandSeqElement.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/CommandSeqElement.java index 2ff00ecf9..a7496a42b 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/CommandSeqElement.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/CommandSeqElement.java @@ -36,33 +36,33 @@ public static FailureConditional ifFails(CommandSeqElement condition) { } public CommandSeqElement andThen(CommandSeqElement next) { - return new ZcodeAndSeqElement(this, next); + return new AndSeqElement(this, next); } public CommandSeqElement dropFailureCondition() { if (canFail()) { - return onFail(new ZcodeBlankCommand()); + return onFail(new BlankCommand()); } return this; } public CommandSeqElement thenFail() { - return andThen(new ZcodeFailureCommand()); + return andThen(new FailureCommand()); } public CommandSeqElement thenAbort() { - return andThen(new ZcodeAbortCommand()); + return andThen(new AbortCommand()); } public CommandSeqElement onFail(CommandSeqElement next) { if (canFail()) { - return new ZcodeOrSeqElement(this, next); + return new OrSeqElement(this, next); } return this; } public CommandSeqElement abortOnFail() { - return onFail(new ZcodeAbortCommand()); + return onFail(new AbortCommand()); } public SuccessConditional ifSucceeds() { diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeFailureCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/FailureCommand.java similarity index 86% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeFailureCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/FailureCommand.java index aea71d0af..dabb00ecd 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeFailureCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/FailureCommand.java @@ -2,7 +2,7 @@ import java.nio.charset.StandardCharsets; -public class ZcodeFailureCommand extends ZcodeCommand { +public class FailureCommand extends ZscriptCommand { @Override public CommandSeqElement thenFail() { @@ -21,12 +21,12 @@ public CommandSeqElement andThen(CommandSeqElement next) { @Override public CommandSeqElement dropFailureCondition() { - return new ZcodeBlankCommand(); + return new BlankCommand(); } @Override public CommandSeqElement abortOnFail() { - return new ZcodeAbortCommand(); + return new AbortCommand(); } @Override @@ -65,7 +65,7 @@ public byte[] compile(boolean includeParens) { } @Override - public void response(ZcodeUnparsedCommandResponse resp) { + public void response(ZscriptUnparsedCommandResponse resp) { } @Override diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeOrSeqElement.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/OrSeqElement.java similarity index 84% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeOrSeqElement.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/OrSeqElement.java index 8307ccc58..6c2230524 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeOrSeqElement.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/OrSeqElement.java @@ -3,11 +3,11 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -public class ZcodeOrSeqElement extends CommandSeqElement { +public class OrSeqElement extends CommandSeqElement { final CommandSeqElement before; final CommandSeqElement after; - public ZcodeOrSeqElement(CommandSeqElement before, CommandSeqElement after) { + public OrSeqElement(CommandSeqElement before, CommandSeqElement after) { this.before = before; this.after = after; before.setParent(this); @@ -29,7 +29,7 @@ public CommandSeqElement reEvaluate() { if (!before.canFail()) { return before.reEvaluate(); } - return new ZcodeOrSeqElement(before.reEvaluate(), after.reEvaluate()); + return new OrSeqElement(before.reEvaluate(), after.reEvaluate()); } @Override diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeCommand.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptCommand.java similarity index 63% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeCommand.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptCommand.java index 0683f6254..e8507ab48 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeCommand.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptCommand.java @@ -3,12 +3,12 @@ import java.util.ArrayList; import java.util.List; -public abstract class ZcodeCommand extends CommandSeqElement { +public abstract class ZscriptCommand extends CommandSeqElement { public static class ZcodeSequencePath { private final List markers; - private final ZcodeCommand next; + private final ZscriptCommand next; - public ZcodeSequencePath(List markers, ZcodeCommand next) { + public ZcodeSequencePath(List markers, ZscriptCommand next) { this.markers = markers; this.next = next; } @@ -23,34 +23,34 @@ public List getMarkers() { return markers; } - public ZcodeCommand getNext() { + public ZscriptCommand getNext() { return next; } } public abstract void notExecuted(); - public abstract void response(ZcodeUnparsedCommandResponse resp); + public abstract void response(ZscriptUnparsedCommandResponse resp); public static ZcodeSequencePath findFirstCommand(final CommandSeqElement start) { CommandSeqElement current = start; CommandSeqElement prev = null; List markers = new ArrayList<>(); while (!current.isCommand()) { - if (current.getClass() == ZcodeAndSeqElement.class) { + if (current.getClass() == AndSeqElement.class) { prev = current; - current = ((ZcodeAndSeqElement) current).getElements().get(0); - } else if (current.getClass() == ZcodeOrSeqElement.class) { + current = ((AndSeqElement) current).getElements().get(0); + } else if (current.getClass() == OrSeqElement.class) { prev = current; - current = ((ZcodeOrSeqElement) current).before; + current = ((OrSeqElement) current).before; } else { throw new IllegalStateException("Unknown CommandSeqElement: " + current); } - if (current.getClass() == ZcodeOrSeqElement.class && prev.getClass() == ZcodeOrSeqElement.class) { + if (current.getClass() == OrSeqElement.class && prev.getClass() == OrSeqElement.class) { markers.add((byte) '('); } } - return new ZcodeSequencePath(markers, (ZcodeCommand) current); + return new ZcodeSequencePath(markers, (ZscriptCommand) current); } public ZcodeSequencePath findNext() { @@ -59,23 +59,23 @@ public ZcodeSequencePath findNext() { List markers = new ArrayList<>(); while (current != null) { - if (current.getClass() == ZcodeOrSeqElement.class) { - ZcodeOrSeqElement orAncestor = (ZcodeOrSeqElement) current; + if (current.getClass() == OrSeqElement.class) { + OrSeqElement orAncestor = (OrSeqElement) current; if (prev == orAncestor.before) { markers.add((byte) '|'); return new ZcodeSequencePath(markers, findFirstCommand(orAncestor.after)); } - } else if (current.getClass() == ZcodeAndSeqElement.class) { - ZcodeAndSeqElement andAncestor = (ZcodeAndSeqElement) current; + } else if (current.getClass() == AndSeqElement.class) { + AndSeqElement andAncestor = (AndSeqElement) current; if (prev != andAncestor.getElements().get(andAncestor.getElements().size() - 1)) { CommandSeqElement next = andAncestor.getElements().get(andAncestor.getElements().indexOf(prev) + 1); - if (prev.getClass() != ZcodeOrSeqElement.class && next.getClass() != ZcodeOrSeqElement.class) { + if (prev.getClass() != OrSeqElement.class && next.getClass() != OrSeqElement.class) { markers.add((byte) '&'); } return new ZcodeSequencePath(markers, findFirstCommand(next)); } } - if (current.getClass() == ZcodeOrSeqElement.class && current.getParent() != null && current.getParent().getClass() != ZcodeOrSeqElement.class) { + if (current.getClass() == OrSeqElement.class && current.getParent() != null && current.getParent().getClass() != OrSeqElement.class) { markers.add((byte) ')'); } prev = current; @@ -90,14 +90,14 @@ public ZcodeSequencePath findFailPath() { List markers = new ArrayList<>(); while (current != null) { - if (current.getClass() == ZcodeOrSeqElement.class) { - ZcodeOrSeqElement orAncestor = (ZcodeOrSeqElement) current; + if (current.getClass() == OrSeqElement.class) { + OrSeqElement orAncestor = (OrSeqElement) current; if (prev == orAncestor.before) { markers.add((byte) '|'); return new ZcodeSequencePath(markers, findFirstCommand(orAncestor.after)); } } - if (current.getClass() == ZcodeOrSeqElement.class && current.getParent() != null && current.getParent().getClass() != ZcodeOrSeqElement.class) { + if (current.getClass() == OrSeqElement.class && current.getParent() != null && current.getParent().getClass() != OrSeqElement.class) { markers.add((byte) ')'); } prev = current; @@ -112,17 +112,17 @@ public ZcodeSequencePath findSuccessPath() { List markers = new ArrayList<>(); while (current != null) { - if (current.getClass() == ZcodeAndSeqElement.class) { - ZcodeAndSeqElement andAncestor = (ZcodeAndSeqElement) current; + if (current.getClass() == AndSeqElement.class) { + AndSeqElement andAncestor = (AndSeqElement) current; if (prev != andAncestor.getElements().get(andAncestor.getElements().size() - 1)) { CommandSeqElement next = andAncestor.getElements().get(andAncestor.getElements().indexOf(prev) + 1); - if (prev.getClass() != ZcodeOrSeqElement.class && next.getClass() != ZcodeOrSeqElement.class) { + if (prev.getClass() != OrSeqElement.class && next.getClass() != OrSeqElement.class) { markers.add((byte) '&'); } return new ZcodeSequencePath(markers, findFirstCommand(next)); } } - if (current.getClass() == ZcodeOrSeqElement.class && current.getParent() != null && current.getParent().getClass() != ZcodeOrSeqElement.class) { + if (current.getClass() == OrSeqElement.class && current.getParent() != null && current.getParent().getClass() != OrSeqElement.class) { markers.add((byte) ')'); } prev = current; diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeCommandBuilder.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptCommandBuilder.java similarity index 84% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeCommandBuilder.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptCommandBuilder.java index ee5871bc1..0df1c2980 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeCommandBuilder.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptCommandBuilder.java @@ -8,12 +8,12 @@ import java.util.List; import java.util.Map; -public abstract class ZcodeCommandBuilder { - private final List> listeners = new ArrayList<>(); +public abstract class ZscriptCommandBuilder { + private final List> listeners = new ArrayList<>(); private final List bigFields = new ArrayList<>(); private final Map fields = new HashMap<>(); - public class ZcodeBuiltCommand extends ZcodeCommand { + public class ZcodeBuiltCommand extends ZscriptCommand { @Override public CommandSeqElement reEvaluate() { @@ -54,16 +54,16 @@ public byte[] compile(boolean includeParens) { } @Override - public void response(ZcodeUnparsedCommandResponse resp) { + public void response(ZscriptUnparsedCommandResponse resp) { T parsed = parseResponse(resp); - for (ZcodeResponseListener listener : listeners) { + for (ZscriptResponseListener listener : listeners) { listener.accept(parsed); } } @Override public void notExecuted() { - for (ZcodeResponseListener listener : listeners) { + for (ZscriptResponseListener listener : listeners) { listener.notExecuted(); } } @@ -134,11 +134,11 @@ public static byte[] writeField(byte f, int value) { } } - protected ZcodeCommandBuilder setField(char key, int value) { + protected ZscriptCommandBuilder setField(char key, int value) { return setField((byte) key, value); } - protected ZcodeCommandBuilder setField(byte key, int value) { + protected ZscriptCommandBuilder setField(byte key, int value) { if ((key & 0x80) != 0) { throw new IllegalArgumentException("Key not a valid Zcode Command key"); } @@ -146,12 +146,12 @@ protected ZcodeCommandBuilder setField(byte key, int value) { return this; } - protected ZcodeCommandBuilder addBigField(byte[] data) { + protected ZscriptCommandBuilder addBigField(byte[] data) { bigFields.add(new BigField(data, false)); return this; } - protected ZcodeCommandBuilder addBigFieldAsSmallest(byte[] data) { + protected ZscriptCommandBuilder addBigFieldAsSmallest(byte[] data) { int bigFieldPlusLen = data.length * 2 + 1; int bigFieldStrLen = 2 + data.length; for (byte b : data) { @@ -163,16 +163,16 @@ protected ZcodeCommandBuilder addBigFieldAsSmallest(byte[] data) { return this; } - protected ZcodeCommandBuilder addBigField(String data) { + protected ZscriptCommandBuilder addBigField(String data) { bigFields.add(new BigField(data.getBytes(StandardCharsets.UTF_8), true)); return this; } - abstract protected T parseResponse(ZcodeUnparsedCommandResponse resp); + abstract protected T parseResponse(ZscriptUnparsedCommandResponse resp); abstract protected boolean commandCanFail(); - public ZcodeCommandBuilder addResponseListener(ZcodeResponseListener listener) { + public ZscriptCommandBuilder addResponseListener(ZscriptResponseListener listener) { listeners.add(listener); return this; } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeResponse.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptResponse.java similarity index 56% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeResponse.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptResponse.java index 899e82a14..034c602c0 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeResponse.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptResponse.java @@ -1,5 +1,5 @@ package net.zscript.javaclient.zcodeApi; -public interface ZcodeResponse { +public interface ZscriptResponse { } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeResponseListener.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptResponseListener.java similarity index 60% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeResponseListener.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptResponseListener.java index 6fe9f5604..19728a59e 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeResponseListener.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptResponseListener.java @@ -1,14 +1,14 @@ package net.zscript.javaclient.zcodeApi; -public interface ZcodeResponseListener { +public interface ZscriptResponseListener { void accept(T resp); // TODO: call this consistently default void notExecuted() { } - private static ZcodeResponseListener onNotExecuted(Runnable r) { - return new ZcodeResponseListener() { + private static ZscriptResponseListener onNotExecuted(Runnable r) { + return new ZscriptResponseListener() { @Override public void accept(T resp) { } diff --git a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeUnparsedCommandResponse.java b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptUnparsedCommandResponse.java similarity index 97% rename from receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeUnparsedCommandResponse.java rename to receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptUnparsedCommandResponse.java index b7973ad10..2c3f323ff 100644 --- a/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZcodeUnparsedCommandResponse.java +++ b/receivers/jvm/java-receiver-token/src/main/java/net/zscript/javaclient/zcodeApi/ZscriptUnparsedCommandResponse.java @@ -9,11 +9,11 @@ import net.zscript.javareceiver.tokenizer.Zchars; import net.zscript.javareceiver.tokenizer.TokenBuffer.TokenReader.ReadToken; -public class ZcodeUnparsedCommandResponse { +public class ZscriptUnparsedCommandResponse { private final ReadToken first; // TODO: split common code from CommandContext - public ZcodeUnparsedCommandResponse(ReadToken first) { + public ZscriptUnparsedCommandResponse(ReadToken first) { this.first = first; } diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZscriptConnection.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZscriptConnection.java index 3f2ffba96..33a156d0f 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZscriptConnection.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/LocalZscriptConnection.java @@ -7,7 +7,7 @@ import java.util.concurrent.Executors; import java.util.function.Consumer; -import net.zscript.javaclient.responseParser.ZcodeConnection; +import net.zscript.javaclient.responseParser.ZscriptConnection; import net.zscript.javareceiver.core.OutputStreamOutStream; import net.zscript.javareceiver.core.Zscript; import net.zscript.javareceiver.core.ZscriptChannel; @@ -17,7 +17,7 @@ import net.zscript.javareceiver.tokenizer.TokenRingBuffer; import net.zscript.javareceiver.tokenizer.Tokenizer; -public class LocalZscriptConnection implements ZcodeConnection { +public class LocalZscriptConnection implements ZscriptConnection { private final ExecutorService exec = Executors.newSingleThreadExecutor(); private final Queue dataIn = new ArrayDeque<>(); private Consumer handler; diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/Main2.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/Main2.java index 9274de83e..28762131e 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/Main2.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/responseParser/Main2.java @@ -1,14 +1,14 @@ package net.zscript.javaclient.responseParser; -import net.zscript.javaclient.responseParser.ZcodeAddress; -import net.zscript.javaclient.responseParser.ZcodeCommandResponseQueue; -import net.zscript.javaclient.responseParser.ZcodeCommandResponseSystem; +import net.zscript.javaclient.responseParser.ZscriptAddress; +import net.zscript.javaclient.responseParser.CommandResponseQueue; +import net.zscript.javaclient.responseParser.CommandResponseSystem; import net.zscript.javaclient.zcodeApiAttempt.DemoActivateCommandBuilder; import net.zscript.javaclient.zcodeApiAttempt.DemoCapabilitiesCommandBuilder; public class Main2 { public static void main(String[] args) { - ZcodeCommandResponseSystem zcodeOut = new ZcodeCommandResponseQueue(new LocalZscriptConnection()); + CommandResponseSystem zcodeOut = new CommandResponseQueue(new LocalZscriptConnection()); zcodeOut.send(new DemoCapabilitiesCommandBuilder() .setVersionType(DemoCapabilitiesCommandBuilder.PLATFORM_FIRMWARE) .addResponseListener(r -> System.out.println(r.getName())) @@ -19,8 +19,8 @@ public static void main(String[] args) { .andThen(new DemoActivateCommandBuilder() .addResponseListener(r -> System.out.println(r.alreadyActivated())) .build())); - ZcodeCommandResponseSystem zcodeOutAddr = new ZcodeCommandResponseQueue( - zcodeOut.getResponseAddressingSystem().getAddressConnection(ZcodeAddress.from(0x50, 0x0, 0x1))); + CommandResponseSystem zcodeOutAddr = new CommandResponseQueue( + zcodeOut.getResponseAddressingSystem().getAddressConnection(ZscriptAddress.from(0x50, 0x0, 0x1))); zcodeOutAddr.send(new DemoCapabilitiesCommandBuilder() .setVersionType(DemoCapabilitiesCommandBuilder.PLATFORM_FIRMWARE) .addResponseListener(r -> System.out.println(r.getName())) diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoActivateCommandBuilder.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoActivateCommandBuilder.java index f251af60b..9769f2daa 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoActivateCommandBuilder.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoActivateCommandBuilder.java @@ -1,12 +1,12 @@ package net.zscript.javaclient.zcodeApiAttempt; -import net.zscript.javaclient.zcodeApi.ZcodeCommandBuilder; -import net.zscript.javaclient.zcodeApi.ZcodeResponse; -import net.zscript.javaclient.zcodeApi.ZcodeUnparsedCommandResponse; +import net.zscript.javaclient.zcodeApi.ZscriptCommandBuilder; +import net.zscript.javaclient.zcodeApi.ZscriptResponse; +import net.zscript.javaclient.zcodeApi.ZscriptUnparsedCommandResponse; import net.zscript.javaclient.zcodeApiAttempt.DemoActivateCommandBuilder.DemoActivateCommandResponse; -public class DemoActivateCommandBuilder extends ZcodeCommandBuilder { - public class DemoActivateCommandResponse implements ZcodeResponse { +public class DemoActivateCommandBuilder extends ZscriptCommandBuilder { + public class DemoActivateCommandResponse implements ZscriptResponse { private final boolean alreadyActivated; public DemoActivateCommandResponse(boolean alreadyActivated) { @@ -23,7 +23,7 @@ public DemoActivateCommandBuilder() { } @Override - protected DemoActivateCommandResponse parseResponse(ZcodeUnparsedCommandResponse resp) { + protected DemoActivateCommandResponse parseResponse(ZscriptUnparsedCommandResponse resp) { return new DemoActivateCommandResponse(resp.getField('A').get() == 1 ? true : false); } diff --git a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoCapabilitiesCommandBuilder.java b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoCapabilitiesCommandBuilder.java index 0c5fad251..940e1b029 100644 --- a/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoCapabilitiesCommandBuilder.java +++ b/receivers/jvm/java-receiver-token/src/test/java/net/zscript/javaclient/zcodeApiAttempt/DemoCapabilitiesCommandBuilder.java @@ -1,11 +1,11 @@ package net.zscript.javaclient.zcodeApiAttempt; -import net.zscript.javaclient.zcodeApi.ZcodeCommandBuilder; -import net.zscript.javaclient.zcodeApi.ZcodeResponse; -import net.zscript.javaclient.zcodeApi.ZcodeUnparsedCommandResponse; +import net.zscript.javaclient.zcodeApi.ZscriptCommandBuilder; +import net.zscript.javaclient.zcodeApi.ZscriptResponse; +import net.zscript.javaclient.zcodeApi.ZscriptUnparsedCommandResponse; import net.zscript.javaclient.zcodeApiAttempt.DemoCapabilitiesCommandBuilder.DemoCapabilitiesCommandResponse; -public class DemoCapabilitiesCommandBuilder extends ZcodeCommandBuilder { +public class DemoCapabilitiesCommandBuilder extends ZscriptCommandBuilder { public static final int USER_FIRMWARE = 0; public static final int USER_HARDWARE = 1; public static final int PLATFORM_FIRMWARE = 2; @@ -14,7 +14,7 @@ public class DemoCapabilitiesCommandBuilder extends ZcodeCommandBuilder