def calculate_metric_data(metric_name, mode, series): # return data, min, max, mean, std data = None min = None max = None mean = None std = None if mode == MetricResult.SNAP: data = series[-1] # take last element from series for data and stamp min = data max = data mean = data.data std = 0.0 elif mode == MetricResult.SPAN_MEAN: min = get_min(series) max = get_max(series) mean = get_mean(series) std = get_std(series) data = DataStamped() data.data = mean # take mean for data data.stamp = series[ -1].stamp # take stamp from last element in series for stamp elif mode == MetricResult.SPAN_MIN: min = get_min(series) max = get_max(series) mean = get_mean(series) std = get_std(series) data = min elif mode == MetricResult.SPAN_ABSMIN: min = get_absmin(series) max = get_absmax(series) mean = get_mean(series) std = get_std(series) data = min elif mode == MetricResult.SPAN_MAX: min = get_min(series) max = get_max(series) mean = get_mean(series) std = get_std(series) data = max elif mode == MetricResult.SPAN_ABSMAX: min = get_absmin(series) max = get_absmax(series) mean = get_mean(series) std = get_std(series) data = max else: # invalid mode raise ATFAnalyserError( "Analysing failed, invalid mode '%s' for metric '%s'." % (mode, metric_name)) res = [data, min, max, mean, std] # verify that all field are set if None in res: ATFAnalyserError("Analysing failed, invalid data for metric '%s'." % (metric_name)) return res
def update(self, topic, msg, t): # get data if testblock is active if self.status.status == TestblockStatus.ACTIVE: if topic == self.topic: ds = DataStamped() ds.stamp = t ds.data = self.get_data(msg) self.series.append(ds)
def update(self, topic, msg, t): # get data if testblock is active if self.status.status == TestblockStatus.ACTIVE: if topic == "/atf/api" and msg.testblock_name == self.testblock_name: api_dict = self.msg_to_dict(msg) interface_data, self.interface_details = self.calculate_data_and_details( api_dict) data = DataStamped() data.stamp = t data.data = interface_data self.series.append(data) # FIXME handle fixed rates
def update(self, topic, msg, t): # make sure we're handling a TFMessage (from /tf or /tf_static) # TODO check type instead of topic names if topic in self.topics: for transform in msg.transforms: self.t.setTransform(transform) # get data if testblock is active if self.status.status == TestblockStatus.ACTIVE: raw_data = self.get_data(t) if raw_data == None: return data = DataStamped() data.stamp = t data.data = round(raw_data, 6) self.series.append(data) # FIXME handle fixed rates
def calculate_publish_rate(self, stamp): data = DataStamped() data.stamp = stamp data.data = round(self.counter / (data.stamp - self.start_time).to_sec(),6) self.series.append(data) # FIXME handle fixed rates
def stop(self, status): self.status = status data = DataStamped() data.stamp = status.stamp data.data = round((data.stamp - self.start_time).to_sec(), 6) self.series.append(data) # FIXME handle fixed rates