private void addTransitionMenuItem_Click(object sender, EventArgs e)
        {
            if (StateMachine.States.Count > 1)
            {
                DataDictionary.ObjectFactory factory = (DataDictionary.ObjectFactory)DataDictionary.Generated.acceptor.getFactory();
                DataDictionary.Rules.Rule    rule    = (DataDictionary.Rules.Rule)factory.createRule();
                rule.Name = "Rule" + (StateMachine.Rules.Count + 1);

                DataDictionary.Rules.RuleCondition ruleCondition = (DataDictionary.Rules.RuleCondition)factory.createRuleCondition();
                ruleCondition.Name = "RuleCondition" + (rule.RuleConditions.Count + 1);
                rule.appendConditions(ruleCondition);

                DataDictionary.Rules.Action action = (DataDictionary.Rules.Action)factory.createAction();
                action.Expression = "THIS <- " + ((State)StateMachine.States[1]).LiteralName;
                ruleCondition.appendActions(action);

                if (MDIWindow.DataDictionaryWindow != null)
                {
                    DataDictionaryView.StateTreeNode stateNode = MDIWindow.DataDictionaryWindow.FindNode((State)StateMachine.States[0]) as DataDictionaryView.StateTreeNode;
                    DataDictionaryView.RuleTreeNode  ruleNode  = stateNode.Rules.AddRule(rule);
                }

                StateContainerPanel.RefreshControl();
                StateContainerPanel.Refresh();

                TransitionControl control = StateContainerPanel.getTransitionControl(ruleCondition);
                Select(control);
            }
        }
        /// <summary>
        /// Adds a new rule disabling in this dictionary
        /// </summary>
        /// <param name="rule"></param>
        public void AppendRuleDisabling(Rules.Rule rule)
        {
            Rules.RuleDisabling disabling = (Rules.RuleDisabling)Generated.acceptor.getFactory().createRuleDisabling();

            disabling.Name = rule.Name;
            disabling.setRule(rule.FullName);
            appendRuleDisablings(disabling);
        }
Esempio n. 3
0
        public override Rule createRule()
        {
            Rule retVal = new Rules.Rule();

            _defaultValueSetter.SetDefaultValue(retVal);

            return(retVal);
        }
Esempio n. 4
0
        /// <summary>
        /// Indicates whether a rule is disabled
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        public bool isDisabled(Rules.Rule rule)
        {
            bool retVal = false;

            foreach (Dictionary dictionary in Dictionaries)
            {
                retVal = dictionary.Disabled(rule);
                if (retVal)
                {
                    break;
                }
            }

            return(retVal);
        }
Esempio n. 5
0
        /// <summary>
        /// Finds a rule according to its full name
        /// </summary>
        /// <param name="fullName"></param>
        /// <returns></returns>
        public Rules.Rule findRule(string fullName)
        {
            Rules.Rule retVal = null;

            foreach (Dictionary dictionary in Dictionaries)
            {
                retVal = dictionary.findRule(fullName);
                if (retVal != null)
                {
                    break;
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Provides the rule according to its fullname
        /// </summary>
        /// <param name="fullName"></param>
        /// <returns></returns>
        public Rules.Rule findRule(string fullName)
        {
            Rules.Rule retVal = null;

            foreach (Rules.Rule rule in AllRules)
            {
                if (rule.FullName.CompareTo(fullName) == 0)
                {
                    retVal = rule;
                    break;
                }
            }

            return(retVal);
        }
Esempio n. 7
0
        /// <summary>
        ///     Adds a model element in this model element
        /// </summary>
        /// <param name="copy"></param>
        public override void AddModelElement(IModelElement element)
        {
            {
                State item = element as State;
                if (item != null)
                {
                    appendStates(item);
                }
            }
            {
                Rule item = element as Rule;
                if (item != null)
                {
                    appendRules(item);
                }
            }

            base.AddModelElement(element);
        }
Esempio n. 8
0
        /// <summary>
        ///     Instanciates this state machine for the instanciation of a StructureProcedure into a Procedure
        /// </summary>
        /// <returns></returns>
        public StateMachine instanciate()
        {
            StateMachine retVal = (StateMachine)acceptor.getFactory().createStateMachine();

            retVal.Name = Name;
            retVal.setFather(getFather());
            retVal.Default = Default;
            foreach (State state in States)
            {
                State newState = state.duplicate();
                retVal.appendStates(newState);
            }
            foreach (Rule rule in Rules)
            {
                Rule newRule = rule.duplicate();
                retVal.appendRules(newRule);
            }

            return(retVal);
        }
Esempio n. 9
0
        /// <summary>
        ///     Sets the update information for this state machine (this state machine updates source)
        /// </summary>
        /// <param name="source"></param>
        public override void SetUpdateInformation(ModelElement source)
        {
            base.SetUpdateInformation(source);
            StateMachine sourceStateMachine = (StateMachine)source;

            foreach (State state in States)
            {
                State baseState = sourceStateMachine.FindState(state.Name);
                if (baseState != null)
                {
                    state.SetUpdateInformation(baseState);
                }
            }

            foreach (Rule rule in Rules)
            {
                Rule baseRule = sourceStateMachine.FindRule(rule.Name);
                if (baseRule != null)
                {
                    rule.SetUpdateInformation(baseRule);
                }
            }
        }
Esempio n. 10
0
        public override Rule createRule()
        {
            Rule retVal = new Rules.Rule();

            _defaultValueSetter.SetDefaultValue(retVal);

            return retVal;
        }
        /// <summary>
        ///     Applies a rule defined in a procedure
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="changes"></param>
        /// <param name="ctxt"></param>
        /// <param name="explanation"></param>
        /// <param name="runner"></param>
        private void ApplyRule(Rule rule, ChangeList changes, InterpretationContext ctxt, ExplanationPart explanation,
            Runner runner)
        {
            foreach (RuleCondition condition in rule.RuleConditions)
            {
                ExplanationPart conditionExplanation = ExplanationPart.CreateSubExplanation(explanation, condition);

                if (condition.EvaluatePreConditions(ctxt, conditionExplanation, runner))
                {
                    ExplanationPart.SetNamable(conditionExplanation, EFSSystem.BoolType.True);
                    foreach (Action action in condition.Actions)
                    {
                        action.GetChanges(ctxt, changes, conditionExplanation, true, runner);
                    }

                    foreach (Rule subRule in condition.SubRules)
                    {
                        ApplyRule(subRule, changes, ctxt, conditionExplanation, runner);
                    }
                    break;
                }
                else
                {
                    ExplanationPart.SetNamable(conditionExplanation, EFSSystem.BoolType.False);
                }
            }
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="model"></param>
 public RuleModelControl(ModelDiagramPanel panel, Rule model)
     : base(panel, model)
 {
     BoxMode = BoxModeEnum.RoundedCorners;
     NormalColor = Color.LightBlue;
 }
        /// <summary>
        /// Indicates whether a rule is disabled in a dictionary
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        public bool Disabled(Rules.Rule rule)
        {
            bool retVal = CachedRuleDisablings.ContainsKey(rule);

            return(retVal);
        }