Search in sources :

Example 11 with EventDataPort

use of org.osate.aadl2.EventDataPort in project AGREE by loonwerks.

the class AgreeASTBuilder method getAgreePortNames.

private List<AgreeVar> getAgreePortNames(ConnectionEnd port, String prefix, ComponentInstance compInst) {
    String portName = port.getName();
    List<AgreeVar> subVars = new ArrayList<>();
    // of a record type. Otherwise it is the first member of a feature group
    if (prefix == null) {
        prefix = "";
    } else if (port instanceof DataSubcomponent) {
        prefix = prefix + ".";
    } else {
        prefix = prefix + dotChar;
    }
    if (port instanceof FeatureGroup) {
        FeatureGroup featGroup = (FeatureGroup) port;
        FeatureGroupType featType = featGroup.getFeatureGroupType();
        for (FeatureGroup subFeatGroup : featType.getOwnedFeatureGroups()) {
            subVars.addAll(getAgreePortNames(subFeatGroup, null, compInst));
        }
        for (DataPort subPort : featType.getOwnedDataPorts()) {
            subVars.addAll(getAgreePortNames(subPort, null, compInst));
        }
        for (EventDataPort subPort : featType.getOwnedEventDataPorts()) {
            subVars.addAll(getAgreePortNames(subPort, null, compInst));
        }
        for (EventPort subPort : featType.getOwnedEventPorts()) {
            subVars.addAll(getAgreePortNames(subPort, null, compInst));
        }
        List<AgreeVar> prefixedStrs = new ArrayList<>();
        for (AgreeVar subVar : subVars) {
            prefixedStrs.add(new AgreeVar(prefix + portName + dotChar + subVar.id, subVar.type, subVar.reference, compInst));
        }
        subVars = prefixedStrs;
    }
    if (port instanceof DataPort || port instanceof EventDataPort || port instanceof DataSubcomponent) {
        Type type = getConnectionEndType(port);
        if (type != null) {
            subVars.add(new AgreeVar(prefix + portName, type, port, compInst));
        }
    }
    if (port instanceof EventDataPort || port instanceof EventPort) {
        subVars.add(new AgreeVar(prefix + portName + eventSuffix, NamedType.BOOL, port, compInst));
    }
    return subVars;
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) FeatureGroup(org.osate.aadl2.FeatureGroup) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) EventPort(org.osate.aadl2.EventPort) DataSubcomponent(org.osate.aadl2.DataSubcomponent) ArrayList(java.util.ArrayList) FeatureGroupType(org.osate.aadl2.FeatureGroupType) EventDataPort(org.osate.aadl2.EventDataPort)

Example 12 with EventDataPort

use of org.osate.aadl2.EventDataPort in project AGREE by loonwerks.

the class AgreeAnnexContentAssist method getNestedDotIDCandidates.

private List<String> getNestedDotIDCandidates(SelectionExpr id) {
    NamedElement base = ((NamedElmExpr) id).getElm();
    NamedElement namedEl = null;
    if (base instanceof Arg) {
        Type type = ((Arg) base).getType();
        DoubleDotRef elID = ((DoubleDotRef) type);
        namedEl = elID.getElm();
    // =======
    // DoubleDotRef elID = ((RecordType) type).getRecord();
    // namedEl = elID.getElm();
    // >>>>>>> origin/develop
    } else if (base instanceof DataPort) {
        namedEl = ((DataPort) base).getDataFeatureClassifier();
    } else if (base instanceof EventDataPort) {
        namedEl = ((EventDataPort) base).getDataFeatureClassifier();
    } else if (base instanceof AadlPackage) {
        return getNestedDotIDCandidates((AadlPackage) base);
    } else {
        return new ArrayList<>();
    }
    return getNestedDotIDCandidates(namedEl);
}
Also used : DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) Type(com.rockwellcollins.atc.agree.agree.Type) AadlPackage(org.osate.aadl2.AadlPackage) Arg(com.rockwellcollins.atc.agree.agree.Arg) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr)

Example 13 with EventDataPort

use of org.osate.aadl2.EventDataPort in project AGREE by loonwerks.

the class AgreeValidator method checkLiftContract.

@Check(CheckType.FAST)
public void checkLiftContract(LiftContractStatement lcst) {
    Classifier comp = lcst.getContainingClassifier();
    if (comp instanceof ComponentImplementation) {
        ComponentType ct = ((ComponentImplementation) comp).getType();
        List<AnnexSubclause> agreeAnnexes = AnnexUtil.getAllAnnexSubclauses(ct, AgreePackage.eINSTANCE.getAgreeContractSubclause());
        if (agreeAnnexes.size() > 0) {
            error(lcst, "'lift contract;' statement is not allowed in component implementation whose type has an AGREE annex.");
        }
        List<Subcomponent> subcomps = ((ComponentImplementation) comp).getAllSubcomponents();
        if (subcomps.size() == 1) {
            Subcomponent subcomp = subcomps.get(0);
            Classifier subCls = subcomp.getClassifier();
            ComponentType subCt = null;
            if (subCls instanceof ComponentImplementation) {
                subCt = ((ComponentImplementation) subCls).getType();
            } else if (subCls instanceof ComponentType) {
                subCt = (ComponentType) subCls;
            } else {
                throw new RuntimeException();
            }
            {
                Set<String> usedParentInPorts = new HashSet<>();
                Set<String> usedParentOutPorts = new HashSet<>();
                Set<String> usedChildInPorts = new HashSet<>();
                Set<String> usedChildOutPorts = new HashSet<>();
                EList<Classifier> ctPlusAllExtended = ct.getSelfPlusAllExtended();
                EList<Classifier> subCtPlusAllExtended = subCt.getSelfPlusAllExtended();
                for (Connection conn : ((ComponentImplementation) comp).getAllConnections()) {
                    {
                        NamedElement sourceNe = conn.getSource().getConnectionEnd();
                        if (subCtPlusAllExtended.contains(sourceNe.getContainingClassifier())) {
                            if (usedChildOutPorts.contains(sourceNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection out of same output " + sourceNe.getQualifiedName() + ".");
                            }
                            usedChildOutPorts.add(sourceNe.getName());
                        }
                        if (ctPlusAllExtended.contains(sourceNe.getContainingClassifier())) {
                            if (usedParentInPorts.contains(sourceNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection out of same input " + sourceNe.getQualifiedName() + ".");
                            }
                            usedParentInPorts.add(sourceNe.getName());
                        }
                    }
                    {
                        NamedElement destNe = conn.getDestination().getConnectionEnd();
                        if (subCtPlusAllExtended.contains(destNe.getContainingClassifier())) {
                            if (usedChildInPorts.contains(destNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection into same input " + destNe.getQualifiedName() + ".");
                            }
                            usedChildInPorts.add(destNe.getName());
                        }
                        if (ctPlusAllExtended.contains(destNe.getContainingClassifier())) {
                            if (usedParentOutPorts.contains(destNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection into same output " + destNe.getQualifiedName() + ".");
                            }
                            usedParentOutPorts.add(destNe.getName());
                        }
                    }
                }
                for (Feature feat : comp.getAllFeatures()) {
                    boolean isIn = false;
                    if (feat instanceof DataPort) {
                        isIn = ((DataPort) feat).isIn();
                    } else if (feat instanceof EventDataPort) {
                        isIn = ((EventDataPort) feat).isIn();
                    } else if (feat instanceof EventPort) {
                        isIn = ((EventPort) feat).isIn();
                    }
                    if (isIn) {
                        if (!usedParentInPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection from input " + feat.getQualifiedName() + ".");
                        }
                    } else {
                        if (!usedParentOutPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection to output " + feat.getQualifiedName() + ".");
                        }
                    }
                }
                for (Feature feat : subCt.getAllFeatures()) {
                    boolean isIn = false;
                    if (feat instanceof DataPort) {
                        isIn = ((DataPort) feat).isIn();
                    } else if (feat instanceof EventDataPort) {
                        isIn = ((EventDataPort) feat).isIn();
                    } else if (feat instanceof EventPort) {
                        isIn = ((EventPort) feat).isIn();
                    }
                    if (isIn) {
                        if (!usedChildInPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection into " + feat.getQualifiedName() + ".");
                        }
                    } else {
                        if (!usedChildOutPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection out of " + feat.getQualifiedName() + ".");
                        }
                    }
                }
            }
        } else {
            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout exactly one subcomponent.");
        }
    } else {
        error(lcst, "'lift contract;' statement is not allowed in component interface.");
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) Set(java.util.Set) HashSet(java.util.HashSet) Connection(org.osate.aadl2.Connection) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EList(org.eclipse.emf.common.util.EList) EventPort(org.osate.aadl2.EventPort) Subcomponent(org.osate.aadl2.Subcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Check(org.eclipse.xtext.validation.Check)

Example 14 with EventDataPort

use of org.osate.aadl2.EventDataPort in project AGREE by loonwerks.

the class AgreeValidator method checkLatchedExpr.

@Check(CheckType.FAST)
public void checkLatchedExpr(LatchedExpr latched) {
    // get container
    EObject container = latched.eContainer();
    AgreeContract contract = null;
    while (!(container instanceof ComponentClassifier)) {
        if (container instanceof AgreeContract) {
            contract = (AgreeContract) container;
        }
        container = container.eContainer();
    }
    if (container instanceof ComponentImplementation) {
        boolean foundLatchedStatement = false;
        for (SpecStatement spec : contract.getSpecs()) {
            if (spec instanceof LatchedStatement) {
                foundLatchedStatement = true;
                break;
            }
        }
        if (!foundLatchedStatement) {
            error(latched, "Latched expressions can appear only in component implementations " + "that contain a latched synchrony statement");
        }
    } else {
        error(latched, "Latched expressions can appear only in component implementations");
    }
    Expr expr = latched.getExpr();
    Expr nestId = null;
    if (expr instanceof NamedElmExpr) {
        nestId = expr;
    } else if (expr instanceof EventExpr) {
        EventExpr eventExpr = (EventExpr) expr;
        nestId = eventExpr.getPort();
    }
    if (nestId != null) {
        NamedElement namedEl = null;
        if (nestId instanceof NamedElmExpr) {
            namedEl = ((NamedElmExpr) nestId).getElm();
        } else if (nestId instanceof SelectionExpr) {
            namedEl = ((SelectionExpr) nestId).getField();
        }
        if ((namedEl instanceof DataPort) && ((DataPort) namedEl).isIn()) {
            return;
        } else if ((namedEl instanceof EventDataPort) && ((EventDataPort) namedEl).isIn()) {
            return;
        } else {
            // check to see if it is an "agree_input"
            EObject namedElContainer = namedEl.eContainer();
            if (namedElContainer instanceof InputStatement) {
                return;
            }
        }
    }
    error(latched, "Latched expressions are valid only for input data ports or event expressions over input event data ports");
}
Also used : AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) NamedSpecStatement(com.rockwellcollins.atc.agree.agree.NamedSpecStatement) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) EObject(org.eclipse.emf.ecore.EObject) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) EventDataPort(org.osate.aadl2.EventDataPort) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) NamedElement(org.osate.aadl2.NamedElement) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) Check(org.eclipse.xtext.validation.Check)

Example 15 with EventDataPort

use of org.osate.aadl2.EventDataPort in project AGREE by loonwerks.

the class AgreeValidator method checkEventExpr.

@Check(CheckType.FAST)
public void checkEventExpr(EventExpr event) {
    if (isInLinearizationBody(event)) {
        error(event, "'event' expressions not allowed in linearization body expressions");
        return;
    }
    Expr expr = event.getPort();
    NamedElement namedEl = null;
    if (expr instanceof NamedElmExpr) {
        namedEl = ((NamedElmExpr) expr).getElm();
    } else if (expr instanceof SelectionExpr) {
        namedEl = ((SelectionExpr) expr).getField();
    }
    if (namedEl == null || !(namedEl instanceof EventPort || namedEl instanceof EventDataPort)) {
        error(event, "Argument of event expression must be an event port or event data port");
    }
}
Also used : EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) EventPort(org.osate.aadl2.EventPort) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) Check(org.eclipse.xtext.validation.Check)

Aggregations

EventDataPort (org.osate.aadl2.EventDataPort)43 DataPort (org.osate.aadl2.DataPort)26 EventPort (org.osate.aadl2.EventPort)23 ArrayList (java.util.ArrayList)18 AnnexSubclause (org.osate.aadl2.AnnexSubclause)13 Port (verdict.vdm.vdm_model.Port)13 CyberRel (com.ge.research.osate.verdict.dsl.verdict.CyberRel)12 CyberReq (com.ge.research.osate.verdict.dsl.verdict.CyberReq)12 Event (com.ge.research.osate.verdict.dsl.verdict.Event)12 SafetyRel (com.ge.research.osate.verdict.dsl.verdict.SafetyRel)12 SafetyReq (com.ge.research.osate.verdict.dsl.verdict.SafetyReq)12 CyberMission (com.ge.research.osate.verdict.dsl.verdict.CyberMission)11 Statement (com.ge.research.osate.verdict.dsl.verdict.Statement)11 Verdict (com.ge.research.osate.verdict.dsl.verdict.Verdict)11 NamedElement (org.osate.aadl2.NamedElement)11 BusAccess (org.osate.aadl2.BusAccess)10 DataAccess (org.osate.aadl2.DataAccess)10 DataSubcomponent (org.osate.aadl2.DataSubcomponent)9 DataSubcomponentType (org.osate.aadl2.DataSubcomponentType)6 DoubleDotRef (com.rockwellcollins.atc.agree.agree.DoubleDotRef)5