Ejemplo n.º 1
0
        public void Add(IElementaryTriggerCondition c)
        {
            var key = c.PostCondition.CacheKey;
            TriggerConditions existing;

            if (!_elements.TryGetValue(key, out existing))
            {
                _elements[key] = existing = new TriggerConditions();
            }

            existing.Compose(c);

            PreCondition = Gate.ComposeOR(PreCondition, c.PreCondition);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a guard to this collection.
        /// </summary>
        /// <param name="tg">The trigger guard to add.</param>
        public void AddGuard(IElementaryTriggerCondition c0, TriggerGuard tg)
        {
            var   name = tg.Guard.Name;
            Entry entry;

            if (!_map.TryGetValue(name, out entry))
            {
                _map[name] = entry = new Entry(tg.Guard);
            }

            // calculate effective conditions for the guard
            var c = new TriggerConditions(c0);

            switch (tg.Guard.Type)
            {
            case GuardType.LEAVE:
                c.PreCondition  = Gate.ComposeAND(c.PreCondition, tg.PreCondition);
                c.PostCondition = Gate.ComposeAND(c.PostCondition, tg.PostCondition);
                break;

            case GuardType.TRANSITION:
                c.PreCondition  = Gate.ComposeAND(c.PreCondition, tg.PreCondition);
                c.PostCondition = Gate.ComposeAND(c.PostCondition, tg.PostCondition);
                break;

            case GuardType.ENTER:
                c.PostCondition = Gate.ComposeAND(c.PostCondition, tg.PostCondition);
                break;

            default:
                throw new ArgumentException("invalid guard type.");
            }

            Log.TraceGuard(c.PreCondition, c.PostCondition, "before join");

            if (!TraceFlags.DisableTriggerJoin)
            {
                // express postconditions by preconditions
                c.JoinTrigger(tg.Trigger);
            }

            Log.TraceGuard(c.PreCondition, c.PostCondition, "add guard");

            // and add to entry
            entry.Add(c);
        }
Ejemplo n.º 3
0
 public void Compose(IElementaryTriggerCondition c)
 {
     PreCondition  = Gate.ComposeOR(PreCondition, c.PreCondition);
     PostCondition = Gate.ComposeOR(PostCondition, c.PostCondition);
 }
Ejemplo n.º 4
0
 public TriggerConditions(IElementaryTriggerCondition other)
 {
     PreCondition  = other.PreCondition;
     PostCondition = other.PostCondition;
 }
Ejemplo n.º 5
0
 public void Compose(IElementaryTriggerCondition c)
 {
     PreCondition = Gate.ComposeOR(PreCondition, c.PreCondition);
     PostCondition = Gate.ComposeOR(PostCondition, c.PostCondition);
 }
Ejemplo n.º 6
0
 public TriggerConditions(IElementaryTriggerCondition other)
 {
     PreCondition = other.PreCondition;
     PostCondition = other.PostCondition;
 }