-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest2.ept
More file actions
130 lines (108 loc) · 2.95 KB
/
test2.ept
File metadata and controls
130 lines (108 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
node detecteur(mvt,onoff,hs: bool) returns (alarme: bool)
var
tick:int;
let
automaton
state Disabled
do alarme = false; tick = 0;
until onoff then Enabled
state Enabled
do alarme = false;
reset
tick = (0 fby tick) + (if hs and mvt then 1 else 0);
every (not mvt)
until onoff then Disabled | (tick > 5) then Detected
state Detected
do alarme = true; tick = 0;
until onoff then Disabled
end;
tel
node chrono2(start_stop,rst,hs: bool) returns (last time: int = 0)
let
automaton
state Stop
do time = if rst then 0 else last time
unless start_stop then Running
state Running
do time = if rst then 0 else if hs then last time + 1000 else last time
unless start_stop then Stop
end;
tel
node chrono3(start_stop,rst,hs,pause: bool) returns (last time: int = 0)
var internal_time: int;
let
internal_time = chrono2(start_stop,rst,hs);
automaton
state Running
do time = internal_time
unless pause then Paused
state Paused
do
unless pause then Running
end;
tel
node chrono2bis(start_stop,rst,hs: bool) returns (last time: int = 0)
var last internal_time: int = 0;
last internal_rst: bool = false;
let
internal_time = chrono2(start_stop,internal_rst,hs);
automaton
state Stop
do time = internal_time; internal_rst = rst
unless start_stop then Running
state Running
do time = internal_time; internal_rst = false
unless rst then Paused | start_stop then Stop
state Paused
do internal_rst = false
unless rst then Running
end;
tel
fun timeToHMS(time: int) returns (h,m,s: int)
let
s = (time/1000) % 60;
m = (time/(1000*60)) % 60;
h = (time/(1000*60*60)) % 24;
tel
node settings(last_initial_time: int; start_stop,rst: bool) returns (new_initial_time: int)
let
automaton
state H
do new_initial_time = (if rst then 1000*60*60 else 0) + last_initial_time;
unless start_stop then M
state M
do new_initial_time = (if rst then 1000*60 else 0) + last_initial_time;
unless start_stop then S
state S
do new_initial_time = (if rst then 1000 else 0) + last_initial_time;
unless start_stop then H
end;
tel
node montre(mode,start_stop,rst,hs,pause:bool) returns (last h: int; last m: int; last s: int)
var last internal_time: int = 0;
last current_time: int = 0;
last initial_time: int = 0;
internal_pause: bool;
let
internal_time = merge internal_pause
(last internal_time when internal_pause)
(chrono3(true fby false,false,hs,false) whenot internal_pause);
current_time = initial_time + internal_time;
automaton
state Time
do internal_pause = false;
(h,m,s) = timeToHMS(current_time);
unless mode then Timer
state Timer
var t_time: int;
do internal_pause = false;
t_time = chrono3(start_stop,rst,hs,pause);
(h,m,s) = timeToHMS(t_time);
unless mode then Settings
state Settings
do internal_pause = true;
initial_time = settings(last initial_time,start_stop,rst);
(h,m,s) = timeToHMS(current_time);
unless mode continue Time
end;
tel