Model Simulation Closure
Applying 'pre' and 'post' closure at the model simulation level.
Concept
In addition to closure for OMS component testing, 'pre' and 'post' closure can be applied to a model simulation containing one to many components.
Implementation
OMS component 'Component' consumes the 'message' parameter and prints it out.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 |
package ex00;
import oms3.annotations.*;
/**
*
* @author od
*/
public class Component {
@In public String message;
@Execute
public void run() {
System.out.println(message);
}
}
|
In this brief example, the simulation file specifies 'pre' and 'post' actions for the one component model simulation, with 'pre' closure printing a string, the model printing the parameter value, and 'post' closure printing another string.
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 |
import static oms3.SimBuilder.instance as OMS3
OMS3.sim (
pre: { m -> // this is a closure, 'c' is the model
println "before sim"
},
post: { m ->
println "after sim"
}
)
{
model {
parameter {
// 'componentname.@In_fieldname' -> object
'c.message' "Hello World ..."
}
components {
// componentname -> type
'c' 'ex00.Component'
}
}
}
|