/// <summary> /// Read the datapoints from the location file. /// </summary> /// <param name="file">The path to the data-file.</param> private void ReadDataPoints(string file) { // Identify data type _dataType = ParseHeatDataType(file); // Init data _dataPoints = new List <HeatDatapoint>(); if (_config.InitialBotPositions != null) { // Only use the initial bot positions _dataPoints.AddRange(_config.InitialBotPositions.Where(t => t.Item1 == _tier.GetInfoID()) .Select(t => new LocationDatapoint() { Tier = _tier.GetInfoID(), TimeStamp = 0, X = t.Item2, Y = t.Item3 })); } else { // Read data using (StreamReader sr = new StreamReader(file)) { string line = ""; while ((line = sr.ReadLine()) != null) { line = line.Trim(); // Skip empty and comment lines if (line.StartsWith(IOConstants.COMMENT_LINE) || string.IsNullOrWhiteSpace(line)) { continue; } // Parse data switch (_dataType) { case HeatDataType.PolledLocation: { LocationDatapoint datapoint = LocationDatapoint.FromCSV(line); // Only add datapoint, if it belongs to the set of task types that shall be considered if (_config.BotTaskFilter.Contains(datapoint.BotTask)) { // Only add datapoint, if it belongs to the set time window (if a window is specified) if (_config.DataTimeFilterLow == _config.DataTimeFilterHigh || _config.DataTimeFilterLow <= datapoint.TimeStamp && datapoint.TimeStamp < _config.DataTimeFilterHigh) { // The datapoint made it through all filters - add it _dataPoints.Add(datapoint); } } } break; case HeatDataType.TimeIndependentTripData: { _dataPoints.Add(TimeIndependentTripDataPoint.FromCSV(line)); } break; case HeatDataType.StorageLocationInfo: { StorageLocationInfoDatapoint datapoint = StorageLocationInfoDatapoint.FromCSV(line); // Only add datapoint, if it belongs to the set time window (if a window is specified) if (_config.DataTimeFilterLow == _config.DataTimeFilterHigh || _config.DataTimeFilterLow <= datapoint.TimeStamp && datapoint.TimeStamp < _config.DataTimeFilterHigh) { // The datapoint made it through all filters - add it _dataPoints.Add(datapoint); } } break; default: throw new ArgumentException("Unknown data type: " + _dataType.ToString()); } } } } // Remark success if (_dataPoints.Any()) { _anyData = true; } else { _anyData = false; } }