Search in sources :

Example 1 with Annotation

use of org.yakindu.base.types.Annotation in project statecharts by Yakindu.

the class JavaGeneratorModule method configureForExecutionStyle.

public void configureForExecutionStyle(GeneratorEntry entry, Binder binder) {
    Statechart statechart = (Statechart) entry.getElementRef();
    Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
    if (eventDrivenAnnotation != null) {
        binder.bind(Statemachine.class).to(EventDrivenStatemachine.class);
    }
}
Also used : EventDrivenStatemachine(org.yakindu.sct.generator.java.eventdriven.EventDrivenStatemachine) Statechart(org.yakindu.sct.model.sgraph.Statechart) Annotation(org.yakindu.base.types.Annotation)

Example 2 with Annotation

use of org.yakindu.base.types.Annotation in project statecharts by Yakindu.

the class CppCodeGeneratorModule method bindEventDrivenClasses.

protected void bindEventDrivenClasses(GeneratorEntry entry, Binder binder) {
    Statechart statechart = (Statechart) entry.getElementRef();
    Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
    if (eventDrivenAnnotation != null) {
        binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
        binder.bind(StatemachineImplementation.class).to(EventDrivenStatemachineImplementation.class);
        binder.bind(CppExpressionsGenerator.class).to(EventDrivenExpressionCode.class);
        binder.bind(EventCode.class).to(EventDrivenEventCode.class);
        binder.bind(StandardCppIncludeProvider.class).to(EventDrivenCppIncludeProvider.class);
    }
}
Also used : EventDrivenStatemachineImplementation(org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineImplementation) Statechart(org.yakindu.sct.model.sgraph.Statechart) EventDrivenStatemachineHeader(org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineHeader) Annotation(org.yakindu.base.types.Annotation) EventDrivenEventCode(org.yakindu.sct.generator.cpp.eventdriven.EventDrivenEventCode)

Example 3 with Annotation

use of org.yakindu.base.types.Annotation in project statecharts by Yakindu.

the class StextResource method serializeStatechart.

protected void serializeStatechart(Statechart statechart) {
    StringBuilder builder = new StringBuilder();
    if (statechart.getNamespace() != null) {
        builder.append("namespace " + statechart.getNamespace());
        builder.append(NEW_LINE);
    }
    for (Annotation annotation : statechart.getAnnotations()) {
        builder.append(serialize(annotation));
        builder.append(NEW_LINE);
    }
    for (Scope scope : statechart.getScopes()) {
        builder.append(serialize(scope));
        builder.append(NEW_LINE);
    }
    statechart.setSpecification(builder.toString());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) Annotation(org.yakindu.base.types.Annotation) ArgumentedAnnotation(org.yakindu.sct.model.stext.stext.ArgumentedAnnotation)

Example 4 with Annotation

use of org.yakindu.base.types.Annotation in project statecharts by Yakindu.

the class CCodeGeneratorModule method configureEventDriven.

protected void configureEventDriven(GeneratorEntry entry, Binder binder) {
    Statechart statechart = (Statechart) entry.getElementRef();
    Annotation eventDrivenAnnotation = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
    if (eventDrivenAnnotation != null) {
        binder.bind(StatemachineHeader.class).to(EventDrivenStatemachineHeader.class);
        binder.bind(StatemachineSource.class).to(EventDrivenStatemachineSource.class);
        binder.bind(CExpressionsGenerator.class).to(EventDrivenExpressionCode.class);
    }
}
Also used : EventDrivenStatemachineSource(org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineSource) Statechart(org.yakindu.sct.model.sgraph.Statechart) EventDrivenStatemachineHeader(org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineHeader) Annotation(org.yakindu.base.types.Annotation)

Example 5 with Annotation

use of org.yakindu.base.types.Annotation in project statecharts by Yakindu.

the class STextJavaValidator method checkAnnotations.

@Check(CheckType.FAST)
public void checkAnnotations(final Statechart statechart) {
    Annotation eventDriven = statechart.getAnnotationOfType(EVENT_DRIVEN_ANNOTATION);
    Annotation cycleBased = statechart.getAnnotationOfType(CYCLE_BASED_ANNOTATION);
    if (eventDriven != null && cycleBased != null) {
        String errorMsg = String.format(CONTRADICTORY_ANNOTATIONS, String.join(", ", eventDriven.getType().toString(), cycleBased.getType().toString()));
        error(errorMsg, cycleBased, null, -1);
    }
    Annotation parentFirst = statechart.getAnnotationOfType(PARENT_FIRST_ANNOTATION);
    Annotation childFirst = statechart.getAnnotationOfType(CHILD_FIRST_ANNOTATION);
    if (parentFirst != null && childFirst != null) {
        String errorMsg = String.format(CONTRADICTORY_ANNOTATIONS, String.join(", ", parentFirst.getType().toString(), childFirst.getType().toString()));
        error(errorMsg, parentFirst, null, -1);
    }
}
Also used : ArgumentedAnnotation(org.yakindu.sct.model.stext.stext.ArgumentedAnnotation) Annotation(org.yakindu.base.types.Annotation) Check(org.eclipse.xtext.validation.Check)

Aggregations

Annotation (org.yakindu.base.types.Annotation)6 Statechart (org.yakindu.sct.model.sgraph.Statechart)3 Check (org.eclipse.xtext.validation.Check)2 ArgumentedAnnotation (org.yakindu.sct.model.stext.stext.ArgumentedAnnotation)2 EObject (org.eclipse.emf.ecore.EObject)1 EventDrivenStatemachineHeader (org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineHeader)1 EventDrivenStatemachineSource (org.yakindu.sct.generator.c.eventdriven.EventDrivenStatemachineSource)1 EventDrivenEventCode (org.yakindu.sct.generator.cpp.eventdriven.EventDrivenEventCode)1 EventDrivenStatemachineHeader (org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineHeader)1 EventDrivenStatemachineImplementation (org.yakindu.sct.generator.cpp.eventdriven.EventDrivenStatemachineImplementation)1 EventDrivenStatemachine (org.yakindu.sct.generator.java.eventdriven.EventDrivenStatemachine)1 Scope (org.yakindu.sct.model.sgraph.Scope)1