3 import de
.learnlib
.api
.SUL
;
4 import de
.learnlib
.api
.SULException
;
7 * Example of a three-state system, hard-coded.
9 * @author Ramon Janssen
11 public class ExampleSUL
implements SUL
<String
, String
> {
12 private enum State
{s0
,s1
,s2
};
13 private State currentState
;
14 private static boolean VERBOSE
= false;
18 // add any code here that should be run at the beginning of every 'session',
19 // i.e. put the system in its initial state
21 System
.out
.println("Starting SUL");
23 currentState
= State
.s0
;
28 // add any code here that should be run at the end of every 'session'
30 System
.out
.println("Shutting down SUL");
35 public String
step(String input
) throws SULException
{
36 State previousState
= this.currentState
;
37 String output
= makeTransition(input
);
38 State nextState
= this.currentState
;
40 System
.out
.println(previousState
+ " --" + input
+ "/" + output
+ "-> " + nextState
);
46 * The behaviour of the SUL. It takes one input, and returns an output. It now
47 * contains a hardcoded state-machine (so the result is easy to check). To learn
48 * an external program/system, connect this method to the SUL (e.g. via sockets
49 * or stdin/stdout) and make it perform an actual input, and retrieve an actual
54 public String
makeTransition(String input
) {
55 switch (currentState
) {
59 currentState
= State
.s1
;
62 currentState
= State
.s2
;
72 currentState
= State
.s2
;
82 currentState
= State
.s0
;
88 throw new SULException(new IllegalArgumentException("Argument '" + input
+ "' was not handled"));