From dba43eab557ed9827a88d0b4bbc91294e985f40e Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Tue, 14 Oct 2014 18:18:01 +0200 Subject: [PATCH] Major Java rename spree... --- compiler/Java_CodeGen.jrag | 40 ++++++++--------- examples/dynamic/test/DynamicPart.java | 30 ++++++------- examples/dynamic/test/StaticDecoder.java | 6 +-- examples/dynamic/test/StaticEncoder.java | 6 +-- .../dynamic/test/TestLabCommCompiler.java | 28 ++++++------ examples/dynamic/test/TestLabcommGen.java | 34 +++++++------- .../labcommTCPtest/client/TestClient.java | 8 ++-- .../client/TestClientSingleshot.java | 8 ++-- .../labcommTCPtest/server/TestServer.java | 8 ++-- examples/simple/Decoder.java | 6 +-- examples/simple/Decoder06.java | 6 +-- examples/simple/Encoder.java | 6 +-- examples/simple/Encoder06.java | 6 +-- .../tcp/labcommTCPtest/client/TestClient.java | 8 ++-- .../client/TestClientSingleshot.java | 8 ++-- .../labcommTCPtest/server/OneShotServer.java | 6 +-- .../tcp/labcommTCPtest/server/TestServer.java | 8 ++-- examples/user_types/Decoder.java | 6 +-- examples/user_types/Encoder.java | 6 +-- examples/wiki_example/data.java | 28 ++++++------ .../wiki_example/example_decoder_encoder.java | 12 ++--- lib/java/Makefile | 26 +++++------ .../labcomm/{LabComm.java => Constant.java} | 2 +- .../{LabCommDecoder.java => Decoder.java} | 6 +-- ...ecoderChannel.java => DecoderChannel.java} | 26 +++++------ ...oderRegistry.java => DecoderRegistry.java} | 26 +++++------ .../{LabCommEncoder.java => Encoder.java} | 8 ++-- ...ncoderChannel.java => EncoderChannel.java} | 32 +++++++------- ...oderRegistry.java => EncoderRegistry.java} | 18 ++++---- .../control/labcomm/LabCommDispatcher.java | 15 ------- .../lth/control/labcomm/LabCommHandler.java | 4 -- .../{LabCommReader.java => Reader.java} | 2 +- .../labcomm/{LabCommType.java => Sample.java} | 2 +- .../lth/control/labcomm/SampleDispatcher.java | 15 +++++++ .../se/lth/control/labcomm/SampleHandler.java | 4 ++ .../labcomm/{LabCommSample.java => Type.java} | 2 +- .../{LabCommWriter.java => Writer.java} | 2 +- .../se/lth/control/labcomm/WriterWrapper.java | 2 +- .../{LabComm.java => Constant.java} | 2 +- .../{LabCommDecoder.java => Decoder.java} | 6 +-- ...ecoderChannel.java => DecoderChannel.java} | 44 +++++++++---------- ...oderRegistry.java => DecoderRegistry.java} | 26 +++++------ .../{LabCommEncoder.java => Encoder.java} | 8 ++-- ...ncoderChannel.java => EncoderChannel.java} | 28 ++++++------ ...oderRegistry.java => EncoderRegistry.java} | 18 ++++---- .../{LabCommReader.java => Reader.java} | 2 +- .../{LabCommType.java => Sample.java} | 2 +- ...mDispatcher.java => SampleDispatcher.java} | 6 +-- ...LabCommHandler.java => SampleHandler.java} | 4 +- .../{LabCommSample.java => Type.java} | 2 +- .../{LabCommWriter.java => Writer.java} | 2 +- .../control/labcomm2006/WriterWrapper.java | 2 +- test/relay_gen_java.py | 10 ++--- 53 files changed, 314 insertions(+), 314 deletions(-) rename lib/java/se/lth/control/labcomm/{LabComm.java => Constant.java} (97%) rename lib/java/se/lth/control/labcomm/{LabCommDecoder.java => Decoder.java} (78%) rename lib/java/se/lth/control/labcomm/{LabCommDecoderChannel.java => DecoderChannel.java} (81%) rename lib/java/se/lth/control/labcomm/{LabCommDecoderRegistry.java => DecoderRegistry.java} (84%) rename lib/java/se/lth/control/labcomm/{LabCommEncoder.java => Encoder.java} (71%) rename lib/java/se/lth/control/labcomm/{LabCommEncoderChannel.java => EncoderChannel.java} (77%) rename lib/java/se/lth/control/labcomm/{LabCommEncoderRegistry.java => EncoderRegistry.java} (66%) delete mode 100644 lib/java/se/lth/control/labcomm/LabCommDispatcher.java delete mode 100644 lib/java/se/lth/control/labcomm/LabCommHandler.java rename lib/java/se/lth/control/labcomm/{LabCommReader.java => Reader.java} (73%) rename lib/java/se/lth/control/labcomm/{LabCommType.java => Sample.java} (53%) create mode 100644 lib/java/se/lth/control/labcomm/SampleDispatcher.java create mode 100644 lib/java/se/lth/control/labcomm/SampleHandler.java rename lib/java/se/lth/control/labcomm/{LabCommSample.java => Type.java} (51%) rename lib/java/se/lth/control/labcomm/{LabCommWriter.java => Writer.java} (78%) rename lib/java/se/lth/control/labcomm2006/{LabComm.java => Constant.java} (97%) rename lib/java/se/lth/control/labcomm2006/{LabCommDecoder.java => Decoder.java} (78%) rename lib/java/se/lth/control/labcomm2006/{LabCommDecoderChannel.java => DecoderChannel.java} (74%) rename lib/java/se/lth/control/labcomm2006/{LabCommDecoderRegistry.java => DecoderRegistry.java} (84%) rename lib/java/se/lth/control/labcomm2006/{LabCommEncoder.java => Encoder.java} (71%) rename lib/java/se/lth/control/labcomm2006/{LabCommEncoderChannel.java => EncoderChannel.java} (73%) rename lib/java/se/lth/control/labcomm2006/{LabCommEncoderRegistry.java => EncoderRegistry.java} (66%) rename lib/java/se/lth/control/labcomm2006/{LabCommReader.java => Reader.java} (74%) rename lib/java/se/lth/control/labcomm2006/{LabCommType.java => Sample.java} (55%) rename lib/java/se/lth/control/labcomm2006/{LabCommDispatcher.java => SampleDispatcher.java} (50%) rename lib/java/se/lth/control/labcomm2006/{LabCommHandler.java => SampleHandler.java} (51%) rename lib/java/se/lth/control/labcomm2006/{LabCommSample.java => Type.java} (54%) rename lib/java/se/lth/control/labcomm2006/{LabCommWriter.java => Writer.java} (78%) diff --git a/compiler/Java_CodeGen.jrag b/compiler/Java_CodeGen.jrag index b01ff8f..2020b5d 100644 --- a/compiler/Java_CodeGen.jrag +++ b/compiler/Java_CodeGen.jrag @@ -293,7 +293,7 @@ aspect Java_Register { public void Program.Java_emitTypeRegister(Java_env env) { /* - env.println("static void register(LabCommChannel c) {"); + env.println("static void register(Channel c) {"); env.indent(); for (int i = 0; i < getNumDecl(); i++) { getDecl(i).Java_emitTypeRegister(env); @@ -340,11 +340,11 @@ aspect Java_Class { } env.println("import java.io.IOException;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommType;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommEncoder;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDecoder;"); + env.println("import se.lth.control.labcomm"+env.verStr+".Type;"); + env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;"); + env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;"); env.println(); - env.println("public class " + getName() + " implements LabCommType {"); + env.println("public class " + getName() + " implements Type {"); env.println(); env.indent(); getType().Java_emitInstance(env); @@ -380,21 +380,21 @@ aspect Java_Class { } env.println("import java.io.IOException;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDecoder;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommDispatcher;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommEncoder;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommHandler;"); - env.println("import se.lth.control.labcomm"+env.verStr+".LabCommSample;"); + env.println("import se.lth.control.labcomm"+env.verStr+".Decoder;"); + env.println("import se.lth.control.labcomm"+env.verStr+".SampleDispatcher;"); + env.println("import se.lth.control.labcomm"+env.verStr+".Encoder;"); + env.println("import se.lth.control.labcomm"+env.verStr+".SampleHandler;"); + env.println("import se.lth.control.labcomm"+env.verStr+".Sample;"); env.println(); env.print("public class " + getName()); // if(getType().isUserType()) { // env.print(" extends "+getType().getTypeName()); // } - env.println(" implements LabCommSample {"); + env.println(" implements Sample {"); env.println(); env.indent(); getType().Java_emitInstance(env); - env.println("public interface Handler extends LabCommHandler {"); + env.println("public interface Handler extends SampleHandler {"); env.print(" public void handle_" + getName() + "("); if (!isVoid()) { getType().Java_emitType(env); @@ -403,21 +403,21 @@ aspect Java_Class { env.println(") throws Exception;"); env.println("}"); env.println(); - env.println("public static void register(LabCommDecoder d, Handler h) throws IOException {"); + env.println("public static void register(Decoder d, SampleHandler h) throws IOException {"); env.indent(); env.println("d.register(new Dispatcher(), h);"); env.unindent(); env.println("}"); env.println(); - env.println("public static void register(LabCommEncoder e) throws IOException {"); + env.println("public static void register(Encoder e) throws IOException {"); env.indent(); env.println("e.register(new Dispatcher());"); env.unindent(); env.println("}"); env.println(); - env.println("private static class Dispatcher implements LabCommDispatcher {"); + env.println("private static class Dispatcher implements SampleDispatcher {"); env.indent(); env.println(); env.println("public Class getSampleClass() {"); @@ -438,8 +438,8 @@ aspect Java_Class { env.unindent(); env.println("}"); env.println(); - env.println("public void decodeAndHandle(LabCommDecoder d,"); - env.println(" LabCommHandler h) throws Exception {"); + env.println("public void decodeAndHandle(Decoder d,"); + env.println(" SampleHandler h) throws Exception {"); env.indent(); if (isVoid()) { env.println(getName() + ".decode(d);"); @@ -481,7 +481,7 @@ aspect Java_Class { } public void TypeDecl.Java_emitEncoder(Java_env env) { - env.print("public static void encode(LabCommEncoder e"); + env.print("public static void encode(Encoder e"); if (!isVoid()) { env.print(", "); getType().Java_emitType(env); @@ -496,7 +496,7 @@ aspect Java_Class { } public void SampleDecl.Java_emitEncoder(Java_env env) { - env.print("public static void encode(LabCommEncoder e"); + env.print("public static void encode(Encoder e"); if (!isVoid()) { env.print(", "); getType().Java_emitType(env); @@ -588,7 +588,7 @@ aspect Java_Class { public void Decl.Java_emitDecoder(Java_env env) { env.print("public static "); getType().Java_emitType(env); - env.println(" decode(LabCommDecoder d) throws IOException {"); + env.println(" decode(Decoder d) throws IOException {"); env.indent(); if (!isVoid()) { getType().Java_emitType(env); diff --git a/examples/dynamic/test/DynamicPart.java b/examples/dynamic/test/DynamicPart.java index 334d493..a313722 100644 --- a/examples/dynamic/test/DynamicPart.java +++ b/examples/dynamic/test/DynamicPart.java @@ -18,12 +18,12 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import se.lth.control.labcomm.LabCommDecoder; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoder; -import se.lth.control.labcomm.LabCommEncoderChannel; -import AST.LabCommParser; -import AST.LabCommScanner; +import se.lth.control.labcomm.Decoder; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.Encoder; +import se.lth.control.labcomm.EncoderChannel; +import AST.Parser; +import AST.Scanner; import AST.Program; import beaver.Parser.Exception; @@ -160,8 +160,8 @@ public class DynamicPart { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { Program ast = null; InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); - LabCommScanner scanner = new LabCommScanner(in); - LabCommParser parser = new LabCommParser(); + Scanner scanner = new Scanner(in); + Parser parser = new Parser(); Collection errors = new LinkedList(); InRAMCompiler irc = null; @@ -272,7 +272,7 @@ public class DynamicPart { private void decodeTest(InRAMCompiler irc, HandlerContext ctxt, String tmpFile, String... sampleNames) { try { FileInputStream in = new FileInputStream(tmpFile); - LabCommDecoderChannel dec = new LabCommDecoderChannel(in); + DecoderChannel dec = new DecoderChannel(in); Class handlerClass = irc.load(handlerClassName); Constructor hcc = handlerClass.getDeclaredConstructor(Object.class); Object handler = hcc.newInstance(ctxt); @@ -282,7 +282,7 @@ public class DynamicPart { Class sampleClass = irc.load(sampleName); Class handlerInterface = irc.load(sampleName+"$Handler"); - Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface); + Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface); reg.invoke(sampleClass, dec, handler); } @@ -324,20 +324,20 @@ public class DynamicPart { FileOutputStream out = new FileOutputStream(tmpFile); - LabCommEncoderChannel enc = new LabCommEncoderChannel(out); + EncoderChannel enc = new EncoderChannel(out); /* register and send foo */ - Method regFoo = fc.getDeclaredMethod("register", LabCommEncoder.class); + Method regFoo = fc.getDeclaredMethod("register", Encoder.class); regFoo.invoke(fc, enc); - Method doEncodeFoo = fc.getDeclaredMethod("encode", LabCommEncoder.class, ft); + Method doEncodeFoo = fc.getDeclaredMethod("encode", Encoder.class, ft); doEncodeFoo.invoke(fc, enc, fv); /* register and send bar (NB! uses primitive type int) */ - Method regBar = bc.getDeclaredMethod("register", LabCommEncoder.class); + Method regBar = bc.getDeclaredMethod("register", Encoder.class); regBar.invoke(bc, enc); - Method doEncodeBar = bc.getDeclaredMethod("encode", LabCommEncoder.class, Integer.TYPE); + Method doEncodeBar = bc.getDeclaredMethod("encode", Encoder.class, Integer.TYPE); doEncodeBar.invoke(bc, enc, ctxt.bar); out.close(); diff --git a/examples/dynamic/test/StaticDecoder.java b/examples/dynamic/test/StaticDecoder.java index b3d74ed..c1c06d3 100644 --- a/examples/dynamic/test/StaticDecoder.java +++ b/examples/dynamic/test/StaticDecoder.java @@ -6,16 +6,16 @@ import gen.bar; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import se.lth.control.labcomm.LabCommDecoderChannel; +import se.lth.control.labcomm.DecoderChannel; public class StaticDecoder implements foo.Handler, bar.Handler { - LabCommDecoderChannel decoder; + DecoderChannel decoder; public StaticDecoder(InputStream in) throws Exception { - decoder = new LabCommDecoderChannel(in); + decoder = new DecoderChannel(in); foo.register(decoder, this); bar.register(decoder, this); diff --git a/examples/dynamic/test/StaticEncoder.java b/examples/dynamic/test/StaticEncoder.java index 697f339..4ea48be 100644 --- a/examples/dynamic/test/StaticEncoder.java +++ b/examples/dynamic/test/StaticEncoder.java @@ -2,19 +2,19 @@ package test; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.EncoderChannel; import gen.foo; import gen.bar; public class StaticEncoder { - LabCommEncoderChannel encoder; + EncoderChannel encoder; public StaticEncoder(OutputStream out) throws Exception { - encoder = new LabCommEncoderChannel(out); + encoder = new EncoderChannel(out); foo.register(encoder); bar.register(encoder); } diff --git a/examples/dynamic/test/TestLabCommCompiler.java b/examples/dynamic/test/TestLabCommCompiler.java index a71e0a6..fe9f5e6 100644 --- a/examples/dynamic/test/TestLabCommCompiler.java +++ b/examples/dynamic/test/TestLabCommCompiler.java @@ -16,18 +16,18 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import se.lth.control.labcomm.LabCommDecoder; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoder; -import se.lth.control.labcomm.LabCommEncoderChannel; -import AST.LabCommParser; -import AST.LabCommScanner; +import se.lth.control.labcomm.Decoder; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.Encoder; +import se.lth.control.labcomm.EncoderChannel; +import AST.Parser; +import AST.Scanner; import AST.Program; import beaver.Parser.Exception; -public class TestLabCommCompiler { +public class TestCompiler { private static final String BAR = "bar"; private static final String FOO = "foo"; @@ -73,7 +73,7 @@ public class TestLabCommCompiler { private static void decodeTest(InRAMCompiler irc, String tmpFile) { try { FileInputStream in = new FileInputStream(tmpFile); - LabCommDecoderChannel dec = new LabCommDecoderChannel(in); + DecoderChannel dec = new DecoderChannel(in); Class fc = irc.load(FOO); Class hc = irc.load("gen_"+FOO+"Handler"); @@ -81,7 +81,7 @@ public class TestLabCommCompiler { Object h = hc.newInstance(); - Method reg = fc.getDeclaredMethod("register", LabCommDecoder.class, hi); + Method reg = fc.getDeclaredMethod("register", Decoder.class, hi); reg.invoke(fc, dec, h); dec.runOne(); @@ -106,11 +106,11 @@ public class TestLabCommCompiler { z.setInt(f, 12); FileOutputStream out = new FileOutputStream(tmpFile); - LabCommEncoderChannel enc = new LabCommEncoderChannel(out); - Method reg = fc.getDeclaredMethod("register", LabCommEncoder.class); + EncoderChannel enc = new EncoderChannel(out); + Method reg = fc.getDeclaredMethod("register", Encoder.class); reg.invoke(fc, enc); - Method doEncode = fc.getDeclaredMethod("encode", LabCommEncoder.class, fc); + Method doEncode = fc.getDeclaredMethod("encode", Encoder.class, fc); doEncode.invoke(fc, enc, f); out.close(); @@ -123,8 +123,8 @@ public class TestLabCommCompiler { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { Program ast = null; InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); - LabCommScanner scanner = new LabCommScanner(in); - LabCommParser parser = new LabCommParser(); + Scanner scanner = new Scanner(in); + Parser parser = new Parser(); Collection errors = new LinkedList(); InRAMCompiler irc = null; diff --git a/examples/dynamic/test/TestLabcommGen.java b/examples/dynamic/test/TestLabcommGen.java index 1ad36b4..7ff4e03 100644 --- a/examples/dynamic/test/TestLabcommGen.java +++ b/examples/dynamic/test/TestLabcommGen.java @@ -18,12 +18,12 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; -import se.lth.control.labcomm.LabCommDecoder; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoder; -import se.lth.control.labcomm.LabCommEncoderChannel; -import AST.LabCommParser; -import AST.LabCommScanner; +import se.lth.control.labcomm.Decoder; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.Encoder; +import se.lth.control.labcomm.EncoderChannel; +import AST.Parser; +import AST.Scanner; import AST.Program; import beaver.Parser.Exception; @@ -163,8 +163,8 @@ public class TestLabcommGen { public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) { Program ast = null; InputStream in = new ByteArrayInputStream(lcDecl.getBytes()); - LabCommScanner scanner = new LabCommScanner(in); - LabCommParser parser = new LabCommParser(); + Scanner scanner = new Scanner(in); + Parser parser = new Parser(); Collection errors = new LinkedList(); InRAMCompiler irc = null; @@ -332,7 +332,7 @@ public class TestLabcommGen { private static void decodeTest(InRAMCompiler irc, String tmpFile, String... sampleNames) { try { FileInputStream in = new FileInputStream(tmpFile); - LabCommDecoderChannel dec = new LabCommDecoderChannel(in); + DecoderChannel dec = new DecoderChannel(in); Class handlerClass = irc.load(handlerClassName); Constructor hcc = handlerClass.getDeclaredConstructor(Object.class); // Object handler = handlerClass.newInstance(); @@ -344,7 +344,7 @@ public class TestLabcommGen { Class sampleClass = irc.load(sampleName); Class handlerInterface = irc.load(sampleName+"$Handler"); - Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface); + Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface); reg.invoke(sampleClass, dec, handler); } @@ -389,20 +389,20 @@ public class TestLabcommGen { FileOutputStream out = new FileOutputStream(tmpFile); - LabCommEncoderChannel enc = new LabCommEncoderChannel(out); + EncoderChannel enc = new EncoderChannel(out); /* register and send foo */ - Method regFoo = fc.getDeclaredMethod("register", LabCommEncoder.class); + Method regFoo = fc.getDeclaredMethod("register", Encoder.class); regFoo.invoke(fc, enc); - Method doEncodeFoo = fc.getDeclaredMethod("encode", LabCommEncoder.class, ft); + Method doEncodeFoo = fc.getDeclaredMethod("encode", Encoder.class, ft); doEncodeFoo.invoke(fc, enc, f); /* register and send bar (NB! uses primitive type int) */ - Method regBar = bc.getDeclaredMethod("register", LabCommEncoder.class); + Method regBar = bc.getDeclaredMethod("register", Encoder.class); regBar.invoke(bc, enc); - Method doEncodeBar = bc.getDeclaredMethod("encode", LabCommEncoder.class, Integer.TYPE); + Method doEncodeBar = bc.getDeclaredMethod("encode", Encoder.class, Integer.TYPE); doEncodeBar.invoke(bc, enc, 42); out.close(); @@ -475,7 +475,7 @@ public class TestLabcommGen { private static void decodeTestSeparate(InRAMCompiler irc, String tmpFile, String... sampleNames) { try { FileInputStream in = new FileInputStream(tmpFile); - LabCommDecoderChannel dec = new LabCommDecoderChannel(in); + DecoderChannel dec = new DecoderChannel(in); for (String sampleName : sampleNames) { System.out.println("registering handler for "+sampleName); Class sampleClass = irc.load(sampleName); @@ -484,7 +484,7 @@ public class TestLabcommGen { Object handler = handlerClass.newInstance(); - Method reg = sampleClass.getDeclaredMethod("register", LabCommDecoder.class, handlerInterface); + Method reg = sampleClass.getDeclaredMethod("register", Decoder.class, handlerInterface); reg.invoke(sampleClass, dec, handler); } diff --git a/examples/jgrafchart/labcommTCPtest/client/TestClient.java b/examples/jgrafchart/labcommTCPtest/client/TestClient.java index 0582d9e..66fa134 100644 --- a/examples/jgrafchart/labcommTCPtest/client/TestClient.java +++ b/examples/jgrafchart/labcommTCPtest/client/TestClient.java @@ -6,8 +6,8 @@ import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.foo; import labcommTCPtest.gen.foo.Handler; @@ -25,7 +25,7 @@ public class TestClient implements Handler { public void test() { try { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); foo.register(e); foo sample = new foo(); sample.c = 17; @@ -36,7 +36,7 @@ public class TestClient implements Handler { printSample("Client sending", sample); foo.encode(e, sample); - LabCommDecoderChannel c = new LabCommDecoderChannel(in); + DecoderChannel c = new DecoderChannel(in); foo.register(c,this); c.run(); } catch (Exception e) { diff --git a/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java b/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java index d54c7bb..9601bca 100644 --- a/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java +++ b/examples/jgrafchart/labcommTCPtest/client/TestClientSingleshot.java @@ -6,8 +6,8 @@ import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.FooSample; import labcommTCPtest.gen.FooSample.Handler; @@ -25,7 +25,7 @@ public class TestClientSingleshot implements Handler { public void test() { try { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); FooSample.register(e); FooSample sample = new FooSample(); sample.x = 17; @@ -35,7 +35,7 @@ public class TestClientSingleshot implements Handler { printSample("Client sending", sample); FooSample.encode(e, sample); - LabCommDecoderChannel c = new LabCommDecoderChannel(in); + DecoderChannel c = new DecoderChannel(in); FooSample.register(c,this); c.runOne(); } catch (Exception e) { diff --git a/examples/jgrafchart/labcommTCPtest/server/TestServer.java b/examples/jgrafchart/labcommTCPtest/server/TestServer.java index 33be0cd..4b95a36 100644 --- a/examples/jgrafchart/labcommTCPtest/server/TestServer.java +++ b/examples/jgrafchart/labcommTCPtest/server/TestServer.java @@ -8,8 +8,8 @@ import java.lang.reflect.Method; import java.net.ServerSocket; import java.net.Socket; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.foo; import labcommTCPtest.gen.foo.Handler; @@ -38,7 +38,7 @@ public class TestServer implements Handler { public void runOne() { try { - LabCommDecoderChannel c = new LabCommDecoderChannel(in); + DecoderChannel c = new DecoderChannel(in); foo.register(c,this); c.runOne(); } catch (Exception e) { @@ -47,7 +47,7 @@ public class TestServer implements Handler { } public void handle_foo(foo sample) throws Exception { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); foo.register(e); System.out.println("TestServer.handle_foo..."); sample.b *= 2; diff --git a/examples/simple/Decoder.java b/examples/simple/Decoder.java index 4ab97e4..48dd3ed 100644 --- a/examples/simple/Decoder.java +++ b/examples/simple/Decoder.java @@ -2,19 +2,19 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import se.lth.control.labcomm.LabCommDecoderChannel; +import se.lth.control.labcomm.DecoderChannel; public class Decoder implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler, doavoid.Handler { - LabCommDecoderChannel decoder; + DecoderChannel decoder; public Decoder(InputStream in) throws Exception { - decoder = new LabCommDecoderChannel(in); + decoder = new DecoderChannel(in); theTwoInts.register(decoder, this); anotherTwoInts.register(decoder, this); IntString.register(decoder, this); diff --git a/examples/simple/Decoder06.java b/examples/simple/Decoder06.java index b6185d7..86ba718 100644 --- a/examples/simple/Decoder06.java +++ b/examples/simple/Decoder06.java @@ -2,19 +2,19 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import se.lth.control.labcomm2006.LabCommDecoderChannel; +import se.lth.control.labcomm2006.DecoderChannel; public class Decoder06 implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler { - LabCommDecoderChannel decoder; + DecoderChannel decoder; public Decoder06(InputStream in) throws Exception { - decoder = new LabCommDecoderChannel(in); + decoder = new DecoderChannel(in); theTwoInts.register(decoder, this); anotherTwoInts.register(decoder, this); IntString.register(decoder, this); diff --git a/examples/simple/Encoder.java b/examples/simple/Encoder.java index b209ea6..d70384c 100644 --- a/examples/simple/Encoder.java +++ b/examples/simple/Encoder.java @@ -2,7 +2,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.EncoderChannel; /** * Simple encoder @@ -10,12 +10,12 @@ import se.lth.control.labcomm.LabCommEncoderChannel; public class Encoder { - LabCommEncoderChannel encoder; + EncoderChannel encoder; public Encoder(OutputStream out) throws Exception { - encoder = new LabCommEncoderChannel(out); + encoder = new EncoderChannel(out); theTwoInts.register(encoder); IntString.register(encoder); TwoArrays.register(encoder); diff --git a/examples/simple/Encoder06.java b/examples/simple/Encoder06.java index 5d913d9..1da84c8 100644 --- a/examples/simple/Encoder06.java +++ b/examples/simple/Encoder06.java @@ -2,7 +2,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; -import se.lth.control.labcomm2006.LabCommEncoderChannel; +import se.lth.control.labcomm2006.EncoderChannel; /** * Simple encoder @@ -10,12 +10,12 @@ import se.lth.control.labcomm2006.LabCommEncoderChannel; public class Encoder06 { - LabCommEncoderChannel encoder; + EncoderChannel encoder; public Encoder06(OutputStream out) throws Exception { - encoder = new LabCommEncoderChannel(out); + encoder = new EncoderChannel(out); theTwoInts.register(encoder); IntString.register(encoder); TwoArrays.register(encoder); diff --git a/examples/tcp/labcommTCPtest/client/TestClient.java b/examples/tcp/labcommTCPtest/client/TestClient.java index d9040fb..fcd621e 100644 --- a/examples/tcp/labcommTCPtest/client/TestClient.java +++ b/examples/tcp/labcommTCPtest/client/TestClient.java @@ -6,8 +6,8 @@ import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.FooSample; import labcommTCPtest.gen.FooSample.Handler; @@ -25,7 +25,7 @@ public class TestClient implements Handler { public void test() { try { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); FooSample.register(e); FooSample sample = new FooSample(); int a[] = new int[3]; @@ -42,7 +42,7 @@ public class TestClient implements Handler { printSample("Client sending", sample); FooSample.encode(e, sample); - LabCommDecoderChannel c = new LabCommDecoderChannel(in); + DecoderChannel c = new DecoderChannel(in); FooSample.register(c,this); c.runOne(); } catch (Exception e) { diff --git a/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java b/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java index d54c7bb..9601bca 100644 --- a/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java +++ b/examples/tcp/labcommTCPtest/client/TestClientSingleshot.java @@ -6,8 +6,8 @@ import java.io.OutputStream; import java.net.Socket; import java.net.UnknownHostException; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.FooSample; import labcommTCPtest.gen.FooSample.Handler; @@ -25,7 +25,7 @@ public class TestClientSingleshot implements Handler { public void test() { try { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); FooSample.register(e); FooSample sample = new FooSample(); sample.x = 17; @@ -35,7 +35,7 @@ public class TestClientSingleshot implements Handler { printSample("Client sending", sample); FooSample.encode(e, sample); - LabCommDecoderChannel c = new LabCommDecoderChannel(in); + DecoderChannel c = new DecoderChannel(in); FooSample.register(c,this); c.runOne(); } catch (Exception e) { diff --git a/examples/tcp/labcommTCPtest/server/OneShotServer.java b/examples/tcp/labcommTCPtest/server/OneShotServer.java index b929d8b..b79b93e 100644 --- a/examples/tcp/labcommTCPtest/server/OneShotServer.java +++ b/examples/tcp/labcommTCPtest/server/OneShotServer.java @@ -6,8 +6,8 @@ import java.io.OutputStream; import java.net.Socket; import java.net.ServerSocket; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.FooSample; public class OneShotServer {//implements Handler { @@ -21,7 +21,7 @@ public class OneShotServer {//implements Handler { public void test() { try { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); FooSample.register(e); FooSample sample = new FooSample(); sample.s = "OneShotServer message"; diff --git a/examples/tcp/labcommTCPtest/server/TestServer.java b/examples/tcp/labcommTCPtest/server/TestServer.java index b9b6d0b..441bac4 100644 --- a/examples/tcp/labcommTCPtest/server/TestServer.java +++ b/examples/tcp/labcommTCPtest/server/TestServer.java @@ -8,8 +8,8 @@ import java.lang.reflect.Method; import java.net.ServerSocket; import java.net.Socket; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; import labcommTCPtest.gen.FooSample; import labcommTCPtest.gen.FooSample.Handler; @@ -38,7 +38,7 @@ public class TestServer implements Handler { public void runOne() { try { - LabCommDecoderChannel c = new LabCommDecoderChannel(in); + DecoderChannel c = new DecoderChannel(in); FooSample.register(c,this); c.runOne(); } catch (Exception e) { @@ -47,7 +47,7 @@ public class TestServer implements Handler { } public void handle_FooSample(FooSample sample) throws Exception { - LabCommEncoderChannel e = new LabCommEncoderChannel(out ); + EncoderChannel e = new EncoderChannel(out ); FooSample.register(e); System.out.println("TestServer.handle_FooSample: "+sample.s); int tmp[] = new int[2*sample.a.length]; diff --git a/examples/user_types/Decoder.java b/examples/user_types/Decoder.java index 01bea43..bdb1737 100644 --- a/examples/user_types/Decoder.java +++ b/examples/user_types/Decoder.java @@ -2,19 +2,19 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import se.lth.control.labcomm.LabCommDecoderChannel; +import se.lth.control.labcomm.DecoderChannel; public class Decoder implements twoLines.Handler { - LabCommDecoderChannel decoder; + DecoderChannel decoder; public Decoder(InputStream in) throws Exception { - decoder = new LabCommDecoderChannel(in); + decoder = new DecoderChannel(in); twoLines.register(decoder, this); try { diff --git a/examples/user_types/Encoder.java b/examples/user_types/Encoder.java index 8cdbba8..aa2f80e 100644 --- a/examples/user_types/Encoder.java +++ b/examples/user_types/Encoder.java @@ -2,7 +2,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.EncoderChannel; /** * Simple encoder @@ -10,12 +10,12 @@ import se.lth.control.labcomm.LabCommEncoderChannel; public class Encoder { - LabCommEncoderChannel encoder; + EncoderChannel encoder; public Encoder(OutputStream out) throws Exception { - encoder = new LabCommEncoderChannel(out); + encoder = new EncoderChannel(out); twoLines.register(encoder); } diff --git a/examples/wiki_example/data.java b/examples/wiki_example/data.java index 7acf55a..5860ed9 100644 --- a/examples/wiki_example/data.java +++ b/examples/wiki_example/data.java @@ -2,27 +2,27 @@ sample float data; */ import java.io.IOException; -import se.lth.control.labcomm.LabCommDecoder; -import se.lth.control.labcomm.LabCommDispatcher; -import se.lth.control.labcomm.LabCommEncoder; -import se.lth.control.labcomm.LabCommHandler; -import se.lth.control.labcomm.LabCommSample; +import se.lth.control.labcomm.Decoder; +import se.lth.control.labcomm.Dispatcher; +import se.lth.control.labcomm.Encoder; +import se.lth.control.labcomm.Handler; +import se.lth.control.labcomm.Sample; -public class data implements LabCommSample { +public class data implements Sample { - public interface Handler extends LabCommHandler { + public interface Handler extends Handler { public void handle_data(float value) throws Exception; } - public static void register(LabCommDecoder d, Handler h) throws IOException { + public static void register(Decoder d, Handler h) throws IOException { d.register(new Dispatcher(), h); } - public static void register(LabCommEncoder e) throws IOException { + public static void register(Encoder e) throws IOException { e.register(new Dispatcher()); } - private static class Dispatcher implements LabCommDispatcher { + private static class Dispatcher implements Dispatcher { public Class getSampleClass() { return data.class; @@ -36,20 +36,20 @@ public class data implements LabCommSample { return signature; } - public void decodeAndHandle(LabCommDecoder d, - LabCommHandler h) throws Exception { + public void decodeAndHandle(Decoder d, + Handler h) throws Exception { ((Handler)h).handle_data(data.decode(d)); } } - public static void encode(LabCommEncoder e, float value) throws IOException { + public static void encode(Encoder e, float value) throws IOException { e.begin(data.class); e.encodeFloat(value); e.end(data.class); } - public static float decode(LabCommDecoder d) throws IOException { + public static float decode(Decoder d) throws IOException { float result; result = d.decodeFloat(); return result; diff --git a/examples/wiki_example/example_decoder_encoder.java b/examples/wiki_example/example_decoder_encoder.java index 63f1d96..252cc1d 100644 --- a/examples/wiki_example/example_decoder_encoder.java +++ b/examples/wiki_example/example_decoder_encoder.java @@ -4,24 +4,24 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; -import se.lth.control.labcomm.LabCommDecoderChannel; -import se.lth.control.labcomm.LabCommEncoderChannel; +import se.lth.control.labcomm.DecoderChannel; +import se.lth.control.labcomm.EncoderChannel; public class example_decoder_encoder implements data.Handler, log_message.Handler { - LabCommDecoderChannel decoder; - LabCommEncoderChannel encoder; + DecoderChannel decoder; + EncoderChannel encoder; public example_decoder_encoder(InputStream in, OutputStream out) throws Exception { - decoder = new LabCommDecoderChannel(in); + decoder = new DecoderChannel(in); log_message.register(decoder, this); data.register(decoder, this); - encoder = new LabCommEncoderChannel(out); + encoder = new EncoderChannel(out); log_message.register(encoder); data.register(encoder); diff --git a/lib/java/Makefile b/lib/java/Makefile index f3f60c2..47b112c 100644 --- a/lib/java/Makefile +++ b/lib/java/Makefile @@ -1,16 +1,16 @@ -MODULES=LabCommDispatcher \ - LabCommDecoderRegistry \ - LabComm \ - LabCommSample \ - LabCommHandler \ - LabCommEncoderRegistry \ - LabCommType \ - LabCommEncoder \ - LabCommEncoderChannel \ - LabCommDecoder \ - LabCommDecoderChannel \ - LabCommWriter \ - LabCommReader \ +MODULES=Constant \ + Decoder \ + DecoderChannel \ + DecoderRegistry \ + Encoder \ + EncoderChannel \ + EncoderRegistry \ + Reader \ + Sample \ + SampleDispatcher \ + SampleHandler \ + Type \ + Writer \ WriterWrapper all: labcomm.jar labcomm20141009.jar labcomm2006.jar diff --git a/lib/java/se/lth/control/labcomm/LabComm.java b/lib/java/se/lth/control/labcomm/Constant.java similarity index 97% rename from lib/java/se/lth/control/labcomm/LabComm.java rename to lib/java/se/lth/control/labcomm/Constant.java index 0a89ea3..7c5da70 100644 --- a/lib/java/se/lth/control/labcomm/LabComm.java +++ b/lib/java/se/lth/control/labcomm/Constant.java @@ -1,6 +1,6 @@ package se.lth.control.labcomm; -public class LabComm { +public class Constant { public static final String VERSION = "LabComm20141009"; diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoder.java b/lib/java/se/lth/control/labcomm/Decoder.java similarity index 78% rename from lib/java/se/lth/control/labcomm/LabCommDecoder.java rename to lib/java/se/lth/control/labcomm/Decoder.java index a40fb85..c3320f3 100644 --- a/lib/java/se/lth/control/labcomm/LabCommDecoder.java +++ b/lib/java/se/lth/control/labcomm/Decoder.java @@ -2,10 +2,10 @@ package se.lth.control.labcomm; import java.io.IOException; -public interface LabCommDecoder { +public interface Decoder { - public void register(LabCommDispatcher dispatcher, - LabCommHandler handler) throws IOException; + public void register(SampleDispatcher dispatcher, + SampleHandler handler) throws IOException; public boolean decodeBoolean() throws IOException; public byte decodeByte() throws IOException; public short decodeShort() throws IOException; diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java b/lib/java/se/lth/control/labcomm/DecoderChannel.java similarity index 81% rename from lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java rename to lib/java/se/lth/control/labcomm/DecoderChannel.java index 4910c6b..6c5a1d2 100644 --- a/lib/java/se/lth/control/labcomm/LabCommDecoderChannel.java +++ b/lib/java/se/lth/control/labcomm/DecoderChannel.java @@ -6,20 +6,20 @@ import java.io.InputStream; import java.io.IOException; import java.io.EOFException; -public class LabCommDecoderChannel implements LabCommDecoder { +public class DecoderChannel implements Decoder { private DataInputStream in; - private LabCommDecoderRegistry registry; + private DecoderRegistry registry; - public LabCommDecoderChannel(InputStream in) throws IOException { + public DecoderChannel(InputStream in) throws IOException { this.in = new DataInputStream(in); - registry = new LabCommDecoderRegistry(); + registry = new DecoderRegistry(); String version = decodeString(); - if (! version.equals(LabComm.VERSION)) { + if (! version.equals(Constant.VERSION)) { throw new IOException("LabComm version mismatch " + - version + " != " + LabComm.VERSION); + version + " != " + Constant.VERSION); } - System.err.println(LabComm.VERSION); + System.err.println(Constant.VERSION); } public void runOne() throws Exception { @@ -28,7 +28,7 @@ public class LabCommDecoderChannel implements LabCommDecoder { int tag = decodePacked32(); int length = decodePacked32(); switch (tag) { - case LabComm.SAMPLE: { + case Constant.SAMPLE: { int index = decodePacked32(); String name = decodeString(); int signature_length = decodePacked32(); @@ -37,15 +37,15 @@ public class LabCommDecoderChannel implements LabCommDecoder { registry.add(index, name, signature); } break; default: { - LabCommDecoderRegistry.Entry e = registry.get(tag); + DecoderRegistry.Entry e = registry.get(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } - LabCommDispatcher d = e.getDispatcher(); + SampleDispatcher d = e.getDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'"); } - LabCommHandler h = e.getHandler(); + SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } @@ -62,8 +62,8 @@ public class LabCommDecoderChannel implements LabCommDecoder { } } - public void register(LabCommDispatcher dispatcher, - LabCommHandler handler) throws IOException { + public void register(SampleDispatcher dispatcher, + SampleHandler handler) throws IOException { registry.add(dispatcher, handler); } diff --git a/lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.java b/lib/java/se/lth/control/labcomm/DecoderRegistry.java similarity index 84% rename from lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.java rename to lib/java/se/lth/control/labcomm/DecoderRegistry.java index 890aeae..fdf8f59 100644 --- a/lib/java/se/lth/control/labcomm/LabCommDecoderRegistry.java +++ b/lib/java/se/lth/control/labcomm/DecoderRegistry.java @@ -3,18 +3,18 @@ package se.lth.control.labcomm; import java.io.IOException; import java.util.HashMap; -public class LabCommDecoderRegistry { +public class DecoderRegistry { public static class Entry { - private LabCommDispatcher dispatcher; - private LabCommHandler handler; + private SampleDispatcher dispatcher; + private SampleHandler handler; private int index; private String name; private byte[] signature; - public Entry(LabCommDispatcher dispatcher, - LabCommHandler handler) { + public Entry(SampleDispatcher dispatcher, + SampleHandler handler) { this.dispatcher = dispatcher; this.name = dispatcher.getName(); this.signature = dispatcher.getSignature(); @@ -27,19 +27,19 @@ public class LabCommDecoderRegistry { this.signature = signature; } - public LabCommDispatcher getDispatcher() { + public SampleDispatcher getDispatcher() { return dispatcher; } - public void setDispatcher(LabCommDispatcher dispatcher) { + public void setDispatcher(SampleDispatcher dispatcher) { this.dispatcher = dispatcher; } - public LabCommHandler getHandler() { + public SampleHandler getHandler() { return handler; } - public void setHandler(LabCommHandler handler) { + public void setHandler(SampleHandler handler) { this.handler = handler; } @@ -89,13 +89,13 @@ public class LabCommDecoderRegistry { private HashMap<Class, Entry> byClass; private HashMap<Integer, Entry> byIndex; - public LabCommDecoderRegistry() { + public DecoderRegistry() { byClass = new HashMap<Class, Entry>(); byIndex = new HashMap<Integer, Entry>(); } - public synchronized void add(LabCommDispatcher dispatcher, - LabCommHandler handler) throws IOException{ + public synchronized void add(SampleDispatcher dispatcher, + SampleHandler handler) throws IOException{ Entry e = byClass.get(dispatcher.getSampleClass()); if (e != null) { e.check(dispatcher.getName(), dispatcher.getSignature()); @@ -141,4 +141,4 @@ public class LabCommDecoderRegistry { return byIndex.get(Integer.valueOf(index)); } -} \ No newline at end of file +} diff --git a/lib/java/se/lth/control/labcomm/LabCommEncoder.java b/lib/java/se/lth/control/labcomm/Encoder.java similarity index 71% rename from lib/java/se/lth/control/labcomm/LabCommEncoder.java rename to lib/java/se/lth/control/labcomm/Encoder.java index f332d78..d6ef3e5 100644 --- a/lib/java/se/lth/control/labcomm/LabCommEncoder.java +++ b/lib/java/se/lth/control/labcomm/Encoder.java @@ -2,11 +2,11 @@ package se.lth.control.labcomm; import java.io.IOException; -public interface LabCommEncoder { +public interface Encoder { - public void register(LabCommDispatcher dispatcher) throws IOException; - public void begin(Class<? extends LabCommSample> c) throws IOException; - public void end(Class<? extends LabCommSample> c) throws IOException; + public void register(SampleDispatcher dispatcher) throws IOException; + public void begin(Class<? extends Sample> c) throws IOException; + public void end(Class<? extends Sample> c) throws IOException; public void encodeBoolean(boolean value) throws IOException; public void encodeByte(byte value) throws IOException; public void encodeShort(short value) throws IOException; diff --git a/lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java b/lib/java/se/lth/control/labcomm/EncoderChannel.java similarity index 77% rename from lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java rename to lib/java/se/lth/control/labcomm/EncoderChannel.java index b5c422d..1bde995 100644 --- a/lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java +++ b/lib/java/se/lth/control/labcomm/EncoderChannel.java @@ -5,44 +5,44 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; -public class LabCommEncoderChannel implements LabCommEncoder { +public class EncoderChannel implements Encoder { - private LabCommWriter writer; + private Writer writer; private ByteArrayOutputStream bytes; private DataOutputStream data; - private LabCommEncoderRegistry registry; + private EncoderRegistry registry; private int current_tag; - public LabCommEncoderChannel(LabCommWriter writer, - boolean emitVersion) throws IOException { + public EncoderChannel(Writer writer, + boolean emitVersion) throws IOException { this.writer = writer; bytes = new ByteArrayOutputStream(); data = new DataOutputStream(bytes); - registry = new LabCommEncoderRegistry(); + registry = new EncoderRegistry(); if (emitVersion) { - encodeString(LabComm.VERSION); + encodeString(Constant.VERSION); data.flush(); writer.write(bytes.toByteArray()); bytes.reset(); } } - public LabCommEncoderChannel(LabCommWriter writer) throws IOException { + public EncoderChannel(Writer writer) throws IOException { this(writer, true); } - public LabCommEncoderChannel(OutputStream writer, - boolean emitVersion) throws IOException { + public EncoderChannel(OutputStream writer, + boolean emitVersion) throws IOException { this(new WriterWrapper(writer), emitVersion); } - public LabCommEncoderChannel(OutputStream writer) throws IOException { + public EncoderChannel(OutputStream writer) throws IOException { this(new WriterWrapper(writer), true); } - public void register(LabCommDispatcher dispatcher) throws IOException { + public void register(SampleDispatcher dispatcher) throws IOException { int index = registry.add(dispatcher); - begin(LabComm.SAMPLE); + begin(Constant.SAMPLE); encodePacked32(index); encodeString(dispatcher.getName()); byte[] signature = dispatcher.getSignature(); @@ -58,11 +58,11 @@ public class LabCommEncoderChannel implements LabCommEncoder { bytes.reset(); } - public void begin(Class<? extends LabCommSample> c) throws IOException { + public void begin(Class<? extends Sample> c) throws IOException { begin(registry.getTag(c)); } - public void end(Class<? extends LabCommSample> c) throws IOException { + public void end(Class<? extends Sample> c) throws IOException { data.flush(); WritePacked32(writer, current_tag); WritePacked32(writer, bytes.size()); @@ -70,7 +70,7 @@ public class LabCommEncoderChannel implements LabCommEncoder { bytes.reset(); } - private void WritePacked32(LabCommWriter s, long value) throws IOException { + private void WritePacked32(Writer s, long value) throws IOException { byte[] tmp1 = new byte[5]; byte[] tmp2 = new byte[1]; long v = value & 0xffffffff; diff --git a/lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.java b/lib/java/se/lth/control/labcomm/EncoderRegistry.java similarity index 66% rename from lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.java rename to lib/java/se/lth/control/labcomm/EncoderRegistry.java index a5e848d..cd0cf72 100644 --- a/lib/java/se/lth/control/labcomm/LabCommEncoderRegistry.java +++ b/lib/java/se/lth/control/labcomm/EncoderRegistry.java @@ -3,19 +3,19 @@ package se.lth.control.labcomm; import java.io.IOException; import java.util.HashMap; -public class LabCommEncoderRegistry { +public class EncoderRegistry { public static class Entry { - private LabCommDispatcher dispatcher; + private SampleDispatcher dispatcher; private int index; - public Entry(LabCommDispatcher dispatcher, int index) { + public Entry(SampleDispatcher dispatcher, int index) { this.dispatcher = dispatcher; this.index = index; } - public LabCommDispatcher getDispatcher() { + public SampleDispatcher getDispatcher() { return dispatcher; } @@ -25,14 +25,14 @@ public class LabCommEncoderRegistry { } - private int userIndex = LabComm.FIRST_USER_INDEX; + private int userIndex = Constant.FIRST_USER_INDEX; private HashMap<Class, Entry> byClass; - public LabCommEncoderRegistry() { + public EncoderRegistry() { byClass = new HashMap<Class, Entry>(); } - public synchronized int add(LabCommDispatcher dispatcher) { + public synchronized int add(SampleDispatcher dispatcher) { Entry e = byClass.get(dispatcher.getSampleClass()); if (e == null) { e = new Entry(dispatcher, userIndex); @@ -42,7 +42,7 @@ public class LabCommEncoderRegistry { return e.getIndex(); } - public int getTag(Class<? extends LabCommSample> sample) throws IOException { + public int getTag(Class<? extends Sample> sample) throws IOException { Entry e = byClass.get(sample); if (e == null) { throw new IOException("'" + @@ -52,4 +52,4 @@ public class LabCommEncoderRegistry { return e.index; } -} \ No newline at end of file +} diff --git a/lib/java/se/lth/control/labcomm/LabCommDispatcher.java b/lib/java/se/lth/control/labcomm/LabCommDispatcher.java deleted file mode 100644 index 86d756c..0000000 --- a/lib/java/se/lth/control/labcomm/LabCommDispatcher.java +++ /dev/null @@ -1,15 +0,0 @@ -package se.lth.control.labcomm; - -public interface LabCommDispatcher { - - public Class getSampleClass(); - - public String getName(); - - public byte[] getSignature(); - - public void decodeAndHandle(LabCommDecoder decoder, - LabCommHandler handler) throws Exception; - -} - diff --git a/lib/java/se/lth/control/labcomm/LabCommHandler.java b/lib/java/se/lth/control/labcomm/LabCommHandler.java deleted file mode 100644 index d30a12f..0000000 --- a/lib/java/se/lth/control/labcomm/LabCommHandler.java +++ /dev/null @@ -1,4 +0,0 @@ -package se.lth.control.labcomm; - -public interface LabCommHandler { -} \ No newline at end of file diff --git a/lib/java/se/lth/control/labcomm/LabCommReader.java b/lib/java/se/lth/control/labcomm/Reader.java similarity index 73% rename from lib/java/se/lth/control/labcomm/LabCommReader.java rename to lib/java/se/lth/control/labcomm/Reader.java index 28d7d05..1dd0dac 100644 --- a/lib/java/se/lth/control/labcomm/LabCommReader.java +++ b/lib/java/se/lth/control/labcomm/Reader.java @@ -1,6 +1,6 @@ package se.lth.control.labcomm; -public interface LabCommReader { +public interface Reader { public void handle(byte[] data, int begin, int end); diff --git a/lib/java/se/lth/control/labcomm/LabCommType.java b/lib/java/se/lth/control/labcomm/Sample.java similarity index 53% rename from lib/java/se/lth/control/labcomm/LabCommType.java rename to lib/java/se/lth/control/labcomm/Sample.java index 6cb84f6..8210e3a 100644 --- a/lib/java/se/lth/control/labcomm/LabCommType.java +++ b/lib/java/se/lth/control/labcomm/Sample.java @@ -1,5 +1,5 @@ package se.lth.control.labcomm; -public interface LabCommType { +public interface Sample { } \ No newline at end of file diff --git a/lib/java/se/lth/control/labcomm/SampleDispatcher.java b/lib/java/se/lth/control/labcomm/SampleDispatcher.java new file mode 100644 index 0000000..8051296 --- /dev/null +++ b/lib/java/se/lth/control/labcomm/SampleDispatcher.java @@ -0,0 +1,15 @@ +package se.lth.control.labcomm; + +public interface SampleDispatcher { + + public Class getSampleClass(); + + public String getName(); + + public byte[] getSignature(); + + public void decodeAndHandle(Decoder decoder, + SampleHandler handler) throws Exception; + +} + diff --git a/lib/java/se/lth/control/labcomm/SampleHandler.java b/lib/java/se/lth/control/labcomm/SampleHandler.java new file mode 100644 index 0000000..d03da88 --- /dev/null +++ b/lib/java/se/lth/control/labcomm/SampleHandler.java @@ -0,0 +1,4 @@ +package se.lth.control.labcomm; + +public interface SampleHandler { +} diff --git a/lib/java/se/lth/control/labcomm/LabCommSample.java b/lib/java/se/lth/control/labcomm/Type.java similarity index 51% rename from lib/java/se/lth/control/labcomm/LabCommSample.java rename to lib/java/se/lth/control/labcomm/Type.java index 8ae824f..46a5507 100644 --- a/lib/java/se/lth/control/labcomm/LabCommSample.java +++ b/lib/java/se/lth/control/labcomm/Type.java @@ -1,5 +1,5 @@ package se.lth.control.labcomm; -public interface LabCommSample { +public interface Type { } \ No newline at end of file diff --git a/lib/java/se/lth/control/labcomm/LabCommWriter.java b/lib/java/se/lth/control/labcomm/Writer.java similarity index 78% rename from lib/java/se/lth/control/labcomm/LabCommWriter.java rename to lib/java/se/lth/control/labcomm/Writer.java index 887c547..2e015b0 100644 --- a/lib/java/se/lth/control/labcomm/LabCommWriter.java +++ b/lib/java/se/lth/control/labcomm/Writer.java @@ -2,7 +2,7 @@ package se.lth.control.labcomm; import java.io.IOException; -public interface LabCommWriter { +public interface Writer { public void write(byte[] data) throws IOException; diff --git a/lib/java/se/lth/control/labcomm/WriterWrapper.java b/lib/java/se/lth/control/labcomm/WriterWrapper.java index 0f7d192..7c33137 100644 --- a/lib/java/se/lth/control/labcomm/WriterWrapper.java +++ b/lib/java/se/lth/control/labcomm/WriterWrapper.java @@ -3,7 +3,7 @@ package se.lth.control.labcomm; import java.io.OutputStream; import java.io.IOException; -class WriterWrapper implements LabCommWriter{ +class WriterWrapper implements Writer{ private OutputStream os; diff --git a/lib/java/se/lth/control/labcomm2006/LabComm.java b/lib/java/se/lth/control/labcomm2006/Constant.java similarity index 97% rename from lib/java/se/lth/control/labcomm2006/LabComm.java rename to lib/java/se/lth/control/labcomm2006/Constant.java index b83c391..5c14ae5 100644 --- a/lib/java/se/lth/control/labcomm2006/LabComm.java +++ b/lib/java/se/lth/control/labcomm2006/Constant.java @@ -1,6 +1,6 @@ package se.lth.control.labcomm2006; -public class LabComm { +public class Constant { public static final String VERSION = "LabComm2006"; diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoder.java b/lib/java/se/lth/control/labcomm2006/Decoder.java similarity index 78% rename from lib/java/se/lth/control/labcomm2006/LabCommDecoder.java rename to lib/java/se/lth/control/labcomm2006/Decoder.java index 864e43e..0b442cb 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommDecoder.java +++ b/lib/java/se/lth/control/labcomm2006/Decoder.java @@ -2,10 +2,10 @@ package se.lth.control.labcomm2006; import java.io.IOException; -public interface LabCommDecoder { +public interface Decoder { - public void register(LabCommDispatcher dispatcher, - LabCommHandler handler) throws IOException; + public void register(SampleDispatcher dispatcher, + SampleHandler handler) throws IOException; public boolean decodeBoolean() throws IOException; public byte decodeByte() throws IOException; public short decodeShort() throws IOException; diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java b/lib/java/se/lth/control/labcomm2006/DecoderChannel.java similarity index 74% rename from lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java rename to lib/java/se/lth/control/labcomm2006/DecoderChannel.java index 28077b5..77a96f1 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java +++ b/lib/java/se/lth/control/labcomm2006/DecoderChannel.java @@ -5,14 +5,14 @@ import java.io.DataInputStream; import java.io.InputStream; import java.io.IOException; -public class LabCommDecoderChannel implements LabCommDecoder { +public class DecoderChannel implements Decoder { private DataInputStream in; - private LabCommDecoderRegistry registry; + private DecoderRegistry registry; - public LabCommDecoderChannel(InputStream in) throws IOException { + public DecoderChannel(InputStream in) throws IOException { this.in = new DataInputStream(in); - registry = new LabCommDecoderRegistry(); + registry = new DecoderRegistry(); } public void runOne() throws Exception { @@ -20,23 +20,23 @@ public class LabCommDecoderChannel implements LabCommDecoder { while (!done) { int tag = decodePacked32(); switch (tag) { - case LabComm.SAMPLE: { + case Constant.SAMPLE: { int index = decodePacked32(); String name = decodeString(); ByteArrayOutputStream signature = new ByteArrayOutputStream(); - collectFlatSignature(new LabCommEncoderChannel(signature, false)); + collectFlatSignature(new EncoderChannel(signature, false)); registry.add(index, name, signature.toByteArray()); } break; default: { - LabCommDecoderRegistry.Entry e = registry.get(tag); + DecoderRegistry.Entry e = registry.get(tag); if (e == null) { throw new IOException("Unhandled tag " + tag); } - LabCommDispatcher d = e.getDispatcher(); + SampleDispatcher d = e.getDispatcher(); if (d == null) { throw new IOException("No dispatcher for '" + e.getName() + "'"); } - LabCommHandler h = e.getHandler(); + SampleHandler h = e.getHandler(); if (h == null) { throw new IOException("No handler for '" + e.getName() +"'"); } @@ -53,11 +53,11 @@ public class LabCommDecoderChannel implements LabCommDecoder { } } - private void collectFlatSignature(LabCommEncoder out) throws IOException { + private void collectFlatSignature(Encoder out) throws IOException { int type = decodePacked32(); out.encodePacked32(type); switch (type) { - case LabComm.ARRAY: { + case Constant.ARRAY: { int dimensions = decodePacked32(); out.encodePacked32(dimensions); for (int i = 0 ; i < dimensions ; i++) { @@ -65,7 +65,7 @@ public class LabCommDecoderChannel implements LabCommDecoder { } collectFlatSignature(out); } break; - case LabComm.STRUCT: { + case Constant.STRUCT: { int fields = decodePacked32(); out.encodePacked32(fields); for (int i = 0 ; i < fields ; i++) { @@ -73,14 +73,14 @@ public class LabCommDecoderChannel implements LabCommDecoder { collectFlatSignature(out); } } break; - case LabComm.BOOLEAN: - case LabComm.BYTE: - case LabComm.SHORT: - case LabComm.INT: - case LabComm.LONG: - case LabComm.FLOAT: - case LabComm.DOUBLE: - case LabComm.STRING: { + case Constant.BOOLEAN: + case Constant.BYTE: + case Constant.SHORT: + case Constant.INT: + case Constant.LONG: + case Constant.FLOAT: + case Constant.DOUBLE: + case Constant.STRING: { } break; default: { throw new IOException("Unimplemented type=" + type); @@ -89,8 +89,8 @@ public class LabCommDecoderChannel implements LabCommDecoder { out.end(null); } - public void register(LabCommDispatcher dispatcher, - LabCommHandler handler) throws IOException { + public void register(SampleDispatcher dispatcher, + SampleHandler handler) throws IOException { registry.add(dispatcher, handler); } diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDecoderRegistry.java b/lib/java/se/lth/control/labcomm2006/DecoderRegistry.java similarity index 84% rename from lib/java/se/lth/control/labcomm2006/LabCommDecoderRegistry.java rename to lib/java/se/lth/control/labcomm2006/DecoderRegistry.java index a94bc6e..8bce34d 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommDecoderRegistry.java +++ b/lib/java/se/lth/control/labcomm2006/DecoderRegistry.java @@ -3,18 +3,18 @@ package se.lth.control.labcomm2006; import java.io.IOException; import java.util.HashMap; -public class LabCommDecoderRegistry { +public class DecoderRegistry { public static class Entry { - private LabCommDispatcher dispatcher; - private LabCommHandler handler; + private SampleDispatcher dispatcher; + private SampleHandler handler; private int index; private String name; private byte[] signature; - public Entry(LabCommDispatcher dispatcher, - LabCommHandler handler) { + public Entry(SampleDispatcher dispatcher, + SampleHandler handler) { this.dispatcher = dispatcher; this.name = dispatcher.getName(); this.signature = dispatcher.getSignature(); @@ -27,19 +27,19 @@ public class LabCommDecoderRegistry { this.signature = signature; } - public LabCommDispatcher getDispatcher() { + public SampleDispatcher getDispatcher() { return dispatcher; } - public void setDispatcher(LabCommDispatcher dispatcher) { + public void setDispatcher(SampleDispatcher dispatcher) { this.dispatcher = dispatcher; } - public LabCommHandler getHandler() { + public SampleHandler getHandler() { return handler; } - public void setHandler(LabCommHandler handler) { + public void setHandler(SampleHandler handler) { this.handler = handler; } @@ -89,13 +89,13 @@ public class LabCommDecoderRegistry { private HashMap<Class, Entry> byClass; private HashMap<Integer, Entry> byIndex; - public LabCommDecoderRegistry() { + public DecoderRegistry() { byClass = new HashMap<Class, Entry>(); byIndex = new HashMap<Integer, Entry>(); } - public synchronized void add(LabCommDispatcher dispatcher, - LabCommHandler handler) throws IOException{ + public synchronized void add(SampleDispatcher dispatcher, + SampleHandler handler) throws IOException{ Entry e = byClass.get(dispatcher.getSampleClass()); if (e != null) { e.check(dispatcher.getName(), dispatcher.getSignature()); @@ -141,4 +141,4 @@ public class LabCommDecoderRegistry { return byIndex.get(Integer.valueOf(index)); } -} \ No newline at end of file +} diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoder.java b/lib/java/se/lth/control/labcomm2006/Encoder.java similarity index 71% rename from lib/java/se/lth/control/labcomm2006/LabCommEncoder.java rename to lib/java/se/lth/control/labcomm2006/Encoder.java index 51c2223..eaf54b2 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommEncoder.java +++ b/lib/java/se/lth/control/labcomm2006/Encoder.java @@ -2,11 +2,11 @@ package se.lth.control.labcomm2006; import java.io.IOException; -public interface LabCommEncoder { +public interface Encoder { - public void register(LabCommDispatcher dispatcher) throws IOException; - public void begin(Class<? extends LabCommSample> c) throws IOException; - public void end(Class<? extends LabCommSample> c) throws IOException; + public void register(SampleDispatcher dispatcher) throws IOException; + public void begin(Class<? extends Sample> c) throws IOException; + public void end(Class<? extends Sample> c) throws IOException; public void encodeBoolean(boolean value) throws IOException; public void encodeByte(byte value) throws IOException; public void encodeShort(short value) throws IOException; diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java b/lib/java/se/lth/control/labcomm2006/EncoderChannel.java similarity index 73% rename from lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java rename to lib/java/se/lth/control/labcomm2006/EncoderChannel.java index 173ff50..b6c8ab7 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java +++ b/lib/java/se/lth/control/labcomm2006/EncoderChannel.java @@ -5,40 +5,40 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; -public class LabCommEncoderChannel implements LabCommEncoder { +public class EncoderChannel implements Encoder { - private LabCommWriter writer; + private Writer writer; private ByteArrayOutputStream bytes; private DataOutputStream data; - private LabCommEncoderRegistry registry; + private EncoderRegistry registry; - public LabCommEncoderChannel(LabCommWriter writer, - boolean emitVersion) throws IOException { + public EncoderChannel(Writer writer, + boolean emitVersion) throws IOException { this.writer = writer; bytes = new ByteArrayOutputStream(); data = new DataOutputStream(bytes); - registry = new LabCommEncoderRegistry(); + registry = new EncoderRegistry(); if (emitVersion) { throw new IllegalArgumentException("Labcomm 2006 does not support emitVersion"); } } - public LabCommEncoderChannel(LabCommWriter writer) throws IOException { + public EncoderChannel(Writer writer) throws IOException { this(writer, false); } - public LabCommEncoderChannel(OutputStream writer, - boolean emitVersion) throws IOException { + public EncoderChannel(OutputStream writer, + boolean emitVersion) throws IOException { this(new WriterWrapper(writer), emitVersion); } - public LabCommEncoderChannel(OutputStream writer) throws IOException { + public EncoderChannel(OutputStream writer) throws IOException { this(new WriterWrapper(writer), false); } - public void register(LabCommDispatcher dispatcher) throws IOException { + public void register(SampleDispatcher dispatcher) throws IOException { int index = registry.add(dispatcher); - encodePacked32(LabComm.SAMPLE); + encodePacked32(Constant.SAMPLE); encodePacked32(index); encodeString(dispatcher.getName()); byte[] signature = dispatcher.getSignature(); @@ -48,11 +48,11 @@ public class LabCommEncoderChannel implements LabCommEncoder { end(null); } - public void begin(Class<? extends LabCommSample> c) throws IOException { + public void begin(Class<? extends Sample> c) throws IOException { encodePacked32(registry.getTag(c)); } - public void end(Class<? extends LabCommSample> c) throws IOException { + public void end(Class<? extends Sample> c) throws IOException { data.flush(); //XXX when writer was a stream, it was probably a bit more GC efficient: //bytes.writeTo(writer); diff --git a/lib/java/se/lth/control/labcomm2006/LabCommEncoderRegistry.java b/lib/java/se/lth/control/labcomm2006/EncoderRegistry.java similarity index 66% rename from lib/java/se/lth/control/labcomm2006/LabCommEncoderRegistry.java rename to lib/java/se/lth/control/labcomm2006/EncoderRegistry.java index 2a5564e..70f6eb7 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommEncoderRegistry.java +++ b/lib/java/se/lth/control/labcomm2006/EncoderRegistry.java @@ -3,19 +3,19 @@ package se.lth.control.labcomm2006; import java.io.IOException; import java.util.HashMap; -public class LabCommEncoderRegistry { +public class EncoderRegistry { public static class Entry { - private LabCommDispatcher dispatcher; + private SampleDispatcher dispatcher; private int index; - public Entry(LabCommDispatcher dispatcher, int index) { + public Entry(SampleDispatcher dispatcher, int index) { this.dispatcher = dispatcher; this.index = index; } - public LabCommDispatcher getDispatcher() { + public SampleDispatcher getDispatcher() { return dispatcher; } @@ -25,14 +25,14 @@ public class LabCommEncoderRegistry { } - private int userIndex = LabComm.FIRST_USER_INDEX; + private int userIndex = Constant.FIRST_USER_INDEX; private HashMap<Class, Entry> byClass; - public LabCommEncoderRegistry() { + public EncoderRegistry() { byClass = new HashMap<Class, Entry>(); } - public synchronized int add(LabCommDispatcher dispatcher) { + public synchronized int add(SampleDispatcher dispatcher) { Entry e = byClass.get(dispatcher.getSampleClass()); if (e == null) { e = new Entry(dispatcher, userIndex); @@ -42,7 +42,7 @@ public class LabCommEncoderRegistry { return e.getIndex(); } - public int getTag(Class<? extends LabCommSample> sample) throws IOException { + public int getTag(Class<? extends Sample> sample) throws IOException { Entry e = byClass.get(sample); if (e == null) { throw new IOException("'" + @@ -52,4 +52,4 @@ public class LabCommEncoderRegistry { return e.index; } -} \ No newline at end of file +} diff --git a/lib/java/se/lth/control/labcomm2006/LabCommReader.java b/lib/java/se/lth/control/labcomm2006/Reader.java similarity index 74% rename from lib/java/se/lth/control/labcomm2006/LabCommReader.java rename to lib/java/se/lth/control/labcomm2006/Reader.java index 1c2561d..62cdacf 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommReader.java +++ b/lib/java/se/lth/control/labcomm2006/Reader.java @@ -1,6 +1,6 @@ package se.lth.control.labcomm2006; -public interface LabCommReader { +public interface Reader { public void handle(byte[] data, int begin, int end); diff --git a/lib/java/se/lth/control/labcomm2006/LabCommType.java b/lib/java/se/lth/control/labcomm2006/Sample.java similarity index 55% rename from lib/java/se/lth/control/labcomm2006/LabCommType.java rename to lib/java/se/lth/control/labcomm2006/Sample.java index 0722e6d..a20b06a 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommType.java +++ b/lib/java/se/lth/control/labcomm2006/Sample.java @@ -1,5 +1,5 @@ package se.lth.control.labcomm2006; -public interface LabCommType { +public interface Sample { } \ No newline at end of file diff --git a/lib/java/se/lth/control/labcomm2006/LabCommDispatcher.java b/lib/java/se/lth/control/labcomm2006/SampleDispatcher.java similarity index 50% rename from lib/java/se/lth/control/labcomm2006/LabCommDispatcher.java rename to lib/java/se/lth/control/labcomm2006/SampleDispatcher.java index 469627e..f3acd50 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommDispatcher.java +++ b/lib/java/se/lth/control/labcomm2006/SampleDispatcher.java @@ -1,6 +1,6 @@ package se.lth.control.labcomm2006; -public interface LabCommDispatcher { +public interface SampleDispatcher { public Class getSampleClass(); @@ -8,8 +8,8 @@ public interface LabCommDispatcher { public byte[] getSignature(); - public void decodeAndHandle(LabCommDecoder decoder, - LabCommHandler handler) throws Exception; + public void decodeAndHandle(Decoder decoder, + SampleHandler handler) throws Exception; } diff --git a/lib/java/se/lth/control/labcomm2006/LabCommHandler.java b/lib/java/se/lth/control/labcomm2006/SampleHandler.java similarity index 51% rename from lib/java/se/lth/control/labcomm2006/LabCommHandler.java rename to lib/java/se/lth/control/labcomm2006/SampleHandler.java index 2880c19..046e3b4 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommHandler.java +++ b/lib/java/se/lth/control/labcomm2006/SampleHandler.java @@ -1,4 +1,4 @@ package se.lth.control.labcomm2006; -public interface LabCommHandler { -} \ No newline at end of file +public interface SampleHandler { +} diff --git a/lib/java/se/lth/control/labcomm2006/LabCommSample.java b/lib/java/se/lth/control/labcomm2006/Type.java similarity index 54% rename from lib/java/se/lth/control/labcomm2006/LabCommSample.java rename to lib/java/se/lth/control/labcomm2006/Type.java index d1dc1ff..63646a0 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommSample.java +++ b/lib/java/se/lth/control/labcomm2006/Type.java @@ -1,5 +1,5 @@ package se.lth.control.labcomm2006; -public interface LabCommSample { +public interface Type { } \ No newline at end of file diff --git a/lib/java/se/lth/control/labcomm2006/LabCommWriter.java b/lib/java/se/lth/control/labcomm2006/Writer.java similarity index 78% rename from lib/java/se/lth/control/labcomm2006/LabCommWriter.java rename to lib/java/se/lth/control/labcomm2006/Writer.java index e70e142..e02b77d 100644 --- a/lib/java/se/lth/control/labcomm2006/LabCommWriter.java +++ b/lib/java/se/lth/control/labcomm2006/Writer.java @@ -2,7 +2,7 @@ package se.lth.control.labcomm2006; import java.io.IOException; -public interface LabCommWriter { +public interface Writer { public void write(byte[] data) throws IOException; diff --git a/lib/java/se/lth/control/labcomm2006/WriterWrapper.java b/lib/java/se/lth/control/labcomm2006/WriterWrapper.java index 4c96d88..b25c0d8 100644 --- a/lib/java/se/lth/control/labcomm2006/WriterWrapper.java +++ b/lib/java/se/lth/control/labcomm2006/WriterWrapper.java @@ -3,7 +3,7 @@ package se.lth.control.labcomm2006; import java.io.OutputStream; import java.io.IOException; -class WriterWrapper implements LabCommWriter{ +class WriterWrapper implements Writer{ private OutputStream os; diff --git a/test/relay_gen_java.py b/test/relay_gen_java.py index 93644bc..40f584e 100755 --- a/test/relay_gen_java.py +++ b/test/relay_gen_java.py @@ -26,8 +26,8 @@ if __name__ == '__main__': |import java.io.FileInputStream; |import java.io.FileOutputStream; |import java.io.IOException; - |import se.lth.control.labcomm.LabCommDecoderChannel; - |import se.lth.control.labcomm.LabCommEncoderChannel; + |import se.lth.control.labcomm.DecoderChannel; + |import se.lth.control.labcomm.EncoderChannel; | |public class java_relay implements """)) @@ -37,7 +37,7 @@ if __name__ == '__main__': result.append(' %s.Handler' % sample[-1][0]) result.extend(split_match('^[^|]*\|(.*)$', """ |{ - | LabCommEncoderChannel encoder; + | EncoderChannel encoder; """)) for func,arg in sample: if arg == 'void': @@ -58,9 +58,9 @@ if __name__ == '__main__': result.extend(split_match('^[^|]*\|(.*)$', """ | public java_relay(String InName, String OutName) throws Exception { | FileInputStream InFile = new FileInputStream(InName); - | LabCommDecoderChannel d = new LabCommDecoderChannel(InFile); + | DecoderChannel d = new DecoderChannel(InFile); | FileOutputStream OutFile = new FileOutputStream(OutName); - | encoder = new LabCommEncoderChannel(OutFile); + | encoder = new EncoderChannel(OutFile); | """)) for func,arg in sample: -- GitLab