Package ptolemy.actor.lib

Examples of ptolemy.actor.lib.Scale


            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    // We don't create the Scale if the corresponding element
                    // in the A matrix is 0.
                    feedback[i][j] = new Scale(this, "feedback_" + i + "_" + j);
                    feedback[i][j].factor.setExpression("A(" + i + ", " + j
                            + ")");
                    feedback[i][j].input.link(states[j]);
                    connect(feedback[i][j].output, stateAdders[i].plus);
                }
            }

            // Inputs
            Scale[][] inputScales = new Scale[n][m];
            IORelation[] inputs = new IORelation[m];

            for (int j = 0; j < m; j++) {
                inputs[j] = new TypedIORelation(this, "relation_input_" + j);
                input.link(inputs[j]);

                // Create input scales.
                for (int i = 0; i < n; i++) {
                    // We create a scale for each input even if the
                    // corresponding element in B is 0. Otherwise,
                    // if the elements of A's in this row are also zero,
                    // then we will have an illegal topology.
                    inputScales[i][j] = new Scale(this, "b_" + i + "_" + j);
                    inputScales[i][j].factor.setExpression("B(" + i + ", " + j
                            + ")");
                    inputScales[i][j].input.link(inputs[j]);
                    connect(inputScales[i][j].output, stateAdders[i].plus);
                }
            }

            // Outputs
            AddSubtract[] outputAdders = new AddSubtract[r];
            Scale[][] outputScales = new Scale[r][n];

            for (int l = 0; l < r; l++) {
                outputAdders[l] = new AddSubtract(this, "outputAdder" + l);
                connect(outputAdders[l].output, output);

                // Create the output scales only if the corresponding
                // 'c' element is not 0.
                for (int i = 0; i < n; i++) {
                    outputScales[l][i] = new Scale(this, "outputScale_" + l
                            + "_" + i);
                    outputScales[l][i].factor.setExpression("C(" + l + ", " + i
                            + ")");
                    outputScales[l][i].input.link(states[i]);
                    connect(outputScales[l][i].output, outputAdders[l].plus);
                }
            }

            // Direct feed through.
            Scale[][] feedThrough = new Scale[r][m];

            for (int l = 0; l < r; l++) {
                for (int j = 0; j < m; j++) {
                    // Create the scale only if the element is not 0.
                    feedThrough[l][j] = new Scale(this, "feedThrough_" + l
                            + "_" + j);
                    feedThrough[l][j].factor.setExpression("D(" + l + ", " + j
                            + ")");
                    feedThrough[l][j].input.link(inputs[j]);
                    connect(feedThrough[l][j].output, outputAdders[l].plus);
View Full Code Here


            if (n == 1) {
                // Algebraic system
                if (a[0] == b[0]) {
                    connect(input, output);
                } else {
                    Scale scaleD = new Scale(this, "ScaleD");
                    scaleD.factor.setToken(new DoubleToken(b[0] / a[0]));
                    connect(input, scaleD.input);
                    connect(output, scaleD.output);
                }
            } else {
                double d = b[0] / a[0];
                int order = n - 1;
                AddSubtract inputAdder = new AddSubtract(this, "InputAdder");
                AddSubtract outputAdder = new AddSubtract(this, "OutputAdder");
                Integrator[] integrators = new Integrator[order];
                IORelation[] nodes = new IORelation[order];
                Scale[] feedback = new Scale[order];
                Scale[] feedforward = new Scale[order];

                for (int i = 0; i < order; i++) {
                    // The integrator names are d0x, d1x, etc.
                    integrators[i] = new Integrator(this, "Integrator" + i);
                    feedback[i] = new Scale(this, "Feedback" + i);
                    feedback[i].factor.setToken(new DoubleToken(-a[i + 1]
                            / a[0]));
                    feedforward[i] = new Scale(this, "Feedforward" + i);
                    feedforward[i].factor.setToken(new DoubleToken(
                            (b[i + 1] - (d * a[i + 1])) / a[0]));

                    // connections
                    nodes[i] = (IORelation) connect(integrators[i].output,
                            feedforward[i].input, "node" + i);
                    feedback[i].input.link(nodes[i]);
                    connect(feedback[i].output, inputAdder.plus);
                    connect(feedforward[i].output, outputAdder.plus);

                    if (i >= 1) {
                        integrators[i].input.link(nodes[i - 1]);
                    }
                }

                connect(inputAdder.output, integrators[0].input);

                IORelation inputRelation = (IORelation) connect(input,
                        inputAdder.plus, "inputRelation");
                connect(output, outputAdder.output, "outputRelation");

                if (d != 0) {
                    Scale scaleD = new Scale(this, "ScaleD");
                    scaleD.factor.setToken(new DoubleToken(d));
                    scaleD.input.link(inputRelation);
                    connect(scaleD.output, outputAdder.plus);
                }
            }
View Full Code Here

        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);
View Full Code Here

        // Create the actors.
        Const LAMBDA = new Const(this, "LAMBDA");
        LAMBDA.value.setExpression("lambda");

        Scale SIGMA = new Scale(this, "SIGMA");
        SIGMA.factor.setExpression("sigma");

        Scale B = new Scale(this, "B");
        B.factor.setExpression("b");

        AddSubtract ADD1 = new AddSubtract(this, "Add1");
        AddSubtract ADD2 = new AddSubtract(this, "Add2");
        AddSubtract ADD3 = new AddSubtract(this, "Add3");
        AddSubtract ADD4 = new AddSubtract(this, "Add4");

        MultiplyDivide MULT1 = new MultiplyDivide(this, "MULT1");
        MultiplyDivide MULT2 = new MultiplyDivide(this, "MULT2");

        Integrator X1 = new Integrator(this, "IntegratorX1");
        Integrator X2 = new Integrator(this, "IntegratorX2");
        Integrator X3 = new Integrator(this, "IntegratorX3");

        Scale MINUS1 = new Scale(this, "MINUS1");
        Scale MINUS2 = new Scale(this, "MINUS2");
        Scale MINUS3 = new Scale(this, "MINUS3");

        XYPlotter myplot = new XYPlotter(this, "CTXYPlot");
        myplot.plot = new Plot();
        myplot.plot.setGrid(true);
        myplot.plot.setXRange(-25.0, 25.0);
View Full Code Here

        ZeroOrderHold hold = new ZeroOrderHold(ctsub, "Hold");
        AddSubtract add1 = new AddSubtract(ctsub, "Add1");

        Integrator intgl1 = new Integrator(ctsub, "Integrator1");
        Integrator intgl2 = new Integrator(ctsub, "Integrator2");
        Scale scale0 = new Scale(ctsub, "Scale0");
        Scale scale1 = new Scale(ctsub, "Scale1");
        Scale scale2 = new Scale(ctsub, "Scale2");
        Scale scale3 = new Scale(ctsub, "Scale3");
        Scale scale4 = new Scale(ctsub, "Scale4");
        scale4.factor.setExpression("feedbackGain");

        TimedPlotter ctPlot = new TimedPlotter(ctsub, "CTPlot");
        ctPlot.plot = new Plot();
        ctPlot.plot.setGrid(true);
View Full Code Here

        Integrator DTm = new Integrator(this, "IntegratorDTm");
        Integrator DDTm = new Integrator(this, "IntegratorDDTm");

        Integrator A = new Integrator(this, "IntegratorA");

        Scale MINUS = new Scale(this, "MINUS");

        //CTPlot ctPlot = new CTPlot(this, "CTPlot", ctPanel);
        XYPlotter xzPlot = new XYPlotter(this, "Helicopter Position");
        xzPlot.plot = new Plot();
        xzPlot.plot.setTitle("Helicopter Position");
View Full Code Here

TOP

Related Classes of ptolemy.actor.lib.Scale

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.