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
2bc1b87e
Commit
2bc1b87e
authored
Nov 14, 2014
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
added c# user_types example
parent
59a49855
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/user_types/ExampleDecoder.cs
+49
-0
49 additions, 0 deletions
examples/user_types/ExampleDecoder.cs
examples/user_types/ExampleEncoder.cs
+85
-0
85 additions, 0 deletions
examples/user_types/ExampleEncoder.cs
examples/user_types/Makefile
+8
-8
8 additions, 8 deletions
examples/user_types/Makefile
with
142 additions
and
8 deletions
examples/user_types/ExampleDecoder.cs
0 → 100644
+
49
−
0
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
));
}
}
}
This diff is collapsed.
Click to expand it.
examples/user_types/ExampleEncoder.cs
0 → 100644
+
85
−
0
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
();
}
}
}
This diff is collapsed.
Click to expand it.
examples/user_types/Makefile
+
8
−
8
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
...
...
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