Search in sources :

Example 1 with LatchedStatement

use of com.rockwellcollins.atc.agree.agree.LatchedStatement 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 2 with LatchedStatement

use of com.rockwellcollins.atc.agree.agree.LatchedStatement in project AGREE by loonwerks.

the class AgreeASTBuilder method getAgreeNode.

private AgreeNode getAgreeNode(ComponentInstance compInst, boolean isTop) {
    List<AgreeVar> inputs = new ArrayList<>();
    List<AgreeVar> outputs = new ArrayList<>();
    List<AgreeVar> locals = new ArrayList<>();
    List<AgreeAADLConnection> aadlConnections = new ArrayList<>();
    List<AgreeOverriddenConnection> userDefinedConections = new ArrayList<>();
    List<AgreeConnection> connections = new ArrayList<>();
    List<AgreeNode> subNodes = new ArrayList<>();
    List<AgreeStatement> assertions = new ArrayList<>();
    List<AgreeStatement> assumptions = new ArrayList<>();
    List<AgreeStatement> guarantees = new ArrayList<>();
    List<AgreeStatement> lemmas = new ArrayList<>();
    List<AgreeEquation> localEquations = new ArrayList<>();
    List<AgreeStatement> patternProps = Collections.emptyList();
    timeOfVarMap = new HashMap<>();
    timeRiseVarMap = new HashMap<>();
    timeFallVarMap = new HashMap<>();
    unspecifiedAadlProperties = new HashMap<>();
    Expr clockConstraint = new BoolExpr(true);
    Expr initialConstraint = new BoolExpr(true);
    String id = compInst.getName();
    AgreeVar clockVar = new AgreeVar(id + clockIDSuffix, NamedType.BOOL, compInst.getSubcomponent(), compInst, null);
    EObject reference = isTop ? compInst.getComponentClassifier() : compInst.getSubcomponent();
    TimingModel timing = null;
    boolean foundSubNode = false;
    boolean hasDirectAnnex = false;
    boolean hasSubcomponents = false;
    ComponentClassifier compClass = compInst.getComponentClassifier();
    Set<ComponentType> effectiveTypes = new HashSet<>();
    Map<String, jkind.lustre.Expr> portRewriteMap = new HashMap<>();
    if (compClass instanceof ComponentImplementation) {
        boolean latched = false;
        ComponentImplementation cc = (ComponentImplementation) compClass;
        effectiveTypes.addAll(getEffectiveComponentTypes(cc.getType()));
        if (isTop || isMonolithic) {
            while (cc != null) {
                AgreeContractSubclause annex = getAgreeAnnex(cc);
                for (ComponentInstance subInst : compInst.getComponentInstances()) {
                    hasSubcomponents = true;
                    curInst = subInst;
                    AgreeNode subNode = getAgreeNode(subInst, false);
                    if (subNode != null && subNodes.stream().noneMatch(it -> it.reference.equals(subNode.reference))) {
                        foundSubNode = true;
                        subNodes.add(subNode);
                    }
                }
                if (annex != null) {
                    hasDirectAnnex = true;
                    AgreeContract contract = (AgreeContract) annex.getContract();
                    curInst = compInst;
                    assertions.addAll(getAssertionStatements(contract.getSpecs()));
                    getEquationStatements(contract.getSpecs(), portRewriteMap).addAllTo(locals, assertions, guarantees);
                    assertions.addAll(getPropertyStatements(contract.getSpecs()));
                    assertions.addAll(getAssignmentStatements(contract.getSpecs()));
                    userDefinedConections.addAll(getConnectionStatements(contract.getSpecs()));
                    lemmas.addAll(getLemmaStatements(contract.getSpecs()));
                    lemmas.addAll(getReachableStatements(contract.getSpecs(), portRewriteMap));
                    addLustreNodes(contract.getSpecs());
                    gatherLustreTypes(contract.getSpecs());
                    // the clock constraints contain other nodes that we add
                    clockConstraint = getClockConstraint(contract.getSpecs(), subNodes);
                    timing = getTimingModel(contract.getSpecs());
                    outputs.addAll(getEquationVars(contract.getSpecs(), compInst));
                    for (SpecStatement spec : contract.getSpecs()) {
                        if (spec instanceof LatchedStatement) {
                            latched = true;
                            break;
                        }
                    }
                }
                // Find extended effective types
                effectiveTypes.addAll(getEffectiveComponentTypes(cc.getType()));
                cc = cc.getExtended();
            }
            EList<ConnectionInstance> connectionInstances = compInst.getAllEnclosingConnectionInstances();
            List<ConnectionInstance> foo = new ArrayList<>();
            compInst.getAllComponentInstances().forEach(ci -> ci.allEnclosingConnectionInstances().forEach(foo::add));
            aadlConnections.addAll(getConnectionsFromInstances(connectionInstances, compInst, subNodes, latched));
            connections.addAll(filterConnections(aadlConnections, userDefinedConections));
        }
        ComponentType compType = ((ComponentImplementation) compClass).getType();
        AgreeContractSubclause compImpAnnex = getAgreeAnnex(compClass);
        if (compImpAnnex != null) {
            AgreeContract contract = (AgreeContract) compImpAnnex.getContract();
            for (SpecStatement spec : contract.getSpecs()) {
                if (spec instanceof LiftContractStatement) {
                    Subcomponent sub = ((ComponentImplementation) compClass).getOwnedSubcomponents().get(0);
                    ComponentType ct = sub.getComponentType();
                    for (Connection conn : ((ComponentImplementation) compClass).getAllConnections()) {
                        NamedElement sourceNe = conn.getSource().getConnectionEnd();
                        NamedElement destNe = conn.getDestination().getConnectionEnd();
                        String sourceStr = sourceNe.getName().replace("::", "__");
                        String destStr = destNe.getName().replace("::", "__");
                        if (ct == sourceNe.getContainingClassifier()) {
                            portRewriteMap.put(sourceStr, new IdExpr(destStr));
                        } else if (ct == destNe.getContainingClassifier()) {
                            portRewriteMap.put(destStr, new IdExpr(sourceStr));
                        }
                    }
                    effectiveTypes.addAll(getEffectiveComponentTypes(ct));
                }
            }
        }
        // make compClass the type so we can get it's other contract elements
        compClass = compType;
    } else if (compClass instanceof ComponentType) {
        effectiveTypes.addAll(getEffectiveComponentTypes((ComponentType) compClass));
    } else {
        throw new AgreeException("Internal error: attempt to run AGREE analysis on instance " + compInst.getFullName() + " not instance of ComponentImplementation or ComponentType.");
    }
    curInst = compInst;
    if (timing == null) {
        timing = TimingModel.SYNC;
    }
    for (ComponentType compType : effectiveTypes) {
        AgreeContractSubclause annex = getAgreeAnnex(compType);
        if (annex != null) {
            hasDirectAnnex = true;
            AgreeContract contract = (AgreeContract) annex.getContract();
            // this makes files for monolithic verification a bit smaller
            if (!isMonolithic || isTop || !hasSubcomponents) {
                assumptions.addAll(getAssumptionStatements(contract.getSpecs(), portRewriteMap));
                guarantees.addAll(getGuaranteeStatements(contract.getSpecs(), portRewriteMap));
                lemmas.addAll(getReachableStatements(contract.getSpecs(), portRewriteMap));
            }
            // Count eq statements with expressions as assertions
            getEquationStatements(contract.getSpecs(), portRewriteMap).addAllTo(locals, assertions, guarantees);
            assertions.addAll(getPropertyStatements(contract.getSpecs()));
            outputs.addAll(getEquationVars(contract.getSpecs(), compInst));
            getAgreeInputVars(contract.getSpecs(), compInst).addAllTo(inputs, assumptions, guarantees);
            initialConstraint = getInitialConstraint(contract.getSpecs());
            addLustreNodes(contract.getSpecs());
            gatherLustreTypes(contract.getSpecs());
        }
    }
    gatherUnspecifiedAadlProperties(unspecifiedAadlProperties, inputs, assumptions, guarantees);
    if (!(foundSubNode || hasDirectAnnex)) {
        return null;
    }
    gatherOutputsInputsAndTypes(outputs, inputs, compInst.getFeatureInstances(), assumptions, guarantees);
    AgreeNodeBuilder builder = new AgreeNodeBuilder(id);
    builder.addInput(inputs);
    builder.addOutput(outputs);
    builder.addLocal(locals);
    builder.addLocalEquation(localEquations);
    builder.addConnection(connections);
    builder.addSubNode(subNodes);
    // Clean up any vacuous true predicates
    Predicate<AgreeStatement> isBoolExprAndisTrue = st -> (st.expr instanceof BoolExpr) && ((BoolExpr) st.expr).value;
    assertions.removeIf(isBoolExprAndisTrue);
    assumptions.removeIf(isBoolExprAndisTrue);
    guarantees.removeIf(isBoolExprAndisTrue);
    builder.addAssertion(assertions);
    builder.addAssumption(assumptions);
    builder.addGuarantee(guarantees);
    builder.addLemma(lemmas);
    builder.addPatternProp(patternProps);
    builder.setClockConstraint(clockConstraint);
    builder.setInitialConstraint(initialConstraint);
    builder.setClockVar(clockVar);
    builder.setReference(reference);
    builder.setTiming(timing);
    builder.setCompInst(compInst);
    builder.addTimeOf(timeOfVarMap);
    builder.addTimeRise(timeRiseVarMap);
    builder.addTimeFall(timeFallVarMap);
    AgreeNode result = builder.build();
    renamings.put(id, compInst.getName());
    refMap.put(id, compInst);
    return linearizationRewriter.visit(result);
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) AnnexUtil(org.osate.annexsupport.AnnexUtil) AadlBoolean(org.osate.aadl2.AadlBoolean) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordDef(com.rockwellcollins.atc.agree.agree.RecordDef) FnDef(com.rockwellcollins.atc.agree.agree.FnDef) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) BigDecimal(java.math.BigDecimal) PropertyExpression(org.osate.aadl2.PropertyExpression) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) Map(java.util.Map) Expr(jkind.lustre.Expr) InputStatement(com.rockwellcollins.atc.agree.agree.InputStatement) BigInteger(java.math.BigInteger) CastExpr(jkind.lustre.CastExpr) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) ConnectionEnd(org.osate.aadl2.ConnectionEnd) CalenStatement(com.rockwellcollins.atc.agree.agree.CalenStatement) FeatureCategory(org.osate.aadl2.instance.FeatureCategory) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) PatternStatement(com.rockwellcollins.atc.agree.agree.PatternStatement) MNSynchronyElement(com.rockwellcollins.atc.agree.analysis.MNSynchronyElement) Set(java.util.Set) ComponentRef(com.rockwellcollins.atc.agree.agree.ComponentRef) AadlPackage(org.osate.aadl2.AadlPackage) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) AgreePatternTranslator(com.rockwellcollins.atc.agree.analysis.realtime.AgreePatternTranslator) PropertyDoesNotApplyToHolderException(org.osate.aadl2.properties.PropertyDoesNotApplyToHolderException) AgreeCalendarUtils(com.rockwellcollins.atc.agree.analysis.AgreeCalendarUtils) MNSynchStatement(com.rockwellcollins.atc.agree.agree.MNSynchStatement) Node(jkind.lustre.Node) ConnectionStatement(com.rockwellcollins.atc.agree.agree.ConnectionStatement) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreeUtils(com.rockwellcollins.atc.agree.analysis.AgreeUtils) AgreeSporadicPattern(com.rockwellcollins.atc.agree.analysis.realtime.AgreeSporadicPattern) NodeCallExpr(jkind.lustre.NodeCallExpr) GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) AgreePeriodicPattern(com.rockwellcollins.atc.agree.analysis.realtime.AgreePeriodicPattern) Feature(org.osate.aadl2.Feature) RealExpr(jkind.lustre.RealExpr) ComponentImplementation(org.osate.aadl2.ComponentImplementation) IdGatherer(com.rockwellcollins.atc.agree.analysis.lustre.visitors.IdGatherer) Type(jkind.lustre.Type) ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) ArrayExpr(jkind.lustre.ArrayExpr) LiftContractStatement(com.rockwellcollins.atc.agree.agree.LiftContractStatement) AgreeCauseEffectPattern(com.rockwellcollins.atc.agree.analysis.realtime.AgreeCauseEffectPattern) SubstitutionVisitor(jkind.translation.SubstitutionVisitor) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) BinaryOp(jkind.lustre.BinaryOp) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FeatureGroup(org.osate.aadl2.FeatureGroup) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) IntegerLiteral(org.osate.aadl2.IntegerLiteral) NamedType(jkind.lustre.NamedType) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) AgreeInlineLatchedConnections(com.rockwellcollins.atc.agree.analysis.ast.visitors.AgreeInlineLatchedConnections) ReachableStatement(com.rockwellcollins.atc.agree.agree.ReachableStatement) PropertyConstant(org.osate.aadl2.PropertyConstant) AgreePatternBuilder(com.rockwellcollins.atc.agree.analysis.realtime.AgreePatternBuilder) Aadl2GlobalScopeUtil(org.osate.aadl2.modelsupport.scoping.Aadl2GlobalScopeUtil) EventPort(org.osate.aadl2.EventPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FeatureGroupType(org.osate.aadl2.FeatureGroupType) PortConnection(org.osate.aadl2.PortConnection) FunctionCallExpr(jkind.lustre.FunctionCallExpr) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) DataPort(org.osate.aadl2.DataPort) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) VarDecl(jkind.lustre.VarDecl) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) AnnexSubclause(org.osate.aadl2.AnnexSubclause) BooleanLiteral(org.osate.aadl2.BooleanLiteral) IfThenElseExpr(jkind.lustre.IfThenElseExpr) NamedElement(org.osate.aadl2.NamedElement) UninterpretedFnDef(com.rockwellcollins.atc.agree.agree.UninterpretedFnDef) RealLiteral(org.osate.aadl2.RealLiteral) NodeStmt(com.rockwellcollins.atc.agree.agree.NodeStmt) AsynchStatement(com.rockwellcollins.atc.agree.agree.AsynchStatement) NamedValue(org.osate.aadl2.NamedValue) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) TupleExpr(jkind.lustre.TupleExpr) PropertyUtils(org.osate.xtext.aadl2.properties.util.PropertyUtils) UnaryExpr(jkind.lustre.UnaryExpr) AgreeMakeClockedLustreNodes(com.rockwellcollins.atc.agree.analysis.ast.visitors.AgreeMakeClockedLustreNodes) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) ComponentType(org.osate.aadl2.ComponentType) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) IntExpr(jkind.lustre.IntExpr) UnaryOp(jkind.lustre.UnaryOp) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AadlReal(org.osate.aadl2.AadlReal) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) Predicate(java.util.function.Predicate) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) AssertStatement(com.rockwellcollins.atc.agree.agree.AssertStatement) NodeEq(com.rockwellcollins.atc.agree.agree.NodeEq) TimingModel(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode.TimingModel) NodeLemma(com.rockwellcollins.atc.agree.agree.NodeLemma) LinearizationRewriter(com.rockwellcollins.atc.agree.analysis.linearization.LinearizationRewriter) EObject(org.eclipse.emf.ecore.EObject) Connection(org.osate.aadl2.Connection) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) List(java.util.List) Property(org.osate.aadl2.Property) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) Entry(java.util.Map.Entry) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) SynchStatement(com.rockwellcollins.atc.agree.agree.SynchStatement) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) ExtensionRegistry(com.rockwellcollins.atc.agree.analysis.extentions.ExtensionRegistry) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) AadlInteger(org.osate.aadl2.AadlInteger) StringLiteral(org.osate.aadl2.StringLiteral) Arg(com.rockwellcollins.atc.agree.agree.Arg) TypeTable(com.rockwellcollins.atc.agree.analysis.TypeTable) Activator(com.rockwellcollins.atc.agree.analysis.Activator) FloorCast(com.rockwellcollins.atc.agree.agree.FloorCast) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) HashMap(java.util.HashMap) NodeBuilder(jkind.lustre.builders.NodeBuilder) ConnectionInstanceEnd(org.osate.aadl2.instance.ConnectionInstanceEnd) LinearizationDef(com.rockwellcollins.atc.agree.agree.LinearizationDef) HashSet(java.util.HashSet) DataSubcomponent(org.osate.aadl2.DataSubcomponent) InitialStatement(com.rockwellcollins.atc.agree.agree.InitialStatement) Function(jkind.lustre.Function) LustreExprFactory(com.rockwellcollins.atc.agree.analysis.translation.LustreExprFactory) PropertyStatement(com.rockwellcollins.atc.agree.agree.PropertyStatement) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeLogger(com.rockwellcollins.atc.agree.analysis.AgreeLogger) ThisRef(com.rockwellcollins.atc.agree.agree.ThisRef) AssignStatement(com.rockwellcollins.atc.agree.agree.AssignStatement) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EqStatement(com.rockwellcollins.atc.agree.agree.EqStatement) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) Equation(jkind.lustre.Equation) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) EList(org.eclipse.emf.common.util.EList) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) AgreeSwitch(com.rockwellcollins.atc.agree.agree.util.AgreeSwitch) PreferenceConstants(com.rockwellcollins.atc.agree.analysis.preferences.PreferenceConstants) DataClassifier(org.osate.aadl2.DataClassifier) EventDataPort(org.osate.aadl2.EventDataPort) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) Collections(java.util.Collections) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) BoolExpr(jkind.lustre.BoolExpr) ComponentClassifier(org.osate.aadl2.ComponentClassifier) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TimingModel(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode.TimingModel) EObject(org.eclipse.emf.ecore.EObject) Subcomponent(org.osate.aadl2.Subcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) LiftContractStatement(com.rockwellcollins.atc.agree.agree.LiftContractStatement) HashSet(java.util.HashSet) AgreeContract(com.rockwellcollins.atc.agree.agree.AgreeContract) ComponentType(org.osate.aadl2.ComponentType) IdExpr(jkind.lustre.IdExpr) PortConnection(org.osate.aadl2.PortConnection) Connection(org.osate.aadl2.Connection) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) 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) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) 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) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) 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) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) 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) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) NamedElement(org.osate.aadl2.NamedElement)

Example 3 with LatchedStatement

use of com.rockwellcollins.atc.agree.agree.LatchedStatement in project AGREE by loonwerks.

the class AgreeValidator method checkSynchStatement.

@Check(CheckType.FAST)
public void checkSynchStatement(SynchStatement sync) {
    Classifier container = sync.getContainingClassifier();
    if (!(container instanceof ComponentImplementation)) {
        error(sync, "Synchrony statements can appear only in component implementations");
    }
    if (sync instanceof CalenStatement || sync instanceof MNSynchStatement || sync instanceof AsynchStatement || sync instanceof LatchedStatement) {
        return;
    }
    // So this may be redundant
    if (Integer.valueOf(sync.getVal()) < 0) {
        error(sync, "The value of synchrony statments must be positive");
    }
    String val2 = sync.getVal2();
    if (val2 != null) {
        if (Integer.valueOf(val2) <= 0) {
            error(sync, "The second value of a synchrony statment must be greater than zero");
        }
        if (Integer.valueOf(sync.getVal()) <= Integer.valueOf(val2)) {
            error(sync, "The second value of a synchrony argument must be less than the first");
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) MNSynchStatement(com.rockwellcollins.atc.agree.agree.MNSynchStatement) LatchedStatement(com.rockwellcollins.atc.agree.agree.LatchedStatement) AsynchStatement(com.rockwellcollins.atc.agree.agree.AsynchStatement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) CalenStatement(com.rockwellcollins.atc.agree.agree.CalenStatement) Check(org.eclipse.xtext.validation.Check)

Aggregations

LatchedStatement (com.rockwellcollins.atc.agree.agree.LatchedStatement)3 ComponentClassifier (org.osate.aadl2.ComponentClassifier)3 AgreeContract (com.rockwellcollins.atc.agree.agree.AgreeContract)2 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)2 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)2 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)2 AsynchStatement (com.rockwellcollins.atc.agree.agree.AsynchStatement)2 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)2 CalenStatement (com.rockwellcollins.atc.agree.agree.CalenStatement)2 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)2 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)2 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)2 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)2 FlatmapExpr (com.rockwellcollins.atc.agree.agree.FlatmapExpr)2 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)2 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)2 ForallExpr (com.rockwellcollins.atc.agree.agree.ForallExpr)2 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)2 IndicesExpr (com.rockwellcollins.atc.agree.agree.IndicesExpr)2 InputStatement (com.rockwellcollins.atc.agree.agree.InputStatement)2