-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAdder.java
More file actions
37 lines (26 loc) · 860 Bytes
/
Adder.java
File metadata and controls
37 lines (26 loc) · 860 Bytes
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
import ee.ioc.cs.vsle.api.ProgramContext;
class Adder {
/*@
specification Adder {
double k1, k2, in1, in2, out, k1s, k2s;
// Comment/uncomment a 2 line pairs below when you want to change k1 and k2 values during the simulation execution
k1 = k1s;
k2 = k2s;
// cocovilaSpecObjectName, in1 -> k1s{getK1};
// cocovilaSpecObjectName, in2 -> k2s{getK2};
out = k1s * in1 + k2s * in2;
}
@*/
public double getK1( String name, double x ) {
try {
return Double.valueOf( (String) ProgramContext.getFieldValue( name, "k1" ) );
} catch(Exception e) { System.err.println( "Error getting k1" ); }
return 0;
}
public double getK2( String name, double x ) {
try {
return Double.valueOf( (String) ProgramContext.getFieldValue( name, "k2" ) );
} catch(Exception e) { System.err.println( "Error getting k2" ); }
return 0;
}
}