From aa6f12f33689001e0529dd331182dd90487771d1 Mon Sep 17 00:00:00 2001 From: Willem Date: Thu, 16 Jan 2025 16:06:38 +0100 Subject: [PATCH] Added NCR1632 embedded bank reset feature --- .../fc18/zion7/FourCornerZionStenoLexer.java | 19 +++++++++++-- .../zion7/FourCornerZionStenoLexerFire.java | 10 +++++-- .../java/org/x4o/fc18/zion7/LexerNCRTest.java | 27 ++++++++++++++----- .../org/x4o/fc18/zion7/TestFireWalker.java | 15 ++++++++--- 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java index e4fa576..5163581 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java @@ -304,6 +304,7 @@ public class FourCornerZionStenoLexer { private void handlePoints(List slicedPoints) { bankReset(); boolean magicSparkler = true; + boolean requestBankReset = false; for (Integer cakePoint : slicedPoints) { if (cakePoint >= FourCornerDotCake.FC_NCR1632_XD.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_XD.getStop()) { int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_XD.getStart(); @@ -314,15 +315,29 @@ public class FourCornerZionStenoLexer { int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_XN.getStart(); numeratorBank[numeratorX / 512] = numeratorX % 512; + // highest number, 1st select + enable request, if second than reset bank + if (cakePoint == FourCornerDotCake.FC_NCR1632_XN.getStop()) { + if (requestBankReset) { + requestBankReset = false; + magicSparkler = false; // if EOF ends with bank reset, ignore + fireSignals.fireStateNCR1632BankReset(); + bankReset(); + continue; + } + requestBankReset = true; + } else { + requestBankReset = false; + } + if (cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStart() + 512) { magicSparkler = true; continue; // Only fire fraction on lowest value select - } + } else bankFire(); magicSparkler = false; } if (magicSparkler) { - fireSignals.fireStateNCR1632Sparkler(); + fireSignals.fireStateNCR1632BankSparkler(); bankFire(); } } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java index 65143b6..1e8b14b 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexerFire.java @@ -34,7 +34,9 @@ public interface FourCornerZionStenoLexerFire { void fireStateScanner(int blockStart, int blockStop, int cakePoint); - void fireStateNCR1632Sparkler(); + void fireStateNCR1632BankSparkler(); + + void fireStateNCR1632BankReset(); interface Adapter extends FourCornerZionStenoLexerFire { @@ -51,7 +53,11 @@ public interface FourCornerZionStenoLexerFire { } @Override - default void fireStateNCR1632Sparkler() { + default void fireStateNCR1632BankSparkler() { + } + + @Override + default void fireStateNCR1632BankReset() { } } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java index 519f023..ac27829 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java @@ -46,22 +46,35 @@ public class LexerNCRTest { TestFireWalker fireWalker = new TestFireWalker(); FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true); lexer.withFireSignals(fireWalker); + List cdc = new ArrayList<>(); cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*3) + 1); /// auto NXX_001 - cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); - - Assertions.assertEquals(0, fireWalker.ncrMagicSparks); + Assertions.assertEquals(0, fireWalker.ncr1632BankSparkler); lexer.read(cdc); - Assertions.assertEquals(1, fireWalker.ncrMagicSparks); + Assertions.assertEquals(1, fireWalker.ncr1632BankSparkler); + cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); // the print above auto value + next test cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // normal NXX_123 cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*4) + 2); /// auto NXX_123 + this - fireWalker.reset(); lexer.read(cdc); - Assertions.assertEquals(2, fireWalker.ncrMagicSparks); + Assertions.assertEquals(2, fireWalker.ncr1632BankSparkler); - Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); + Assertions.assertEquals(0, fireWalker.ncr1632BankReset); + cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); // the print above auto value + next test (normal bank reset) + cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() - 1 + 11); + cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*3) + 12); + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*4) + 13); + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*5) + 14); + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // and one which prints + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStop()); + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStop()); // embedded bank reset + cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // normal NXX_123 + fireWalker.reset(); + lexer.read(cdc); + Assertions.assertEquals(1, fireWalker.ncr1632BankReset); + + Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇¹²³/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } @Test diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java index 70992b9..db8edf0 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/TestFireWalker.java @@ -35,7 +35,8 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter { int scanBlockStart; int scanBlockStop; int scanCakePoint; - int ncrMagicSparks; + int ncr1632BankSparkler; + int ncr1632BankReset; public TestFireWalker() { reset(); @@ -45,7 +46,8 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter { currentLine = 0; currentColumn = 0; scanBlockStart = 0; - ncrMagicSparks = 0; + ncr1632BankSparkler = 0; + ncr1632BankReset = 0; } @Override @@ -66,7 +68,12 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter { } @Override - public void fireStateNCR1632Sparkler() { - ncrMagicSparks++; + public void fireStateNCR1632BankSparkler() { + ncr1632BankSparkler++; + } + + @Override + public void fireStateNCR1632BankReset() { + ncr1632BankReset++; } }