Package ptolemy.domains.ct.kernel

Examples of ptolemy.domains.ct.kernel.CTCompositeActor


        //newPlot.addLegend(1, "Trigger");
        newPlot.setXRange(0.0, 5.0);
        newPlot.setYRange(0.0, 0.2);
        newPlot.setSize(500, 300);

        CTCompositeActor hs = new CTCompositeActor(this, "HS");

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

        //TypedIOPort hsout = (TypedIOPort)hs.newPort("output");
        //hsout.setOutput(true);
        //hsout.setTypeEquals(BaseType.DOUBLE);
        TypedIOPort hsst = (TypedIOPort) hs.newPort("state");
        hsst.setOutput(true);
        hsst.setTypeEquals(BaseType.DOUBLE);

        //TypedIOPort hstr = (TypedIOPort)hs.newPort("trig");
        //hstr.setOutput(true);
        //hstr.setTypeEquals(BaseType.DOUBLE);
        FSMActor ctrl = new FSMActor(hs, "Controller");

        //ctrl.addDebugListener(dbl);
        State ctrlInc = new State(ctrl, "Increasing");
        State ctrlDec = new State(ctrl, "Decreasing");
        ctrl.initialStateName.setExpression("Increasing");

        Transition ctrlTr1 = new Transition(ctrl, "ctrlTr1");
        ctrlInc.outgoingPort.link(ctrlTr1);
        ctrlDec.incomingPort.link(ctrlTr1);
        ctrlTr1.setGuardExpression("output_isPresent");
        ctrlTr1.setActions
                .setExpression("Decreasing.Integrator.initialState = state");
        ctrlTr1.reset.setExpression("true");

        Transition ctrlTr2 = new Transition(ctrl, "ctrlTr2");
        ctrlDec.outgoingPort.link(ctrlTr2);
        ctrlInc.incomingPort.link(ctrlTr2);
        ctrlTr2.setGuardExpression("output_isPresent");
        ctrlTr2.setActions
                .setExpression("Increasing.Integrator.initialState = state");
        ctrlTr2.reset.setExpression("true");

        IOPort ctrlIn = new TypedIOPort(ctrl, "output");
        ctrlIn.setInput(true);

        IOPort ctrlSt = new TypedIOPort(ctrl, "state");
        ctrlSt.setInput(true);

        // the hybrid system director
        HSFSMDirector hsdir = new HSFSMDirector(hs, "HSFSMDirector");

        //hs.setDirector(hsdir);
        hsdir.controllerName.setExpression("Controller");

        //hsdir.addDebugListener(dbl);
        CTCompositeActor ctInc = new CTCompositeActor(hs, "Increasing");

        //ZeroOrderHold ctIncH = new ZeroOrderHold(ctInc, "Hold");
        Integrator ctIncI = new Integrator(ctInc, "Integrator");

        //ctIncI.addDebugListener(dbl);
        ZeroCrossingDetector ctIncD = new ZeroCrossingDetector(ctInc, "ZD");

        //ctIncD.addDebugListener(dbl);
        Expression ctIncGF = new Expression(ctInc, "EXPRESSION");

        TypedIOPort ctIncGFi = (TypedIOPort) ctIncGF.newPort("in");
        ctIncGFi.setInput(true);
        ctIncGFi.setTypeEquals(BaseType.DOUBLE);
        ctIncGF.output.setTypeEquals(BaseType.DOUBLE);
        ctIncGF.expression.setExpression("in - 0.2");

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

        TypedIOPort ctIncOut = (TypedIOPort) ctInc.newPort("output");
        ctIncOut.setOutput(true);
        ctIncOut.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctIncSt = (TypedIOPort) ctInc.newPort("state");
        ctIncSt.setOutput(true);
        ctIncSt.setTypeEquals(BaseType.DOUBLE);

        TypedIOPort ctIncTr = (TypedIOPort) ctInc.newPort("trig");
        ctIncTr.setOutput(true);
        ctIncTr.setTypeEquals(BaseType.DOUBLE);

        // connect ctInc
        //ctInc.connect(ctIncIn, ctIncH.input);
        //ctInc.connect(ctIncH.output, ctIncI.input);
        ctInc.connect(ctIncIn, ctIncI.input);

        Relation ctIncR2 = ctInc.newRelation("R2");
        ctIncGF.output.link(ctIncR2);
        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);
View Full Code Here


        //dir.addDebugListener(new StreamListener());
        // ---------------------------------
        // Create the controller actors.
        // ---------------------------------
        CTCompositeActor sub = new CTCompositeActor(this, "Controllers");
        HSFSMDirector hsdir = new HSFSMDirector(sub, "HSFSMDirector");

        TypedIOPort subinPx = new TypedIOPort(sub, "inputPx");
        subinPx.setInput(true);
        subinPx.setOutput(false);

        TypedIOPort subinDPx = new TypedIOPort(sub, "inputDPx");
        subinDPx.setInput(true);
        subinDPx.setOutput(false);

        TypedIOPort subinDDPx = new TypedIOPort(sub, "inputDDPx");
        subinDDPx.setInput(true);
        subinDDPx.setOutput(false);

        TypedIOPort subinD3Px = new TypedIOPort(sub, "inputD3Px");
        subinD3Px.setInput(true);
        subinD3Px.setOutput(false);

        TypedIOPort subinD4Px = new TypedIOPort(sub, "inputD4Px");
        subinD4Px.setInput(true);
        subinD4Px.setOutput(false);

        TypedIOPort subinPz = new TypedIOPort(sub, "inputPz");
        subinPz.setInput(true);
        subinPz.setOutput(false);

        TypedIOPort subinDPz = new TypedIOPort(sub, "inputDPz");
        subinDPz.setInput(true);
        subinDPz.setOutput(false);

        TypedIOPort subinDDPz = new TypedIOPort(sub, "inputDDPz");
        subinDDPz.setInput(true);
        subinDDPz.setOutput(false);

        TypedIOPort subinD3Pz = new TypedIOPort(sub, "inputD3Pz");
        subinD3Pz.setInput(true);
        subinD3Pz.setOutput(false);

        TypedIOPort subinD4Pz = new TypedIOPort(sub, "inputD4Pz");
        subinD4Pz.setInput(true);
        subinD4Pz.setOutput(false);

        TypedIOPort subinAction = new TypedIOPort(sub, "inputAction");
        subinAction.setInput(true);
        subinAction.setOutput(false);

        TypedIOPort suboutVx = new TypedIOPort(sub, "outputVx");
        suboutVx.setInput(false);
        suboutVx.setOutput(true);

        TypedIOPort suboutVz = new TypedIOPort(sub, "outputVz");
        suboutVz.setInput(false);
        suboutVz.setOutput(true);

        FSMActor hsctrl = new FSMActor(sub, "HSController");
        hsdir.controllerName.setExpression("HSController");

        TypedIOPort hscInAct = new TypedIOPort(hsctrl, "inputAction");
        hscInAct.setInput(true);
        hscInAct.setOutput(false);

        TypedIOPort hscInPz = new TypedIOPort(hsctrl, "inputPz");
        hscInPz.setInput(true);
        hscInPz.setOutput(false);

        TypedIOPort hscInV = new TypedIOPort(hsctrl, "outputV");
        hscInV.setInput(true);
        hscInV.setOutput(false);

        TypedIOPort hscInR = new TypedIOPort(hsctrl, "outputR");
        hscInR.setInput(true);
        hscInR.setOutput(false);

        State hoverState = new State(hsctrl, "HoverState");
        State accelState = new State(hsctrl, "AccelState");
        State cruise1State = new State(hsctrl, "Cruise1State");
        State climbState = new State(hsctrl, "ClimbState");
        State cruise2State = new State(hsctrl, "Cruise2State");
        hsctrl.initialStateName.setExpression("HoverState");

        /* CTCompositeActor linHover = */_createLinearizer(sub, 0);

        /* CTCompositeActor linAccel = */_createLinearizer(sub, 1);

        /* CTCompositeActor linCruise1 = */_createLinearizer(sub, 2);

        /* CTCompositeActor linClimb = */_createLinearizer(sub, 3);

        /* CTCompositeActor linCruise2 = */_createLinearizer(sub, 4);
        hoverState.refinementName.setExpression("HoverCTSub");
        accelState.refinementName.setExpression("AccelCTSub");
        cruise1State.refinementName.setExpression("Cruise1CTSub");
        climbState.refinementName.setExpression("ClimbCTSub");
        cruise2State.refinementName.setExpression("Cruise2CTSub");

        Transition tr1 = new Transition(hsctrl, "tr1");
        hoverState.outgoingPort.link(tr1);
        accelState.incomingPort.link(tr1);
        tr1.setGuardExpression("inputAction");

        Transition tr2 = new Transition(hsctrl, "tr2");
        accelState.outgoingPort.link(tr2);
        cruise1State.incomingPort.link(tr2);
        tr2.setGuardExpression("(outputV >= 5.0) && (inputPz > -2.05) "
                + "&& (inputPz < -1.95)");

        Transition tr3 = new Transition(hsctrl, "tr3");
        cruise1State.outgoingPort.link(tr3);
        climbState.incomingPort.link(tr3);
        tr3.setGuardExpression("(outputV > 4.9) && (outputV < 5.1) "
                + "&& (outputR > -0.01) && (outputR < 0.01)");

        Transition tr4 = new Transition(hsctrl, "tr4");
        climbState.outgoingPort.link(tr4);
        cruise2State.incomingPort.link(tr4);

        //
        tr4.setGuardExpression("(outputV > 4.9) && (outputV < 5.1) "
                + "&& (inputPz > -10.05) && (inputPz < -9.95)");

        TypedIORelation rSubPx = new TypedIORelation(sub, "rSubPx");
        TypedIORelation rSubDPx = new TypedIORelation(sub, "rSubDPx");
        TypedIORelation rSubDDPx = new TypedIORelation(sub, "rSubDDPx");
        TypedIORelation rSubD3Px = new TypedIORelation(sub, "rSubD3Px");
        TypedIORelation rSubD4Px = new TypedIORelation(sub, "rSubD4Px");
        TypedIORelation rSubPz = new TypedIORelation(sub, "rSubPz");
        TypedIORelation rSubDPz = new TypedIORelation(sub, "rSubDPz");
        TypedIORelation rSubDDPz = new TypedIORelation(sub, "rSubDDPz");
        TypedIORelation rSubD3Pz = new TypedIORelation(sub, "rSubD3Pz");
        TypedIORelation rSubD4Pz = new TypedIORelation(sub, "rSubD4Pz");
        TypedIORelation rSubOutVx = new TypedIORelation(sub, "rSubOutVx");
        TypedIORelation rSubOutVz = new TypedIORelation(sub, "rSubOutVz");
        TypedIORelation rSubOutV = new TypedIORelation(sub, "rSubOutV");
        TypedIORelation rSubOutR = new TypedIORelation(sub, "rSubOutR");

        subinPx.link(rSubPx);
        subinDPx.link(rSubDPx);
        subinDDPx.link(rSubDDPx);
        subinD3Px.link(rSubD3Px);
        subinD4Px.link(rSubD4Px);
        subinPz.link(rSubPz);
        subinDPz.link(rSubDPz);
        subinDDPz.link(rSubDDPz);
        subinD3Pz.link(rSubD3Pz);
        subinD4Pz.link(rSubD4Pz);
        suboutVx.link(rSubOutVx);
        suboutVz.link(rSubOutVz);

        sub.connect(subinAction, hscInAct);

        //hscInPz.link(rSubPz);
        //hscInV.link(rSubOutV);
        //hscInR.link(rSubOutR);
        Iterator entities = sub.entityList().iterator();

        while (entities.hasNext()) {
            Entity ent = (Entity) entities.next();
            Port p = ent.getPort("inputPx");

            if (p != null) {
                p.link(rSubPx);
            }

            p = ent.getPort("inputDPx");

            if (p != null) {
                p.link(rSubDPx);
            }

            p = ent.getPort("inputDDPx");

            if (p != null) {
                p.link(rSubDDPx);
            }

            p = ent.getPort("inputD3Px");

            if (p != null) {
                p.link(rSubD3Px);
            }

            p = ent.getPort("inputD4Px");

            if (p != null) {
                p.link(rSubD4Px);
            }

            p = ent.getPort("inputPz");

            if (p != null) {
                p.link(rSubPz);
            }

            p = ent.getPort("inputDPz");

            if (p != null) {
                p.link(rSubDPz);
            }

            p = ent.getPort("inputDDPz");

            if (p != null) {
                p.link(rSubDDPz);
            }

            p = ent.getPort("inputD3Pz");

            if (p != null) {
                p.link(rSubD3Pz);
            }

            p = ent.getPort("inputD4Pz");

            if (p != null) {
                p.link(rSubD4Pz);
            }

            p = ent.getPort("outputVx");

            if (p != null) {
                p.link(rSubOutVx);
            }

            p = ent.getPort("outputVz");

            if (p != null) {
                p.link(rSubOutVz);
            }

            p = ent.getPort("outputV");

            if (p != null) {
                p.link(rSubOutV);
            }

            p = ent.getPort("outputR");

            if (p != null) {
                p.link(rSubOutR);
            }
        }

        // CTActors
        Clock clock = new Clock(this, "Clock");
        clock.period.setToken(new DoubleToken(1e308));
        clock.offsets.setExpression("{0.0, 20.0}");
        clock.values.setExpression("{false, true}");
        connect(clock.output, subinAction);

        HelicopterActor heli = new HelicopterActor(this, "Helicopter");
        ControllerActor ctrl = new ControllerActor(this, "Controller");
        XZHigherDerivatives higher = new XZHigherDerivatives(this,
                "XZHigherDerivatives");

        Integrator Px = new Integrator(this, "IntegratorPx");
        Integrator DPx = new Integrator(this, "IntegratorDPx");

        Integrator Pz = new Integrator(this, "IntegratorPz");
        Integrator DPz = new Integrator(this, "IntegratorDPz");

        Integrator Th = new Integrator(this, "IntegratorTh");
        Integrator DTh = new Integrator(this, "IntegratorDTh");

        Integrator Tm = new Integrator(this, "IntegratorTm");
        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");
        xzPlot.plot.setButtons(false);
        xzPlot.plot.setGrid(true);
        xzPlot.plot.setXRange(-1.0, 100.0);
        xzPlot.plot.setYRange(1.0, 12.0);
        xzPlot.plot.setSize(200, 200);
        xzPlot.plot.addLegend(0, "x, z");

        TimedPlotter vxPlot = new TimedPlotter(this, "Horizontal Speed");
        vxPlot.plot = new Plot();
        vxPlot.plot.setTitle("Horizontal Speed");
        vxPlot.plot.setButtons(false);
        vxPlot.plot.setGrid(true);
        vxPlot.plot.setXRange(0.0, 70.0);
        vxPlot.plot.setYRange(0.0, 6.0);
        vxPlot.plot.setSize(200, 200);
        vxPlot.plot.addLegend(0, "Vx");

        TimedPlotter pzPlot = new TimedPlotter(this, "Vertical Position");
        pzPlot.plot = new Plot();
        pzPlot.plot.setTitle("Vertical Position");
        pzPlot.plot.setButtons(false);
        pzPlot.plot.setGrid(true);
        pzPlot.plot.setXRange(0.0, 70.0);
        pzPlot.plot.setYRange(0.0, 12.0);
        pzPlot.plot.setSize(200, 200);
        pzPlot.plot.addLegend(0, "Pz");

        TimedPlotter thPlot = new TimedPlotter(this, "Pitch Angle");
        thPlot.plot = new Plot();
        thPlot.plot.setTitle("Pitch Angle");
        thPlot.plot.setButtons(false);
        thPlot.plot.setGrid(true);
        thPlot.plot.setXRange(0.0, 70.0);
        thPlot.plot.setYRange(-0.05, 0.05);
        thPlot.plot.setSize(200, 200);
        thPlot.plot.addLegend(0, "Th");

        // CTConnections
        TypedIORelation rPx = new TypedIORelation(this, "rPx");
        TypedIORelation rDPx = new TypedIORelation(this, "rDPx");
        TypedIORelation rDDPx = new TypedIORelation(this, "rDDPx");
        TypedIORelation rD3Px = new TypedIORelation(this, "rD3Px");
        TypedIORelation rD4Px = new TypedIORelation(this, "rD4Px");

        TypedIORelation rPz = new TypedIORelation(this, "rPz");
        TypedIORelation rDPz = new TypedIORelation(this, "rDPz");
        TypedIORelation rDDPz = new TypedIORelation(this, "rDDPz");
        TypedIORelation rD3Pz = new TypedIORelation(this, "rD3Pz");
        TypedIORelation rD4Pz = new TypedIORelation(this, "rD4Pz");

        TypedIORelation rTh = new TypedIORelation(this, "rTh");
        TypedIORelation rDTh = new TypedIORelation(this, "rDTh");
        TypedIORelation rDDTh = new TypedIORelation(this, "rDDTh");

        TypedIORelation rTm = new TypedIORelation(this, "rTm");
        TypedIORelation rDTm = new TypedIORelation(this, "rDTm");
        TypedIORelation rDDTm = new TypedIORelation(this, "rDDTm");

        TypedIORelation rA = new TypedIORelation(this, "rA");
        TypedIORelation rVx = new TypedIORelation(this, "rVx");
        TypedIORelation rVz = new TypedIORelation(this, "rVz");

        sub.getPort("outputVx").link(rVx);
        sub.getPort("outputVz").link(rVz);
        sub.getPort("inputPx").link(rPx);
        sub.getPort("inputDPx").link(rDPx);
        sub.getPort("inputDDPx").link(rDDPx);
        sub.getPort("inputD3Px").link(rD3Px);
        sub.getPort("inputD4Px").link(rD4Px);

        sub.getPort("inputPz").link(rPz);
        sub.getPort("inputDPz").link(rDPz);
        sub.getPort("inputDDPz").link(rDDPz);
        sub.getPort("inputD3Pz").link(rD3Pz);
        sub.getPort("inputD4Pz").link(rD4Pz);

        Px.output.link(rPx);
        DPx.output.link(rDPx);
        heli.outputDDPx.link(rDDPx);
        higher.outputD3Px.link(rD3Px);
View Full Code Here

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////
    CTCompositeActor _createLinearizer(TypedCompositeActor container, int code)
            throws NameDuplicationException, IllegalActionException {
        CTCompositeActor sub = new CTCompositeActor(container, "dummy");
        CTEmbeddedDirector subdir = new CTEmbeddedDirector(sub,
                "CTInnerDirector");

        TypedIOPort subinPx = new TypedIOPort(sub, "inputPx");
        subinPx.setInput(true);
        subinPx.setOutput(false);

        TypedIOPort subinDPx = new TypedIOPort(sub, "inputDPx");
        subinDPx.setInput(true);
        subinDPx.setOutput(false);

        TypedIOPort subinDDPx = new TypedIOPort(sub, "inputDDPx");
        subinDDPx.setInput(true);
        subinDDPx.setOutput(false);

        TypedIOPort subinD3Px = new TypedIOPort(sub, "inputD3Px");
        subinD3Px.setInput(true);
        subinD3Px.setOutput(false);

        TypedIOPort subinD4Px = new TypedIOPort(sub, "inputD4Px");
        subinD4Px.setInput(true);
        subinD4Px.setOutput(false);

        TypedIOPort subinPz = new TypedIOPort(sub, "inputPz");
        subinPz.setInput(true);
        subinPz.setOutput(false);

        TypedIOPort subinDPz = new TypedIOPort(sub, "inputDPz");
        subinDPz.setInput(true);
        subinDPz.setOutput(false);

        TypedIOPort subinDDPz = new TypedIOPort(sub, "inputDDPz");
        subinDDPz.setInput(true);
        subinDDPz.setOutput(false);

        TypedIOPort subinD3Pz = new TypedIOPort(sub, "inputD3Pz");
        subinD3Pz.setInput(true);
        subinD3Pz.setOutput(false);

        TypedIOPort subinD4Pz = new TypedIOPort(sub, "inputD4Pz");
        subinD4Pz.setInput(true);
        subinD4Pz.setOutput(false);

        TypedIOPort suboutVx = new TypedIOPort(sub, "outputVx");
        suboutVx.setInput(false);
        suboutVx.setOutput(true);

        TypedIOPort suboutVz = new TypedIOPort(sub, "outputVz");
        suboutVz.setInput(false);
        suboutVz.setOutput(true);

        TypedIOPort suboutV = new TypedIOPort(sub, "outputV");
        suboutV.setInput(false);
        suboutV.setOutput(true);

        TypedIOPort suboutR = new TypedIOPort(sub, "outputR");
        suboutR.setInput(false);
        suboutR.setOutput(true);

        // ---------------------------------
        // Create the actors.
        // ---------------------------------
        TypedAtomicActor lin = null;
        ThresholdMonitor mon1 = null;
        ThresholdMonitor mon2 = null;

        switch (code) {
        case 0: // hover state
            sub.setName("HoverCTSub");
            lin = new HoverLinearizer(sub, "Hover");
            break;

        case 1: // acc state
            sub.setName("AccelCTSub");
            lin = new AccelerLinearizer(sub, "Accel");
            mon1 = new ThresholdMonitor(sub, "Mon1");
            break;

        case 2: // first cruise state
            sub.setName("Cruise1CTSub");
            lin = new CruiseLinearizer(sub, "Cruise1");
            mon1 = new ThresholdMonitor(sub, "Mon1");
            mon2 = new ThresholdMonitor(sub, "Mon2");
            break;

        case 3: // climb state
            sub.setName("ClimbCTSub");
            lin = new ClimbLinearizer(sub, "Climb");
            mon1 = new ThresholdMonitor(sub, "Mon1");
            mon2 = new ThresholdMonitor(sub, "Mon2");
            break;

        case 4: // second cruise state
            sub.setName("Cruise2CTSub");
            lin = new CruiseLinearizer(sub, "Cruise2");

            Parameter param = (Parameter) lin.getAttribute("CPz");
            param.setToken(new DoubleToken(-10.0));
            param = (Parameter) lin.getAttribute("CVx");
            param.setToken(new DoubleToken(5.0));
            break;

        default:
            break;
        }

        /*
         ZeroOrderHold hPx = new ZeroOrderHold(sub, "HPx");
         ZeroOrderHold hDPx = new ZeroOrderHold(sub, "HDPx");
         ZeroOrderHold hDDPx = new ZeroOrderHold(sub, "HDDPx");
         ZeroOrderHold hD3Px = new ZeroOrderHold(sub, "HD3Px");
         ZeroOrderHold hD4Px = new ZeroOrderHold(sub, "HD4Px");
         ZeroOrderHold hPz = new ZeroOrderHold(sub, "HPz");
         ZeroOrderHold hDPz = new ZeroOrderHold(sub, "HDPz");
         ZeroOrderHold hDDPz = new ZeroOrderHold(sub, "HDDPz");
         ZeroOrderHold hD3Pz = new ZeroOrderHold(sub, "HD3Pz");
         ZeroOrderHold hD4Pz = new ZeroOrderHold(sub, "HD4Pz");

         sub.connect(hPx.input, subinPx);
         sub.connect(hDPx.input, subinDPx);
         sub.connect(hDDPx.input, subinDDPx);
         sub.connect(hD3Px.input, subinD3Px);
         sub.connect(hD4Px.input, subinD4Px);

         Relation rInPz = sub.connect(hPz.input, subinPz);
         sub.connect(hDPz.input, subinDPz);
         sub.connect(hDDPz.input, subinDDPz);
         sub.connect(hD3Pz.input, subinD3Pz);
         sub.connect(hD4Pz.input, subinD4Pz);

         sub.connect(hPx.output, (ComponentPort)lin.getPort("inputPx"));
         sub.connect(hDPx.output, (ComponentPort)lin.getPort("inputDPx"));
         sub.connect(hDDPx.output, (ComponentPort)lin.getPort("inputDDPx"));
         sub.connect(hD3Px.output, (ComponentPort)lin.getPort("inputD3Px"));
         sub.connect(hD4Px.output, (ComponentPort)lin.getPort("inputD4Px"));

         sub.connect(hPz.output, (ComponentPort)lin.getPort("inputPz"));
         sub.connect(hDPz.output, (ComponentPort)lin.getPort("inputDPz"));
         sub.connect(hDDPz.output, (ComponentPort)lin.getPort("inputDDPz"));
         sub.connect(hD3Pz.output, (ComponentPort)lin.getPort("inputD3Pz"));
         sub.connect(hD4Pz.output, (ComponentPort)lin.getPort("inputD4Pz"));
         */
        sub.connect(subinPx, (ComponentPort) lin.getPort("inputPx"));
        sub.connect(subinDPx, (ComponentPort) lin.getPort("inputDPx"));
        sub.connect(subinDDPx, (ComponentPort) lin.getPort("inputDDPx"));
        sub.connect(subinD3Px, (ComponentPort) lin.getPort("inputD3Px"));
        sub.connect(subinD4Px, (ComponentPort) lin.getPort("inputD4Px"));

        Relation rInPz = sub.connect(subinPz, (ComponentPort) lin
                .getPort("inputPz"));

        //sub.connect(hPz.output, (ComponentPort)lin.getPort("inputPz"));
        sub.connect(subinDPz, (ComponentPort) lin.getPort("inputDPz"));
        sub.connect(subinDDPz, (ComponentPort) lin.getPort("inputDDPz"));
        sub.connect(subinD3Pz, (ComponentPort) lin.getPort("inputD3Pz"));
        sub.connect(subinD4Pz, (ComponentPort) lin.getPort("inputD4Pz"));

        sub.connect(suboutVx, (ComponentPort) lin.getPort("outputVx"));
        sub.connect(suboutVz, (ComponentPort) lin.getPort("outputVz"));

        Relation rV = sub.connect(suboutV, (ComponentPort) lin
                .getPort("outputV"));
        Relation rR = sub.connect(suboutR, (ComponentPort) lin
                .getPort("outputR"));

        // connect and set the monitors
        Parameter p = null;

View Full Code Here

TOP

Related Classes of ptolemy.domains.ct.kernel.CTCompositeActor

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.