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); }
/// <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); }
public void Compose(IElementaryTriggerCondition c) { PreCondition = Gate.ComposeOR(PreCondition, c.PreCondition); PostCondition = Gate.ComposeOR(PostCondition, c.PostCondition); }
public TriggerConditions(IElementaryTriggerCondition other) { PreCondition = other.PreCondition; PostCondition = other.PostCondition; }
public void Compose(IElementaryTriggerCondition c) { PreCondition = Gate.ComposeOR(PreCondition, c.PreCondition); PostCondition = Gate.ComposeOR(PostCondition, c.PostCondition); }
public TriggerConditions(IElementaryTriggerCondition other) { PreCondition = other.PreCondition; PostCondition = other.PostCondition; }