/// <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
        public override State createState()
        {
            State retVal = new Constants.State();

            _defaultValueSetter.SetDefaultValue(retVal);

            return(retVal);
        }
        /// <summary>
        /// Setups the combo boxes according to the state machine and (optionally start and end states)
        /// </summary>
        /// <param name="stateMachine"></param>
        /// <param name="initialState"></param>
        /// <param name="endState"></param>
        public void SetStateMachine(StateMachine stateMachine, State initialState = null, State endState = null)
        {
            startStatesComboBox.Items.Clear();
            endStatesComboBox.Items.Clear();
            foreach (State state in stateMachine.States)
            {
                startStatesComboBox.Items.Add(state.Name);
                endStatesComboBox.Items.Add(state.Name);
            }

            if (initialState != null)
            {
                startStatesComboBox.Text = initialState.Name;
            }

            if (endState != null)
            {
                endStatesComboBox.Text = endState.Name;
            }
        }
        /// <summary>
        /// Provides the state control which corresponds to the state provided
        /// </summary>
        /// <param name="state"></param>
        /// <returns></returns>
        public StateControl getStateControl(State state)
        {
            StateControl retVal = null;

            if (state != null)
            {
                if (states.ContainsKey(state))
                {
                    retVal = states[state];
                }
            }

            return retVal;
        }
 public StandardValuesCollection GetValues(State State)
 {
     return GetValues(State.StateMachine);
 }
 /// <summary>
 /// Updates (if possible) the target state of this transition
 /// </summary>
 /// <param name="targetState"></param>
 public void SetTargetState(State targetState)
 {
     if (Action != null)
     {
         Action.Expression = "THIS <- " + targetState.LiteralName;
     }
     TargetState = targetState;
 }
        /// <summary>
        /// Updates (if possible) the initial state for this transition
        /// </summary>
        /// <param name="initialState"></param>
        public void SetInitialState(State initialState)
        {
            if (Action != null)
            {
                if (PreCondition != null)
                {
                    if (PreCondition.Rule == Action.Rule)
                    {
                        List<State> states = DataDictionary.Types.StateMachine.GetStates(PreCondition.ExpressionTree);
                        if (states.Count == 1)
                        {
                            PreCondition.ExpressionText = "THIS == " + initialState.FullName;
                            InitialState = initialState;
                        }
                        else
                        {
                            throw new CannotChangeRuleException("More than one state in the pre condition expression");
                        }
                    }
                    else
                    {
                        throw new CannotChangeRuleException("Precondition is not at the same level as the action");
                    }
                }
                else
                {
                    RuleCondition ruleCondition = Action.Enclosing as RuleCondition;
                    Rule rule = ruleCondition.EnclosingRule;

                    if (Utils.EnclosingFinder<Constants.State>.find(rule) == InitialState)
                    {
                        if (rule.RuleConditions.Count == 1)
                        {
                            InitialState.StateMachine.removeRules(rule);
                            InitialState = initialState;
                            InitialState.StateMachine.appendRules(rule);
                        }
                        else
                        {
                            rule.removeConditions(ruleCondition);
                            InitialState = initialState;
                            Rule newRule = (Rule)Generated.acceptor.getFactory().createRule();
                            newRule.Name = rule.Name;
                            newRule.appendConditions(ruleCondition);
                            InitialState.StateMachine.appendRules(newRule);
                        }
                    }
                    else
                    {
                        throw new CannotChangeRuleException("Action is not defined directly in the state");
                    }
                }
            }
            InitialState = initialState;
        }
        public override State createState()
        {
            State retVal = new Constants.State();

            _defaultValueSetter.SetDefaultValue(retVal);

            return retVal;
        }