/** * Starts pulling line */ public void Init(PollerConfig config) { // Spawn threads to handle line requests SpawnLineHandlerThreads(config.MaxConcurrency); // Set timer to fetch lines at specific intervals FetchLines(config.LineNumbers); // fetch lines immediatly, otherwise we will wait for the first tick // which could take couple of seconds _linesFetchTimer = new System.Timers.Timer(config.PollIntervalSeconds * 1000); _linesFetchTimer.Elapsed += (sender, e) => FetchLines(config.LineNumbers); _linesFetchTimer.AutoReset = true; _linesFetchTimer.Enabled = true; _matcher.Init(config); }
/** * Init fetches for each bus line its stops intervals and * saves this data in memory */ public void Init(PollerConfig config) { foreach (var line in config.LineNumbers) { _tripsSequenceByLine[line] = 1; var stopsInterval = _provider.GetLineIntervals(line); _stopsIntervalByLineList[line] = stopsInterval; if (!_stopsIntervalByLineDictionary.ContainsKey(line)) { _stopsIntervalByLineDictionary[line] = new Dictionary <int, int>(); } foreach (var stop in stopsInterval) { _stopsIntervalByLineDictionary[line][stop.ToStopId] = stop.IntervalSeconds; } } SpawnHandlerThread(); }