-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.java
More file actions
75 lines (56 loc) · 1.66 KB
/
Process.java
File metadata and controls
75 lines (56 loc) · 1.66 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
import ee.ioc.cs.vsle.api.*;
/*
* This Process should work with any chosen approximation method (Euler, RK2, RK4)
*/
public class Process {
/*@ specification Process {
int time, time_s;
double T;
long delay;
delay = 1;
boolean debug;
void done;
boolean repaintImmediately;
alias initstate = (*.initstate);
alias state = (*.state);
alias nextstate = (*.nextstate);
alias finalstate = (*.finalstate);
alias (double) allT = (*.T);
allT.length, T -> allT{setT};
alias draw = (*.drawing_ready);
alias (boolean) repaint = (*.repaintImmediately);
repaint.length, repaintImmediately -> repaint{setRepaint};
alias processEnded = (*.paintAll);
[ state -> nextstate, draw], initstate, time, delay, debug, repaintImmediately -> done, processEnded{proc_run};
-> done;
}@*/
public boolean[] setRepaint( int len, boolean t ) {
boolean[] tmp = new boolean[len];
for( int i = 0; i < len; i++ ) {
tmp[i] = t;
}
return tmp;
}
public double[] setT( int len, double t ) {
double[] tmp = new double[len];
for( int i = 0; i < len; i++ ) {
tmp[i] = t;
}
return tmp;
}
public void proc_run( Subtask st, Object initst, int time, long delay,
boolean debug, boolean repaintImmediately ) {
if ( debug )
System.out.println( "time value is: " + time );
Object[] in = new Object[] { initst };
for ( int i = 1; i <= time; i++ ) {
Object[] out = st.run( in );
in = out;
if ( delay > 0 && repaintImmediately )
try {
Thread.sleep( delay );
} catch ( Exception e ) {
}
}
}
}