Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sven Gestegård Robertz
LabComm
Commits
4a14ea73
Commit
4a14ea73
authored
Jul 16, 2013
by
Sven Robertz
Browse files
fixed static part so it runs. Still not integrated the demo
parent
b7760998
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/dynamic/StaticPart.java
View file @
4a14ea73
...
...
@@ -12,7 +12,7 @@ public class StaticPart {
/**
* Simple encoder
*/
public
class
Encoder
{
public
static
class
Encoder
{
LabCommEncoderChannel
encoder
;
...
...
@@ -20,30 +20,28 @@ public class StaticPart {
throws
Exception
{
encoder
=
new
LabCommEncoderChannel
(
out
);
theTwoInts
.
register
(
encoder
);
IntString
.
register
(
encoder
);
TwoArrays
.
register
(
encoder
);
foo
.
register
(
encoder
);
bar
.
register
(
encoder
);
}
public
void
doEncode
()
throws
java
.
io
.
IOException
{
TwoInts
x
=
new
TwoInts
();
x
.
a
=
17
;
x
.
b
=
42
;
IntString
y
=
new
IntString
();
y
.
x
=
37
;
y
.
s
=
"Testing, testing"
;
System
.
out
.
println
(
"Encoding theTwoInts, a="
+
x
.
a
+
", b="
+
x
.
b
);
theTwoInts
.
encode
(
encoder
,
x
);
System
.
out
.
println
(
"Encoding IntString, x="
+
y
.
x
+
", s="
+
y
.
s
);
IntString
.
encode
(
encoder
,
y
);
foo
f
=
new
foo
();
f
.
x
=
17
;
f
.
y
=
42
;
f
.
z
=
37
;
int
b
=
13
;
System
.
out
.
println
(
"Encoding foo, x="
+
f
.
x
+
", y="
+
f
.
y
+
", z="
+
f
.
z
);
foo
.
encode
(
encoder
,
f
);
System
.
out
.
println
(
"Encoding bar: "
+
b
);
bar
.
encode
(
encoder
,
b
);
}
}
public
class
Decoder
implements
theTwoInts
.
Handler
,
anotherTwoInts
.
Handler
,
IntString
.
Handler
public
static
class
Decoder
implements
foo
.
Handler
,
bar
.
Handler
{
LabCommDecoderChannel
decoder
;
...
...
@@ -52,46 +50,40 @@ public class StaticPart {
throws
Exception
{
decoder
=
new
LabCommDecoderChannel
(
in
);
theTwoInts
.
register
(
decoder
,
this
);
anotherTwoInts
.
register
(
decoder
,
this
);
IntString
.
register
(
decoder
,
this
);
TwoArrays
.
register
(
decoder
,
this
);
TwoFixedArrays
.
register
(
decoder
,
this
);
foo
.
register
(
decoder
,
this
);
bar
.
register
(
decoder
,
this
);
}
public
void
doDecode
()
throws
java
.
io
.
IOException
{
try
{
System
.
out
.
println
(
"Running decoder."
);
decoder
.
run
();
}
catch
(
java
.
io
.
EOFException
e
)
{
System
.
out
.
println
(
"Decoder reached end of file."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
printTwoInts
(
TwoInts
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"a="
+
d
.
a
+
", b="
+
d
.
b
);
}
public
void
handle_theTwoInts
(
TwoInts
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
print
(
"Got theTwoInts: "
);
printTwoInts
(
d
);
}
public
void
handle_anotherTwoInts
(
TwoInts
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
print
(
"Got anotherheTwoInts: "
);
printTwoInts
(
d
);
public
void
handle_foo
(
foo
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got foo, x="
+
d
.
x
+
", y="
+
d
.
y
+
", z="
+
d
.
z
);
}
public
void
handle_
IntString
(
IntString
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got
IntString, x="
+
d
.
x
+
", s="
+
d
.
s
);
public
void
handle_
bar
(
int
d
)
throws
java
.
io
.
IOException
{
System
.
out
.
println
(
"Got
bar: "
+
d
);
}
}
public
static
void
main
(
String
[]
arg
)
throws
Exception
{
FileOutputStream
fos
=
new
FileOutputStream
(
arg
[
0
]);
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
arg
[
0
]))
Encoder
example
=
new
Encoder
(
fos
);
Decoder
example
=
new
Decoder
(
fis
);
example
.
doEncode
();
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
arg
[
0
]));
Encoder
enc
=
new
Encoder
(
fos
);
Decoder
dec
=
new
Decoder
(
fis
);
enc
.
doEncode
();
dec
.
doDecode
();
fos
.
close
();
fis
.
close
();
}
...
...
examples/dynamic/TestLabcommGen.java
View file @
4a14ea73
...
...
@@ -31,6 +31,7 @@ public class TestLabcommGen {
private
static
final
String
SAMPLE_NAME_FOO
=
"foo"
;
private
static
final
String
SAMPLE_NAME_BAR
=
"bar"
;
/** A class representing the source code for one Labcomm handler */
static
class
HandlerSrc
{
private
String
sampleName
;
private
String
param
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment