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
Anders Blomdell
LabComm
Commits
0802e984
Commit
0802e984
authored
May 25, 2015
by
Sven Gestegård Robertz
Browse files
Csharp adapted to protocol with intentions. (Ignoring them)
parent
b638d1b1
Changes
2
Show whitespace changes
Inline
Side-by-side
lib/csharp/se/lth/control/labcomm2014/DecoderChannel.cs
View file @
0802e984
...
...
@@ -31,7 +31,7 @@ namespace se.lth.control.labcomm2014 {
}
break
;
case
Constant
.
SAMPLE_DEF
:
{
int
index
=
decodePacked32
();
String
name
=
decode
String
();
String
name
=
decode
Intentions
();
int
signature_length
=
decodePacked32
();
byte
[]
signature
=
new
byte
[
signature_length
];
ReadBytes
(
signature
,
signature_length
);
...
...
@@ -39,7 +39,7 @@ namespace se.lth.control.labcomm2014 {
}
break
;
case
Constant
.
SAMPLE_REF
:
{
int
index
=
decodePacked32
();
String
name
=
decode
String
();
String
name
=
decode
Intentions
();
int
signature_length
=
decodePacked32
();
byte
[]
signature
=
new
byte
[
signature_length
];
ReadBytes
(
signature
,
signature_length
);
...
...
@@ -166,6 +166,30 @@ namespace se.lth.control.labcomm2014 {
return
(
int
)
(
res
&
0xffffffff
);
}
private
byte
[]
decodeBytes
()
{
int
len
=
decodePacked32
();
byte
[]
result
=
new
byte
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
result
[
i
]
=
decodeByte
();
}
return
result
;
}
private
String
decodeIntentions
()
{
int
numIntentions
=
decodePacked32
();
string
name
=
""
;
for
(
int
i
=
0
;
i
<
numIntentions
;
i
++)
{
byte
[]
key
=
decodeBytes
();
byte
[]
val
=
decodeBytes
();
if
(
key
.
Length
==
0
)
{
name
=
Encoding
.
UTF8
.
GetString
(
val
,
0
,
val
.
Length
);
}
}
return
name
;
}
public
Type
decodeSampleRef
()
{
int
index
=
(
int
)
ReadInt
(
4
);
try
{
...
...
lib/csharp/se/lth/control/labcomm2014/EncoderChannel.cs
View file @
0802e984
...
...
@@ -26,7 +26,7 @@ namespace se.lth.control.labcomm2014 {
int
index
=
def_registry
.
add
(
dispatcher
);
begin
(
Constant
.
SAMPLE_DEF
);
encodePacked32
(
index
);
encode
String
(
dispatcher
.
getName
());
encode
Intentions
(
dispatcher
.
getName
());
byte
[]
signature
=
dispatcher
.
getSignature
();
encodePacked32
(
signature
.
Length
);
for
(
int
i
=
0
;
i
<
signature
.
Length
;
i
++)
{
...
...
@@ -39,7 +39,7 @@ namespace se.lth.control.labcomm2014 {
int
index
=
ref_registry
.
add
(
dispatcher
);
begin
(
Constant
.
SAMPLE_REF
);
encodePacked32
(
index
);
encode
String
(
dispatcher
.
getName
());
encode
Intentions
(
dispatcher
.
getName
());
byte
[]
signature
=
dispatcher
.
getSignature
();
encodePacked32
(
signature
.
Length
);
for
(
int
i
=
0
;
i
<
signature
.
Length
;
i
++)
{
...
...
@@ -132,6 +132,12 @@ namespace se.lth.control.labcomm2014 {
WritePacked32
(
bytes
,
value
);
}
private
void
encodeIntentions
(
String
name
)
{
encodePacked32
(
1
);
// one intention field
encodePacked32
(
0
);
// empty key: name
encodeString
(
name
);
}
public
void
encodeSampleRef
(
Type
value
)
{
int
index
=
0
;
try
{
...
...
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