Beispiel #1
0
        protected TransitionMonitor(TransitionSet tset, IGate pre, IGate post)
        {
            _transitions = tset;

            Name          = "internal";
            PreCondition  = pre;
            PostCondition = post;
        }
Beispiel #2
0
        public void CalculateEffects()
        {
            _tset = new TransitionSet();

            // overall precondition for the event
            var c = new TriggerTermCollection <bool>(true);

            foreach (var t in Triggers)
            {
                c.Add(t);

                // add to event wide transition set
                _tset.AddRange(t.Transitions);
            }

            var guards = new GuardCollection();
            var before = new EffectsCollection();
            var after  = new EffectsCollection();

            foreach (var t in Triggers)
            {
                foreach (var g in t.Guards)
                {
                    guards.AddGuard(t, g);
                }

                foreach (var effect in t.Effects)
                {
                    after.AddEffect(t, effect);
                }
            }

            guards.AddLeaveEffects(before);
            guards.AddEnterEffects(after);

            // make results visible
            EffectsBefore = before;
            EffectsAfter  = after;
            PreCondition  = c.PreCondition;
        }
Beispiel #3
0
        public TransitionSet GetTransitions(IGate c, bool post = false)
        {
            var tset   = new TransitionSet();
            var vclist = c.SelectAll(g => g is IVariableCondition).OfType <IVariableCondition>();

            foreach (var vc in vclist)
            {
                foreach (var x in GetTransitions(vc.Variable))
                {
                    if (!post)
                    {
                        // work on preconditions
                        if (x.PreStateIndexes.Contains(vc.StateIndex))
                        {
                            // transition matches variable condition
                            if (x.PreStateIndexes.Length > 1)
                            {
                                // reduce to simple transition
                                var y = new Transition(x.Parent);
                                y.PreStateIndexes = new int[] { vc.StateIndex };
                                y.NewStateIndexes = x.NewStateIndexes;
                                tset.Add(y);
                            }
                            else
                            {
                                tset.Add(x);
                            }
                        }
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
            }

            return(tset);
        }
Beispiel #4
0
 /// <summary>
 /// Creates a trigger based on another trigger, with new conditions.
 /// </summary>
 /// <param name="parent">The original trigger.</param>
 /// <param name="tset">The corresponding transition set.</param>
 /// <param name="pre">The precondition for the new trigger.</param>
 /// <param name="post">The postcondition for the new trigger.</param>
 internal ProductTrigger(Trigger parent, TransitionSet tset, IGate pre, IGate post)
     : base(parent, tset, pre, post)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Creates a trigger based on another trigger, with new conditions.
 /// </summary>
 /// <param name="parent">The original trigger.</param>
 /// <param name="tset">The corresponding transition set.</param>
 /// <param name="pre">The precondition for the new trigger.</param>
 /// <param name="post">The postcondition for the new trigger.</param>
 protected Trigger(Trigger parent, TransitionSet tset, IGate pre, IGate post)
     : base(tset, pre, post)
 {
     Event = parent.Event;
     AddEffects(parent.Effects);
 }
Beispiel #6
0
 /// <summary>
 /// Constructs a transition set from the variable conditions in a gate.
 /// </summary>
 /// <param name="g"></param>
 public TransitionSet(TransitionSet parent, IGate g)
 {
     AddRange(parent.GetTransitions(g));
 }