use of org.yakindu.sct.simulation.core.engine.scheduling.ITimeTaskScheduler.TimeTask 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);
}
Aggregations