use of org.osate.aadl2.instance.ModeTransitionInstance in project osate-plugin by sireum.
the class Visitor method buildEndPoint.
private List<org.sireum.hamr.ir.EndPoint> buildEndPoint(ConnectionInstanceEnd connInstEnd, List<String> path) {
List<org.sireum.hamr.ir.EndPoint> result = VisitorUtil.iList();
final List<String> component = Arrays.asList(connInstEnd.getComponentInstance().getInstanceObjectPath().split("\\."));
final Position componentPos = VisitorUtil.buildPosInfo(connInstEnd.getComponentInstance().getInstantiatedObjects().get(0));
if (connInstEnd instanceof FeatureInstance) {
FeatureInstance connElem = (FeatureInstance) connInstEnd;
String featurePre = connElem.getFeature().getName();
FeatureInstance temp = connElem;
while (temp.eContainer() instanceof FeatureInstance) {
featurePre = ((FeatureInstance) temp.eContainer()).getName() + "_" + featurePre;
temp = (FeatureInstance) temp.eContainer();
}
if (connElem.getCategory() == FeatureCategory.FEATURE_GROUP && !connElem.getFeatureInstances().isEmpty()) {
// Feature ff = connElem.getFeature().getRefined();
final String fp = featurePre;
result = VisitorUtil.addAll(result, connElem.getFeatureInstances().stream().flatMap(fii -> flattenFeatureGroupInstance(fii, fp, component, componentPos, false).stream()).collect(Collectors.toList()));
} else if (connElem.getCategory() == FeatureCategory.BUS_ACCESS) {
final List<String> feature = VisitorUtil.add(component, featurePre);
final Position featurePos = VisitorUtil.buildPosInfo(connElem.getInstantiatedObjects().get(0));
final AadlASTJavaFactory.Direction direction = AadlASTJavaFactory.Direction.InOut;
result = VisitorUtil.add(result, factory.endPoint(factory.name(component, componentPos), factory.name(feature, featurePos), direction));
} else {
final List<String> feature = VisitorUtil.add(component, featurePre);
final Position featurePos = VisitorUtil.buildPosInfo(connElem.getInstantiatedObjects().get(0));
final AadlASTJavaFactory.Direction direction = handleDirection(connElem.getDirection());
result = VisitorUtil.add(result, factory.endPoint(factory.name(component, componentPos), factory.name(feature, featurePos), direction));
}
// org.sireum.hamr.ir.Feature f = buildFeature(connElem, component);
// if(connElem.getCategory() == FeatureCategory.FEATURE_GROUP) {
// connElem.getFeatureInstances().forEach(fi -> {
//
// });
// }
// final List<String> component = (connElem.getgetContext() != null) && (connElem
// .getContext() instanceof Subcomponent)
// ? VisitorUtil.add(path, connElem.getContext().getName())
// : path;
} else if (connInstEnd instanceof ComponentInstance) {
result = VisitorUtil.toIList(factory.endPoint(factory.name(component, componentPos), null, null));
} else if (connInstEnd instanceof ModeTransitionInstance) {
throw new RuntimeException("Need to handle ModeTransitionInstanceImpl: " + connInstEnd);
} else {
throw new RuntimeException("Unexpected: " + connInstEnd);
}
if (result.size() > 1) {
// System.out.println("");
}
return result;
}
use of org.osate.aadl2.instance.ModeTransitionInstance in project osate2 by osate.
the class ValidateConnectionsSwitch method checkConnectionClassifiers.
private void checkConnectionClassifiers(final ConnectionInstance conni) {
final ConnectionInstanceEnd srcEnd = conni.getSource();
final ConnectionInstanceEnd destEnd = conni.getDestination();
if (!(srcEnd instanceof ModeTransitionInstance) && !(destEnd instanceof ModeTransitionInstance)) {
final boolean sourceIsSubcomponent = srcEnd instanceof ComponentInstance;
final boolean destIsSubcomponent = destEnd instanceof ComponentInstance;
final Classifier srcClassifier = getConnectionEndClassifier(srcEnd);
final Classifier destClassifier = getConnectionEndClassifier(destEnd);
if (srcClassifier == null && destClassifier != null) {
if (!isAbstractFeature(srcEnd)) {
warning(conni, "Expected " + (sourceIsSubcomponent ? "subcomponent \'" : "feature \'") + srcEnd.getComponentInstancePath() + "' to have classifier '" + destClassifier.getQualifiedName() + '\'');
}
} else if (srcClassifier != null && destClassifier == null) {
if (!isAbstractFeature(destEnd)) {
warning(conni, "Expected " + (destIsSubcomponent ? "subcomponent \'" : "feature \'") + destEnd.getComponentInstancePath() + "' to have classifier '" + srcClassifier.getQualifiedName() + '\'');
}
} else {
checkEndPointClassifierMatching(conni, srcEnd, destEnd, srcClassifier, destClassifier);
}
}
}
use of org.osate.aadl2.instance.ModeTransitionInstance in project osate2 by osate.
the class CreateEndToEndFlowsSwitch method doFlowSpecInstances.
/**
* add flowspec instances to the component instance
*/
private void doFlowSpecInstances(ComponentInstance ci) {
EList<FlowSpecification> flowspecs = InstanceUtil.getComponentType(ci, 0, null).getAllFlowSpecifications();
for (Iterator<FlowSpecification> it = flowspecs.iterator(); it.hasNext(); ) {
FlowSpecification f = it.next();
FlowSpecificationInstance speci = InstanceFactory.eINSTANCE.createFlowSpecificationInstance();
speci.setFlowSpecification(f);
speci.setName(f.getName());
FlowEnd inend = f.getAllInEnd();
if (inend != null) {
Feature srcfp = inend.getFeature();
Context srcpg = inend.getContext();
if (srcpg == null) {
FeatureInstance fi = ci.findFeatureInstance(srcfp);
if (fi != null) {
speci.setSource(fi);
}
} else if (srcpg instanceof FeatureGroup) {
FeatureInstance pgi = ci.findFeatureInstance((FeatureGroup) srcpg);
if (pgi != null) {
FeatureInstance fi = pgi.findFeatureInstance(srcfp);
if (fi != null) {
speci.setSource(fi);
}
}
}
}
FlowEnd outend = f.getAllOutEnd();
if (outend != null) {
Feature dstfp = outend.getFeature();
Context dstpg = outend.getContext();
if (dstpg == null) {
FeatureInstance fi = ci.findFeatureInstance(dstfp);
if (fi != null) {
speci.setDestination(fi);
}
} else if (dstpg instanceof FeatureGroup) {
FeatureInstance pgi = ci.findFeatureInstance((FeatureGroup) dstpg);
if (pgi != null) {
FeatureInstance fi = pgi.findFeatureInstance(dstfp);
if (fi != null) {
speci.setDestination(fi);
}
}
}
}
ci.getFlowSpecifications().add(speci);
for (Mode mode : f.getAllInModes()) {
ModeInstance mi = ci.findModeInstance(mode);
if (mi != null) {
speci.getInModes().add(mi);
}
}
for (ModeTransition mt : f.getInModeTransitions()) {
ModeTransitionInstance ti = ci.findModeTransitionInstance(mt);
if (ti != null) {
speci.getInModeTransitions().add(ti);
}
}
}
}
use of org.osate.aadl2.instance.ModeTransitionInstance in project osate2 by osate.
the class InstantiateModel method fillModeTransitions.
/**
* @param ci
* @param transitions
* @throws InterruptedException
*/
protected void fillModeTransitions(ComponentInstance ci, List<ModeTransition> transitions) throws InterruptedException {
for (ModeTransition mt : transitions) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
ModeTransitionInstance mti = InstanceFactory.eINSTANCE.createModeTransitionInstance();
Mode srcmode = mt.getSource();
Mode dstmode = mt.getDestination();
ModeInstance srcI = ci.findModeInstance(srcmode);
ModeInstance dstI = ci.findModeInstance(dstmode);
mti.setSource(srcI);
mti.setDestination(dstI);
mti.setModeTransition(mt);
List<ModeTransitionTrigger> triggers = mt.getOwnedTriggers();
String eventName = "";
if (!triggers.isEmpty()) {
TriggerPort tp = triggers.get(0).getTriggerPort();
if (tp instanceof Port) {
Context ctx = triggers.get(0).getContext();
if (ctx instanceof Subcomponent) {
eventName = ((Subcomponent) ctx).getName() + "_";
}
}
eventName += tp.getName();
}
mti.setName(srcmode.getName() + "_" + (!eventName.equals("") ? eventName + "_" : "") + dstmode.getName());
// add only triggers that are ports
for (ModeTransitionTrigger t : triggers) {
TriggerPort tp = t.getTriggerPort();
if (tp instanceof Port) {
Port port = (Port) tp;
FeatureInstance porti = null;
Context ctx = t.getContext();
if (ctx instanceof Subcomponent) {
ComponentInstance subi = ci.findSubcomponentInstance((Subcomponent) ctx);
porti = subi.findFeatureInstance(port);
} else if (ctx instanceof FeatureGroup) {
FeatureInstance fgi = ci.findFeatureInstance((FeatureGroup) ctx);
porti = fgi.findFeatureInstance(port);
} else if (ctx == null) {
porti = ci.findFeatureInstance(port);
}
if (porti != null) {
mti.getTriggers().add(porti);
}
}
}
ci.getModeTransitionInstances().add(mti);
}
}
use of org.osate.aadl2.instance.ModeTransitionInstance in project osate2 by osate.
the class AbstractInstanceSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Aadl2Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Aadl2Package.ARRAY_RANGE:
sequence_ArrayRange(context, (ArrayRange) semanticObject);
return;
case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
return;
case Aadl2Package.BOOLEAN_LITERAL:
sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
return;
case Aadl2Package.CLASSIFIER_VALUE:
sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
return;
case Aadl2Package.COMPUTED_VALUE:
sequence_ComputedTerm(context, (ComputedValue) semanticObject);
return;
case Aadl2Package.CONTAINED_NAMED_ELEMENT:
sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
return;
case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
return;
case Aadl2Package.INTEGER_LITERAL:
sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
return;
case Aadl2Package.LIST_VALUE:
sequence_ListTerm(context, (ListValue) semanticObject);
return;
case Aadl2Package.MODAL_PROPERTY_VALUE:
if (rule == grammarAccess.getModalPropertyValueRule()) {
sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyValueRule()) {
sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else
break;
case Aadl2Package.NAMED_VALUE:
if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
sequence_ConstantValue(context, (NamedValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
return;
} else
break;
case Aadl2Package.OPERATION:
sequence_SignedConstant(context, (Operation) semanticObject);
return;
case Aadl2Package.PROPERTY_ASSOCIATION:
if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyAssociationRule()) {
sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else
break;
case Aadl2Package.RANGE_VALUE:
sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
return;
case Aadl2Package.REAL_LITERAL:
sequence_RealTerm(context, (RealLiteral) semanticObject);
return;
case Aadl2Package.RECORD_VALUE:
if (rule == grammarAccess.getOldRecordTermRule()) {
sequence_OldRecordTerm(context, (RecordValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
sequence_RecordTerm(context, (RecordValue) semanticObject);
return;
} else
break;
case Aadl2Package.REFERENCE_VALUE:
sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
return;
case Aadl2Package.STRING_LITERAL:
sequence_StringTerm(context, (StringLiteral) semanticObject);
return;
}
else if (epackage == InstancePackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case InstancePackage.COMPONENT_INSTANCE:
sequence_ComponentInstance(context, (ComponentInstance) semanticObject);
return;
case InstancePackage.CONNECTION_INSTANCE:
sequence_ConnectionInstance(context, (ConnectionInstance) semanticObject);
return;
case InstancePackage.CONNECTION_REFERENCE:
sequence_ConnectionReference(context, (ConnectionReference) semanticObject);
return;
case InstancePackage.END_TO_END_FLOW_INSTANCE:
sequence_EndToEndFlowInstance(context, (EndToEndFlowInstance) semanticObject);
return;
case InstancePackage.FEATURE_INSTANCE:
sequence_FeatureInstance(context, (FeatureInstance) semanticObject);
return;
case InstancePackage.FLOW_SPECIFICATION_INSTANCE:
sequence_FlowSpecificationInstance(context, (FlowSpecificationInstance) semanticObject);
return;
case InstancePackage.INSTANCE_REFERENCE_VALUE:
sequence_InstanceReferenceValue(context, (InstanceReferenceValue) semanticObject);
return;
case InstancePackage.MODE_INSTANCE:
sequence_ModeInstance(context, (ModeInstance) semanticObject);
return;
case InstancePackage.MODE_TRANSITION_INSTANCE:
sequence_ModeTransitionInstance(context, (ModeTransitionInstance) semanticObject);
return;
case InstancePackage.PROPERTY_ASSOCIATION_INSTANCE:
sequence_PropertyAssociationInstance(context, (PropertyAssociationInstance) semanticObject);
return;
case InstancePackage.SYSTEM_INSTANCE:
sequence_SystemInstance(context, (SystemInstance) semanticObject);
return;
case InstancePackage.SYSTEM_OPERATION_MODE:
sequence_SystemOperationMode(context, (SystemOperationMode) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations