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
Select Git revision
  • anders.blomdell
  • compiler-refactoring
  • java_dyn_msg_dec
  • js
  • labcomm2013
  • labcomm2014
  • labcomm2014_tc31
  • master
  • pragma
  • typeref
  • v2013.0
  • v2014.0
  • v2014.1
13 results

Target

Select target project
  • anders_blomdell/labcomm
  • klaren/labcomm
  • tommyo/labcomm
  • erikj/labcomm
  • sven/labcomm
5 results
Select Git revision
  • anders.blomdell
  • compiler-refactoring
  • labcomm2006
  • labcomm2013
  • labcomm2014
  • master
  • pragma
  • python_sig_hash
  • typedefs
  • typeref
  • v2006.0
  • v2013.0
  • v2014.0
  • v2014.1
  • v2014.2
  • v2014.3
  • v2014.4
  • v2014.5
  • v2014.6
  • v2015.0
20 results
Show changes
Commits on Source (1)
MODULES=Constant \
Decoder \
DecoderChannel \
DynamicDecoderChannel \
DecoderRegistry \
Encoder \
EncoderChannel \
......
......@@ -8,9 +8,9 @@ import java.io.EOFException;
public class DecoderChannel implements Decoder {
private DataInputStream in;
private DecoderRegistry def_registry = new DecoderRegistry();
private DecoderRegistry ref_registry = new DecoderRegistry();
protected DataInputStream in;
protected DecoderRegistry def_registry = new DecoderRegistry();
protected DecoderRegistry ref_registry = new DecoderRegistry();
public DecoderChannel(InputStream in) throws IOException {
this.in = new DataInputStream(in);
......@@ -55,9 +55,38 @@ public class DecoderChannel implements Decoder {
}
}
protected void processSample(int tag) throws Exception {
DecoderRegistry.Entry e = def_registry.get(tag);
if (e == null) {
throw new IOException("Unhandled tag " + tag);
}
SampleDispatcher d = e.getDispatcher();
if (d == null) {
throw new IOException("No dispatcher for '" + e.getName() + "'");
}
SampleHandler h = e.getHandler();
if (h == null) {
throw new IOException("No handler for '" + e.getName() +"'");
}
d.decodeAndHandle(this, h);
}
public void runOne() throws Exception {
boolean done = false;
while (!done) {
runOne(true);
}
/**
* Run the decoder.
*
* @param waitForSample Wether to wait until an actual sample has
* been decoded or to return after any complete entity has
* been decoded. Set to <code>true</code> to get the old
* behaviour.
*/
public void runOne(boolean waitForSample) throws Exception {
boolean done = !waitForSample;
do {
int tag = decodePacked32();
int length = decodePacked32();
switch (tag) {
......@@ -84,23 +113,11 @@ public class DecoderChannel implements Decoder {
processPragma(length);
} break;
default: {
DecoderRegistry.Entry e = def_registry.get(tag);
if (e == null) {
throw new IOException("Unhandled tag " + tag);
}
SampleDispatcher d = e.getDispatcher();
if (d == null) {
throw new IOException("No dispatcher for '" + e.getName() + "'");
}
SampleHandler h = e.getHandler();
if (h == null) {
throw new IOException("No handler for '" + e.getName() +"'");
}
d.decodeAndHandle(this, h);
processSample(tag);
done = true;
}
}
}
} while (!done);
}
public void run() throws Exception {
......
package se.lth.control.labcomm;
import java.io.IOException;
import java.io.InputStream;
public class DynamicDecoderChannel extends DecoderChannel {
public DynamicDecoderChannel(InputStream in) throws IOException {
super(in);
}
public void runOne() throws Exception {
runOne(false);
}
protected void processSample(int tag) throws Exception {
DecoderRegistry.Entry e = def_registry.get(tag);
if (e == null)
throw new IOException("Have not read any registration for " + tag);
SampleDispatcher d = e.getDispatcher();
if (d != null) {
SampleHandler h = e.getHandler();
if (h == null)
throw new IOException("No handler for '" + e.getName() +"'");
d.decodeAndHandle(this, h);
} else {
dynamicDecode();
}
}
private void dynamicDecode() {
throw new UnsupportedOperationException("Dynamic decoding not implemented yet.");
}
}
package se.lth.control.labcomm2006;
import java.io.IOException;
import java.io.InputStream;
public class DynamicDecoderChannel extends DecoderChannel {
public DynamicDecoderChannel(InputStream in) throws IOException {
super(in);
throw new UnsupportedOperationException("Use 2014.");
}
}