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
2bc1b87e
Commit
2bc1b87e
authored
Nov 14, 2014
by
Sven Gestegård Robertz
Browse files
added c# user_types example
parent
59a49855
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/user_types/ExampleDecoder.cs
0 → 100644
View file @
2bc1b87e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.IO
;
using
se.lth.control.labcomm
;
namespace
user_types
{
class
Decoder
:
twoLines
.
Handler
{
DecoderChannel
dec
;
public
Decoder
(
Stream
stream
)
{
dec
=
new
DecoderChannel
(
stream
);
twoLines
.
register
(
dec
,
this
);
try
{
Console
.
WriteLine
(
"Running decoder."
);
dec
.
run
();
}
catch
(
EndOfStreamException
)
{
Console
.
WriteLine
(
"EOF reached"
);
}
}
private
string
genPoint
(
point
p
)
{
return
"("
+
p
.
x
.
val
+
", "
+
p
.
y
.
val
+
")"
;
}
private
String
genLine
(
line
l
)
{
return
"Line from "
+
genPoint
(
l
.
start
)
+
" to "
+
genPoint
(
l
.
end
);
}
public
void
handle
(
twoLines
d
)
{
Console
.
WriteLine
(
"Got twoLines: "
);
Console
.
WriteLine
(
"Line l1: "
+
genLine
(
d
.
l1
));
Console
.
WriteLine
(
"Line l2: "
+
genLine
(
d
.
l2
));
}
static
void
Main
(
string
[]
args
)
{
new
Decoder
(
new
FileStream
(
args
[
0
],
FileMode
.
Open
));
}
}
}
examples/user_types/ExampleEncoder.cs
0 → 100644
View file @
2bc1b87e
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
se.lth.control.labcomm
;
namespace
user_types
{
public
class
Encoder
{
private
EncoderChannel
enc
;
public
Encoder
(
Stream
stream
)
{
enc
=
new
EncoderChannel
(
stream
);
twoLines
.
register
(
enc
);
}
public
void
doEncode
()
{
twoLines
x
=
new
twoLines
();
line
l1
=
new
line
();
point
p11
=
new
point
();
coord
c11x
=
new
coord
();
coord
c11y
=
new
coord
();
c11x
.
val
=
11
;
c11y
.
val
=
99
;
p11
.
x
=
c11x
;
p11
.
y
=
c11y
;
l1
.
start
=
p11
;
point
p12
=
new
point
();
coord
c12x
=
new
coord
();
coord
c12y
=
new
coord
();
c12x
.
val
=
22
;
c12y
.
val
=
88
;
p12
.
x
=
c12x
;
p12
.
y
=
c12y
;
l1
.
end
=
p12
;
line
l2
=
new
line
();
point
p21
=
new
point
();
coord
c21x
=
new
coord
();
coord
c21y
=
new
coord
();
c21x
.
val
=
17
;
c21y
.
val
=
42
;
p21
.
x
=
c21x
;
p21
.
y
=
c21y
;
l2
.
start
=
p21
;
point
p22
=
new
point
();
coord
c22x
=
new
coord
();
coord
c22y
=
new
coord
();
c22x
.
val
=
13
;
c22y
.
val
=
37
;
p22
.
x
=
c22x
;
p22
.
y
=
c22y
;
l2
.
end
=
p22
;
foo
f
=
new
foo
();
f
.
a
=
10
;
f
.
b
=
20
;
f
.
c
=
false
;
x
.
l1
=
l1
;
x
.
l2
=
l2
;
x
.
f
=
f
;
Console
.
WriteLine
(
"Encoding theTwoLines"
);
twoLines
.
encode
(
enc
,
x
);
}
static
void
Main
(
string
[]
args
)
{
FileStream
stream
=
new
FileStream
(
args
[
0
],
FileMode
.
Create
);
Encoder
example
=
new
Encoder
(
stream
);
example
.
doEncode
();
stream
.
Close
();
}
}
}
examples/user_types/Makefile
View file @
2bc1b87e
...
...
@@ -32,11 +32,11 @@ cleanbuild: clean build
labcomm.dll
:
ln
-sf
../../lib/csharp/labcomm.dll
$@
Encoder.exe
:
Encoder.cs gen/test.cs labcomm.dll Makefile
Example
Encoder.exe
:
Example
Encoder.cs gen/test.cs labcomm.dll Makefile
mcs
-out
:
$@
$(
filter
%.cs,
$^
)
-lib
:../../lib/csharp/
-r
:labcomm
chmod
a+x
$@
Decoder.exe
:
Decoder.cs gen/test.cs labcomm.dll Makefile
Example
Decoder.exe
:
Example
Decoder.cs gen/test.cs labcomm.dll Makefile
mcs
-out
:
$@
$(
filter
%.cs,
$^
)
-lib
:../../lib/csharp/
-r
:labcomm
chmod
a+x
$@
...
...
@@ -100,7 +100,7 @@ run:
@echo "************ running python decoder (from wiki_example)
:
"
PYTHONPATH
=
${LCDIR}
/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
runwcs
:
Encoder.exe Decoder.exe
runwcs
:
Example
Encoder.exe
Example
Decoder.exe
export
LD_LIBRARY_PATH
=
${LCDIR}
/lib/c/
@
echo
@
echo
"********************************************"
...
...
@@ -120,7 +120,7 @@ runwcs: Encoder.exe Decoder.exe
@
PYTHONPATH
=
${LCDIR}
/lib/python ../wiki_example/example_decoder.py encoded_data_j LabComm2014
@echo "************ running C# decoder
:
*****************"
@
./Decoder.exe encoded_data_j
@
./
Example
Decoder.exe encoded_data_j
@echo "************ running C encoder
:
*****************"
@
./example_encoder encoded_data_c
...
...
@@ -135,7 +135,7 @@ runwcs: Encoder.exe Decoder.exe
@
PYTHONPATH
=
${LCDIR}
/lib/python ../wiki_example/example_decoder.py encoded_data_c LabComm2014
@echo "************ running C# decoder
:
*****************"
@
./Decoder.exe encoded_data_c
@
./
Example
Decoder.exe encoded_data_c
@echo "************ running python encoder
:
*****************"
@
PYTHONPATH
=
${LCDIR}
/lib/python:
${GENDIR}
./example_encoder.py encoded_data_p LabComm2014
...
...
@@ -150,10 +150,10 @@ runwcs: Encoder.exe Decoder.exe
PYTHONPATH
=
${LCDIR}
/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
@echo "************ running C# decoder
:
*****************"
@
./Decoder.exe encoded_data_p
@
./
Example
Decoder.exe encoded_data_p
@echo "************ running C# encoder
:
*****************"
@
./Encoder.exe encoded_data_cs
@
./
Example
Encoder.exe encoded_data_cs
@echo "************ running Java decoder
:
*****************"
@
java
-cp
.:
${LCDIR}
/lib/java/labcomm.jar:
${GENDIR}
Decoder encoded_data_cs
...
...
@@ -165,7 +165,7 @@ runwcs: Encoder.exe Decoder.exe
@
PYTHONPATH
=
${LCDIR}
/lib/python ../wiki_example/example_decoder.py encoded_data_cs LabComm2014
@echo "************ running C# decoder
:
*****************"
@
./Decoder.exe encoded_data_cs
@
./
Example
Decoder.exe encoded_data_cs
...
...
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