public bool IsEvent(EventPatternKey EventPatternKey)
        {
            if (!EventPatterns.ContainsKey(EventPatternKey))
            {
                throw new ApplicationException("Incorrect event passed.");
            }

            EventPattern pattern = EventPatterns[EventPatternKey];

            string stateString = String.Empty;

            switch (pattern.StateType)
            {
            case StateType.Position:
                stateString = this.PositionStates;
                break;

            case StateType.Range:
                stateString = this.RangeStates;
                break;

            default:
                throw new ApplicationException("Incorrect state type.");
            }

            if (stateString.Length == this.LastMatchedLengths[pattern.EventType])
            {
                return(false);
            }

            return(pattern.Pattern.IsMatch(stateString));
        }
示例#2
0
        public List <BarrierEventObject> GetAllEvents(StudyValue StudyValue, int BarNumber)
        {
            List <BarrierEventObject> events = new List <BarrierEventObject>();

            foreach (BarrierHistory history in this.Histories.Values)
            {
                EventType[] eventTypes = (EventType[])Enum.GetValues(typeof(EventType));
                foreach (EventType eventType in eventTypes)
                {
                    if (eventType != EventType.NotSet)
                    {
                        Direction[] directions = (Direction[])Enum.GetValues(typeof(Direction));
                        foreach (Direction direction in directions)
                        {
                            EventPatternKey key = new EventPatternKey(eventType, direction);
                            if ((direction != Direction.NotSet) && (direction != Direction.Unknown))
                            {
                                BarrierEventObject evnt = GetEvent(key, history.Barrier, StudyValue, BarNumber);
                                if (evnt != null)
                                {
                                    events.Add(evnt);
                                }
                            }
                        }
                    }
                }
            }

            return(events);
        }
        private Dictionary <EventType, int> GetNextMatchedLengths()
        {
            Dictionary <EventType, int> nextMatchedLengths = new Dictionary <EventType, int>();

            int positionLength = this.PositionStates.Length;
            int rangeLength    = this.RangeStates.Length;

            EventType[] eventTypes = (EventType[])Enum.GetValues(typeof(EventType));
            foreach (EventType type in eventTypes)
            {
                if (type != EventType.NotSet)
                {
                    bool isPositionMatchedLength = false;
                    bool isRangedMatchedLength   = false;

                    Direction[] directions = (Direction[])Enum.GetValues(typeof(Direction));
                    foreach (Direction direction in directions)
                    {
                        if ((direction != Direction.NotSet) && (direction != Direction.Unknown))
                        {
                            EventPatternKey key       = new EventPatternKey(type, direction);
                            StateType       stateType = EventPatterns[key].StateType;

                            if (IsEvent(key))
                            {
                                if (stateType == StateType.Position)
                                {
                                    isPositionMatchedLength = true;
                                }
                                else
                                {
                                    isRangedMatchedLength = true;
                                }
                            }
                        }
                    }

                    if ((!isPositionMatchedLength) && (!isRangedMatchedLength))
                    {
                        nextMatchedLengths.Add(type, this.LastMatchedLengths[type]);
                    }
                    else if (isPositionMatchedLength)
                    {
                        nextMatchedLengths.Add(type, positionLength);
                    }
                    else if (isRangedMatchedLength)
                    {
                        nextMatchedLengths.Add(type, rangeLength);
                    }
                }
            }

            return(nextMatchedLengths);
        }
示例#4
0
 private BarrierEventObject GetEvent(
     EventPatternKey EventPatternKey,
     IBarrierValue Barrier,
     StudyValue StudyValue,
     int BarNumber)
 {
     if (this.Histories[Barrier.BarrierUniqueKey].IsEvent(EventPatternKey))
     {
         return(new BarrierEventObject(EventPatternKey.EventType, EventPatternKey.Direction, Barrier, StudyValue, BarNumber));
     }
     else
     {
         return(null);
     }
 }