Ecere Software
/
ede
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
updated .gitignore for .configs/
[ede]
/
explorer
/
src
/
Structures
/
Temp.ec
1
public import "ecere"
2
3
public class TimerTemp
4
{
5
bool active;
6
7
Time count;
8
Time from;
9
10
void Start()
11
{
12
if(!active)
13
{
14
active = true;
15
from = GetTime();
16
}
17
}
18
19
void Stop()
20
{
21
if(active)
22
{
23
active = false;
24
count += GetTime() - from;
25
}
26
}
27
28
void Reset()
29
{
30
count = 0;
31
if(active)
32
from = GetTime();
33
}
34
}
35
36
/*
37
public class Delay : Seconds
38
{
39
40
private:
41
42
Time from;
43
44
public:
45
46
property bool elapsed
47
{
48
get
49
{
50
Time now = GetTime();
51
if(!from || now - from > (Time)this)
52
{
53
from = now;
54
return true;
55
}
56
return false;
57
}
58
}
59
}
60
*/
61
62
public class TimeGate
63
{
64
65
private:
66
67
Time from;
68
69
public:
70
71
Time delay;
72
73
/*
74
property bool
75
{
76
get
77
{
78
if(!from || GetTime() - from > delay)
79
{
80
from = GetTime();
81
return true;
82
}
83
return false;
84
}
85
}
86
*/
87
88
property bool elapsed
89
{
90
get
91
{
92
Time now = GetTime();
93
if(!from || now - from > delay)
94
{
95
from = now;
96
return true;
97
}
98
return false;
99
}
100
}
101
}
102