Search in sources :

Example 1 with Port

use of com.google.cloud.aiplatform.v1.Port in project VERDICT by ge-high-assurance.

the class Agree2Vdm method getVdmExpressionFromAgreeExpression.

// method to translate expression in Agree to expression in vdm
private Expression getVdmExpressionFromAgreeExpression(Expr agreeExpr, HashSet<String> dataTypeDecl, HashSet<String> nodeDecl, Model model) {
    Expression vdmExpr = new Expression();
    if (agreeExpr instanceof IfThenElseExpr) {
        IfThenElseExpr ifexpr = (IfThenElseExpr) agreeExpr;
        // for vdm model
        IfThenElse ifThenElseVal = new IfThenElse();
        Expression condExpr = getVdmExpressionFromAgreeExpression(ifexpr.getA(), dataTypeDecl, nodeDecl, model);
        ifThenElseVal.setCondition(condExpr);
        Expression thenBranchExpr = getVdmExpressionFromAgreeExpression(ifexpr.getB(), dataTypeDecl, nodeDecl, model);
        ifThenElseVal.setThenBranch(thenBranchExpr);
        Expression elseBranchExpr = getVdmExpressionFromAgreeExpression(ifexpr.getC(), dataTypeDecl, nodeDecl, model);
        ifThenElseVal.setElseBranch(elseBranchExpr);
        vdmExpr.setConditionalExpression(ifThenElseVal);
    } else if (agreeExpr instanceof CallExpr) {
        CallExpr callExpr = (CallExpr) agreeExpr;
        DoubleDotRef ddref = (DoubleDotRef) callExpr.getRef();
        if (ddref.getElm() instanceof NodeDef) {
            NodeDef nodeDef = (NodeDef) ddref.getElm();
            addNodeDefToTypeDeclarations(nodeDef, dataTypeDecl, nodeDecl, model);
            // create node call in vdm model
            NodeCall vdmNodeCall = new NodeCall();
            // setting node name
            vdmNodeCall.setNodeId(nodeDef.getName());
            EList<Expr> callExprArgs = callExpr.getArgs();
            // below are the parameters passed to the function call
            for (Expr callExprArg : callExprArgs) {
                Expression argExpr = getVdmExpressionFromAgreeExpression(callExprArg, dataTypeDecl, nodeDecl, model);
                // setting node arguments
                vdmNodeCall.getArgument().add(argExpr);
            }
            vdmExpr.setCall(vdmNodeCall);
        } else {
            System.out.println("Unmapped Typed");
        }
    } else if (agreeExpr instanceof NamedElmExpr) {
        NamedElmExpr nmExpr = (NamedElmExpr) agreeExpr;
        vdmExpr.setIdentifier(nmExpr.getElm().getName());
        // define corresponding types in the VDM if not already defined
        if (nmExpr.getElm() instanceof Arg) {
            Arg nmElmArg = (Arg) nmExpr.getElm();
            // define corresponding type in the VDM if not already defined
            Type argType = nmElmArg.getType();
            defineDataTypeDataImplementationTypeInVDM(argType, dataTypeDecl, model);
        } else if (nmExpr.getElm() instanceof Port) {
            Port nmElmPort = (Port) nmExpr.getElm();
            // define corresponding type in the VDM if not already defined
            if (nmElmPort instanceof DataPortImpl) {
                DataPort nmElmDataPort = (DataPort) nmElmPort;
                DataSubcomponentType dSubCompType = nmElmDataPort.getDataFeatureClassifier();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
            } else if (nmElmPort instanceof EventDataPortImpl) {
                EventDataPort nmElmDataPort = (EventDataPort) nmElmPort;
                DataSubcomponentType dSubCompType = nmElmDataPort.getDataFeatureClassifier();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
            } else {
                if (!(nmElmPort instanceof EventPort)) {
                    System.out.println("Unresolved Port Type");
                }
            }
        } else if (nmExpr.getElm() instanceof ConstStatement) {
            ConstStatement nmElmConstStatement = (ConstStatement) nmExpr.getElm();
            String nmElmConstStatementName = nmElmConstStatement.getName();
            // add const declaration to VDM if not already defined
            if (!dataTypeDecl.contains(nmElmConstStatementName)) {
                dataTypeDecl.add(nmElmConstStatementName);
                ConstantDeclaration vdmConstDeclaration = new ConstantDeclaration();
                vdmConstDeclaration.setName(nmElmConstStatementName);
                vdmConstDeclaration.setDefinition(getVdmExpressionFromAgreeExpression(nmElmConstStatement.getExpr(), dataTypeDecl, nodeDecl, model));
                vdmConstDeclaration.setDataType(getVdmTypeFromAgreeType(nmElmConstStatement.getType(), dataTypeDecl, model));
                LustreProgram lustreProgram = model.getDataflowCode();
                lustreProgram.getConstantDeclaration().add(vdmConstDeclaration);
                model.setDataflowCode(lustreProgram);
            }
        } else {
            System.out.println("Unresolved/unmapped NamedExprElm: " + nmExpr.getElm().getName());
        }
    } else if (agreeExpr instanceof SelectionExpr) {
        // selection expression corresponds to record projection in VDM
        RecordProjection vdmRecordProj = new RecordProjection();
        SelectionExpr selExpr = (SelectionExpr) agreeExpr;
        if (selExpr.getField() == null) {
            System.out.println("Null Selection Expr field: " + selExpr.getField());
        } else {
            NamedElement field = selExpr.getField();
            // set record-projection's reference
            if (selExpr.getTarget() != null) {
                // target can be NamedElmExpr or a SelectionExpr
                vdmRecordProj.setRecordReference(getVdmExpressionFromAgreeExpression(selExpr.getTarget(), dataTypeDecl, nodeDecl, model));
            }
            // set record-projection's field id
            vdmRecordProj.setFieldId(field.getName());
            // also set the name of the field's type as the record-projection's record-type
            if (field instanceof DataPortImpl) {
                DataPort dport = (DataPort) field;
                DataSubcomponentType dSubCompType = dport.getDataFeatureClassifier();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
                vdmRecordProj.setRecordType(dSubCompType.getName());
            } else if (field instanceof DataSubcomponentImpl) {
                DataSubcomponent dSubComp = (DataSubcomponent) field;
                DataSubcomponentType dSubCompType = dSubComp.getDataSubcomponentType();
                defineDataTypeDataImplementationTypeInVDM(dSubCompType, dataTypeDecl, model);
                vdmRecordProj.setRecordType(dSubCompType.getName());
            } else if (field instanceof ArgImpl) {
                Arg arg = (Arg) field;
                Type argType = arg.getType();
                defineDataTypeDataImplementationTypeInVDM(argType, dataTypeDecl, model);
                if (argType instanceof PrimType) {
                    vdmRecordProj.setRecordType(getDataTypeName(argType));
                } else {
                    System.out.println("Unresolved Arg Type so not setting record-type in record-projection.");
                }
            } else {
                System.out.println("Unresolved type of field.");
            }
        }
        vdmExpr.setRecordProjection(vdmRecordProj);
    } else if (agreeExpr instanceof BinaryExpr) {
        BinaryExpr binExpr = (BinaryExpr) agreeExpr;
        // for vdm
        BinaryOperation binoper = new BinaryOperation();
        // set left operand
        Expression leftOperand = getVdmExpressionFromAgreeExpression(binExpr.getLeft(), dataTypeDecl, nodeDecl, model);
        binoper.setLhsOperand(leftOperand);
        // set right operand
        Expression rightOperand = getVdmExpressionFromAgreeExpression(binExpr.getRight(), dataTypeDecl, nodeDecl, model);
        binoper.setRhsOperand(rightOperand);
        // set appropriate operator
        String operator = binExpr.getOp();
        if (operator.equalsIgnoreCase("->")) {
            vdmExpr.setArrow(binoper);
        } else if (operator.equalsIgnoreCase("=>")) {
            vdmExpr.setImplies(binoper);
        } else if (operator.equalsIgnoreCase("and")) {
            vdmExpr.setAnd(binoper);
        } else if (operator.equalsIgnoreCase("or")) {
            vdmExpr.setOr(binoper);
        } else if (operator.equalsIgnoreCase("=")) {
            vdmExpr.setEqual(binoper);
        } else if (operator.equalsIgnoreCase(">")) {
            vdmExpr.setGreaterThan(binoper);
        } else if (operator.equalsIgnoreCase("<")) {
            vdmExpr.setLessThan(binoper);
        } else if (operator.equalsIgnoreCase(">=")) {
            vdmExpr.setGreaterThanOrEqualTo(binoper);
        } else if (operator.equalsIgnoreCase("<=")) {
            vdmExpr.setLessThanOrEqualTo(binoper);
        } else if (operator.equalsIgnoreCase("+")) {
            vdmExpr.setPlus(binoper);
        } else if (operator.equalsIgnoreCase("-")) {
            vdmExpr.setMinus(binoper);
        } else if (operator.equalsIgnoreCase("!=") || operator.equalsIgnoreCase("<>")) {
            vdmExpr.setNotEqual(binoper);
        } else if (operator.equalsIgnoreCase("/")) {
            vdmExpr.setDiv(binoper);
        } else if (operator.equalsIgnoreCase("*")) {
            vdmExpr.setTimes(binoper);
        } else {
            System.out.println("Unmapped binary operator: " + operator);
        }
    } else if (agreeExpr instanceof UnaryExpr) {
        UnaryExpr unExpr = (UnaryExpr) agreeExpr;
        Expression singleOperand = getVdmExpressionFromAgreeExpression(unExpr.getExpr(), dataTypeDecl, nodeDecl, model);
        String operator = unExpr.getOp();
        if (operator.equalsIgnoreCase("this")) {
            vdmExpr.setCurrent(singleOperand);
        } else if (operator.equalsIgnoreCase("not")) {
            vdmExpr.setNot(singleOperand);
        } else if (operator.equalsIgnoreCase("-")) {
            vdmExpr.setNegative(singleOperand);
        } else {
            System.out.println("Unmapped unary operator.");
        }
    } else if (agreeExpr instanceof BoolLitExpr) {
        BoolLitExpr boolExpr = (BoolLitExpr) agreeExpr;
        vdmExpr.setBoolLiteral(boolExpr.getVal().getValue());
    } else if (agreeExpr instanceof EnumLitExpr) {
        EnumLitExpr enumExpr = (EnumLitExpr) agreeExpr;
        // check if elm is DataImplementationImpl or DataTypeImpl -- if yes add definition to type declarations if not already present
        DoubleDotRef enumType = enumExpr.getEnumType();
        if (enumType.getElm() instanceof DataTypeImpl) {
            org.osate.aadl2.DataType aadlDType = (org.osate.aadl2.DataType) enumType.getElm();
            resolveAADLDataType(aadlDType, dataTypeDecl, model);
        } else {
            System.out.println("Unexpected Elm type for EnumLitExpr");
        }
        vdmExpr.setIdentifier(enumExpr.getValue());
    } else if (agreeExpr instanceof PreExpr) {
        PreExpr preExpr = (PreExpr) agreeExpr;
        Expression expr = getVdmExpressionFromAgreeExpression(preExpr.getExpr(), dataTypeDecl, nodeDecl, model);
        vdmExpr.setPre(expr);
    } else if (agreeExpr instanceof RecordLitExpr) {
        RecordLiteral vdmRecordLiteral = new RecordLiteral();
        RecordLitExpr recLitExpr = (RecordLitExpr) agreeExpr;
        if (recLitExpr.getRecordType() instanceof DoubleDotRef) {
            DoubleDotRef recType = (DoubleDotRef) recLitExpr.getRecordType();
            if (recType.getElm().getName() != null) {
                // check if elm is DataImplementationImpl -- if yes add definition to type declarations if not already present
                if (recType.getElm() instanceof DataImplementation) {
                    org.osate.aadl2.DataImplementation aadlDImpl = (org.osate.aadl2.DataImplementation) recType.getElm();
                    resolveAADLDataImplementationType(aadlDImpl, dataTypeDecl, model);
                } else {
                    System.out.println("Unexpected Elm type for EnumLitExpr");
                }
                // set name of the record literal in the vdm model
                vdmRecordLiteral.setRecordType(recType.getElm().getName());
                // get args and arg-expr and set them as field identifier and value in the vdm model
                EList<NamedElement> recLitArgs = recLitExpr.getArgs();
                EList<Expr> recLitArgsExpr = recLitExpr.getArgExpr();
                // below are the values set to variable
                for (int ind = 0; ind < recLitArgs.size(); ind++) {
                    FieldDefinition fieldDef = new FieldDefinition();
                    fieldDef.setFieldIdentifier(recLitArgs.get(ind).getName());
                    fieldDef.setFieldValue(getVdmExpressionFromAgreeExpression(recLitArgsExpr.get(ind), dataTypeDecl, nodeDecl, model));
                    // set field definitions in the record literal in the vdm model
                    vdmRecordLiteral.getFieldDefinition().add(fieldDef);
                }
                vdmExpr.setRecordLiteral(vdmRecordLiteral);
            } else {
                System.out.println("Unexpected Literal's Record Type that has null named elm.");
            }
        } else {
            System.out.println("Unresolved or unmapped record literal expression.");
        }
    } else if (agreeExpr instanceof IntLitExpr) {
        IntLitExpr intLitExpr = (IntLitExpr) agreeExpr;
        BigInteger bigInt = new BigInteger(intLitExpr.getVal());
        vdmExpr.setIntLiteral(bigInt);
    } else if (agreeExpr instanceof RealLitExpr) {
        RealLitExpr realLitExpr = (RealLitExpr) agreeExpr;
        BigDecimal bigDecimal = new BigDecimal(realLitExpr.getVal());
        vdmExpr.setRealLiteral(bigDecimal);
    } else if (agreeExpr instanceof EventExpr) {
        EventExpr eventExpr = (EventExpr) agreeExpr;
        if (eventExpr.getPort() != null) {
            vdmExpr.setEvent(getVdmExpressionFromAgreeExpression(eventExpr.getPort(), dataTypeDecl, nodeDecl, model));
        } else {
            System.out.println("EventExpr does not have port infornation.");
        }
    } else if (agreeExpr instanceof RealCast) {
        RealCast realCastExpr = (RealCast) agreeExpr;
        vdmExpr.setToReal(getVdmExpressionFromAgreeExpression(realCastExpr.getExpr(), dataTypeDecl, nodeDecl, model));
    } else {
        System.out.println("Unresolved/umapped agree expr" + agreeExpr.toString());
    }
    return vdmExpr;
}
Also used : BinaryOperation(verdict.vdm.vdm_lustre.BinaryOperation) EventPort(org.osate.aadl2.EventPort) DataPort(org.osate.aadl2.DataPort) Port(org.osate.aadl2.Port) EventDataPort(org.osate.aadl2.EventDataPort) FieldDefinition(verdict.vdm.vdm_lustre.FieldDefinition) ConstantDeclaration(verdict.vdm.vdm_lustre.ConstantDeclaration) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) RealCast(com.rockwellcollins.atc.agree.agree.RealCast) RecordProjection(verdict.vdm.vdm_lustre.RecordProjection) DoubleDotRef(com.rockwellcollins.atc.agree.agree.DoubleDotRef) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) EventDataPort(org.osate.aadl2.EventDataPort) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) RecordLiteral(verdict.vdm.vdm_lustre.RecordLiteral) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) EventDataPortImpl(org.osate.aadl2.impl.EventDataPortImpl) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ConstStatement(com.rockwellcollins.atc.agree.agree.ConstStatement) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) 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) Expr(com.rockwellcollins.atc.agree.agree.Expr) 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) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) Arg(com.rockwellcollins.atc.agree.agree.Arg) BigInteger(java.math.BigInteger) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) NamedElement(org.osate.aadl2.NamedElement) ArgImpl(com.rockwellcollins.atc.agree.agree.impl.ArgImpl) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeDef(com.rockwellcollins.atc.agree.agree.NodeDef) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) DataSubcomponentImpl(org.osate.aadl2.impl.DataSubcomponentImpl) EventPort(org.osate.aadl2.EventPort) NodeCall(verdict.vdm.vdm_lustre.NodeCall) DataPortImpl(org.osate.aadl2.impl.DataPortImpl) EventDataPortImpl(org.osate.aadl2.impl.EventDataPortImpl) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) DataImplementation(org.osate.aadl2.DataImplementation) BigDecimal(java.math.BigDecimal) PrimType(com.rockwellcollins.atc.agree.agree.PrimType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) Type(com.rockwellcollins.atc.agree.agree.Type) EnumType(verdict.vdm.vdm_data.EnumType) RecordType(verdict.vdm.vdm_data.RecordType) SystemType(org.osate.aadl2.SystemType) ComponentType(verdict.vdm.vdm_model.ComponentType) EList(org.eclipse.emf.common.util.EList) PropertyExpression(org.osate.aadl2.PropertyExpression) Expression(verdict.vdm.vdm_lustre.Expression) LustreProgram(verdict.vdm.vdm_lustre.LustreProgram) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DataTypeImpl(org.osate.aadl2.impl.DataTypeImpl) IfThenElse(verdict.vdm.vdm_lustre.IfThenElse)

Example 2 with Port

use of com.google.cloud.aiplatform.v1.Port in project osate2 by osate.

the class CreateConnectionsSwitch method doModeTransitionConnections.

/**
 * As we are following connection declarations we need to check whether the
 * destination of the connection is named in one of the mode transitions of
 * the component instance that is the destination of the connection being
 * added
 *
 * @param parentci
 *            The component that is the context in which the connections are
 *            declared
 * @param pci
 *            PortConnectionInstance that is being created
 * @param conn
 *            connection being added to the ConnectionInstance
 * @return true if we created a ModetransitionInstance
 */
private boolean doModeTransitionConnections(final ComponentInstance parentci, ConnectionInfo connInfo, Connection conn) {
    boolean didTransition = false;
    if (!(conn instanceof PortConnection || conn instanceof FeatureGroupConnection)) {
        return false;
    }
    ComponentInstance parent = null;
    Context fc = conn.getAllDestinationContext();
    Element connContext = null;
    if (fc instanceof ComponentImplementation || fc instanceof FeatureGroup) {
        // we
        // have
        // an
        // outgoing
        // connection
        parent = (ComponentInstance) parentci.eContainer();
        connContext = parentci.getSubcomponent();
    } else if (fc instanceof Subcomponent) {
        parent = parentci.findSubcomponentInstance((Subcomponent) fc);
        connContext = ((Subcomponent) fc).getAllClassifier();
    }
    if (parent == null) {
        return false;
    }
    EList<ModeTransitionInstance> mtl = parent.getModeTransitionInstances();
    Feature f = (Feature) conn.getAllDestination();
    for (ModeTransitionInstance mti : mtl) {
        ModeTransition mt = mti.getModeTransition();
        Context co = null;
        for (ModeTransitionTrigger trigger : mt.getOwnedTriggers()) {
            TriggerPort tp = trigger.getTriggerPort();
            if (tp instanceof Port) {
                Port o = (Port) tp;
                co = trigger.getContext();
                NamedElement context = co;
                if (context instanceof FeatureGroup) {
                    context = parent.getSubcomponent().getAllClassifier();
                }
                if (f == o && context == connContext) {
                    final ConnectionInstance mtci = addConnectionInstance(parentci.getSystemInstance(), connInfo.convertToModeTransition(), mti);
                    fillInModes(mtci);
                    fillInModeTransitions(mtci);
                    didTransition = true;
                }
            } else {
            // TODO-LW: what if it's a processor port or internal event?
            }
        }
    }
    return didTransition;
}
Also used : Context(org.osate.aadl2.Context) ComponentImplementation(org.osate.aadl2.ComponentImplementation) ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) FeatureGroup(org.osate.aadl2.FeatureGroup) Element(org.osate.aadl2.Element) NamedElement(org.osate.aadl2.NamedElement) ConnectedElement(org.osate.aadl2.ConnectedElement) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) TriggerPort(org.osate.aadl2.TriggerPort) ModeTransition(org.osate.aadl2.ModeTransition) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature) PortConnection(org.osate.aadl2.PortConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) NamedElement(org.osate.aadl2.NamedElement) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 3 with Port

use of com.google.cloud.aiplatform.v1.Port in project osate2 by osate.

the class CreateConnectionsSwitch method doModeTransitionConnections.

// ------------------------------------------------------------------------
// Methods related to mode transition connections
// ------------------------------------------------------------------------
/**
 * handles the situation that a mode transition may name an event port in a
 * thread (or other leaf component instance) and that port is not the
 * destination of a connection instance - it is the start of a connection
 * instance
 *
 * @param ci
 *            ComponentInstance
 * @param fi
 *            FeatureInstance
 * @return true if we created a ModetransitionInstance
 */
private boolean doModeTransitionConnections(ComponentInstance ci, FeatureInstance fi) {
    boolean didTransition = false;
    if (fi.getCategory() == FeatureCategory.EVENT_PORT) {
        Subcomponent sub = ci.getSubcomponent();
        Feature f = fi.getFeature();
        for (ModeTransitionInstance mti : ci.getContainingComponentInstance().getModeTransitionInstances()) {
            for (ModeTransitionTrigger trigger : mti.getModeTransition().getOwnedTriggers()) {
                TriggerPort tp = trigger.getTriggerPort();
                if (tp instanceof Port) {
                    Port p = (Port) tp;
                    Context c = trigger.getContext();
                    if (f == p && c == sub) {
                        addConnectionInstance(ci.getSystemInstance(), ConnectionInfo.newModeTransition(fi), mti);
                        didTransition = true;
                    }
                } else {
                // TODO-LW: what if it's a processor port or internal
                // event?
                }
            }
        }
    }
    return didTransition;
}
Also used : Context(org.osate.aadl2.Context) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) Port(org.osate.aadl2.Port) TriggerPort(org.osate.aadl2.TriggerPort) TriggerPort(org.osate.aadl2.TriggerPort) ModeTransitionInstance(org.osate.aadl2.instance.ModeTransitionInstance) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 4 with Port

use of com.google.cloud.aiplatform.v1.Port in project java-aiplatform by googleapis.

the class GetModelSample method getModelSample.

static void getModelSample(String project, String modelId) throws IOException {
    ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
        String location = "us-central1";
        ModelName modelName = ModelName.of(project, location, modelId);
        Model modelResponse = modelServiceClient.getModel(modelName);
        System.out.println("Get Model response");
        System.out.format("\tName: %s\n", modelResponse.getName());
        System.out.format("\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\tMetadata: %s\n", modelResponse.getMetadata());
        System.out.format("\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList());
        System.out.format("\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList());
        System.out.format("\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList());
        System.out.format("\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\tPredict Schemata");
        System.out.format("\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (ExportFormat exportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\tSupported Export Format");
            System.out.format("\t\tId: %s\n", exportFormat.getId());
        }
        ModelContainerSpec containerSpec = modelResponse.getContainerSpec();
        System.out.println("\tContainer Spec");
        System.out.format("\t\tImage Uri: %s\n", containerSpec.getImageUri());
        System.out.format("\t\tCommand: %s\n", containerSpec.getCommandList());
        System.out.format("\t\tArgs: %s\n", containerSpec.getArgsList());
        System.out.format("\t\tPredict Route: %s\n", containerSpec.getPredictRoute());
        System.out.format("\t\tHealth Route: %s\n", containerSpec.getHealthRoute());
        for (EnvVar envVar : containerSpec.getEnvList()) {
            System.out.println("\t\tEnv");
            System.out.format("\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : containerSpec.getPortsList()) {
            System.out.println("\t\tPort");
            System.out.format("\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\tDeployed Model");
            System.out.format("\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
    }
}
Also used : PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) ModelName(com.google.cloud.aiplatform.v1.ModelName) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) Port(com.google.cloud.aiplatform.v1.Port) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) ExportFormat(com.google.cloud.aiplatform.v1.Model.ExportFormat) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Example 5 with Port

use of com.google.cloud.aiplatform.v1.Port in project java-aiplatform by googleapis.

the class GetTrainingPipelineSample method getTrainingPipeline.

static void getTrainingPipeline(String project, String trainingPipelineId) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        TrainingPipelineName trainingPipelineName = TrainingPipelineName.of(project, location, trainingPipelineId);
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.getTrainingPipeline(trainingPipelineName);
        System.out.println("Get Training Pipeline Response");
        System.out.format("\tName: %s\n", trainingPipelineResponse.getName());
        System.out.format("\tDisplay Name: %s\n", trainingPipelineResponse.getDisplayName());
        System.out.format("\tTraining Task Definition: %s\n", trainingPipelineResponse.getTrainingTaskDefinition());
        System.out.format("\tTraining Task Inputs: %s\n", trainingPipelineResponse.getTrainingTaskInputs());
        System.out.format("\tTraining Task Metadata: %s\n", trainingPipelineResponse.getTrainingTaskMetadata());
        System.out.format("\tState: %s\n", trainingPipelineResponse.getState());
        System.out.format("\tCreate Time: %s\n", trainingPipelineResponse.getCreateTime());
        System.out.format("\tStart Time: %s\n", trainingPipelineResponse.getStartTime());
        System.out.format("\tEnd Time: %s\n", trainingPipelineResponse.getEndTime());
        System.out.format("\tUpdate Time: %s\n", trainingPipelineResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", trainingPipelineResponse.getLabelsMap());
        InputDataConfig inputDataConfig = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s\n", inputDataConfig.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfig.getAnnotationsFilter());
        FractionSplit fractionSplit = inputDataConfig.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplit.getTestFraction());
        FilterSplit filterSplit = inputDataConfig.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Filter: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Filter: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Filter: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfig.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfig.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\t\tModel to upload");
        System.out.format("\t\tName: %s\n", modelResponse.getName());
        System.out.format("\t\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\t\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\t\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\t\tMeta Data: %s\n", modelResponse.getMetadata());
        System.out.format("\t\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\t\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\t\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList().toString());
        System.out.format("\t\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList().toString());
        System.out.format("\t\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList().toString());
        System.out.format("\t\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\t\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\t\tLabels: %s\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\tPredict Schemata");
        System.out.format("\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (Model.ExportFormat supportedExportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\tSupported Export Format");
            System.out.format("\t\tId: %s\n", supportedExportFormat.getId());
        }
        ModelContainerSpec containerSpec = modelResponse.getContainerSpec();
        System.out.println("\tContainer Spec");
        System.out.format("\t\tImage Uri: %s\n", containerSpec.getImageUri());
        System.out.format("\t\tCommand: %s\n", containerSpec.getCommandList());
        System.out.format("\t\tArgs: %s\n", containerSpec.getArgsList());
        System.out.format("\t\tPredict Route: %s\n", containerSpec.getPredictRoute());
        System.out.format("\t\tHealth Route: %s\n", containerSpec.getHealthRoute());
        for (EnvVar envVar : containerSpec.getEnvList()) {
            System.out.println("\t\tEnv");
            System.out.format("\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : containerSpec.getPortsList()) {
            System.out.println("\t\tPort");
            System.out.format("\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\tDeployed Model");
            System.out.format("\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
        Status status = trainingPipelineResponse.getError();
        System.out.println("\tError");
        System.out.format("\t\tCode: %s\n", status.getCode());
        System.out.format("\t\tMessage: %s\n", status.getMessage());
    }
}
Also used : Status(com.google.rpc.Status) PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) TrainingPipelineName(com.google.cloud.aiplatform.v1.TrainingPipelineName) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Port(com.google.cloud.aiplatform.v1.Port) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) PredefinedSplit(com.google.cloud.aiplatform.v1.PredefinedSplit) FilterSplit(com.google.cloud.aiplatform.v1.FilterSplit) FractionSplit(com.google.cloud.aiplatform.v1.FractionSplit) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient)

Aggregations

DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)10 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)10 Model (com.google.cloud.aiplatform.v1.Model)10 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)10 Port (com.google.cloud.aiplatform.v1.Port)10 PredictSchemata (com.google.cloud.aiplatform.v1.PredictSchemata)10 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)9 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)9 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)9 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)9 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)9 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)9 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)9 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)9 Status (com.google.rpc.Status)9 LocationName (com.google.cloud.aiplatform.v1.LocationName)8 Port (org.osate.aadl2.Port)8 ExportFormat (com.google.cloud.aiplatform.v1.Model.ExportFormat)7 Subcomponent (org.osate.aadl2.Subcomponent)6 ArrayList (java.util.ArrayList)5