Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Jansson
LabComm
Commits
d6c8fa44
"lib/c/2006/labcomm2006_error.h" did not exist on "984ddf795469bfe99682b3fbdfef7452bf35d8ef"
Commit
d6c8fa44
authored
Oct 25, 2014
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
more java decoder pragma skeleton
parent
9bfa7c14
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/java/se/lth/control/labcomm/DecoderChannel.java
+56
-13
56 additions, 13 deletions
lib/java/se/lth/control/labcomm/DecoderChannel.java
with
56 additions
and
13 deletions
lib/java/se/lth/control/labcomm/DecoderChannel.java
+
56
−
13
View file @
d6c8fa44
...
...
@@ -3,6 +3,7 @@ package se.lth.control.labcomm;
import
java.io.ByteArrayOutputStream
;
import
java.io.DataInputStream
;
import
java.io.InputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.EOFException
;
...
...
@@ -11,11 +12,55 @@ public class DecoderChannel implements Decoder {
private
DataInputStream
in
;
private
DecoderRegistry
registry
;
public
DecoderChannel
(
InputStream
in
)
throws
IOException
{
public
DecoderChannel
(
InputStream
in
,
DecoderRegistry
reg
)
throws
IOException
{
this
.
in
=
new
DataInputStream
(
in
);
registry
=
new
DecoderRegistry
();
this
.
registry
=
reg
;
}
public
DecoderChannel
(
InputStream
in
)
throws
IOException
{
this
(
in
,
new
DecoderRegistry
());
}
private
void
processSampleDef
()
throws
IOException
{
int
index
=
decodePacked32
();
String
name
=
decodeString
();
int
signature_length
=
decodePacked32
();
byte
[]
signature
=
new
byte
[
signature_length
];
ReadBytes
(
signature
,
signature_length
);
registry
.
add
(
index
,
name
,
signature
);
}
private
void
processPragma
(
int
len
)
throws
IOException
{
// String pt = decodeString();
// System.out.println("Pragma["+pt+"]: skipping "+plen+" bytes");
// for(int i=0; i<plen; i++) {
// decodeByte();
// }
String
type
=
decodeString
();
int
plen
=
len
-
(
type
.
length
()+
1
);
// XXX HERE BE DRAGONS: +1?
System
.
out
.
println
(
"[ begin pragma ("
+
type
+
") ]"
);
//System.out.println("metadata : "+len + " bytes, ref: " + Integer.toHexString(typeRefId)+".");
byte
buf
[]
=
new
byte
[
plen
];
for
(
int
i
=
0
;
i
<
plen
;
i
++)
{
buf
[
i
]=
decodeByte
();
}
ByteArrayInputStream
bis
=
new
ByteArrayInputStream
(
buf
);
DecoderChannel
pd
=
new
DecoderChannel
(
bis
,
registry
);
try
{
pd
.
run
();
}
catch
(
java
.
io
.
EOFException
ex
)
{
// We're done.
}
catch
(
Throwable
e
)
{
// Something unexpected happened
// (an unregistered handler is OK, but still report it.
// TODO: implement exception handling here. Aborting is fine,
// that only means skipping the rest of the metadata packet.)
System
.
out
.
println
(
"Exception while decoding pragma: "
+
e
);
}
System
.
out
.
println
(
"[ end pragma ]"
);
}
public
void
runOne
()
throws
Exception
{
boolean
done
=
false
;
while
(!
done
)
{
...
...
@@ -30,23 +75,21 @@ public class DecoderChannel implements Decoder {
}
}
break
;
case
Constant
.
SAMPLE_DEF
:
{
int
index
=
decodePacked32
();
String
name
=
decodeString
();
int
signature_length
=
decodePacked32
();
byte
[]
signature
=
new
byte
[
signature_length
];
ReadBytes
(
signature
,
signature_length
);
registry
.
add
(
index
,
name
,
signature
);
processSampleDef
();
}
break
;
case
Constant
.
PRAGMA
:
{
System
.
out
.
println
(
"Pragma: skipping "
+
length
+
" bytes"
);
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
decodeByte
();
}
processPragma
(
length
);
// String pt = decodeString();
// int plen = length - pt.length()-1;
// System.out.println("Pragma["+pt+"]: skipping "+plen+" bytes");
// for(int i=0; i<plen; i++) {
// decodeByte();
// }
}
break
;
default
:
{
DecoderRegistry
.
Entry
e
=
registry
.
get
(
tag
);
if
(
e
==
null
)
{
throw
new
IOException
(
"Unhandled tag "
+
tag
);
throw
new
IOException
(
"Unhandled tag
0x
"
+
Integer
.
toHexString
(
tag
)
)
;
}
SampleDispatcher
d
=
e
.
getDispatcher
();
if
(
d
==
null
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment