Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
verimag
synchrone
lutin
Commits
568eae01
Commit
568eae01
authored
Jan 13, 2011
by
Erwan Jahier
Browse files
Add an example of use of the lution toplevel interpreter via sockets
parent
3d7f852f
Changes
20
Hide whitespace changes
Inline
Side-by-side
Makefile.common.source
View file @
568eae01
...
...
@@ -8,8 +8,9 @@ ifndef LURETTE_PATH
export
LURETTE_PATH
=
$(HOME)
/lurette
endif
ifndef
HOSTTYPE
export
HOSTTYPE
=
`
uname
`
HOSTTYPE
=
`
uname
`
endif
export
HOSTTYPE
PREFIX
=
$(LURETTE_PATH)
...
...
examples/lutin/C/Makefile
View file @
568eae01
...
...
@@ -62,7 +62,7 @@ ifeq ($(HOSTTYPE),win32)
foo
$(EXE)
else
./foo
>
test.rif
rm
-f
test.res
&&
diff
-u
-i
test.rif.exp test.rif
>
test.res
rm
-f
test.res
&&
diff
-B
-u
-i
test.rif.exp test.rif
>
test.res
[
!
-s
test.res
]
&&
make clean
endif
...
...
examples/lutin/crazy-rabbit/Makefile
View file @
568eae01
...
...
@@ -40,7 +40,7 @@ clean:
test
:
clean $(MAIN).opt
./
$(MAIN)
.opt 1000 0.0
test
|
grep
-v
"The random engine is initialized with the seed"
rm
-f
test.res
&&
diff
-u
-i
$(MAIN)
.out.exp
$(MAIN)
.out
>
test.res
&&
\
rm
-f
test.res
&&
diff
-B
-u
-i
$(MAIN)
.out.exp
$(MAIN)
.out
>
test.res
&&
\
[
!
-s
test.res
]
&&
make clean
utest
:
...
...
@@ -55,4 +55,4 @@ utest:
# 2 - Colorer l'obstacle en bleu pour pouvoir remettre les anciens points de
# la trajectoire
# 3 - Faire se ballader l'obstacle un peu plus aleatoirement
#
\ No newline at end of file
#
examples/lutin/external_code/Makefile
View file @
568eae01
...
...
@@ -69,13 +69,13 @@ run: $(OBJDIR)/$(MAIN).$(DLEXT)
test1
:
clean $(OBJDIR)/$(MAIN).$(DLEXT)
../../../
$(HOSTTYPE)
/bin/lutin call_external_c_code.lut
-m
Fun_Call
-L
libm.so
-L
obj/foo.so
\
-l
10
-seed
834966010 |
sed
-e
"s/^M//"
|
grep
-v
" Version"
>
test1.rif
rm
-f
test1.res
&&
diff
-u
-i
test1.rif.exp test1.rif
>
test1.res
rm
-f
test1.res
&&
diff
-u
-i
-B
test1.rif.exp test1.rif
>
test1.res
[
!
-s
test1.res
]
&&
make clean
test2
:
echo
"1.0 1.0"
| ../../../
$(HOSTTYPE)
/bin/lutin
-l
1
-L
libm.so polar.lut
-m
cartesian
\
-seed
1
>
test2.rif
rm
-f
test2.res
&&
diff
-u
-i
test2.rif.exp test2.rif
>
test2.res
rm
-f
test2.res
&&
diff
-u
-i
-B
test2.rif.exp test2.rif
>
test2.res
[
!
-s
test2.res
]
&&
make clean
test
:
test1 test2
...
...
examples/lutin/lustre/Makefile
View file @
568eae01
...
...
@@ -58,7 +58,7 @@ ifeq ($(HOSTTYPE),win32)
else
touch
test.rif
;
rm
test.rif
echo
"1 1 1 1 1 1 1 1 1 1 1"
| ./foo
>
test.rif
rm
-f
test.res
&&
diff
-u
-i
test.rif.exp test.rif
>
test.res
rm
-f
test.res
&&
diff
-B
-u
-i
test.rif.exp test.rif
>
test.res
[
!
-s
test.res
]
&&
make clean
endif
...
...
examples/lutin/ocaml/Makefile
View file @
568eae01
...
...
@@ -39,7 +39,7 @@ clean:
test
:
clean $(MAIN).opt
./
$(MAIN)
.opt
rm
-f
test.res
&&
diff
-u
-i
$(MAIN)
.rif.exp
$(MAIN)
.rif
>
test.res
&&
\
rm
-f
test.res
&&
diff
-B
-u
-i
$(MAIN)
.rif.exp
$(MAIN)
.rif
>
test.res
&&
\
[
!
-s
test.res
]
&&
make clean
utest
:
...
...
examples/lutin/socket-from-ocaml/Makefile
0 → 100644
View file @
568eae01
#
# Illustrate the use of a ocaml programs that calls the lutin interpreter
# via sockets
################################################################
CMXA_LIB
=
unix.cmxa
MAIN
=
call_foo_via_socket
ifndef
OCAMLOPT
OCAMLOPT
=
ocamlopt.opt
endif
OCAMLC
=
ocamlc.opt
$(MAIN).opt
:
$(MAIN).ml
$(OCAMLOPT)
$(CMXA_LIB)
$(MAIN)
.ml
-o
$(MAIN)
.opt
$(MAIN)
:
$(MAIN).ml
$(OCAMLC)
$(MAIN)
.ml
-o
$(MAIN)
################################################################
clean
:
rm
-f
*
.top
*
.cmi
*
.cmo
*
.cmx
*
.o
*
.cma
*
.cmxa
*
.a
*
.cmi
*
.cmo
*
.cmi
*
.cmx
*
.o
*
~
$(MAIN)
$(MAIN)
.opt
*
~
*
.pp_luc
*
.rif test.res
test
:
clean $(MAIN).opt
./
$(MAIN)
.opt
rm
-f
test.res
&&
diff
-B
-u
-w
-i
$(MAIN)
.rif.exp
$(MAIN)
.rif
>
test.res
&&
\
[
!
-s
test.res
]
&&
make clean
utest
:
cp
$(MAIN)
.rif
$(MAIN)
.rif.exp
examples/lutin/socket-from-ocaml/call_foo_via_socket.ml
0 → 100644
View file @
568eae01
(* Demonstrate the use of of a ocaml programs that calls the lutin
interpreter via sockets. *)
let
rif_oc
=
open_out
"call_foo_via_socket.rif"
let
lutin
=
"/home/jahier/lurette/pre_release/cross-win32/bin/lutin"
let
lutin
=
"lutin"
let
call_via_socket
=
"call-via-socket"
let
my_create_process
prog
args
=
try
Unix
.
create_process
prog
(
Array
.
of_list
args
)
Unix
.
stdin
Unix
.
stdout
Unix
.
stderr
with
_
->
print_string
(
"*** can not find "
^
prog
^
" in path.
\n
"
);
exit
1
let
fork_lutin
lut_prog
=
(* Socket administration stuff *)
let
sock_io
=
Unix
.
socket
Unix
.
PF_INET
Unix
.
SOCK_STREAM
0
in
let
sock_addr
=
let
my_entrie_byname
=
try
Unix
.
gethostbyname
(
Unix
.
gethostname
()
)
with
Not_found
->
assert
false
in
my_entrie_byname
.
Unix
.
h_addr_list
.
(
0
)
in
let
socket_port_io
=
let
rec
(
bind_with_free_port
:
Unix
.
file_descr
->
Unix
.
inet_addr
->
int
->
int
->
int
)
=
fun
s
saddr
port
maxtry
->
if
maxtry
=
0
then
failwith
"socket bind failure"
else
try
Unix
.
bind
s
(
Unix
.
ADDR_INET
(
saddr
,
port
));
port
with
_
->
bind_with_free_port
s
saddr
(
port
+
1
)
(
maxtry
-
1
)
in
bind_with_free_port
sock_io
sock_addr
2000
100
in
let
args
=
[
call_via_socket
;
Unix
.
string_of_inet_addr
sock_addr
;
string_of_int
socket_port_io
;
lutin
;
"-seed"
;
"42"
;
lut_prog
]
in
let
_pid
=
my_create_process
(
List
.
hd
args
)
args
in
let
(
sock
,
_
)
=
Unix
.
listen
sock_io
1
;
Unix
.
accept
sock_io
(* bloquant *)
in
let
ic
=
Unix
.
in_channel_of_descr
sock
in
let
oc
=
Unix
.
out_channel_of_descr
sock
in
ic
,
oc
,
sock
(* main *)
let
_
=
let
ic
,
oc
,
sock
=
fork_lutin
"foo.lut"
in
(* Read 2 lines (the interface decl). Mandatory too *)
output_string
rif_oc
((
input_line
ic
)
^
"
\n
"
);
output_string
rif_oc
((
input_line
ic
)
^
"
\n
"
);
for
i
=
1
to
10
do
let
data_in
=
"42 t 3.14
\n
"
in
let
_
=
output_string
oc
data_in
;
flush
oc
;
(* put the data on the socket... *)
in
let
data_out
=
input_line
ic
^
"
\n
"
^
input_line
ic
(* ... and read it back! *)
in
output_string
rif_oc
(
"
\n
"
^
data_in
^
""
^
data_out
^
""
);
done
;
flush
rif_oc
;
close_out
rif_oc
;
Unix
.
shutdown
sock
Unix
.
SHUTDOWN_ALL
examples/lutin/socket-from-ocaml/call_foo_via_socket.rif.exp
0 → 100644
View file @
568eae01
#inputs "a":int "b":bool "c":real
#outputs "x":int "y":bool "z":real
42 t 3.14
#outs 40 T 0.33
#step 1
42 t 3.14
#outs 41 T 6.83
#step 2
42 t 3.14
#outs 44 T 2.18
#step 3
42 t 3.14
#outs 43 T 2.11
#step 4
42 t 3.14
#outs 44 T 2.95
#step 5
42 t 3.14
#outs 46 T 4.13
#step 6
42 t 3.14
#outs 38 T 5.73
#step 7
42 t 3.14
#outs 45 T -0.71
#step 8
42 t 3.14
#outs 41 T -0.83
#step 9
42 t 3.14
#outs 39 T 6.96
#step 10
\ No newline at end of file
examples/lutin/socket-from-ocaml/foo.lut
0 → 100644
View file @
568eae01
let
abs_int
(
x
:
int
)
=
if
x
>=
0
then
x
else
-
x
let
abs_real
(
x
:
real
)
=
if
x
>=
0
.
0
then
x
else
-
x
node
main
(
a
:
int
;
b
:
bool
;
c
:
real
)
returns
(
x
:
int
[
-
100000
;
100000
];
y
:
bool
;
z
:
real
[
-
100000
.
0
;
100000
.
0
])
=
loop
{
(
b
=>
y
)
and
abs_int
(
x
-
a
)
<
5
and
abs_real
(
z
-
c
)
<
5
.
0
}
examples/lutin/test_ok/,dotest
View file @
568eae01
...
...
@@ -41,7 +41,7 @@ function testit {
exit
1
fi
dolutin
"
$base
"
$n
diff
-u
-i
"
$rif
"
"
$ref
"
>
"
$res
"
diff
-B
-u
-i
"
$rif
"
"
$ref
"
>
"
$res
"
if
[
$?
!=
0
]
;
then
exit
1
;
fi
local
problem
=
`
cat
"
$res
"
|
wc
-c
`
if
[
$problem
!=
0
]
;
then
...
...
examples/lutin/up_and_down/Makefile
View file @
568eae01
...
...
@@ -9,7 +9,7 @@ LUTIN=../../../$(HOSTTYPE)/bin/lutin$(EXE) -seed 1
test
:
$(LUTIN)
-l
100 ud.lut
-main
main |
sed
-e
"s/^M//"
>
test.rif
rm
-f
test.res
&&
diff
-u
-i
test.rif.exp test.rif
>
test.res
rm
-f
test.res
&&
diff
-B
-u
-i
-w
test.rif.exp test.rif
>
test.res
[
!
-s
test.res
]
&&
make clean
...
...
examples/lutin/up_and_down/test.rif.exp
View file @
568eae01
#inputs
#outputs "x":real
#step 1
#outs 64.52
#step 2
#outs 60.80
#step 3
#outs 58.07
#step 4
#outs 56.25
#step 5
#outs 55.23
#step 6
#outs 54.28
#step 7
#outs 51.42
#step 8
#outs 50.80
#step 9
#outs 46.48
#step 10
#outs 45.15
#step 11
#outs 40.93
#step 12
#outs 38.62
#step 13
#outs 37.23
#step 14
#outs 33.35
#step 15
#outs 32.29
#step 16
#outs 30.09
#step 17
#outs 26.20
#step 18
#outs 25.42
#step 19
#outs 21.93
#step 20
#outs 17.57
#step 21
#outs 13.59
#step 22
#outs 10.92
#step 23
#outs 7.08
#step 24
#outs 6.06
#step 25
#outs 5.91
#step 26
#outs 2.87
#step 27
#outs -1.64
#step 28
#outs 0.72
#step 29
#outs 1.22
#step 30
#outs 4.58
#step 31
#outs 5.73
#step 32
#outs 10.09
#step 33
#outs 13.40
#step 34
#outs 13.67
#step 35
#outs 13.86
#step 36
#outs 17.17
#step 37
#outs 17.80
#step 38
#outs 17.84
#step 39
#outs 19.54
#step 40
#outs 24.11
#step 41
#outs 25.29
#step 42
#outs 28.55
#step 43
#outs 29.16
#step 44
#outs 30.99
#step 45
#outs 34.64
#step 46
#outs 36.88
#step 47
#outs 41.55
#step 48
#outs 44.13
#step 49
#outs 48.12
#step 50
#outs 52.51
#step 51
#outs 56.55
#step 52
#outs 59.50
#step 53
#outs 60.41
#step 54
#outs 63.77
#step 55
#outs 68.39
#step 56
#outs 70.05
#step 57
#outs 71.13
#step 58
#outs 72.16
#step 59
#outs 75.77
#step 60
#outs 79.39
#step 61
#outs 80.35
#step 62
#outs 82.65
#step 63
#outs 86.97
#step 64
#outs 90.03
#step 65
#outs 94.70
#step 66
#outs 97.03
#step 67
#outs 100.19
#step 68
#outs 96.69
#step 69
#outs 95.40
#step 70
#outs 93.99
#step 71
#outs 91.89
#step 72
#outs 90.64
#step 73
#outs 88.56
#step 74
#outs 88.26
#step 75
#outs 87.71
#step 76
#outs 84.07
#step 77
#outs 82.97
#step 78
#outs 80.74
#step 79
#outs 79.73
#step 80
#outs 79.58
#step 81
#outs 75.20
#step 82
#outs 71.69
#step 83
#outs 71.47
#step 84
#outs 69.50
#step 85
#outs 69.38
#step 86
#outs 65.65
#step 87
#outs 61.89
#step 88
#outs 59.25
#step 89
#outs 58.65
#step 90
#outs 58.16
#step 91
#outs 53.22
#step 92
#outs 51.39
#step 93
#outs 47.20
#step 94
#outs 47.01
#step 95
#outs 46.46
#step 96
#outs 41.82
#step 97
#outs 39.13
#step 98
#outs 38.86
#step 99
#outs 38.22
#step 100
#outs 37.36
#end
examples/lutin/xlurette/Makefile
View file @
568eae01
...
...
@@ -15,7 +15,7 @@ test:
$(LURETTETOP)
-go
--output
test.rif0 env.lut
&&
\
grep
-v
"lurette chronogram"
test.rif0 |
\
grep
-v
"The execution lasted"
|
sed
-e
"s/^M//"
>
test.rif
&&
\
rm
-f
test.res
&&
diff
-u
-i
test.rif.exp test.rif
>
test.res
rm
-f
test.res
&&
diff
-B
-u
-i
test.rif.exp test.rif
>
test.res
[
!
-s
test.res
]
&&
make clean
...
...
@@ -34,7 +34,7 @@ test_dontgo:
$(LURETTETOP)
--output
test.rif0 degradable-sensors.luc
&&
\
grep
-v
"lurette chronogram"
test.rif0 |
\
grep
-v
"The execution lasted"
|
sed
-e
"s/^M//"
>
test.rif
&&
\
rm
-f
test.res
&&
diff
-u
-i
test.rif.exp test.rif
>
test.res
rm
-f
test.res
&&
diff
-B
-u
-i
test.rif.exp test.rif
>
test.res
[
!
-s
test.res
]
&&
make clean
source/Lucky/luc2alice.ml
View file @
568eae01
...
...
@@ -213,13 +213,7 @@ let (gen_alice_stub_h : alice_args -> unit) =
fun
args
->
let
amn
=
args
.
alice_module_name
in
let
oc
=
open_out
(
amn
^
".h"
)
in
let
put
s
=
output_string
oc
s
in
let
putln
s
=
output_string
oc
(
s
^
"
\n
"
)
in
let
rec
putlist
=
function
[]
->
()
|
[
x
]
->
put
x
|
x
::
l'
->
put
x
;
put
", "
;
putlist
l'
in
let
fn
=
args
.
env_name
in
putln
(
Util
.
entete
"// "
);
putln
(
"
...
...
source/Lutin/main.ml
View file @
568eae01
...
...
@@ -262,7 +262,7 @@ Utils.time_R "main_loop2";
Verbose
.
exe
~
level
:
3
(
fun
()
->
Printf
.
fprintf
stdout
"#LOC SUBST LIST=%s
\n
"
(
Value
.
OfIdent
.
to_string
";"
loc
));
print_string
step_str
;
print_string
"
\n
#outs "
;
print_string
"#outs "
;
Rif
.
write
stdout
next_state
.
Prog
.
s
.
Prog
.
out_vars
out
;
if
MainArg
.
show_locals
()
then
(
...
...
source/Makefile
View file @
568eae01
...
...
@@ -261,7 +261,6 @@ gnuplot-rif_clean:$(OBJDIR)
cd
$(OBJDIR)
&&
$(MAKE)
-k
-f
../Gnuplot-rif/Makefile clean
##############################################################################"
gnuplot-socket
:
$(OBJDIR)
cd
$(OBJDIR)
&&
\
$(MAKE)
-k
ln
-f
../misc/Makefile.gnuplot-socket
&&
\
...
...
@@ -270,6 +269,15 @@ gnuplot-socket:$(OBJDIR)
gnuplot-socket_clean
:
$(OBJDIR)
cd
$(OBJDIR)
&&
$(MAKE)
-k
clean
-f
../misc/Makefile.gnuplot-socket
##############################################################################"
call-via-socket
:
$(OBJDIR)
cd
$(OBJDIR)
&&
\
$(MAKE)
-k
ln
-f
../misc/Makefile.call-via-socket
&&
\
$(MAKE)
-k
nc
-f
../misc/Makefile.call-via-socket
call-via-socket_clean
:
$(OBJDIR)
cd
$(OBJDIR)
&&
$(MAKE)
-k
clean
-f
../misc/Makefile.call-via-socket
##############################################################################"
.PHONY
:
lucky
lucky
:
$(OBJDIR)
...
...
@@ -537,7 +545,7 @@ all_assert:
check
:
echo
"A faire dans le repertoire test, sinon, ca vaut pas !!! "
allw
:
clean lurette_ml_exec lucky libnc ltop show stubs gnuplot-rif gnuplot-socket gen_luc luc2c luc2luciole luc4c libluc4c_nc.a draw-all luc4ocaml-all
allw
:
clean lurette_ml_exec lucky libnc ltop show stubs gnuplot-rif gnuplot-socket
call-via-socket
gen_luc luc2c luc2luciole luc4c libluc4c_nc.a draw-all luc4ocaml-all