-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.java
More file actions
49 lines (43 loc) · 1.16 KB
/
Clock.java
File metadata and controls
49 lines (43 loc) · 1.16 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
// Class name: Clock
//
// Description: timer
//
// Output variables (poles):
// out - output
//
// State components:
// 1: out
//
// Created: 01.12.2007
// Last modified: 25.01.2008
//------------------------------------------------
class Clock {
/*@ specification Clock {
double tau;
double out;
// State variables
double initstate_c, oldstate_c, state_c;
double nextstate_c, finalstate_c;
alias (double) initstate = (initstate_c);
alias (double) oldstate = (oldstate_c);
alias (double) state = (state_c);
alias (double) nextstate = (nextstate_c);
alias (double) finalstate = (finalstate_c);
// Evaluating initstate components
initstate_c = 0;
// Equations
out = state_c;
// Method specification
tau, state_c -> nextstate_c {clock_next};
}@*/
//================================================
// tau, state_c -> nextstate_c { clock_next };
//================================================
public double clock_next ( double tau,
double st) {
double nst;
if ( tau == 0 ) { nst = st; }
else { nst = st + 1/tau; }
return nst;
}
}