public bool Process(IEvent e)
        {
            if (e is IntervalStepEvent)
            {
                if (start == -1)
                {
                    throw new Exception("ES registered start of interval before interval was started");
                }

                IntervalStepEvent interval = e as IntervalStepEvent;

                errors.Add(Math.Abs(start + period * interval.Step - interval.exactTicks));
            }
            else if (e is IntervalChangedEvent)
            {
                IntervalChangedEvent intervalChanged = e as IntervalChangedEvent;

                period = intervalChanged.NewInterval;
            }
            else if (e is IntervalStartedEvent)
            {
                IntervalStartedEvent intervalStarted = e as IntervalStartedEvent;

                start  = intervalStarted.TimeStarted;
                period = intervalStarted.Interval;
            }

            return(true); // Check all events
        }
Ejemplo n.º 2
0
        public void StartTimer(IntervalStartedEvent started, IntervalStepEvent lastStep, IntervalChangedEvent lastIntervalChange)
        {
            // Determine start time
            DateTime start = new DateTime(started.TimeStarted);

            // Determine interval
            TimeSpan intervalSpan;

            if (lastIntervalChange == null)
            {
                intervalSpan = new TimeSpan(started.Interval);
            }
            else
            {
                intervalSpan = new TimeSpan(lastIntervalChange.NewInterval);
            }

            // Determine curret step
            step = lastStep.Step;
            if (step > 0)
            {
                hasStarted = true;
            }

            StartTimer(start, intervalSpan);
        }