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);
}
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);
}
Aggregations