Search in sources :

Example 1 with ErrorTransition

use of org.sireum.hamr.ir.ErrorTransition in project osate-plugin by sireum.

the class Emv2Visitor method errorBehaviorStateMachine.

private org.sireum.hamr.ir.BehaveStateMachine errorBehaviorStateMachine(ErrorBehaviorStateMachine ebsm) {
    Name id = getErrorType(ebsm).get();
    List<String> path = VisitorUtil.add(VisitorUtil.toIList(EMV2Util.getPrintName(EMV2Util.getContainingErrorModelLibrary(ebsm))), ebsm.getName());
    List<org.sireum.hamr.ir.ErrorEvent> events = ebsm.getEvents().stream().map(evnt -> factory.errorEvent(factory.name(VisitorUtil.add(path, evnt.getName()), VisitorUtil.buildPosInfo(evnt)))).collect(Collectors.toList());
    List<org.sireum.hamr.ir.ErrorState> states = ebsm.getStates().stream().map(st -> factory.errorState(factory.name(VisitorUtil.add(path, st.getName()), VisitorUtil.buildPosInfo(st)), st.isIntial())).collect(Collectors.toList());
    List<ErrorTransition> transitions = ebsm.getTransitions().stream().map(trans -> errorTransition(trans, path)).collect(Collectors.toList());
    // ebsm.getProperties().stream().map(pa -> emv2Property(pa,
    List<org.sireum.hamr.ir.Property> properties = VisitorUtil.iList();
    return factory.behaveStateMachine(id, events, states, transitions, properties);
}
Also used : ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes) Arrays(java.util.Arrays) Element(org.osate.aadl2.Element) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) Name(org.sireum.hamr.ir.Name) PropertyExpression(org.osate.aadl2.PropertyExpression) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) AnnexLib(org.sireum.hamr.ir.AnnexLib) Classifier(org.osate.aadl2.Classifier) Aadl2QualifiedNameProvider(org.osate.xtext.aadl2.naming.Aadl2QualifiedNameProvider) EMV2Properties(org.osate.xtext.aadl2.errormodel.util.EMV2Properties) OutgoingPropagationCondition(org.osate.xtext.aadl2.errormodel.errorModel.OutgoingPropagationCondition) ErrorAliasDef(org.sireum.hamr.ir.ErrorAliasDef) Annex(org.sireum.hamr.ir.Annex) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) AndExpression(org.osate.xtext.aadl2.errormodel.errorModel.AndExpression) Collection(java.util.Collection) ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) Collectors(java.util.stream.Collectors) BehaveStateMachine(org.sireum.hamr.ir.BehaveStateMachine) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) List(java.util.List) Stream(java.util.stream.Stream) Property(org.osate.aadl2.Property) Optional(java.util.Optional) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorTransition(org.sireum.hamr.ir.ErrorTransition) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) EMV2Util(org.osate.xtext.aadl2.errormodel.util.EMV2Util) Emv2BehaviorSection(org.sireum.hamr.ir.Emv2BehaviorSection) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorTypeDef(org.sireum.hamr.ir.ErrorTypeDef) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) OrlessExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrlessExpression) DirectionType(org.osate.aadl2.DirectionType) AllExpression(org.osate.xtext.aadl2.errormodel.errorModel.AllExpression) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) ErrorTypeSetDef(org.sireum.hamr.ir.ErrorTypeSetDef) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) ErrorPropagationImpl(org.osate.xtext.aadl2.errormodel.errorModel.impl.ErrorPropagationImpl) EList(org.eclipse.emf.common.util.EList) ErrorBehaviorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) NamedElement(org.osate.aadl2.NamedElement) Emv2Library(org.sireum.hamr.ir.Emv2Library) Collections(java.util.Collections) ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) Name(org.sireum.hamr.ir.Name) ErrorTransition(org.sireum.hamr.ir.ErrorTransition) Property(org.osate.aadl2.Property)

Example 2 with ErrorTransition

use of org.sireum.hamr.ir.ErrorTransition in project osate-plugin by sireum.

the class Emv2Visitor method errorTransition.

// private org.sireum.hamr.ir.Property emv2Property(EMV2PropertyAssociation epa, List<String> path) {
// Property prop = epa.getProperty();
// final NamedElement cont = (NamedElement) epa.eContainer();
// 
// List<PropertyValue> values = VisitorUtil.iList();
// try {
// PropertyExpression pe = PropertyUtils.getSimplePropertyValue(cont, prop);
// values = new Visitor().getPropertyExpressionValue(pe, path);
// } catch (Throwable t) {
// java.lang.System.err.println("Error encountered while trying to fetch property value for "
// + prop.getQualifiedName() + " from " + cont.getQualifiedName() + " : " + t.getMessage());
// }
// 
// return factory.property(
// factory.name(VisitorUtil.add(path, epa.getProperty().getName()), VisitorUtil.buildPosInfo(prop)),
// values);
// }
private org.sireum.hamr.ir.ErrorTransition errorTransition(ErrorBehaviorTransition ebt, List<String> path) {
    List<String> cp = (ebt.getName() != null) ? VisitorUtil.add(path, ebt.getName()) : path;
    Name name = null;
    if (ebt.getName() != null) {
        factory.name(cp, VisitorUtil.buildPosInfo(ebt));
    }
    Name source = null;
    if (ebt.isAllStates()) {
        if (ebt.getOwner() instanceof ComponentInstance && EMV2Util.getAllErrorBehaviorStates((ComponentInstance) ebt.getOwner()).isEmpty()) {
            source = getStateName(EMV2Util.getAllErrorBehaviorStates((ComponentInstance) ebt.getOwner()).stream().findFirst().get());
        }
        source = factory.name(VisitorUtil.add(VisitorUtil.iList(), ALL_STATE), VisitorUtil.buildPosInfo(ebt));
    } else {
        source = getStateName(ebt.getSource());
    }
    org.sireum.hamr.ir.ErrorCondition condition = errorCondition(ebt.getCondition(), path);
    Name target = null;
    if (ebt.getTarget() != null) {
        target = getStateName(ebt.getTarget());
    } else {
        target = ebt.getDestinationBranches().stream().map(db -> getStateName(db.getTarget())).collect(Collectors.toList()).get(// TODO: Support branching with probability
        0);
    }
    return factory.errorTransition(name, source, condition, target);
}
Also used : ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes) Arrays(java.util.Arrays) Element(org.osate.aadl2.Element) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) Name(org.sireum.hamr.ir.Name) PropertyExpression(org.osate.aadl2.PropertyExpression) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink) EventOrPropagation(org.osate.xtext.aadl2.errormodel.errorModel.EventOrPropagation) AnnexLib(org.sireum.hamr.ir.AnnexLib) Classifier(org.osate.aadl2.Classifier) Aadl2QualifiedNameProvider(org.osate.xtext.aadl2.naming.Aadl2QualifiedNameProvider) EMV2Properties(org.osate.xtext.aadl2.errormodel.util.EMV2Properties) OutgoingPropagationCondition(org.osate.xtext.aadl2.errormodel.errorModel.OutgoingPropagationCondition) ErrorAliasDef(org.sireum.hamr.ir.ErrorAliasDef) Annex(org.sireum.hamr.ir.Annex) OrmoreExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrmoreExpression) AndExpression(org.osate.xtext.aadl2.errormodel.errorModel.AndExpression) Collection(java.util.Collection) ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) Collectors(java.util.stream.Collectors) BehaveStateMachine(org.sireum.hamr.ir.BehaveStateMachine) ErrorBehaviorStateMachine(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine) List(java.util.List) Stream(java.util.stream.Stream) Property(org.osate.aadl2.Property) Optional(java.util.Optional) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorTransition(org.sireum.hamr.ir.ErrorTransition) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) EMV2Util(org.osate.xtext.aadl2.errormodel.util.EMV2Util) Emv2BehaviorSection(org.sireum.hamr.ir.Emv2BehaviorSection) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ErrorTypeDef(org.sireum.hamr.ir.ErrorTypeDef) ErrorBehaviorTransition(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) EMV2PropertyAssociation(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation) OrExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrExpression) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) OrlessExpression(org.osate.xtext.aadl2.errormodel.errorModel.OrlessExpression) DirectionType(org.osate.aadl2.DirectionType) AllExpression(org.osate.xtext.aadl2.errormodel.errorModel.AllExpression) ConditionExpression(org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression) ErrorTypeSetDef(org.sireum.hamr.ir.ErrorTypeSetDef) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) ErrorPropagationImpl(org.osate.xtext.aadl2.errormodel.errorModel.impl.ErrorPropagationImpl) EList(org.eclipse.emf.common.util.EList) ErrorBehaviorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelLibrary(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary) NamedElement(org.osate.aadl2.NamedElement) Emv2Library(org.sireum.hamr.ir.Emv2Library) Collections(java.util.Collections) ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) Name(org.sireum.hamr.ir.Name)

Aggregations

ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 EList (org.eclipse.emf.common.util.EList)2 Classifier (org.osate.aadl2.Classifier)2 DirectionType (org.osate.aadl2.DirectionType)2 Element (org.osate.aadl2.Element)2 NamedElement (org.osate.aadl2.NamedElement)2 Property (org.osate.aadl2.Property)2 PropertyExpression (org.osate.aadl2.PropertyExpression)2 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)2 AllExpression (org.osate.xtext.aadl2.errormodel.errorModel.AllExpression)2 AndExpression (org.osate.xtext.aadl2.errormodel.errorModel.AndExpression)2 ConditionElement (org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement)2