blob: 704e897893ef6497762fb0213c781678b6d48ffd (
plain)
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
|
package org.uscxml.apache.commons.scxml2;
import java.net.URL;
import org.uscxml.ActionLanguage;
import org.uscxml.Factory;
import org.uscxml.Interpreter;
import org.uscxml.InterpreterException;
import org.uscxml.InterpreterState;
import org.uscxml.helper.TestMonitor;
public class SCXMLExecutor {
public Interpreter interpreter = null;
public URL sourceURL = null;
public ActionLanguage al = new ActionLanguage();
public SCXMLExecutor(Evaluator evaluator, Object object, SimpleErrorReporter simpleErrorReporter) {
// TODO Auto-generated constructor stub
}
public void setStateMachine(SCXML scxml) {
sourceURL = scxml.url;
}
public void setRootContext(Context rootContext) {
al.setDataModel(rootContext.dm);
}
public void go() {
try {
interpreter = Interpreter.fromURL(sourceURL.toString());
interpreter.setActionLanguage(al);
TestMonitor tm = new TestMonitor();
interpreter.addMonitor(tm);
InterpreterState state = InterpreterState.USCXML_UNDEF;
while(state != InterpreterState.USCXML_FINISHED) {
interpreter.step();
}
} catch (InterpreterException e) {
e.printStackTrace();
}
}
}
|