Package ptolemy.actor

Examples of ptolemy.actor.TypedIORelation


            // channel point to the appropriate buffer of the relation.
            int channel = 0;

            for (Iterator relations = port.linkedRelationList().iterator(); relations
                    .hasNext();) {
                TypedIORelation relation = (TypedIORelation) relations.next();

                for (int i = 0; i < relation.getWidth(); i++, channel++) {
                    // FIXME: buffersize is only one!
                    //  if (bufsize == 1) {
                    //  } else {
                    // Get the buffer associated with the channel.
                    SootField arrayField = _modelClass
View Full Code Here


            // channel point to the appropriate buffer of the relation.
            int channel = 0;

            for (Iterator relations = port.insideRelationList().iterator(); relations
                    .hasNext();) {
                TypedIORelation relation = (TypedIORelation) relations.next();

                for (int i = 0; i < relation.getWidth(); i++, channel++) {
                    // FIXME: buffersize is only one!
                    //  if (bufsize == 1) {
                    //  } else {
                    // Get the buffer associated with the channel.
                    SootField arrayField = modelClass
View Full Code Here

                relationList = port.linkedRelationList();
            }

            for (Iterator relations = relationList.iterator(); !found
                    && relations.hasNext();) {
                TypedIORelation relation = (TypedIORelation) relations.next();

                for (int i = 0; !found && (i < relation.getWidth()); i++, channel++) {
                    if (channel == argChannel) {
                        found = true;

                        SootField arrayField = _modelClass
                                .getFieldByName(InlinePortTransformer
View Full Code Here

        // Refer directly to the buffer in the _model
        int channel = 0;

        for (Iterator relations = port.linkedRelationList().iterator(); relations
                .hasNext();) {
            TypedIORelation relation = (TypedIORelation) relations.next();

            for (int i = 0; i < relation.getWidth(); i++, channel++) {
                SootField arrayField = _modelClass
                        .getFieldByName(InlinePortTransformer
                                .getBufferFieldName(relation, i, port.getType()));

                // assign the value.
View Full Code Here

        Chain clinitUnits = clinitBody.getUnits();

        // Loop over all the relations, creating buffers for each channel.
        for (Iterator relations = _model.relationList().iterator(); relations
                .hasNext();) {
            TypedIORelation relation = (TypedIORelation) relations.next();

            // Determine the types that the relation is connected to.
            Map typeMap = new HashMap();
            List destinationPortList = relation.linkedDestinationPortList();

            for (Iterator destinationPorts = destinationPortList.iterator(); destinationPorts
                    .hasNext();) {
                TypedIOPort port = (TypedIOPort) destinationPorts.next();
                ptolemy.data.type.Type type = port.getType();
                typeMap.put(type.toString(), type);
            }

            for (Iterator types = typeMap.keySet().iterator(); types.hasNext();) {
                ptolemy.data.type.Type type = (ptolemy.data.type.Type) typeMap
                        .get(types.next());
                RefType tokenType = PtolemyUtilities
                        .getSootTypeForTokenType(type);

                String fieldName = relation.getName() + "_bufferLocal";
                Local arrayLocal = Jimple.v().newLocal(fieldName, tokenType);
                clinitBody.getLocals().add(arrayLocal);

                for (int i = 0; i < relation.getWidth(); i++) {
                    SootField field = new SootField(InlinePortTransformer
                            .getBufferFieldName(relation, i, type), tokenType,
                            Modifier.PUBLIC | Modifier.STATIC);
                    _modelClass.addField(field);
View Full Code Here

                relationList = port.linkedRelationList();
            }

            for (Iterator relations = relationList.iterator(); relations
                    .hasNext();) {
                TypedIORelation relation = (TypedIORelation) relations.next();

                for (int i = 0; i < relation.getWidth(); i++, channel++) {
                    if (channel == argChannel) {
                        SootField arrayField = modelClass
                                .getFieldByName(InlinePortTransformer
                                        .getBufferFieldName(relation, i, type));
View Full Code Here

        ctIncD.trigger.link(ctIncR2);
        ctIncTr.link(ctIncR2);
        ctInc.connect(ctIncD.output, ctIncOut);

        //ctInc.connect(ctIncS.output, ctIncSt);
        TypedIORelation ctIncR1 = (TypedIORelation) ctInc
                .newRelation("CTIncR1");
        ctIncI.output.link(ctIncR1);

        //ctIncS.input.link(ctIncR1);
        ctIncGFi.link(ctIncR1);
        ctIncSt.link(ctIncR1);

        CTEmbeddedDirector ctIncDir = new CTEmbeddedDirector(ctInc, "CTIncDir");

        //ctIncDir.addDebugListener(dbl);
        CTCompositeActor ctDec = new CTCompositeActor(hs, "Decreasing");

        //ctDec.addDebugListener(dbl);
        //ZeroOrderHold ctDecH = new ZeroOrderHold(ctDec, "Hold");
        Integrator ctDecI = new Integrator(ctDec, "Integrator");
        Scale ctGain = new Scale(ctDec, "Gain");
        ZeroCrossingDetector ctDecD = new ZeroCrossingDetector(ctDec, "ZD");

        Expression ctDecGF = new Expression(ctDec, "EXPRESSION");
        TypedIOPort ctDecGFi = (TypedIOPort) ctDecGF.newPort("in");
        ctDecGFi.setInput(true);
        ctDecGFi.setTypeEquals(BaseType.DOUBLE);
        ctDecGF.output.setTypeEquals(BaseType.DOUBLE);
        ctDecGF.expression.setExpression("in + 0.0");

        // the ports
        TypedIOPort ctDecIn = (TypedIOPort) ctDec.newPort("input");
        ctDecIn.setInput(true);
        ctDecIn.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctDecOut = (TypedIOPort) ctDec.newPort("output");
        ctDecOut.setOutput(true);
        ctDecOut.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctDecSt = (TypedIOPort) ctDec.newPort("state");
        ctDecSt.setOutput(true);
        ctDecSt.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctDecTr = (TypedIOPort) ctDec.newPort("trig");
        ctDecTr.setOutput(true);
        ctDecTr.setTypeEquals(BaseType.DOUBLE);

        // connect ctDec
        //ctDec.connect(ctDecIn, ctDecH.input);
        //ctDec.connect(ctDecH.output, ctGain.input);
        ctDec.connect(ctDecIn, ctGain.input);
        ctDec.connect(ctGain.output, ctDecI.input);

        Relation ctDecR2 = ctDec.newRelation("R2");
        ctDecGF.output.link(ctDecR2);
        ctDecD.trigger.link(ctDecR2);
        ctDecTr.link(ctDecR2);
        ctDec.connect(ctDecD.output, ctDecOut);

        //ctDec.connect(ctDecS.output, ctDecSt);
        TypedIORelation ctDecR1 = (TypedIORelation) ctDec
                .newRelation("CTDecR1");
        ctDecI.output.link(ctDecR1);

        //ctDecS.input.link(ctDecR1);
        ctDecGFi.link(ctDecR1);
        ctDecSt.link(ctDecR1);

        CTEmbeddedDirector ctDecDir = new CTEmbeddedDirector(ctDec, "CTDecDir");

        //ctDecDir.addDebugListener(dbl);
        ctrlInc.refinementName.setExpression("Increasing");
        ctrlDec.refinementName.setExpression("Decreasing");

        // connect hs
        TypedIORelation hsr1 = (TypedIORelation) hs.newRelation("HSr1");
        hsin.link(hsr1);
        ctIncIn.link(hsr1);
        ctDecIn.link(hsr1);

        TypedIORelation hsr2 = (TypedIORelation) hs.newRelation("HSr2");
        ctrlIn.link(hsr2);
        ctIncOut.link(hsr2);
        ctDecOut.link(hsr2);

        TypedIORelation hsr3 = (TypedIORelation) hs.newRelation("HSr3");
        hsst.link(hsr3);
        ctIncSt.link(hsr3);
        ctDecSt.link(hsr3);
        ctrlSt.link(hsr3);
View Full Code Here

                throws PtalonRuntimeException {
            try {
                for (String portName : _relations.keySet()) {
                    String relationName = _actor.getMappedName(_relations
                            .get(portName));
                    TypedIORelation relation = (TypedIORelation) _actor
                            .getRelation(relationName);
                    TypedIOPort port = (TypedIOPort) actor.getPort(portName);
                    if (port == null) {
                        port = new TypedIOPort(actor, actor
                                .uniqueName(portName));
                        inner: for (Object connection : relation
                                .linkedPortList()) {
                            if (connection instanceof TypedIOPort) {
                                TypedIOPort testPort = (TypedIOPort) connection;
                                if (testPort.getContainer().equals(_actor)) {
                                    if (testPort.isInput()) {
                                        port.setInput(true);
                                    }
                                    if (testPort.isOutput()) {
                                        port.setOutput(true);
                                    }
                                } else {
                                    if (testPort.isInput()) {
                                        port.setOutput(true);
                                    }
                                    if (testPort.isOutput()) {
                                        port.setInput(true);
                                    }
                                }
                                break inner;
                            }
                        }
                    }
                    port.link(relation);
                }
                for (String portName : _transparencies.keySet()) {
                    TypedIOPort port = (TypedIOPort) actor.getPort(portName);
                    String shortName = _transparencies.get(portName);
                    if (_transparentRelations.containsKey(shortName)) {
                        TypedIOPort connectionPoint = _transparentRelations
                                .get(shortName);
                        String relationName = _actor.uniqueName("relation");
                        TypedIORelation rel = new TypedIORelation(_actor,
                                relationName);
                        if (port == null) {
                            port = new TypedIOPort(actor, actor
                                    .uniqueName(portName));
                            inner: for (Object connection : rel
                                    .linkedPortList()) {
                                if (connection instanceof TypedIOPort) {
                                    TypedIOPort testPort = (TypedIOPort) connection;
                                    if (testPort.getContainer().equals(_actor)) {
                                        if (testPort.isInput()) {
                                            port.setInput(true);
                                        }
                                        if (testPort.isOutput()) {
                                            port.setOutput(true);
                                        }
                                    } else {
                                        if (testPort.isInput()) {
                                            port.setOutput(true);
                                        }
                                        if (testPort.isOutput()) {
                                            port.setInput(true);
                                        }
                                    }
                                    break inner;
                                }
                            }
                        }
                        port.link(rel);
                        connectionPoint.link(rel);
                    } else {
                        if (port == null) {
                            port = new TypedIOPort(actor, actor
                                    .uniqueName(portName));
                            port.setMultiport(true);
                            port.setInput(true);
                            port.setOutput(false);
                        }
                        _transparentRelations.put(shortName, port);
                    }
                }
                for (String portName : _ports.keySet()) {
                    TypedIOPort port = (TypedIOPort) actor.getPort(portName);
                    String containerPortName = _actor.getMappedName(_ports
                            .get(portName));
                    TypedIOPort containerPort = (TypedIOPort) _actor
                            .getPort(containerPortName);
                    if (port == null) {
                        port = new TypedIOPort(actor, actor
                                .uniqueName(portName));
                        if (containerPort.isInput()) {
                            port.setInput(true);
                        }
                        if (containerPort.isOutput()) {
                            port.setOutput(true);
                        }
                    }
                    String relationName = _actor.uniqueName("relation");
                    TypedIORelation relation = new TypedIORelation(_actor,
                            relationName);
                    port.link(relation);
                    containerPort.link(relation);
                }
                for (String portName : _unknownPrefixes.keySet()) {
                    String suffix = evaluateString(_unknownExpressions
                            .get(portName));
                    if (suffix == null) {
                        throw new PtalonRuntimeException(
                                "Not able to evaluate suffix "
                                        + _unknownExpressions.get(portName));
                    }
                    String name = _unknownPrefixes.get(portName) + suffix;
                    if (_getType(name).endsWith("port")) {
                        TypedIOPort port = (TypedIOPort) actor
                                .getPort(portName);
                        String containerPortName = _actor.getMappedName(name);
                        TypedIOPort containerPort = (TypedIOPort) _actor
                                .getPort(containerPortName);
                        if (port == null) {
                            port = new TypedIOPort(actor, actor
                                    .uniqueName(portName));
                            if (containerPort.isInput()) {
                                port.setInput(true);
                            }
                            if (containerPort.isOutput()) {
                                port.setOutput(true);
                            }
                        }
                        String relationName = _actor.uniqueName("relation");
                        TypedIORelation relation = new TypedIORelation(_actor,
                                relationName);
                        port.link(relation);
                        containerPort.link(relation);
                    } else if (_getType(name).equals("relation")) {
                        String relationName = _actor.getMappedName(name);
                        TypedIORelation relation = (TypedIORelation) _actor
                                .getRelation(relationName);
                        TypedIOPort port = (TypedIOPort) actor
                                .getPort(portName);
                        if (port == null) {
                            port = new TypedIOPort(actor, actor
                                    .uniqueName(portName));
                            inner: for (Object connection : relation
                                    .linkedPortList()) {
                                if (connection instanceof TypedIOPort) {
                                    TypedIOPort testPort = (TypedIOPort) connection;
                                    if (testPort.getContainer().equals(_actor)) {
                                        if (testPort.isInput()) {
                                            port.setInput(true);
                                        }
                                        if (testPort.isOutput()) {
                                            port.setOutput(true);
                                        }
                                    } else {
                                        if (testPort.isInput()) {
                                            port.setOutput(true);
                                        }
                                        if (testPort.isOutput()) {
                                            port.setInput(true);
                                        }
                                    }
                                    break inner;
                                }
                            }
                        }
                        port.link(relation);
                    } else if (_getType(name).equals("transparent")) {
                        TypedIOPort port = (TypedIOPort) actor
                                .getPort(portName);
                        if (_transparentRelations.containsKey(name)) {
                            TypedIOPort connectionPoint = _transparentRelations
                                    .get(name);
                            String relationName = _actor.uniqueName("relation");
                            TypedIORelation rel = new TypedIORelation(_actor,
                                    relationName);
                            if (port == null) {
                                port = new TypedIOPort(actor, actor
                                        .uniqueName(portName));
                                inner: for (Object connection : rel
                                        .linkedPortList()) {
                                    if (connection instanceof TypedIOPort) {
                                        TypedIOPort testPort = (TypedIOPort) connection;
                                        if (testPort.getContainer().equals(
                                                _actor)) {
                                            if (testPort.isInput()) {
                                                port.setInput(true);
                                            }
                                            if (testPort.isOutput()) {
                                                port.setOutput(true);
                                            }
                                        } else {
                                            if (testPort.isInput()) {
                                                port.setOutput(true);
                                            }
                                            if (testPort.isOutput()) {
                                                port.setInput(true);
                                            }
                                        }
                                        break inner;
                                    }
                                }
                            }
                            port.link(rel);
                            connectionPoint.link(rel);
                        } else {
                            if (port == null) {
                                port = new TypedIOPort(actor, actor
                                        .uniqueName(portName));
                                port.setMultiport(true);
                                port.setInput(true);
                                port.setOutput(false);
                            }
                            _transparentRelations.put(name, port);
                        }
                    } else {
                        throw new PtalonRuntimeException(name
                                + " not a port or relation");
                    }
                }
                if (_danglingPortsOkay) {
                    return;
                }
                PtalonActor container = (PtalonActor) actor.getContainer();
                for (Object port : actor.portList()) {
                    if (port instanceof TypedIOPort) {
                        TypedIOPort ioport = (TypedIOPort) port;
                        if (ioport.numLinks() == 0) {
                            String name = container.uniqueName(actor.getName()
                                    + "_" + ioport.getName());
                            TypedIOPort newPort = new TypedIOPort(container,
                                    name);
                            String rel = container.uniqueName("relation");
                            TypedIORelation relation = new TypedIORelation(
                                    container, rel);
                            if (ioport.isMultiport()) {
                                relation.setWidth(ioport.getWidth());
                                newPort.setMultiport(true);
                                if (ioport.getWidth() == 0) {
                                    ioport.link(relation);
                                    newPort.link(relation);
                                } else {
View Full Code Here

        public void makeThisConnections() throws PtalonRuntimeException {
            try {
                for (String portName : _relations.keySet()) {
                    String relationName = _actor.getMappedName(_relations
                            .get(portName));
                    TypedIORelation relation = (TypedIORelation) _actor
                            .getRelation(relationName);
                    TypedIOPort port = (TypedIOPort) _actor.getPort(portName);
                    if (port == null) {
                        if (_transparentRelations.containsKey(portName)) {
                            port = _transparentRelations.get(portName);
                        } else {
                            throw new PtalonRuntimeException("No port named "
                                    + portName);
                        }
                    }
                    port.link(relation);
                }
                for (String portName : _transparencies.keySet()) {
                    TypedIOPort port = (TypedIOPort) _actor.getPort(portName);
                    String shortName = _transparencies.get(portName);
                    if (_transparentRelations.containsKey(shortName)) {
                        TypedIOPort connectionPoint = _transparentRelations
                                .get(shortName);
                        String relationName = _actor.uniqueName("relation");
                        TypedIORelation rel = new TypedIORelation(_actor,
                                relationName);
                        if (port == null) {
                            if (_transparentRelations.containsKey(portName)) {
                                port = _transparentRelations.get(portName);
                            } else {
                                throw new PtalonRuntimeException(
                                        "No port named " + portName);
                            }
                        }
                        port.link(rel);
                        connectionPoint.link(rel);
                    } else {
                        if (port == null) {
                            throw new PtalonRuntimeException("No port named "
                                    + portName);
                        }
                        _transparentRelations.put(shortName, port);
                    }
                }
                for (String portName : _ports.keySet()) {
                    TypedIOPort port = (TypedIOPort) _actor.getPort(portName);
                    String containerPortName = _actor.getMappedName(_ports
                            .get(portName));
                    TypedIOPort containerPort = (TypedIOPort) _actor
                            .getPort(containerPortName);
                    if (port == null) {
                        throw new PtalonRuntimeException("No port named "
                                + portName);
                    }
                    String relationName = _actor.uniqueName("relation");
                    TypedIORelation relation = new TypedIORelation(_actor,
                            relationName);
                    port.link(relation);
                    containerPort.link(relation);
                }
                for (String portName : _unknownPrefixes.keySet()) {
                    String suffix = evaluateString(_unknownExpressions
                            .get(portName));
                    if (suffix == null) {
                        throw new PtalonRuntimeException(
                                "Not able to evaluate suffix "
                                        + _unknownExpressions.get(portName));
                    }
                    String name = _unknownPrefixes.get(portName) + suffix;
                    if (_getType(name).endsWith("port")) {
                        TypedIOPort port = (TypedIOPort) _actor
                                .getPort(portName);
                        String containerPortName = _actor.getMappedName(name);
                        TypedIOPort containerPort = (TypedIOPort) _actor
                                .getPort(containerPortName);
                        if (port == null) {
                            throw new PtalonRuntimeException("No port named "
                                    + portName);
                        }
                        String relationName = _actor.uniqueName("relation");
                        TypedIORelation relation = new TypedIORelation(_actor,
                                relationName);
                        port.link(relation);
                        containerPort.link(relation);
                    } else if (_getType(name).equals("relation")) {
                        String relationName = _actor.getMappedName(name);
                        TypedIORelation relation = (TypedIORelation) _actor
                                .getRelation(relationName);
                        TypedIOPort port = (TypedIOPort) _actor
                                .getPort(portName);
                        if (port == null) {
                            if (_transparentRelations.containsKey(portName)) {
                                port = _transparentRelations.get(portName);
                            } else {
                                throw new PtalonRuntimeException(
                                        "No port named " + portName);
                            }
                        }
                        port.link(relation);
                    } else if (_getType(name).equals("transparent")) {
                        TypedIOPort port = (TypedIOPort) _actor
                                .getPort(portName);
                        if (_transparentRelations.containsKey(name)) {
                            TypedIOPort connectionPoint = _transparentRelations
                                    .get(name);
                            String relationName = _actor.uniqueName("relation");
                            TypedIORelation rel = new TypedIORelation(_actor,
                                    relationName);
                            if (port == null) {
                                if (_transparentRelations.containsKey(portName)) {
                                    port = _transparentRelations.get(portName);
                                } else {
View Full Code Here

        myplot.plot.setYRange(-25.0, 25.0);
        myplot.plot.setSize(400, 400);
        myplot.plot.addLegend(0, "(x1, x2)");

        // CTConnections
        TypedIORelation x1 = new TypedIORelation(this, "X1");
        TypedIORelation x2 = new TypedIORelation(this, "X2");
        TypedIORelation x3 = new TypedIORelation(this, "X3");
        X1.output.link(x1);
        X2.output.link(x2);
        X3.output.link(x3);
        MINUS1.input.link(x1);
        MINUS2.input.link(x2);
View Full Code Here

TOP

Related Classes of ptolemy.actor.TypedIORelation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.