|
32 | 32 | class MonitoredTopic:
|
33 | 33 | """Monitor for the statistics and status of a single topic."""
|
34 | 34 |
|
35 |
| - def __init__(self, topic_id, stale_time, lock=None): |
| 35 | + def __init__(self, topic_id, stale_time, lock): |
36 | 36 | self.expected_value = None
|
37 | 37 | self.expected_value_timer = None
|
38 | 38 | self.initial_value = None
|
39 |
| - self.lock = lock or Lock() |
| 39 | + self.lock = lock |
40 | 40 | self.received_values = []
|
41 | 41 | self.reception_rate_over_time = []
|
42 | 42 | self.stale_time = stale_time
|
@@ -128,7 +128,6 @@ def add_monitored_topic(
|
128 | 128 | expected_period=1.0, allowed_latency=1.0, stale_time=1.0):
|
129 | 129 | # Create a subscription to the topic
|
130 | 130 | monitored_topic = MonitoredTopic(topic_name, stale_time, lock=self.monitored_topics_lock)
|
131 |
| - monitored_topic.topic_name = topic_name |
132 | 131 | node_logger = node.get_logger()
|
133 | 132 | node_logger.info('Subscribing to topic: %s' % topic_name)
|
134 | 133 | sub = node.create_subscription(
|
@@ -210,9 +209,6 @@ def check_status(self):
|
210 | 209 | return status_changed
|
211 | 210 |
|
212 | 211 | def calculate_statistics(self):
|
213 |
| - self.calculate_reception_rates() |
214 |
| - |
215 |
| - def calculate_reception_rates(self): |
216 | 212 | with self.monitored_topics_lock:
|
217 | 213 | for topic_id, monitored_topic in self.monitored_topics.items():
|
218 | 214 | rate = monitored_topic.current_reception_rate(self.window_size)
|
@@ -247,7 +243,7 @@ def make_plot(self):
|
247 | 243 | plt.title('Reception rate over time')
|
248 | 244 | plt.xlabel('Time (s)')
|
249 | 245 | plt.ylabel('Reception rate (last %i msgs)' % self.topic_monitor.get_window_size())
|
250 |
| - self.ax = self.fig.add_subplot(111) |
| 246 | + self.ax = self.fig.get_axes()[0] |
251 | 247 | self.ax.axis([0, self.x_range_s, 0, 1.1])
|
252 | 248 |
|
253 | 249 | # Shrink axis' height to make room for legend
|
@@ -344,7 +340,7 @@ def run_topic_listening(node, topic_monitor, options):
|
344 | 340 | if topic_name not in already_ignored_topics:
|
345 | 341 | node.get_logger().info(
|
346 | 342 | "Warning: ignoring topic '%s' because its message type (%s)"
|
347 |
| - 'is not suported.' |
| 343 | + 'is not supported.' |
348 | 344 | % (topic_name, type_name))
|
349 | 345 | already_ignored_topics.add(topic_name)
|
350 | 346 | continue
|
|
0 commit comments