def _add_channels_results_time(self, channels, query_data): try: time_data_values = query_data['Interval'] for channel in channels: chart = self.ids.chart channel_data_values = query_data[channel] channel_data = channel_data_values.values # If we queried a channel that has no sample results, skip adding the plot if len(channel_data) == 0 or channel_data[0] is None: continue key = channel_data_values.channel + str( channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] time_index = OrderedDict() sample_index = 0 time_data = time_data_values.values sample_count = len(time_data) interval = max(1, int(sample_count / self.MAX_SAMPLES_TO_DISPLAY)) Logger.info('LineChart: plot interval {}'.format(interval)) last_time = None time = 0 last_time = time_data[0] while sample_index < sample_count: current_time = time_data[sample_index] if last_time > current_time: Logger.warn( 'LineChart: interruption in interval channel, possible reset in data stream ({}->{})' .format(last_time, current_time)) last_time = current_time sample = channel_data[sample_index] time += current_time - last_time last_time = current_time points.append((time, sample)) time_index[time] = sample_index sample_index += interval channel_plot.chart_x_index = time_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max plot.points = points self._channel_plots[str(channel_plot)] = channel_plot # sync max chart x dimension self._update_max_chart_x() self._update_x_marker_value() finally: ProgressSpinner.decrement_refcount()
def _add_channels_results_time(self, channels, query_data): try: time_data_values = query_data['Interval'] for channel in channels: chart = self.ids.chart channel_data_values = query_data[channel] channel_data = channel_data_values.values # If we queried a channel that has no sample results, skip adding the plot if len(channel_data) == 0 or channel_data[0] is None: continue key = channel_data_values.channel + str(channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] time_index = OrderedDict() sample_index = 0 time_data = time_data_values.values sample_count = len(time_data) interval = max(1, int(sample_count / self.MAX_SAMPLES_TO_DISPLAY)) Logger.info('LineChart: plot interval {}'.format(interval)) last_time = None time = 0 last_time = time_data[0] while sample_index < sample_count: current_time = time_data[sample_index] if last_time > current_time: Logger.warn('LineChart: interruption in interval channel, possible reset in data stream ({}->{})'.format(last_time, current_time)) last_time = current_time sample = channel_data[sample_index] time += current_time - last_time last_time = current_time points.append((time, sample)) time_index[time] = sample_index sample_index += interval channel_plot.chart_x_index = time_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max plot.points = points self._channel_plots[str(channel_plot)] = channel_plot # sync max chart x dimension self._update_max_chart_x() self._update_x_marker_value() finally: ProgressSpinner.decrement_refcount()
def _add_channels_results_distance(self, channels, query_data): try: distance_data_values = query_data['Distance'] for channel in channels: chart = self.ids.chart channel_data_values = query_data[channel] key = channel_data_values.channel + str( channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] distance_index = OrderedDict() sample_index = 0 distance_data = distance_data_values.values channel_data = channel_data_values.values sample_count = len(distance_data) interval = max(1, int(sample_count / self.MAX_SAMPLES_TO_DISPLAY)) Logger.info('LineChart: plot interval {}'.format(interval)) while sample_index < sample_count: sample = channel_data[sample_index] distance = distance_data[sample_index] points.append((distance, sample)) distance_index[distance] = sample_index sample_index += interval channel_plot.chart_x_index = distance_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max plot.points = points self._channel_plots[str(channel_plot)] = channel_plot # sync max chart distances self._update_max_chart_x() self._update_x_marker_value() finally: ProgressSpinner.decrement_refcount()
def _add_channels_results_distance(self, channels, query_data): try: distance_data_values = query_data['Distance'] for channel in channels: chart = self.ids.chart channel_data_values = query_data[channel] key = channel_data_values.channel + str(channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] distance_index = OrderedDict() sample_index = 0 distance_data = distance_data_values.values channel_data = channel_data_values.values sample_count = len(distance_data) interval = max(1, int(sample_count / self.MAX_SAMPLES_TO_DISPLAY)) Logger.info('LineChart: plot interval {}'.format(interval)) while sample_index < sample_count: sample = channel_data[sample_index] distance = distance_data[sample_index] points.append((distance, sample)) distance_index[distance] = sample_index sample_index += interval channel_plot.chart_x_index = distance_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max plot.points = points self._channel_plots[str(channel_plot)] = channel_plot # sync max chart distances self._update_max_chart_x() self._update_x_marker_value() finally: ProgressSpinner.decrement_refcount()
def add_channel(self, channel, lap_ref): query_data = self.datastore.get_channel_data(lap_ref, ['Distance', channel]) chart = self.ids.chart channel_data_values = query_data[channel] distance_data_values = query_data['Distance'] key = channel_data_values.channel + str(channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] distance_index = OrderedDict() max_distance = chart.xmax sample_index = 0 distance_data = distance_data_values.data.values channel_data = channel_data_values.data.values for sample in channel_data: distance = distance_data[sample_index] if distance > max_distance: max_distance = distance points.append((distance, sample)) distance_index[distance] = sample_index sample_index += 1 channel_plot.distance_index = distance_index channel_plot.samples = sample_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max chart.xmin = 0 chart.xmax = max_distance plot.points = points self._channel_plots[str(channel_plot)] = channel_plot self.max_distance = max_distance self.current_distance = max_distance
def _add_channels_results(self, channels, query_data): try: distance_data_values = query_data['Distance'] for channel in channels: chart = self.ids.chart channel_data_values = query_data[channel] key = channel_data_values.channel + str(channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] distance_index = OrderedDict() sample_index = 0 distance_data = distance_data_values.values channel_data = channel_data_values.values for sample in channel_data: distance = distance_data[sample_index] points.append((distance, sample)) distance_index[distance] = sample_index sample_index += 1 channel_plot.distance_index = distance_index channel_plot.samples = sample_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max plot.points = points self._channel_plots[str(channel_plot)] = channel_plot #sync max chart distances self._update_max_distance() finally: ProgressSpinner.decrement_refcount()
def _add_channels_results(self, channels, query_data): try: distance_data_values = query_data['Distance'] for channel in channels: chart = self.ids.chart channel_data_values = query_data[channel] key = channel_data_values.channel + str( channel_data_values.source) plot = SmoothLinePlot(color=self.color_sequence.get_color(key)) channel_plot = ChannelPlot(plot, channel_data_values.channel, channel_data_values.min, channel_data_values.max, channel_data_values.source) chart.add_plot(plot) points = [] distance_index = OrderedDict() sample_index = 0 distance_data = distance_data_values.values channel_data = channel_data_values.values for sample in channel_data: distance = distance_data[sample_index] points.append((distance, sample)) distance_index[distance] = sample_index sample_index += 1 channel_plot.distance_index = distance_index channel_plot.samples = sample_index plot.ymin = channel_data_values.min plot.ymax = channel_data_values.max plot.points = points self._channel_plots[str(channel_plot)] = channel_plot #sync max chart distances self._update_max_distance() finally: ProgressSpinner.decrement_refcount()