From 5f273d102f8426df97dadf79ec8b505237cc65e9 Mon Sep 17 00:00:00 2001
From: Sven Gestegard Robertz <sven.robertz@cs.lth.se>
Date: Fri, 13 Feb 2015 13:57:54 +0100
Subject: [PATCH] added minimal encoder to examples/simple

---
 examples/simple/EncoderIS.java | 53 ++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 examples/simple/EncoderIS.java

diff --git a/examples/simple/EncoderIS.java b/examples/simple/EncoderIS.java
new file mode 100644
index 0000000..4d7fd3a
--- /dev/null
+++ b/examples/simple/EncoderIS.java
@@ -0,0 +1,53 @@
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import se.lth.control.labcomm.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();
+  }
+
+}
+
-- 
GitLab