use of org.yakindu.sct.model.sruntime.ExecutionContext in project statecharts by Yakindu.
the class ExecutionContextVisualizer method highlightSuspendedElements.
protected void highlightSuspendedElements(final Notification notification) {
highlight(notification, DefaultDynamicNotationHandler.SUSPENDED_PARAMS);
List<IHighlightingSupport.Action> actions = new ArrayList<IHighlightingSupport.Action>();
// This is required to set active state highlighting after resuming from
// terminated local reaction breakpoint
ExecutionContext context = getExecutionContext(notification);
List<EObject> newValues = toList(notification.getNewValue());
List<EObject> oldValues = toList(notification.getOldValue());
oldValues.removeAll(newValues);
for (EObject eObject : oldValues) {
if (context.getActiveStates().contains(eObject)) {
actions.add(new IHighlightingSupport.Highlight(eObject, DefaultDynamicNotationHandler.STATE_HIGHLIGHT_PARAMS));
}
}
getHighlightingSupport().executeAsync(actions);
}
use of org.yakindu.sct.model.sruntime.ExecutionContext in project statecharts by Yakindu.
the class FeatureParameterValueImpl method getExecutionContext.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
protected ExecutionContext getExecutionContext() {
if (!(EcoreUtil.getRootContainer(this) instanceof GeneratorModel)) {
return new ExecutionContextImpl();
}
ExecutionContext context = new ExecutionContextImpl();
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getRootContainer(this);
EList<PropertyDefinition> properties = generatorModel.getProperties();
for (PropertyDefinition propertyDefinition : properties) {
ExecutionVariable variable = SRuntimeFactory.eINSTANCE.createExecutionVariable();
variable.setName(propertyDefinition.getName());
variable.setFqName(propertyDefinition.getName());
variable.setType(propertyDefinition.getType());
variable.setValue(interpreter.evaluate(propertyDefinition.getInitialValue(), context));
context.getSlots().add(variable);
}
return context;
}
use of org.yakindu.sct.model.sruntime.ExecutionContext in project statecharts by Yakindu.
the class DefaultSimulationEngineFactory method restore.
protected ExecutionContext restore(String context, Statechart statechart) {
try {
ResourceSet set = new ResourceSetImpl();
Resource resource = set.createResource(URI.createURI("snapshot.xmi"));
if (resource == null)
return null;
set.getResources().add(resource);
resource.load(new URIConverter.ReadableInputStream(context, "UTF_8"), Collections.emptyMap());
IDomain domain = DomainRegistry.getDomain(statechart);
Injector injector = domain.getInjector(IDomain.FEATURE_SIMULATION);
ITypeSystem typeSystem = injector.getInstance(ITypeSystem.class);
if (typeSystem instanceof AbstractTypeSystem) {
set.getResources().add(((AbstractTypeSystem) typeSystem).getResource());
}
EcoreUtil.resolveAll(resource);
ExecutionContext result = (ExecutionContext) resource.getContents().get(0);
result.setSnapshot(true);
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.yakindu.sct.model.sruntime.ExecutionContext in project statecharts by Yakindu.
the class DefaultSimulationEngineFactory method createExecutionContainer.
public ISimulationEngine createExecutionContainer(Statechart statechart, ILaunch launch) throws CoreException {
ISimulationEngine controller = createController(statechart);
injector.injectMembers(controller);
// For restoring execution context
String attribute = launch.getLaunchConfiguration().getAttribute(ISCTLaunchParameters.EXECUTION_CONTEXT, "");
if (attribute != null && attribute.trim().length() > 0) {
ExecutionContext context = restore(attribute, statechart);
controller.setExecutionContext(context);
}
return controller;
}
Aggregations