Commits

German Larrain  committed f74fde9

robot.sensors: added 'MultipleSignalsSensor' based in 'SingleSignalSensor's code.

  • Participants
  • Parent commits 95329a7
  • Branches dev-sensors

Comments (0)

Files changed (1)

File ars/model/robot/sensors.py

 			sender=self._sender)
 
 
+class MultipleSignalsSensor(BaseSignalSensor):
+
+	"""Abstract base class for sensors subscribed to multiple signals."""
+
+	__metaclass__ = ABCMeta
+
+	@abstractmethod
+	def __init__(self, signals, *args, **kwargs):
+		"""Constructor.
+
+		:param signals: signals to subscribe to
+		:type signals: iterable
+
+		"""
+		super(MultipleSignalsSensor, self).__init__(*args, **kwargs)
+		self._signals = signals
+
+		# subscribe :meth:`on_send` handler to the signals in :attr:`_signals`
+		# sent by ``sender``
+		for signal in self._signals:
+			dispatcher.connect(self.on_send, signal=signal,
+				sender=self._sender)
+
+
 class BodySensor(Sensor):
 
 	"""Abstract base class for sensors whose source of data is a body."""