def _query_channel_data(self, source_ref, channels, combined_channel_data): Logger.info('CachingAnalysisDatastore: querying {} {}'.format( source_ref, channels)) lap = source_ref.lap session = source_ref.session f = Filter().eq('CurrentLap', lap) dataset = self.query(sessions=[session], channels=channels, data_filter=f) records = dataset.fetch_records() for index in range(len(channels)): channel = channels[index] values = [] for record in records: # pluck out just the channel value values.append(record[1 + index]) channel_meta = self.get_channel(channel) channel_data = ChannelData(values=values, channel=channel, min=channel_meta.min, max=channel_meta.max, source=source_ref) combined_channel_data[channel] = channel_data
def _get_location_data(self, params): ''' Retrieve cached or query Location data as appropriate. ''' source_ref = params.source_ref source_key = str(source_ref) cache = self._session_location_cache.get(source_key) if cache == None: session = source_ref.session lap = source_ref.lap f = Filter().neq('Latitude', 0).and_().neq('Longitude', 0).eq("CurrentLap", lap) dataset = self.query(sessions=[session], channels=["Latitude", "Longitude"], data_filter=f) records = dataset.fetch_records() cache = [] for r in records: lat = r[1] lon = r[2] cache.append(GeoPoint.fromPoint(lat, lon)) self._session_location_cache[source_key] = cache Clock.schedule_once(lambda dt: params.callback(cache))
def _get_location_data(self, source_ref, callback): ''' Retrieve cached or query Location data as appropriate. ''' session = source_ref.session lap = source_ref.lap f = Filter().neq('Latitude', 0).and_().neq('Longitude', 0) if self.session_has_laps(session): f.eq("CurrentLap", lap) dataset = self.query(sessions=[session], channels=["Latitude", "Longitude"], data_filter=f) records = dataset.fetch_records() cache = [] for r in records: lat = r[1] lon = r[2] cache.append(GeoPoint.fromPoint(lat, lon)) self._session_location_cache[str(source_ref)] = cache Clock.schedule_once(lambda dt: callback(cache))
def refresh_session_list(self): try: self.clear_sessions() sessions = self.datastore.get_sessions() f = Filter().gt('CurrentLap', 0) session = None for session in sessions: session = self.append_session(session_id=session.session_id, name=session.name, notes=session.notes) laps = self.datastore.get_laps(session.session_id) if len(laps) == 0: session.append_label('No Laps') else: for lap in laps: self.append_lap(session, lap.lap, lap.lap_time) self.sessions = sessions self.ids.session_alert.text = '' if session else 'No Sessions' except Exception as e: Logger.error('AnalysisView: unable to fetch laps: {}\n\{}'.format( e, traceback.format_exc()))