/// <summary> /// Constructs the actual automaton, and specify its properties. /// </summary> /// <returns>The AFA descriptor.</returns> public AfaDescriptor <StockTick, Register> CreateDescriptor() { AfaDescriptor <StockTick, Register> afaDescriptor = new AfaDescriptor <StockTick, Register>(); // Specify the start and final states afaDescriptor.StartState = 0; afaDescriptor.AddFinalState(2); // Specify the arcs in the automaton. See AFAexample.pptx // for a visualization of this automaton. // // If we see a downtick in the start state 0, we make // two transitions: one stays in state 0 and the other // progresses the automaton to state 1. In both cases, // the counter is incremented by 1. afaDescriptor.AddArc(0, 0, Transition0); afaDescriptor.AddArc(0, 1, Transition0); // If we see an uptick, and the counter is greater than // 1, we decrement the counter and stay in the same state // (state 1) because the pattern has not yet been found afaDescriptor.AddArc(1, 1, Transition1); // If we see an uptick, and the counter is equal to 1, we // decrement the counter (so it becomes 0) and move to state 2, // which is a final state and produces a pattern match output afaDescriptor.AddArc(1, 2, Transition2); // Specify the default (initial) register content afaDescriptor.DefaultRegister = new Register { Counter = 0 }; // This AFA does not see CTI events, and hence CtiVisibility is set to false. // If CtiVisibility is true, CTIs will be seen by arcs (transition functions). // In the latter case, the transition functions above will need to be modified // to check the kind of an incoming event before processing it. afaDescriptor.CtiVisibility = false; // This AFA allows a new pattern matching instance to start at every new event, // and hence AllowOverlappingInstances is set to true. // If AllowOverlappingInstances is instead set to false, an incoming event will // not start a new pattern matching instance unless: // (1) there are no ongoing (in-progress) matches, or // (2) all ongoing matches end due to the current incoming event. afaDescriptor.AllowOverlappingInstances = true; return(afaDescriptor); }
public AfaDescriptor <StockTick, RegisterType> CreateDescriptor() { AfaDescriptor <StockTick, RegisterType> afaDescriptor = new AfaDescriptor <StockTick, RegisterType>(); // Specify the start and final states afaDescriptor.StartState = 0; afaDescriptor.AddFinalState(2); // Specify the arcs in the automaton. See AFAexample.pptx // for a visualization of this automaton. // // If we see a downtick in the start state 0, we make // two transitions: one stays in state 0 and the other // progresses the automaton to state 1. In both cases, // the counter is incremented by 1. afaDescriptor.AddArc(0, 0, Transition0); afaDescriptor.AddArc(0, 1, Transition0); // If we see an uptick, and the counter is greater than // 1, we decrement the counter and stay in the same state // (state 1) because the pattern has not yet been found afaDescriptor.AddArc(1, 1, Transition1); // If we see an uptick, and the counter is equal to 1, we // decrement the counter (so it becomes 0) and move to state 2, // which is a final state and produces a pattern match output afaDescriptor.AddArc(1, 2, Transition2); // Specify the default (initial) register content afaDescriptor.DefaultRegister = new RegisterType { Counter = 0 }; return(afaDescriptor); }