Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Show changes
Showing
with 285 additions and 98 deletions
......@@ -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.labcomm2014.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);
}
......
......@@ -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 AST.Program;
import se.lth.control.labcomm2014.Decoder;
import se.lth.control.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.Encoder;
import se.lth.control.labcomm2014.EncoderChannel;
import AST.Parser;
import AST.Scanner;
import AST.Specification;
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();
......@@ -121,15 +121,15 @@ public class TestLabCommCompiler {
}
public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
Program ast = null;
Specification 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;
try {
Program p = (Program)parser.parse(scanner);
Specification p = (Specification)parser.parse(scanner);
p.errorCheck(errors);
if (errors.isEmpty()) {
ast = p;
......@@ -207,10 +207,10 @@ public class TestLabCommCompiler {
* @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases
*/
private static InRAMCompiler handleAst(Program lcAST, HashMap<String, String> handlers) {
private static InRAMCompiler handleAst(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>();
try {
lcAST.J_gen(genCode, "labcomm.generated");
lcAST.J_gen(genCode, "labcomm.generated", 2013);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -18,17 +18,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 AST.Program;
import se.lth.control.labcomm2014.Decoder;
import se.lth.control.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.Encoder;
import se.lth.control.labcomm2014.EncoderChannel;
import se.lth.control.labcomm2014.compiler.LabCommParser;
import se.lth.control.labcomm2014.compiler.LabCommScanner;
import se.lth.control.labcomm2014.compiler.Program;
import beaver.Parser.Exception;
public class TestLabcommGen {
private static final String TYPE_NAME_FOO = "foo_t";
private static final String SAMPLE_NAME_FOO = "foo";
private static final String SAMPLE_NAME_BAR = "bar";
......@@ -79,7 +80,7 @@ public class TestLabcommGen {
if(irc != null) {
System.out.println("*** Testing instantiation and invocation of Handler ");
dummyTest(irc);
//dummyTest(irc);
String tmpFile = args[2];
System.out.println("*** Testing writing and reading file "+tmpFile);
......@@ -160,7 +161,7 @@ public class TestLabcommGen {
}
public static InRAMCompiler generateCode(String lcDecl, HashMap<String, String> handlers) {
Program ast = null;
Specification ast = null;
InputStream in = new ByteArrayInputStream(lcDecl.getBytes());
LabCommScanner scanner = new LabCommScanner(in);
LabCommParser parser = new LabCommParser();
......@@ -168,7 +169,7 @@ public class TestLabcommGen {
InRAMCompiler irc = null;
try {
Program p = (Program)parser.parse(scanner);
Specification p = (Specification)parser.parse(scanner);
p.errorCheck(errors);
if (errors.isEmpty()) {
ast = p;
......@@ -199,10 +200,10 @@ public class TestLabcommGen {
* @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases
*/
private static InRAMCompiler handleAst(Program lcAST, HashMap<String, String> handlers) {
private static InRAMCompiler handleAst(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>();
try {
lcAST.J_gen(genCode, "labcomm.generated");
lcAST.J_gen(genCode, "labcomm.generated", 2014);
} catch (IOException e) {
e.printStackTrace();
}
......@@ -226,25 +227,35 @@ public class TestLabcommGen {
try {
while(i.hasNext()){
final String sampleName = i.next();
System.out.println("sample: "+sampleName);
final String src = genCode.get(sampleName);
handlerClass.append(sampleName+".Handler");
if(i.hasNext()) {
handlerClass.append(", ");
String hctmp = handlers.get(sampleName);
if(hctmp != null) {
handlerClass.append(sampleName+".Handler");
if(i.hasNext()) {
handlerClass.append(", ");
}
handlerMethods.append(hctmp);
handlerMethods.append("\n");
}
handlerMethods.append(handlers.get(sampleName));
handlerMethods.append("\n");
//System.out.println("FOOOO:"+sampleName+"++++"+hctmp);
//System.out.println("GOOO: "+sampleName+"----"+handlerMethods);
System.out.println("***"+sampleName+"\n"+src);
irc.compile(sampleName, src); // while iterating, compile the labcomm generated code
}
handlerClass.append("{\n");
handlerClass.append(handlerAttributes);
handlerClass.append(handlerConstr);
handlerClass.append(handlerConstrCtxt);
handlerClass.append(handlerMethods.toString());
if(handlerAttributes != null)
handlerClass.append(handlerAttributes);
if(handlerConstr != null)
handlerClass.append(handlerConstr);
if(handlerConstrCtxt != null)
handlerClass.append(handlerConstrCtxt);
if(handlerMethods != null)
handlerClass.append(handlerMethods.toString());
handlerClass.append("}\n");
System.out.println("-------------------------------------");
System.out.println("--- generated code to compile -------"+ handlerClassName);
final String handlerSrc = handlerClass.toString();
System.out.println(handlerSrc);
......@@ -273,10 +284,10 @@ public class TestLabcommGen {
* @param handlers - a map <name, source> of handlers for the types in ast
* @return an InRAMCompiler object containing the generated clases
*/
private static InRAMCompiler handleAstSeparate(Program lcAST, HashMap<String, String> handlers) {
private static InRAMCompiler handleAstSeparate(Specification lcAST, HashMap<String, String> handlers) {
Map<String, String> genCode = new HashMap<String, String>();
try {
lcAST.J_gen(genCode, "labcomm.generated");
lcAST.J_gen(genCode, "labcomm.generated", 2013);
} catch (IOException e) {
e.printStackTrace();
}
......@@ -294,7 +305,7 @@ public class TestLabcommGen {
sb.append("public class gen_"+sampleName+"Handler implements "+sampleName+".Handler {\n");
sb.append(handlers.get(sampleName));
sb.append("}\n");
System.out.println("-------------------------------------");
System.out.println("--- foo -----------------------------");
System.out.println(sb.toString());
try {
irc.compile(sampleName, src);
......@@ -321,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();
......@@ -333,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);
}
......@@ -356,35 +367,42 @@ public class TestLabcommGen {
*/
private static void encodeTest(InRAMCompiler irc, String tmpFile) {
try {
Class ft;
Class fc = irc.load(SAMPLE_NAME_FOO);
Class bc = irc.load(SAMPLE_NAME_BAR);
try {
ft = irc.load(TYPE_NAME_FOO);
} catch (ClassNotFoundException e) {
System.out.println("encodeTest: defaulting to ft == fc");
ft = fc;
}
/* create sample class and instance objects */
Object f = fc.newInstance();
Object f = ft.newInstance();
Field x = fc.getDeclaredField("x");
Field y = fc.getDeclaredField("y");
Field z = fc.getDeclaredField("z");
Field x = ft.getDeclaredField("x");
Field y = ft.getDeclaredField("y");
Field z = ft.getDeclaredField("z");
x.setInt(f, 10);
y.setInt(f, 11);
z.setInt(f, 12);
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, fc);
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();
......@@ -457,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);
......@@ -466,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);
}
......
#dummy script to test the on-the-fly compilation
javac -cp .:../../compiler/labcomm2014_compiler.jar:../../lib/java/labcomm2014.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test/TestLabcommGen.java
javac test/HandlerContext.java
java -cp .:../../compiler/labcomm2014_compiler.jar:../../lib/java/labcomm2014.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test.TestLabcommGen simple_type.lc handlers_type.txt encoded_data
LCDIR=../..
LCC=java -jar ${LCDIR}/compiler/labComm.jar
CLASSPATH=.:${LCDIR}/lib/java/labcomm.jar
LABCOMM_JAR=../../compiler/labcomm2014_compiler.jar
LABCOMM=java -jar $(LABCOMM_JAR)
CLASSPATH=.:${LCDIR}/lib/java/labcomm2014.jar
JAVA_PKG=labcommTCPtest
SAMPLENAME=foo
LCC=java -jar ${LCDIR}/compiler/labComm.jar
LCLIBDIR=${LCDIR}/lib/c
LCFILE=jg
......@@ -12,7 +12,7 @@ TLCFILE=turtle1
TAUX=turtle_enc.c turtle_dec.c
${JAVA_PKG}/gen/foo.java: ${LCFILE}.lc
${LCC} --javapackage=${JAVA_PKG}.gen --java=${JAVA_PKG}/gen $<
${LABCOMM} --javapackage=${JAVA_PKG}.gen --java=${JAVA_PKG}/gen $<
${JAVA_PKG}/gen/${SAMPLENAME}.class: ${JAVA_PKG}/gen/${SAMPLENAME}.java
javac -cp ${CLASSPATH} $<
......@@ -24,9 +24,11 @@ ${JAVA_PKG}/client/TestClient.class: ${JAVA_PKG}/client/TestClient.java ${JAVA_P
javac -cp ${CLASSPATH} $<
.PHONY: runjavaserver
runjavaserver : ${JAVA_PKG}/server/TestServer.class
java -cp ${CLASSPATH} $(<:.class=)
.PHONY: runjavaclient
runjavaclient : ${JAVA_PKG}/client/TestClient.class
java -cp ${CLASSPATH} $(<:.class=)
......@@ -36,27 +38,34 @@ client: client.c ${LCFILE}.c ${AUX} ${AUX:.c=.h}
testserver: testserver.c ${LCFILE}.c ${AUX} ${AUX:.c=.h}
${CC} -o $@ testserver.c ${AUX} ${LCFILE}.c -I${LCLIBDIR} -L${LCLIBDIR} -llabcomm
turtleclient: turtleclient.c ${TLCFILE}.c ${TAUX} ${TAUX:.c=.h}
${CC} -o $@ turtleclient.c ${TAUX} ${TLCFILE}.c -I${LCLIBDIR} -L${LCLIBDIR} -llabcomm
${LCFILE}.c : ${LCFILE}.lc
${LCC} -C ${LCFILE}.lc
${LABCOMM} -C ${LCFILE}.lc
${TLCFILE}.c : ${TLCFILE}.lc
${LCC} -C ${TLCFILE}.lc
${LABCOMM} -C ${TLCFILE}.lc
all: client testserver ${JAVA_PKG}/server/TestServer.class ${JAVA_PKG}/client/TestClient.class turtleclient
.PHONY: clean runclient runserver runjavaserver runjavaclient turtleclient
.PHONY: clean
clean :
rm ${LCFILE}.c ${LCFILE}.h client testserver turtleclient
rm ${JAVA_PKG}/server/*.class ${JAVA_PKG}/client/*.class ${JAVA_PKG}/gen/*
rm -f ${LCFILE}.c ${LCFILE}.h client testserver turtleclient
rm -f ${JAVA_PKG}/server/*.class ${JAVA_PKG}/client/*.class
rm -f ${JAVA_PKG}/gen/*
.PHONY: distclean
distclean: clean
.PHONY: runclient
runclient : client
LD_LIBRARY_PATH=${LCLIBDIR} ./$< localhost 9999
.PHONY: runserver
runserver : testserver
LD_LIBRARY_PATH=${LCLIBDIR} ./$< 9999
.PHONY: runtclient
runtclient : turtleclient
LD_LIBRARY_PATH=${LCLIBDIR} ./$< localhost 8082
......@@ -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.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.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) {
......
......@@ -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.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.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) {
......
......@@ -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.labcomm2014.DecoderChannel;
import se.lth.control.labcomm2014.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;
......
/* Topic types */
sample struct {
string turtle_name;
float linear;
float angular;
} velocity;
sample struct {
string turtle_name;
float x;
float y;
float theta;
float linear_velocity;
float angular_velocity;
} pose;
sample struct {
string turtle_name;
float r;
float g;
float b;
} color;
/* Srv types */
sample void clear; /* Empty. */
sample void clear_resp; /* Empty. */
sample void reset; /* Empty. */
sample void reset_resp; /* Empty. */
sample string kill; /* Name of turtle. */
sample void kill_resp; /* Empty. */
sample struct {
string name;
float x;
float y;
float theta;
} spawn; /* Coordinates and direction. */
sample string spawn_resp; /* Returns name of turtle */
sample struct {
string turtle_name;
byte r;
byte g;
byte b;
byte width;
byte off;
} set_pen; /* Pen properties. */
sample void set_pen_resp; /* Empty. */
/* TODO: The following two are duplicates. Change to typedefs when working. */
sample struct {
string turtle_name;
float x;
float y;
float theta;
} teleport_absolute; /* Coordinates and direction. */
sample void teleport_absolute_resp; /* Empty. */
sample struct {
string turtle_name;
float linear;
float angular;
} teleport_relative; /* Similar to velocity but instant. */
sample void teleport_relative_resp; /* Empty. */
......@@ -3,4 +3,4 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
</configuration>
......@@ -46,4 +46,4 @@ MODULE Follow
RETURN;
ENDPROC
ENDMODULE
\ No newline at end of file
ENDMODULE
......@@ -35,4 +35,4 @@ sample struct {
float eax_e;
float eax_f;
} extax;
} jointtarget;
\ No newline at end of file
} jointtarget;
all:
clean:
distclean:
using se.lth.control.labcomm;
using se.lth.control.labcomm2014;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace RobotCtrl
{
class Program
class Specification
{
public static string IP_ADDRESS = "127.0.0.1";
......@@ -20,11 +20,11 @@ namespace RobotCtrl
{
jointtarget val = new jointtarget { robax = new jointtarget.struct_robax(), extax = new jointtarget.struct_extax() };
TcpClient client = new TcpClient();
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Program.IP_ADDRESS), Program.PORT);
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(Specification.IP_ADDRESS), Specification.PORT);
try
{
client.Connect(serverEndPoint);
LabCommEncoder enc = new LabCommEncoderChannel(client.GetStream(), true);
Encoder enc = new EncoderChannel(client.GetStream(), true);
jointtarget.register(enc);
jointtarget.encode(enc, val);
for (int i = 0; i < 10; i++)
......
......@@ -42,7 +42,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="LCRobot.cs" />
<Compile Include="Program.cs" />
<Compile Include="Specification.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......@@ -62,4 +62,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
</Project>
encoded_data
encoded_data06
example_decoder
example_decoder06
example_encoder
example_encoder06
gen
gen06
......@@ -2,24 +2,25 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import se.lth.control.labcomm.LabCommDecoderChannel;
import se.lth.control.labcomm2014.DecoderChannel;
public class Decoder
implements theTwoInts.Handler, anotherTwoInts.Handler, IntString.Handler, TwoArrays.Handler, TwoFixedArrays.Handler
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);
TwoArrays.register(decoder, this);
TwoFixedArrays.register(decoder, this);
doavoid.register(decoder, this);
try {
System.out.println("Running decoder.");
......@@ -72,6 +73,10 @@ public class Decoder
}
System.out.println();
}
public void handle_doavoid() throws java.io.IOException {
System.out.println("Got doavoid");
}
public static void main(String[] arg) throws Exception {
......
......@@ -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.labcomm2014.EncoderChannel;
/**
* Simple encoder
......@@ -10,18 +10,20 @@ 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);
doavoid.register(encoder);
theTwoInts.register(encoder);
IntString.register(encoder);
TwoArrays.register(encoder);
}
public void doEncode() throws java.io.IOException {
TwoInts x = new TwoInts();
x.a = 17;
x.b = 42;
......@@ -35,6 +37,9 @@ public class Encoder
// ta.variable = new int[][] {{1,2},{0x11,0x12},{0x21,0x22},{0x31,0x32}};
ta.variable = new int[][] {{1,2, 3, 4},{0x21,0x22,0x23,0x24}};
System.out.println("Encoding doavoid");
doavoid.encode(encoder);
System.out.println("Encoding theTwoInts, a="+x.a+", b="+x.b);
theTwoInts.encode(encoder, x);
......
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import se.lth.control.labcomm2014.EncoderChannel;
/**
* Simple encoder
*/
public class EncoderIS
{
EncoderChannel encoder;
public EncoderIS(OutputStream out)
throws Exception
{
encoder = new EncoderChannel(out);
// doavoid.register(encoder);
// theTwoInts.register(encoder);
IntString.register(encoder);
// TwoArrays.register(encoder);
}
public void doEncodeIS() throws java.io.IOException {
IntString a = new IntString();
a.x = 17;
a.s = "A string";
IntString b = new IntString();
b.x = 9;
b.s = "Hej";
IntString c = new IntString();
c.x = 133742;
c.s = "Thirteenthirtysevenfourtytwo";
System.out.println("Encoding IntStrings");
IntString.encode(encoder, a);
IntString.encode(encoder, b);
IntString.encode(encoder, c);
}
public static void main(String[] arg) throws Exception {
FileOutputStream fos = new FileOutputStream(arg[0]);
EncoderIS example = new EncoderIS(fos);
example.doEncodeIS();
fos.close();
}
}
all:
clean:
distclean:
rm -rf gen
rm -f *.class
rm -f example_encoder
rm -f example_decoder
rm -f encoded_data