コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="rule"></param>
 /// <param name="preCondition">The precondition which setup the initial state</param>
 /// <param name="initialState">The initial stae of this transition</param>
 /// <param name="update">The statement which set up the target state</param>
 /// <param name="targetState">The target state of this transition</param>
 public Transition(PreCondition preCondition, State initialState, Interpreter.Statement.VariableUpdateStatement update, State targetState)
 {
     PreCondition = preCondition;
     InitialState = initialState;
     Update       = update;
     TargetState  = targetState;
 }
コード例 #2
0
        /// <summary>
        /// Indicates the name of the updated variable, if any
        /// </summary>
        /// <returns></returns>
        public string UpdatedVariable()
        {
            string retVal = null;

            Interpreter.Statement.VariableUpdateStatement update = Statement as Interpreter.Statement.VariableUpdateStatement;
            if (update != null)
            {
                retVal = update.VariableIdentification.ToString();
            }

            return(retVal);
        }
コード例 #3
0
        /// <summary>
        /// Provides the statement which modifies the variable
        /// </summary>
        /// <param name="variable"></param>
        /// <returns>null if no statement modifies the element</returns>
        public Interpreter.Statement.VariableUpdateStatement Modifies(Types.ITypedElement variable)
        {
            Interpreter.Statement.VariableUpdateStatement retVal = null;

            foreach (Action action in Actions)
            {
                retVal = action.Modifies(variable);
                if (retVal != null)
                {
                    return(retVal);
                }
            }

            return(retVal);
        }
コード例 #4
0
            /// <summary>
            /// Adds a transition in the transitions sets
            /// </summary>
            /// <param name="update">The update state which provides the target of the transition</param>
            /// <param name="target">The target state, as determined by the update statement</param>
            /// <param name="filteredOut"></param>
            /// <param name="preCondition">the precondition (if any) which is used to determine the initial state</param>
            /// <param name="initial">The initial state</param>
            /// <returns>true if the transition has been filtered out. A transition can be filtered out if the target state is equal to the initial state or the initial state is null
            /// </returns>
            private bool AddTransition(Interpreter.Statement.VariableUpdateStatement update, Constants.State target, Rules.PreCondition preCondition, Constants.State initial)
            {
                bool retVal = false;

                Constants.State initialState = StateMachine.StateInThisStateMachine(initial);
                // TargetState is the target state either in this state machine or in a sub state machine
                Constants.State targetState = StateMachine.StateInThisStateMachine(target);

                // Determine the rule condition (if any) related to this state machine
                Rules.RuleCondition condition = null;
                if (update != null)
                {
                    Rules.Action action = update.Root as Rules.Action;
                    condition = action.RuleCondition;
                }

                if (targetState != null || initialState != null)
                {
                    // This transition is about this state machine.
                    if (initialState != targetState && initialState != null)
                    {
                        // Check that the transition is not yet present
                        // This case can occur when the same RuleCondition references two different states
                        // in a substate machine. Only draws the transition once.
                        if (!findMatchingTransition(condition, initialState, targetState))
                        {
                            Transitions.Add(new Rules.Transition(preCondition, initialState, update, targetState));
                        }
                    }
                    else
                    {
                        if (initialState == initial)
                        {
                            retVal = true;
                        }
                    }
                }

                return(retVal);
            }