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
Erik Jansson
LabComm
Commits
0b806600
Commit
0b806600
authored
Mar 07, 2013
by
Sven Robertz
Browse files
started refactoring Java EncoderChannel to use LabCommWriter + minor fixes
parent
245a4f7c
Changes
5
Hide whitespace changes
Inline
Side-by-side
compiler/build.xml
View file @
0b806600
...
...
@@ -15,7 +15,7 @@
<property
name=
"tools"
value=
"tools"
/>
<!-- "test" is the directory where tests are located. -->
<property
name=
"test"
value=
"test"
/>
<property
name=
"test"
value=
"
../
test"
/>
<!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
<taskdef
name=
"jflex"
classname=
"JFlex.anttask.JFlexTask"
classpath=
"tools/JFlex.jar"
/>
...
...
@@ -66,7 +66,7 @@ classpath="tools/jastadd2.jar"/>
<!-- compile sources -->
<target
name=
"test"
depends=
"jar"
>
<echo
message =
"Running tests"
/>
<exec
executable=
"./run"
dir=
"test"
>
<exec
executable=
"./run"
dir=
"
../
test"
>
<env
key=
"PYTHONPATH"
value=
"../lib/python"
/>
<!--arg value="hej"/-->
</exec>
...
...
lib/c/labcomm_fd_reader_writer.h
View file @
0b806600
...
...
@@ -6,4 +6,5 @@ extern int labcomm_fd_reader(
extern
int
labcomm_fd_writer
(
labcomm_writer_t
*
r
,
labcomm_writer_action_t
action
);
labcomm_writer_action_t
action
,
...);
lib/java/se/lth/control/labcomm/LabCommEncoderChannel.java
View file @
0b806600
...
...
@@ -7,18 +7,22 @@ import java.io.OutputStream;
public
class
LabCommEncoderChannel
implements
LabCommEncoder
{
private
OutputStream
writer
;
private
LabCommWriter
writer
;
private
ByteArrayOutputStream
bytes
;
private
DataOutputStream
data
;
private
LabCommEncoderRegistry
registry
;
public
LabCommEncoderChannel
(
OutputStream
writer
)
{
public
LabCommEncoderChannel
(
LabCommWriter
writer
)
{
this
.
writer
=
writer
;
bytes
=
new
ByteArrayOutputStream
();
data
=
new
DataOutputStream
(
bytes
);
registry
=
new
LabCommEncoderRegistry
();
}
public
LabCommEncoderChannel
(
OutputStream
writer
)
{
this
(
new
WriterWrapper
(
writer
));
}
public
void
register
(
LabCommDispatcher
dispatcher
)
throws
IOException
{
int
index
=
registry
.
add
(
dispatcher
);
encodePacked32
(
LabComm
.
SAMPLE
);
...
...
@@ -37,7 +41,9 @@ public class LabCommEncoderChannel implements LabCommEncoder {
public
void
end
(
Class
<?
extends
LabCommSample
>
c
)
throws
IOException
{
data
.
flush
();
bytes
.
writeTo
(
writer
);
//XXX when writer was a stream, it was probably a bit more GC efficient:
//bytes.writeTo(writer);
writer
.
write
(
bytes
.
toByteArray
());
bytes
.
reset
();
}
...
...
lib/java/se/lth/control/labcomm/LabCommWriter.java
View file @
0b806600
package
se.lth.control.labcomm
;
import
java.io.IOException
;
public
interface
LabCommWriter
{
public
void
write
(
byte
[]
data
);
public
void
write
(
byte
[]
data
)
throws
IOException
;
}
lib/java/se/lth/control/labcomm/WriterWrapper.java
0 → 100644
View file @
0b806600
package
se.lth.control.labcomm
;
import
java.io.OutputStream
;
import
java.io.IOException
;
class
WriterWrapper
implements
LabCommWriter
{
private
OutputStream
os
;
public
WriterWrapper
(
OutputStream
os
)
{
this
.
os
=
os
;
}
public
void
write
(
byte
[]
data
)
throws
IOException
{
os
.
write
(
data
);
}
}
Write
Preview
Supports
Markdown
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