예제 #1
0
파일: Activation.cs 프로젝트: samieze/aMuSE
 public Activation(State startState, AbstractEvent[] oldEventBuffer, AbstractEvent newBufferEvent)
 {
     currentState   = startState;
     eventBuffer    = new AbstractEvent[oldEventBuffer.Count() + 1];
     eventBuffer[0] = newBufferEvent;
     oldEventBuffer.CopyTo(eventBuffer, 1);
 }
        public override IEnumerable <ComplexEvent> processInputEvent(AbstractEvent e)
        {
            if (!activationsByInputEventType.ContainsKey(e.type))
            {
                return(Enumerable.Empty <ComplexEvent>());
            }

            List <ComplexEvent> outputEvents = new List <ComplexEvent>();

            foreach (var activation in activationsByInputEventType[e.type])
            {
                var(newactivations, outputeventcomponents) = activation.consumeEvent(e);

                if (newactivations != null)
                {
                    foreach (var newactivation in newactivations)
                    {
                        activationsByInputEventType[newactivation.currentState.requiredEventType].Add(newactivation);
                    }
                }

                if (outputeventcomponents != null)
                {
                    outputEvents.Add(new ComplexEvent(query.name, outputeventcomponents));
                }
            }

            return(outputEvents);
        }
예제 #3
0
        public bool testGuardConditions(AbstractEvent candidate, IEnumerable <AbstractEvent> eventBuffer)
        {
            if (!candidate.type.Equals(requiredEventType))
            {
                return(false);
            }

            if (eventBuffer == null)
            {
                eventBuffer = Enumerable.Empty <AbstractEvent>();
            }

            if (!PrimitiveBufferComponentAnyMatchConstraint.checkAll(pBCAnyMatchConstraints, candidate, eventBuffer))
            {
                return(false);
            }

            if (!PrimitiveBufferComponentAllMatchConstraint.checkAll(pBCAllMatchConstraints, candidate, eventBuffer))
            {
                return(false);
            }

            foreach (var item in bufferConstraints)
            {
                if (!item.check(candidate, eventBuffer))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #4
0
파일: Activation.cs 프로젝트: samieze/aMuSE
 /// returns potentially new activations or the a complete event buffer to generate the output event from
 public (IEnumerable <Activation>, IEnumerable <AbstractEvent>) consumeEvent(AbstractEvent e)
 {
     if (currentState.testGuardConditions(e, eventBuffer))
     {
         if (currentState.nextStates == null)
         {
             // no next states exist, returning the complete buffer to then create the output event
             var bufferlistoutput = new List <AbstractEvent>(eventBuffer);
             bufferlistoutput.Add(e);
             return(null, bufferlistoutput);
         }
         else
         {
             var outputActivations = currentState.nextStates.Select((state) => new Activation(state, eventBuffer, e));
             return(outputActivations, null);
         }
     }
     else
     {
         return(null, null);
     }
 }
예제 #5
0
파일: Activation.cs 프로젝트: samieze/aMuSE
 public Activation(State startState, AbstractEvent firstEvent)
 {
     currentState = startState;
     eventBuffer  = new AbstractEvent[] { firstEvent };
 }
예제 #6
0
파일: Activation.cs 프로젝트: samieze/aMuSE
 public Activation(State startState)
 {
     currentState = startState;
     eventBuffer  = new AbstractEvent[0];
 }