Пример #1
0
        /// <summary>
        ///     Sets the update information for this rule condition (this rule condition updates source)
        /// </summary>
        /// <param name="source"></param>
        public override void SetUpdateInformation(ModelElement source)
        {
            base.SetUpdateInformation(source);
            RuleCondition sourceRuleCondition = (RuleCondition)source;

            foreach (Action action in Actions)
            {
                Action baseAction = sourceRuleCondition.FindAction(action.Name);
                if (baseAction != null)
                {
                    action.SetUpdateInformation(baseAction);
                }
            }

            foreach (PreCondition preCondition in PreConditions)
            {
                PreCondition basePreCondition = sourceRuleCondition.FindPreCondition(preCondition.Name);
                if (basePreCondition != null)
                {
                    preCondition.SetUpdateInformation(basePreCondition);
                }
            }

            foreach (Rule rule in SubRules)
            {
                Rule baseRule = sourceRuleCondition.FindRule(rule.Name);
                if (baseRule != null)
                {
                    rule.SetUpdateInformation(baseRule);
                }
            }
        }
 /// <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;
 }
 /// <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;
 }
Пример #4
0
        /// <summary>
        ///     Adds a model element in this model element
        /// </summary>
        /// <param name="copy"></param>
        public override void AddModelElement(IModelElement element)
        {
            {
                PreCondition item = element as PreCondition;
                if (item != null)
                {
                    appendPreConditions(item);
                }
            }
            {
                Action item = element as Action;
                if (item != null)
                {
                    appendActions(item);
                }
            }
            {
                Rule item = element as Rule;
                if (item != null)
                {
                    appendSubRules(item);
                }
            }

            base.AddModelElement(element);
        }
Пример #5
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <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, VariableUpdateStatement update,
                   State targetState)
 {
     PreCondition = preCondition;
     Source       = initialState;
     Update       = update;
     Target       = targetState;
 }
Пример #6
0
        public override PreCondition createPreCondition()
        {
            PreCondition retVal = new Rules.PreCondition();

            _defaultValueSetter.SetDefaultValue(retVal);

            return(retVal);
        }
Пример #7
0
        /// <summary>
        ///     Duplicates this model element
        /// </summary>
        /// <returns></returns>
        public PreCondition duplicate()
        {
            PreCondition retVal = (PreCondition)acceptor.getFactory().createPreCondition();

            retVal.Name           = Name;
            retVal.ExpressionText = ExpressionText;

            return(retVal);
        }
Пример #8
0
        /// <summary>
        ///     Creates a default element
        /// </summary>
        /// <param name="enclosingCollection"></param>
        /// <returns></returns>
        public static PreCondition CreateDefault(ICollection enclosingCollection)
        {
            PreCondition retVal = (PreCondition)acceptor.getFactory().createPreCondition();

            Util.DontNotify(() =>
            {
                retVal.Name      = "PreCondition" + GetElementNumber(enclosingCollection);
                retVal.Condition = "";
            });

            return(retVal);
        }
Пример #9
0
        /// <summary>
        /// Duplicates this model element
        /// </summary>
        /// <returns></returns>
        public RuleCondition duplicate()
        {
            RuleCondition retVal = (RuleCondition)Generated.acceptor.getFactory().createRuleCondition();

            retVal.Name = Name;
            foreach (PreCondition preCondition in PreConditions)
            {
                PreCondition newPreCondition = preCondition.duplicate();
                retVal.appendPreConditions(newPreCondition);
            }
            foreach (Action action in Actions)
            {
                Action newAction = action.duplicate();
                retVal.appendActions(newAction);
            }

            return(retVal);
        }
Пример #10
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(VariableUpdateStatement update, State target, PreCondition preCondition,
                                       State initial)
            {
                bool retVal = false;

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

                    // Determine the rule condition (if any) related to this state machine
                    Rules.RuleCondition condition = null;
                    if (update != null)
                    {
                        Action action = update.Root as 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 Transition(preCondition, initialState, update, targetState));
                            }
                        }
                        else
                        {
                            if (initialState == initial)
                            {
                                retVal = true;
                            }
                        }
                    }
                }

                return(retVal);
            }
        public override void visit(Generated.PreCondition obj, bool subNodes)
        {
            Rules.PreCondition preCondition = obj as Rules.PreCondition;

            if (preCondition != null)
            {
                try
                {
                    // Check whether the expression is valid
                    Interpreter.Expression expression = checkExpression(preCondition, preCondition.Condition);
                    if (!preCondition.Dictionary.EFSSystem.BoolType.Match(expression.GetExpressionType()))
                    {
                        preCondition.AddError("Expression type should be Boolean");
                    }

                    Types.ITypedElement element = OverallTypedElementFinder.INSTANCE.findByName(preCondition, preCondition.findVariable());
                    if (element != null)
                    {
                        if (element.Type is Types.StateMachine)
                        {
                            if (preCondition.findOperator() != null)
                            {
                                if (preCondition.findOperator().CompareTo("==") == 0)
                                {
                                    preCondition.AddWarning("Operator == should not be used for state machines");
                                }
                                else if (preCondition.findOperator().CompareTo("!=") == 0)
                                {
                                    preCondition.AddWarning("Operator != should not be used for state machines");
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    preCondition.AddException(exception);
                }
            }

            base.visit(obj, subNodes);
        }
            /// <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(VariableUpdateStatement update, State target, PreCondition preCondition,
                State initial)
            {
                bool retVal = false;

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

                    // Determine the rule condition (if any) related to this state machine
                    Rules.RuleCondition condition = null;
                    if (update != null)
                    {
                        Action action = update.Root as 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 Transition(preCondition, initialState, update, targetState));
                            }
                        }
                        else
                        {
                            if (initialState == initial)
                            {
                                retVal = true;
                            }
                        }
                    }
                }

                return retVal;
            }
Пример #13
0
        public override PreCondition createPreCondition()
        {
            PreCondition retVal = new Rules.PreCondition();

            _defaultValueSetter.SetDefaultValue(retVal);

            return retVal;
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="model"></param>
 public PreConditionModelControl(ModelDiagramPanel panel, PreCondition model)
     : base(panel, model)
 {
 }