Download Lucid Synchrone Manual

Transcript
| Light_on ->
do nok = false
and open_light = false
and open_gas = true
until (not on_heat) then Light_off
| Try ->
do
(open_light, open_gas) = command millisecond
until light_on then Light_on
until (count 3 (edge (not open_light))) then Failure
| Failure ->
do nok = true
and open_light = false
and open_gas = false
done
end
Finally, the main function connects the two parts.
(* the main function *)
let node main millisecond restart expected_temp actual_temp on_light =
(open_light, open_gas, ok, nok) where
rec reset
on_heat = heat expected_temp actual_temp
and
(open_light, open_gas,nok) = light milisecond on_heat on_light
and
ok = not nok
every restart
Supposing that the program is written in a file heater.ls, the program can be compiled
by typing:
% lucyc -s main heater.ls
which produces files heater.ml and main.ml, the later containing the transition function for
the node main.
2.3
The Coffee Machine
The following example is inspired from the Coffee Machine introduced by Milner in his CCS
book [9].
The description is the following. The machine may serve coffee or tea. A tea costs ten
cents whereas a coffee costs five. The user may enter dimes or nickels. He can select a tea, a
coffee or ask for his money back.
type coin = Dime | Nickel