Skip to content
Snippets Groups Projects
Commit c222f77c authored by Sven Robertz's avatar Sven Robertz
Browse files

added var array

parent 4143e65f
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ import java.io.InputStream;
import se.lth.control.labcomm.LabCommDecoderChannel;
public class Decoder
implements TwoInts.Handler, IntString.Handler
implements TwoInts.Handler, IntString.Handler, TwoArrays.Handler
{
LabCommDecoderChannel decoder;
......@@ -16,6 +16,7 @@ public class Decoder
decoder = new LabCommDecoderChannel(in);
TwoInts.register(decoder, this);
IntString.register(decoder, this);
TwoArrays.register(decoder, this);
try {
System.out.println("Running decoder.");
......@@ -33,6 +34,18 @@ public class Decoder
System.out.println("Got IntString, x="+d.x+", s="+d.s);
}
public void handle_TwoArrays(TwoArrays d) throws java.io.IOException {
System.out.println("Got TwoArrays:");
for(int i=0; i<d.fixed.length; i++) {
System.out.print(d.fixed[i]+" ");
}
System.out.println();
for(int i=0; i<d.variable[0].length; i++) {
System.out.print(d.variable[0][i]+" ");
System.out.print(d.variable[1][i]+" ");
}
System.out.println();
}
public static void main(String[] arg) throws Exception {
Decoder example = new Decoder(
......
......@@ -28,19 +28,25 @@ int main(int argc, char *argv[]) {
printf("Encoding TwoInts, a=%d, b=%d\n", ti.a, ti.b);
labcomm_encode_simple_TwoInts(encoder, &ti);
int foo[10];
int foo[20];
simple_TwoArrays ta;
ta.fixed.a[0] = 17;
ta.fixed.a[1] = 42;
ta.variable.n_0 = 10;
ta.variable.n_1 = 10;
ta.variable.a = foo;
int k;
for(k=0; k<20; k++) {
foo[k] = k;
}
labcomm_encode_simple_TwoArrays(encoder, &ta);
ti.a = 23;
ti.b = 47;
printf("Encoding TwoInts, a=%d, b=%d\n", ti.a, ti.b);
labcomm_encode_simple_TwoInts(encoder, &ti);
labcomm_encode_simple_TwoArrays(encoder, &ta);
}
......@@ -15,5 +15,5 @@ sample struct {
sample struct {
int fixed[2];
int variable[_];
int variable[2,_];
} TwoArrays;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment