Ejemplo n.º 1
0
        /// <summary>
        /// Adds an assertion rule to the state machine.
        /// </summary>
        /// <param name="assertion"></param>
        public void AddAssertion(ICondition assertion)
        {
            // mark all combination of states where the condition is not true

            /*var senum = new StateEnumerator(this);
             * foreach(var s in senum.GetStates(new InvertCondition(assertion)))
             * {
             *  GetState(s).Unallowed = true;
             * }*/

            _assertions.Add(assertion.Decompose(ConditionMode.Static));
        }
Ejemplo n.º 2
0
        public TransitionCondition(ICondition lcond, ICondition rcond)
        {
            if (lcond.ContainsTransitions() || rcond.ContainsTransitions())
            {
                throw new CompilerException(ErrorCode.BadCondition,
                                            "arguments to transition condition must not include transitions.");
            }

            // right hand must be a product
            var r = rcond.Decompose(ConditionMode.Static);

            if (r.Type == GateType.OR)
            {
                throw new CompilerException(ErrorCode.BadCondition,
                                            "right side of a transition must be a product.");
            }

            _rgate = r;

            var rvclist = r.GetVariableConditions().ToArray();

            var l = lcond.Decompose(ConditionMode.Static);

            // split left side into terms ...
            IEnumerable <IGate> terms = new[] { l };

            if (l.Type == GateType.OR)
            {
                terms = l.GetInputs();
            }

            // construct the transition set from the left side terms and the right side product.
            var tset = BuildTransitionSet(terms, rvclist);

            Left        = lcond;
            Right       = rcond;
            Transitions = tset;
        }
Ejemplo n.º 3
0
        public TransitionCondition(ICondition lcond, ICondition rcond)
        {
            if (lcond.ContainsTransitions() || rcond.ContainsTransitions())
            {
                throw new CompilerException(ErrorCode.BadCondition,
                    "arguments to transition condition must not include transitions.");
            }

            // right hand must be a product
            var r = rcond.Decompose(ConditionMode.Static);
            if(r.Type == GateType.OR)
            {
                throw new CompilerException(ErrorCode.BadCondition,
                    "right side of a transition must be a product.");
            }

            _rgate = r;

            var rvclist = r.GetVariableConditions().ToArray();

            var l = lcond.Decompose(ConditionMode.Static);

            // split left side into terms ...
            IEnumerable<IGate> terms = new[] { l };
            if(l.Type == GateType.OR)
            {
                terms = l.GetInputs();
            }

            // construct the transition set from the left side terms and the right side product.
            var tset = BuildTransitionSet(terms, rvclist);

            Left = lcond;
            Right = rcond;
            Transitions = tset;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds an assertion rule to the state machine.
        /// </summary>
        /// <param name="assertion"></param>
        public void AddAssertion(ICondition assertion)
        {
            // mark all combination of states where the condition is not true
            /*var senum = new StateEnumerator(this);
            foreach(var s in senum.GetStates(new InvertCondition(assertion)))
            {
                GetState(s).Unallowed = true;
            }*/

            _assertions.Add(assertion.Decompose(ConditionMode.Static));
        }
Ejemplo n.º 5
0
 public override IGate Decompose(ConditionMode mode)
 {
     return(Gate.Invert(_b.Decompose(mode)));
 }