コード例 #1
0
	def test_mixed_listeners(self):
		def listener3(value):
			self.listenerVal3 = value

		def listener4(value):
			self.listenerVal4 = value
			
			
		sample = Sample()
		metaRpm = ChannelMeta(name='RPM')
		metaEngineTemp = ChannelMeta(name='EngineTemp')
		sample.channel_metas = [metaRpm, metaEngineTemp]
		sample.samples = [SampleValue(1111, metaRpm)]
			
		dataBus = DataBus()
		dataBus.addChannelListener('RPM', listener3)
		dataBus.addChannelListener('EngineTemp', listener4)
		dataBus.update_samples(sample)
		dataBus.notify_listeners(None)
		#ensure we don't set the wrong listener
		self.assertEqual(self.listenerVal3, 1111)
		self.assertEqual(self.listenerVal4, None)
		
		sample.samples = [SampleValue(1111, metaRpm), SampleValue(199, metaEngineTemp)]
		
		dataBus.update_samples(sample)
		dataBus.notify_listeners(None)
		#ensure we don't affect unrelated channels
		self.assertEqual(self.listenerVal3, 1111)
		self.assertEqual(self.listenerVal4, 199)
コード例 #2
0
	def test_no_listener(self):

		sample = Sample()
		meta = ChannelMeta(name='EngineTemp')
		sample.channel_metas = [meta]
		sample.samples = [SampleValue(200, meta)]
		
		dataBus = DataBus()
		dataBus.update_samples(sample)
		dataBus.notify_listeners(None)
コード例 #3
0
	def test_update_value(self):
		dataBus = DataBus()

		sample = Sample()
		
		meta = ChannelMeta(name='RPM')
		sample.channel_metas = [meta]
		sample.samples = [SampleValue(1234, meta)]
		
		dataBus.update_samples(sample)
		dataBus.notify_listeners(None)
		
		value = dataBus.getData('RPM')
		self.assertEqual(value, 1234)
コード例 #4
0
    def test_listener(self):
        def listener(value):
            self.listenerVal0 = value

        sample = Sample()

        meta = ChannelMeta(name='RPM')
        sample.channel_metas = [meta]
        sample.samples = [SampleValue(1111, meta)]

        dataBus = DataBus()
        dataBus.addChannelListener('RPM', listener)
        dataBus.update_samples(sample)
        dataBus.notify_listeners(None)
        self.assertEqual(self.listenerVal0, 1111)
コード例 #5
0
	def test_listener(self):
		
		def listener(value):
			self.listenerVal0 = value

		sample = Sample()
		
		meta = ChannelMeta(name='RPM')
		sample.channel_metas = [meta]
		sample.samples = [SampleValue(1111, meta)]


		dataBus = DataBus()
		dataBus.addChannelListener('RPM', listener)
		dataBus.update_samples(sample)
		dataBus.notify_listeners(None)
		self.assertEqual(self.listenerVal0, 1111)