Package ptolemy.domains.fsm.kernel

Examples of ptolemy.domains.fsm.kernel.State


     *  state, or the prefire() method of refinements throw it, or the super
     class throws it.
     */
    public boolean prefire() throws IllegalActionException {
        FSMActor ctrl = getController();
        State currentState = ctrl.currentState();

        if (_debugging) {
            _debug(getName(), " find FSMActor " + ctrl.getName()
                    + " and the current state is " + currentState.getName());
        }

        Actor[] actors = currentState.getRefinement();
        _enabledRefinements = new LinkedList();

        if (actors != null) {
            for (int i = 0; i < actors.length; ++i) {
                _enabledRefinements.add(actors[i]);
View Full Code Here


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

    /** Initialize the model with a single state.
     */
    private void _init() throws IllegalActionException,
            NameDuplicationException {
        // Create the one and only state in the controller.
        _state = new State(_controller, "State");
        _controller.initialStateName.setExpression("State");
        // FIXME: The following doesn't give much info.
        // _controller.addDebugListener(this);
        // Make the controller transient (it is reconstructed
        // at construction time).
View Full Code Here

            if (_conservativeAnalysis) {
                // Conservative approximation
                Iterator states = controller.entityList(State.class).iterator();
                while (states.hasNext()) {
                    State state = (State) states.next();
                    Actor[] actors = state.getRefinement();
                    // If the modal model has no refinements, the modal model is
                    // basically an FSM actor. We use the function dependency of
                    // the controller instead.
                    if ((actors != null) && (actors.length > 0)) {
                        for (int i = 0; i < actors.length; ++i) {
View Full Code Here

            int numberOfStates = entity.entityList().size();

            // Figure out what state we are in.
            for (Iterator states = entity.entityList().iterator(); states
                    .hasNext();) {
                State state = (State) states.next();
                Stmt startStmt = Jimple.v().newNopStmt();

                stateToStartStmt.put(state, startStmt);
                stateStmtList.add(startStmt);
            }

            Local currentStateLocal = Jimple.v().newLocal("currentStateLocal",
                    IntType.v());
            body.getLocals().add(currentStateLocal);

            Local nextStateLocal = Jimple.v().newLocal("nextStateLocal",
                    IntType.v());
            body.getLocals().add(nextStateLocal);

            Local flagLocal = Jimple.v().newLocal("flagLocal", BooleanType.v());
            body.getLocals().add(flagLocal);

            Local transitionTakenLocal = Jimple.v().newLocal(
                    "transitionTakenLocal", BooleanType.v());
            body.getLocals().add(transitionTakenLocal);

            Local nextTransitionLocal = Jimple.v().newLocal(
                    "nextTransitionLocal", IntType.v());
            body.getLocals().add(nextTransitionLocal);

            units.add(Jimple.v().newAssignStmt(
                    currentStateLocal,
                    Jimple.v().newInstanceFieldRef(thisLocal,
                            currentStateField.makeRef())));

            // Start by doing nothing.
            units.add(Jimple.v().newAssignStmt(transitionTakenLocal,
                    IntConstant.v(0)));
            units.add(Jimple.v().newAssignStmt(nextTransitionLocal,
                    IntConstant.v(-1)));

            // If no transition is taken, then stay in this state.
            units.add(Jimple.v().newAssignStmt(nextStateLocal,
                    currentStateLocal));

            Stmt finishedStmt = Jimple.v().newNopStmt();
            Stmt errorStmt = Jimple.v().newNopStmt();

            // Get the current state.
            units.add(Jimple.v().newTableSwitchStmt(currentStateLocal, 0,
                    numberOfStates - 1, stateStmtList, errorStmt));

            // Generate code for each state.
            for (Iterator states = entity.entityList().iterator(); states
                    .hasNext();) {
                State state = (State) states.next();
                System.out.println("state " + state.getName());

                Stmt startStmt = (Stmt) stateToStartStmt.get(state);
                units.add(startStmt);

                // Fire the refinement actor.
                TypedActor[] refinements = null;

                try {
                    refinements = state.getRefinement();
                } catch (Exception ex) {
                    throw new RuntimeException(ex.getMessage());
                }

                if (refinements != null) {
View Full Code Here

        ptolemy.domains.fsm.kernel.MultirateFSMDirector director = (ptolemy.domains.fsm.kernel.MultirateFSMDirector) getComponent();
        ptolemy.domains.fsm.kernel.FSMActor controller = director
                .getController();
        //FSMActor controllerHelper = (FSMActor) _getHelper(controller);
        State initialState = controller.getInitialState();
        Actor[] actors = initialState.getRefinement();
        if (actors == null) { // no refinement for the initial state
            // We assume all transitions from the initial state are
            // nonpreemptive transitions.
            Iterator transitions = initialState.nonpreemptiveTransitionList()
                    .iterator();
            initializeCode.append(_generateInitialTransitionCode(transitions));
        } else {
            initializeCode.append(super.generateInitializeCode());
            _updateConfigurationNumber(initializeCode, initialState);
View Full Code Here

        // Find the number of configurations of the container actor, which is
        // the sum of numbers of configurations of all the refinements.
        Iterator states = controller.entityList().iterator();
        while (states.hasNext()) {
            State state = (State) states.next();
            TypedActor[] actors = state.getRefinement();
            if (actors != null) {
                CodeGeneratorHelper refinementHelper = (CodeGeneratorHelper) _getHelper((NamedObj) actors[0]);
                int[][] rates = refinementHelper.getRates();
                if (rates != null) {
                    numberOfConfigurationsOfContainer += rates.length;
                } else {
                    numberOfConfigurationsOfContainer += 1;
                }
            }
        }

        int[][] containerRates = new int[numberOfConfigurationsOfContainer][];

        states = controller.entityList().iterator();
        int configurationNumber = 0;
        while (states.hasNext()) {
            State state = (State) states.next();
            TypedActor[] actors = state.getRefinement();
            if (actors != null) {
                CodeGeneratorHelper refinementHelper = (CodeGeneratorHelper) _getHelper((NamedObj) actors[0]);
                int[][] rates = refinementHelper.getRates();
                if (rates != null) {
                    for (int i = 0; i < rates.length; i++) {
View Full Code Here

        for (int configurationNumber = 0; configurationNumber < rates.length; configurationNumber++) {

            // Find the state corresponding to the given configuration number.
            Iterator states = controller.entityList().iterator();
            int number = configurationNumber;
            State currentState = null;
            while (states.hasNext()) {
                State state = (State) states.next();
                Actor[] actors = state.getRefinement();
                if (actors != null) {
                    int[][] refinementRates = ((CodeGeneratorHelper) _getHelper((NamedObj) actors[0]))
                            .getRates();
                    if (refinementRates != null) {
                        number -= refinementRates.length;
View Full Code Here

            codeBuffer.append(super.generateInitializeCode());

            // Generate code for updating current state.
            // This overrides using initial state as the current state in
            // the initialize code of the controller.
            State destinationState = transition.destinationState();
            controllerHelper._updateCurrentState(codeBuffer, destinationState,
                    0);

            // Generate code for updating configuration number of this
            // FSMActor's container actor.
View Full Code Here

        TypedCompositeActor refinementHelper = (TypedCompositeActor) _getHelper((NamedObj) refinements[0]);
        Iterator states = controller.entityList().iterator();
        int tempSum = 0;

        while (states.hasNext()) {
            State nextState = (State) states.next();
            Actor[] actors = nextState.getRefinement();
            if (actors != null) {
                TypedCompositeActor helper = (TypedCompositeActor) _getHelper((NamedObj) actors[0]);
                int[][] rates = helper.getRates();

                if (nextState == state) {
View Full Code Here

TOP

Related Classes of ptolemy.domains.fsm.kernel.State

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.