use of org.yakindu.sct.model.stext.stext.ArgumentedAnnotation in project statecharts by Yakindu.
the class CycleBasedSimulationEngine method scheduleCycleEvent.
private void scheduleCycleEvent() {
Long cyclePeriod = DEFAULT_CYCLE_PERIOD;
ArgumentedAnnotation cycleBased = (ArgumentedAnnotation) getStatechart().getAnnotationOfType(CYCLE_BASED_ANNOTATION);
if (cycleBased != null) {
cyclePeriod = (Long) statementInterpreter.evaluate(cycleBased.getExpressions().get(0), SRuntimeFactory.eINSTANCE.createExecutionContext());
}
TimeTask cycleTask = new TimeTask("$cycle", () -> {
try {
interpreter.runCycle();
} catch (Exception e) {
handleException(e);
}
}, Priority.LOW);
timeTaskScheduler.scheduleTimeTask(cycleTask, true, cyclePeriod);
}
use of org.yakindu.sct.model.stext.stext.ArgumentedAnnotation in project statecharts by Yakindu.
the class AbstractExecutionFlowTest method getCyclePeriod.
protected long getCyclePeriod() {
ArgumentedAnnotation annotation = (ArgumentedAnnotation) ((Statechart) flow.getSourceElement()).getAnnotationOfType(CYCLE_BASED_ANNOTATION);
long cyclePeriod = 200;
if (annotation != null) {
cyclePeriod = (Long) stmtInterpreter.evaluate(annotation.getExpressions().get(0), context);
}
return cyclePeriod;
}
use of org.yakindu.sct.model.stext.stext.ArgumentedAnnotation in project statecharts by Yakindu.
the class StextResource method parseStatechart.
protected void parseStatechart(Statechart statechart) {
IParseResult parseResult = parse(statechart, StatechartSpecification.class.getSimpleName());
StatechartSpecification rootASTElement = (StatechartSpecification) parseResult.getRootASTElement();
statechart.setNamespace(rootASTElement.getNamespace());
statechart.getScopes().clear();
EList<Scope> definitionScopes = rootASTElement.getScopes();
if (definitionScopes != null) {
statechart.getScopes().addAll(definitionScopes);
}
statechart.getAnnotations().clear();
EList<ArgumentedAnnotation> annotations = rootASTElement.getAnnotations();
if (annotations != null) {
statechart.getAnnotations().addAll(annotations);
}
}
Aggregations